/src/libreoffice/xmloff/source/transform/MetaTContext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <com/sun/star/xml/sax/XDocumentHandler.hpp> |
21 | | #include <xmloff/namespacemap.hxx> |
22 | | #include <xmloff/xmltoken.hxx> |
23 | | #include <xmloff/xmlnamespace.hxx> |
24 | | |
25 | | #include "TransformerBase.hxx" |
26 | | #include "MutableAttrList.hxx" |
27 | | #include "MetaTContext.hxx" |
28 | | |
29 | | using namespace ::xmloff::token; |
30 | | using namespace ::com::sun::star::uno; |
31 | | using namespace ::com::sun::star::xml::sax; |
32 | | |
33 | | XMLTokenEnum const aMetaTokens[] = |
34 | | { |
35 | | XML_GENERATOR, |
36 | | XML_TITLE, |
37 | | XML_DESCRIPTION, |
38 | | XML_SUBJECT, |
39 | | XML_INITIAL_CREATOR, |
40 | | XML_CREATION_DATE, |
41 | | XML_CREATOR, |
42 | | XML_DATE, |
43 | | XML_PRINTED_BY, |
44 | | XML_PRINT_DATE, |
45 | | XML_KEYWORD, |
46 | | XML_LANGUAGE, |
47 | | XML_EDITING_CYCLES, |
48 | | XML_EDITING_DURATION, |
49 | | XML_HYPERLINK_BEHAVIOUR, |
50 | | XML_AUTO_RELOAD, |
51 | | XML_TEMPLATE, |
52 | | XML_USER_DEFINED, |
53 | | XML_DOCUMENT_STATISTIC, |
54 | | XML_TOKEN_END |
55 | | }; |
56 | | |
57 | | XMLMetaTransformerContext::XMLMetaTransformerContext( XMLTransformerBase& rImp, |
58 | | const OUString& rQName ) : |
59 | 0 | XMLTransformerContext( rImp, rQName ) |
60 | 0 | { |
61 | 0 | } |
62 | | |
63 | | XMLMetaTransformerContext::~XMLMetaTransformerContext() |
64 | 0 | { |
65 | 0 | } |
66 | | |
67 | | rtl::Reference<XMLTransformerContext> XMLMetaTransformerContext::CreateChildContext( |
68 | | sal_uInt16 /*nPrefix*/, |
69 | | const OUString& rLocalName, |
70 | | const OUString& rQName, |
71 | | const Reference< XAttributeList >& ) |
72 | 0 | { |
73 | 0 | rtl::Reference<XMLPersTextContentTContext> pContext( |
74 | 0 | new XMLPersTextContentTContext( GetTransformer(), rQName )); |
75 | 0 | XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext ); |
76 | 0 | m_aContexts.insert( aVal ); |
77 | |
|
78 | 0 | return pContext; |
79 | 0 | } |
80 | | |
81 | | void XMLMetaTransformerContext::EndElement() |
82 | 0 | { |
83 | | // export everything in the correct order |
84 | 0 | OUString aKeywordsQName; |
85 | 0 | XMLTokenEnum const *pToken = aMetaTokens; |
86 | 0 | while( *pToken != XML_TOKEN_END ) |
87 | 0 | { |
88 | 0 | const OUString& rToken = GetXMLToken( *pToken ); |
89 | 0 | XMLMetaContexts_Impl::const_iterator aIter = |
90 | 0 | m_aContexts.find( rToken ); |
91 | 0 | if( aIter != m_aContexts.end() ) |
92 | 0 | { |
93 | 0 | if( XML_KEYWORD == *pToken ) |
94 | 0 | { |
95 | 0 | aKeywordsQName = |
96 | 0 | GetTransformer().GetNamespaceMap().GetQNameByKey( |
97 | 0 | XML_NAMESPACE_META, GetXMLToken(XML_KEYWORDS ) ); |
98 | |
|
99 | 0 | Reference< XAttributeList > xAttrList = |
100 | 0 | new XMLMutableAttributeList; |
101 | 0 | GetTransformer().GetDocHandler()->startElement( aKeywordsQName, |
102 | 0 | xAttrList ); |
103 | 0 | } |
104 | | |
105 | | // All elements may occur multiple times |
106 | 0 | XMLMetaContexts_Impl::const_iterator aEndIter = |
107 | 0 | m_aContexts.upper_bound( rToken ); |
108 | 0 | while( aIter != aEndIter ) |
109 | 0 | { |
110 | 0 | (*aIter).second->Export(); |
111 | 0 | ++aIter; |
112 | 0 | } |
113 | |
|
114 | 0 | if( XML_KEYWORD == *pToken ) |
115 | 0 | GetTransformer().GetDocHandler()->endElement( aKeywordsQName ); |
116 | 0 | } |
117 | 0 | pToken++; |
118 | 0 | } |
119 | |
|
120 | 0 | GetTransformer().GetDocHandler()->endElement( GetQName() ); |
121 | 0 | } |
122 | | |
123 | | void XMLMetaTransformerContext::Characters( const OUString& ) |
124 | 0 | { |
125 | | // ignore them |
126 | 0 | } |
127 | | |
128 | | |
129 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |