1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <com/sun/star/xml/sax/SAXParseException.hpp>
30 #include <com/sun/star/xml/sax/SAXException.hpp>
31 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
32 #include <com/sun/star/xml/sax/XAttributeList.hpp>
33 #include <xmloff/nmspmap.hxx>
34 #include <xmloff/xmltoken.hxx>
35 #include "xmloff/xmlnmspe.hxx"
37 #include "TransformerBase.hxx"
38 #include "MutableAttrList.hxx"
39 #include "MetaTContext.hxx"
41 using ::rtl::OUString
;
42 using namespace ::xmloff::token
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::xml::sax
;
46 XMLTokenEnum aMetaTokens
[] =
62 XML_HYPERLINK_BEHAVIOUR
,
66 XML_DOCUMENT_STATISTIC
,
70 TYPEINIT1( XMLMetaTransformerContext
, XMLTransformerContext
);
72 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase
& rImp
,
73 const OUString
& rQName
) :
74 XMLTransformerContext( rImp
, rQName
)
78 XMLMetaTransformerContext::~XMLMetaTransformerContext()
82 XMLTransformerContext
*XMLMetaTransformerContext::CreateChildContext(
83 sal_uInt16
/*nPrefix*/,
84 const OUString
& rLocalName
,
85 const OUString
& rQName
,
86 const Reference
< XAttributeList
>& )
88 XMLPersTextContentTContext
*pContext
=
89 new XMLPersTextContentTContext( GetTransformer(), rQName
);
90 XMLMetaContexts_Impl::value_type
aVal( rLocalName
, pContext
);
91 m_aContexts
.insert( aVal
);
96 void XMLMetaTransformerContext::EndElement()
98 // export everything in the correct order
99 OUString aKeywordsQName
;
100 XMLTokenEnum
*pToken
= aMetaTokens
;
101 while( *pToken
!= XML_TOKEN_END
)
103 const OUString
& rToken
= GetXMLToken( *pToken
);
104 XMLMetaContexts_Impl::const_iterator aIter
=
105 m_aContexts
.find( rToken
);
106 if( aIter
!= m_aContexts
.end() )
108 if( XML_KEYWORD
== *pToken
)
111 GetTransformer().GetNamespaceMap().GetQNameByKey(
112 XML_NAMESPACE_META
, GetXMLToken(XML_KEYWORDS
) );
114 Reference
< XAttributeList
> xAttrList
=
115 new XMLMutableAttributeList
;
116 GetTransformer().GetDocHandler()->startElement( aKeywordsQName
,
120 // All elements may occur multiple times
121 XMLMetaContexts_Impl::const_iterator aEndIter
=
122 m_aContexts
.upper_bound( rToken
);
123 while( aIter
!= aEndIter
)
125 (*aIter
).second
->Export();
129 if( XML_KEYWORD
== *pToken
)
130 GetTransformer().GetDocHandler()->endElement( aKeywordsQName
);
135 GetTransformer().GetDocHandler()->endElement( GetQName() );
138 void XMLMetaTransformerContext::Characters( const OUString
& )
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */