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 .
20 #include <com/sun/star/xml/sax/SAXParseException.hpp>
21 #include <com/sun/star/xml/sax/SAXException.hpp>
22 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
23 #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 #include <xmloff/nmspmap.hxx>
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/xmlnmspe.hxx>
28 #include "TransformerBase.hxx"
29 #include "MutableAttrList.hxx"
30 #include "MetaTContext.hxx"
32 using namespace ::xmloff::token
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star::xml::sax
;
36 XMLTokenEnum aMetaTokens
[] =
52 XML_HYPERLINK_BEHAVIOUR
,
56 XML_DOCUMENT_STATISTIC
,
60 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase
& rImp
,
61 const OUString
& rQName
) :
62 XMLTransformerContext( rImp
, rQName
)
66 XMLMetaTransformerContext::~XMLMetaTransformerContext()
70 rtl::Reference
<XMLTransformerContext
> XMLMetaTransformerContext::CreateChildContext(
71 sal_uInt16
/*nPrefix*/,
72 const OUString
& rLocalName
,
73 const OUString
& rQName
,
74 const Reference
< XAttributeList
>& )
76 rtl::Reference
<XMLPersTextContentTContext
> pContext(
77 new XMLPersTextContentTContext( GetTransformer(), rQName
));
78 XMLMetaContexts_Impl::value_type
aVal( rLocalName
, pContext
);
79 m_aContexts
.insert( aVal
);
81 return pContext
.get();
84 void XMLMetaTransformerContext::EndElement()
86 // export everything in the correct order
87 OUString aKeywordsQName
;
88 XMLTokenEnum
*pToken
= aMetaTokens
;
89 while( *pToken
!= XML_TOKEN_END
)
91 const OUString
& rToken
= GetXMLToken( *pToken
);
92 XMLMetaContexts_Impl::const_iterator aIter
=
93 m_aContexts
.find( rToken
);
94 if( aIter
!= m_aContexts
.end() )
96 if( XML_KEYWORD
== *pToken
)
99 GetTransformer().GetNamespaceMap().GetQNameByKey(
100 XML_NAMESPACE_META
, GetXMLToken(XML_KEYWORDS
) );
102 Reference
< XAttributeList
> xAttrList
=
103 new XMLMutableAttributeList
;
104 GetTransformer().GetDocHandler()->startElement( aKeywordsQName
,
108 // All elements may occur multiple times
109 XMLMetaContexts_Impl::const_iterator aEndIter
=
110 m_aContexts
.upper_bound( rToken
);
111 while( aIter
!= aEndIter
)
113 (*aIter
).second
->Export();
117 if( XML_KEYWORD
== *pToken
)
118 GetTransformer().GetDocHandler()->endElement( aKeywordsQName
);
123 GetTransformer().GetDocHandler()->endElement( GetQName() );
126 void XMLMetaTransformerContext::Characters( const OUString
& )
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */