1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "SchXMLImport.hxx"
28cdf0e10cSrcweir #include "SchXMLTextListContext.hxx"
29cdf0e10cSrcweir #include "SchXMLParagraphContext.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
32cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
33cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir using ::rtl::OUString;
36cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
37cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
38cdf0e10cSrcweir using namespace com::sun::star;
39cdf0e10cSrcweir using namespace ::xmloff::token;
40cdf0e10cSrcweir
41cdf0e10cSrcweir //-------------------------------------------------
42cdf0e10cSrcweir class SchXMLListItemContext : public SvXMLImportContext
43cdf0e10cSrcweir {
44cdf0e10cSrcweir public:
45cdf0e10cSrcweir SchXMLListItemContext( SvXMLImport& rImport, const OUString& rLocalName, OUString& rText );
46cdf0e10cSrcweir virtual ~SchXMLListItemContext();
47cdf0e10cSrcweir virtual void StartElement( const Reference< xml::sax::XAttributeList >& xAttrList );
48cdf0e10cSrcweir virtual void EndElement();
49cdf0e10cSrcweir
50cdf0e10cSrcweir virtual SvXMLImportContext* CreateChildContext(
51cdf0e10cSrcweir sal_uInt16 nPrefix,
52cdf0e10cSrcweir const ::rtl::OUString& rLocalName,
53cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
54cdf0e10cSrcweir
55cdf0e10cSrcweir private:
56cdf0e10cSrcweir ::rtl::OUString& m_rText;
57cdf0e10cSrcweir };
58cdf0e10cSrcweir
SchXMLListItemContext(SvXMLImport & rImport,const OUString & rLocalName,OUString & rText)59cdf0e10cSrcweir SchXMLListItemContext::SchXMLListItemContext(
60cdf0e10cSrcweir SvXMLImport& rImport
61cdf0e10cSrcweir , const OUString& rLocalName
62cdf0e10cSrcweir , OUString& rText )
63cdf0e10cSrcweir : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName )
64cdf0e10cSrcweir , m_rText( rText )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
~SchXMLListItemContext()68cdf0e10cSrcweir SchXMLListItemContext::~SchXMLListItemContext()
69cdf0e10cSrcweir {}
70cdf0e10cSrcweir
StartElement(const Reference<xml::sax::XAttributeList> &)71cdf0e10cSrcweir void SchXMLListItemContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
EndElement()75cdf0e10cSrcweir void SchXMLListItemContext::EndElement()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> &)79cdf0e10cSrcweir SvXMLImportContext* SchXMLListItemContext::CreateChildContext(
80cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName,
81cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList >& )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir SvXMLImportContext* pContext = 0;
84cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_P ) )
85cdf0e10cSrcweir pContext = new SchXMLParagraphContext( GetImport(), rLocalName, m_rText );
86cdf0e10cSrcweir else
87cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
88cdf0e10cSrcweir return pContext;
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
91cdf0e10cSrcweir //-------------------------------------------------
92cdf0e10cSrcweir
SchXMLTextListContext(SvXMLImport & rImport,const OUString & rLocalName,Sequence<OUString> & rTextList)93cdf0e10cSrcweir SchXMLTextListContext::SchXMLTextListContext(
94cdf0e10cSrcweir SvXMLImport& rImport
95cdf0e10cSrcweir , const OUString& rLocalName
96cdf0e10cSrcweir , Sequence< OUString>& rTextList )
97cdf0e10cSrcweir : SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName )
98cdf0e10cSrcweir , m_rTextList( rTextList )
99cdf0e10cSrcweir , m_aTextVector()
100cdf0e10cSrcweir {
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
~SchXMLTextListContext()103cdf0e10cSrcweir SchXMLTextListContext::~SchXMLTextListContext()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
StartElement(const Reference<xml::sax::XAttributeList> &)107cdf0e10cSrcweir void SchXMLTextListContext::StartElement( const Reference< xml::sax::XAttributeList >& /*xAttrList*/ )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
EndElement()111cdf0e10cSrcweir void SchXMLTextListContext::EndElement()
112cdf0e10cSrcweir {
113cdf0e10cSrcweir sal_Int32 nCount = m_aTextVector.size();
114cdf0e10cSrcweir m_rTextList.realloc(nCount);
115cdf0e10cSrcweir for( sal_Int32 nN=0; nN<nCount; nN++ )
116cdf0e10cSrcweir m_rTextList[nN]=m_aTextVector[nN];
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const uno::Reference<xml::sax::XAttributeList> &)119cdf0e10cSrcweir SvXMLImportContext* SchXMLTextListContext::CreateChildContext(
120cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName,
121cdf0e10cSrcweir const uno::Reference< xml::sax::XAttributeList >& )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir SvXMLImportContext* pContext = 0;
124cdf0e10cSrcweir if( nPrefix == XML_NAMESPACE_TEXT && IsXMLToken( rLocalName, XML_LIST_ITEM ) )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir m_aTextVector.push_back( OUString() );
127cdf0e10cSrcweir pContext = new SchXMLListItemContext( GetImport(), rLocalName, m_aTextVector.back() );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir else
130cdf0e10cSrcweir pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
131cdf0e10cSrcweir return pContext;
132cdf0e10cSrcweir }
133