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