1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "XMLStringBufferImportContext.hxx"
27 #include <xmloff/xmltoken.hxx>
28 #include "xmloff/xmlnmspe.hxx"
29 
30 
31 using ::rtl::OUString;
32 using ::rtl::OUStringBuffer;
33 using ::com::sun::star::uno::Reference;
34 using ::com::sun::star::xml::sax::XAttributeList;
35 using ::xmloff::token::IsXMLToken;
36 using ::xmloff::token::XML_P;
37 
38 
39 TYPEINIT1(XMLStringBufferImportContext, SvXMLImportContext);
40 
XMLStringBufferImportContext(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & sLocalName,OUStringBuffer & rBuffer)41 XMLStringBufferImportContext::XMLStringBufferImportContext(
42 	SvXMLImport& rImport,
43 	sal_uInt16 nPrefix,
44 	const OUString& sLocalName,
45 	OUStringBuffer& rBuffer) :
46 	SvXMLImportContext(rImport, nPrefix, sLocalName),
47 	rTextBuffer(rBuffer)
48 {
49 }
50 
~XMLStringBufferImportContext()51 XMLStringBufferImportContext::~XMLStringBufferImportContext()
52 {
53 }
54 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> &)55 SvXMLImportContext *XMLStringBufferImportContext::CreateChildContext(
56 	sal_uInt16 nPrefix,
57 	const OUString& rLocalName,
58 	const Reference<XAttributeList> &)
59 {
60 	return new XMLStringBufferImportContext(GetImport(), nPrefix,
61 											rLocalName, rTextBuffer);
62 }
63 
Characters(const OUString & rChars)64 void XMLStringBufferImportContext::Characters(
65 	const OUString& rChars )
66 {
67 	rTextBuffer.append(rChars);
68 }
69 
EndElement()70 void XMLStringBufferImportContext::EndElement()
71 {
72 	// add return for paragraph elements
73 	if ( (XML_NAMESPACE_TEXT == GetPrefix()) &&
74 		 (IsXMLToken(GetLocalName(), XML_P))    )
75 	{
76 		rTextBuffer.append(sal_Unicode(0x0a));
77 	}
78 }
79 
80