1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include <com/sun/star/xml/sax/SAXParseException.hpp>
27 #include <com/sun/star/xml/sax/SAXException.hpp>
28 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
29 #include <com/sun/star/xml/sax/XAttributeList.hpp>
30 #include <xmloff/nmspmap.hxx>
31 #include <xmloff/xmltoken.hxx>
32 #include "xmloff/xmlnmspe.hxx"
33
34 #ifndef _XMLOFF_TRANSFOERMERBASE_HXX
35 #include "TransformerBase.hxx"
36 #endif
37 #include "MutableAttrList.hxx"
38 #include "MetaTContext.hxx"
39
40 using ::rtl::OUString;
41 using namespace ::xmloff::token;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::xml::sax;
44
45 XMLTokenEnum aMetaTokens[] =
46 {
47 XML_GENERATOR,
48 XML_TITLE,
49 XML_DESCRIPTION,
50 XML_SUBJECT,
51 XML_INITIAL_CREATOR,
52 XML_CREATION_DATE,
53 XML_CREATOR,
54 XML_DATE,
55 XML_PRINTED_BY,
56 XML_PRINT_DATE,
57 XML_KEYWORD,
58 XML_LANGUAGE,
59 XML_EDITING_CYCLES,
60 XML_EDITING_DURATION,
61 XML_HYPERLINK_BEHAVIOUR,
62 XML_AUTO_RELOAD,
63 XML_TEMPLATE,
64 XML_USER_DEFINED,
65 XML_DOCUMENT_STATISTIC,
66 XML_TOKEN_END
67 };
68
69 TYPEINIT1( XMLMetaTransformerContext, XMLTransformerContext );
70
XMLMetaTransformerContext(XMLTransformerBase & rImp,const OUString & rQName)71 XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase& rImp,
72 const OUString& rQName ) :
73 XMLTransformerContext( rImp, rQName )
74 {
75 }
76
~XMLMetaTransformerContext()77 XMLMetaTransformerContext::~XMLMetaTransformerContext()
78 {
79 }
80
CreateChildContext(sal_uInt16,const OUString & rLocalName,const OUString & rQName,const Reference<XAttributeList> &)81 XMLTransformerContext *XMLMetaTransformerContext::CreateChildContext(
82 sal_uInt16 /*nPrefix*/,
83 const OUString& rLocalName,
84 const OUString& rQName,
85 const Reference< XAttributeList >& )
86 {
87 XMLPersTextContentTContext *pContext =
88 new XMLPersTextContentTContext( GetTransformer(), rQName );
89 XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext );
90 m_aContexts.insert( aVal );
91
92 return pContext;
93 }
94
EndElement()95 void XMLMetaTransformerContext::EndElement()
96 {
97 // export everything in the correct order
98 OUString aKeywordsQName;
99 XMLTokenEnum *pToken = aMetaTokens;
100 while( *pToken != XML_TOKEN_END )
101 {
102 const OUString& rToken = GetXMLToken( *pToken );
103 XMLMetaContexts_Impl::const_iterator aIter =
104 m_aContexts.find( rToken );
105 if( aIter != m_aContexts.end() )
106 {
107 if( XML_KEYWORD == *pToken )
108 {
109 aKeywordsQName =
110 GetTransformer().GetNamespaceMap().GetQNameByKey(
111 XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) );
112
113 Reference< XAttributeList > xAttrList =
114 new XMLMutableAttributeList;
115 GetTransformer().GetDocHandler()->startElement( aKeywordsQName,
116 xAttrList );
117 }
118
119 // All elements may occur multiple times
120 XMLMetaContexts_Impl::const_iterator aEndIter =
121 m_aContexts.upper_bound( rToken );
122 while( aIter != aEndIter )
123 {
124 (*aIter).second->Export();
125 ++aIter;
126 }
127
128 if( XML_KEYWORD == *pToken )
129 GetTransformer().GetDocHandler()->endElement( aKeywordsQName );
130 }
131 pToken++;
132 }
133
134 GetTransformer().GetDocHandler()->endElement( GetQName() );
135 }
136
Characters(const OUString &)137 void XMLMetaTransformerContext::Characters( const OUString& )
138 {
139 // ignore them
140 }
141
142
143