LibreOffice Module xmloff (master)  1
MetaTContext.cxx
Go to the documentation of this file.
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/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>
26 
27 #include "TransformerBase.hxx"
28 #include "MutableAttrList.hxx"
29 #include "MetaTContext.hxx"
30 
31 using namespace ::xmloff::token;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::xml::sax;
34 
36 {
38  XML_TITLE,
44  XML_DATE,
57 };
58 
60  const OUString& rQName ) :
61  XMLTransformerContext( rImp, rQName )
62 {
63 }
64 
66 {
67 }
68 
70  sal_uInt16 /*nPrefix*/,
71  const OUString& rLocalName,
72  const OUString& rQName,
73  const Reference< XAttributeList >& )
74 {
77  XMLMetaContexts_Impl::value_type aVal( rLocalName, pContext );
78  m_aContexts.insert( aVal );
79 
80  return pContext.get();
81 }
82 
84 {
85  // export everything in the correct order
86  OUString aKeywordsQName;
87  XMLTokenEnum const *pToken = aMetaTokens;
88  while( *pToken != XML_TOKEN_END )
89  {
90  const OUString& rToken = GetXMLToken( *pToken );
91  XMLMetaContexts_Impl::const_iterator aIter =
92  m_aContexts.find( rToken );
93  if( aIter != m_aContexts.end() )
94  {
95  if( XML_KEYWORD == *pToken )
96  {
97  aKeywordsQName =
100 
101  Reference< XAttributeList > xAttrList =
103  GetTransformer().GetDocHandler()->startElement( aKeywordsQName,
104  xAttrList );
105  }
106 
107  // All elements may occur multiple times
108  XMLMetaContexts_Impl::const_iterator aEndIter =
109  m_aContexts.upper_bound( rToken );
110  while( aIter != aEndIter )
111  {
112  (*aIter).second->Export();
113  ++aIter;
114  }
115 
116  if( XML_KEYWORD == *pToken )
117  GetTransformer().GetDocHandler()->endElement( aKeywordsQName );
118  }
119  pToken++;
120  }
121 
122  GetTransformer().GetDocHandler()->endElement( GetQName() );
123 }
124 
126 {
127  // ignore them
128 }
129 
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void EndElement() override
XMLTokenEnum const aMetaTokens[]
SvXMLNamespaceMap & GetNamespaceMap()
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
XMLMetaContexts_Impl m_aContexts
virtual ~XMLMetaTransformerContext() override
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
XMLTransformerBase & GetTransformer()
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
XMLMetaTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
Handling of tokens in XML:
constexpr sal_uInt16 XML_NAMESPACE_META
const OUString & GetQName() const
virtual void Characters(const OUString &rChars) override