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