LibreOffice Module xmloff (master)  1
XMLStringBufferImportContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmlnamespace.hxx>
23 
24 
25 using ::com::sun::star::uno::Reference;
26 using ::com::sun::star::xml::sax::XAttributeList;
29 
30 
32  SvXMLImport& rImport,
33  sal_uInt16 nPrefix,
34  const OUString& sLocalName,
35  OUStringBuffer& rBuffer) :
36  SvXMLImportContext(rImport, nPrefix, sLocalName),
37  rTextBuffer(rBuffer)
38 {
39 }
40 
42  SvXMLImport& rImport,
43  OUStringBuffer& rBuffer) :
44  SvXMLImportContext(rImport),
45  rTextBuffer(rBuffer)
46 {
47 }
48 
50 {
51 }
52 
53 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLStringBufferImportContext::createFastChildContext(
54  sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
55 {
57 }
58 
60  sal_uInt16 nPrefix,
61  const OUString& rLocalName,
62  const Reference<XAttributeList> &)
63 {
64  return new XMLStringBufferImportContext(GetImport(), nPrefix,
65  rLocalName, rTextBuffer);
66 }
67 
68 void XMLStringBufferImportContext::characters(const OUString& rChars )
69 {
70  rTextBuffer.append(rChars);
71 }
72 
74  const OUString& rChars )
75 {
76  rTextBuffer.append(rChars);
77 }
78 
80 {
81  // add return for paragraph elements
82  if ( nElement == XML_ELEMENT(TEXT, XML_P) || nElement == XML_ELEMENT(LO_EXT, XML_P))
83  {
84  rTextBuffer.append(u'\x000a');
85  }
86 }
87 
89  const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ )
90 {
91 }
92 
94 {
95  // add return for paragraph elements
96  if ( (XML_NAMESPACE_TEXT == GetPrefix() ||
99  {
100  rTextBuffer.append(u'\x000a');
101  }
102 }
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3434
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:62
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
virtual void Characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
virtual void EndElement() override
EndElement is called before a context will be destructed, but after an elements context has been pars...
const OUString & GetLocalName() const
Definition: xmlictxt.hxx:69
constexpr sal_uInt16 XML_NAMESPACE_TEXT
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
XMLStringBufferImportContext(SvXMLImport &rImport, sal_uInt16 nPrefix, const OUString &sLocalName, OUStringBuffer &rBuffer)
float u
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual SvXMLImportContextRef CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
Create a children element context.
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:94
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
virtual void SAL_CALL characters(const OUString &rChars) override
TEXT
sal_uInt16 GetPrefix() const
Definition: xmlictxt.hxx:68
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override