Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "txTextHandler.h"
7 : #include "nsAString.h"
8 :
9 0 : txTextHandler::txTextHandler(bool aOnlyText) : mLevel(0),
10 0 : mOnlyText(aOnlyText)
11 : {
12 0 : }
13 :
14 : nsresult
15 0 : txTextHandler::attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,
16 : nsIAtom* aLowercaseLocalName, int32_t aNsID,
17 : const nsString& aValue)
18 : {
19 0 : return NS_OK;
20 : }
21 :
22 : nsresult
23 0 : txTextHandler::attribute(nsIAtom* aPrefix, const nsAString& aLocalName,
24 : const int32_t aNsID,
25 : const nsString& aValue)
26 : {
27 0 : return NS_OK;
28 : }
29 :
30 : nsresult
31 0 : txTextHandler::characters(const nsAString& aData, bool aDOE)
32 : {
33 0 : if (mLevel == 0)
34 0 : mValue.Append(aData);
35 :
36 0 : return NS_OK;
37 : }
38 :
39 : nsresult
40 0 : txTextHandler::comment(const nsString& aData)
41 : {
42 0 : return NS_OK;
43 : }
44 :
45 : nsresult
46 0 : txTextHandler::endDocument(nsresult aResult)
47 : {
48 0 : return NS_OK;
49 : }
50 :
51 : nsresult
52 0 : txTextHandler::endElement()
53 : {
54 0 : if (mOnlyText)
55 0 : --mLevel;
56 :
57 0 : return NS_OK;
58 : }
59 :
60 : nsresult
61 0 : txTextHandler::processingInstruction(const nsString& aTarget, const nsString& aData)
62 : {
63 0 : return NS_OK;
64 : }
65 :
66 : nsresult
67 0 : txTextHandler::startDocument()
68 : {
69 0 : return NS_OK;
70 : }
71 :
72 : nsresult
73 0 : txTextHandler::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
74 : nsIAtom* aLowercaseLocalName, const int32_t aNsID)
75 : {
76 0 : if (mOnlyText)
77 0 : ++mLevel;
78 :
79 0 : return NS_OK;
80 : }
81 :
82 : nsresult
83 0 : txTextHandler::startElement(nsIAtom* aPrefix, const nsAString& aLocalName,
84 : const int32_t aNsID)
85 : {
86 0 : if (mOnlyText)
87 0 : ++mLevel;
88 :
89 0 : return NS_OK;
90 : }
|