1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is TransforMiiX XSLT processor code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 2001
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Peter Van der Beken <peterv@propagandism.org>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "txTextHandler.h"
40 : #include "nsAString.h"
41 :
42 0 : txTextHandler::txTextHandler(bool aOnlyText) : mLevel(0),
43 0 : mOnlyText(aOnlyText)
44 : {
45 0 : }
46 :
47 : nsresult
48 0 : txTextHandler::attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,
49 : nsIAtom* aLowercaseLocalName, PRInt32 aNsID,
50 : const nsString& aValue)
51 : {
52 0 : return NS_OK;
53 : }
54 :
55 : nsresult
56 0 : txTextHandler::attribute(nsIAtom* aPrefix, const nsSubstring& aLocalName,
57 : const PRInt32 aNsID,
58 : const nsString& aValue)
59 : {
60 0 : return NS_OK;
61 : }
62 :
63 : nsresult
64 0 : txTextHandler::characters(const nsSubstring& aData, bool aDOE)
65 : {
66 0 : if (mLevel == 0)
67 0 : mValue.Append(aData);
68 :
69 0 : return NS_OK;
70 : }
71 :
72 : nsresult
73 0 : txTextHandler::comment(const nsString& aData)
74 : {
75 0 : return NS_OK;
76 : }
77 :
78 : nsresult
79 0 : txTextHandler::endDocument(nsresult aResult)
80 : {
81 0 : return NS_OK;
82 : }
83 :
84 : nsresult
85 0 : txTextHandler::endElement()
86 : {
87 0 : if (mOnlyText)
88 0 : --mLevel;
89 :
90 0 : return NS_OK;
91 : }
92 :
93 : nsresult
94 0 : txTextHandler::processingInstruction(const nsString& aTarget, const nsString& aData)
95 : {
96 0 : return NS_OK;
97 : }
98 :
99 : nsresult
100 0 : txTextHandler::startDocument()
101 : {
102 0 : return NS_OK;
103 : }
104 :
105 : nsresult
106 0 : txTextHandler::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
107 : nsIAtom* aLowercaseLocalName, const PRInt32 aNsID)
108 : {
109 0 : if (mOnlyText)
110 0 : ++mLevel;
111 :
112 0 : return NS_OK;
113 : }
114 :
115 : nsresult
116 0 : txTextHandler::startElement(nsIAtom* aPrefix, const nsSubstring& aLocalName,
117 : const PRInt32 aNsID)
118 : {
119 0 : if (mOnlyText)
120 0 : ++mLevel;
121 :
122 0 : return NS_OK;
123 : }
|