Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "xmlconti.hxx"
30 : : #include "xmlimprt.hxx"
31 : : #include "global.hxx"
32 : : #include "document.hxx"
33 : :
34 : : #include <xmloff/xmltkmap.hxx>
35 : : #include <xmloff/nmspmap.hxx>
36 : : #include <xmloff/xmlnmspe.hxx>
37 : : #include <xmloff/xmltoken.hxx>
38 : :
39 : : using namespace xmloff::token;
40 : :
41 : : //------------------------------------------------------------------
42 : :
43 : 14 : ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
44 : : sal_uInt16 nPrfx,
45 : : const ::rtl::OUString& rLName,
46 : : const ::com::sun::star::uno::Reference<
47 : : ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
48 : : rtl::OUStringBuffer& sTempValue) :
49 : : SvXMLImportContext( rImport, nPrfx, rLName ),
50 : : sOUText(),
51 : 14 : sValue(sTempValue)
52 : : {
53 : 14 : }
54 : :
55 : 14 : ScXMLContentContext::~ScXMLContentContext()
56 : : {
57 [ - + ]: 28 : }
58 : :
59 : 0 : SvXMLImportContext *ScXMLContentContext::CreateChildContext( sal_uInt16 nPrefix,
60 : : const ::rtl::OUString& rLName,
61 : : const ::com::sun::star::uno::Reference<
62 : : ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
63 : : {
64 : 0 : SvXMLImportContext *pContext = 0;
65 : :
66 [ # # ][ # # ]: 0 : if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S))
[ # # ]
67 : : {
68 : 0 : sal_Int32 nRepeat(0);
69 [ # # ]: 0 : sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
70 [ # # ]: 0 : for( sal_Int16 i=0; i < nAttrCount; ++i )
71 : : {
72 [ # # ][ # # ]: 0 : const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
73 [ # # ][ # # ]: 0 : const rtl::OUString& sAttrValue(xAttrList->getValueByIndex( i ));
74 : 0 : rtl::OUString aLocalName;
75 : 0 : sal_uInt16 nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName(
76 [ # # ]: 0 : sAttrName, &aLocalName );
77 [ # # ][ # # ]: 0 : if ((nPrfx == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C))
[ # # ][ # # ]
78 : 0 : nRepeat = sAttrValue.toInt32();
79 : 0 : }
80 [ # # ]: 0 : if (nRepeat)
81 [ # # ]: 0 : for (sal_Int32 j = 0; j < nRepeat; ++j)
82 : 0 : sOUText.append(static_cast<sal_Unicode>(' '));
83 : : else
84 : 0 : sOUText.append(static_cast<sal_Unicode>(' '));
85 : : }
86 : :
87 [ # # ]: 0 : if( !pContext )
88 [ # # ]: 0 : pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
89 : :
90 : 0 : return pContext;
91 : : }
92 : :
93 : 14 : void ScXMLContentContext::Characters( const ::rtl::OUString& rChars )
94 : : {
95 : 14 : sOUText.append(rChars);
96 : 14 : }
97 : :
98 : 14 : void ScXMLContentContext::EndElement()
99 : : {
100 [ + - ]: 14 : sValue.append(sOUText.toString());
101 : 14 : }
102 : :
103 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|