merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / xml / xmlconti.cxx
blobf03659c62ca19c5fb4b42f9def8fabdaa9e4b308
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlconti.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "xmlconti.hxx"
39 #include "xmlimprt.hxx"
40 #include "global.hxx"
41 #include "document.hxx"
43 #include <xmloff/xmltkmap.hxx>
44 #include <xmloff/nmspmap.hxx>
45 #include <xmloff/xmlnmspe.hxx>
46 #include <xmloff/xmltoken.hxx>
48 using namespace xmloff::token;
50 //------------------------------------------------------------------
52 ScXMLContentContext::ScXMLContentContext( ScXMLImport& rImport,
53 USHORT nPrfx,
54 const ::rtl::OUString& rLName,
55 const ::com::sun::star::uno::Reference<
56 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */,
57 rtl::OUStringBuffer& sTempValue) :
58 SvXMLImportContext( rImport, nPrfx, rLName ),
59 sOUText(),
60 sValue(sTempValue)
64 ScXMLContentContext::~ScXMLContentContext()
68 SvXMLImportContext *ScXMLContentContext::CreateChildContext( USHORT nPrefix,
69 const ::rtl::OUString& rLName,
70 const ::com::sun::star::uno::Reference<
71 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
73 SvXMLImportContext *pContext = 0;
75 if ((nPrefix == XML_NAMESPACE_TEXT) && IsXMLToken(rLName, XML_S))
77 sal_Int32 nRepeat(0);
78 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
79 for( sal_Int16 i=0; i < nAttrCount; ++i )
81 const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
82 const rtl::OUString& sAttrValue(xAttrList->getValueByIndex( i ));
83 rtl::OUString aLocalName;
84 USHORT nPrfx = GetScImport().GetNamespaceMap().GetKeyByAttrName(
85 sAttrName, &aLocalName );
86 if ((nPrfx == XML_NAMESPACE_TEXT) && IsXMLToken(aLocalName, XML_C))
87 nRepeat = sAttrValue.toInt32();
89 if (nRepeat)
90 for (sal_Int32 j = 0; j < nRepeat; ++j)
91 sOUText.append(static_cast<sal_Unicode>(' '));
92 else
93 sOUText.append(static_cast<sal_Unicode>(' '));
96 if( !pContext )
97 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
99 return pContext;
102 void ScXMLContentContext::Characters( const ::rtl::OUString& rChars )
104 sOUText.append(rChars);
107 void ScXMLContentContext::EndElement()
109 sValue.append(sOUText);