Teach symstore more duplicated DLLs
[LibreOffice.git] / xmloff / source / transform / ControlOASISTContext.cxx
bloba34f10de7ca0318056c430b694fe6195d09a56d4
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 "MutableAttrList.hxx"
21 #include <xmloff/xmlnmspe.hxx>
22 #include <xmloff/nmspmap.hxx>
23 #include "ActionMapTypesOASIS.hxx"
24 #include "AttrTransformerAction.hxx"
25 #include "TransformerActions.hxx"
26 #include "TransformerBase.hxx"
27 #include "ControlOASISTContext.hxx"
28 #include <osl/diagnose.h>
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::xml::sax;
32 using namespace ::xmloff::token;
34 XMLControlOASISTransformerContext::XMLControlOASISTransformerContext(
35 XMLTransformerBase& rImp,
36 const OUString& rQName,
37 bool bCreateControl ) :
38 XMLTransformerContext( rImp, rQName ),
39 m_aElemQName( rImp.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_FORM,
40 ::xmloff::token::GetXMLToken( XML_CONTROL ) ) ),
41 m_bCreateControl( bCreateControl )
45 void XMLControlOASISTransformerContext::StartElement(
46 const Reference< XAttributeList >& rAttrList )
49 XMLTransformerActions *pActions =
50 GetTransformer().GetUserDefinedActions( OASIS_FORM_CONTROL_ACTIONS );
51 OSL_ENSURE( pActions, "go no actions" );
53 Reference< XAttributeList > xAttrList( rAttrList );
54 XMLMutableAttributeList *pMutableAttrList = nullptr;
55 // GetTransformer().ProcessAttrList( xAttrList, OOO_SHAPE_ACTIONS,
56 // sal_True );
58 XMLMutableAttributeList *pControlMutableAttrList =
59 m_bCreateControl ? new XMLMutableAttributeList : nullptr;
60 Reference< XAttributeList > xControlAttrList( pControlMutableAttrList );
62 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
63 for( sal_Int16 i=0; i < nAttrCount; i++ )
65 const OUString& rAttrName = xAttrList->getNameByIndex( i );
66 OUString aLocalName;
67 sal_uInt16 nPrefix =
68 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
69 &aLocalName );
70 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
71 XMLTransformerActions::const_iterator aIter =
72 pActions->find( aKey );
73 if( aIter != pActions->end() )
75 if( !pMutableAttrList )
77 pMutableAttrList =
78 new XMLMutableAttributeList( rAttrList );
79 xAttrList = pMutableAttrList;
81 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
82 switch( (*aIter).second.m_nActionType )
84 case XML_ATACTION_MOVE_TO_ELEM:
85 if( m_bCreateControl )
87 pControlMutableAttrList->AddAttribute( rAttrName,
88 rAttrValue );
89 pMutableAttrList->RemoveAttributeByIndex( i );
90 --i;
91 --nAttrCount;
93 break;
94 case XML_ATACTION_RENAME_REMOVE_NAMESPACE_PREFIX:
96 OUString aAttrValue( rAttrValue );
97 sal_uInt16 nValPrefix =
98 static_cast<sal_uInt16>( (*aIter).second.m_nParam2 );
99 GetTransformer().RemoveNamespacePrefix( aAttrValue,
100 nValPrefix );
101 OUString aNewAttrQName(
102 GetTransformer().GetNamespaceMap().GetQNameByKey(
103 (*aIter).second.GetQNamePrefixFromParam1(),
104 ::xmloff::token::GetXMLToken(
105 (*aIter).second.GetQNameTokenFromParam1()) ) );
106 if( m_bCreateControl )
108 pControlMutableAttrList->AddAttribute( aNewAttrQName,
109 aAttrValue );
110 pMutableAttrList->RemoveAttributeByIndex( i );
111 --i;
112 --nAttrCount;
114 else
116 pMutableAttrList->RenameAttributeByIndex( i,
117 aNewAttrQName );
118 pMutableAttrList->SetValueByIndex( i, aAttrValue );
121 break;
122 case XML_ATACTION_URI_OASIS:
124 OUString aAttrValue( rAttrValue );
125 if( GetTransformer().ConvertURIToOOo( aAttrValue,
126 static_cast< bool >((*aIter).second.m_nParam1)) )
127 pMutableAttrList->SetValueByIndex( i, aAttrValue );
129 break;
130 default:
131 OSL_ENSURE( false, "unknown action" );
132 break;
137 if( m_bCreateControl )
138 GetTransformer().GetDocHandler()->startElement( m_aElemQName,
139 xControlAttrList );
140 XMLTransformerContext::StartElement( xAttrList );
143 void XMLControlOASISTransformerContext::EndElement()
145 XMLTransformerContext::EndElement();
146 if( m_bCreateControl )
147 GetTransformer().GetDocHandler()->endElement( m_aElemQName );
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */