fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / transform / FrameOOoTContext.cxx
blob6e84be6533dfbce85a302e910e5a3e0f68cf4bd9
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 "FrameOOoTContext.hxx"
21 #include "IgnoreTContext.hxx"
22 #include "MutableAttrList.hxx"
23 #include "xmloff/xmlnmspe.hxx"
24 #include <xmloff/nmspmap.hxx>
25 #include "ActionMapTypesOOo.hxx"
26 #include "AttrTransformerAction.hxx"
27 #include "ElemTransformerAction.hxx"
28 #include "TransformerActions.hxx"
29 #include "TransformerBase.hxx"
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::xml::sax;
33 using namespace ::xmloff::token;
35 TYPEINIT1( XMLFrameOOoTransformerContext, XMLPersElemContentTContext );
37 XMLFrameOOoTransformerContext::XMLFrameOOoTransformerContext(
38 XMLTransformerBase& rImp,
39 const OUString& rQName ) :
40 XMLPersElemContentTContext( rImp, rQName ),
41 m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DRAW,
42 ::xmloff::token::GetXMLToken( XML_FRAME ) ) )
46 XMLFrameOOoTransformerContext::~XMLFrameOOoTransformerContext()
50 void XMLFrameOOoTransformerContext::StartElement(
51 const Reference< XAttributeList >& rAttrList )
54 XMLTransformerActions *pActions =
55 GetTransformer().GetUserDefinedActions( OOO_FRAME_ATTR_ACTIONS );
56 OSL_ENSURE( pActions, "go no actions" );
58 Reference< XAttributeList > xAttrList( rAttrList );
59 XMLMutableAttributeList *pMutableAttrList =
60 GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
61 sal_True );
62 if( !pMutableAttrList )
63 pMutableAttrList = new XMLMutableAttributeList( rAttrList );
64 xAttrList = pMutableAttrList;
66 XMLMutableAttributeList *pFrameMutableAttrList =
67 new XMLMutableAttributeList;
68 Reference< XAttributeList > xFrameAttrList( pFrameMutableAttrList );
70 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
71 for( sal_Int16 i=0; i < nAttrCount; i++ )
73 const OUString& rAttrName = xAttrList->getNameByIndex( i );
74 OUString aLocalName;
75 sal_uInt16 nPrefix =
76 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
77 &aLocalName );
78 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
79 XMLTransformerActions::const_iterator aIter =
80 pActions->find( aKey );
81 if( !(aIter == pActions->end() ) )
83 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
84 switch( (*aIter).second.m_nActionType )
86 case XML_ATACTION_MOVE_TO_ELEM:
87 pFrameMutableAttrList->AddAttribute( rAttrName, rAttrValue );
88 pMutableAttrList->RemoveAttributeByIndex( i );
89 --i;
90 --nAttrCount;
91 break;
92 default:
93 OSL_ENSURE( !this, "unknown action" );
94 break;
99 GetTransformer().GetDocHandler()->startElement( m_aElemQName,
100 xFrameAttrList );
101 XMLTransformerContext::StartElement( xAttrList );
104 XMLTransformerContext *XMLFrameOOoTransformerContext::CreateChildContext(
105 sal_uInt16 nPrefix,
106 const OUString& rLocalName,
107 const OUString& rQName,
108 const Reference< XAttributeList >& rAttrList )
110 XMLTransformerContext *pContext = 0;
112 XMLTransformerActions *pActions =
113 GetTransformer().GetUserDefinedActions( OOO_FRAME_ELEM_ACTIONS );
114 OSL_ENSURE( pActions, "go no actions" );
115 XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
116 XMLTransformerActions::const_iterator aIter = pActions->find( aKey );
118 if( !(aIter == pActions->end()) )
120 switch( (*aIter).second.m_nActionType )
122 case XML_ETACTION_COPY:
123 case XML_ETACTION_COPY_TEXT:
124 case XML_ETACTION_RENAME_ELEM:
125 // the ones in the list have to be persistent
127 pContext = XMLPersElemContentTContext::CreateChildContext(
128 nPrefix, rLocalName, rQName, rAttrList );
129 break;
130 default:
131 OSL_ENSURE( !this, "unknown action" );
132 break;
136 // default is copying
137 if( !pContext )
138 pContext = XMLTransformerContext::CreateChildContext(
139 nPrefix, rLocalName, rQName, rAttrList );
141 return pContext;
144 void XMLFrameOOoTransformerContext::EndElement()
146 XMLTransformerContext::EndElement();
147 ExportContent();
148 GetTransformer().GetDocHandler()->endElement( m_aElemQName );
151 void XMLFrameOOoTransformerContext::Characters( const OUString& rChars )
153 XMLTransformerContext::Characters( rChars );
156 sal_Bool XMLFrameOOoTransformerContext::IsPersistent() const
158 // this context stores some of its child elements, but is not persistent
159 // itself.
160 return sal_False;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */