nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / transform / MetaTContext.cxx
blobd37934eccf78a45941a1f8d794c2a80e1034aef7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/SAXException.hpp>
21 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
22 #include <com/sun/star/xml/sax/XAttributeList.hpp>
23 #include <xmloff/namespacemap.hxx>
24 #include <xmloff/xmltoken.hxx>
25 #include <xmloff/xmlnamespace.hxx>
27 #include "TransformerBase.hxx"
28 #include "MutableAttrList.hxx"
29 #include "MetaTContext.hxx"
31 using namespace ::xmloff::token;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
35 XMLTokenEnum const aMetaTokens[] =
37 XML_GENERATOR,
38 XML_TITLE,
39 XML_DESCRIPTION,
40 XML_SUBJECT,
41 XML_INITIAL_CREATOR,
42 XML_CREATION_DATE,
43 XML_CREATOR,
44 XML_DATE,
45 XML_PRINTED_BY,
46 XML_PRINT_DATE,
47 XML_KEYWORD,
48 XML_LANGUAGE,
49 XML_EDITING_CYCLES,
50 XML_EDITING_DURATION,
51 XML_HYPERLINK_BEHAVIOUR,
52 XML_AUTO_RELOAD,
53 XML_TEMPLATE,
54 XML_USER_DEFINED,
55 XML_DOCUMENT_STATISTIC,
56 XML_TOKEN_END
59 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase& rImp,
60 const OUString& rQName ) :
61 XMLTransformerContext( rImp, rQName )
65 XMLMetaTransformerContext::~XMLMetaTransformerContext()
69 rtl::Reference<XMLTransformerContext> XMLMetaTransformerContext::CreateChildContext(
70 sal_uInt16 /*nPrefix*/,
71 const OUString& rLocalName,
72 const OUString& rQName,
73 const Reference< XAttributeList >& )
75 rtl::Reference<XMLPersTextContentTContext> pContext(
76 new XMLPersTextContentTContext( GetTransformer(), rQName ));
77 XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext );
78 m_aContexts.insert( aVal );
80 return pContext.get();
83 void XMLMetaTransformerContext::EndElement()
85 // export everything in the correct order
86 OUString aKeywordsQName;
87 XMLTokenEnum const *pToken = aMetaTokens;
88 while( *pToken != XML_TOKEN_END )
90 const OUString& rToken = GetXMLToken( *pToken );
91 XMLMetaContexts_Impl::const_iterator aIter =
92 m_aContexts.find( rToken );
93 if( aIter != m_aContexts.end() )
95 if( XML_KEYWORD == *pToken )
97 aKeywordsQName =
98 GetTransformer().GetNamespaceMap().GetQNameByKey(
99 XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) );
101 Reference< XAttributeList > xAttrList =
102 new XMLMutableAttributeList;
103 GetTransformer().GetDocHandler()->startElement( aKeywordsQName,
104 xAttrList );
107 // All elements may occur multiple times
108 XMLMetaContexts_Impl::const_iterator aEndIter =
109 m_aContexts.upper_bound( rToken );
110 while( aIter != aEndIter )
112 (*aIter).second->Export();
113 ++aIter;
116 if( XML_KEYWORD == *pToken )
117 GetTransformer().GetDocHandler()->endElement( aKeywordsQName );
119 pToken++;
122 GetTransformer().GetDocHandler()->endElement( GetQName() );
125 void XMLMetaTransformerContext::Characters( const OUString& )
127 // ignore them
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */