1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "DlgOASISTContext.hxx"
27 #include "MutableAttrList.hxx"
28 #include "xmloff/xmlnmspe.hxx"
29 #include "ActionMapTypesOASIS.hxx"
30 #include "AttrTransformerAction.hxx"
31 #include "TransformerActions.hxx"
32 #ifndef _XMLOFF_TRANSFORMERBASE_HXX
33 #include "TransformerBase.hxx"
34 #endif
35
36 using ::rtl::OUString;
37
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::xml::sax;
40 using namespace ::xmloff::token;
41
42 // -----------------------------------------------------------------------------
43
44 TYPEINIT1( XMLDlgOASISTransformerContext, XMLTransformerContext);
45
XMLDlgOASISTransformerContext(XMLTransformerBase & rImp,const OUString & rQName)46 XMLDlgOASISTransformerContext::XMLDlgOASISTransformerContext(
47 XMLTransformerBase& rImp,
48 const OUString& rQName ) :
49 XMLTransformerContext( rImp, rQName )
50 {
51 }
52
~XMLDlgOASISTransformerContext()53 XMLDlgOASISTransformerContext::~XMLDlgOASISTransformerContext()
54 {
55 }
56
StartElement(const Reference<XAttributeList> & rAttrList)57 void XMLDlgOASISTransformerContext::StartElement(
58 const Reference< XAttributeList >& rAttrList )
59 {
60 XMLTransformerActions *pActions =
61 GetTransformer().GetUserDefinedActions( OASIS_DLG_ACTIONS );
62 OSL_ENSURE( pActions, "go no actions" );
63
64 Reference< XAttributeList > xAttrList( rAttrList );
65 XMLMutableAttributeList *pMutableAttrList = 0;
66 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
67
68 for( sal_Int16 i=0; i < nAttrCount; i++ )
69 {
70 const OUString& rAttrName = xAttrList->getNameByIndex( i );
71 OUString aLocalName;
72 sal_uInt16 nPrefix =
73 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
74 &aLocalName );
75
76 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
77 XMLTransformerActions::const_iterator aIter =
78 pActions->find( aKey );
79
80 if( !(aIter == pActions->end() ) )
81 {
82 if( !pMutableAttrList )
83 {
84 pMutableAttrList =
85 new XMLMutableAttributeList( xAttrList );
86 xAttrList = pMutableAttrList;
87 }
88 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
89 switch( (*aIter).second.m_nActionType )
90 {
91 case XML_ATACTION_DLG_BORDER:
92 {
93 OUString aAttrValue( rAttrValue );
94
95 if ( !aAttrValue.equals( GetXMLToken( XML_NONE ) ) &&
96 !aAttrValue.equals( GetXMLToken( XML_SIMPLE ) ) &&
97 !aAttrValue.equals( GetXMLToken( XML_3D ) ) )
98 {
99 pMutableAttrList->SetValueByIndex(
100 i, GetXMLToken( XML_NONE ) );
101 }
102 }
103 break;
104 default:
105 OSL_ENSURE( !this, "unknown action" );
106 break;
107 }
108 }
109 }
110
111 XMLTransformerContext::StartElement( xAttrList );
112 }
113