1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MetaTContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <com/sun/star/xml/sax/SAXParseException.hpp>
34 #include <com/sun/star/xml/sax/SAXException.hpp>
35 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
36 #include <com/sun/star/xml/sax/XAttributeList.hpp>
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include "xmlnmspe.hxx"
41 #ifndef _XMLOFF_TRANSFOERMERBASE_HXX
42 #include "TransformerBase.hxx"
44 #include "MutableAttrList.hxx"
45 #include "MetaTContext.hxx"
47 using ::rtl::OUString
;
48 using namespace ::xmloff::token
;
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::xml::sax
;
52 XMLTokenEnum aMetaTokens
[] =
68 XML_HYPERLINK_BEHAVIOUR
,
72 XML_DOCUMENT_STATISTIC
,
76 TYPEINIT1( XMLMetaTransformerContext
, XMLTransformerContext
);
78 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase
& rImp
,
79 const OUString
& rQName
) :
80 XMLTransformerContext( rImp
, rQName
)
84 XMLMetaTransformerContext::~XMLMetaTransformerContext()
88 XMLTransformerContext
*XMLMetaTransformerContext::CreateChildContext(
89 sal_uInt16
/*nPrefix*/,
90 const OUString
& rLocalName
,
91 const OUString
& rQName
,
92 const Reference
< XAttributeList
>& )
94 XMLPersTextContentTContext
*pContext
=
95 new XMLPersTextContentTContext( GetTransformer(), rQName
);
96 XMLMetaContexts_Impl::value_type
aVal( rLocalName
, pContext
);
97 m_aContexts
.insert( aVal
);
102 void XMLMetaTransformerContext::EndElement()
104 // export everything in the correct order
105 OUString aKeywordsQName
;
106 XMLTokenEnum
*pToken
= aMetaTokens
;
107 while( *pToken
!= XML_TOKEN_END
)
109 const OUString
& rToken
= GetXMLToken( *pToken
);
110 XMLMetaContexts_Impl::const_iterator aIter
=
111 m_aContexts
.find( rToken
);
112 if( aIter
!= m_aContexts
.end() )
114 if( XML_KEYWORD
== *pToken
)
117 GetTransformer().GetNamespaceMap().GetQNameByKey(
118 XML_NAMESPACE_META
, GetXMLToken(XML_KEYWORDS
) );
120 Reference
< XAttributeList
> xAttrList
=
121 new XMLMutableAttributeList
;
122 GetTransformer().GetDocHandler()->startElement( aKeywordsQName
,
126 // All elements may occur multiple times
127 XMLMetaContexts_Impl::const_iterator aEndIter
=
128 m_aContexts
.upper_bound( rToken
);
129 while( aIter
!= aEndIter
)
131 (*aIter
).second
->Export();
135 if( XML_KEYWORD
== *pToken
)
136 GetTransformer().GetDocHandler()->endElement( aKeywordsQName
);
141 GetTransformer().GetDocHandler()->endElement( GetQName() );
144 void XMLMetaTransformerContext::Characters( const OUString
& )