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/XDocumentHandler.hpp>
21 #include <xmloff/namespacemap.hxx>
22 #include <xmloff/xmltoken.hxx>
23 #include <xmloff/xmlnamespace.hxx>
25 #include "TransformerBase.hxx"
26 #include "MutableAttrList.hxx"
27 #include "MetaTContext.hxx"
29 using namespace ::xmloff::token
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star::xml::sax
;
33 XMLTokenEnum
const aMetaTokens
[] =
49 XML_HYPERLINK_BEHAVIOUR
,
53 XML_DOCUMENT_STATISTIC
,
57 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase
& rImp
,
58 const OUString
& rQName
) :
59 XMLTransformerContext( rImp
, rQName
)
63 XMLMetaTransformerContext::~XMLMetaTransformerContext()
67 rtl::Reference
<XMLTransformerContext
> XMLMetaTransformerContext::CreateChildContext(
68 sal_uInt16
/*nPrefix*/,
69 const OUString
& rLocalName
,
70 const OUString
& rQName
,
71 const Reference
< XAttributeList
>& )
73 rtl::Reference
<XMLPersTextContentTContext
> pContext(
74 new XMLPersTextContentTContext( GetTransformer(), rQName
));
75 XMLMetaContexts_Impl::value_type
aVal( rLocalName
, pContext
);
76 m_aContexts
.insert( aVal
);
81 void XMLMetaTransformerContext::EndElement()
83 // export everything in the correct order
84 OUString aKeywordsQName
;
85 XMLTokenEnum
const *pToken
= aMetaTokens
;
86 while( *pToken
!= XML_TOKEN_END
)
88 const OUString
& rToken
= GetXMLToken( *pToken
);
89 XMLMetaContexts_Impl::const_iterator aIter
=
90 m_aContexts
.find( rToken
);
91 if( aIter
!= m_aContexts
.end() )
93 if( XML_KEYWORD
== *pToken
)
96 GetTransformer().GetNamespaceMap().GetQNameByKey(
97 XML_NAMESPACE_META
, GetXMLToken(XML_KEYWORDS
) );
99 Reference
< XAttributeList
> xAttrList
=
100 new XMLMutableAttributeList
;
101 GetTransformer().GetDocHandler()->startElement( aKeywordsQName
,
105 // All elements may occur multiple times
106 XMLMetaContexts_Impl::const_iterator aEndIter
=
107 m_aContexts
.upper_bound( rToken
);
108 while( aIter
!= aEndIter
)
110 (*aIter
).second
->Export();
114 if( XML_KEYWORD
== *pToken
)
115 GetTransformer().GetDocHandler()->endElement( aKeywordsQName
);
120 GetTransformer().GetDocHandler()->endElement( GetQName() );
123 void XMLMetaTransformerContext::Characters( const OUString
& )
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */