LibreOffice Module xmloff (master)  1
TransformerBase.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 <rtl/ref.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <osl/diagnose.h>
23 #include <com/sun/star/i18n/CharacterClassification.hpp>
24 #include <com/sun/star/i18n/UnicodeType.hpp>
25 #include <com/sun/star/util/MeasureUnit.hpp>
26 #include <sax/tools/converter.hxx>
28 #include <xmloff/nmspmap.hxx>
29 #include <xmloff/xmlnmspe.hxx>
30 #include "IgnoreTContext.hxx"
31 #include "RenameElemTContext.hxx"
32 #include "ProcAttrTContext.hxx"
33 #include "ProcAddAttrTContext.hxx"
34 #include "MergeElemTContext.hxx"
35 #include "CreateElemTContext.hxx"
36 #include "MutableAttrList.hxx"
37 #include "TransformerActions.hxx"
39 #include "PropertyActionsOOo.hxx"
40 #include "TransformerTokenMap.hxx"
41 
42 #include "TransformerBase.hxx"
43 #include <xmloff/xmlimp.hxx>
44 
45 using namespace ::osl;
46 using namespace ::xmloff::token;
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::i18n;
52 using namespace ::com::sun::star::xml::sax;
53 
54 namespace
55 {
56 bool lcl_ConvertAttr( OUString & rOutAttribute, sal_Int32 nParam )
57 {
58  bool bResult = false;
59  enum XMLTokenEnum eTokenToRename =
60  static_cast< enum XMLTokenEnum >( nParam & 0xffff );
61  if( eTokenToRename != XML_TOKEN_INVALID &&
62  IsXMLToken( rOutAttribute, eTokenToRename ))
63  {
64  enum XMLTokenEnum eReplacementToken =
65  static_cast< enum XMLTokenEnum >( nParam >> 16 );
66  rOutAttribute = GetXMLToken( eReplacementToken );
67  bResult = true;
68  }
69  return bResult;
70 }
71 } // anonymous namespace
72 
74  const OUString& rLocalName, const OUString& rQName )
75 {
76  XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
77  XMLTransformerActions::const_iterator aIter =
78  GetElemActions().find( aKey );
79 
80  if( aIter != GetElemActions().end() )
81  {
82  sal_uInt32 nActionType = (*aIter).second.m_nActionType;
83  if( (nActionType & XML_ETACTION_USER_DEFINED) != 0 )
84  {
85  XMLTransformerContext *pContext =
86  CreateUserDefinedContext( (*aIter).second,
87  rQName );
88  OSL_ENSURE( pContext && !pContext->IsPersistent(),
89  "unknown or not persistent action" );
90  return pContext;
91  }
92 
93  switch( nActionType )
94  {
96  return new XMLIgnoreTransformerContext( *this, rQName, false,
97  false );
98  case XML_ETACTION_COPY:
99  return new XMLTransformerContext( *this, rQName );
101  return new XMLRenameElemTransformerContext( *this, rQName,
102  (*aIter).second.GetQNamePrefixFromParam1(),
103  (*aIter).second.GetQNameTokenFromParam1() );
105  return new XMLRenameElemTransformerContext( *this, rQName,
106  (*aIter).second.GetQNamePrefixFromParam1(),
107  (*aIter).second.GetQNameTokenFromParam1(),
108  (*aIter).second.GetQNamePrefixFromParam2(),
109  (*aIter).second.GetQNameTokenFromParam2(),
110  static_cast< XMLTokenEnum >( (*aIter).second.m_nParam3 ) );
112  return new XMLProcAttrTransformerContext( *this, rQName,
113  (*aIter).second.GetQNamePrefixFromParam1(),
114  (*aIter).second.GetQNameTokenFromParam1(),
115  static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
117  return new XMLProcAddAttrTransformerContext( *this, rQName,
118  (*aIter).second.GetQNamePrefixFromParam1(),
119  (*aIter).second.GetQNameTokenFromParam1(),
120  static_cast< sal_uInt16 >(
121  (*aIter).second.m_nParam3 >> 16 ),
122  (*aIter).second.GetQNamePrefixFromParam2(),
123  (*aIter).second.GetQNameTokenFromParam2(),
124  static_cast< XMLTokenEnum >(
125  (*aIter).second.m_nParam3 & 0xffff ) );
127  {
128  const XMLTransformerContext *pCurrent = GetCurrentContext();
129  if( pCurrent->HasQName(
130  (*aIter).second.GetQNamePrefixFromParam3(),
131  (*aIter).second.GetQNameTokenFromParam3() ) )
132  return new XMLProcAttrTransformerContext( *this, rQName,
133  (*aIter).second.GetQNamePrefixFromParam1(),
134  (*aIter).second.GetQNameTokenFromParam1(),
135  static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
136  else
137  return new XMLProcAttrTransformerContext( *this, rQName,
138  static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
139  }
141  return new XMLProcAttrTransformerContext( *this, rQName,
142  static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
144  {
145  const XMLTransformerContext *pCurrent = GetCurrentContext();
146  if( pCurrent->HasQName(
147  (*aIter).second.GetQNamePrefixFromParam1(),
148  (*aIter).second.GetQNameTokenFromParam1() ) )
149  return new XMLProcAttrTransformerContext( *this, rQName,
150  static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
151  }
152  break;
154  return new XMLCreateElemTransformerContext( *this, rQName,
155  static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
157  return new XMLMergeElemTransformerContext( *this, rQName,
158  static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
159  default:
160  OSL_ENSURE( false, "unknown action" );
161  break;
162  }
163  }
164 
165  // default is copying
166  return new XMLTransformerContext( *this, rQName );
167 }
168 
170 {
171  return nullptr;
172 }
173 
175  ::xmloff::token::XMLTokenEnum const *pTKMapInit )
176  throw () :
177  m_pNamespaceMap( new SvXMLNamespaceMap ),
178  m_ElemActions( pInit ),
179  m_TokenMap( pTKMapInit )
180 {
182  GetNamespaceMap().Add( GetXMLToken(XML_NP_DC), GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
183  GetNamespaceMap().Add( GetXMLToken(XML_NP_MATH), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
184  GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
185  GetNamespaceMap().Add( GetXMLToken(XML_NP_DOM), GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
186  GetNamespaceMap().Add( GetXMLToken(XML_NP_OOOW), GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
187  GetNamespaceMap().Add( GetXMLToken(XML_NP_OOOC), GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
188 }
189 
191 {
192 }
193 
195 {
196  m_xHandler->startDocument();
197 }
198 
200 {
201  m_xHandler->endDocument();
202 }
203 
204 void SAL_CALL XMLTransformerBase::startElement( const OUString& rName,
205  const Reference< XAttributeList >& rAttrList )
206 {
207  std::unique_ptr<SvXMLNamespaceMap> pRewindMap;
208 
209  // Process namespace attributes. This must happen before creating the
210  // context, because namespace declaration apply to the element name itself.
211  XMLMutableAttributeList *pMutableAttrList = nullptr;
212  Reference< XAttributeList > xAttrList( rAttrList );
213  sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
214  for( sal_Int16 i=0; i < nAttrCount; i++ )
215  {
216  const OUString& rAttrName = xAttrList->getNameByIndex( i );
217  if( ( rAttrName.getLength() >= 5 ) &&
218  ( rAttrName.startsWith( GetXMLToken(XML_XMLNS) ) ) &&
219  ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
220  {
221  if( !pRewindMap )
222  {
223  pRewindMap = std::move(m_pNamespaceMap);
224  m_pNamespaceMap.reset( new SvXMLNamespaceMap( *pRewindMap ) );
225  }
226  const OUString& rAttrValue = xAttrList->getValueByIndex( i );
227 
228  OUString aPrefix( ( rAttrName.getLength() == 5 )
229  ? OUString()
230  : rAttrName.copy( 6 ) );
231  // Add namespace, but only if it is known.
232  sal_uInt16 nKey = m_pNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
233  // If namespace is unknown, try to match a name with similar
234  // TC Id and version
235  if( XML_NAMESPACE_UNKNOWN == nKey )
236  {
237  OUString aTestName( rAttrValue );
238  if( SvXMLNamespaceMap::NormalizeOasisURN( aTestName ) )
239  nKey = m_pNamespaceMap->AddIfKnown( aPrefix, aTestName );
240  }
241  // If that namespace is not known, too, add it as unknown
242  if( XML_NAMESPACE_UNKNOWN == nKey )
243  nKey = m_pNamespaceMap->Add( aPrefix, rAttrValue );
244 
245  const OUString& rRepName = m_vReplaceNamespaceMap.GetNameByKey( nKey );
246  if( !rRepName.isEmpty() )
247  {
248  if( !pMutableAttrList )
249  {
250  pMutableAttrList = new XMLMutableAttributeList( xAttrList );
251  xAttrList = pMutableAttrList;
252  }
253 
254  pMutableAttrList->SetValueByIndex( i, rRepName );
255  }
256  }
257  }
258 
259  // Get element's namespace and local name.
260  OUString aLocalName;
261  sal_uInt16 nPrefix =
262  m_pNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
263 
264  // If there are contexts already, call a CreateChildContext at the topmost
265  // context. Otherwise, create a default context.
267  if( !m_vContexts.empty() )
268  {
269  xContext = m_vContexts.back()->CreateChildContext( nPrefix,
270  aLocalName,
271  rName,
272  xAttrList );
273  }
274  else
275  {
276  xContext = CreateContext( nPrefix, aLocalName, rName );
277  }
278 
279  OSL_ENSURE( xContext.is(), "XMLTransformerBase::startElement: missing context" );
280  if( !xContext.is() )
281  xContext = new XMLTransformerContext( *this, rName );
282 
283  // Remember old namespace map.
284  if( pRewindMap )
285  xContext->PutRewindMap( std::move(pRewindMap) );
286 
287  // Push context on stack.
288  m_vContexts.push_back( xContext );
289 
290  // Call a startElement at the new context.
291  xContext->StartElement( xAttrList );
292 }
293 
294 void SAL_CALL XMLTransformerBase::endElement( const OUString&
295 #if OSL_DEBUG_LEVEL > 0
296 rName
297 #endif
298 )
299 {
300  if( !m_vContexts.empty() )
301  {
302  // Get topmost context
304 
305 #if OSL_DEBUG_LEVEL > 0
306  OSL_ENSURE( xContext->GetQName() == rName,
307  "XMLTransformerBase::endElement: popped context has wrong lname" );
308 #endif
309 
310  // Call a EndElement at the current context.
311  xContext->EndElement();
312 
313  // and remove it from the stack.
314  m_vContexts.pop_back();
315 
316  // Get a namespace map to rewind.
317  std::unique_ptr<SvXMLNamespaceMap> pRewindMap = xContext->TakeRewindMap();
318 
319  // Delete the current context.
320  xContext = nullptr;
321 
322  // Rewind a namespace map.
323  if( pRewindMap )
324  {
325  m_pNamespaceMap = std::move( pRewindMap );
326  }
327  }
328 }
329 
330 void SAL_CALL XMLTransformerBase::characters( const OUString& rChars )
331 {
332  if( !m_vContexts.empty() )
333  {
334  m_vContexts.back()->Characters( rChars );
335  }
336 }
337 
338 void SAL_CALL XMLTransformerBase::ignorableWhitespace( const OUString& rWhitespaces )
339 {
340  m_xHandler->ignorableWhitespace( rWhitespaces );
341 }
342 
343 void SAL_CALL XMLTransformerBase::processingInstruction( const OUString& rTarget,
344  const OUString& rData )
345 {
346  m_xHandler->processingInstruction( rTarget, rData );
347 }
348 
349 void SAL_CALL XMLTransformerBase::setDocumentLocator( const Reference< XLocator >& )
350 {
351 }
352 
353 // XExtendedDocumentHandler
355 {
356 }
357 
359 {
360 }
361 
362 void SAL_CALL XMLTransformerBase::comment( const OUString& /*rComment*/ )
363 {
364 }
365 
367 {
368 }
369 
370 void SAL_CALL XMLTransformerBase::unknown( const OUString& /*rString*/ )
371 {
372 }
373 
374 // XInitialize
375 void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments )
376 {
377  for( const auto& rArgument : aArguments )
378  {
379  // use isAssignableFrom instead of comparing the types to
380  // allow XExtendedDocumentHandler instead of XDocumentHandler (used in
381  // writeOasis2OOoLibraryElement in sfx2).
382  // The Any shift operator can't be used to query the type because it
383  // uses queryInterface, and the model also has a XPropertySet interface.
384 
385  // document handler
386  if( cppu::UnoType<XDocumentHandler>::get().isAssignableFrom( rArgument.getValueType() ) )
387  {
388  m_xHandler.set( rArgument, UNO_QUERY );
389  // Type change to avoid crashing of dynamic_cast
390  if (SvXMLImport *pFastHandler = dynamic_cast<SvXMLImport*>(
391  uno::Reference< XFastDocumentHandler >( m_xHandler, uno::UNO_QUERY ).get() ) )
392  m_xHandler.set( new SvXMLLegacyToFastDocHandler( pFastHandler ) );
393  }
394 
395  // property set to transport data across
396  if( cppu::UnoType<XPropertySet>::get().isAssignableFrom( rArgument.getValueType() ) )
397  m_xPropSet.set( rArgument, UNO_QUERY );
398 
399  // xmodel
400  if( cppu::UnoType<css::frame::XModel>::get().isAssignableFrom( rArgument.getValueType() ) )
401  mxModel.set( rArgument, UNO_QUERY );
402  }
403 
404  if( m_xPropSet.is() )
405  {
406  Any aAny;
407  OUString sRelPath, sName;
408  Reference< XPropertySetInfo > xPropSetInfo =
409  m_xPropSet->getPropertySetInfo();
410  OUString sPropName( "StreamRelPath" );
411  if( xPropSetInfo->hasPropertyByName(sPropName) )
412  {
413  aAny = m_xPropSet->getPropertyValue(sPropName);
414  aAny >>= sRelPath;
415  }
416  sPropName = "StreamName";
417  if( xPropSetInfo->hasPropertyByName(sPropName) )
418  {
419  aAny = m_xPropSet->getPropertyValue(sPropName);
420  aAny >>= sName;
421  }
422  if( !sName.isEmpty() )
423  {
424  m_aExtPathPrefix = "../";
425 
426  // If there is a rel path within a package, then append
427  // additional '../'. If the rel path contains an ':', then it is
428  // an absolute URI (or invalid URI, because zip files don't
429  // permit ':'), and it will be ignored.
430  if( !sRelPath.isEmpty() )
431  {
432  sal_Int32 nColPos = sRelPath.indexOf( ':' );
433  OSL_ENSURE( -1 == nColPos,
434  "StreamRelPath contains ':', absolute URI?" );
435 
436  if( -1 == nColPos )
437  {
438  OUString sTmp = m_aExtPathPrefix;
439  sal_Int32 nPos = 0;
440  do
441  {
442  m_aExtPathPrefix += sTmp;
443  nPos = sRelPath.indexOf( '/', nPos + 1 );
444  }
445  while( -1 != nPos );
446  }
447  }
448 
449  }
450  }
451 
452  assert(m_xHandler.is()); // can't do anything without that
453 }
454 
455 static sal_Int16 lcl_getUnit( const OUString& rValue )
456 {
457  if( rValue.endsWithIgnoreAsciiCase( "cm" ) )
458  return util::MeasureUnit::CM;
459  else if ( rValue.endsWithIgnoreAsciiCase( "mm" ) )
460  return util::MeasureUnit::MM;
461  else
462  return util::MeasureUnit::INCH;
463 }
464 
466  Reference< XAttributeList >& rAttrList, sal_uInt16 nActionMap,
467  bool bClone )
468 {
469  XMLMutableAttributeList *pMutableAttrList = nullptr;
470  XMLTransformerActions *pActions = GetUserDefinedActions( nActionMap );
471  OSL_ENSURE( pActions, "go no actions" );
472  if( pActions )
473  {
474  sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
475  for( sal_Int16 i=0; i < nAttrCount; ++i )
476  {
477  const OUString& rAttrName = rAttrList->getNameByIndex( i );
478  const OUString& rAttrValue = rAttrList->getValueByIndex( i );
479  OUString aLocalName;
480  sal_uInt16 nPrefix = GetNamespaceMap().GetKeyByAttrName( rAttrName,
481  &aLocalName );
482 
483  XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
484  XMLTransformerActions::const_iterator aIter =
485  pActions->find( aKey );
486  if( aIter != pActions->end() )
487  {
488  if( !pMutableAttrList )
489  {
490  pMutableAttrList = new XMLMutableAttributeList( rAttrList,
491  bClone );
492  rAttrList = pMutableAttrList;
493  }
494 
495  sal_uInt32 nAction = (*aIter).second.m_nActionType;
496  bool bRename = false;
497  switch( nAction )
498  {
499  case XML_ATACTION_RENAME:
500  bRename = true;
501  break;
502  case XML_ATACTION_COPY:
503  break;
504  case XML_ATACTION_REMOVE:
506  pMutableAttrList->RemoveAttributeByIndex( i );
507  --i;
508  --nAttrCount;
509  break;
511  bRename = true;
512  [[fallthrough]];
514  {
515  OUString aAttrValue( rAttrValue );
516  if( ReplaceSingleInWithInch( aAttrValue ) )
517  pMutableAttrList->SetValueByIndex( i, aAttrValue );
518  }
519  break;
521  {
522  OUString aAttrValue( rAttrValue );
523  if( ReplaceInWithInch( aAttrValue ) )
524  pMutableAttrList->SetValueByIndex( i, aAttrValue );
525  }
526  break;
528  bRename = true;
529  [[fallthrough]];
531  {
532  OUString aAttrValue( rAttrValue );
533  if( ReplaceSingleInchWithIn( aAttrValue ) )
534  pMutableAttrList->SetValueByIndex( i, aAttrValue );
535  }
536  break;
538  {
539  OUString aAttrValue( rAttrValue );
540  if( ReplaceInchWithIn( aAttrValue ) )
541  pMutableAttrList->SetValueByIndex( i, aAttrValue );
542  }
543  break;
545  {
546  OUString aAttrValue( rAttrValue );
547 
549  if( isWriter() )
550  {
551  sal_Int16 const nDestUnit = lcl_getUnit(aAttrValue);
552 
553  // convert twips value to inch
554  sal_Int32 nMeasure;
555  if (::sax::Converter::convertMeasure(nMeasure,
556  aAttrValue))
557  {
558 
559  // #i13778#,#i36248# apply correct twip-to-1/100mm
560  nMeasure = static_cast<sal_Int32>( nMeasure >= 0
561  ? ((nMeasure*127+36)/72)
562  : ((nMeasure*127-36)/72) );
563 
564  OUStringBuffer aBuffer;
566  nMeasure, util::MeasureUnit::MM_100TH,
567  nDestUnit );
568  aAttrValue = aBuffer.makeStringAndClear();
569  }
570  }
571 
572  pMutableAttrList->SetValueByIndex( i, aAttrValue );
573  }
574  break;
576  bRename = true;
577  [[fallthrough]];
580  {
581  OUString aAttrValue( rAttrValue );
582  if( DecodeStyleName(aAttrValue) )
583  pMutableAttrList->SetValueByIndex( i, aAttrValue );
584  }
585  break;
587  {
588  OUString aAttrValue( rAttrValue );
589  if( EncodeStyleName(aAttrValue) )
590  {
591  pMutableAttrList->SetValueByIndex( i, aAttrValue );
592  OUString aNewAttrQName(
593  GetNamespaceMap().GetQNameByKey(
594  nPrefix,
596  XML_DISPLAY_NAME ) ) );
597  pMutableAttrList->AddAttribute( aNewAttrQName,
598  rAttrValue );
599  }
600  }
601  break;
603  bRename = true;
604  [[fallthrough]];
606  {
607  OUString aAttrValue( rAttrValue );
608  if( EncodeStyleName(aAttrValue) )
609  pMutableAttrList->SetValueByIndex( i, aAttrValue );
610  }
611  break;
613  bRename = true;
614  [[fallthrough]];
616  {
617  OUString aAttrValue( rAttrValue );
618  if( NegPercent( aAttrValue ) )
619  pMutableAttrList->SetValueByIndex( i, aAttrValue );
620  }
621  break;
623  bRename = true;
624  [[fallthrough]];
626  {
627  OUString aAttrValue( rAttrValue );
628  sal_uInt16 nValPrefix =
629  static_cast<sal_uInt16>(
630  bRename ? (*aIter).second.m_nParam2
631  : (*aIter).second.m_nParam1);
632  AddNamespacePrefix( aAttrValue, nValPrefix );
633  pMutableAttrList->SetValueByIndex( i, aAttrValue );
634  }
635  break;
637  {
638  OUString aAttrValue( rAttrValue );
639  sal_uInt16 nValPrefix =
640  static_cast<sal_uInt16>((*aIter).second.m_nParam1);
642  nValPrefix = XML_NAMESPACE_OOOC;
643  else if( IsXMLToken( GetClass(), XML_TEXT ) )
644  nValPrefix = XML_NAMESPACE_OOOW;
645  AddNamespacePrefix( aAttrValue, nValPrefix );
646  pMutableAttrList->SetValueByIndex( i, aAttrValue );
647  }
648  break;
650  bRename = true;
651  [[fallthrough]];
653  {
654  OUString aAttrValue( rAttrValue );
655  sal_uInt16 nValPrefix =
656  static_cast<sal_uInt16>(
657  bRename ? (*aIter).second.m_nParam2
658  : (*aIter).second.m_nParam1);
659  if( RemoveNamespacePrefix( aAttrValue, nValPrefix ) )
660  pMutableAttrList->SetValueByIndex( i, aAttrValue );
661  }
662  break;
664  {
665  OUString aAttrValue( rAttrValue );
666  if( RemoveNamespacePrefix( aAttrValue ) )
667  pMutableAttrList->SetValueByIndex( i, aAttrValue );
668  }
669  break;
671  {
672  OUString aAttrValue( rAttrValue );
673  if( ConvertURIToOASIS( aAttrValue,
674  static_cast< bool >((*aIter).second.m_nParam1)))
675  pMutableAttrList->SetValueByIndex( i, aAttrValue );
676  }
677  break;
679  {
680  OUString aAttrValue( rAttrValue );
681  if( ConvertURIToOOo( aAttrValue,
682  static_cast< bool >((*aIter).second.m_nParam1)))
683  pMutableAttrList->SetValueByIndex( i, aAttrValue );
684  }
685  break;
687  {
688  OUString aAttrValue( rAttrValue );
690  aAttrValue,
691  (*aIter).second.m_nParam1,
692  (*aIter).second.m_nParam2,
693  (*aIter).second.m_nParam3 );
694  pMutableAttrList->SetValueByIndex( i, aAttrValue );
695  }
696  break;
698  {
699  OUString aAttrValue( rAttrValue );
700  if( ConvertRNGDateTimeToISO( aAttrValue ))
701  pMutableAttrList->SetValueByIndex( i, aAttrValue );
702  }
703  break;
705  {
706  OUString aAttrValue( rAttrValue );
707  if( ConvertRNGDateTimeToISO( aAttrValue ))
708  pMutableAttrList->SetValueByIndex( i, aAttrValue );
709  bRename = true;
710  }
711  break;
713  {
714  OUString aAttrValue( rAttrValue );
716 
717  if( isWriter() )
718  {
719  sal_Int16 const nDestUnit = lcl_getUnit(aAttrValue);
720 
721  // convert inch value to twips and export as faked inch
722  sal_Int32 nMeasure;
723  if (::sax::Converter::convertMeasure(nMeasure,
724  aAttrValue))
725  {
726 
727  // #i13778#,#i36248#/ apply correct 1/100mm-to-twip conversion
728  nMeasure = static_cast<sal_Int32>( nMeasure >= 0
729  ? ((nMeasure*72+63)/127)
730  : ((nMeasure*72-63)/127) );
731 
732  OUStringBuffer aBuffer;
734  nMeasure, util::MeasureUnit::MM_100TH,
735  nDestUnit );
736  aAttrValue = aBuffer.makeStringAndClear();
737  }
738  }
739 
740  pMutableAttrList->SetValueByIndex( i, aAttrValue );
741  }
742  break;
744  {
745  OUString aAttrValue( rAttrValue );
746  ReplaceSingleInchWithIn( aAttrValue );
747 
748  sal_Int16 const nDestUnit = lcl_getUnit( aAttrValue );
749 
750  sal_Int32 nMeasure;
751  if (::sax::Converter::convertMeasure(nMeasure,
752  aAttrValue))
753  {
754 
755  if( nMeasure > 0 )
756  nMeasure -= 1;
757  else if( nMeasure < 0 )
758  nMeasure += 1;
759 
760 
761  OUStringBuffer aBuffer;
762  ::sax::Converter::convertMeasure(aBuffer, nMeasure,
763  util::MeasureUnit::MM_100TH, nDestUnit);
764  aAttrValue = aBuffer.makeStringAndClear();
765  }
766 
767  pMutableAttrList->SetValueByIndex( i, aAttrValue );
768  }
769  break;
771  {
772  OUString aAttrValue( rAttrValue );
773  ReplaceSingleInWithInch( aAttrValue );
774 
775  sal_Int16 const nDestUnit = lcl_getUnit( aAttrValue );
776 
777  sal_Int32 nMeasure;
778  if (::sax::Converter::convertMeasure(nMeasure,
779  aAttrValue))
780  {
781 
782  if( nMeasure > 0 )
783  nMeasure += 1;
784  else if( nMeasure < 0 )
785  nMeasure -= 1;
786 
787 
788  OUStringBuffer aBuffer;
789  ::sax::Converter::convertMeasure(aBuffer, nMeasure,
790  util::MeasureUnit::MM_100TH, nDestUnit );
791  aAttrValue = aBuffer.makeStringAndClear();
792  }
793 
794  pMutableAttrList->SetValueByIndex( i, aAttrValue );
795  }
796  break;
798  {
799  const sal_Int32 nLen = rAttrValue.getLength();
800  OUStringBuffer aBuffer;
801 
802  sal_Int32 pos;
803  for( pos = 0; pos < nLen; pos++ )
804  {
805  sal_Unicode c = rAttrValue[pos];
806  if( (c >= '0') && (c <= '9') )
807  aBuffer.append( c );
808  else
809  aBuffer.append( static_cast<sal_Int32>(c) );
810  }
811 
812  pMutableAttrList->SetValueByIndex( i, aBuffer.makeStringAndClear() );
813  }
814  break;
815  // #i50322# - special handling for the
816  // transparency of writer background graphics.
818  {
819  // determine, if it's the transparency of a document style
820  XMLTransformerContext* pFirstContext = m_vContexts[0].get();
821  OUString aFirstContextLocalName;
822  /* sal_uInt16 nFirstContextPrefix = */
823  GetNamespaceMap().GetKeyByAttrName( pFirstContext->GetQName(),
824  &aFirstContextLocalName );
825  bool bIsDocumentStyle(
826  ::xmloff::token::IsXMLToken( aFirstContextLocalName,
828  // no conversion of transparency value for document
829  // styles, because former OpenOffice.org version writes
830  // writes always a transparency value of 100% and doesn't
831  // read the value. Thus, it's interpreted as 0%
832  if ( !bIsDocumentStyle )
833  {
834  OUString aAttrValue( rAttrValue );
835  NegPercent(aAttrValue);
836  pMutableAttrList->SetValueByIndex( i, aAttrValue );
837  }
838  bRename = true;
839  }
840  break;
842  {
843  OUString sNewValue = "shape" + rAttrValue;
844  pMutableAttrList->SetValueByIndex( i, sNewValue );
845  break;
846  }
847 
848  default:
849  OSL_ENSURE( false, "unknown action" );
850  break;
851  }
852 
853  if( bRename )
854  {
855  OUString aNewAttrQName(
856  GetNamespaceMap().GetQNameByKey(
857  (*aIter).second.GetQNamePrefixFromParam1(),
859  (*aIter).second.GetQNameTokenFromParam1()) ) );
860  pMutableAttrList->RenameAttributeByIndex( i,
861  aNewAttrQName );
862  }
863  }
864  }
865  }
866 
867  return pMutableAttrList;
868 }
869 
871 {
872  bool bRet = false;
873  sal_Int32 nPos = rValue.getLength();
874  while( nPos && rValue[nPos-1] <= ' ' )
875  --nPos;
876  if( nPos > 2 &&
877  ('c'==rValue[nPos-2] || 'C'==rValue[nPos-2]) &&
878  ('h'==rValue[nPos-1] || 'H'==rValue[nPos-1]) )
879  {
880  rValue =rValue.copy( 0, nPos-2 );
881  bRet = true;
882  }
883 
884  return bRet;
885 }
886 
888 {
889  bool bRet = false;
890  sal_Int32 nPos = 1;
891  while( nPos < rValue.getLength()-3 )
892  {
893  sal_Unicode c = rValue[nPos];
894  if( 'i'==c || 'I'==c )
895  {
896  c = rValue[nPos-1];
897  if( (c >= '0' && c <= '9') || '.' == c )
898  {
899  c = rValue[nPos+1];
900  if( 'n'==c || 'N'==c )
901  {
902  c = rValue[nPos+2];
903  if( 'c'==c || 'C'==c )
904  {
905  c = rValue[nPos+3];
906  if( 'h'==c || 'H'==c )
907  {
908  rValue = rValue.replaceAt( nPos,
909  4, GetXMLToken(XML_IN) );
910  nPos += 2;
911  bRet = true;
912  continue;
913  }
914  }
915  }
916  }
917  }
918  ++nPos;
919  }
920 
921  return bRet;
922 }
923 
925 {
926  bool bRet = false;
927 
928  sal_Int32 nPos = rValue.getLength();
929  while( nPos && rValue[nPos-1] <= ' ' )
930  --nPos;
931  if( nPos > 2 &&
932  ('i'==rValue[nPos-2] ||
933  'I'==rValue[nPos-2]) &&
934  ('n'==rValue[nPos-1] ||
935  'N'==rValue[nPos-1]) )
936  {
937  nPos -= 2;
938  rValue = rValue.replaceAt( nPos, rValue.getLength() - nPos,
940  bRet = true;
941  }
942 
943  return bRet;
944 }
945 
947 {
948  bool bRet = false;
949  sal_Int32 nPos = 1;
950  while( nPos < rValue.getLength()-1 )
951  {
952  sal_Unicode c = rValue[nPos];
953  if( 'i'==c || 'I'==c )
954  {
955  c = rValue[nPos-1];
956  if( (c >= '0' && c <= '9') || '.' == c )
957  {
958  c = rValue[nPos+1];
959  if( 'n'==c || 'N'==c )
960  {
961  rValue = rValue.replaceAt( nPos,
962  2, GetXMLToken(XML_INCH) );
963  nPos += 4;
964  bRet = true;
965  continue;
966  }
967  }
968  }
969  ++nPos;
970  }
971 
972  return bRet;
973 }
974 
975 bool XMLTransformerBase::EncodeStyleName( OUString& rName ) const
976 {
977  static const char aHexTab[] = "0123456789abcdef";
978 
979  bool bEncoded = false;
980 
981  sal_Int32 nLen = rName.getLength();
982  OUStringBuffer aBuffer( nLen );
983 
984  for( sal_Int32 i = 0; i < nLen; i++ )
985  {
986  sal_Unicode c = rName[i];
987  bool bValidChar = false;
988  if( c < 0x00ffU )
989  {
990  bValidChar =
991  (c >= 0x0041 && c <= 0x005a) ||
992  (c >= 0x0061 && c <= 0x007a) ||
993  (c >= 0x00c0 && c <= 0x00d6) ||
994  (c >= 0x00d8 && c <= 0x00f6) ||
995  (c >= 0x00f8 && c <= 0x00ff) ||
996  ( i > 0 && ( (c >= 0x0030 && c <= 0x0039) ||
997  c == 0x00b7 || c == '-' || c == '.') );
998  }
999  else
1000  {
1001  if( (c >= 0xf900U && c <= 0xfffeU) ||
1002  (c >= 0x20ddU && c <= 0x20e0U))
1003  {
1004  bValidChar = false;
1005  }
1006  else if( (c >= 0x02bbU && c <= 0x02c1U) || c == 0x0559 ||
1007  c == 0x06e5 || c == 0x06e6 )
1008  {
1009  bValidChar = true;
1010  }
1011  else if( c == 0x0387 )
1012  {
1013  bValidChar = i > 0;
1014  }
1015  else
1016  {
1017  if( !xCharClass.is() )
1018  {
1019  const_cast < XMLTransformerBase * >(this)
1020  ->xCharClass = CharacterClassification::create( comphelper::getProcessComponentContext() );
1021  }
1022  sal_Int16 nType = xCharClass->getType( rName, i );
1023 
1024  switch( nType )
1025  {
1026  case UnicodeType::UPPERCASE_LETTER: // Lu
1027  case UnicodeType::LOWERCASE_LETTER: // Ll
1028  case UnicodeType::TITLECASE_LETTER: // Lt
1029  case UnicodeType::OTHER_LETTER: // Lo
1030  case UnicodeType::LETTER_NUMBER: // Nl
1031  bValidChar = true;
1032  break;
1033  case UnicodeType::NON_SPACING_MARK: // Ms
1034  case UnicodeType::ENCLOSING_MARK: // Me
1035  case UnicodeType::COMBINING_SPACING_MARK: //Mc
1036  case UnicodeType::MODIFIER_LETTER: // Lm
1037  case UnicodeType::DECIMAL_DIGIT_NUMBER: // Nd
1038  bValidChar = i > 0;
1039  break;
1040  }
1041  }
1042  }
1043  if( bValidChar )
1044  {
1045  aBuffer.append( c );
1046  }
1047  else
1048  {
1049  aBuffer.append( '_' );
1050  if( c > 0x0fff )
1051  aBuffer.append( static_cast< sal_Unicode >(
1052  aHexTab[ (c >> 12) & 0x0f ] ) );
1053  if( c > 0x00ff )
1054  aBuffer.append( static_cast< sal_Unicode >(
1055  aHexTab[ (c >> 8) & 0x0f ] ) );
1056  if( c > 0x000f )
1057  aBuffer.append( static_cast< sal_Unicode >(
1058  aHexTab[ (c >> 4) & 0x0f ] ) );
1059  aBuffer.append( static_cast< sal_Unicode >(
1060  aHexTab[ c & 0x0f ] ) );
1061  aBuffer.append( '_' );
1062  bEncoded = true;
1063  }
1064  }
1065 
1066  if( aBuffer.getLength() > (1<<15)-1 )
1067  bEncoded = false;
1068 
1069  if( bEncoded )
1070  rName = aBuffer.makeStringAndClear();
1071  return bEncoded;
1072 }
1073 
1075 {
1076  bool bEncoded = false;
1077 
1078  sal_Int32 nLen = rName.getLength();
1079  OUStringBuffer aBuffer( nLen );
1080 
1081  bool bWithinHex = false;
1082  sal_Unicode cEnc = 0;
1083  for( sal_Int32 i = 0; i < nLen; i++ )
1084  {
1085  sal_Unicode c = rName[i];
1086  if( '_' == c )
1087  {
1088  if( bWithinHex )
1089  {
1090  aBuffer.append( cEnc );
1091  cEnc = 0;
1092  }
1093  else
1094  {
1095  bEncoded = true;
1096  }
1097  bWithinHex = !bWithinHex;
1098  }
1099  else if( bWithinHex )
1100  {
1101  sal_Unicode cDigit;
1102  if( c >= '0' && c <= '9' )
1103  {
1104  cDigit = c - '0';
1105  }
1106  else if( c >= 'a' && c <= 'f' )
1107  {
1108  cDigit = c - 'a' + 10;
1109  }
1110  else if( c >= 'A' && c <= 'F' )
1111  {
1112  cDigit = c - 'A' + 10;
1113  }
1114  else
1115  {
1116  // error
1117  bEncoded = false;
1118  break;
1119  }
1120  cEnc = (cEnc << 4) + cDigit;
1121  }
1122  else
1123  {
1124  aBuffer.append( c );
1125  }
1126  }
1127 
1128  if( bEncoded )
1129  rName = aBuffer.makeStringAndClear();
1130  return bEncoded;
1131 }
1132 
1134 {
1135  bool bRet = false;
1136  bool bNeg = false;
1137  double nVal = 0;
1138 
1139  sal_Int32 nPos = 0;
1140  sal_Int32 nLen = rValue.getLength();
1141 
1142  // skip white space
1143  while( nPos < nLen && ' ' == rValue[nPos] )
1144  nPos++;
1145 
1146  if( nPos < nLen && '-' == rValue[nPos] )
1147  {
1148  bNeg = true;
1149  nPos++;
1150  }
1151 
1152  // get number
1153  while( nPos < nLen &&
1154  '0' <= rValue[nPos] &&
1155  '9' >= rValue[nPos] )
1156  {
1157  // TODO: check overflow!
1158  nVal *= 10;
1159  nVal += (rValue[nPos] - '0');
1160  nPos++;
1161  }
1162  if( nPos < nLen && '.' == rValue[nPos] )
1163  {
1164  nPos++;
1165  double nDiv = 1.;
1166 
1167  while( nPos < nLen &&
1168  '0' <= rValue[nPos] &&
1169  '9' >= rValue[nPos] )
1170  {
1171  // TODO: check overflow!
1172  nDiv *= 10;
1173  nVal += ( static_cast<double>(rValue[nPos] - '0') / nDiv );
1174  nPos++;
1175  }
1176  }
1177 
1178  // skip white space
1179  while( nPos < nLen && ' ' == rValue[nPos] )
1180  nPos++;
1181 
1182  if( nPos < nLen && '%' == rValue[nPos] )
1183  {
1184  if( bNeg )
1185  nVal = -nVal;
1186  nVal += .5;
1187 
1188  sal_Int32 nIntVal = 100 - static_cast<sal_Int32>( nVal );
1189 
1190  rValue = OUString::number(nIntVal) + "%";
1191 
1192  bRet = true;
1193  }
1194 
1195  return bRet;
1196 }
1197 
1199  sal_uInt16 nPrefix ) const
1200 {
1201  rName = GetNamespaceMap().GetQNameByKey( nPrefix, rName, false );
1202 }
1203 
1205  sal_uInt16 nPrefixOnly ) const
1206 {
1207  OUString aLocalName;
1208  sal_uInt16 nPrefix =
1209  GetNamespaceMap().GetKeyByAttrValueQName(rName, &aLocalName);
1210  bool bRet = XML_NAMESPACE_UNKNOWN != nPrefix &&
1211  (USHRT_MAX == nPrefixOnly || nPrefix == nPrefixOnly);
1212  if( bRet )
1213  rName = aLocalName;
1214 
1215  return bRet;
1216 }
1217 
1219  bool bSupportPackage ) const
1220 {
1221  bool bRet = false;
1222  if( !m_aExtPathPrefix.isEmpty() && !rURI.isEmpty() )
1223  {
1224  bool bRel = false;
1225  switch( rURI[0] )
1226  {
1227  case '#':
1228  // no rel path, but
1229  // for package URIs, the '#' has to be removed
1230  if( bSupportPackage )
1231  {
1232  rURI = rURI.copy( 1 );
1233  bRet = true;
1234  }
1235  break;
1236  case '/':
1237  // no rel path; nothing to do
1238  break;
1239  case '.':
1240  // a rel path; to keep URI simple, remove './', if there
1241  bRel = true;
1242  if( rURI.getLength() > 1 && '/' == rURI[1] )
1243  {
1244  rURI = rURI.copy( 2 );
1245  bRet = true;
1246  }
1247  break;
1248  default:
1249  // check for a RFC2396 schema
1250  {
1251  bRel = true;
1252  sal_Int32 nPos = 1;
1253  sal_Int32 nLen = rURI.getLength();
1254  while( nPos < nLen )
1255  {
1256  switch( rURI[nPos] )
1257  {
1258  case '/':
1259  // a relative path segment
1260  nPos = nLen; // leave loop
1261  break;
1262  case ':':
1263  // a schema
1264  bRel = false;
1265  nPos = nLen; // leave loop
1266  break;
1267  default:
1268  // we don't care about any other characters
1269  break;
1270  }
1271  ++nPos;
1272  }
1273  }
1274  }
1275 
1276  if( bRel )
1277  {
1278  rURI = m_aExtPathPrefix + rURI;
1279  bRet = true;
1280  }
1281  }
1282 
1283  return bRet;
1284 }
1285 
1287  bool bSupportPackage ) const
1288 {
1289  bool bRet = false;
1290  if( !rURI.isEmpty() )
1291  {
1292  bool bPackage = false;
1293  switch( rURI[0] )
1294  {
1295  case '/':
1296  // no rel path; nothing to do
1297  break;
1298  case '.':
1299  // a rel path
1300  if( rURI.startsWith( m_aExtPathPrefix ) )
1301  {
1302  // an external URI; remove '../'
1303  rURI = rURI.copy( m_aExtPathPrefix.getLength() );
1304  bRet = true;
1305  }
1306  else
1307  {
1308  bPackage = true;
1309  }
1310  break;
1311  default:
1312  // check for a RFC2396 schema
1313  {
1314  bPackage = true;
1315  sal_Int32 nPos = 1;
1316  sal_Int32 nLen = rURI.getLength();
1317  while( nPos < nLen )
1318  {
1319  switch( rURI[nPos] )
1320  {
1321  case '/':
1322  // a relative path segment within the package
1323  nPos = nLen; // leave loop
1324  break;
1325  case ':':
1326  // a schema
1327  bPackage = false;
1328  nPos = nLen; // leave loop
1329  break;
1330  default:
1331  // we don't care about any other characters
1332  break;
1333  }
1334  ++nPos;
1335  }
1336  }
1337  }
1338 
1339  if( bPackage && bSupportPackage )
1340  {
1341  OUString sTmp( '#' );
1342  if( rURI.startsWith( "./" ) )
1343  rURI = rURI.copy( 2 );
1344  sTmp += rURI;
1345  rURI = sTmp;
1346  bRet = true;
1347  }
1348  }
1349 
1350  return bRet;
1351 }
1352 
1354  OUString& rOutAttributeValue,
1355  sal_Int32 nParam1,
1356  sal_Int32 nParam2,
1357  sal_Int32 nParam3 )
1358 {
1359  return ( lcl_ConvertAttr( rOutAttributeValue, nParam1) ||
1360  lcl_ConvertAttr( rOutAttributeValue, nParam2) ||
1361  lcl_ConvertAttr( rOutAttributeValue, nParam3) );
1362 }
1363 
1364 // static
1366 {
1367  if( !rDateTime.isEmpty() &&
1368  rDateTime.indexOf( '.' ) != -1 )
1369  {
1370  rDateTime = rDateTime.replace( '.', ',');
1371  return true;
1372  }
1373 
1374  return false;
1375 }
1376 
1377 XMLTokenEnum XMLTransformerBase::GetToken( const OUString& rStr ) const
1378 {
1379  XMLTransformerTokenMap::const_iterator aIter =
1380  m_TokenMap.find( rStr );
1381  if( aIter == m_TokenMap.end() )
1382  return XML_TOKEN_END;
1383  else
1384  return (*aIter).second;
1385 }
1386 
1387 
1389 {
1390  OSL_ENSURE( !m_vContexts.empty(), "empty stack" );
1391 
1392 
1393  return m_vContexts.empty() ? nullptr : m_vContexts.back().get();
1394 }
1395 
1397  sal_uInt32 n ) const
1398 {
1399  auto nSize = m_vContexts.size();
1400 
1401  OSL_ENSURE( nSize > n + 2 , "invalid context" );
1402 
1403  return nSize > n + 2 ? m_vContexts[nSize - (n + 2)].get() : nullptr;
1404 }
1405 
1407 {
1408  Reference< XServiceInfo > xSI( mxModel, UNO_QUERY );
1409  return xSI.is() &&
1410  ( xSI->supportsService("com.sun.star.text.TextDocument") ||
1411  xSI->supportsService("com.sun.star.text.WebDocument") ||
1412  xSI->supportsService("com.sun.star.text.GlobalDocument") );
1413 }
1414 
1415 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetClass() const
bool IsXMLToken(const OUString &rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3422
virtual XMLTransformerContext * CreateUserDefinedContext(const TransformerAction_Impl &rAction, const OUString &rQName, bool bPersistent=false)=0
static const char aHexTab[]
Definition: xmluconv.cxx:282
XMLTransformerBase(XMLTransformerActionInit const *pInit,::xmloff::token::XMLTokenEnum const *pTKMapInit)
css::uno::Reference< css::frame::XModel > mxModel
virtual void SAL_CALL startDocument() override
static bool convertMeasure(sal_Int32 &rValue, const OUString &rString, sal_Int16 nTargetUnit=css::util::MeasureUnit::MM_100TH, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
std::unique_ptr< SvXMLNamespaceMap > m_pNamespaceMap
static bool ReplaceInchWithIn(OUString &rValue)
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
constexpr sal_uInt16 XML_NAMESPACE_DC
Definition: xmlnmspe.hxx:36
virtual void SAL_CALL endElement(const OUString &aName) override
const sal_uInt16 XML_NAMESPACE_UNKNOWN
Definition: nmspmap.hxx:38
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
Definition: nmspmap.cxx:437
virtual void SAL_CALL startCDATA() override
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
sal_uInt16 sal_Unicode
bool ConvertURIToOOo(OUString &rURI, bool bSupportPackage) const
constexpr sal_uInt16 XML_NAMESPACE_MATH
Definition: xmlnmspe.hxx:43
size_t pos
bool isAssignableFrom(const Type &_rAssignable, const Type &_rFrom)
static bool RenameAttributeValue(OUString &rOutAttributeValue, sal_Int32 nParam1, sal_Int32 nParam2, sal_Int32 nParam3)
renames the given rOutAttributeValue if one of the parameters contains a matching token in its lower ...
SvXMLNamespaceMap & GetNamespaceMap()
sal_uInt16 GetKeyByAttrValueQName(const OUString &rAttrName, OUString *pLocalName) const
Definition: nmspmap.cxx:263
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xHandler
const char * sName
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:47
bool RemoveNamespacePrefix(OUString &rName, sal_uInt16 nPrefixOnly=0xffffU) const
bool HasQName(sal_uInt16 nPrefix,::xmloff::token::XMLTokenEnum eToken) const
static bool ConvertRNGDateTimeToISO(OUString &rDateTime)
converts the '.
virtual void SAL_CALL unknown(const OUString &sString) override
int i
void SetValueByIndex(sal_Int16 i, const OUString &rValue)
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
sal_uInt16 & nParam
virtual ~XMLTransformerBase() override
void RemoveAttributeByIndex(sal_Int16 i)
const XMLTransformerContext * GetAncestorContext(sal_uInt32 i) const
static bool ReplaceInWithInch(OUString &rValue)
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
css::uno::Reference< css::beans::XPropertySet > m_xPropSet
constexpr sal_uInt16 XML_NAMESPACE_OOO
Definition: xmlnmspe.hxx:62
void AddAttribute(const OUString &sName, const OUString &sValue)
void RenameAttributeByIndex(sal_Int16 i, const OUString &rNewName)
virtual void SAL_CALL allowLineBreak() override
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
Definition: nmspmap.cxx:187
enumrange< T >::Iterator end(enumrange< T >)
static bool ReplaceSingleInWithInch(OUString &rValue)
const OUString & GetNameByKey(sal_uInt16 nKey) const
Definition: nmspmap.cxx:168
constexpr sal_uInt16 XML_NAMESPACE_OOOW
Definition: xmlnmspe.hxx:63
void AddNamespacePrefix(OUString &rName, sal_uInt16 nPrefix) const
XMLTransformerTokenMap const m_TokenMap
constexpr sal_uInt16 XML_NAMESPACE_XLINK
Definition: xmlnmspe.hxx:35
virtual void SAL_CALL comment(const OUString &sComment) override
static bool NormalizeOasisURN(OUString &rName)
Definition: nmspmap.cxx:478
css::uno::Reference< css::i18n::XCharacterClassification > xCharClass
virtual XMLTransformerActions * GetUserDefinedActions(sal_uInt16 n)
std::unique_ptr< char[]> aBuffer
friend class XMLTransformerContext
constexpr sal_uInt16 XML_NAMESPACE_OOOC
Definition: xmlnmspe.hxx:64
static bool ReplaceSingleInchWithIn(OUString &rValue)
static bool NegPercent(OUString &rValue)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3366
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Handling of tokens in XML:
XMLTransformerContext * CreateContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName)
::xmloff::token::XMLTokenEnum GetToken(const OUString &rStr) const
Reference< XComponentContext > getProcessComponentContext()
QPRO_FUNC_TYPE nType
virtual bool IsPersistent() const
virtual void SAL_CALL endCDATA() override
const XMLTransformerContext * GetCurrentContext() const
XMLMutableAttributeList * ProcessAttrList(css::uno::Reference< css::xml::sax::XAttributeList > &rAttrList, sal_uInt16 nActionMap, bool bClone)
bool EncodeStyleName(OUString &rName) const
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
XMLTransformerActions & GetElemActions()
static bool DecodeStyleName(OUString &rName)
const OUString & GetQName() const
bool ConvertURIToOASIS(OUString &rURI, bool bSupportPackage) const
SvXMLNamespaceMap m_vReplaceNamespaceMap
static sal_Int16 lcl_getUnit(const OUString &rValue)
constexpr sal_uInt16 XML_NAMESPACE_DOM
Definition: xmlnmspe.hxx:57
sal_uInt16 nPos
std::vector< rtl::Reference< XMLTransformerContext > > m_vContexts