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 "SchXMLParagraphContext.hxx"
23 #include <xmloff/xmlimp.hxx>
24 #include <xmloff/xmlnmspe.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/nmspmap.hxx>
28 #include <com/sun/star/xml/sax/XAttributeList.hpp>
30 using namespace com::sun::star
;
31 using namespace ::xmloff::token
;
33 SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport
& rImport
,
34 const OUString
& rLocalName
,
36 OUString
* pOutId
/* = 0 */ ) :
37 SvXMLImportContext( rImport
, XML_NAMESPACE_TEXT
, rLocalName
),
43 SchXMLParagraphContext::~SchXMLParagraphContext()
46 void SchXMLParagraphContext::StartElement( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
48 // remember the id. It is used for storing the original cell range string in
49 // a local table (cached data)
52 sal_Int16 nAttrCount
= xAttrList
.is()? xAttrList
->getLength(): 0;
53 bool bHaveXmlId( false );
55 for( sal_Int16 i
= 0; i
< nAttrCount
; i
++ )
57 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
59 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
61 if (IsXMLToken(aLocalName
, XML_ID
))
63 if (nPrefix
== XML_NAMESPACE_XML
)
65 (*mpId
) = xAttrList
->getValueByIndex( i
);
68 if (nPrefix
== XML_NAMESPACE_TEXT
)
69 { // text:id shall be ignored if xml:id exists
72 (*mpId
) = xAttrList
->getValueByIndex( i
);
80 void SchXMLParagraphContext::EndElement()
82 mrText
= maBuffer
.makeStringAndClear();
85 SvXMLImportContextRef
SchXMLParagraphContext::CreateChildContext(
87 const OUString
& rLocalName
,
88 const uno::Reference
< xml::sax::XAttributeList
>& )
90 if( nPrefix
== XML_NAMESPACE_TEXT
)
92 if( rLocalName
== ::xmloff::token::GetXMLToken( ::xmloff::token::XML_TAB_STOP
))
94 maBuffer
.append( u
'\x0009'); // tabulator
96 else if( rLocalName
== ::xmloff::token::GetXMLToken( ::xmloff::token::XML_LINE_BREAK
))
98 maBuffer
.append( u
'\x000A'); // linefeed
102 return new SvXMLImportContext( GetImport(), nPrefix
, rLocalName
);
105 void SchXMLParagraphContext::Characters( const OUString
& rChars
)
107 maBuffer
.append( rChars
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */