Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / xmloff / source / chart / SchXMLParagraphContext.cxx
blobba8a254266f04bd61f9bb6f8ad735fddb4afe7a4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "SchXMLImport.hxx"
22 #include "SchXMLParagraphContext.hxx"
24 #include <xmloff/xmlnmspe.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/nmspmap.hxx>
28 using namespace com::sun::star;
29 using namespace ::xmloff::token;
31 SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport,
32 const OUString& rLocalName,
33 OUString& rText,
34 OUString * pOutId /* = 0 */ ) :
35 SvXMLImportContext( rImport, XML_NAMESPACE_TEXT, rLocalName ),
36 mrText( rText ),
37 mpId( pOutId )
41 SchXMLParagraphContext::~SchXMLParagraphContext()
44 void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
46 // remember the id. It is used for storing the original cell range string in
47 // a local table (cached data)
48 if( mpId )
50 sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
51 bool bHaveXmlId( false );
53 for( sal_Int16 i = 0; i < nAttrCount; i++ )
55 OUString sAttrName = xAttrList->getNameByIndex( i );
56 OUString aLocalName;
57 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
59 if (IsXMLToken(aLocalName, XML_ID))
61 if (nPrefix == XML_NAMESPACE_XML)
63 (*mpId) = xAttrList->getValueByIndex( i );
64 bHaveXmlId = true;
66 if (nPrefix == XML_NAMESPACE_TEXT)
67 { // text:id shall be ignored if xml:id exists
68 if (!bHaveXmlId)
70 (*mpId) = xAttrList->getValueByIndex( i );
78 void SchXMLParagraphContext::EndElement()
80 mrText = maBuffer.makeStringAndClear();
83 SvXMLImportContext* SchXMLParagraphContext::CreateChildContext(
84 sal_uInt16 nPrefix,
85 const OUString& rLocalName,
86 const uno::Reference< xml::sax::XAttributeList >& )
88 if( nPrefix == XML_NAMESPACE_TEXT )
90 if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP )))
92 maBuffer.append( sal_Unicode( 0x0009 )); // tabulator
94 else if( rLocalName.equals( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK )))
96 maBuffer.append( sal_Unicode( 0x000A )); // linefeed
100 return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
103 void SchXMLParagraphContext::Characters( const OUString& rChars )
105 maBuffer.append( rChars );
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */