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
24#include <xmloff/xmltoken.hxx>
25#include <xmloff/xmlimp.hxx>
26#include <xmloff/xmlictxt.hxx>
27#include <sal/log.hxx>
28
29using ::com::sun::star::uno::Sequence;
30using ::com::sun::star::uno::Reference;
31using namespace com::sun::star;
32using namespace ::xmloff::token;
33
34namespace {
35
36class SchXMLListItemContext : public SvXMLImportContext
37{
38public:
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
45private:
46 OUString& m_rText;
47};
48
49}
50
51SchXMLListItemContext::SchXMLListItemContext(
52 SvXMLImport& rImport
53 , OUString& rText )
54 : SvXMLImportContext( rImport )
55 , m_rText( rText )
56{
57}
58
59css::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{
78}
79
81{
82}
83
85{
86 sal_Int32 nCount = m_aTextVector.size();
87 m_rTextList.realloc(nCount);
88 auto pTextList = m_rTextList.getArray();
89 for( sal_Int32 nN=0; nN<nCount; nN++ )
90 pTextList[nN]=m_aTextVector[nN];
91}
92
93css::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: */
css::uno::Sequence< OUString > & m_rTextList
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 ...
std::vector< OUString > m_aTextVector
virtual ~SchXMLTextListContext() override
SchXMLTextListContext(SvXMLImport &rImport, css::uno::Sequence< OUString > &rTextList)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:59
int nCount
Handling of tokens in XML:
TEXT
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97