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