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