LibreOffice Module xmloff (master)  1
SchXMLTextListContext.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 
22 
23 #include <xmloff/xmlnamespace.hxx>
24 #include <xmloff/xmltoken.hxx>
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/xmlictxt.hxx>
27 #include <sal/log.hxx>
28 
29 using ::com::sun::star::uno::Sequence;
30 using ::com::sun::star::uno::Reference;
31 using namespace com::sun::star;
32 using namespace ::xmloff::token;
33 
34 namespace {
35 
36 class SchXMLListItemContext : public SvXMLImportContext
37 {
38 public:
39  SchXMLListItemContext( SvXMLImport& rImport, OUString& rText );
40 
41  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
42  sal_Int32 nElement,
43  const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
44 
45 private:
46  OUString& m_rText;
47 };
48 
49 }
50 
51 SchXMLListItemContext::SchXMLListItemContext(
52  SvXMLImport& rImport
53  , OUString& rText )
54  : SvXMLImportContext( rImport )
55  , m_rText( rText )
56 {
57 }
58 
59 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLListItemContext::createFastChildContext(
60  sal_Int32 nElement,
61  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
62 {
63  SvXMLImportContext* pContext = nullptr;
64  if( nElement == XML_ELEMENT(TEXT, XML_P) ||
65  nElement == XML_ELEMENT(LO_EXT, XML_P) )
66  pContext = new SchXMLParagraphContext( GetImport(), m_rText );
67  else
68  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
69  return pContext;
70 }
71 
73  SvXMLImport& rImport
74  , Sequence< OUString>& rTextList )
75  : SvXMLImportContext( rImport )
76  , m_rTextList( rTextList )
77  , m_aTextVector()
78 {
79 }
80 
82 {
83 }
84 
86 {
87  sal_Int32 nCount = m_aTextVector.size();
88  m_rTextList.realloc(nCount);
89  for( sal_Int32 nN=0; nN<nCount; nN++ )
90  m_rTextList[nN]=m_aTextVector[nN];
91 }
92 
93 css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLTextListContext::createFastChildContext(
94  sal_Int32 nElement,
95  const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
96 {
97  SvXMLImportContext* pContext = nullptr;
98  if( nElement == XML_ELEMENT(TEXT, XML_LIST_ITEM) )
99  {
100  m_aTextVector.emplace_back( );
101  pContext = new SchXMLListItemContext( GetImport(), m_aTextVector.back() );
102  }
103  else
104  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
105  return pContext;
106 }
107 
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:56
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
int nCount
css::uno::Sequence< OUString > & m_rTextList
SchXMLTextListContext(SvXMLImport &rImport, css::uno::Sequence< OUString > &rTextList)
virtual ~SchXMLTextListContext() override
std::vector< OUString > m_aTextVector
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:96
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:116
TEXT