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 : //------------------------------------------------------------------
33 :
34 3 : ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
35 : sal_uInt16 nPrfx,
36 : const ::rtl::OUString& rLName,
37 : const ::com::sun::star::uno::Reference<
38 : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
39 : rtl::OUStringBuffer& sTempValue) :
40 : SvXMLImportContext( rImport, nPrfx, rLName ),
41 : sOUText(),
42 3 : sValue(sTempValue)
43 : {
44 3 : }
45 :
46 6 : ScXMLContentContext::~ScXMLContentContext()
47 : {
48 6 : }
49 :
50 0 : SvXMLImportContext *ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefix,
51 : const ::rtl::OUString& rLName,
52 : const ::com::sun::star::uno::Reference<
53 : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
54 : {
55 0 : SvXMLImportContext *pContext = 0;
56 :
57 0 : if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S))
58 : {
59 0 : sal_Int32 nRepeat(0);
60 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
61 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
62 : {
63 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
64 0 : const rtl::OUString& sAttrValue(xAttrList->getValueByIndex( i ));
65 0 : rtl::OUString aLocalName;
66 0 : sal_uInt16 nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName(
67 0 : sAttrName, &aLocalName );
68 0 : if ((nPrfx == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C))
69 0 : nRepeat = sAttrValue.toInt32();
70 0 : }
71 0 : if (nRepeat)
72 0 : for (sal_Int32 j = 0; j < nRepeat; ++j)
73 0 : sOUText.append(static_cast<sal_Unicode>(' '));
74 : else
75 0 : sOUText.append(static_cast<sal_Unicode>(' '));
76 : }
77 :
78 0 : if( !pContext )
79 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
80 :
81 0 : return pContext;
82 : }
83 :
84 3 : void ScXMLContentContext::Characters( const ::rtl::OUString& rChars )
85 : {
86 3 : sOUText.append(rChars);
87 3 : }
88 :
89 3 : void ScXMLContentContext::EndElement()
90 : {
91 3 : sValue.append(sOUText.toString());
92 3 : }
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|