1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include <com/sun/star/xml/sax/SAXParseException.hpp> 31 #include <com/sun/star/xml/sax/SAXException.hpp> 32 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 33 #include <com/sun/star/xml/sax/XAttributeList.hpp> 34 #include <xmloff/nmspmap.hxx> 35 #include <xmloff/xmltoken.hxx> 36 #include "xmloff/xmlnmspe.hxx" 37 38 #ifndef _XMLOFF_TRANSFOERMERBASE_HXX 39 #include "TransformerBase.hxx" 40 #endif 41 #include "MutableAttrList.hxx" 42 #include "MetaTContext.hxx" 43 44 using ::rtl::OUString; 45 using namespace ::xmloff::token; 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::xml::sax; 48 49 XMLTokenEnum aMetaTokens[] = 50 { 51 XML_GENERATOR, 52 XML_TITLE, 53 XML_DESCRIPTION, 54 XML_SUBJECT, 55 XML_INITIAL_CREATOR, 56 XML_CREATION_DATE, 57 XML_CREATOR, 58 XML_DATE, 59 XML_PRINTED_BY, 60 XML_PRINT_DATE, 61 XML_KEYWORD, 62 XML_LANGUAGE, 63 XML_EDITING_CYCLES, 64 XML_EDITING_DURATION, 65 XML_HYPERLINK_BEHAVIOUR, 66 XML_AUTO_RELOAD, 67 XML_TEMPLATE, 68 XML_USER_DEFINED, 69 XML_DOCUMENT_STATISTIC, 70 XML_TOKEN_END 71 }; 72 73 TYPEINIT1( XMLMetaTransformerContext, XMLTransformerContext ); 74 75 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase& rImp, 76 const OUString& rQName ) : 77 XMLTransformerContext( rImp, rQName ) 78 { 79 } 80 81 XMLMetaTransformerContext::~XMLMetaTransformerContext() 82 { 83 } 84 85 XMLTransformerContext *XMLMetaTransformerContext::CreateChildContext( 86 sal_uInt16 /*nPrefix*/, 87 const OUString& rLocalName, 88 const OUString& rQName, 89 const Reference< XAttributeList >& ) 90 { 91 XMLPersTextContentTContext *pContext = 92 new XMLPersTextContentTContext( GetTransformer(), rQName ); 93 XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext ); 94 m_aContexts.insert( aVal ); 95 96 return pContext; 97 } 98 99 void XMLMetaTransformerContext::EndElement() 100 { 101 // export everything in the correct order 102 OUString aKeywordsQName; 103 XMLTokenEnum *pToken = aMetaTokens; 104 while( *pToken != XML_TOKEN_END ) 105 { 106 const OUString& rToken = GetXMLToken( *pToken ); 107 XMLMetaContexts_Impl::const_iterator aIter = 108 m_aContexts.find( rToken ); 109 if( aIter != m_aContexts.end() ) 110 { 111 if( XML_KEYWORD == *pToken ) 112 { 113 aKeywordsQName = 114 GetTransformer().GetNamespaceMap().GetQNameByKey( 115 XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) ); 116 117 Reference< XAttributeList > xAttrList = 118 new XMLMutableAttributeList; 119 GetTransformer().GetDocHandler()->startElement( aKeywordsQName, 120 xAttrList ); 121 } 122 123 // All elements may occur multiple times 124 XMLMetaContexts_Impl::const_iterator aEndIter = 125 m_aContexts.upper_bound( rToken ); 126 while( aIter != aEndIter ) 127 { 128 (*aIter).second->Export(); 129 ++aIter; 130 } 131 132 if( XML_KEYWORD == *pToken ) 133 GetTransformer().GetDocHandler()->endElement( aKeywordsQName ); 134 } 135 pToken++; 136 } 137 138 GetTransformer().GetDocHandler()->endElement( GetQName() ); 139 } 140 141 void XMLMetaTransformerContext::Characters( const OUString& ) 142 { 143 // ignore them 144 } 145 146 147