merge the formfield patch from ooo-build
[ooovba.git] / xmloff / source / transform / MetaTContext.cxx
blob20f591a192213022863882c8bf72193d1070684a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MetaTContext.cxx,v $
10 * $Revision: 1.8 $
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"
43 #endif
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[] =
54 XML_GENERATOR,
55 XML_TITLE,
56 XML_DESCRIPTION,
57 XML_SUBJECT,
58 XML_INITIAL_CREATOR,
59 XML_CREATION_DATE,
60 XML_CREATOR,
61 XML_DATE,
62 XML_PRINTED_BY,
63 XML_PRINT_DATE,
64 XML_KEYWORD,
65 XML_LANGUAGE,
66 XML_EDITING_CYCLES,
67 XML_EDITING_DURATION,
68 XML_HYPERLINK_BEHAVIOUR,
69 XML_AUTO_RELOAD,
70 XML_TEMPLATE,
71 XML_USER_DEFINED,
72 XML_DOCUMENT_STATISTIC,
73 XML_TOKEN_END
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 );
99 return pContext;
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 )
116 aKeywordsQName =
117 GetTransformer().GetNamespaceMap().GetQNameByKey(
118 XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) );
120 Reference< XAttributeList > xAttrList =
121 new XMLMutableAttributeList;
122 GetTransformer().GetDocHandler()->startElement( aKeywordsQName,
123 xAttrList );
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();
132 ++aIter;
135 if( XML_KEYWORD == *pToken )
136 GetTransformer().GetDocHandler()->endElement( aKeywordsQName );
138 pToken++;
141 GetTransformer().GetDocHandler()->endElement( GetQName() );
144 void XMLMetaTransformerContext::Characters( const OUString& )
146 // ignore them