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_sc.hxx"
26
27
28
29 // INCLUDE ---------------------------------------------------------------
30
31 #include "xmlconti.hxx"
32 #include "xmlimprt.hxx"
33 #include "global.hxx"
34 #include "document.hxx"
35
36 #include <xmloff/xmltkmap.hxx>
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmlnmspe.hxx>
39 #include <xmloff/xmltoken.hxx>
40
41 using namespace xmloff::token;
42
43 //------------------------------------------------------------------
44
ScXMLContentContext(ScXMLImport & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> &,rtl::OUStringBuffer & sTempValue)45 ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
46 sal_uInt16 nPrfx,
47 const ::rtl::OUString& rLName,
48 const ::com::sun::star::uno::Reference<
49 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
50 rtl::OUStringBuffer& sTempValue) :
51 SvXMLImportContext( rImport, nPrfx, rLName ),
52 sOUText(),
53 sValue(sTempValue)
54 {
55 }
56
~ScXMLContentContext()57 ScXMLContentContext::~ScXMLContentContext()
58 {
59 }
60
CreateChildContext(sal_uInt16 nPrefix,const::rtl::OUString & rLName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList)61 SvXMLImportContext *ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefix,
62 const ::rtl::OUString& rLName,
63 const ::com::sun::star::uno::Reference<
64 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
65 {
66 SvXMLImportContext *pContext = 0;
67
68 if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S))
69 {
70 sal_Int32 nRepeat(0);
71 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
72 for( sal_Int16 i=0; i < nAttrCount; ++i )
73 {
74 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
75 const rtl::OUString& sAttrValue(xAttrList->getValueByIndex( i ));
76 rtl::OUString aLocalName;
77 sal_uInt16 nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName(
78 sAttrName, &aLocalName );
79 if ((nPrfx == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C))
80 nRepeat = sAttrValue.toInt32();
81 }
82 if (nRepeat)
83 for (sal_Int32 j = 0; j < nRepeat; ++j)
84 sOUText.append(static_cast<sal_Unicode>(' '));
85 else
86 sOUText.append(static_cast<sal_Unicode>(' '));
87 }
88
89 if( !pContext )
90 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
91
92 return pContext;
93 }
94
Characters(const::rtl::OUString & rChars)95 void ScXMLContentContext::Characters( const ::rtl::OUString& rChars )
96 {
97 sOUText.append(rChars);
98 }
99
EndElement()100 void ScXMLContentContext::EndElement()
101 {
102 sValue.append(sOUText);
103 }
104