1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "SchXMLTextListContext.hxx"
21 #include "SchXMLParagraphContext.hxx"
23 #include <xmloff/xmlnmspe.hxx>
24 #include <xmloff/xmltoken.hxx>
26 using ::com::sun::star::uno::Sequence
;
27 using ::com::sun::star::uno::Reference
;
28 using namespace com::sun::star
;
29 using namespace ::xmloff::token
;
31 class SchXMLListItemContext
: public SvXMLImportContext
34 SchXMLListItemContext( SvXMLImport
& rImport
, const OUString
& rLocalName
, OUString
& rText
);
36 virtual void StartElement( const Reference
< xml::sax::XAttributeList
>& xAttrList
) override
;
37 virtual void EndElement() override
;
39 virtual SvXMLImportContextRef
CreateChildContext(
41 const OUString
& rLocalName
,
42 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
48 SchXMLListItemContext::SchXMLListItemContext(
50 , const OUString
& rLocalName
52 : SvXMLImportContext( rImport
, XML_NAMESPACE_TEXT
, rLocalName
)
57 void SchXMLListItemContext::StartElement( const Reference
< xml::sax::XAttributeList
>& /*xAttrList*/ )
61 void SchXMLListItemContext::EndElement()
65 SvXMLImportContextRef
SchXMLListItemContext::CreateChildContext(
66 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
67 const uno::Reference
< xml::sax::XAttributeList
>& )
69 SvXMLImportContext
* pContext
= nullptr;
70 if( (nPrefix
== XML_NAMESPACE_TEXT
||
71 nPrefix
== XML_NAMESPACE_LO_EXT
) && IsXMLToken( rLocalName
, XML_P
) )
72 pContext
= new SchXMLParagraphContext( GetImport(), rLocalName
, m_rText
);
74 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
78 SchXMLTextListContext::SchXMLTextListContext(
80 , const OUString
& rLocalName
81 , Sequence
< OUString
>& rTextList
)
82 : SvXMLImportContext( rImport
, XML_NAMESPACE_TEXT
, rLocalName
)
83 , m_rTextList( rTextList
)
88 SchXMLTextListContext::~SchXMLTextListContext()
92 void SchXMLTextListContext::StartElement( const Reference
< xml::sax::XAttributeList
>& /*xAttrList*/ )
96 void SchXMLTextListContext::EndElement()
98 sal_Int32 nCount
= m_aTextVector
.size();
99 m_rTextList
.realloc(nCount
);
100 for( sal_Int32 nN
=0; nN
<nCount
; nN
++ )
101 m_rTextList
[nN
]=m_aTextVector
[nN
];
104 SvXMLImportContextRef
SchXMLTextListContext::CreateChildContext(
105 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
106 const uno::Reference
< xml::sax::XAttributeList
>& )
108 SvXMLImportContext
* pContext
= nullptr;
109 if( nPrefix
== XML_NAMESPACE_TEXT
&& IsXMLToken( rLocalName
, XML_LIST_ITEM
) )
111 m_aTextVector
.emplace_back( );
112 pContext
= new SchXMLListItemContext( GetImport(), rLocalName
, m_aTextVector
.back() );
115 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */