1*63bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*63bba73cSAndrew Rist * distributed with this work for additional information
6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance
9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10*63bba73cSAndrew Rist *
11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*63bba73cSAndrew Rist *
13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*63bba73cSAndrew Rist * software distributed under the License is distributed on an
15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the
17*63bba73cSAndrew Rist * specific language governing permissions and limitations
18*63bba73cSAndrew Rist * under the License.
19*63bba73cSAndrew Rist *
20*63bba73cSAndrew Rist *************************************************************/
21*63bba73cSAndrew Rist
22*63bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include <rtl/ref.hxx>
27cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
28cdf0e10cSrcweir #include <com/sun/star/i18n/XCharacterClassification.hpp>
29cdf0e10cSrcweir #include <com/sun/star/i18n/UnicodeType.hpp>
30cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
31cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
32cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
33cdf0e10cSrcweir #include "IgnoreTContext.hxx"
34cdf0e10cSrcweir #include "RenameElemTContext.hxx"
35cdf0e10cSrcweir #include "ProcAttrTContext.hxx"
36cdf0e10cSrcweir #include "ProcAddAttrTContext.hxx"
37cdf0e10cSrcweir #include "MergeElemTContext.hxx"
38cdf0e10cSrcweir #include "CreateElemTContext.hxx"
39cdf0e10cSrcweir #include "MutableAttrList.hxx"
40cdf0e10cSrcweir #include "TransformerActions.hxx"
41cdf0e10cSrcweir #include "ElemTransformerAction.hxx"
42cdf0e10cSrcweir // --> OD 2005-06-29 #i50322#
43cdf0e10cSrcweir #include "PropertyActionsOOo.hxx"
44cdf0e10cSrcweir // <--
45cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERTOKENMAP_HXX
46cdf0e10cSrcweir #include "TransformerTokenMap.hxx"
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERBASE_HXX
51cdf0e10cSrcweir #include "TransformerBase.hxx"
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #include "TContextVector.hxx"
54cdf0e10cSrcweir
55cdf0e10cSrcweir using ::rtl::OUString;
56cdf0e10cSrcweir using ::rtl::OUStringBuffer;
57cdf0e10cSrcweir using namespace ::osl;
58cdf0e10cSrcweir using namespace ::xmloff::token;
59cdf0e10cSrcweir using namespace ::com::sun::star::uno;
60cdf0e10cSrcweir using namespace ::com::sun::star::beans;
61cdf0e10cSrcweir using namespace ::com::sun::star::lang;
62cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
63cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
64cdf0e10cSrcweir
65cdf0e10cSrcweir // -----------------------------------------------------------------------------
66cdf0e10cSrcweir
67cdf0e10cSrcweir namespace
68cdf0e10cSrcweir {
lcl_ConvertAttr(OUString & rOutAttribute,sal_Int32 nParam)69cdf0e10cSrcweir bool lcl_ConvertAttr( OUString & rOutAttribute, sal_Int32 nParam )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir bool bResult = false;
72cdf0e10cSrcweir enum XMLTokenEnum eTokenToRename =
73cdf0e10cSrcweir static_cast< enum XMLTokenEnum >( nParam & 0xffff );
74cdf0e10cSrcweir if( eTokenToRename != XML_TOKEN_INVALID &&
75cdf0e10cSrcweir IsXMLToken( rOutAttribute, eTokenToRename ))
76cdf0e10cSrcweir {
77cdf0e10cSrcweir enum XMLTokenEnum eReplacementToken =
78cdf0e10cSrcweir static_cast< enum XMLTokenEnum >( nParam >> 16 );
79cdf0e10cSrcweir rOutAttribute = GetXMLToken( eReplacementToken );
80cdf0e10cSrcweir bResult = true;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir return bResult;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir } // anonymous namespace
85cdf0e10cSrcweir
86cdf0e10cSrcweir // -----------------------------------------------------------------------------
87cdf0e10cSrcweir
CreateContext(sal_uInt16 nPrefix,const OUString & rLocalName,const OUString & rQName)88cdf0e10cSrcweir XMLTransformerContext *XMLTransformerBase::CreateContext( sal_uInt16 nPrefix,
89cdf0e10cSrcweir const OUString& rLocalName, const OUString& rQName )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
92cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter =
93cdf0e10cSrcweir GetElemActions().find( aKey );
94cdf0e10cSrcweir
95cdf0e10cSrcweir if( !(aIter == GetElemActions().end()) )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir sal_uInt32 nActionType = (*aIter).second.m_nActionType;
98cdf0e10cSrcweir if( (nActionType & XML_ETACTION_USER_DEFINED) != 0 )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir XMLTransformerContext *pContext =
101cdf0e10cSrcweir CreateUserDefinedContext( (*aIter).second,
102cdf0e10cSrcweir rQName );
103cdf0e10cSrcweir OSL_ENSURE( pContext && !pContext->IsPersistent(),
104cdf0e10cSrcweir "unknown or not persistent action" );
105cdf0e10cSrcweir return pContext;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
108cdf0e10cSrcweir switch( nActionType )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir case XML_ETACTION_COPY_CONTENT:
111cdf0e10cSrcweir return new XMLIgnoreTransformerContext( *this, rQName, sal_False,
112cdf0e10cSrcweir sal_False );
113cdf0e10cSrcweir case XML_ETACTION_COPY:
114cdf0e10cSrcweir return new XMLTransformerContext( *this, rQName );
115cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM:
116cdf0e10cSrcweir return new XMLRenameElemTransformerContext( *this, rQName,
117cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
118cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1() );
119cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_ADD_ATTR:
120cdf0e10cSrcweir return new XMLRenameElemTransformerContext( *this, rQName,
121cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
122cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(),
123cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam2(),
124cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam2(),
125cdf0e10cSrcweir static_cast< XMLTokenEnum >( (*aIter).second.m_nParam3 ) );
126cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_PROC_ATTRS:
127cdf0e10cSrcweir return new XMLProcAttrTransformerContext( *this, rQName,
128cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
129cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(),
130cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
131cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR:
132cdf0e10cSrcweir return new XMLProcAddAttrTransformerContext( *this, rQName,
133cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
134cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(),
135cdf0e10cSrcweir static_cast< sal_uInt16 >(
136cdf0e10cSrcweir (*aIter).second.m_nParam3 >> 16 ),
137cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam2(),
138cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam2(),
139cdf0e10cSrcweir static_cast< XMLTokenEnum >(
140cdf0e10cSrcweir (*aIter).second.m_nParam3 & 0xffff ) );
141cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_COND:
142cdf0e10cSrcweir {
143cdf0e10cSrcweir const XMLTransformerContext *pCurrent = GetCurrentContext();
144cdf0e10cSrcweir if( pCurrent->HasQName(
145cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam2(),
146cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam2() ) )
147cdf0e10cSrcweir return new XMLRenameElemTransformerContext( *this, rQName,
148cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
149cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1() );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir break;
152cdf0e10cSrcweir case XML_ETACTION_RENAME_ELEM_PROC_ATTRS_COND:
153cdf0e10cSrcweir {
154cdf0e10cSrcweir const XMLTransformerContext *pCurrent = GetCurrentContext();
155cdf0e10cSrcweir if( pCurrent->HasQName(
156cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam3(),
157cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam3() ) )
158cdf0e10cSrcweir return new XMLProcAttrTransformerContext( *this, rQName,
159cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
160cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1(),
161cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
162cdf0e10cSrcweir else
163cdf0e10cSrcweir return new XMLProcAttrTransformerContext( *this, rQName,
164cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir case XML_ETACTION_PROC_ATTRS:
167cdf0e10cSrcweir return new XMLProcAttrTransformerContext( *this, rQName,
168cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
169cdf0e10cSrcweir case XML_ETACTION_PROC_ATTRS_COND:
170cdf0e10cSrcweir {
171cdf0e10cSrcweir const XMLTransformerContext *pCurrent = GetCurrentContext();
172cdf0e10cSrcweir if( pCurrent->HasQName(
173cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
174cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1() ) )
175cdf0e10cSrcweir return new XMLProcAttrTransformerContext( *this, rQName,
176cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir break;
179cdf0e10cSrcweir case XML_ETACTION_MOVE_ATTRS_TO_ELEMS:
180cdf0e10cSrcweir return new XMLCreateElemTransformerContext( *this, rQName,
181cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
182cdf0e10cSrcweir case XML_ETACTION_MOVE_ELEMS_TO_ATTRS:
183cdf0e10cSrcweir return new XMLMergeElemTransformerContext( *this, rQName,
184cdf0e10cSrcweir static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
185cdf0e10cSrcweir default:
186cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" );
187cdf0e10cSrcweir break;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir // default is copying
192cdf0e10cSrcweir return new XMLTransformerContext( *this, rQName );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
GetUserDefinedActions(sal_uInt16)195cdf0e10cSrcweir XMLTransformerActions *XMLTransformerBase::GetUserDefinedActions( sal_uInt16 )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir return 0;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir
XMLTransformerBase(XMLTransformerActionInit * pInit,::xmloff::token::XMLTokenEnum * pTKMapInit)200cdf0e10cSrcweir XMLTransformerBase::XMLTransformerBase( XMLTransformerActionInit *pInit,
201cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum *pTKMapInit )
202cdf0e10cSrcweir throw () :
203cdf0e10cSrcweir m_pNamespaceMap( new SvXMLNamespaceMap ),
204cdf0e10cSrcweir m_pReplaceNamespaceMap( new SvXMLNamespaceMap ),
205cdf0e10cSrcweir m_pContexts( new XMLTransformerContextVector ),
206cdf0e10cSrcweir m_pElemActions( new XMLTransformerActions( pInit ) ),
207cdf0e10cSrcweir m_pTokenMap( new XMLTransformerTokenMap( pTKMapInit ) )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
210cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
211cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
212cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
213cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
214cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
215cdf0e10cSrcweir GetNamespaceMap().Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
216cdf0e10cSrcweir }
217cdf0e10cSrcweir
~XMLTransformerBase()218cdf0e10cSrcweir XMLTransformerBase::~XMLTransformerBase() throw ()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir ResetTokens();
221cdf0e10cSrcweir
222cdf0e10cSrcweir delete m_pNamespaceMap;
223cdf0e10cSrcweir delete m_pReplaceNamespaceMap;
224cdf0e10cSrcweir delete m_pContexts;
225cdf0e10cSrcweir delete m_pElemActions;
226cdf0e10cSrcweir delete m_pTokenMap;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
startDocument(void)229cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::startDocument( void )
230cdf0e10cSrcweir throw( SAXException, RuntimeException )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir m_xHandler->startDocument();
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
endDocument(void)235cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::endDocument( void )
236cdf0e10cSrcweir throw( SAXException, RuntimeException)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir m_xHandler->endDocument();
239cdf0e10cSrcweir }
240cdf0e10cSrcweir
startElement(const OUString & rName,const Reference<XAttributeList> & rAttrList)241cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::startElement( const OUString& rName,
242cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList )
243cdf0e10cSrcweir throw(SAXException, RuntimeException)
244cdf0e10cSrcweir {
245cdf0e10cSrcweir SvXMLNamespaceMap *pRewindMap = 0;
246cdf0e10cSrcweir
247cdf0e10cSrcweir bool bRect = rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "presentation:show-shape" ) );
248cdf0e10cSrcweir (void)bRect;
249cdf0e10cSrcweir
250cdf0e10cSrcweir // Process namespace attributes. This must happen before creating the
251cdf0e10cSrcweir // context, because namespace decaration apply to the element name itself.
252cdf0e10cSrcweir XMLMutableAttributeList *pMutableAttrList = 0;
253cdf0e10cSrcweir Reference< XAttributeList > xAttrList( rAttrList );
254cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
255cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i );
258cdf0e10cSrcweir if( ( rAttrName.getLength() >= 5 ) &&
259cdf0e10cSrcweir ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) &&
260cdf0e10cSrcweir ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
261cdf0e10cSrcweir {
262cdf0e10cSrcweir if( !pRewindMap )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir pRewindMap = m_pNamespaceMap;
265cdf0e10cSrcweir m_pNamespaceMap = new SvXMLNamespaceMap( *m_pNamespaceMap );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir const OUString& rAttrValue = xAttrList->getValueByIndex( i );
268cdf0e10cSrcweir
269cdf0e10cSrcweir OUString aPrefix( ( rAttrName.getLength() == 5 )
270cdf0e10cSrcweir ? OUString()
271cdf0e10cSrcweir : rAttrName.copy( 6 ) );
272cdf0e10cSrcweir // Add namespace, but only if it is known.
273cdf0e10cSrcweir sal_uInt16 nKey = m_pNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
274cdf0e10cSrcweir // If namespace is unknwon, try to match a name with similar
275cdf0e10cSrcweir // TC Id an version
276cdf0e10cSrcweir if( XML_NAMESPACE_UNKNOWN == nKey )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir OUString aTestName( rAttrValue );
279cdf0e10cSrcweir if( SvXMLNamespaceMap::NormalizeOasisURN( aTestName ) )
280cdf0e10cSrcweir nKey = m_pNamespaceMap->AddIfKnown( aPrefix, aTestName );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir // If that namespace is not known, too, add it as unknown
283cdf0e10cSrcweir if( XML_NAMESPACE_UNKNOWN == nKey )
284cdf0e10cSrcweir nKey = m_pNamespaceMap->Add( aPrefix, rAttrValue );
285cdf0e10cSrcweir
286cdf0e10cSrcweir const OUString& rRepName = m_pReplaceNamespaceMap->GetNameByKey( nKey );
287cdf0e10cSrcweir if( rRepName.getLength() )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir if( !pMutableAttrList )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir pMutableAttrList = new XMLMutableAttributeList( xAttrList );
292cdf0e10cSrcweir xAttrList = pMutableAttrList;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
295cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, rRepName );
296cdf0e10cSrcweir }
297cdf0e10cSrcweir }
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
300cdf0e10cSrcweir // Get element's namespace and local name.
301cdf0e10cSrcweir OUString aLocalName;
302cdf0e10cSrcweir sal_uInt16 nPrefix =
303cdf0e10cSrcweir m_pNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
304cdf0e10cSrcweir
305cdf0e10cSrcweir // If there are contexts already, call a CreateChildContext at the topmost
306cdf0e10cSrcweir // context. Otherwise, create a default context.
307cdf0e10cSrcweir ::rtl::Reference < XMLTransformerContext > xContext;
308cdf0e10cSrcweir if( !m_pContexts->empty() )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir xContext = m_pContexts->back()->CreateChildContext( nPrefix,
311cdf0e10cSrcweir aLocalName,
312cdf0e10cSrcweir rName,
313cdf0e10cSrcweir xAttrList );
314cdf0e10cSrcweir }
315cdf0e10cSrcweir else
316cdf0e10cSrcweir {
317cdf0e10cSrcweir xContext = CreateContext( nPrefix, aLocalName, rName );
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir OSL_ENSURE( xContext.is(), "XMLTransformerBase::startElement: missing context" );
321cdf0e10cSrcweir if( !xContext.is() )
322cdf0e10cSrcweir xContext = new XMLTransformerContext( *this, rName );
323cdf0e10cSrcweir
324cdf0e10cSrcweir // Remeber old namespace map.
325cdf0e10cSrcweir if( pRewindMap )
326cdf0e10cSrcweir xContext->SetRewindMap( pRewindMap );
327cdf0e10cSrcweir
328cdf0e10cSrcweir // Push context on stack.
329cdf0e10cSrcweir m_pContexts->push_back( xContext );
330cdf0e10cSrcweir
331cdf0e10cSrcweir // Call a startElement at the new context.
332cdf0e10cSrcweir xContext->StartElement( xAttrList );
333cdf0e10cSrcweir }
334cdf0e10cSrcweir
endElement(const OUString & rName)335cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::endElement( const OUString&
336cdf0e10cSrcweir #ifdef DBG_UTIL
337cdf0e10cSrcweir rName
338cdf0e10cSrcweir #endif
339cdf0e10cSrcweir )
340cdf0e10cSrcweir throw(SAXException, RuntimeException)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir if( !m_pContexts->empty() )
343cdf0e10cSrcweir {
344cdf0e10cSrcweir // Get topmost context
345cdf0e10cSrcweir ::rtl::Reference< XMLTransformerContext > xContext = m_pContexts->back();
346cdf0e10cSrcweir
347cdf0e10cSrcweir #ifdef DBG_UTIL
348cdf0e10cSrcweir OSL_ENSURE( xContext->GetQName() == rName,
349cdf0e10cSrcweir "XMLTransformerBase::endElement: popped context has wrong lname" );
350cdf0e10cSrcweir #endif
351cdf0e10cSrcweir
352cdf0e10cSrcweir // Call a EndElement at the current context.
353cdf0e10cSrcweir xContext->EndElement();
354cdf0e10cSrcweir
355cdf0e10cSrcweir // and remove it from the stack.
356cdf0e10cSrcweir m_pContexts->pop_back();
357cdf0e10cSrcweir
358cdf0e10cSrcweir // Get a namespace map to rewind.
359cdf0e10cSrcweir SvXMLNamespaceMap *pRewindMap = xContext->GetRewindMap();
360cdf0e10cSrcweir
361cdf0e10cSrcweir // Delete the current context.
362cdf0e10cSrcweir xContext = 0;
363cdf0e10cSrcweir
364cdf0e10cSrcweir // Rewind a namespace map.
365cdf0e10cSrcweir if( pRewindMap )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir delete m_pNamespaceMap;
368cdf0e10cSrcweir m_pNamespaceMap = pRewindMap;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir }
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
characters(const OUString & rChars)373cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::characters( const OUString& rChars )
374cdf0e10cSrcweir throw(SAXException, RuntimeException)
375cdf0e10cSrcweir {
376cdf0e10cSrcweir if( !m_pContexts->empty() )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir m_pContexts->back()->Characters( rChars );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
ignorableWhitespace(const OUString & rWhitespaces)382cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::ignorableWhitespace( const OUString& rWhitespaces )
383cdf0e10cSrcweir throw(SAXException, RuntimeException)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir m_xHandler->ignorableWhitespace( rWhitespaces );
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
processingInstruction(const OUString & rTarget,const OUString & rData)388cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::processingInstruction( const OUString& rTarget,
389cdf0e10cSrcweir const OUString& rData )
390cdf0e10cSrcweir throw(SAXException, RuntimeException)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir m_xHandler->processingInstruction( rTarget, rData );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir
setDocumentLocator(const Reference<XLocator> & rLocator)395cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::setDocumentLocator( const Reference< XLocator >& rLocator )
396cdf0e10cSrcweir throw(SAXException, RuntimeException)
397cdf0e10cSrcweir {
398cdf0e10cSrcweir m_xLocator = rLocator;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
401cdf0e10cSrcweir // XExtendedDocumentHandler
startCDATA(void)402cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::startCDATA( void ) throw(SAXException, RuntimeException)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir if( m_xExtHandler.is() )
405cdf0e10cSrcweir m_xExtHandler->startCDATA();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir
endCDATA(void)408cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::endCDATA( void ) throw(RuntimeException)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir if( m_xExtHandler.is() )
411cdf0e10cSrcweir m_xExtHandler->endCDATA();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir
comment(const OUString & rComment)414cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::comment( const OUString& rComment )
415cdf0e10cSrcweir throw(SAXException, RuntimeException)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir if( m_xExtHandler.is() )
418cdf0e10cSrcweir m_xExtHandler->comment( rComment );
419cdf0e10cSrcweir }
420cdf0e10cSrcweir
allowLineBreak(void)421cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::allowLineBreak( void )
422cdf0e10cSrcweir throw(SAXException, RuntimeException)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir if( m_xExtHandler.is() )
425cdf0e10cSrcweir m_xExtHandler->allowLineBreak();
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
unknown(const OUString & rString)428cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::unknown( const OUString& rString )
429cdf0e10cSrcweir throw(SAXException, RuntimeException)
430cdf0e10cSrcweir {
431cdf0e10cSrcweir if( m_xExtHandler.is() )
432cdf0e10cSrcweir m_xExtHandler->unknown( rString );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir
435cdf0e10cSrcweir // XInitialize
initialize(const Sequence<Any> & aArguments)436cdf0e10cSrcweir void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments )
437cdf0e10cSrcweir throw(Exception, RuntimeException)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir const sal_Int32 nAnyCount = aArguments.getLength();
440cdf0e10cSrcweir const Any* pAny = aArguments.getConstArray();
441cdf0e10cSrcweir
442cdf0e10cSrcweir for( sal_Int32 nIndex = 0; nIndex < nAnyCount; nIndex++, pAny++ )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // #b6236750# use isAssignableFrom instead of comparing the types to
445cdf0e10cSrcweir // allow XExtendedDocumentHandler instead of XDocumentHandler (used in
446cdf0e10cSrcweir // writeOasis2OOoLibraryElement in sfx2).
447cdf0e10cSrcweir // The Any shift operator can't be used to query the type because it
448cdf0e10cSrcweir // uses queryInterface, and the model also has a XPropertySet interface.
449cdf0e10cSrcweir
450cdf0e10cSrcweir // document handler
451cdf0e10cSrcweir if( ::getCppuType( (const Reference< XDocumentHandler >*) 0 ).isAssignableFrom( pAny->getValueType() ) )
452cdf0e10cSrcweir m_xHandler.set( *pAny, UNO_QUERY );
453cdf0e10cSrcweir
454cdf0e10cSrcweir // property set to transport data across
455cdf0e10cSrcweir if( ::getCppuType( (const Reference< XPropertySet >*) 0 ).isAssignableFrom( pAny->getValueType() ) )
456cdf0e10cSrcweir m_xPropSet.set( *pAny, UNO_QUERY );
457cdf0e10cSrcweir
458cdf0e10cSrcweir // xmodel
459cdf0e10cSrcweir if( ::getCppuType( (const Reference< ::com::sun::star::frame::XModel >*) 0 ).isAssignableFrom( pAny->getValueType() ) )
460cdf0e10cSrcweir mxModel.set( *pAny, UNO_QUERY );
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir if( m_xPropSet.is() )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir Any aAny;
466cdf0e10cSrcweir OUString sRelPath, sName;
467cdf0e10cSrcweir Reference< XPropertySetInfo > xPropSetInfo =
468cdf0e10cSrcweir m_xPropSet->getPropertySetInfo();
469cdf0e10cSrcweir OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) );
470cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName(sPropName) )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir aAny = m_xPropSet->getPropertyValue(sPropName);
473cdf0e10cSrcweir aAny >>= sRelPath;
474cdf0e10cSrcweir }
475cdf0e10cSrcweir sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamName" ) );
476cdf0e10cSrcweir if( xPropSetInfo->hasPropertyByName(sPropName) )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir aAny = m_xPropSet->getPropertyValue(sPropName);
479cdf0e10cSrcweir aAny >>= sName;
480cdf0e10cSrcweir }
481cdf0e10cSrcweir if( sName.getLength() )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir m_aExtPathPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM("../" ) );
484cdf0e10cSrcweir
485cdf0e10cSrcweir // If there is a rel path within a package, then append
486cdf0e10cSrcweir // additional '../'. If the rel path contains an ':', then it is
487cdf0e10cSrcweir // an absolute URI (or invalid URI, because zip files don't
488cdf0e10cSrcweir // permit ':'), and it will be ignored.
489cdf0e10cSrcweir if( sRelPath.getLength() )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir sal_Int32 nColPos = sRelPath.indexOf( ':' );
492cdf0e10cSrcweir OSL_ENSURE( -1 == nColPos,
493cdf0e10cSrcweir "StreamRelPath contains ':', absolute URI?" );
494cdf0e10cSrcweir
495cdf0e10cSrcweir if( -1 == nColPos )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir OUString sTmp = m_aExtPathPrefix;
498cdf0e10cSrcweir sal_Int32 nPos = 0;
499cdf0e10cSrcweir do
500cdf0e10cSrcweir {
501cdf0e10cSrcweir m_aExtPathPrefix += sTmp;
502cdf0e10cSrcweir nPos = sRelPath.indexOf( '/', nPos + 1 );
503cdf0e10cSrcweir }
504cdf0e10cSrcweir while( -1 != nPos );
505cdf0e10cSrcweir }
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
508cdf0e10cSrcweir }
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir
lcl_getUnit(const OUString & rValue)512cdf0e10cSrcweir static MapUnit lcl_getUnit( const OUString& rValue )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir MapUnit nDestUnit;
515cdf0e10cSrcweir if( rValue.endsWithIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "cm" ) ) )
516cdf0e10cSrcweir nDestUnit = MAP_CM;
517cdf0e10cSrcweir else if ( rValue.endsWithIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "mm" ) ) )
518cdf0e10cSrcweir nDestUnit = MAP_MM;
519cdf0e10cSrcweir else
520cdf0e10cSrcweir nDestUnit = MAP_INCH;
521cdf0e10cSrcweir return nDestUnit;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
ProcessAttrList(Reference<XAttributeList> & rAttrList,sal_uInt16 nActionMap,sal_Bool bClone)524cdf0e10cSrcweir XMLMutableAttributeList *XMLTransformerBase::ProcessAttrList(
525cdf0e10cSrcweir Reference< XAttributeList >& rAttrList, sal_uInt16 nActionMap,
526cdf0e10cSrcweir sal_Bool bClone )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir XMLMutableAttributeList *pMutableAttrList = 0;
529cdf0e10cSrcweir XMLTransformerActions *pActions = GetUserDefinedActions( nActionMap );
530cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" );
531cdf0e10cSrcweir if( pActions )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
534cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; ++i )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir const OUString& rAttrName = rAttrList->getNameByIndex( i );
537cdf0e10cSrcweir const OUString& rAttrValue = rAttrList->getValueByIndex( i );
538cdf0e10cSrcweir OUString aLocalName;
539cdf0e10cSrcweir sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( rAttrName,
540cdf0e10cSrcweir &aLocalName );
541cdf0e10cSrcweir
542cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
543cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter =
544cdf0e10cSrcweir pActions->find( aKey );
545cdf0e10cSrcweir if( !(aIter == pActions->end() ) )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir if( !pMutableAttrList )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir pMutableAttrList = new XMLMutableAttributeList( rAttrList,
550cdf0e10cSrcweir bClone );
551cdf0e10cSrcweir rAttrList = pMutableAttrList;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir
554cdf0e10cSrcweir sal_uInt32 nAction = (*aIter).second.m_nActionType;
555cdf0e10cSrcweir sal_Bool bRename = sal_False;
556cdf0e10cSrcweir switch( nAction )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir case XML_ATACTION_RENAME:
559cdf0e10cSrcweir bRename = sal_True;
560cdf0e10cSrcweir break;
561cdf0e10cSrcweir case XML_ATACTION_COPY:
562cdf0e10cSrcweir break;
563cdf0e10cSrcweir case XML_ATACTION_REMOVE:
564cdf0e10cSrcweir case XML_ATACTION_STYLE_DISPLAY_NAME:
565cdf0e10cSrcweir pMutableAttrList->RemoveAttributeByIndex( i );
566cdf0e10cSrcweir --i;
567cdf0e10cSrcweir --nAttrCount;
568cdf0e10cSrcweir break;
569cdf0e10cSrcweir case XML_ATACTION_RENAME_IN2INCH:
570cdf0e10cSrcweir bRename = sal_True;
571cdf0e10cSrcweir case XML_ATACTION_IN2INCH:
572cdf0e10cSrcweir {
573cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
574cdf0e10cSrcweir if( ReplaceSingleInWithInch( aAttrValue ) )
575cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir break;
578cdf0e10cSrcweir case XML_ATACTION_INS2INCHS:
579cdf0e10cSrcweir {
580cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
581cdf0e10cSrcweir if( ReplaceInWithInch( aAttrValue ) )
582cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
583cdf0e10cSrcweir }
584cdf0e10cSrcweir break;
585cdf0e10cSrcweir case XML_ATACTION_RENAME_INCH2IN:
586cdf0e10cSrcweir bRename = sal_True;
587cdf0e10cSrcweir case XML_ATACTION_INCH2IN:
588cdf0e10cSrcweir {
589cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
590cdf0e10cSrcweir if( ReplaceSingleInchWithIn( aAttrValue ) )
591cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
592cdf0e10cSrcweir }
593cdf0e10cSrcweir break;
594cdf0e10cSrcweir case XML_ATACTION_INCHS2INS:
595cdf0e10cSrcweir {
596cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
597cdf0e10cSrcweir if( ReplaceInchWithIn( aAttrValue ) )
598cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir break;
601cdf0e10cSrcweir case XML_ATACTION_TWIPS2IN:
602cdf0e10cSrcweir {
603cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
604cdf0e10cSrcweir
605cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue );
606cdf0e10cSrcweir if( isWriter() )
607cdf0e10cSrcweir {
608cdf0e10cSrcweir MapUnit nDestUnit = lcl_getUnit( aAttrValue );
609cdf0e10cSrcweir
610cdf0e10cSrcweir // convert twips value to inch
611cdf0e10cSrcweir sal_Int32 nMeasure;
612cdf0e10cSrcweir if( SvXMLUnitConverter::convertMeasure(nMeasure, aAttrValue, MAP_100TH_MM ) )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir
615cdf0e10cSrcweir // --> OD 2004-10-29 #i13778#,#i36248#
616cdf0e10cSrcweir // apply correct twip-to-1/100mm
617cdf0e10cSrcweir nMeasure = (sal_Int32)( nMeasure >= 0
618cdf0e10cSrcweir ? ((nMeasure*127+36)/72)
619cdf0e10cSrcweir : ((nMeasure*127-36)/72) );
620cdf0e10cSrcweir // <--
621cdf0e10cSrcweir
622cdf0e10cSrcweir rtl::OUStringBuffer aBuffer;
623cdf0e10cSrcweir SvXMLUnitConverter::convertMeasure( aBuffer, nMeasure, MAP_100TH_MM, nDestUnit );
624cdf0e10cSrcweir aAttrValue = aBuffer.makeStringAndClear();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir
628cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
629cdf0e10cSrcweir }
630cdf0e10cSrcweir break;
631cdf0e10cSrcweir case XML_ATACTION_RENAME_DECODE_STYLE_NAME_REF:
632cdf0e10cSrcweir bRename = sal_True;
633cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME:
634cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME_REF:
635cdf0e10cSrcweir {
636cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
637cdf0e10cSrcweir if( DecodeStyleName(aAttrValue) )
638cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir break;
641cdf0e10cSrcweir case XML_ATACTION_ENCODE_STYLE_NAME:
642cdf0e10cSrcweir {
643cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
644cdf0e10cSrcweir if( EncodeStyleName(aAttrValue) )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
647cdf0e10cSrcweir OUString aNewAttrQName(
648cdf0e10cSrcweir GetNamespaceMap().GetQNameByKey(
649cdf0e10cSrcweir nPrefix,
650cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
651cdf0e10cSrcweir XML_DISPLAY_NAME ) ) );
652cdf0e10cSrcweir pMutableAttrList->AddAttribute( aNewAttrQName,
653cdf0e10cSrcweir rAttrValue );
654cdf0e10cSrcweir }
655cdf0e10cSrcweir }
656cdf0e10cSrcweir break;
657cdf0e10cSrcweir case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF:
658cdf0e10cSrcweir bRename = sal_True;
659cdf0e10cSrcweir case XML_ATACTION_ENCODE_STYLE_NAME_REF:
660cdf0e10cSrcweir {
661cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
662cdf0e10cSrcweir if( EncodeStyleName(aAttrValue) )
663cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
664cdf0e10cSrcweir }
665cdf0e10cSrcweir break;
666cdf0e10cSrcweir case XML_ATACTION_RENAME_NEG_PERCENT:
667cdf0e10cSrcweir bRename = sal_True;
668cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT:
669cdf0e10cSrcweir {
670cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
671cdf0e10cSrcweir if( NegPercent( aAttrValue ) )
672cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
673cdf0e10cSrcweir }
674cdf0e10cSrcweir break;
675cdf0e10cSrcweir case XML_ATACTION_RENAME_ADD_NAMESPACE_PREFIX:
676cdf0e10cSrcweir bRename = sal_True;
677cdf0e10cSrcweir case XML_ATACTION_ADD_NAMESPACE_PREFIX:
678cdf0e10cSrcweir {
679cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
680cdf0e10cSrcweir sal_uInt16 nValPrefix =
681cdf0e10cSrcweir static_cast<sal_uInt16>(
682cdf0e10cSrcweir bRename ? (*aIter).second.m_nParam2
683cdf0e10cSrcweir : (*aIter).second.m_nParam1);
684cdf0e10cSrcweir if( AddNamespacePrefix( aAttrValue, nValPrefix ) )
685cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
686cdf0e10cSrcweir }
687cdf0e10cSrcweir break;
688cdf0e10cSrcweir case XML_ATACTION_ADD_APP_NAMESPACE_PREFIX:
689cdf0e10cSrcweir {
690cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
691cdf0e10cSrcweir sal_uInt16 nValPrefix =
692cdf0e10cSrcweir static_cast<sal_uInt16>((*aIter).second.m_nParam1);
693cdf0e10cSrcweir if( IsXMLToken( GetClass(), XML_SPREADSHEET ) )
694cdf0e10cSrcweir nValPrefix = XML_NAMESPACE_OOOC;
695cdf0e10cSrcweir else if( IsXMLToken( GetClass(), XML_TEXT ) )
696cdf0e10cSrcweir nValPrefix = XML_NAMESPACE_OOOW;
697cdf0e10cSrcweir if( AddNamespacePrefix( aAttrValue, nValPrefix ) )
698cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir break;
701cdf0e10cSrcweir case XML_ATACTION_RENAME_REMOVE_NAMESPACE_PREFIX:
702cdf0e10cSrcweir bRename = sal_True;
703cdf0e10cSrcweir case XML_ATACTION_REMOVE_NAMESPACE_PREFIX:
704cdf0e10cSrcweir {
705cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
706cdf0e10cSrcweir sal_uInt16 nValPrefix =
707cdf0e10cSrcweir static_cast<sal_uInt16>(
708cdf0e10cSrcweir bRename ? (*aIter).second.m_nParam2
709cdf0e10cSrcweir : (*aIter).second.m_nParam1);
710cdf0e10cSrcweir if( RemoveNamespacePrefix( aAttrValue, nValPrefix ) )
711cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
712cdf0e10cSrcweir }
713cdf0e10cSrcweir break;
714cdf0e10cSrcweir case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX:
715cdf0e10cSrcweir {
716cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
717cdf0e10cSrcweir if( RemoveNamespacePrefix( aAttrValue ) )
718cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
719cdf0e10cSrcweir }
720cdf0e10cSrcweir break;
721cdf0e10cSrcweir case XML_ATACTION_URI_OOO:
722cdf0e10cSrcweir {
723cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
724cdf0e10cSrcweir if( ConvertURIToOASIS( aAttrValue,
725cdf0e10cSrcweir static_cast< sal_Bool >((*aIter).second.m_nParam1)))
726cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
727cdf0e10cSrcweir }
728cdf0e10cSrcweir break;
729cdf0e10cSrcweir case XML_ATACTION_URI_OASIS:
730cdf0e10cSrcweir {
731cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
732cdf0e10cSrcweir if( ConvertURIToOOo( aAttrValue,
733cdf0e10cSrcweir static_cast< sal_Bool >((*aIter).second.m_nParam1)))
734cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
735cdf0e10cSrcweir }
736cdf0e10cSrcweir break;
737cdf0e10cSrcweir case XML_ATACTION_RENAME_ATTRIBUTE:
738cdf0e10cSrcweir {
739cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
740cdf0e10cSrcweir RenameAttributeValue(
741cdf0e10cSrcweir aAttrValue,
742cdf0e10cSrcweir (*aIter).second.m_nParam1,
743cdf0e10cSrcweir (*aIter).second.m_nParam2,
744cdf0e10cSrcweir (*aIter).second.m_nParam3 );
745cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
746cdf0e10cSrcweir }
747cdf0e10cSrcweir break;
748cdf0e10cSrcweir case XML_ATACTION_RNG2ISO_DATETIME:
749cdf0e10cSrcweir {
750cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
751cdf0e10cSrcweir if( ConvertRNGDateTimeToISO( aAttrValue ))
752cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir break;
755cdf0e10cSrcweir case XML_ATACTION_RENAME_RNG2ISO_DATETIME:
756cdf0e10cSrcweir {
757cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
758cdf0e10cSrcweir if( ConvertRNGDateTimeToISO( aAttrValue ))
759cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
760cdf0e10cSrcweir bRename = sal_True;
761cdf0e10cSrcweir }
762cdf0e10cSrcweir break;
763cdf0e10cSrcweir case XML_ATACTION_IN2TWIPS:
764cdf0e10cSrcweir {
765cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
766cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInWithInch( aAttrValue );
767cdf0e10cSrcweir
768cdf0e10cSrcweir if( isWriter() )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir MapUnit nDestUnit = lcl_getUnit( aAttrValue );
771cdf0e10cSrcweir
772cdf0e10cSrcweir // convert inch value to twips and export as faked inch
773cdf0e10cSrcweir sal_Int32 nMeasure;
774cdf0e10cSrcweir if( SvXMLUnitConverter::convertMeasure(nMeasure, aAttrValue, MAP_100TH_MM ) )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir
777cdf0e10cSrcweir // --> OD 2004-10-29 #i13778#,#i36248#
778cdf0e10cSrcweir // apply correct 1/100mm-to-twip conversion
779cdf0e10cSrcweir nMeasure = (sal_Int32)( nMeasure >= 0
780cdf0e10cSrcweir ? ((nMeasure*72+63)/127)
781cdf0e10cSrcweir : ((nMeasure*72-63)/127) );
782cdf0e10cSrcweir // <--
783cdf0e10cSrcweir
784cdf0e10cSrcweir OUStringBuffer aBuffer;
785cdf0e10cSrcweir SvXMLUnitConverter::convertMeasure( aBuffer, nMeasure, MAP_100TH_MM, nDestUnit );
786cdf0e10cSrcweir aAttrValue = aBuffer.makeStringAndClear();
787cdf0e10cSrcweir }
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
790cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
791cdf0e10cSrcweir }
792cdf0e10cSrcweir break;
793cdf0e10cSrcweir case XML_ATACTION_SVG_WIDTH_HEIGHT_OOO:
794cdf0e10cSrcweir {
795cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
796cdf0e10cSrcweir ReplaceSingleInchWithIn( aAttrValue );
797cdf0e10cSrcweir
798cdf0e10cSrcweir MapUnit nDestUnit = lcl_getUnit( aAttrValue );
799cdf0e10cSrcweir
800cdf0e10cSrcweir sal_Int32 nMeasure;
801cdf0e10cSrcweir if( SvXMLUnitConverter::convertMeasure(nMeasure, aAttrValue, MAP_100TH_MM ) )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir
804cdf0e10cSrcweir if( nMeasure > 0 )
805cdf0e10cSrcweir nMeasure -= 1;
806cdf0e10cSrcweir else if( nMeasure < 0 )
807cdf0e10cSrcweir nMeasure += 1;
808cdf0e10cSrcweir
809cdf0e10cSrcweir
810cdf0e10cSrcweir OUStringBuffer aBuffer;
811cdf0e10cSrcweir SvXMLUnitConverter::convertMeasure( aBuffer, nMeasure, MAP_100TH_MM, nDestUnit );
812cdf0e10cSrcweir aAttrValue = aBuffer.makeStringAndClear();
813cdf0e10cSrcweir }
814cdf0e10cSrcweir
815cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
816cdf0e10cSrcweir }
817cdf0e10cSrcweir break;
818cdf0e10cSrcweir case XML_ATACTION_SVG_WIDTH_HEIGHT_OASIS:
819cdf0e10cSrcweir {
820cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
821cdf0e10cSrcweir ReplaceSingleInWithInch( aAttrValue );
822cdf0e10cSrcweir
823cdf0e10cSrcweir MapUnit nDestUnit = lcl_getUnit( aAttrValue );
824cdf0e10cSrcweir
825cdf0e10cSrcweir sal_Int32 nMeasure;
826cdf0e10cSrcweir if( SvXMLUnitConverter::convertMeasure(nMeasure, aAttrValue, MAP_100TH_MM ) )
827cdf0e10cSrcweir {
828cdf0e10cSrcweir
829cdf0e10cSrcweir if( nMeasure > 0 )
830cdf0e10cSrcweir nMeasure += 1;
831cdf0e10cSrcweir else if( nMeasure < 0 )
832cdf0e10cSrcweir nMeasure -= 1;
833cdf0e10cSrcweir
834cdf0e10cSrcweir
835cdf0e10cSrcweir OUStringBuffer aBuffer;
836cdf0e10cSrcweir SvXMLUnitConverter::convertMeasure( aBuffer, nMeasure, MAP_100TH_MM, nDestUnit );
837cdf0e10cSrcweir aAttrValue = aBuffer.makeStringAndClear();
838cdf0e10cSrcweir }
839cdf0e10cSrcweir
840cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
841cdf0e10cSrcweir }
842cdf0e10cSrcweir break;
843cdf0e10cSrcweir case XML_ATACTION_DECODE_ID:
844cdf0e10cSrcweir {
845cdf0e10cSrcweir OUString aAttrValue;
846cdf0e10cSrcweir
847cdf0e10cSrcweir const sal_Int32 nLen = rAttrValue.getLength();
848cdf0e10cSrcweir OUStringBuffer aBuffer;
849cdf0e10cSrcweir
850cdf0e10cSrcweir sal_Int32 pos;
851cdf0e10cSrcweir for( pos = 0; pos < nLen; pos++ )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir sal_Unicode c = rAttrValue[pos];
854cdf0e10cSrcweir if( (c >= '0') && (c <= '9') )
855cdf0e10cSrcweir aBuffer.append( c );
856cdf0e10cSrcweir else
857cdf0e10cSrcweir aBuffer.append( (sal_Int32)c );
858cdf0e10cSrcweir }
859cdf0e10cSrcweir
860cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aBuffer.makeStringAndClear() );
861cdf0e10cSrcweir }
862cdf0e10cSrcweir break;
863cdf0e10cSrcweir // --> OD 2005-06-10 #i50322# - special handling for the
864cdf0e10cSrcweir // transparency of writer background graphics.
865cdf0e10cSrcweir case XML_ATACTION_WRITER_BACK_GRAPHIC_TRANSPARENCY:
866cdf0e10cSrcweir {
867cdf0e10cSrcweir // determine, if it's the transparency of a document style
868cdf0e10cSrcweir XMLTransformerContext* pFirstContext = (*m_pContexts)[0].get();
869cdf0e10cSrcweir OUString aFirstContextLocalName;
870cdf0e10cSrcweir /* sal_uInt16 nFirstContextPrefix = */
871cdf0e10cSrcweir GetNamespaceMap().GetKeyByAttrName( pFirstContext->GetQName(),
872cdf0e10cSrcweir &aFirstContextLocalName );
873cdf0e10cSrcweir bool bIsDocumentStyle(
874cdf0e10cSrcweir ::xmloff::token::IsXMLToken( aFirstContextLocalName,
875cdf0e10cSrcweir XML_DOCUMENT_STYLES ) );
876cdf0e10cSrcweir // no conversion of transparency value for document
877cdf0e10cSrcweir // styles, because former OpenOffice.org version writes
878cdf0e10cSrcweir // writes always a transparency value of 100% and doesn't
879cdf0e10cSrcweir // read the value. Thus, it's intepreted as 0%
880cdf0e10cSrcweir if ( !bIsDocumentStyle )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
883cdf0e10cSrcweir NegPercent(aAttrValue);
884cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
885cdf0e10cSrcweir }
886cdf0e10cSrcweir bRename = sal_True;
887cdf0e10cSrcweir }
888cdf0e10cSrcweir break;
889cdf0e10cSrcweir // <--
890cdf0e10cSrcweir case XML_ATACTION_SHAPEID:
891cdf0e10cSrcweir {
892cdf0e10cSrcweir OUString sNewValue( RTL_CONSTASCII_USTRINGPARAM( "shape" ) );
893cdf0e10cSrcweir sNewValue += rAttrValue;
894cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, sNewValue );
895cdf0e10cSrcweir break;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir
898cdf0e10cSrcweir default:
899cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" );
900cdf0e10cSrcweir break;
901cdf0e10cSrcweir }
902cdf0e10cSrcweir
903cdf0e10cSrcweir if( bRename )
904cdf0e10cSrcweir {
905cdf0e10cSrcweir OUString aNewAttrQName(
906cdf0e10cSrcweir GetNamespaceMap().GetQNameByKey(
907cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
908cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
909cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) );
910cdf0e10cSrcweir pMutableAttrList->RenameAttributeByIndex( i,
911cdf0e10cSrcweir aNewAttrQName );
912cdf0e10cSrcweir }
913cdf0e10cSrcweir }
914cdf0e10cSrcweir }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
917cdf0e10cSrcweir return pMutableAttrList;
918cdf0e10cSrcweir }
919cdf0e10cSrcweir
ReplaceSingleInchWithIn(OUString & rValue)920cdf0e10cSrcweir sal_Bool XMLTransformerBase::ReplaceSingleInchWithIn( OUString& rValue )
921cdf0e10cSrcweir {
922cdf0e10cSrcweir sal_Bool bRet = sal_False;
923cdf0e10cSrcweir sal_Int32 nPos = rValue.getLength();
924cdf0e10cSrcweir while( nPos && rValue[nPos-1] <= ' ' )
925cdf0e10cSrcweir --nPos;
926cdf0e10cSrcweir if( nPos > 2 &&
927cdf0e10cSrcweir ('c'==rValue[nPos-2] || 'C'==rValue[nPos-2]) &&
928cdf0e10cSrcweir ('h'==rValue[nPos-1] || 'H'==rValue[nPos-1]) )
929cdf0e10cSrcweir {
930cdf0e10cSrcweir rValue =rValue.copy( 0, nPos-2 );
931cdf0e10cSrcweir bRet = sal_True;
932cdf0e10cSrcweir }
933cdf0e10cSrcweir
934cdf0e10cSrcweir return bRet;
935cdf0e10cSrcweir }
936cdf0e10cSrcweir
ReplaceInchWithIn(OUString & rValue)937cdf0e10cSrcweir sal_Bool XMLTransformerBase::ReplaceInchWithIn( OUString& rValue )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir sal_Bool bRet = sal_False;
940cdf0e10cSrcweir sal_Int32 nPos = 1;
941cdf0e10cSrcweir while( nPos < rValue.getLength()-3 )
942cdf0e10cSrcweir {
943cdf0e10cSrcweir sal_Unicode c = rValue[nPos];
944cdf0e10cSrcweir if( 'i'==c || 'I'==c )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir c = rValue[nPos-1];
947cdf0e10cSrcweir if( (c >= '0' && c <= '9') || '.' == c )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir c = rValue[nPos+1];
950cdf0e10cSrcweir if( 'n'==c || 'N'==c )
951cdf0e10cSrcweir {
952cdf0e10cSrcweir c = rValue[nPos+2];
953cdf0e10cSrcweir if( 'c'==c || 'C'==c )
954cdf0e10cSrcweir {
955cdf0e10cSrcweir c = rValue[nPos+3];
956cdf0e10cSrcweir if( 'h'==c || 'H'==c )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir rValue = rValue.replaceAt( nPos,
959cdf0e10cSrcweir 4, GetXMLToken(XML_UNIT_INCH) );
960cdf0e10cSrcweir nPos += 2;
961cdf0e10cSrcweir bRet = sal_True;
962cdf0e10cSrcweir continue;
963cdf0e10cSrcweir }
964cdf0e10cSrcweir }
965cdf0e10cSrcweir }
966cdf0e10cSrcweir }
967cdf0e10cSrcweir }
968cdf0e10cSrcweir ++nPos;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir
971cdf0e10cSrcweir return bRet;
972cdf0e10cSrcweir }
973cdf0e10cSrcweir
ReplaceSingleInWithInch(OUString & rValue)974cdf0e10cSrcweir sal_Bool XMLTransformerBase::ReplaceSingleInWithInch( OUString& rValue )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir sal_Bool bRet = sal_False;
977cdf0e10cSrcweir
978cdf0e10cSrcweir sal_Int32 nPos = rValue.getLength();
979cdf0e10cSrcweir while( nPos && rValue[nPos-1] <= ' ' )
980cdf0e10cSrcweir --nPos;
981cdf0e10cSrcweir if( nPos > 2 &&
982cdf0e10cSrcweir ('i'==rValue[nPos-2] ||
983cdf0e10cSrcweir 'I'==rValue[nPos-2]) &&
984cdf0e10cSrcweir ('n'==rValue[nPos-1] ||
985cdf0e10cSrcweir 'N'==rValue[nPos-1]) )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir nPos -= 2;
988cdf0e10cSrcweir rValue = rValue.replaceAt( nPos, rValue.getLength() - nPos,
989cdf0e10cSrcweir GetXMLToken(XML_INCH) );
990cdf0e10cSrcweir bRet = sal_True;
991cdf0e10cSrcweir }
992cdf0e10cSrcweir
993cdf0e10cSrcweir return bRet;
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
ReplaceInWithInch(OUString & rValue)996cdf0e10cSrcweir sal_Bool XMLTransformerBase::ReplaceInWithInch( OUString& rValue )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir sal_Bool bRet = sal_False;
999cdf0e10cSrcweir sal_Int32 nPos = 1;
1000cdf0e10cSrcweir while( nPos < rValue.getLength()-1 )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir sal_Unicode c = rValue[nPos];
1003cdf0e10cSrcweir if( 'i'==c || 'I'==c )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir c = rValue[nPos-1];
1006cdf0e10cSrcweir if( (c >= '0' && c <= '9') || '.' == c )
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir c = rValue[nPos+1];
1009cdf0e10cSrcweir if( 'n'==c || 'N'==c )
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir rValue = rValue.replaceAt( nPos,
1012cdf0e10cSrcweir 2, GetXMLToken(XML_INCH) );
1013cdf0e10cSrcweir nPos += 4;
1014cdf0e10cSrcweir bRet = sal_True;
1015cdf0e10cSrcweir continue;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir ++nPos;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir return bRet;
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir
EncodeStyleName(OUString & rName) const1025cdf0e10cSrcweir sal_Bool XMLTransformerBase::EncodeStyleName( OUString& rName ) const
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir static sal_Char aHexTab[] = "0123456789abcdef";
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir sal_Bool bEncoded = sal_False;
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir sal_Int32 nLen = rName.getLength();
1032cdf0e10cSrcweir OUStringBuffer aBuffer( nLen );
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; i++ )
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir sal_Unicode c = rName[i];
1037cdf0e10cSrcweir sal_Bool bValidChar = sal_False;
1038cdf0e10cSrcweir if( c < 0x00ffU )
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir bValidChar =
1041cdf0e10cSrcweir (c >= 0x0041 && c <= 0x005a) ||
1042cdf0e10cSrcweir (c >= 0x0061 && c <= 0x007a) ||
1043cdf0e10cSrcweir (c >= 0x00c0 && c <= 0x00d6) ||
1044cdf0e10cSrcweir (c >= 0x00d8 && c <= 0x00f6) ||
1045cdf0e10cSrcweir (c >= 0x00f8 && c <= 0x00ff) ||
1046cdf0e10cSrcweir ( i > 0 && ( (c >= 0x0030 && c <= 0x0039) ||
1047cdf0e10cSrcweir c == 0x00b7 || c == '-' || c == '.') );
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir else
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir if( (c >= 0xf900U && c <= 0xfffeU) ||
1052cdf0e10cSrcweir (c >= 0x20ddU && c <= 0x20e0U))
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir bValidChar = sal_False;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir else if( (c >= 0x02bbU && c <= 0x02c1U) || c == 0x0559 ||
1057cdf0e10cSrcweir c == 0x06e5 || c == 0x06e6 )
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir bValidChar = sal_True;
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir else if( c == 0x0387 )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir bValidChar = i > 0;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir else
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir if( !xCharClass.is() )
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory =
1070cdf0e10cSrcweir comphelper::getProcessServiceFactory();
1071cdf0e10cSrcweir if( xFactory.is() )
1072cdf0e10cSrcweir {
1073cdf0e10cSrcweir try
1074cdf0e10cSrcweir {
1075cdf0e10cSrcweir const_cast < XMLTransformerBase * >(this)
1076cdf0e10cSrcweir ->xCharClass =
1077cdf0e10cSrcweir Reference < XCharacterClassification >(
1078cdf0e10cSrcweir xFactory->createInstance(
1079cdf0e10cSrcweir OUString::createFromAscii(
1080cdf0e10cSrcweir "com.sun.star.i18n.CharacterClassification_Unicode") ),
1081cdf0e10cSrcweir UNO_QUERY );
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir OSL_ENSURE( xCharClass.is(),
1084cdf0e10cSrcweir "can't instantiate character clossification component" );
1085cdf0e10cSrcweir }
1086cdf0e10cSrcweir catch( com::sun::star::uno::Exception& )
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir if( xCharClass.is() )
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir sal_Int16 nType = xCharClass->getType( rName, i );
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir switch( nType )
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir case UnicodeType::UPPERCASE_LETTER: // Lu
1098cdf0e10cSrcweir case UnicodeType::LOWERCASE_LETTER: // Ll
1099cdf0e10cSrcweir case UnicodeType::TITLECASE_LETTER: // Lt
1100cdf0e10cSrcweir case UnicodeType::OTHER_LETTER: // Lo
1101cdf0e10cSrcweir case UnicodeType::LETTER_NUMBER: // Nl
1102cdf0e10cSrcweir bValidChar = sal_True;
1103cdf0e10cSrcweir break;
1104cdf0e10cSrcweir case UnicodeType::NON_SPACING_MARK: // Ms
1105cdf0e10cSrcweir case UnicodeType::ENCLOSING_MARK: // Me
1106cdf0e10cSrcweir case UnicodeType::COMBINING_SPACING_MARK: //Mc
1107cdf0e10cSrcweir case UnicodeType::MODIFIER_LETTER: // Lm
1108cdf0e10cSrcweir case UnicodeType::DECIMAL_DIGIT_NUMBER: // Nd
1109cdf0e10cSrcweir bValidChar = i > 0;
1110cdf0e10cSrcweir break;
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir }
1115cdf0e10cSrcweir if( bValidChar )
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir aBuffer.append( c );
1118cdf0e10cSrcweir }
1119cdf0e10cSrcweir else
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >( '_' ) );
1122cdf0e10cSrcweir if( c > 0x0fff )
1123cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >(
1124cdf0e10cSrcweir aHexTab[ (c >> 12) & 0x0f ] ) );
1125cdf0e10cSrcweir if( c > 0x00ff )
1126cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >(
1127cdf0e10cSrcweir aHexTab[ (c >> 8) & 0x0f ] ) );
1128cdf0e10cSrcweir if( c > 0x000f )
1129cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >(
1130cdf0e10cSrcweir aHexTab[ (c >> 4) & 0x0f ] ) );
1131cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >(
1132cdf0e10cSrcweir aHexTab[ c & 0x0f ] ) );
1133cdf0e10cSrcweir aBuffer.append( static_cast< sal_Unicode >( '_' ) );
1134cdf0e10cSrcweir bEncoded = sal_True;
1135cdf0e10cSrcweir }
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
1138cdf0e10cSrcweir if( aBuffer.getLength() > (1<<15)-1 )
1139cdf0e10cSrcweir bEncoded = sal_False;
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir if( bEncoded )
1142cdf0e10cSrcweir rName = aBuffer.makeStringAndClear();
1143cdf0e10cSrcweir return bEncoded;
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir
DecodeStyleName(OUString & rName)1146cdf0e10cSrcweir sal_Bool XMLTransformerBase::DecodeStyleName( OUString& rName )
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir sal_Bool bEncoded = sal_False;
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir sal_Int32 nLen = rName.getLength();
1151cdf0e10cSrcweir OUStringBuffer aBuffer( nLen );
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir sal_Bool bWithinHex = sal_False;
1154cdf0e10cSrcweir sal_Unicode cEnc = 0;
1155cdf0e10cSrcweir for( sal_Int32 i = 0; i < nLen; i++ )
1156cdf0e10cSrcweir {
1157cdf0e10cSrcweir sal_Unicode c = rName[i];
1158cdf0e10cSrcweir if( '_' == c )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir if( bWithinHex )
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir aBuffer.append( cEnc );
1163cdf0e10cSrcweir cEnc = 0;
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir else
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir bEncoded = sal_True;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir bWithinHex = !bWithinHex;
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir else if( bWithinHex )
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir sal_Unicode cDigit;
1174cdf0e10cSrcweir if( c >= '0' && c <= '9' )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir cDigit = c - '0';
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir else if( c >= 'a' && c <= 'f' )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir cDigit = c - 'a' + 10;
1181cdf0e10cSrcweir }
1182cdf0e10cSrcweir else if( c >= 'A' && c <= 'F' )
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir cDigit = c - 'A' + 10;
1185cdf0e10cSrcweir }
1186cdf0e10cSrcweir else
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir // error
1189cdf0e10cSrcweir bEncoded = sal_False;
1190cdf0e10cSrcweir break;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir cEnc = (cEnc << 4) + cDigit;
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir else
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir aBuffer.append( c );
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir if( bEncoded )
1201cdf0e10cSrcweir rName = aBuffer.makeStringAndClear();
1202cdf0e10cSrcweir return bEncoded;
1203cdf0e10cSrcweir }
1204cdf0e10cSrcweir
NegPercent(OUString & rValue)1205cdf0e10cSrcweir sal_Bool XMLTransformerBase::NegPercent( OUString& rValue )
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir sal_Bool bRet = sal_False;
1208cdf0e10cSrcweir sal_Bool bNeg = sal_False;
1209cdf0e10cSrcweir double nVal = 0;
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir sal_Int32 nPos = 0;
1212cdf0e10cSrcweir sal_Int32 nLen = rValue.getLength();
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir // skip white space
1215cdf0e10cSrcweir while( nPos < nLen && sal_Unicode(' ') == rValue[nPos] )
1216cdf0e10cSrcweir nPos++;
1217cdf0e10cSrcweir
1218cdf0e10cSrcweir if( nPos < nLen && sal_Unicode('-') == rValue[nPos] )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir bNeg = sal_True;
1221cdf0e10cSrcweir nPos++;
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir // get number
1225cdf0e10cSrcweir while( nPos < nLen &&
1226cdf0e10cSrcweir sal_Unicode('0') <= rValue[nPos] &&
1227cdf0e10cSrcweir sal_Unicode('9') >= rValue[nPos] )
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir // TODO: check overflow!
1230cdf0e10cSrcweir nVal *= 10;
1231cdf0e10cSrcweir nVal += (rValue[nPos] - sal_Unicode('0'));
1232cdf0e10cSrcweir nPos++;
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir double nDiv = 1.;
1235cdf0e10cSrcweir if( nPos < nLen && sal_Unicode('.') == rValue[nPos] )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir nPos++;
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir while( nPos < nLen &&
1240cdf0e10cSrcweir sal_Unicode('0') <= rValue[nPos] &&
1241cdf0e10cSrcweir sal_Unicode('9') >= rValue[nPos] )
1242cdf0e10cSrcweir {
1243cdf0e10cSrcweir // TODO: check overflow!
1244cdf0e10cSrcweir nDiv *= 10;
1245cdf0e10cSrcweir nVal += ( static_cast<double>(rValue[nPos] - sal_Unicode('0')) / nDiv );
1246cdf0e10cSrcweir nPos++;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir // skip white space
1251cdf0e10cSrcweir while( nPos < nLen && sal_Unicode(' ') == rValue[nPos] )
1252cdf0e10cSrcweir nPos++;
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir if( nPos < nLen && sal_Unicode('%') == rValue[nPos] )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir if( bNeg )
1257cdf0e10cSrcweir nVal = -nVal;
1258cdf0e10cSrcweir nVal += .5;
1259cdf0e10cSrcweir
1260cdf0e10cSrcweir sal_Int32 nIntVal = 100 - static_cast<sal_Int32>( nVal );
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir OUStringBuffer aNewValBuffer;
1263cdf0e10cSrcweir aNewValBuffer.append( nIntVal );
1264cdf0e10cSrcweir aNewValBuffer.append( sal_Unicode('%' ) );
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir rValue = aNewValBuffer.makeStringAndClear();
1267cdf0e10cSrcweir bRet = sal_True;
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir return bRet;
1271cdf0e10cSrcweir }
1272cdf0e10cSrcweir
AddNamespacePrefix(::rtl::OUString & rName,sal_uInt16 nPrefix) const1273cdf0e10cSrcweir sal_Bool XMLTransformerBase::AddNamespacePrefix( ::rtl::OUString& rName,
1274cdf0e10cSrcweir sal_uInt16 nPrefix ) const
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir rName = GetNamespaceMap().GetQNameByKey( nPrefix, rName, sal_False );
1277cdf0e10cSrcweir return sal_True;
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir
RemoveNamespacePrefix(::rtl::OUString & rName,sal_uInt16 nPrefixOnly) const1280cdf0e10cSrcweir sal_Bool XMLTransformerBase::RemoveNamespacePrefix( ::rtl::OUString& rName,
1281cdf0e10cSrcweir sal_uInt16 nPrefixOnly ) const
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir OUString aLocalName;
1284cdf0e10cSrcweir sal_uInt16 nPrefix =
1285cdf0e10cSrcweir GetNamespaceMap()._GetKeyByAttrName( rName, &aLocalName, sal_False );
1286cdf0e10cSrcweir sal_Bool bRet = XML_NAMESPACE_UNKNOWN != nPrefix &&
1287cdf0e10cSrcweir (USHRT_MAX == nPrefixOnly || nPrefix == nPrefixOnly);
1288cdf0e10cSrcweir if( bRet )
1289cdf0e10cSrcweir rName = aLocalName;
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir return bRet;
1292cdf0e10cSrcweir }
1293cdf0e10cSrcweir
ConvertURIToOASIS(::rtl::OUString & rURI,sal_Bool bSupportPackage) const1294cdf0e10cSrcweir sal_Bool XMLTransformerBase::ConvertURIToOASIS( ::rtl::OUString& rURI,
1295cdf0e10cSrcweir sal_Bool bSupportPackage ) const
1296cdf0e10cSrcweir {
1297cdf0e10cSrcweir sal_Bool bRet = sal_False;
1298cdf0e10cSrcweir if( m_aExtPathPrefix.getLength() && rURI.getLength() )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir sal_Bool bRel = sal_False;
1301cdf0e10cSrcweir switch( rURI[0] )
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir case '#':
1304cdf0e10cSrcweir // no rel path, but
1305cdf0e10cSrcweir // for package URIs, the '#' has to be removed
1306cdf0e10cSrcweir if( bSupportPackage )
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir rURI = rURI.copy( 1 );
1309cdf0e10cSrcweir bRet = sal_True;
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir break;
1312cdf0e10cSrcweir case '/':
1313cdf0e10cSrcweir // no rel path; nothing to do
1314cdf0e10cSrcweir break;
1315cdf0e10cSrcweir case '.':
1316cdf0e10cSrcweir // a rel path; to keep URI simple, remove './', if there
1317cdf0e10cSrcweir bRel = sal_True;
1318cdf0e10cSrcweir if( rURI.getLength() > 1 && '/' == rURI[1] )
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir rURI = rURI.copy( 2 );
1321cdf0e10cSrcweir bRet = sal_True;
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir break;
1324cdf0e10cSrcweir default:
1325cdf0e10cSrcweir // check for a RFC2396 schema
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir bRel = sal_True;
1328cdf0e10cSrcweir sal_Int32 nPos = 1;
1329cdf0e10cSrcweir sal_Int32 nLen = rURI.getLength();
1330cdf0e10cSrcweir while( nPos < nLen )
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir switch( rURI[nPos] )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir case '/':
1335cdf0e10cSrcweir // a relative path segement
1336cdf0e10cSrcweir nPos = nLen; // leave loop
1337cdf0e10cSrcweir break;
1338cdf0e10cSrcweir case ':':
1339cdf0e10cSrcweir // a schema
1340cdf0e10cSrcweir bRel = sal_False;
1341cdf0e10cSrcweir nPos = nLen; // leave loop
1342cdf0e10cSrcweir break;
1343cdf0e10cSrcweir default:
1344cdf0e10cSrcweir // we don't care about any other characters
1345cdf0e10cSrcweir break;
1346cdf0e10cSrcweir }
1347cdf0e10cSrcweir ++nPos;
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir
1352cdf0e10cSrcweir if( bRel )
1353cdf0e10cSrcweir {
1354cdf0e10cSrcweir OUString sTmp( m_aExtPathPrefix );
1355cdf0e10cSrcweir sTmp += rURI;
1356cdf0e10cSrcweir rURI = sTmp;
1357cdf0e10cSrcweir bRet = sal_True;
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir
1361cdf0e10cSrcweir return bRet;
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir
ConvertURIToOOo(::rtl::OUString & rURI,sal_Bool bSupportPackage) const1364cdf0e10cSrcweir sal_Bool XMLTransformerBase::ConvertURIToOOo( ::rtl::OUString& rURI,
1365cdf0e10cSrcweir sal_Bool bSupportPackage ) const
1366cdf0e10cSrcweir {
1367cdf0e10cSrcweir sal_Bool bRet = sal_False;
1368cdf0e10cSrcweir if( rURI.getLength() )
1369cdf0e10cSrcweir {
1370cdf0e10cSrcweir sal_Bool bPackage = sal_False;
1371cdf0e10cSrcweir switch( rURI[0] )
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir case '/':
1374cdf0e10cSrcweir // no rel path; nothing to to
1375cdf0e10cSrcweir break;
1376cdf0e10cSrcweir case '.':
1377cdf0e10cSrcweir // a rel path
1378cdf0e10cSrcweir if( 0 == rURI.compareTo( m_aExtPathPrefix,
1379cdf0e10cSrcweir m_aExtPathPrefix.getLength() ) )
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir // an external URI; remove '../'
1382cdf0e10cSrcweir rURI = rURI.copy( m_aExtPathPrefix.getLength() );
1383cdf0e10cSrcweir bRet = sal_True;
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir else
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir bPackage = sal_True;
1388cdf0e10cSrcweir }
1389cdf0e10cSrcweir break;
1390cdf0e10cSrcweir default:
1391cdf0e10cSrcweir // check for a RFC2396 schema
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir bPackage = sal_True;
1394cdf0e10cSrcweir sal_Int32 nPos = 1;
1395cdf0e10cSrcweir sal_Int32 nLen = rURI.getLength();
1396cdf0e10cSrcweir while( nPos < nLen )
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir switch( rURI[nPos] )
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir case '/':
1401cdf0e10cSrcweir // a relative path segement within the package
1402cdf0e10cSrcweir nPos = nLen; // leave loop
1403cdf0e10cSrcweir break;
1404cdf0e10cSrcweir case ':':
1405cdf0e10cSrcweir // a schema
1406cdf0e10cSrcweir bPackage = sal_False;
1407cdf0e10cSrcweir nPos = nLen; // leave loop
1408cdf0e10cSrcweir break;
1409cdf0e10cSrcweir default:
1410cdf0e10cSrcweir // we don't care about any other characters
1411cdf0e10cSrcweir break;
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir ++nPos;
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir }
1416cdf0e10cSrcweir }
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir if( bPackage && bSupportPackage )
1419cdf0e10cSrcweir {
1420cdf0e10cSrcweir OUString sTmp( OUString::valueOf( sal_Unicode( '#' ) ) );
1421cdf0e10cSrcweir if( 0 == rURI.compareToAscii( "./", 2 ) )
1422cdf0e10cSrcweir rURI = rURI.copy( 2 );
1423cdf0e10cSrcweir sTmp += rURI;
1424cdf0e10cSrcweir rURI = sTmp;
1425cdf0e10cSrcweir bRet = sal_True;
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir
1429cdf0e10cSrcweir return bRet;
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir
RenameAttributeValue(OUString & rOutAttributeValue,sal_Int32 nParam1,sal_Int32 nParam2,sal_Int32 nParam3)1432cdf0e10cSrcweir sal_Bool XMLTransformerBase::RenameAttributeValue(
1433cdf0e10cSrcweir OUString& rOutAttributeValue,
1434cdf0e10cSrcweir sal_Int32 nParam1,
1435cdf0e10cSrcweir sal_Int32 nParam2,
1436cdf0e10cSrcweir sal_Int32 nParam3 )
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir return ( lcl_ConvertAttr( rOutAttributeValue, nParam1) ||
1439cdf0e10cSrcweir lcl_ConvertAttr( rOutAttributeValue, nParam2) ||
1440cdf0e10cSrcweir lcl_ConvertAttr( rOutAttributeValue, nParam3) );
1441cdf0e10cSrcweir }
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir // static
ConvertRNGDateTimeToISO(::rtl::OUString & rDateTime)1444cdf0e10cSrcweir bool XMLTransformerBase::ConvertRNGDateTimeToISO( ::rtl::OUString& rDateTime )
1445cdf0e10cSrcweir {
1446cdf0e10cSrcweir if( rDateTime.getLength() > 0 &&
1447cdf0e10cSrcweir rDateTime.indexOf( sal_Unicode('.')) != -1 )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir rDateTime = rDateTime.replace( sal_Unicode('.'), sal_Unicode(','));
1450cdf0e10cSrcweir return true;
1451cdf0e10cSrcweir }
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir return false;
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir
GetToken(const OUString & rStr) const1456cdf0e10cSrcweir XMLTokenEnum XMLTransformerBase::GetToken( const OUString& rStr ) const
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir XMLTransformerTokenMap::const_iterator aIter =
1459cdf0e10cSrcweir m_pTokenMap->find( rStr );
1460cdf0e10cSrcweir if( aIter == m_pTokenMap->end() )
1461cdf0e10cSrcweir return XML_TOKEN_END;
1462cdf0e10cSrcweir else
1463cdf0e10cSrcweir return (*aIter).second;
1464cdf0e10cSrcweir }
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir
1467cdf0e10cSrcweir
GetCurrentContext() const1468cdf0e10cSrcweir const XMLTransformerContext *XMLTransformerBase::GetCurrentContext() const
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir OSL_ENSURE( !m_pContexts->empty(), "empty stack" );
1471cdf0e10cSrcweir
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir return m_pContexts->empty() ? 0 : m_pContexts->back().get();
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir
GetAncestorContext(sal_uInt32 n) const1476cdf0e10cSrcweir const XMLTransformerContext *XMLTransformerBase::GetAncestorContext(
1477cdf0e10cSrcweir sal_uInt32 n ) const
1478cdf0e10cSrcweir {
1479cdf0e10cSrcweir XMLTransformerContextVector::size_type nSize =
1480cdf0e10cSrcweir m_pContexts->size();
1481cdf0e10cSrcweir XMLTransformerContextVector::size_type nPos =
1482cdf0e10cSrcweir static_cast<XMLTransformerContextVector::size_type>( n );
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir OSL_ENSURE( nSize >nPos+2 , "invalid context" );
1485cdf0e10cSrcweir
1486cdf0e10cSrcweir return nSize > nPos+2 ? (*m_pContexts)[nSize-(nPos+2)].get() : 0;
1487cdf0e10cSrcweir }
1488cdf0e10cSrcweir
isWriter() const1489cdf0e10cSrcweir bool XMLTransformerBase::isWriter() const
1490cdf0e10cSrcweir {
1491cdf0e10cSrcweir Reference< XServiceInfo > xSI( mxModel, UNO_QUERY );
1492cdf0e10cSrcweir return xSI.is() &&
1493cdf0e10cSrcweir ( xSI->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) ) ||
1494cdf0e10cSrcweir xSI->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) ) ||
1495cdf0e10cSrcweir xSI->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) ) );
1496cdf0e10cSrcweir }
1497