LibreOffice Module xmloff (master) 1
FrameOOoTContext.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 "FrameOOoTContext.hxx"
21#include "MutableAttrList.hxx"
24#include "ActionMapTypesOOo.hxx"
28#include "TransformerBase.hxx"
29#include <osl/diagnose.h>
30
31using namespace ::com::sun::star::uno;
32using namespace ::com::sun::star::xml::sax;
33using namespace ::xmloff::token;
34
37 const OUString& rQName ) :
38 XMLPersElemContentTContext( rImp, rQName ),
39 m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW,
40 ::xmloff::token::GetXMLToken( XML_FRAME ) ) )
41{
42}
43
45 const Reference< XAttributeList >& rAttrList )
46{
47
48 XMLTransformerActions *pActions =
50 OSL_ENSURE( pActions, "go no actions" );
51
52 Reference< XAttributeList > xAttrList( rAttrList );
55 true );
56 if( !pMutableAttrList )
57 pMutableAttrList = new XMLMutableAttributeList( rAttrList );
58 xAttrList = pMutableAttrList;
59
60 rtl::Reference<XMLMutableAttributeList> pFrameMutableAttrList =
62 Reference< XAttributeList > xFrameAttrList( pFrameMutableAttrList );
63
64 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
65 for( sal_Int16 i=0; i < nAttrCount; i++ )
66 {
67 const OUString& rAttrName = xAttrList->getNameByIndex( i );
68 OUString aLocalName;
69 sal_uInt16 nPrefix =
71 &aLocalName );
72 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
73 XMLTransformerActions::const_iterator aIter =
74 pActions->find( aKey );
75 if( aIter != pActions->end() )
76 {
77 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
78 switch( (*aIter).second.m_nActionType )
79 {
81 pFrameMutableAttrList->AddAttribute( rAttrName, rAttrValue );
82 pMutableAttrList->RemoveAttributeByIndex( i );
83 --i;
84 --nAttrCount;
85 break;
86 default:
87 OSL_ENSURE( false, "unknown action" );
88 break;
89 }
90 }
91 }
92
93 GetTransformer().GetDocHandler()->startElement( m_aElemQName,
94 xFrameAttrList );
96}
97
99 sal_uInt16 nPrefix,
100 const OUString& rLocalName,
101 const OUString& rQName,
102 const Reference< XAttributeList >& rAttrList )
103{
105
106 XMLTransformerActions *pActions =
108 OSL_ENSURE( pActions, "go no actions" );
109 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
110 XMLTransformerActions::const_iterator aIter = pActions->find( aKey );
111
112 if( aIter != pActions->end() )
113 {
114 switch( (*aIter).second.m_nActionType )
115 {
119 // the ones in the list have to be persistent
120
122 nPrefix, rLocalName, rQName, rAttrList );
123 break;
124 default:
125 OSL_ENSURE( false, "unknown action" );
126 break;
127 }
128 }
129
130 // default is copying
131 if( !pContext.is() )
133 nPrefix, rLocalName, rQName, rAttrList );
134
135 return pContext;
136}
137
139{
142 GetTransformer().GetDocHandler()->endElement( m_aElemQName );
143}
144
145void XMLFrameOOoTransformerContext::Characters( const OUString& rChars )
146{
148}
149
151{
152 // this context stores some of its child elements, but is not persistent
153 // itself.
154 return false;
155}
156
157/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ OOO_FRAME_ATTR_ACTIONS
@ OOO_FRAME_ELEM_ACTIONS
@ OOO_SHAPE_ACTIONS
@ XML_ATACTION_MOVE_TO_ELEM
@ XML_ETACTION_RENAME_ELEM
@ XML_ETACTION_COPY_TEXT
@ XML_ETACTION_COPY
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void Characters(const OUString &rChars) override
virtual bool IsPersistent() const override
virtual void EndElement() override
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
XMLFrameOOoTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual void ExportContent() override
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual XMLTransformerActions * GetUserDefinedActions(sal_uInt16 n)
SvXMLNamespaceMap & GetNamespaceMap()
const css::uno::Reference< css::xml::sax::XDocumentHandler > & GetDocHandler() const
XMLMutableAttributeList * ProcessAttrList(css::uno::Reference< css::xml::sax::XAttributeList > &rAttrList, sal_uInt16 nActionMap, bool bClone)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
virtual void Characters(const OUString &rChars)
XMLTransformerBase & GetTransformer()
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
int i
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
constexpr sal_uInt16 XML_NAMESPACE_DRAW