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