LibreOffice Module xmloff (master)  1
txtimp.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 <memory>
21 #include <tuple>
22 #include <vector>
23 
24 #include <com/sun/star/container/XEnumerationAccess.hpp>
25 #include <com/sun/star/frame/XModel.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <com/sun/star/text/ReferenceFieldSource.hpp>
29 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>
30 #include <com/sun/star/text/XTextFrame.hpp>
31 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
32 #include <com/sun/star/text/XTextFramesSupplier.hpp>
33 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
34 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
35 #include <com/sun/star/text/XFormField.hpp>
36 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
37 #include <com/sun/star/container/XNamed.hpp>
38 #include <com/sun/star/style/XStyle.hpp>
39 #include <xmloff/xmlnamespace.hxx>
40 #include <xmloff/txtstyli.hxx>
41 #include <xmloff/xmlnumi.hxx>
42 #include <xmloff/maptype.hxx>
43 
44 #include <sal/log.hxx>
45 #include "txtparai.hxx"
46 #include <xmloff/txtprmap.hxx>
47 #include <xmloff/txtimppr.hxx>
48 #include <xmloff/xmlimp.hxx>
49 #include <txtvfldi.hxx>
50 #include <xmloff/i18nmap.hxx>
53 #include "XMLTextFrameContext.hxx"
56 #include "XMLIndexTOCContext.hxx"
62 
65 #include <PageMasterStyleMap.hxx>
67 #include <PageMasterPropMapper.hxx>
68 // XML import: reconstruction of assignment of paragraph style to outline levels (#i69629#)
69 #include <com/sun/star/beans/XPropertyState.hpp>
70 #include <txtlists.hxx>
71 #include <xmloff/odffields.hxx>
73 
74 using ::com::sun::star::ucb::XAnyCompare;
75 
76 using namespace ::std;
77 using namespace ::com::sun::star;
78 using namespace ::com::sun::star::uno;
79 using namespace ::com::sun::star::beans;
80 using namespace ::com::sun::star::text;
81 using namespace ::com::sun::star::frame;
82 using namespace ::com::sun::star::style;
83 using namespace ::com::sun::star::container;
84 using namespace ::com::sun::star::drawing;
85 using namespace ::com::sun::star::xml::sax;
86 using namespace ::com::sun::star::lang;
87 using namespace ::xmloff::token;
88 using namespace ::com::sun::star::ucb;
89 
90 
91 // maximum allowed length of combined characters field
92 #define MAX_COMBINED_CHARACTERS 6
93 
95 {
96  std::unique_ptr< std::vector<OUString> > m_xPrevFrmNames;
97  std::unique_ptr< std::vector<OUString> > m_xNextFrmNames;
98  std::unique_ptr<XMLTextListsHelper> m_xTextListsHelper;
99 
101 
107 
108  std::unique_ptr<SvI18NMap> m_xRenameMap;
109 
110  /* Change and extend data structure:
111  - data structure contains candidates of paragraph styles, which
112  will be assigned to the outline style
113  - data structure contains more than one candidate for each list level
114  of the outline style (#i69629#)
115  */
116  std::unique_ptr< std::vector< OUString > []>
118 
119  // start range, xml:id, RDFa stuff
120  typedef std::tuple<
121  uno::Reference<text::XTextRange>, OUString,
122  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > >
125  std::map< OUString, BookmarkMapEntry_t > m_BookmarkStartRanges;
126 
127  std::vector< OUString > m_BookmarkVector;
128 
131 
132  // Used for frame deduplication, the name of the last frame imported directly before the current one
134 
135  std::map< OUString, bool > m_bBookmarkHidden;
136  std::map< OUString, OUString > m_sBookmarkCondition;
137 
138  uno::Reference<text::XText> m_xText;
139  uno::Reference<text::XTextCursor> m_xCursor;
140  uno::Reference<text::XTextRange> m_xCursorAsRange;
141  uno::Reference<container::XNameContainer> m_xParaStyles;
142  uno::Reference<container::XNameContainer> m_xTextStyles;
143  uno::Reference<container::XNameContainer> m_xNumStyles;
144  uno::Reference<container::XNameContainer> m_xFrameStyles;
145  uno::Reference<container::XNameContainer> m_xPageStyles;
146  uno::Reference<container::XNameContainer> m_xCellStyles;
147  uno::Reference<container::XIndexReplace> m_xChapterNumbering;
148  uno::Reference<container::XNameAccess> m_xTextFrames;
149  uno::Reference<container::XNameAccess> m_xGraphics;
150  uno::Reference<container::XNameAccess> m_xObjects;
151  uno::Reference<lang::XMultiServiceFactory> m_xServiceFactory;
152 
154 
155  bool m_bInsertMode : 1;
157  bool m_bBlockMode : 1;
158  bool m_bProgress : 1;
161 
164 
165  typedef ::std::pair< OUString, OUString> field_name_type_t;
166  typedef ::std::pair< OUString, OUString > field_param_t;
167  typedef ::std::vector< field_param_t > field_params_t;
168  typedef ::std::tuple<field_name_type_t, field_params_t, uno::Reference<text::XFormField>> field_stack_item_t;
169  typedef ::std::stack< field_stack_item_t > field_stack_t;
170 
171  field_stack_t m_FieldStack;
172 
174 
175  std::unique_ptr<std::map<OUString, OUString>> m_pCrossRefHeadingBookmarkMap;
176 
177  Impl( uno::Reference<frame::XModel> const& rModel,
178  SvXMLImport & rImport,
179  bool const bInsertMode, bool const bStylesOnlyMode,
180  bool const bProgress, bool const bBlockMode,
181  bool const bOrganizerMode)
182  : m_xTextListsHelper( new XMLTextListsHelper() )
183  // XML import: reconstruction of assignment of paragraph style to outline levels (#i69629#)
184  , m_xServiceFactory( rModel, UNO_QUERY )
185  , m_rSvXMLImport( rImport )
186  , m_bInsertMode( bInsertMode )
187  , m_bStylesOnlyMode( bStylesOnlyMode )
188  , m_bBlockMode( bBlockMode )
189  , m_bProgress( bProgress )
190  , m_bOrganizerMode( bOrganizerMode )
191  , m_bBodyContentStarted( true )
192  , m_bInsideDeleteContext( false )
193  {
194  }
195  Impl(const Impl&) = delete;
196  Impl& operator=(const Impl&) = delete;
197 
199  {
201  {
202  size_t const size(m_xChapterNumbering->getCount());
204  new ::std::vector< OUString >[size] );
205  }
206  }
207 
208 };
209 
210 
211 uno::Reference< text::XText > & XMLTextImportHelper::GetText()
212 {
213  return m_xImpl->m_xText;
214 }
215 
216 uno::Reference< text::XTextCursor > & XMLTextImportHelper::GetCursor()
217 {
218  return m_xImpl->m_xCursor;
219 }
220 
221 uno::Reference< text::XTextRange > & XMLTextImportHelper::GetCursorAsRange()
222 {
223  return m_xImpl->m_xCursorAsRange;
224 }
225 
227 {
228  return m_xImpl->m_bInsertMode;
229 }
230 
232 {
233  return m_xImpl->m_bStylesOnlyMode;
234 }
235 
237 {
238  return m_xImpl->m_bBlockMode;
239 }
240 
242 {
243  return m_xImpl->m_bOrganizerMode;
244 }
245 
247 {
248  return m_xImpl->m_bProgress;
249 }
250 
251 uno::Reference<container::XNameContainer> const&
253 {
254  return m_xImpl->m_xParaStyles;
255 }
256 
257 uno::Reference<container::XNameContainer> const&
259 {
260  return m_xImpl->m_xTextStyles;
261 }
262 
263 uno::Reference<container::XNameContainer> const&
265 {
266  return m_xImpl->m_xNumStyles;
267 }
268 
269 uno::Reference<container::XNameContainer> const&
271 {
272  return m_xImpl->m_xFrameStyles;
273 }
274 
275 uno::Reference<container::XNameContainer> const&
277 {
278  return m_xImpl->m_xPageStyles;
279 }
280 
281 uno::Reference<container::XNameContainer> const&
283 {
284  return m_xImpl->m_xCellStyles;
285 }
286 
287 uno::Reference<container::XIndexReplace> const&
289 {
290  return m_xImpl->m_xChapterNumbering;
291 }
292 
295 {
296  return m_xImpl->m_xParaImpPrMap;
297 }
298 
301 {
302  return m_xImpl->m_xTextImpPrMap;
303 }
304 
307 {
308  return m_xImpl->m_xSectionImpPrMap;
309 }
310 
313 {
314  return m_xImpl->m_xRubyImpPrMap;
315 }
316 
318 {
319  m_xImpl->m_bInsideDeleteContext = bNew;
320 }
321 
323 {
324  return m_xImpl->m_bInsideDeleteContext;
325 }
326 
328 {
329  return m_xImpl->m_rSvXMLImport;
330 }
331 
333 {
334  return *m_xImpl->m_xTextListsHelper;
335 }
336 
337 namespace
338 {
339  class FieldParamImporter
340  {
341  public:
342  typedef pair<OUString,OUString> field_param_t;
343  typedef vector<field_param_t> field_params_t;
344  FieldParamImporter(const field_params_t* const pInParams, Reference<XNameContainer> const & xOutParams)
345  : m_pInParams(pInParams)
346  , m_xOutParams(xOutParams)
347  { };
348  void Import();
349 
350  private:
351  const field_params_t* const m_pInParams;
352  Reference<XNameContainer> m_xOutParams;
353  };
354 
355  void FieldParamImporter::Import()
356  {
357  ::std::vector<OUString> vListEntries;
358  ::std::map<OUString, Any> vOutParams;
359  for(const auto& rCurrent : *m_pInParams)
360  {
361  if(rCurrent.first == ODF_FORMDROPDOWN_RESULT)
362  {
363  // sal_Int32
364  vOutParams[rCurrent.first] <<= rCurrent.second.toInt32();
365  }
366  else if(rCurrent.first == ODF_FORMCHECKBOX_RESULT)
367  {
368  // bool
369  vOutParams[rCurrent.first] <<= rCurrent.second.toBoolean();
370  }
371  else if(rCurrent.first == ODF_FORMDROPDOWN_LISTENTRY)
372  {
373  // sequence
374  vListEntries.push_back(rCurrent.second);
375  }
376  else
377  vOutParams[rCurrent.first] <<= rCurrent.second;
378  }
379  if(!vListEntries.empty())
380  {
381  Sequence<OUString> vListEntriesSeq(vListEntries.size());
382  copy(vListEntries.begin(), vListEntries.end(), vListEntriesSeq.begin());
383  vOutParams[OUString(ODF_FORMDROPDOWN_LISTENTRY)] <<= vListEntriesSeq;
384  }
385  for(const auto& rCurrent : vOutParams)
386  {
387  try
388  {
389  m_xOutParams->insertByName(rCurrent.first, rCurrent.second);
390  }
391  catch(const ElementExistException&)
392  {
393  SAL_INFO("xmloff.text", "duplicate fieldmark param");
394  }
395  }
396  }
397 }
398 
400  uno::Reference<frame::XModel> const& rModel,
401  SvXMLImport& rImport,
402  bool const bInsertMode, bool const bStylesOnlyMode,
403  bool const bProgress, bool const bBlockMode,
404  bool const bOrganizerMode)
405  : m_xImpl( new Impl(rModel, rImport, bInsertMode, bStylesOnlyMode,
406  bProgress, bBlockMode, bOrganizerMode) )
407  , m_xBackpatcherImpl( MakeBackpatcherImpl() )
408 {
409  static constexpr OUStringLiteral s_PropNameDefaultListId = u"DefaultListId";
410 
411  Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY );
412 
413  if (xCNSupplier.is())
414  {
415  // note: m_xChapterNumbering is accessed to import some fields
416  m_xImpl->m_xChapterNumbering = xCNSupplier->getChapterNumberingRules();
417  // the AutoCorrect document doesn't have a proper outline numbering
418  if (!IsBlockMode() && m_xImpl->m_xChapterNumbering.is())
419  {
420  Reference< XPropertySet > const xNumRuleProps(
421  m_xImpl->m_xChapterNumbering, UNO_QUERY);
422  if ( xNumRuleProps.is() )
423  {
424  Reference< XPropertySetInfo > xNumRulePropSetInfo(
425  xNumRuleProps->getPropertySetInfo());
426  if (xNumRulePropSetInfo.is() &&
427  xNumRulePropSetInfo->hasPropertyByName(
428  s_PropNameDefaultListId))
429  {
430  OUString sListId;
431  xNumRuleProps->getPropertyValue(s_PropNameDefaultListId)
432  >>= sListId;
433  assert( !sListId.isEmpty() &&
434  "no default list id found at chapter numbering rules instance. Serious defect." );
435  if ( !sListId.isEmpty() )
436  {
437  Reference< XNamed > const xChapterNumNamed(
438  m_xImpl->m_xChapterNumbering, UNO_QUERY);
439  if ( xChapterNumNamed.is() )
440  {
441  m_xImpl->m_xTextListsHelper->KeepListAsProcessed(
442  sListId,
443  xChapterNumNamed->getName(),
444  OUString() );
445  }
446  }
447  }
448  }
449  }
450  }
451 
452  Reference< XStyleFamiliesSupplier > xFamiliesSupp( rModel, UNO_QUERY );
453 // SAL_WARN_IF( !xFamiliesSupp.is(), "xmloff", "no chapter numbering supplier" ); for clipboard there may be documents without styles
454 
455  if( xFamiliesSupp.is() )
456  {
457  Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
458 
459  const OUString aParaStyles("ParagraphStyles");
460  if( xFamilies->hasByName( aParaStyles ) )
461  {
462  m_xImpl->m_xParaStyles.set(xFamilies->getByName(aParaStyles),
463  UNO_QUERY);
464  }
465 
466  const OUString aCharStyles("CharacterStyles");
467  if( xFamilies->hasByName( aCharStyles ) )
468  {
469  m_xImpl->m_xTextStyles.set(xFamilies->getByName(aCharStyles),
470  UNO_QUERY);
471  }
472 
473  const OUString aNumStyles("NumberingStyles");
474  if( xFamilies->hasByName( aNumStyles ) )
475  {
476  m_xImpl->m_xNumStyles.set(xFamilies->getByName(aNumStyles),
477  UNO_QUERY);
478  }
479 
480  const OUString aFrameStyles("FrameStyles");
481  if( xFamilies->hasByName( aFrameStyles ) )
482  {
483  m_xImpl->m_xFrameStyles.set(xFamilies->getByName(aFrameStyles),
484  UNO_QUERY);
485  }
486 
487  const OUString aPageStyles("PageStyles");
488  if( xFamilies->hasByName( aPageStyles ) )
489  {
490  m_xImpl->m_xPageStyles.set(xFamilies->getByName(aPageStyles),
491  UNO_QUERY);
492  }
493 
494  const OUString aCellStyles("CellStyles");
495  if( xFamilies->hasByName( aCellStyles ) )
496  {
497  m_xImpl->m_xCellStyles.set(xFamilies->getByName(aCellStyles),
498  UNO_QUERY);
499  }
500  }
501 
502  Reference < XTextFramesSupplier > xTFS( rModel, UNO_QUERY );
503  if( xTFS.is() )
504  {
505  m_xImpl->m_xTextFrames.set(xTFS->getTextFrames());
506  }
507 
508  Reference < XTextGraphicObjectsSupplier > xTGOS( rModel, UNO_QUERY );
509  if( xTGOS.is() )
510  {
511  m_xImpl->m_xGraphics.set(xTGOS->getGraphicObjects());
512  }
513 
514  Reference < XTextEmbeddedObjectsSupplier > xTEOS( rModel, UNO_QUERY );
515  if( xTEOS.is() )
516  {
517  m_xImpl->m_xObjects.set(xTEOS->getEmbeddedObjects());
518  }
519 
520  XMLPropertySetMapper *pPropMapper =
522  m_xImpl->m_xParaImpPrMap =
523  new XMLTextImportPropertyMapper( pPropMapper, rImport );
524 
525  pPropMapper = new XMLTextPropertySetMapper( TextPropMap::TEXT, false );
526  m_xImpl->m_xTextImpPrMap =
527  new XMLTextImportPropertyMapper( pPropMapper, rImport );
528 
529  pPropMapper = new XMLTextPropertySetMapper( TextPropMap::FRAME, false );
530  m_xImpl->m_xFrameImpPrMap =
531  new XMLTextImportPropertyMapper( pPropMapper, rImport );
532 
533  pPropMapper = new XMLTextPropertySetMapper( TextPropMap::SECTION, false );
534  m_xImpl->m_xSectionImpPrMap =
535  new XMLTextImportPropertyMapper( pPropMapper, rImport );
536 
537  pPropMapper = new XMLTextPropertySetMapper( TextPropMap::RUBY, false );
538  m_xImpl->m_xRubyImpPrMap =
539  new SvXMLImportPropertyMapper( pPropMapper, rImport );
540 }
541 
543 {
544 }
545 
547 {
548  if (m_xImpl->m_xAutoStyles)
549  m_xImpl->m_xAutoStyles->dispose();
550 }
551 
553 {
554  XMLPropertySetMapper *pPropMapper =
556  return new XMLTextImportPropertyMapper( pPropMapper, rImport );
557 }
558 
560 {
561  XMLPropertySetMapper *pPropMapper =
563  return new XMLTextImportPropertyMapper( pPropMapper, rImport );
564 }
565 
567 {
568  XMLPropertySetMapper* pPropMapper =
570  SvXMLImportPropertyMapper* pImportMapper = new XMLTextImportPropertyMapper( pPropMapper, rImport );
571 
572  pPropMapper =
574  pImportMapper->ChainImportMapper( new XMLTextImportPropertyMapper( pPropMapper, rImport ) );
575 
576  return pImportMapper;
577 }
578 
581  SvXMLImport& rImport )
582 {
583  XMLPropertySetMapper *pPropMapper =
585  return new SvXMLImportPropertyMapper( pPropMapper, rImport );
586 }
587 
590  SvXMLImport& rImport )
591 {
592  XMLPropertySetMapper *pPropMapper =
594  return new SvXMLImportPropertyMapper( pPropMapper, rImport );
595 }
596 
599  SvXMLImport& rImport )
600 {
601  XMLPropertySetMapper *pPropMapper =
603  return new XMLTextImportPropertyMapper( pPropMapper, rImport );
604 }
605 
608 {
610  XMLPropertySetMapper *const pPropMapper(
612  return new SvXMLImportPropertyMapper(pPropMapper, rImport);
613 }
614 
615 void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor )
616 {
617  m_xImpl->m_xCursor.set(rCursor);
618  m_xImpl->m_xText.set(rCursor->getText());
619  m_xImpl->m_xCursorAsRange = rCursor;
620 }
621 
623 {
624  m_xImpl->m_xCursor.set(nullptr);
625  m_xImpl->m_xText.set(nullptr);
626  m_xImpl->m_xCursorAsRange.set(nullptr);
627 }
628 
629 
630 bool XMLTextImportHelper::HasFrameByName( const OUString& rName ) const
631 {
632  return (m_xImpl->m_xTextFrames.is() &&
633  m_xImpl->m_xTextFrames->hasByName(rName))
634  || (m_xImpl->m_xGraphics.is() &&
635  m_xImpl->m_xGraphics->hasByName(rName))
636  || (m_xImpl->m_xObjects.is() &&
637  m_xImpl->m_xObjects->hasByName(rName));
638 }
639 
640 bool XMLTextImportHelper::IsDuplicateFrame(const OUString& sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const
641 {
642  if (HasFrameByName(sName))
643  {
644  uno::Reference<beans::XPropertySet> xOtherFrame;
645  if(m_xImpl->m_xTextFrames.is() && m_xImpl->m_xTextFrames->hasByName(sName))
646  xOtherFrame.set(m_xImpl->m_xTextFrames->getByName(sName), uno::UNO_QUERY);
647  else if(m_xImpl->m_xGraphics.is() && m_xImpl->m_xGraphics->hasByName(sName))
648  xOtherFrame.set(m_xImpl->m_xGraphics->getByName(sName), uno::UNO_QUERY);
649  else if (m_xImpl->m_xObjects.is() && m_xImpl->m_xObjects->hasByName(sName))
650  xOtherFrame.set(m_xImpl->m_xObjects->getByName(sName), uno::UNO_QUERY);
651 
652  Reference< XPropertySetInfo > xPropSetInfo = xOtherFrame->getPropertySetInfo();
653  if(xPropSetInfo->hasPropertyByName("Width"))
654  {
655  sal_Int32 nOtherWidth = 0;
656  xOtherFrame->getPropertyValue("Width") >>= nOtherWidth;
657  if(nWidth != nOtherWidth)
658  return false;
659  }
660 
661  if (xPropSetInfo->hasPropertyByName("Height"))
662  {
663  sal_Int32 nOtherHeight = 0;
664  xOtherFrame->getPropertyValue("Height") >>= nOtherHeight;
665  if (nHeight != nOtherHeight)
666  return false;
667  }
668 
669  if (xPropSetInfo->hasPropertyByName("HoriOrientPosition"))
670  {
671  sal_Int32 nOtherX = 0;
672  xOtherFrame->getPropertyValue("HoriOrientPosition") >>= nOtherX;
673  if (nX != nOtherX)
674  return false;
675  }
676 
677  if (xPropSetInfo->hasPropertyByName("VertOrientPosition"))
678  {
679  sal_Int32 nOtherY = 0;
680  xOtherFrame->getPropertyValue("VertOrientPosition") >>= nOtherY;
681  if (nY != nOtherY)
682  return false;
683  }
684 
685  // In some case, position is not defined for frames, so check whether the two frames follow each other (are anchored to the same position)
686  return m_xImpl->msLastImportedFrameName == sName;
687  }
688  return false;
689 }
690 
692 {
693  m_xImpl->msLastImportedFrameName = rName;
694 }
695 
697 {
698  m_xImpl->msLastImportedFrameName.clear();
699 }
700 
701 void XMLTextImportHelper::InsertString( const OUString& rChars )
702 {
703  assert(m_xImpl->m_xText.is());
704  assert(m_xImpl->m_xCursorAsRange.is());
705  if (m_xImpl->m_xText.is())
706  {
707  m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange,
708  rChars, false);
709  }
710 }
711 
712 void XMLTextImportHelper::InsertString( const OUString& rChars,
713  bool& rIgnoreLeadingSpace )
714 {
715  assert(m_xImpl->m_xText.is());
716  assert(m_xImpl->m_xCursorAsRange.is());
717  if (m_xImpl->m_xText.is())
718  {
719  sal_Int32 nLen = rChars.getLength();
720  OUStringBuffer sChars( nLen );
721 
722  for( sal_Int32 i=0; i < nLen; i++ )
723  {
724  sal_Unicode c = rChars[i];
725  switch( c )
726  {
727  case 0x20:
728  case 0x09:
729  case 0x0a:
730  case 0x0d:
731  if( !rIgnoreLeadingSpace )
732  sChars.append( u' ' );
733  rIgnoreLeadingSpace = true;
734  break;
735  default:
736  rIgnoreLeadingSpace = false;
737  sChars.append( c );
738  break;
739  }
740  }
741  m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange,
742  sChars.makeStringAndClear(), false);
743  }
744 }
745 
747 {
748  assert(m_xImpl->m_xText.is());
749  assert(m_xImpl->m_xCursorAsRange.is());
750  if (m_xImpl->m_xText.is())
751  {
752  m_xImpl->m_xText->insertControlCharacter(
753  m_xImpl->m_xCursorAsRange, nControl, false);
754  }
755 }
756 
758  Reference < XTextContent > const & xContent )
759 {
760  assert(m_xImpl->m_xText.is());
761  assert(m_xImpl->m_xCursorAsRange.is());
762  if (m_xImpl->m_xText.is())
763  {
764  // note: this may throw IllegalArgumentException and callers handle it
765  m_xImpl->m_xText->insertTextContent( m_xImpl->m_xCursorAsRange, xContent, false);
766  }
767 }
768 
770 {
771  assert(m_xImpl->m_xText.is());
772  assert(m_xImpl->m_xCursor.is());
773  assert(m_xImpl->m_xCursorAsRange.is());
774 
775  bool bDelete = true;
776  Reference < XEnumerationAccess > const xEnumAccess(
777  m_xImpl->m_xCursor, UNO_QUERY);
778  if( xEnumAccess.is() )
779  {
780  Reference < XEnumeration > xEnum(xEnumAccess->createEnumeration());
781  SAL_WARN_IF(!xEnum->hasMoreElements(), "xmloff.text",
782  "empty text enumeration");
783  if( xEnum->hasMoreElements() )
784  {
785  Reference < XComponent > xComp( xEnum->nextElement(), UNO_QUERY );
786  assert(xComp.is());
787  if( xComp.is() )
788  {
789  xComp->dispose();
790  bDelete = false;
791  }
792  }
793  }
794  if( bDelete )
795  {
796  if (m_xImpl->m_xCursor->goLeft( 1, true ))
797  {
798  m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange,
799  "", true);
800  }
801  }
802 }
803 
804 OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars,
805  const OUString& rStyleName,
806  sal_uInt8& rFlags,
807  bool bPara,
808  SvXMLImport& rImport ) const
809 {
810  OUStringBuffer sChars( rChars );
811  bool bConverted = false;
812  for( sal_Int32 j=0; j<rChars.getLength(); j++ )
813  {
814  sal_Unicode c = rChars[j];
815  if( c >= 0xf000 && c <= 0xf0ff )
816  {
817  if( (rFlags & CONV_STAR_FONT_FLAGS_VALID) == 0 )
818  {
819  XMLTextStyleContext *pStyle = nullptr;
822  if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is())
823  {
824  const SvXMLStyleContext* pTempStyle =
825  m_xImpl->m_xAutoStyles->
826  FindStyleChildContext( nFamily, rStyleName,
827  true );
828  pStyle = const_cast<XMLTextStyleContext*>( dynamic_cast< const XMLTextStyleContext* >(pTempStyle));
829  }
830 
831  if( pStyle )
832  {
833  sal_Int32 nCount = pStyle->GetProperties_().size();
834  if( nCount )
835  {
837  m_xImpl->m_xAutoStyles->GetImportPropertyMapper(nFamily);
838  if( xImpPrMap.is() )
839  {
841  xImpPrMap->getPropertySetMapper();
842  for( sal_Int32 i=0; i < nCount; i++ )
843  {
844  const XMLPropertyState& rProp = pStyle->GetProperties_()[i];
845  sal_Int32 nIdx = rProp.mnIndex;
846  sal_uInt32 nContextId = rPropMapper->GetEntryContextId(nIdx);
847  if( CTF_FONTFAMILYNAME == nContextId )
848  {
850  OUString sFontName;
851  rProp.maValue >>= sFontName;
852  if( sFontName.equalsIgnoreAsciiCase( "StarBats" ) )
853  rFlags |= CONV_FROM_STAR_BATS;
854  else if( sFontName.equalsIgnoreAsciiCase( "StarMath" ) )
855  rFlags |= CONV_FROM_STAR_MATH;
856  break;
857  }
858  }
859  }
860  }
861 
862  }
863 
864  rFlags |= CONV_STAR_FONT_FLAGS_VALID;
865  }
866  if( (rFlags & CONV_FROM_STAR_BATS ) != 0 )
867  {
868  sChars[j] = rImport.ConvStarBatsCharToStarSymbol( c );
869  bConverted = true;
870  }
871  else if( (rFlags & CONV_FROM_STAR_MATH ) != 0 )
872  {
873  sChars[j] = rImport.ConvStarMathCharToStarSymbol( c );
874  bConverted = true;
875  }
876  }
877  }
878 
879  return bConverted ? sChars.makeStringAndClear() : rChars;
880 }
881 
882 /* Helper method to determine, if a paragraph style has a list style (inclusive
883  an empty one) inherits a list style (inclusive an empty one) from one of its parents (#i69629#)
884 */
885 /* Apply special case, that found list style equals the chapter numbering, also
886  to the found list styles of the parent styles. (#i73973#)
887 */
888 static bool lcl_HasListStyle( const OUString& sStyleName,
889  const Reference < XNameContainer >& xParaStyles,
890  SvXMLImport const & rImport,
891  const OUString& sNumberingStyleName,
892  std::u16string_view sOutlineStyleName )
893 {
894  bool bRet( false );
895 
896  if ( !xParaStyles->hasByName( sStyleName ) )
897  {
898  // error case
899  return true;
900  }
901 
902  Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ),
903  UNO_QUERY );
904  if ( !xPropState.is() )
905  {
906  // error case
907  return false;
908  }
909 
910  if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
911  {
912  // list style found
913  bRet = true;
914  // special case: the set list style equals the chapter numbering
915  Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
916  if ( xPropSet.is() )
917  {
918  OUString sListStyle;
919  xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
920  if ( !sListStyle.isEmpty() &&
921  sListStyle == sOutlineStyleName )
922  {
923  bRet = false;
924  }
925  }
926  }
927  else
928  {
929  // Tools.Outline settings lost on Save (#i77708#)
930  sal_Int32 nUPD( 0 );
931  sal_Int32 nBuild( 0 );
932  // Don't use UPD for versioning: xmloff/source/text/txtstyli.cxx and txtimp.cxx (#i86058#)
933  const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
934  // search list style at parent
935  Reference<XStyle> xStyle( xPropState, UNO_QUERY );
936  while ( xStyle.is() )
937  {
938  OUString aParentStyle( xStyle->getParentStyle() );
939  if ( !aParentStyle.isEmpty() )
940  {
941  aParentStyle =
943  aParentStyle );
944  }
945  if ( aParentStyle.isEmpty() || !xParaStyles->hasByName( aParentStyle ) )
946  {
947  // no list style found
948  break;
949  }
950  else
951  {
952  xPropState.set( xParaStyles->getByName( aParentStyle ),
953  UNO_QUERY );
954  if ( !xPropState.is() )
955  {
956  // error case
957  return true;
958  }
959  if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE )
960  {
961  // list style found
962  bRet = true;
963  // Special case: the found list style equals the chapter numbering (#i73973#)
964  Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY );
965  if ( xPropSet.is() )
966  {
967  OUString sListStyle;
968  xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle;
969  if ( !sListStyle.isEmpty() &&
970  sListStyle == sOutlineStyleName )
971  {
972  bRet = false;
973  }
974  // Special handling for text documents from OOo version prior OOo 2.4 (#i77708#)
975  /* Check explicitly on certain versions and on import of
976  text documents in OpenOffice.org file format (#i86058#)
977  */
978  else if ( sListStyle.isEmpty() &&
979  ( rImport.IsTextDocInOOoFileFormat() ||
980  ( bBuildIdFound &&
981  ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
982  ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1
983  {
984  bRet = false;
985  }
986  }
987  break;
988  }
989  else
990  {
991  // search list style at parent
992  Reference<XStyle> xParentStyle(xPropState, UNO_QUERY);
993  if (xStyle == xParentStyle)
994  {
995  // error case
996  return true;
997  }
998  xStyle = xParentStyle;
999  }
1000  }
1001  }
1002  }
1003 
1004  return bRet;
1005 }
1007  SvXMLImport const & rImport,
1008  const Reference < XTextCursor >& rCursor,
1009  const OUString& rStyleName,
1010  bool bPara,
1011  bool bOutlineLevelAttrFound,
1012  sal_Int8 nOutlineLevel,
1013  // Numberings/Bullets in table not visible after save/reload (#i80724#)
1014  bool bSetListAttrs,
1015  bool bOutlineContentVisible)
1016 {
1017  static constexpr OUStringLiteral s_NumberingRules = u"NumberingRules";
1018  static constexpr OUStringLiteral s_NumberingIsNumber = u"NumberingIsNumber";
1019  static constexpr OUStringLiteral s_NumberingLevel = u"NumberingLevel";
1020  static constexpr OUStringLiteral s_ParaIsNumberingRestart = u"ParaIsNumberingRestart";
1021  static constexpr OUStringLiteral s_NumberingStartValue = u"NumberingStartValue";
1022  static constexpr OUStringLiteral s_PropNameListId = u"ListId";
1023  static constexpr OUStringLiteral s_PageDescName = u"PageDescName";
1024  static constexpr OUStringLiteral s_OutlineLevel = u"OutlineLevel";
1025 
1026  const XmlStyleFamily nFamily = bPara ? XmlStyleFamily::TEXT_PARAGRAPH
1028  XMLTextStyleContext *pStyle = nullptr;
1029  OUString sStyleName( rStyleName );
1030  if (!sStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is())
1031  {
1032  const SvXMLStyleContext* pTempStyle =
1033  m_xImpl->m_xAutoStyles->FindStyleChildContext( nFamily, sStyleName, true );
1034  pStyle = const_cast<XMLTextStyleContext*>(dynamic_cast< const XMLTextStyleContext* >(pTempStyle));
1035  }
1036  if( pStyle )
1037  sStyleName = pStyle->GetParentName();
1038 
1039  Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1040  Reference< XPropertySetInfo > xPropSetInfo(
1041  xPropSet->getPropertySetInfo());
1042 
1043  // style
1044  if( !sStyleName.isEmpty() )
1045  {
1046  sStyleName = rImport.GetStyleDisplayName( nFamily, sStyleName );
1047  const OUString rPropName = bPara ? OUString("ParaStyleName") : OUString("CharStyleName");
1048  const Reference < XNameContainer > & rStyles = bPara
1049  ? m_xImpl->m_xParaStyles
1050  : m_xImpl->m_xTextStyles;
1051  if( rStyles.is() &&
1052  xPropSetInfo->hasPropertyByName( rPropName ) &&
1053  rStyles->hasByName( sStyleName ) )
1054  {
1055  xPropSet->setPropertyValue( rPropName, makeAny(sStyleName) );
1056  }
1057  else
1058  sStyleName.clear();
1059  }
1060 
1061  /* The outline level needs to be only applied as list level, if the heading
1062  is not inside a list and if it by default applies the outline style. (#i70748#)
1063  */
1064  bool bApplyOutlineLevelAsListLevel( false );
1065  // Numberings/Bullets in table not visible after save/reload (#i80724#)
1066  if (bSetListAttrs && bPara
1067  && xPropSetInfo->hasPropertyByName( s_NumberingRules))
1068  {
1069  // Set numbering rules
1070  Reference< XIndexReplace > const xNumRules(
1071  xPropSet->getPropertyValue(s_NumberingRules), UNO_QUERY);
1072 
1073  XMLTextListBlockContext * pListBlock(nullptr);
1074  XMLTextListItemContext * pListItem(nullptr);
1075  XMLNumberedParaContext * pNumberedParagraph(nullptr);
1077  pListBlock, pListItem, pNumberedParagraph);
1078 
1079  assert(!(pListBlock && pNumberedParagraph) && "XMLTextImportHelper::"
1080  "SetStyleAndAttrs: both list and numbered-paragraph???");
1081 
1082  Reference < XIndexReplace > xNewNumRules;
1083  sal_Int8 nLevel(-1);
1084  OUString sListId;
1085  sal_Int16 nStartValue(-1);
1086  bool bNumberingIsNumber(true);
1087 
1088  if (pListBlock) {
1089 
1090  if (!pListItem) {
1091  bNumberingIsNumber = false; // list-header
1092  }
1093  // consider text:style-override property of <text:list-item>
1094  xNewNumRules.set(
1095  (pListItem != nullptr && pListItem->HasNumRulesOverride())
1096  ? pListItem->GetNumRulesOverride()
1097  : pListBlock->GetNumRules() );
1098  nLevel = static_cast<sal_Int8>(pListBlock->GetLevel());
1099 
1100  if ( pListItem && pListItem->HasStartValue() ) {
1101  nStartValue = pListItem->GetStartValue();
1102  }
1103 
1104  // Inconsistent behavior regarding lists (#i92811#)
1105  sListId = m_xImpl->m_xTextListsHelper->GetListIdForListBlock(
1106  *pListBlock);
1107  }
1108  else if (pNumberedParagraph)
1109  {
1110  xNewNumRules.set(pNumberedParagraph->GetNumRules());
1111  nLevel = static_cast<sal_Int8>(pNumberedParagraph->GetLevel());
1112  sListId = pNumberedParagraph->GetListId();
1113  nStartValue = pNumberedParagraph->GetStartValue();
1114  }
1115 
1116 
1117  if (pListBlock || pNumberedParagraph)
1118  {
1119  // Assure that list style of automatic paragraph style is applied at paragraph. (#i101349#)
1120  bool bApplyNumRules = pStyle && pStyle->IsListStyleSet();
1121  if ( !bApplyNumRules )
1122  {
1123  bool bSameNumRules = xNewNumRules == xNumRules;
1124  if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
1125  {
1126  // If the interface pointers are different, then this does
1127  // not mean that the num rules are different. Further tests
1128  // are required then. However, if only one num rule is
1129  // set, no tests are required of course.
1130  Reference< XNamed > xNewNamed( xNewNumRules, UNO_QUERY );
1131  Reference< XNamed > xNamed( xNumRules, UNO_QUERY );
1132  if( xNewNamed.is() && xNamed.is() )
1133  {
1134  bSameNumRules = xNewNamed->getName() == xNamed->getName();
1135  }
1136  else
1137  {
1138  Reference< XAnyCompare > xNumRuleCompare( xNumRules, UNO_QUERY );
1139  if( xNumRuleCompare.is() )
1140  {
1141  bSameNumRules = (xNumRuleCompare->compare( Any(xNumRules), Any(xNewNumRules) ) == 0);
1142  }
1143  }
1144  }
1145  bApplyNumRules = !bSameNumRules;
1146  }
1147 
1148  if ( bApplyNumRules )
1149  {
1150  // #102607# This may except when xNewNumRules contains
1151  // a Writer-NumRule-Implementation bug gets applied to
1152  // a shape. Since this may occur inside a document
1153  // (e.g. when edited), this must be handled
1154  // gracefully.
1155  try
1156  {
1157  xPropSet->setPropertyValue(
1158  s_NumberingRules, makeAny(xNewNumRules) );
1159  }
1160  catch(const Exception&)
1161  {
1162  ; // I would really like to use a warning here,
1163  // but I can't access the XMLErrorHandler from
1164  // here.
1165  }
1166  }
1167 
1168  if (!bNumberingIsNumber &&
1169  xPropSetInfo->hasPropertyByName(s_NumberingIsNumber))
1170  {
1171  xPropSet->setPropertyValue(s_NumberingIsNumber, Any(false));
1172  }
1173 
1174  xPropSet->setPropertyValue( s_NumberingLevel, Any(nLevel) );
1175 
1176  if( pListBlock && pListBlock->IsRestartNumbering() )
1177  {
1178  // TODO: property missing
1179  if (xPropSetInfo->hasPropertyByName(s_ParaIsNumberingRestart))
1180  {
1181  xPropSet->setPropertyValue(s_ParaIsNumberingRestart,
1182  makeAny(true) );
1183  }
1184  pListBlock->ResetRestartNumbering();
1185  }
1186 
1187  if ( 0 <= nStartValue &&
1188  xPropSetInfo->hasPropertyByName(s_NumberingStartValue))
1189  {
1190  xPropSet->setPropertyValue(s_NumberingStartValue,
1191  makeAny(nStartValue));
1192  }
1193 
1194  if (xPropSetInfo->hasPropertyByName(s_PropNameListId))
1195  {
1196  if (!sListId.isEmpty()) {
1197  xPropSet->setPropertyValue(s_PropNameListId,
1198  makeAny(sListId) );
1199  }
1200  }
1201 
1202  GetTextListHelper().SetListItem( nullptr );
1203  }
1204  else
1205  {
1206  /* If the paragraph is not in a list but its style, remove it from
1207  the list. Do not remove it, if the list of the style is
1208  the chapter numbering rule.
1209  */
1210  if( xNumRules.is() )
1211  {
1212  bool bRemove( true );
1213  // Special handling for document from OOo 2.x (#i70748#)
1214  sal_Int32 nUPD( 0 );
1215  sal_Int32 nBuild( 0 );
1216  const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1217  if ( ( bBuildIdFound && nUPD == 680 ) ||
1218  !pStyle || !pStyle->IsListStyleSet() )
1219  {
1220  if (m_xImpl->m_xChapterNumbering.is())
1221  {
1222  Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY );
1223  Reference< XNamed > const xChapterNumNamed (
1224  m_xImpl->m_xChapterNumbering, UNO_QUERY);
1225  if ( xNumNamed.is() && xChapterNumNamed.is() &&
1226  xNumNamed->getName() == xChapterNumNamed->getName() )
1227  {
1228  bRemove = false;
1229  // RFE: inserting headings into text documents (#i70748#)
1230  bApplyOutlineLevelAsListLevel = true;
1231  }
1232  }
1233  }
1234  else
1235  {
1236  SAL_INFO_IF(!pStyle->GetListStyle().isEmpty(),
1237  "xmloff.text",
1238  "automatic paragraph style with list style name, but paragraph not in list???");
1239  }
1240  if ( bRemove )
1241  {
1242  xPropSet->setPropertyValue( s_NumberingRules, Any() );
1243  }
1244  }
1245  }
1246  }
1247 
1248  // hard paragraph properties
1249  if( pStyle )
1250  {
1251  pStyle->FillPropertySet( xPropSet );
1252  if( bPara && pStyle->HasMasterPageName() &&
1253  xPropSetInfo->hasPropertyByName(s_PageDescName))
1254  {
1255  OUString sDisplayName(
1256  rImport.GetStyleDisplayName(
1258  pStyle->GetMasterPageName()) );
1259  if( sDisplayName.isEmpty() ||
1260  (m_xImpl->m_xPageStyles.is() &&
1261  m_xImpl->m_xPageStyles->hasByName( sDisplayName)))
1262  {
1263  xPropSet->setPropertyValue(s_PageDescName,
1264  makeAny(sDisplayName));
1265  }
1266  }
1267  if( bPara && !pStyle->GetDropCapStyleName().isEmpty() &&
1268  m_xImpl->m_xTextStyles.is())
1269  {
1270  OUString sDisplayName(
1271  rImport.GetStyleDisplayName(
1273  pStyle->GetDropCapStyleName()) );
1274  if (m_xImpl->m_xTextStyles->hasByName(sDisplayName) &&
1275  xPropSetInfo->hasPropertyByName("DropCapCharStyleName"))
1276  {
1277  xPropSet->setPropertyValue("DropCapCharStyleName", makeAny(sDisplayName));
1278  }
1279  }
1280 
1281  // combined characters special treatment
1282  if (!bPara && pStyle->HasCombinedCharactersLetter())
1283  {
1284  // insert combined characters text field
1285  if (m_xImpl->m_xServiceFactory.is())
1286  {
1287  uno::Reference<beans::XPropertySet> const xTmp(
1288  m_xImpl->m_xServiceFactory->createInstance(
1289  "com.sun.star.text.TextField.CombinedCharacters"), UNO_QUERY);
1290  if( xTmp.is() )
1291  {
1292  // fix cursor if larger than possible for
1293  // combined characters field
1294  if (rCursor->getString().getLength() >
1296  {
1297  rCursor->gotoRange(rCursor->getStart(), false);
1298  rCursor->goRight(MAX_COMBINED_CHARACTERS, true);
1299  }
1300 
1301  // set field value (the combined character string)
1302  xTmp->setPropertyValue("Content",
1303  makeAny(rCursor->getString()));
1304 
1305  // insert the field over it's original text
1306  Reference<XTextContent> xTextContent(xTmp, UNO_QUERY);
1307  if (m_xImpl->m_xText.is() && rCursor.is())
1308  {
1309  // #i107225# the combined characters need to be inserted first
1310  // the selected text has to be removed afterwards
1311  m_xImpl->m_xText->insertTextContent( rCursor->getStart(), xTextContent, true );
1312 
1313  if( !rCursor->getString().isEmpty() )
1314  {
1315  try
1316  {
1317  uno::Reference< text::XTextCursor > xCrsr = rCursor->getText()->createTextCursorByRange( rCursor->getStart() );
1318  xCrsr->goLeft( 1, true );
1319  uno::Reference< beans::XPropertySet> xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW );
1320  //the hard properties of the removed text need to be applied to the combined characters field
1321  pStyle->FillPropertySet( xCrsrProperties );
1322  xCrsr->collapseToEnd();
1323  xCrsr->gotoRange( rCursor->getEnd(), true );
1324  xCrsr->setString( OUString() );
1325  }
1326  catch(const uno::Exception&)
1327  {
1328  }
1329  }
1330  }
1331  }
1332  }
1333  }
1334  }
1335 
1336  // outline level; set after list style has been set
1337  // Complete re-worked and corrected: (#i53198#)
1338  // - set outline level at paragraph
1339  // - set numbering level at paragraph, if none is already set
1340  // - assure that style is marked as an outline style for the corresponding
1341  // outline level.
1342  // - DO NOT set type of numbering rule to outline.
1343  // - DO NOT set numbering rule directly at the paragraph.
1344 
1345  // Some minor rework and adjust access to paragraph styles (#i70748#)
1346  if ( bPara )
1347  {
1348  // Headings not numbered anymore in 3.1 (#i103817#)
1349  sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
1350  const bool bHasOutlineLevelProp(
1351  xPropSetInfo->hasPropertyByName(s_OutlineLevel));
1352  if ( bHasOutlineLevelProp )
1353  {
1354  xPropSet->getPropertyValue(s_OutlineLevel)
1355  >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
1356  }
1357  if ( nOutlineLevel > 0 )
1358  {
1359  if ( bHasOutlineLevelProp )
1360  {
1361  // In case that the value equals the value of its paragraph style
1362  // attribute outline level, the paragraph attribute value is left unset
1363  if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
1364  {
1365  xPropSet->setPropertyValue( s_OutlineLevel,
1366  makeAny( static_cast<sal_Int16>(nOutlineLevel) ) );
1367  }
1368  }
1369  if (!bOutlineContentVisible)
1370  {
1371  uno::Sequence<beans::PropertyValue> aGrabBag;
1372  xPropSet->getPropertyValue("ParaInteropGrabBag") >>= aGrabBag;
1373  sal_Int32 length = aGrabBag.getLength();
1374  aGrabBag.realloc(length + 1);
1375  aGrabBag[length].Name = "OutlineContentVisibleAttr";
1376  aGrabBag[length].Value <<= bool(bOutlineContentVisible);
1377  xPropSet->setPropertyValue("ParaInteropGrabBag", uno::makeAny(aGrabBag));
1378  }
1379  // RFE: inserting headings into text documents (#i70748#)
1380  if ( bApplyOutlineLevelAsListLevel )
1381  {
1382  sal_Int16 nNumLevel = -1;
1383  xPropSet->getPropertyValue( s_NumberingLevel ) >>= nNumLevel;
1384  if ( nNumLevel == -1 ||
1385  nNumLevel != (nOutlineLevel - 1) )
1386  {
1387  xPropSet->setPropertyValue( s_NumberingLevel,
1388  makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1389  }
1390  }
1391  /* Correction: (#i69629#)
1392  - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1393  the paragraph style of a heading should be assigned to the
1394  corresponding list level of the outline style.
1395  - for other text documents the paragraph style of a heading is only
1396  a candidate for an assignment to the list level of the outline
1397  style, if it has no direct list style property and (if exists) the
1398  automatic paragraph style has also no direct list style set.
1399  */
1400  if (m_xImpl->m_xParaStyles.is() && m_xImpl->m_xParaStyles->hasByName(sStyleName))
1401  {
1402  bool bOutlineStyleCandidate( false );
1403 
1404  sal_Int32 nUPD( 0 );
1405  sal_Int32 nBuild( 0 );
1406  const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1407  // Lost outline numbering in master document (#i73509#)
1408  // Check explicitly on certain versions (#i86058#)
1409  if ( rImport.IsTextDocInOOoFileFormat() ||
1410  ( bBuildIdFound &&
1411  ( nUPD == 645 || nUPD == 641 ) ) )
1412  {
1413  bOutlineStyleCandidate = true;
1414  }
1415  else if ( nUPD == 680 && nBuild <= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1416  {
1417  bOutlineStyleCandidate = bOutlineLevelAttrFound;
1418  }
1419  if ( bOutlineStyleCandidate )
1420  {
1421  AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
1422  }
1423  // Assure that heading applies the outline style (#i103817#)
1424  if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
1425  !bOutlineStyleCandidate &&
1426  m_xImpl->m_xChapterNumbering.is())
1427  {
1428  if ( !lcl_HasListStyle( sStyleName,
1429  m_xImpl->m_xParaStyles, GetXMLImport(),
1430  u"NumberingStyleName",
1431  u"" ) )
1432  {
1433  // heading not in a list --> apply outline style
1434  xPropSet->setPropertyValue( s_NumberingRules,
1435  makeAny(m_xImpl->m_xChapterNumbering) );
1436  xPropSet->setPropertyValue( s_NumberingLevel,
1437  makeAny(static_cast<sal_Int8>(nOutlineLevel - 1)));
1438  }
1439  }
1440  }
1441  }
1442  //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1443  else if( bHasOutlineLevelProp )
1444  {
1445  if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
1446  {
1447  xPropSet->setPropertyValue(s_OutlineLevel,
1448  makeAny( sal_Int16(0) ));
1449  }
1450  }
1451  }
1452 
1453  return sStyleName;
1454 }
1455 
1457  sal_Int8 nOutlineLevel )
1458 {
1459  // style name empty?
1460  if( rStyleName.isEmpty() )
1461  {
1462  // Empty? Then we need o do stuff. Let's do error checking first.
1463  if (m_xImpl->m_xChapterNumbering.is() &&
1464  ( nOutlineLevel > 0 ) &&
1465  (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount()))
1466  {
1467  nOutlineLevel--; // for the remainder, the level's are 0-based
1468 
1469  // empty style name: look-up previously used name
1470 
1471  // if we don't have a previously used name, we'll use the default
1472  m_xImpl->InitOutlineStylesCandidates();
1473  if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty())
1474  {
1475  // no other name used previously? Then use default
1476 
1477  // iterate over property value sequence to find the style name
1478  Sequence<PropertyValue> aProperties;
1479  m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel )
1480  >>= aProperties;
1481  auto pProp = std::find_if(aProperties.begin(), aProperties.end(),
1482  [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; });
1483  if (pProp != aProperties.end())
1484  {
1485  OUString aOutlineStyle;
1486  pProp->Value >>= aOutlineStyle;
1487  m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel]
1488  .push_back( aOutlineStyle );
1489  }
1490  }
1491 
1492  // finally, we'll use the previously used style name for this
1493  // format (or the default we've just put into that style)
1494  // take last added one (#i71249#)
1495  rStyleName =
1496  m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back();
1497  }
1498  // else: nothing we can do, so we'll leave it empty
1499  }
1500  // else: we already had a style name, so we let it pass.
1501 }
1502 
1504  const OUString& rStyleName )
1505 {
1506  if (!rStyleName.isEmpty()
1507  && m_xImpl->m_xChapterNumbering.is()
1508  && (nOutlineLevel > 0)
1509  && (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount()))
1510  {
1511  m_xImpl->InitOutlineStylesCandidates();
1512  m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel-1].push_back(
1513  rStyleName);
1514  }
1515 }
1516 
1517 void XMLTextImportHelper::SetOutlineStyles( bool bSetEmptyLevels )
1518 {
1519  if (!(m_xImpl->m_xOutlineStylesCandidates != nullptr || bSetEmptyLevels) ||
1520  !m_xImpl->m_xChapterNumbering.is() ||
1521  IsInsertMode())
1522  return;
1523 
1524  bool bChooseLastOne( false );
1525  {
1526  if ( GetXMLImport().IsTextDocInOOoFileFormat() )
1527  {
1528  bChooseLastOne = true;
1529  }
1530  else
1531  {
1532  sal_Int32 nUPD( 0 );
1533  sal_Int32 nBuild( 0 );
1534  if ( GetXMLImport().getBuildIds( nUPD, nBuild ) )
1535  {
1536  // check explicitly on certain versions
1537  bChooseLastOne = ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1538  ( nUPD == 680 && nBuild <= 9073 ); // OOo 2.0 - OOo 2.0.4
1539  }
1540  }
1541  }
1542 
1543  OUString sOutlineStyleName;
1544  {
1545  Reference<XPropertySet> xChapterNumRule(
1546  m_xImpl->m_xChapterNumbering, UNO_QUERY);
1547  xChapterNumRule->getPropertyValue("Name") >>= sOutlineStyleName;
1548  }
1549 
1550  const sal_Int32 nCount = m_xImpl->m_xChapterNumbering->getCount();
1551  /* First collect all paragraph styles chosen for assignment to each
1552  list level of the outline style, then perform the intrinsic assignment.
1553  Reason: The assignment of a certain paragraph style to a list level
1554  of the outline style causes side effects on the children
1555  paragraph styles in Writer. (#i106218#)
1556  */
1557  ::std::vector<OUString> sChosenStyles(nCount);
1558  for( sal_Int32 i=0; i < nCount; ++i )
1559  {
1560  if ( bSetEmptyLevels ||
1561  (m_xImpl->m_xOutlineStylesCandidates &&
1562  !m_xImpl->m_xOutlineStylesCandidates[i].empty()))
1563  {
1564  // determine, which candidate is one to be assigned to the list
1565  // level of the outline style
1566  if (m_xImpl->m_xOutlineStylesCandidates &&
1567  !m_xImpl->m_xOutlineStylesCandidates[i].empty())
1568  {
1569  if ( bChooseLastOne )
1570  {
1571  sChosenStyles[i] =
1572  m_xImpl->m_xOutlineStylesCandidates[i].back();
1573  }
1574  else
1575  {
1576  for (size_t j = 0;
1577  j < m_xImpl->m_xOutlineStylesCandidates[i].size();
1578  ++j)
1579  {
1580  if (!lcl_HasListStyle(
1581  m_xImpl->m_xOutlineStylesCandidates[i][j],
1582  m_xImpl->m_xParaStyles,
1583  GetXMLImport(),
1584  "NumberingStyleName",
1585  sOutlineStyleName))
1586  {
1587  sChosenStyles[i] =
1588  m_xImpl->m_xOutlineStylesCandidates[i][j];
1589  break;
1590  }
1591  }
1592  }
1593  }
1594  }
1595  }
1596  // Trashed outline numbering in ODF 1.1 text document created by OOo 3.x (#i106218#)
1597  Sequence < PropertyValue > aProps( 1 );
1598  PropertyValue *pProps = aProps.getArray();
1599  pProps->Name = "HeadingStyleName";
1600  for ( sal_Int32 i = 0; i < nCount; ++i )
1601  {
1602  // Paragraph style assignments in Outline of template lost from second level on (#i107610#)
1603  if ( bSetEmptyLevels || !sChosenStyles[i].isEmpty() )
1604  {
1605  pProps->Value <<= sChosenStyles[i];
1606  m_xImpl->m_xChapterNumbering->replaceByIndex(i,
1607  makeAny( aProps ));
1608  }
1609  }
1610 
1611 }
1612 
1614  SvXMLImport const & rImport,
1615  const Reference < XTextCursor >& rCursor,
1616  const OUString& rHRef,
1617  const OUString& rName,
1618  const OUString& rTargetFrameName,
1619  const OUString& rStyleName,
1620  const OUString& rVisitedStyleName,
1621  XMLEventsImportContext* pEvents)
1622 {
1623  static constexpr OUStringLiteral s_HyperLinkURL = u"HyperLinkURL";
1624  static constexpr OUStringLiteral s_HyperLinkName = u"HyperLinkName";
1625  static constexpr OUStringLiteral s_HyperLinkTarget = u"HyperLinkTarget";
1626  static constexpr OUStringLiteral s_UnvisitedCharStyleName = u"UnvisitedCharStyleName";
1627  static constexpr OUStringLiteral s_VisitedCharStyleName = u"VisitedCharStyleName";
1628  static constexpr OUStringLiteral s_HyperLinkEvents = u"HyperLinkEvents";
1629 
1630  Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1631  Reference < XPropertySetInfo > xPropSetInfo(
1632  xPropSet->getPropertySetInfo());
1633  if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1634  return;
1635 
1636  xPropSet->setPropertyValue(s_HyperLinkURL, makeAny(rHRef));
1637 
1638  if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1639  {
1640  xPropSet->setPropertyValue(s_HyperLinkName, makeAny(rName));
1641  }
1642 
1643  if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1644  {
1645  xPropSet->setPropertyValue(s_HyperLinkTarget,
1646  makeAny(rTargetFrameName));
1647  }
1648 
1649  if ( (pEvents != nullptr) &&
1650  xPropSetInfo->hasPropertyByName(s_HyperLinkEvents))
1651  {
1652  // The API treats events at hyperlinks differently from most
1653  // other properties: You have to set a name replace with the
1654  // events in it. The easiest way to do this is to 1) get
1655  // events, 2) set new ones, and 3) then put events back.
1656  uno::Reference<XNameReplace> const xReplace(
1657  xPropSet->getPropertyValue(s_HyperLinkEvents), UNO_QUERY);
1658  if (xReplace.is())
1659  {
1660  // set events
1661  pEvents->SetEvents(xReplace);
1662 
1663  // put events
1664  xPropSet->setPropertyValue(s_HyperLinkEvents, makeAny(xReplace));
1665  }
1666  }
1667 
1668  if (m_xImpl->m_xTextStyles.is())
1669  {
1670  OUString sDisplayName(
1671  rImport.GetStyleDisplayName(
1672  XmlStyleFamily::TEXT_TEXT, rStyleName ) );
1673  if( !sDisplayName.isEmpty() &&
1674  xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) &&
1675  m_xImpl->m_xTextStyles->hasByName(sDisplayName))
1676  {
1677  xPropSet->setPropertyValue(s_UnvisitedCharStyleName,
1679  }
1680 
1681  sDisplayName =
1682  rImport.GetStyleDisplayName(
1683  XmlStyleFamily::TEXT_TEXT, rVisitedStyleName );
1684  if( !sDisplayName.isEmpty() &&
1685  xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) &&
1686  m_xImpl->m_xTextStyles->hasByName(sDisplayName))
1687  {
1688  xPropSet->setPropertyValue(s_VisitedCharStyleName,
1690  }
1691  }
1692 }
1693 
1695  SvXMLImport const & rImport,
1696  const Reference < XTextCursor >& rCursor,
1697  const OUString& rStyleName,
1698  const OUString& rTextStyleName,
1699  const OUString& rText )
1700 {
1701  Reference<XPropertySet> xPropSet(rCursor, UNO_QUERY);
1702 
1703  OUString sRubyText("RubyText");
1704 
1705  // if we have one Ruby property, we assume all of them are present
1706  if (xPropSet.is() &&
1707  xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText ))
1708  {
1709  // the ruby text
1710  xPropSet->setPropertyValue(sRubyText, makeAny(rText));
1711 
1712  // the ruby style (ruby-adjust)
1713  if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is())
1714  {
1715  const SvXMLStyleContext* pTempStyle =
1716  m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY,
1717  rStyleName, true );
1718  XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
1719 
1720  if (nullptr != pStyle)
1721  pStyle->FillPropertySet( xPropSet );
1722  }
1723 
1724  // the ruby text character style
1725  if (m_xImpl->m_xTextStyles.is())
1726  {
1727  OUString sDisplayName(
1728  rImport.GetStyleDisplayName(
1729  XmlStyleFamily::TEXT_TEXT, rTextStyleName ) );
1730  if( (!sDisplayName.isEmpty()) &&
1731  m_xImpl->m_xTextStyles->hasByName( sDisplayName ))
1732  {
1733  xPropSet->setPropertyValue("RubyCharStyleName", makeAny(sDisplayName));
1734  }
1735  }
1736  }
1737 }
1738 
1740 {
1741  m_xImpl->m_xAutoStyles = pStyles;
1742 }
1743 
1745  SvXMLImport& rImport,
1746  sal_Int32 nElement,
1747  const Reference< XFastAttributeList > & xAttrList,
1748  XMLTextType eType )
1749 {
1750  SvXMLImportContext *pContext = nullptr;
1751 
1752  bool bContent = true;
1753  switch( nElement )
1754  {
1755  case XML_ELEMENT(TEXT, XML_H):
1756  case XML_ELEMENT(TEXT, XML_P):
1757  case XML_ELEMENT(LO_EXT, XML_P):
1758  pContext = new XMLParaContext( rImport,
1759  nElement,
1760  xAttrList );
1761  if (m_xImpl->m_bProgress && XMLTextType::Shape != eType)
1762  {
1763  rImport.GetProgressBarHelper()->Increment();
1764  }
1765  break;
1766  // #i52127#
1768  pContext = new XMLNumberedParaContext(
1769  rImport, nElement, xAttrList );
1770  break;
1771  case XML_ELEMENT(TEXT, XML_LIST):
1772  pContext = new XMLTextListBlockContext( rImport, *this,
1773  xAttrList );
1774  break;
1775  case XML_ELEMENT(TABLE,XML_TABLE):
1776  case XML_ELEMENT(LO_EXT, XML_TABLE):
1777  if( XMLTextType::Body == eType ||
1778  XMLTextType::TextBox == eType ||
1779  XMLTextType::Section == eType ||
1780  XMLTextType::HeaderFooter == eType ||
1781  XMLTextType::ChangedRegion == eType ||
1782  XMLTextType::Cell == eType )
1783  pContext = CreateTableChildContext( rImport, nElement, xAttrList );
1784  break;
1786  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1787  XMLTextType::HeaderFooter == eType )
1788  {
1789  pContext = new XMLVariableDeclsImportContext(
1790  rImport, *this, VarTypeSequence);
1791  bContent = false;
1792  }
1793  break;
1795  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1796  XMLTextType::HeaderFooter == eType )
1797  {
1798  pContext = new XMLVariableDeclsImportContext(
1799  rImport, *this, VarTypeSimple);
1800  bContent = false;
1801  }
1802  break;
1804  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted)||
1805  XMLTextType::HeaderFooter == eType )
1806  {
1807  pContext = new XMLVariableDeclsImportContext(
1808  rImport, *this, VarTypeUserField);
1809  bContent = false;
1810  }
1811  break;
1813  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1814  XMLTextType::HeaderFooter == eType )
1815  {
1816  pContext = new XMLDdeFieldDeclsImportContext(rImport);
1817  bContent = false;
1818  }
1819  break;
1820  case XML_ELEMENT(DRAW, XML_FRAME):
1821  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1822  XMLTextType::TextBox == eType ||
1823  XMLTextType::ChangedRegion == eType )
1824  {
1825  TextContentAnchorType eAnchorType =
1826  XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME
1827  : TextContentAnchorType_AT_PAGE;
1828  pContext = new XMLTextFrameContext( rImport, xAttrList,
1829  eAnchorType );
1830  bContent = false;
1831  }
1832  break;
1833  case XML_ELEMENT(DRAW, XML_A):
1834  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1835  XMLTextType::TextBox == eType ||
1836  XMLTextType::ChangedRegion == eType)
1837  {
1838  TextContentAnchorType eAnchorType =
1839  XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME
1840  : TextContentAnchorType_AT_PAGE;
1841  pContext = new XMLTextFrameHyperlinkContext( rImport, nElement,
1842  xAttrList,
1843  eAnchorType );
1844  bContent = false;
1845  }
1846  break;
1848  case XML_ELEMENT(TEXT, XML_SECTION):
1849  pContext = new XMLSectionImportContext( rImport );
1850  break;
1858  if( XMLTextType::Shape != eType )
1859  pContext = new XMLIndexTOCContext( rImport, nElement );
1860  break;
1862  pContext = new XMLTrackedChangesImportContext( rImport );
1863  bContent = false;
1864  break;
1865  case XML_ELEMENT(TEXT, XML_CHANGE):
1868  pContext = new XMLChangeImportContext(
1869  rImport,
1870  ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END))
1872  : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START))
1875  true);
1876  break;
1877  case XML_ELEMENT(OFFICE, XML_FORMS):
1879  bContent = false;
1880  break;
1882  if( XMLTextType::Body == eType )
1883  {
1884  pContext = new XMLAutoMarkFileContext(rImport);
1885  }
1886  bContent = false;
1887  break;
1889  pContext = new XMLCalculationSettingsContext ( rImport, nElement, xAttrList);
1890  bContent = false;
1891  break;
1892 
1893  default:
1894  if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1895  XMLTextType::TextBox == eType ||
1896  XMLTextType::ChangedRegion == eType )
1897  {
1898  Reference < XShapes > xShapes;
1900  rImport, nElement, xAttrList, xShapes );
1901  bContent = false;
1902  }
1903  }
1904 
1905  // handle open redlines
1906  if ( (XML_ELEMENT(TEXT, XML_CHANGE) != nElement) &&
1907  (XML_ELEMENT(TEXT, XML_CHANGE_END) != nElement) &&
1908  (XML_ELEMENT(TEXT, XML_CHANGE_START) != nElement) )
1909  {
1910 // ResetOpenRedlineId();
1911  }
1912 
1913  if( XMLTextType::Body == eType && bContent )
1914  {
1915  m_xImpl->m_bBodyContentStarted = false;
1916  }
1917 
1918  if( nElement != XML_ELEMENT(DRAW, XML_FRAME) )
1920 
1921  if (!pContext)
1922  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1923 
1924  return pContext;
1925 }
1926 
1928  SvXMLImport&,
1929  sal_Int32 /*nElement*/,
1930  const Reference< XFastAttributeList > & )
1931 {
1932  return nullptr;
1933 }
1934 
1936 sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName,
1937  bool* pIsSystemLanguage )
1938 {
1939  if (!m_xImpl->m_xAutoStyles.is())
1940  return -1;
1941 
1942  const SvXMLStyleContext* pStyle =
1943  m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::DATA_STYLE,
1944  sStyleName, true );
1945 
1946  // get appropriate context
1947 
1948 
1949  // first check if it's an Impress and draw only number format
1950  // this is needed since it's also a SvXMLNumFormatContext,
1951  // that was needed to support them for controls in impress/draw also
1952  const SdXMLNumberFormatImportContext* pSdNumStyle = dynamic_cast<const SdXMLNumberFormatImportContext*>( pStyle );
1953  if( pSdNumStyle )
1954  {
1955  return pSdNumStyle->GetDrawKey();
1956  }
1957  else
1958  {
1959  SvXMLNumFormatContext* pNumStyle = const_cast<SvXMLNumFormatContext*>(dynamic_cast<const SvXMLNumFormatContext*>( pStyle ) );
1960  if( pNumStyle )
1961  {
1962  if( pIsSystemLanguage != nullptr )
1963  *pIsSystemLanguage = pNumStyle->IsSystemLanguage();
1964 
1965  // return key
1966  return pNumStyle->GetKey();
1967  }
1968  }
1969  return -1;
1970 }
1971 
1973 {
1974  const SvxXMLListStyleContext *pStyle = nullptr;
1975  if (m_xImpl->m_xAutoStyles.is())
1976  {
1977  const SvXMLStyleContext* pTempStyle =
1978  m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_LIST, rName,
1979  true );
1980  pStyle = dynamic_cast< const SvxXMLListStyleContext* >(pTempStyle);
1981  }
1982 
1983  return pStyle;
1984 }
1985 
1987 {
1988  XMLPropStyleContext *pStyle = nullptr;
1989  if (m_xImpl->m_xAutoStyles.is())
1990  {
1991  const SvXMLStyleContext* pTempStyle =
1992  m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::SD_GRAPHICS_ID, rName,
1993  true );
1994  pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
1995  }
1996 
1997  return pStyle;
1998 }
1999 
2001  const OUString& rName ) const
2002 {
2003  XMLPropStyleContext* pStyle = nullptr;
2004  if (m_xImpl->m_xAutoStyles.is())
2005  {
2006  const SvXMLStyleContext* pTempStyle =
2007  m_xImpl->m_xAutoStyles->FindStyleChildContext(
2009  rName, true );
2010  pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
2011  }
2012 
2013  return pStyle;
2014 }
2015 
2017  const OUString& rName ) const
2018 {
2019  XMLPropStyleContext* pStyle = nullptr;
2020  if (m_xImpl->m_xAutoStyles.is())
2021  {
2022  const SvXMLStyleContext* pTempStyle =
2023  m_xImpl->m_xAutoStyles->FindStyleChildContext(
2025  rName, true );
2026  pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
2027  }
2028 
2029  return pStyle;
2030 }
2031 
2033 {
2034  if (!m_xImpl->m_xAutoStyles.is())
2035  {
2036  return nullptr;
2037  }
2038  SvXMLStyleContext const* pStyle(
2039  m_xImpl->m_xAutoStyles->FindStyleChildContext(
2040  XmlStyleFamily::SD_DRAWINGPAGE_ID, rName, true));
2041  assert(pStyle == nullptr || dynamic_cast<XMLPropStyleContext const*>(pStyle) != nullptr);
2042  return const_cast<XMLPropStyleContext*>(static_cast<XMLPropStyleContext const*>(pStyle));
2043 }
2044 
2046 {
2047  GetTextListHelper().PushListContext(static_cast<XMLTextListBlockContext*>(nullptr));
2048 }
2049 
2051 {
2053 }
2054 
2055 
2057 {
2058  if (!m_xImpl->m_xRenameMap)
2059  {
2060  m_xImpl->m_xRenameMap.reset( new SvI18NMap );
2061  }
2062  return *m_xImpl->m_xRenameMap;
2063 }
2064 
2066  const OUString & sName,
2067  const Reference<XTextRange> & rRange,
2068  OUString const& i_rXmlId,
2069  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes)
2070 {
2071  m_xImpl->m_BookmarkStartRanges[sName] =
2072  std::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes);
2073  m_xImpl->m_BookmarkVector.push_back(sName);
2074 }
2075 
2077  const OUString & sName,
2078  Reference<XTextRange> & o_rRange,
2079  OUString & o_rXmlId,
2080  std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes)
2081 {
2082  if (m_xImpl->m_BookmarkStartRanges.count(sName))
2083  {
2084  Impl::BookmarkMapEntry_t & rEntry =
2085  (*m_xImpl->m_BookmarkStartRanges.find(sName)).second;
2086  o_rRange.set(std::get<0>(rEntry));
2087  o_rXmlId = std::get<1>(rEntry);
2088  o_rpRDFaAttributes = std::get<2>(rEntry);
2089  m_xImpl->m_BookmarkStartRanges.erase(sName);
2090  auto it = std::find(m_xImpl->m_BookmarkVector.begin(), m_xImpl->m_BookmarkVector.end(), sName);
2091  if (it!=m_xImpl->m_BookmarkVector.end())
2092  {
2093  m_xImpl->m_BookmarkVector.erase(it);
2094  }
2095  return true;
2096  }
2097  else
2098  {
2099  return false;
2100  }
2101 }
2102 
2103 void XMLTextImportHelper::pushFieldCtx( const OUString& name, const OUString& type )
2104 {
2105  m_xImpl->m_FieldStack.push(Impl::field_stack_item_t(
2106  Impl::field_name_type_t(name, type), Impl::field_params_t(), uno::Reference<text::XFormField>{}));
2107 }
2108 
2109 uno::Reference<text::XFormField>
2111 {
2112  uno::Reference<text::XFormField> xRet;
2113  if ( !m_xImpl->m_FieldStack.empty() )
2114  {
2115  xRet = std::get<2>(m_xImpl->m_FieldStack.top());
2116  m_xImpl->m_FieldStack.pop();
2117  }
2118  else
2119  {
2120  SAL_INFO("xmloff.text", "unexpected fieldmark end");
2121  }
2122  return xRet;
2123 }
2124 
2125 void XMLTextImportHelper::addFieldParam( const OUString& name, const OUString& value )
2126 {
2127  assert(!m_xImpl->m_FieldStack.empty());
2128  if (!m_xImpl->m_FieldStack.empty()) {
2129  Impl::field_stack_item_t & FieldStackItem(m_xImpl->m_FieldStack.top());
2130  std::get<1>(FieldStackItem).emplace_back( name, value );
2131  }
2132 }
2133 
2135 {
2136  assert(!m_xImpl->m_FieldStack.empty());
2137  if (!m_xImpl->m_FieldStack.empty())
2138  {
2139  return std::get<0>(m_xImpl->m_FieldStack.top()).second;
2140  }
2141  else
2142  {
2143  return OUString();
2144  }
2145 }
2146 
2148 {
2149  return !m_xImpl->m_FieldStack.empty();
2150 }
2151 
2152 void XMLTextImportHelper::setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField)
2153 {
2154  assert(!m_xImpl->m_FieldStack.empty());
2155  if (!m_xImpl->m_FieldStack.empty() && xFormField.is())
2156  {
2157  FieldParamImporter(&std::get<1>(m_xImpl->m_FieldStack.top()),
2158  xFormField->getParameters()).Import();
2159  std::get<2>(m_xImpl->m_FieldStack.top()) = xFormField;
2160  }
2161 }
2162 
2163 
2165  const OUString& rFrmName,
2166  const OUString& rNextFrmName,
2167  const Reference < XPropertySet >& rFrmPropSet )
2168 {
2169  if( rFrmName.isEmpty() )
2170  return;
2171 
2172  if( !rNextFrmName.isEmpty() )
2173  {
2174  OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME,
2175  rNextFrmName ));
2176  if (m_xImpl->m_xTextFrames.is()
2177  && m_xImpl->m_xTextFrames->hasByName(sNextFrmName))
2178  {
2179  rFrmPropSet->setPropertyValue("ChainNextName",
2180  makeAny(sNextFrmName));
2181  }
2182  else
2183  {
2184  if (!m_xImpl->m_xPrevFrmNames)
2185  {
2186  m_xImpl->m_xPrevFrmNames.reset( new std::vector<OUString> );
2187  m_xImpl->m_xNextFrmNames.reset( new std::vector<OUString> );
2188  }
2189  m_xImpl->m_xPrevFrmNames->push_back(rFrmName);
2190  m_xImpl->m_xNextFrmNames->push_back(sNextFrmName);
2191  }
2192  }
2193  if (m_xImpl->m_xPrevFrmNames && !m_xImpl->m_xPrevFrmNames->empty())
2194  {
2195  for(std::vector<OUString>::iterator i = m_xImpl->m_xPrevFrmNames->begin(), j = m_xImpl->m_xNextFrmNames->begin(); i != m_xImpl->m_xPrevFrmNames->end() && j != m_xImpl->m_xNextFrmNames->end(); ++i, ++j)
2196  {
2197  if((*j) == rFrmName)
2198  {
2199  // The previous frame must exist, because it existing than
2200  // inserting the entry
2201  rFrmPropSet->setPropertyValue("ChainPrevName", makeAny(*i));
2202 
2203  i = m_xImpl->m_xPrevFrmNames->erase(i);
2204  j = m_xImpl->m_xNextFrmNames->erase(j);
2205 
2206  // There cannot be more than one previous frames
2207  break;
2208  }
2209  }
2210  }
2211 }
2212 
2214 {
2215  static constexpr OUStringLiteral s_TextFrame = u"TextFrame";
2216 
2217  bool bIsInFrame = false;
2218 
2219  // are we currently in a text frame? yes, if the cursor has a
2220  // TextFrame property and it's non-NULL
2221  Reference<XPropertySet> xPropSet(const_cast<XMLTextImportHelper*>(this)->GetCursor(), UNO_QUERY);
2222  if (xPropSet.is())
2223  {
2224  if (xPropSet->getPropertySetInfo()->hasPropertyByName(s_TextFrame))
2225  {
2226  uno::Reference<XTextFrame> const xFrame(
2227  xPropSet->getPropertyValue(s_TextFrame), UNO_QUERY);
2228 
2229  if (xFrame.is())
2230  {
2231  bIsInFrame = true;
2232  }
2233  }
2234  }
2235 
2236  return bIsInFrame;
2237 }
2238 
2240 {
2241  return false;
2242 }
2243 
2245  SvXMLImport&,
2246  const OUString& /*rHRef*/,
2247  const OUString& /*rStyleName*/,
2248  const OUString& /*rTblName*/,
2249  sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2250 {
2251  Reference< XPropertySet> xPropSet;
2252  return xPropSet;
2253 }
2254 
2256  SvXMLImport&,
2257  const OUString& /*rHRef*/,
2258  const OUString& /*rStyleName*/,
2259  const OUString& /*rTblName*/,
2260  sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2261 {
2262  Reference< XPropertySet> xPropSet;
2263  return xPropSet;
2264 }
2265 
2267  const OUString& /*rCode*/,
2268  const OUString& /*rName*/,
2269  bool /*bMayScript*/,
2270  const OUString& /*rHRef*/,
2271  sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2272 {
2273  Reference< XPropertySet> xPropSet;
2274  return xPropSet;
2275 }
2277  const OUString& /*rMimeType*/,
2278  const OUString& /*rHRef*/,
2279  sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2280 {
2281  Reference< XPropertySet> xPropSet;
2282  return xPropSet;
2283 }
2285  const OUString& /*rName*/,
2286  const OUString& /*rHRef*/,
2287  const OUString& /*rStyleName*/,
2288  sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2289 {
2290  Reference< XPropertySet> xPropSet;
2291  return xPropSet;
2292 }
2293 
2295  const Reference < XPropertySet> &,
2296  std::map < const OUString, OUString > &)
2297 {
2298 }
2299 // redline helper: dummy implementation to be overridden in sw/filter/xml
2300 void XMLTextImportHelper::RedlineAdd( const OUString& /*rType*/,
2301  const OUString& /*rId*/,
2302  const OUString& /*rAuthor*/,
2303  const OUString& /*rComment*/,
2304  const util::DateTime& /*rDateTime*/,
2305  bool /*bMergeLastPara*/)
2306 {
2307  // dummy implementation: do nothing
2308 }
2309 
2311  Reference<XTextCursor> & /*rOldCursor*/,
2312  const OUString& /*rId*/)
2313 {
2314  // dummy implementation: do nothing
2315  Reference<XTextCursor> xRet;
2316  return xRet;
2317 }
2318 
2320  const OUString& /*rId*/,
2321  bool /*bStart*/,
2322  bool /*bIsOutsideOfParagraph*/)
2323 {
2324  // dummy implementation: do nothing
2325 }
2326 
2328 {
2329  // dummy implementation: do nothing
2330 }
2331 
2333 {
2334  // dummy implementation: do nothing
2335 }
2336 
2338 {
2339  // dummy implementation: do nothing
2340 }
2341 void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
2342 {
2343  // dummy implementation: do nothing
2344 }
2345 
2346 
2348 {
2349  return m_xImpl->m_sOpenRedlineIdentifier;
2350 }
2351 
2352 void XMLTextImportHelper::SetOpenRedlineId( OUString const & rId)
2353 {
2354  m_xImpl->m_sOpenRedlineIdentifier = rId;
2355 }
2356 
2358 {
2359  SetOpenRedlineId("");
2360 }
2361 
2362 void
2364 {
2365  m_xImpl->m_sCellParaStyleDefault = rNewValue;
2366 }
2367 
2369 {
2370  return m_xImpl->m_sCellParaStyleDefault;
2371 }
2372 
2373 void XMLTextImportHelper::AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo)
2374 {
2375  if (!m_xImpl->m_pCrossRefHeadingBookmarkMap)
2376  {
2377  m_xImpl->m_pCrossRefHeadingBookmarkMap.reset(new std::map<OUString, OUString>);
2378  }
2379  m_xImpl->m_pCrossRefHeadingBookmarkMap->insert(std::make_pair(rFrom, rTo));
2380 }
2381 
2382 // tdf#94804: hack to map cross reference fields that reference duplicate marks
2383 // note that we can't really check meta:generator for this since the file might
2384 // be round-tripped by different versions preserving duplicates => always map
2386 {
2387  if (!m_xImpl->m_pCrossRefHeadingBookmarkMap)
2388  {
2389  return;
2390  }
2391 
2392  uno::Reference<text::XTextFieldsSupplier> const xFieldsSupplier(
2393  m_xImpl->m_rSvXMLImport.GetModel(), uno::UNO_QUERY);
2394  if (!xFieldsSupplier.is())
2395  {
2396  return;
2397  }
2398  uno::Reference<container::XEnumerationAccess> const xFieldsEA(
2399  xFieldsSupplier->getTextFields());
2400  uno::Reference<container::XEnumeration> const xFields(
2401  xFieldsEA->createEnumeration());
2402  while (xFields->hasMoreElements())
2403  {
2404  uno::Reference<lang::XServiceInfo> const xFieldInfo(
2405  xFields->nextElement(), uno::UNO_QUERY);
2406  if (!xFieldInfo->supportsService("com.sun.star.text.textfield.GetReference"))
2407  {
2408  continue;
2409  }
2410  uno::Reference<beans::XPropertySet> const xField(
2411  xFieldInfo, uno::UNO_QUERY);
2412  sal_uInt16 nType(0);
2413  xField->getPropertyValue("ReferenceFieldSource") >>= nType;
2414  if (text::ReferenceFieldSource::BOOKMARK != nType)
2415  {
2416  continue;
2417  }
2418  OUString name;
2419  xField->getPropertyValue("SourceName") >>= name;
2420  auto const iter(m_xImpl->m_pCrossRefHeadingBookmarkMap->find(name));
2421  if (iter == m_xImpl->m_pCrossRefHeadingBookmarkMap->end())
2422  {
2423  continue;
2424  }
2425  xField->setPropertyValue("SourceName", uno::makeAny(iter->second));
2426  }
2427 }
2428 
2429 void XMLTextImportHelper::setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition)
2430 {
2431  m_xImpl->m_bBookmarkHidden[bookmark] = hidden;
2432  m_xImpl->m_sBookmarkCondition[bookmark] = condition;
2433 }
2434 
2435 bool XMLTextImportHelper::getBookmarkHidden(OUString const& bookmark) const
2436 {
2437  return m_xImpl->m_bBookmarkHidden[bookmark];
2438 }
2439 
2440 const OUString& XMLTextImportHelper::getBookmarkCondition(OUString const& bookmark) const
2441 {
2442  return m_xImpl->m_sBookmarkCondition[bookmark];
2443 }
2444 
2445 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::container::XIndexReplace > & GetNumRulesOverride() const
virtual void SetShowChanges(bool bShowChanges)
Definition: txtimp.cxx:2332
bool IsOrganizerMode() const
Definition: txtimp.cxx:241
bool IsBlockMode() const
Definition: txtimp.cxx:236
#define XML_TEXT_RENAME_TYPE_FRAME
Definition: txtimp.hxx:91
static SvXMLImportPropertyMapper * CreateShapeExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:552
void SetInsideDeleteContext(bool const bNew)
redlining : Setter to remember the fact we are inside/outside a element (deleted redl...
Definition: txtimp.cxx:317
bool m_bInsideDeleteContext
Are we inside a element (deleted redline section)
Definition: txtimp.cxx:163
css::uno::Reference< css::text::XTextCursor > & GetCursor()
Definition: txtimp.cxx:216
uno::Reference< text::XText > m_xText
Definition: txtimp.cxx:138
std::unique_ptr< Impl > m_xImpl
Definition: txtimp.hxx:100
virtual css::uno::Reference< css::beans::XPropertySet > createAndInsertPlugin(const OUString &rMimeType, const OUString &rHRef, sal_Int32 nWidth, sal_Int32 nHeight)
Definition: txtimp.cxx:2276
void AddCrossRefHeadingMapping(OUString const &rFrom, OUString const &rTo)
Definition: txtimp.cxx:2373
void SetEvents(const css::uno::Reference< css::document::XEventsSupplier > &xEventsSupplier)
if the import operates in delayed mode, you can use this method to set all events that have been read...
virtual css::uno::Reference< css::text::XTextCursor > RedlineCreateText(css::uno::Reference< css::text::XTextCursor > &rOldCursor, const OUString &rId)
Definition: txtimp.cxx:2310
Import all indices.
XMLPropStyleContext * FindDrawingPage(OUString const &rName) const
Definition: txtimp.cxx:2032
signed char sal_Int8
XMLPropStyleContext * FindSectionStyle(const OUString &rName) const
Definition: txtimp.cxx:2000
rtl::Reference< SvXMLImportPropertyMapper > m_xParaImpPrMap
Definition: txtimp.cxx:102
uno::Reference< container::XNameContainer > m_xFrameStyles
Definition: txtimp.cxx:144
void MapCrossRefHeadingFieldsHorribly()
Definition: txtimp.cxx:2385
rtl::Reference< SvXMLImportPropertyMapper > const & GetRubyImportPropertySetMapper() const
Definition: txtimp.cxx:312
virtual void RedlineSetCursor(const OUString &rId, bool bStart, bool bIsOutsideOfParagraph)
Definition: txtimp.cxx:2319
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
Definition: txtstyli.cxx:360
#define SAL_INFO_IF(condition, area, stream)
Reference< XFrame > xFrame
sal_Unicode ConvStarMathCharToStarSymbol(sal_Unicode c)
Definition: xmlimp.cxx:1703
void DeleteParagraph()
Definition: txtimp.cxx:769
#define CONV_FROM_STAR_MATH
Definition: txtparai.hxx:34
const SvxXMLListStyleContext * FindAutoListStyle(const OUString &rName) const
Definition: txtimp.cxx:1972
const ::std::vector< XMLPropertyState > & GetProperties_()
Definition: txtstyli.hxx:89
void PopListContext()
pop the list context stack
Definition: txtimp.cxx:2050
std::unique_ptr< XMLTextListsHelper > m_xTextListsHelper
Definition: txtimp.cxx:98
sal_Int32 mnIndex
Definition: maptype.hxx:124
void SetOpenRedlineId(OUString const &rId)
modify the last open redline ID
Definition: txtimp.cxx:2352
std::map< OUString, BookmarkMapEntry_t > m_BookmarkStartRanges
start ranges for open bookmarks
Definition: txtimp.cxx:125
Definition: txtimp.hxx:70
SvI18NMap & GetRenameMap()
Definition: txtimp.cxx:2056
const OUString & GetDropCapStyleName() const
Definition: txtstyli.hxx:75
const css::uno::Reference< css::container::XNameContainer > & GetParaStyles() const
Definition: txtimp.cxx:252
rtl::Reference< SvXMLImportPropertyMapper > m_xFrameImpPrMap
Definition: txtimp.cxx:104
uno::Reference< container::XNameAccess > m_xTextFrames
Definition: txtimp.cxx:148
bool IsProgress() const
Definition: txtimp.cxx:246
std::unique_ptr< std::vector< OUString >[]> m_xOutlineStylesCandidates
Definition: txtimp.cxx:117
#define CONV_FROM_STAR_BATS
Definition: txtparai.hxx:33
#define CTF_FONTFAMILYNAME
Definition: txtprmap.hxx:58
void ResetOpenRedlineId()
reset the last open redline ID
Definition: txtimp.cxx:2357
#define ODF_FORMDROPDOWN_RESULT
Definition: odffields.hxx:33
virtual bool IsInHeaderFooter() const
Definition: txtimp.cxx:2239
#define ODF_FORMCHECKBOX_RESULT
Definition: odffields.hxx:29
virtual void SetChangesProtectionKey(const css::uno::Sequence< sal_Int8 > &rProtectionKey)
Definition: txtimp.cxx:2341
SvXMLImportContext * CreateTextChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLTextType eType=XMLTextType::Shape)
Definition: txtimp.cxx:1744
virtual css::uno::Reference< css::beans::XPropertySet > createAndInsertOOoLink(SvXMLImport &rImport, const OUString &rHRef, const OUString &rStyleName, const OUString &rTblName, sal_Int32 nWidth, sal_Int32 nHeight)
Definition: txtimp.cxx:2255
XmlStyleFamily
Definition: families.hxx:47
sal_uInt16 sal_Unicode
PropertiesInfo aProperties
OUString ConvertStarFonts(const OUString &rChars, const OUString &rStyleName, sal_uInt8 &rFlags, bool bPara, SvXMLImport &rImport) const
Definition: txtimp.cxx:804
variable declaration container for all variable fields (variable-decls, user-field-decls, sequence-decls)
Definition: txtvfldi.hxx:358
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
DRAW
void InsertString(const OUString &rChars)
Definition: txtimp.cxx:701
length
OUString msLastImportedFrameName
Definition: txtimp.cxx:133
int nCount
virtual void RedlineAdd(const OUString &rType, const OUString &rId, const OUString &rAuthor, const OUString &rComment, const css::util::DateTime &rDateTime, bool bMergeLastParagraph)
Definition: txtimp.cxx:2300
Definition: txtimp.hxx:72
const css::uno::Reference< css::container::XNameContainer > & GetFrameStyles() const
Definition: txtimp.cxx:270
void ListContextTop(XMLTextListBlockContext *&o_pListBlockContext, XMLTextListItemContext *&o_pListItemContext, XMLNumberedParaContext *&o_pNumberedParagraphContext)
peek at the top of the list context stack
Definition: txtlists.cxx:74
uno::Reference< lang::XMultiServiceFactory > m_xServiceFactory
Definition: txtimp.cxx:151
std::unique_ptr< std::vector< OUString > > m_xNextFrmNames
Definition: txtimp.cxx:97
const OUString & getBookmarkCondition(OUString const &bookmark) const
Definition: txtimp.cxx:2440
void addFieldParam(const OUString &name, const OUString &value)
Definition: txtimp.cxx:2125
uno::Reference< container::XNameContainer > m_xCellStyles
Definition: txtimp.cxx:146
uno::Reference< container::XNameContainer > m_xNumStyles
Definition: txtimp.cxx:143
void SetHyperlink(SvXMLImport const &rImport, const css::uno::Reference< css::text::XTextCursor > &rCursor, const OUString &rHRef, const OUString &rName, const OUString &rTargetFrameName, const OUString &rStyleName, const OUString &rVisitedStyleName, XMLEventsImportContext *pEvents)
Definition: txtimp.cxx:1613
static SvXMLImportPropertyMapper * CreateTableDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:580
void ConnectFrameChains(const OUString &rFrmName, const OUString &rNextFrmName, const css::uno::Reference< css::beans::XPropertySet > &rFrmPropSet)
Definition: txtimp.cxx:2164
OUString m_sOpenRedlineIdentifier
name of the last 'open' redline that started between paragraphs
Definition: txtimp.cxx:130
css::uno::Reference< css::text::XText > & GetText()
Definition: txtimp.cxx:211
#define MAX_COMBINED_CHARACTERS
Definition: txtimp.cxx:92
::std::tuple< field_name_type_t, field_params_t, uno::Reference< text::XFormField > > field_stack_item_t
Definition: txtimp.cxx:168
static SvXMLImportContext * createOfficeFormsContext(SvXMLImport &_rImport)
creates an import context for the office:forms element
void Increment(sal_Int32 nInc=1)
css::uno::Reference< css::text::XTextRange > & GetCursorAsRange()
Definition: txtimp.cxx:221
uno::Reference< container::XIndexReplace > m_xChapterNumbering
Definition: txtimp.cxx:147
uno::Reference< text::XTextCursor > m_xCursor
Definition: txtimp.cxx:139
OUString getCurrentFieldType()
Definition: txtimp.cxx:2134
bool IsInFrame() const
Definition: txtimp.cxx:2213
int i
SvXMLImport & GetXMLImport()
Definition: txtimp.cxx:327
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
Definition: prstylei.cxx:222
virtual css::uno::Reference< css::beans::XPropertySet > createAndInsertApplet(const OUString &rName, const OUString &rCode, bool bMayScript, const OUString &rHRef, sal_Int32 nWidth, sal_Int32 nHeight)
Definition: txtimp.cxx:2266
bool getBuildIds(sal_Int32 &rUPD, sal_Int32 &rBuild) const
returns the upd and build id (f.e.
Definition: xmlimp.cxx:1810
const css::uno::Reference< css::container::XNameContainer > & GetPageStyles() const
Definition: txtimp.cxx:276
sal_Unicode ConvStarBatsCharToStarSymbol(sal_Unicode c)
Definition: xmlimp.cxx:1686
bool FindAndRemoveBookmarkStartRange(const OUString &sName, css::uno::Reference< css::text::XTextRange > &o_rRange, OUString &o_rXmlId, std::shared_ptr< ::xmloff::ParsedRDFaAttributes > &o_rpRDFaAttributes)
process the start of a range reference
Definition: txtimp.cxx:2076
void SetCellParaStyleDefault(OUString const &rNewValue)
Definition: txtimp.cxx:2363
::std::vector< field_param_t > field_params_t
Definition: txtimp.cxx:167
OUString SetStyleAndAttrs(SvXMLImport const &rImport, const css::uno::Reference< css::text::XTextCursor > &rCursor, const OUString &rStyleName, bool bPara, bool bOutlineLevelAttrFound=false, sal_Int8 nOutlineLevel=-1, bool bSetListAttrs=true, bool bOutlineContentVisible=true)
Definition: txtimp.cxx:1006
bool IsTextDocInOOoFileFormat() const
Definition: xmlimp.cxx:1800
const OUString & GetMasterPageName() const
Definition: txtstyli.hxx:73
float u
uno::Reference< text::XTextRange > m_xCursorAsRange
Definition: txtimp.cxx:140
bool getBookmarkHidden(OUString const &bookmark) const
Definition: txtimp.cxx:2435
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlimp.cxx:1428
static SvXMLImportPropertyMapper * CreateParaDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:566
const css::uno::Reference< css::container::XIndexReplace > & GetChapterNumbering() const
Definition: txtimp.cxx:288
size
std::vector< OUString > m_BookmarkVector
Definition: txtimp.cxx:127
void PushListContext()
push a list context on the list context stack
Definition: txtimp.cxx:2045
static bool lcl_HasListStyle(const OUString &sStyleName, const Reference< XNameContainer > &xParaStyles, SvXMLImport const &rImport, const OUString &sNumberingStyleName, std::u16string_view sOutlineStyleName)
Definition: txtimp.cxx:888
bool IsInsertMode() const
Definition: txtimp.cxx:226
void FindOutlineStyleName(OUString &rStyleName, sal_Int8 nOutlineLevel)
Find a suitable name for the given outline level.
Definition: txtimp.cxx:1456
std::unique_ptr< SvI18NMap > m_xRenameMap
Definition: txtimp.cxx:108
bool hasCurrentFieldCtx() const
Definition: txtimp.cxx:2147
uno::Reference< container::XNameContainer > m_xTextStyles
Definition: txtimp.cxx:142
void InsertControlCharacter(sal_Int16 nControl)
Definition: txtimp.cxx:746
void SetAutoStyles(SvXMLStylesContext *pStyles)
Definition: txtimp.cxx:1739
virtual ~XMLTextImportHelper() override
Definition: txtimp.cxx:542
::std::pair< OUString, OUString > field_param_t
Definition: txtimp.cxx:166
XMLPropertyMapEntry const g_XMLPageMasterDrawingPageStyleMap[]
virtual SvXMLImportContext * CreateTableChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: txtimp.cxx:1927
bool HasMasterPageName() const
Definition: txtstyli.hxx:74
void PushListContext(XMLTextListBlockContext *i_pListBlock)
list stack for importing:
Definition: txtlists.cxx:51
const css::uno::Reference< css::container::XIndexReplace > & GetNumRules() const
Definition: txtparai.hxx:99
Impl(uno::Reference< frame::XModel > const &rModel, SvXMLImport &rImport, bool const bInsertMode, bool const bStylesOnlyMode, bool const bProgress, bool const bBlockMode, bool const bOrganizerMode)
Definition: txtimp.cxx:177
OUString m_sCellParaStyleDefault
Definition: txtimp.cxx:173
XMLTextListsHelper & GetTextListHelper()
Definition: txtimp.cxx:332
rtl::Reference< SvXMLImportPropertyMapper > m_xTextImpPrMap
Definition: txtimp.cxx:103
const css::uno::Reference< css::container::XNameContainer > & GetNumberingStyles() const
Definition: txtimp.cxx:264
rtl::Reference< SvXMLImportPropertyMapper > m_xRubyImpPrMap
Definition: txtimp.cxx:106
static SvXMLImportPropertyMapper * CreateTableCellExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:598
void SetRuby(SvXMLImport const &rImport, const css::uno::Reference< css::text::XTextCursor > &rCursor, const OUString &rStyleName, const OUString &rTextStyleName, const OUString &rText)
Definition: txtimp.cxx:1694
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
bool IsListStyleSet() const
Definition: txtstyli.hxx:68
void InsertTextContent(css::uno::Reference< css::text::XTextContent > const &xContent)
Definition: txtimp.cxx:757
void InsertBookmarkStartRange(const OUString &sName, const css::uno::Reference< css::text::XTextRange > &rRange, OUString const &i_rXmlId, std::shared_ptr< ::xmloff::ParsedRDFaAttributes > &i_rpRDFaAttributes)
save the start of a range reference
Definition: txtimp.cxx:2065
virtual void RedlineAdjustStartNodeCursor()
Definition: txtimp.cxx:2327
std::unique_ptr< std::map< OUString, OUString > > m_pCrossRefHeadingBookmarkMap
Definition: txtimp.cxx:175
void StoreLastImportedFrameName(const OUString &rName)
Definition: txtimp.cxx:691
::std::pair< OUString, OUString > field_name_type_t
Definition: txtimp.cxx:165
const css::uno::Reference< css::container::XNameContainer > & GetTextStyles() const
Definition: txtimp.cxx:258
void SetOutlineStyles(bool bSetEmpty)
Definition: txtimp.cxx:1517
css::uno::Reference< css::text::XFormField > popFieldCtx()
Definition: txtimp.cxx:2110
css::uno::Any maValue
Definition: maptype.hxx:125
const OUString & GetParentName() const
Definition: xmlstyle.hxx:80
uno::Reference< container::XNameContainer > m_xParaStyles
Definition: txtimp.cxx:141
virtual css::uno::Reference< css::beans::XPropertySet > createAndInsertOLEObject(SvXMLImport &rImport, const OUString &rHRef, const OUString &rStyleName, const OUString &rTblName, sal_Int32 nWidth, sal_Int32 nHeight)
Definition: txtimp.cxx:2244
uno::Reference< container::XNameContainer > m_xPageStyles
Definition: txtimp.cxx:145
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
Definition: xmlimp.cxx:1402
#define SAL_WARN_IF(condition, area, stream)
sal_Int16 GetStartValue() const
unsigned char sal_uInt8
uno::Reference< container::XNameAccess > m_xGraphics
Definition: txtimp.cxx:149
void SetListItem(XMLTextListItemContext *pListItem)
set list item on top of the list context stack
Definition: txtlists.cxx:89
bool IsStylesOnlyMode() const
Definition: txtimp.cxx:231
#define CONV_STAR_FONT_FLAGS_VALID
Definition: txtparai.hxx:35
Handling of tokens in XML:
XMLTextImportHelper(const XMLTextImportHelper &)=delete
XMLPropStyleContext * FindAutoFrameStyle(const OUString &rName) const
Definition: txtimp.cxx:1986
#define SAL_INFO(area, stream)
#define ODF_FORMDROPDOWN_LISTENTRY
Definition: odffields.hxx:32
void PopListContext()
pop the list context stack
Definition: txtlists.cxx:67
const OUString & GetListId() const
Definition: txtparai.hxx:101
void AddOutlineStyleCandidate(const sal_Int8 nOutlineLevel, const OUString &rStyleName)
Definition: txtimp.cxx:1503
void ClearLastImportedTextFrameName()
Definition: txtimp.cxx:696
void pushFieldCtx(const OUString &name, const OUString &type)
Definition: txtimp.cxx:2103
Definition: txtimp.hxx:71
rtl::Reference< SvXMLImportPropertyMapper > const & GetParaImportPropertySetMapper() const
Definition: txtimp.cxx:294
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:96
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
void copy(const fs::path &src, const fs::path &dest)
sal_Int16 GetStartValue() const
Definition: txtparai.hxx:102
QPRO_FUNC_TYPE nType
const char * name
rtl::Reference< SvXMLStylesContext > m_xAutoStyles
Definition: txtimp.cxx:100
SvXMLImport & m_rSvXMLImport
Definition: txtimp.cxx:153
TABLE
void SetCursor(const css::uno::Reference< css::text::XTextCursor > &rCursor)
Definition: txtimp.cxx:615
bool HasFrameByName(const OUString &rName) const
Definition: txtimp.cxx:630
static SvXMLImportPropertyMapper * CreateDrawingPageExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:607
std::map< OUString, OUString > m_sBookmarkCondition
Definition: txtimp.cxx:136
bool IsDuplicateFrame(const OUString &sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const
Definition: txtimp.cxx:640
XMLTextType
Definition: txtimp.hxx:68
rtl::Reference< SvXMLImportPropertyMapper > const & GetSectionImportPropertySetMapper() const
Definition: txtimp.cxx:306
rtl::Reference< SvXMLImportPropertyMapper > const & GetTextImportPropertySetMapper() const
Definition: txtimp.cxx:300
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
void InitOutlineStylesCandidates()
Definition: txtimp.cxx:198
sal_Int16 GetLevel() const
Definition: txtparai.hxx:98
uno::Reference< container::XNameAccess > m_xObjects
Definition: txtimp.cxx:150
bool HasCombinedCharactersLetter() const
Definition: txtstyli.hxx:86
::std::stack< field_stack_item_t > field_stack_t
Definition: txtimp.cxx:169
virtual css::uno::Reference< css::beans::XPropertySet > createAndInsertFloatingFrame(const OUString &rName, const OUString &rHRef, const OUString &rStyleName, sal_Int32 nWidth, sal_Int32 nHeight)
Definition: txtimp.cxx:2284
import dde field declaration container ()
Definition: txtfldi.hxx:825
static SvXMLShapeContext * CreateGroupChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape=false)
bool IsInsideDeleteContext() const
redlining : Getter to know if we are inside a element (deleted redline section) ...
Definition: txtimp.cxx:322
XMLPropStyleContext * FindPageMaster(const OUString &rName) const
Definition: txtimp.cxx:2016
static SvXMLImportPropertyMapper * CreateParaExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:559
void setBookmarkAttributes(OUString const &bookmark, bool hidden, OUString const &condition)
Definition: txtimp.cxx:2429
virtual void SetRecordChanges(bool bRecordChanges)
Definition: txtimp.cxx:2337
static SvXMLImportPropertyMapper * CreateTableRowDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:589
void ChainImportMapper(const rtl::Reference< SvXMLImportPropertyMapper > &rMapper)
Definition: xmlimppr.cxx:76
import change tracking/redlining markers , , ...
std::unique_ptr< std::vector< OUString > > m_xPrevFrmNames
Definition: txtimp.cxx:96
const OUString & GetListStyle() const
Definition: txtstyli.hxx:66
const css::uno::Reference< css::container::XNameContainer > & GetCellStyles() const
Definition: txtimp.cxx:282
bool IsSystemLanguage() const
determine whether number format uses the system language
Definition: xmlnumfi.cxx:2063
Impl & operator=(const Impl &)=delete
TEXT
rtl::Reference< SvXMLImportPropertyMapper > m_xSectionImpPrMap
Definition: txtimp.cxx:105
std::map< OUString, bool > m_bBookmarkHidden
Definition: txtimp.cxx:135
void setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField > const &xFormField)
Definition: txtimp.cxx:2152
virtual void endAppletOrPlugin(const css::uno::Reference< css::beans::XPropertySet > &rPropSet,::std::map< const OUString, OUString > &rParamMap)
Definition: txtimp.cxx:2294
std::tuple< uno::Reference< text::XTextRange >, OUString, std::shared_ptr< ::xmloff::ParsedRDFaAttributes > > BookmarkMapEntry_t
Definition: txtimp.cxx:123
OUString const & GetCellParaStyleDefault() const
Definition: txtimp.cxx:2368
field_stack_t m_FieldStack
Definition: txtimp.cxx:171
OUString sDisplayName
OUString const & GetOpenRedlineId() const
get the last open redline ID
Definition: txtimp.cxx:2347
sal_Int32 GetDataStyleKey(const OUString &sStyleName, bool *pIsSystemLanguage=nullptr)
return key appropriate for use with NumberFormat property return -1 if style is not found (may return...
Definition: txtimp.cxx:1936
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)