1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
,
34 OUString
* pOutId
/* = 0 */ ) :
35 SvXMLImportContext( rImport
, XML_NAMESPACE_TEXT
, rLocalName
),
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)
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
);
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
);
66 if (nPrefix
== XML_NAMESPACE_TEXT
)
67 { // text:id shall be ignored if xml:id exists
70 (*mpId
) = xAttrList
->getValueByIndex( i
);
78 void SchXMLParagraphContext::EndElement()
80 mrText
= maBuffer
.makeStringAndClear();
83 SvXMLImportContext
* SchXMLParagraphContext::CreateChildContext(
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: */