update dev300-m58
[ooovba.git] / xmloff / source / chart / SchXMLParagraphContext.cxx
blob45f29e53250ab1d640af0102b6ace1fe603e0ad3
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: SchXMLParagraphContext.cxx,v $
10 * $Revision: 1.9 $
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_xmloff.hxx"
34 #include "SchXMLImport.hxx"
35 #include "SchXMLParagraphContext.hxx"
37 #include "xmlnmspe.hxx"
38 #include <xmloff/xmltoken.hxx>
39 #include <xmloff/nmspmap.hxx>
41 using ::rtl::OUString;
42 using namespace com::sun::star;
43 using namespace ::xmloff::token;
45 SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport,
46 const OUString& rLocalName,
47 OUString& rText,
48 OUString * pOutId /* = 0 */ ) :
49 SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
50 mrText( rText ),
51 mpId( pOutId )
55 SchXMLParagraphContext::~SchXMLParagraphContext()
58 void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
60 // remember the id. It is used for storing the original cell range string in
61 // a local table (cached data)
62 if( mpId )
64 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
65 rtl::OUString aValue;
67 for( sal_Int16 i = 0; i < nAttrCount; i++ )
69 rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
70 rtl::OUString aLocalName;
71 USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
73 if( nPrefix == XML_NAMESPACE_TEXT &&
74 IsXMLToken( aLocalName, XML_ID ) )
76 (*mpId) = xAttrList->getValueByIndex( i );
77 break; // we only need this attribute
83 void SchXMLParagraphContext::EndElement()
85 mrText = maBuffer.makeStringAndClear();
88 SvXMLImportContext* SchXMLParagraphContext::CreateChildContext(
89 USHORT nPrefix,
90 const OUString& rLocalName,
91 const uno::Reference< xml::sax::XAttributeList >& )
93 if( nPrefix == XML_NAMESPACE_TEXT )
95 if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP )))
97 maBuffer.append( sal_Unicode( 0x0009 )); // tabulator
99 else if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK )))
101 maBuffer.append( sal_Unicode( 0x000A )); // linefeed
105 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
108 void SchXMLParagraphContext::Characters( const OUString& rChars )
110 maBuffer.append( rChars );