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 ::com::sun::star;
78using namespace ::com::sun::star::uno;
79using namespace ::com::sun::star::beans;
80using namespace ::com::sun::star::text;
81using namespace ::com::sun::star::frame;
82using namespace ::com::sun::star::style;
83using namespace ::com::sun::star::container;
84using namespace ::com::sun::star::drawing;
85using namespace ::com::sun::star::xml::sax;
86using namespace ::com::sun::star::lang;
87using namespace ::xmloff::token;
88using 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::optional< std::vector<OUString> > m_xPrevFrmNames;
97 std::optional< 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
153 SvXMLImport & m_rSvXMLImport;
154
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>, uno::Reference<text::XTextRange>> field_stack_item_t;
169 typedef ::std::stack< field_stack_item_t > field_stack_t;
170
172
174
175 std::optional<std::map<OUString, OUString>> m_xCrossRefHeadingBookmarkMap;
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)
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
211uno::Reference< text::XText > & XMLTextImportHelper::GetText()
212{
213 return m_xImpl->m_xText;
214}
215
216uno::Reference< text::XTextCursor > & XMLTextImportHelper::GetCursor()
217{
218 return m_xImpl->m_xCursor;
219}
220
221uno::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
251uno::Reference<container::XNameContainer> const&
253{
254 return m_xImpl->m_xParaStyles;
255}
256
257uno::Reference<container::XNameContainer> const&
259{
260 return m_xImpl->m_xTextStyles;
261}
262
263uno::Reference<container::XNameContainer> const&
265{
266 return m_xImpl->m_xNumStyles;
267}
268
269uno::Reference<container::XNameContainer> const&
271{
272 return m_xImpl->m_xFrameStyles;
273}
274
275uno::Reference<container::XNameContainer> const&
277{
278 return m_xImpl->m_xPageStyles;
279}
280
281uno::Reference<container::XNameContainer> const&
283{
284 return m_xImpl->m_xCellStyles;
285}
286
287uno::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
337namespace
338{
339 class FieldParamImporter
340 {
341 public:
342 typedef std::pair<OUString,OUString> field_param_t;
343 typedef std::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.getArray());
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 static constexpr OUStringLiteral aParaStyles(u"ParagraphStyles");
460 if( xFamilies->hasByName( aParaStyles ) )
461 {
462 m_xImpl->m_xParaStyles.set(xFamilies->getByName(aParaStyles),
463 UNO_QUERY);
464 }
465
466 static constexpr OUStringLiteral aCharStyles(u"CharacterStyles");
467 if( xFamilies->hasByName( aCharStyles ) )
468 {
469 m_xImpl->m_xTextStyles.set(xFamilies->getByName(aCharStyles),
470 UNO_QUERY);
471 }
472
473 static constexpr OUStringLiteral aNumStyles(u"NumberingStyles");
474 if( xFamilies->hasByName( aNumStyles ) )
475 {
476 m_xImpl->m_xNumStyles.set(xFamilies->getByName(aNumStyles),
477 UNO_QUERY);
478 }
479
480 static constexpr OUStringLiteral aFrameStyles(u"FrameStyles");
481 if( xFamilies->hasByName( aFrameStyles ) )
482 {
483 m_xImpl->m_xFrameStyles.set(xFamilies->getByName(aFrameStyles),
484 UNO_QUERY);
485 }
486
487 static constexpr OUStringLiteral aPageStyles(u"PageStyles");
488 if( xFamilies->hasByName( aPageStyles ) )
489 {
490 m_xImpl->m_xPageStyles.set(xFamilies->getByName(aPageStyles),
491 UNO_QUERY);
492 }
493
494 static constexpr OUStringLiteral aCellStyles(u"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
615void 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
630bool 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
640bool XMLTextImportHelper::IsDuplicateFrame(const OUString& sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const
641{
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
701void 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
712void XMLTextImportHelper::InsertString( std::u16string_view 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 return;
719
720 sal_Int32 nLen = rChars.size();
721 OUStringBuffer sChars( nLen );
722
723 for( sal_Int32 i=0; i < nLen; i++ )
724 {
725 sal_Unicode c = rChars[i];
726 switch( c )
727 {
728 case 0x20:
729 case 0x09:
730 case 0x0a:
731 case 0x0d:
732 if( !rIgnoreLeadingSpace )
733 sChars.append( u' ' );
734 rIgnoreLeadingSpace = true;
735 break;
736 default:
737 rIgnoreLeadingSpace = false;
738 sChars.append( c );
739 break;
740 }
741 }
742 m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange,
743 sChars.makeStringAndClear(), false);
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
804OUString 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
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*/
888static 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 =
942 rImport.GetStyleDisplayName( XmlStyleFamily::TEXT_PARAGRAPH,
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, Any(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 // Assure that list style of automatic paragraph style is applied at paragraph. (#i101349#)
1088 bool bApplyNumRules(pStyle && pStyle->IsListStyleSet());
1089
1090 if (pListBlock) {
1091 // the xNumRules is always created, even without a list-style-name
1092 if (pListBlock->HasListStyleName()
1093 || (pListItem != nullptr && pListItem->HasNumRulesOverride()))
1094 {
1095 bApplyNumRules = true; // tdf#114287
1096 }
1097
1098 if (!pListItem) {
1099 bNumberingIsNumber = false; // list-header
1100 }
1101
1102 // consider text:style-override property of <text:list-item>
1103 xNewNumRules.set(
1104 (pListItem != nullptr && pListItem->HasNumRulesOverride())
1105 ? pListItem->GetNumRulesOverride()
1106 : pListBlock->GetNumRules() );
1107 nLevel = static_cast<sal_Int8>(pListBlock->GetLevel());
1108
1109 if ( pListItem && pListItem->HasStartValue() ) {
1110 nStartValue = pListItem->GetStartValue();
1111 }
1112
1113 // Inconsistent behavior regarding lists (#i92811#)
1114 sListId = m_xImpl->m_xTextListsHelper->GetListIdForListBlock(
1115 *pListBlock);
1116 }
1117 else if (pNumberedParagraph)
1118 {
1119 xNewNumRules.set(pNumberedParagraph->GetNumRules());
1120 nLevel = static_cast<sal_Int8>(pNumberedParagraph->GetLevel());
1121 sListId = pNumberedParagraph->GetListId();
1122 nStartValue = pNumberedParagraph->GetStartValue();
1123 }
1124
1125
1126 if (pListBlock || pNumberedParagraph)
1127 {
1128 if ( !bApplyNumRules )
1129 {
1130 bool bSameNumRules = xNewNumRules == xNumRules;
1131 if( !bSameNumRules && xNewNumRules.is() && xNumRules.is() )
1132 {
1133 // If the interface pointers are different, then this does
1134 // not mean that the num rules are different. Further tests
1135 // are required then. However, if only one num rule is
1136 // set, no tests are required of course.
1137 Reference< XNamed > xNewNamed( xNewNumRules, UNO_QUERY );
1138 Reference< XNamed > xNamed( xNumRules, UNO_QUERY );
1139 if( xNewNamed.is() && xNamed.is() )
1140 {
1141 bSameNumRules = xNewNamed->getName() == xNamed->getName();
1142 }
1143 else
1144 {
1145 Reference< XAnyCompare > xNumRuleCompare( xNumRules, UNO_QUERY );
1146 if( xNumRuleCompare.is() )
1147 {
1148 bSameNumRules = (xNumRuleCompare->compare( Any(xNumRules), Any(xNewNumRules) ) == 0);
1149 }
1150 }
1151 }
1152 bApplyNumRules = !bSameNumRules;
1153 }
1154
1155 if ( bApplyNumRules )
1156 {
1157 // #102607# This may except when xNewNumRules contains
1158 // a Writer-NumRule-Implementation bug gets applied to
1159 // a shape. Since this may occur inside a document
1160 // (e.g. when edited), this must be handled
1161 // gracefully.
1162 try
1163 {
1164 xPropSet->setPropertyValue(
1165 s_NumberingRules, Any(xNewNumRules) );
1166 }
1167 catch(const Exception&)
1168 {
1169 ; // I would really like to use a warning here,
1170 // but I can't access the XMLErrorHandler from
1171 // here.
1172 }
1173 }
1174
1175 if (!bNumberingIsNumber &&
1176 xPropSetInfo->hasPropertyByName(s_NumberingIsNumber))
1177 {
1178 xPropSet->setPropertyValue(s_NumberingIsNumber, Any(false));
1179 }
1180
1181 xPropSet->setPropertyValue( s_NumberingLevel, Any(nLevel) );
1182
1183 if( pListBlock && pListBlock->IsRestartNumbering() )
1184 {
1185 // TODO: property missing
1186 if (xPropSetInfo->hasPropertyByName(s_ParaIsNumberingRestart))
1187 {
1188 xPropSet->setPropertyValue(s_ParaIsNumberingRestart,
1189 Any(true) );
1190 }
1191 pListBlock->ResetRestartNumbering();
1192 }
1193
1194 if ( 0 <= nStartValue &&
1195 xPropSetInfo->hasPropertyByName(s_NumberingStartValue))
1196 {
1197 xPropSet->setPropertyValue(s_NumberingStartValue,
1198 Any(nStartValue));
1199 }
1200
1201 if (xPropSetInfo->hasPropertyByName(s_PropNameListId))
1202 {
1203 if (!sListId.isEmpty()) {
1204 xPropSet->setPropertyValue(s_PropNameListId,
1205 Any(sListId) );
1206 }
1207 }
1208
1209 GetTextListHelper().SetListItem( nullptr );
1210 }
1211 else
1212 {
1213 /* If the paragraph is not in a list but its style, remove it from
1214 the list. Do not remove it, if the list of the style is
1215 the chapter numbering rule.
1216 */
1217 if( xNumRules.is() )
1218 {
1219 bool bRemove( true );
1220 // Special handling for document from OOo 2.x (#i70748#)
1221 sal_Int32 nUPD( 0 );
1222 sal_Int32 nBuild( 0 );
1223 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1224 if ( ( bBuildIdFound && nUPD == 680 ) ||
1225 !pStyle || !pStyle->IsListStyleSet() )
1226 {
1227 if (m_xImpl->m_xChapterNumbering.is())
1228 {
1229 Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY );
1230 Reference< XNamed > const xChapterNumNamed (
1231 m_xImpl->m_xChapterNumbering, UNO_QUERY);
1232 if ( xNumNamed.is() && xChapterNumNamed.is() &&
1233 xNumNamed->getName() == xChapterNumNamed->getName() )
1234 {
1235 bRemove = false;
1236 // RFE: inserting headings into text documents (#i70748#)
1237 bApplyOutlineLevelAsListLevel = true;
1238 }
1239 }
1240 }
1241 else
1242 {
1243 SAL_INFO_IF(!pStyle->GetListStyle().isEmpty(),
1244 "xmloff.text",
1245 "automatic paragraph style with list style name, but paragraph not in list???");
1246 }
1247 if ( bRemove )
1248 {
1249 xPropSet->setPropertyValue( s_NumberingRules, Any() );
1250 }
1251 }
1252 }
1253 }
1254
1255 // hard paragraph properties
1256 if( pStyle )
1257 {
1258 pStyle->FillPropertySet( xPropSet );
1259 if( bPara && pStyle->HasMasterPageName() &&
1260 xPropSetInfo->hasPropertyByName(s_PageDescName))
1261 {
1262 OUString sDisplayName(
1263 rImport.GetStyleDisplayName(
1265 pStyle->GetMasterPageName()) );
1266 if( sDisplayName.isEmpty() ||
1267 (m_xImpl->m_xPageStyles.is() &&
1268 m_xImpl->m_xPageStyles->hasByName( sDisplayName)))
1269 {
1270 xPropSet->setPropertyValue(s_PageDescName,
1271 Any(sDisplayName));
1272 }
1273 }
1274 if( bPara && !pStyle->GetDropCapStyleName().isEmpty() &&
1275 m_xImpl->m_xTextStyles.is())
1276 {
1277 OUString sDisplayName(
1278 rImport.GetStyleDisplayName(
1280 pStyle->GetDropCapStyleName()) );
1281 if (m_xImpl->m_xTextStyles->hasByName(sDisplayName) &&
1282 xPropSetInfo->hasPropertyByName("DropCapCharStyleName"))
1283 {
1284 xPropSet->setPropertyValue("DropCapCharStyleName", Any(sDisplayName));
1285 }
1286 }
1287
1288 // combined characters special treatment
1289 if (!bPara && pStyle->HasCombinedCharactersLetter())
1290 {
1291 // insert combined characters text field
1292 if (m_xImpl->m_xServiceFactory.is())
1293 {
1294 uno::Reference<beans::XPropertySet> const xTmp(
1295 m_xImpl->m_xServiceFactory->createInstance(
1296 "com.sun.star.text.TextField.CombinedCharacters"), UNO_QUERY);
1297 if( xTmp.is() )
1298 {
1299 // fix cursor if larger than possible for
1300 // combined characters field
1301 if (rCursor->getString().getLength() >
1303 {
1304 rCursor->gotoRange(rCursor->getStart(), false);
1305 rCursor->goRight(MAX_COMBINED_CHARACTERS, true);
1306 }
1307
1308 // set field value (the combined character string)
1309 xTmp->setPropertyValue("Content",
1310 Any(rCursor->getString()));
1311
1312 // insert the field over it's original text
1313 Reference<XTextContent> xTextContent(xTmp, UNO_QUERY);
1314 if (m_xImpl->m_xText.is() && rCursor.is())
1315 {
1316 // #i107225# the combined characters need to be inserted first
1317 // the selected text has to be removed afterwards
1318 m_xImpl->m_xText->insertTextContent( rCursor->getStart(), xTextContent, true );
1319
1320 if( !rCursor->getString().isEmpty() )
1321 {
1322 try
1323 {
1324 uno::Reference< text::XTextCursor > xCrsr = rCursor->getText()->createTextCursorByRange( rCursor->getStart() );
1325 xCrsr->goLeft( 1, true );
1326 uno::Reference< beans::XPropertySet> xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW );
1327 //the hard properties of the removed text need to be applied to the combined characters field
1328 pStyle->FillPropertySet( xCrsrProperties );
1329 xCrsr->collapseToEnd();
1330 xCrsr->gotoRange( rCursor->getEnd(), true );
1331 xCrsr->setString( OUString() );
1332 }
1333 catch(const uno::Exception&)
1334 {
1335 }
1336 }
1337 }
1338 }
1339 }
1340 }
1341 }
1342
1343 // outline level; set after list style has been set
1344 // Complete re-worked and corrected: (#i53198#)
1345 // - set outline level at paragraph
1346 // - set numbering level at paragraph, if none is already set
1347 // - assure that style is marked as an outline style for the corresponding
1348 // outline level.
1349 // - DO NOT set type of numbering rule to outline.
1350 // - DO NOT set numbering rule directly at the paragraph.
1351
1352 // Some minor rework and adjust access to paragraph styles (#i70748#)
1353 if ( bPara )
1354 {
1355 // Headings not numbered anymore in 3.1 (#i103817#)
1356 sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0;
1357 const bool bHasOutlineLevelProp(
1358 xPropSetInfo->hasPropertyByName(s_OutlineLevel));
1359 if ( bHasOutlineLevelProp )
1360 {
1361 xPropSet->getPropertyValue(s_OutlineLevel)
1362 >>= nCurrentOutlineLevelInheritedFromParagraphStyle;
1363 }
1364 if ( nOutlineLevel > 0 )
1365 {
1366 if ( bHasOutlineLevelProp )
1367 {
1368 // In case that the value equals the value of its paragraph style
1369 // attribute outline level, the paragraph attribute value is left unset
1370 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel )
1371 {
1372 xPropSet->setPropertyValue( s_OutlineLevel,
1373 Any( static_cast<sal_Int16>(nOutlineLevel) ) );
1374 }
1375 }
1376 if (!bOutlineContentVisible)
1377 {
1378 uno::Sequence<beans::PropertyValue> aGrabBag;
1379 xPropSet->getPropertyValue("ParaInteropGrabBag") >>= aGrabBag;
1380 sal_Int32 length = aGrabBag.getLength();
1381 aGrabBag.realloc(length + 1);
1382 auto pGrabBag = aGrabBag.getArray();
1383 pGrabBag[length].Name = "OutlineContentVisibleAttr";
1384 pGrabBag[length].Value <<= bool(bOutlineContentVisible);
1385 xPropSet->setPropertyValue("ParaInteropGrabBag", uno::Any(aGrabBag));
1386 }
1387 // RFE: inserting headings into text documents (#i70748#)
1388 if ( bApplyOutlineLevelAsListLevel )
1389 {
1390 sal_Int16 nNumLevel = -1;
1391 xPropSet->getPropertyValue( s_NumberingLevel ) >>= nNumLevel;
1392 if ( nNumLevel == -1 ||
1393 nNumLevel != (nOutlineLevel - 1) )
1394 {
1395 xPropSet->setPropertyValue( s_NumberingLevel,
1396 Any( static_cast<sal_Int8>(nOutlineLevel - 1) ) );
1397 }
1398 }
1399 /* Correction: (#i69629#)
1400 - for text document from version OOo 2.0.4/SO 8 PU4 and earlier
1401 the paragraph style of a heading should be assigned to the
1402 corresponding list level of the outline style.
1403 - for other text documents the paragraph style of a heading is only
1404 a candidate for an assignment to the list level of the outline
1405 style, if it has no direct list style property and (if exists) the
1406 automatic paragraph style has also no direct list style set.
1407 */
1408 if (m_xImpl->m_xParaStyles.is() && m_xImpl->m_xParaStyles->hasByName(sStyleName))
1409 {
1410 bool bOutlineStyleCandidate( false );
1411
1412 sal_Int32 nUPD( 0 );
1413 sal_Int32 nBuild( 0 );
1414 const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild );
1415 // Lost outline numbering in master document (#i73509#)
1416 // Check explicitly on certain versions (#i86058#)
1417 if ( rImport.IsTextDocInOOoFileFormat() ||
1418 ( bBuildIdFound &&
1419 ( nUPD == 645 || nUPD == 641 ) ) )
1420 {
1421 bOutlineStyleCandidate = true;
1422 }
1423 else if ( nUPD == 680 && nBuild <= 9073 ) /* BuildId of OOo 2.0.4/SO8 PU4 */
1424 {
1425 bOutlineStyleCandidate = bOutlineLevelAttrFound;
1426 }
1427 if ( bOutlineStyleCandidate )
1428 {
1429 AddOutlineStyleCandidate( nOutlineLevel, sStyleName );
1430 }
1431 // Assure that heading applies the outline style (#i103817#)
1432 if ( ( !pStyle || !pStyle->IsListStyleSet() ) &&
1433 !bOutlineStyleCandidate &&
1434 m_xImpl->m_xChapterNumbering.is())
1435 {
1436 if ( !lcl_HasListStyle( sStyleName,
1437 m_xImpl->m_xParaStyles, GetXMLImport(),
1438 u"NumberingStyleName",
1439 u"" ) )
1440 {
1441 // heading not in a list --> apply outline style
1442 xPropSet->setPropertyValue( s_NumberingRules,
1443 Any(m_xImpl->m_xChapterNumbering) );
1444 xPropSet->setPropertyValue( s_NumberingLevel,
1445 Any(static_cast<sal_Int8>(nOutlineLevel - 1)));
1446 }
1447 }
1448 }
1449 }
1450 //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10]
1451 else if( bHasOutlineLevelProp )
1452 {
1453 if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 )
1454 {
1455 xPropSet->setPropertyValue(s_OutlineLevel,
1456 Any( sal_Int16(0) ));
1457 }
1458 }
1459 }
1460
1461 return sStyleName;
1462}
1463
1465 sal_Int8 nOutlineLevel )
1466{
1467 // style name empty?
1468 if( !rStyleName.isEmpty() )
1469 return;
1470
1471 // Empty? Then we need o do stuff. Let's do error checking first.
1472 if (m_xImpl->m_xChapterNumbering.is() &&
1473 ( nOutlineLevel > 0 ) &&
1474 (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount()))
1475 {
1476 nOutlineLevel--; // for the remainder, the level's are 0-based
1477
1478 // empty style name: look-up previously used name
1479
1480 // if we don't have a previously used name, we'll use the default
1481 m_xImpl->InitOutlineStylesCandidates();
1482 if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty())
1483 {
1484 // no other name used previously? Then use default
1485
1486 // iterate over property value sequence to find the style name
1487 Sequence<PropertyValue> aProperties;
1488 m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel )
1489 >>= aProperties;
1490 auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties),
1491 [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; });
1492 if (pProp != std::cend(aProperties))
1493 {
1494 OUString aOutlineStyle;
1495 pProp->Value >>= aOutlineStyle;
1496 m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel]
1497 .push_back( aOutlineStyle );
1498 }
1499 }
1500
1501 // finally, we'll use the previously used style name for this
1502 // format (or the default we've just put into that style)
1503 // take last added one (#i71249#)
1504 rStyleName =
1505 m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back();
1506 }
1507 // else: nothing we can do, so we'll leave it empty
1508 // else: we already had a style name, so we let it pass.
1509}
1510
1512 const OUString& rStyleName )
1513{
1514 if (!rStyleName.isEmpty()
1515 && m_xImpl->m_xChapterNumbering.is()
1516 && (nOutlineLevel > 0)
1517 && (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount()))
1518 {
1519 m_xImpl->InitOutlineStylesCandidates();
1520 m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel-1].push_back(
1521 rStyleName);
1522 }
1523}
1524
1525void XMLTextImportHelper::SetOutlineStyles( bool bSetEmptyLevels )
1526{
1527 if (!(m_xImpl->m_xOutlineStylesCandidates != nullptr || bSetEmptyLevels) ||
1528 !m_xImpl->m_xChapterNumbering.is() ||
1529 IsInsertMode())
1530 return;
1531
1532 bool bChooseLastOne( false );
1533 {
1534 if ( GetXMLImport().IsTextDocInOOoFileFormat() )
1535 {
1536 bChooseLastOne = true;
1537 }
1538 else
1539 {
1540 sal_Int32 nUPD( 0 );
1541 sal_Int32 nBuild( 0 );
1542 if ( GetXMLImport().getBuildIds( nUPD, nBuild ) )
1543 {
1544 // check explicitly on certain versions
1545 bChooseLastOne = ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
1546 ( nUPD == 680 && nBuild <= 9073 ); // OOo 2.0 - OOo 2.0.4
1547 }
1548 }
1549 }
1550
1551 OUString sOutlineStyleName;
1552 {
1553 Reference<XPropertySet> xChapterNumRule(
1554 m_xImpl->m_xChapterNumbering, UNO_QUERY);
1555 xChapterNumRule->getPropertyValue("Name") >>= sOutlineStyleName;
1556 }
1557
1558 const sal_Int32 nCount = m_xImpl->m_xChapterNumbering->getCount();
1559 /* First collect all paragraph styles chosen for assignment to each
1560 list level of the outline style, then perform the intrinsic assignment.
1561 Reason: The assignment of a certain paragraph style to a list level
1562 of the outline style causes side effects on the children
1563 paragraph styles in Writer. (#i106218#)
1564 */
1565 ::std::vector<OUString> sChosenStyles(nCount);
1566 for( sal_Int32 i=0; i < nCount; ++i )
1567 {
1568 if ( bSetEmptyLevels ||
1569 (m_xImpl->m_xOutlineStylesCandidates &&
1570 !m_xImpl->m_xOutlineStylesCandidates[i].empty()))
1571 {
1572 // determine, which candidate is one to be assigned to the list
1573 // level of the outline style
1574 if (m_xImpl->m_xOutlineStylesCandidates &&
1575 !m_xImpl->m_xOutlineStylesCandidates[i].empty())
1576 {
1577 if ( bChooseLastOne )
1578 {
1579 sChosenStyles[i] =
1580 m_xImpl->m_xOutlineStylesCandidates[i].back();
1581 }
1582 else
1583 {
1584 for (size_t j = 0;
1585 j < m_xImpl->m_xOutlineStylesCandidates[i].size();
1586 ++j)
1587 {
1588 if (!lcl_HasListStyle(
1589 m_xImpl->m_xOutlineStylesCandidates[i][j],
1590 m_xImpl->m_xParaStyles,
1591 GetXMLImport(),
1592 "NumberingStyleName",
1593 sOutlineStyleName))
1594 {
1595 sChosenStyles[i] =
1596 m_xImpl->m_xOutlineStylesCandidates[i][j];
1597 break;
1598 }
1599 }
1600 }
1601 }
1602 }
1603 }
1604 // Trashed outline numbering in ODF 1.1 text document created by OOo 3.x (#i106218#)
1605 Sequence < PropertyValue > aProps( 1 );
1606 PropertyValue *pProps = aProps.getArray();
1607 pProps->Name = "HeadingStyleName";
1608 for ( sal_Int32 i = 0; i < nCount; ++i )
1609 {
1610 // Paragraph style assignments in Outline of template lost from second level on (#i107610#)
1611 if ( bSetEmptyLevels || !sChosenStyles[i].isEmpty() )
1612 {
1613 pProps->Value <<= sChosenStyles[i];
1614 m_xImpl->m_xChapterNumbering->replaceByIndex(i,
1615 Any( aProps ));
1616 }
1617 }
1618
1619}
1620
1622 SvXMLImport const & rImport,
1623 const Reference < XTextCursor >& rCursor,
1624 const OUString& rHRef,
1625 const OUString& rName,
1626 const OUString& rTargetFrameName,
1627 const OUString& rStyleName,
1628 const OUString& rVisitedStyleName,
1629 XMLEventsImportContext* pEvents)
1630{
1631 static constexpr OUStringLiteral s_HyperLinkURL = u"HyperLinkURL";
1632 static constexpr OUStringLiteral s_HyperLinkName = u"HyperLinkName";
1633 static constexpr OUStringLiteral s_HyperLinkTarget = u"HyperLinkTarget";
1634 static constexpr OUStringLiteral s_UnvisitedCharStyleName = u"UnvisitedCharStyleName";
1635 static constexpr OUStringLiteral s_VisitedCharStyleName = u"VisitedCharStyleName";
1636 static constexpr OUStringLiteral s_HyperLinkEvents = u"HyperLinkEvents";
1637
1638 Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY );
1639 Reference < XPropertySetInfo > xPropSetInfo(
1640 xPropSet->getPropertySetInfo());
1641 if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1642 return;
1643
1644 xPropSet->setPropertyValue(s_HyperLinkURL, Any(rHRef));
1645
1646 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1647 {
1648 xPropSet->setPropertyValue(s_HyperLinkName, Any(rName));
1649 }
1650
1651 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1652 {
1653 xPropSet->setPropertyValue(s_HyperLinkTarget,
1654 Any(rTargetFrameName));
1655 }
1656
1657 if ( (pEvents != nullptr) &&
1658 xPropSetInfo->hasPropertyByName(s_HyperLinkEvents))
1659 {
1660 // The API treats events at hyperlinks differently from most
1661 // other properties: You have to set a name replace with the
1662 // events in it. The easiest way to do this is to 1) get
1663 // events, 2) set new ones, and 3) then put events back.
1664 uno::Reference<XNameReplace> const xReplace(
1665 xPropSet->getPropertyValue(s_HyperLinkEvents), UNO_QUERY);
1666 if (xReplace.is())
1667 {
1668 // set events
1669 pEvents->SetEvents(xReplace);
1670
1671 // put events
1672 xPropSet->setPropertyValue(s_HyperLinkEvents, Any(xReplace));
1673 }
1674 }
1675
1676 if (!m_xImpl->m_xTextStyles.is())
1677 return;
1678
1679 OUString sDisplayName(
1680 rImport.GetStyleDisplayName(
1681 XmlStyleFamily::TEXT_TEXT, rStyleName ) );
1682 if( !sDisplayName.isEmpty() &&
1683 xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) &&
1684 m_xImpl->m_xTextStyles->hasByName(sDisplayName))
1685 {
1686 xPropSet->setPropertyValue(s_UnvisitedCharStyleName,
1687 Any(sDisplayName));
1688 }
1689
1690 sDisplayName =
1691 rImport.GetStyleDisplayName(
1692 XmlStyleFamily::TEXT_TEXT, rVisitedStyleName );
1693 if( !sDisplayName.isEmpty() &&
1694 xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) &&
1695 m_xImpl->m_xTextStyles->hasByName(sDisplayName))
1696 {
1697 xPropSet->setPropertyValue(s_VisitedCharStyleName,
1698 Any(sDisplayName));
1699 }
1700}
1701
1703 SvXMLImport const & rImport,
1704 const Reference < XTextCursor >& rCursor,
1705 const OUString& rStyleName,
1706 const OUString& rTextStyleName,
1707 const OUString& rText )
1708{
1709 Reference<XPropertySet> xPropSet(rCursor, UNO_QUERY);
1710
1711 OUString sRubyText("RubyText");
1712
1713 // if we have one Ruby property, we assume all of them are present
1714 if (!xPropSet.is() ||
1715 !xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText ))
1716 return;
1717
1718 // the ruby text
1719 xPropSet->setPropertyValue(sRubyText, Any(rText));
1720
1721 // the ruby style (ruby-adjust)
1722 if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is())
1723 {
1724 const SvXMLStyleContext* pTempStyle =
1725 m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY,
1726 rStyleName, true );
1727 XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
1728
1729 if (nullptr != pStyle)
1730 pStyle->FillPropertySet( xPropSet );
1731 }
1732
1733 // the ruby text character style
1734 if (m_xImpl->m_xTextStyles.is())
1735 {
1736 OUString sDisplayName(
1737 rImport.GetStyleDisplayName(
1738 XmlStyleFamily::TEXT_TEXT, rTextStyleName ) );
1739 if( (!sDisplayName.isEmpty()) &&
1740 m_xImpl->m_xTextStyles->hasByName( sDisplayName ))
1741 {
1742 xPropSet->setPropertyValue("RubyCharStyleName", Any(sDisplayName));
1743 }
1744 }
1745}
1746
1748{
1749 m_xImpl->m_xAutoStyles = pStyles;
1750}
1751
1753 SvXMLImport& rImport,
1754 sal_Int32 nElement,
1755 const Reference< XFastAttributeList > & xAttrList,
1756 XMLTextType eType )
1757{
1758 SvXMLImportContext *pContext = nullptr;
1759
1760 bool bContent = true;
1761 switch( nElement )
1762 {
1763 case XML_ELEMENT(TEXT, XML_H):
1764 case XML_ELEMENT(TEXT, XML_P):
1765 case XML_ELEMENT(LO_EXT, XML_P):
1766 pContext = new XMLParaContext( rImport,
1767 nElement,
1768 xAttrList );
1769 if (m_xImpl->m_bProgress && XMLTextType::Shape != eType)
1770 {
1771 rImport.GetProgressBarHelper()->Increment();
1772 }
1773 break;
1774 // #i52127#
1776 pContext = new XMLNumberedParaContext(
1777 rImport, nElement, xAttrList );
1778 break;
1779 case XML_ELEMENT(TEXT, XML_LIST):
1780 pContext = new XMLTextListBlockContext( rImport, *this,
1781 xAttrList );
1782 break;
1784 case XML_ELEMENT(LO_EXT, XML_TABLE):
1785 if( XMLTextType::Body == eType ||
1791 pContext = CreateTableChildContext( rImport, nElement, xAttrList );
1792 break;
1794 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1796 {
1797 pContext = new XMLVariableDeclsImportContext(
1798 rImport, *this, VarTypeSequence);
1799 bContent = false;
1800 }
1801 break;
1803 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1805 {
1806 pContext = new XMLVariableDeclsImportContext(
1807 rImport, *this, VarTypeSimple);
1808 bContent = false;
1809 }
1810 break;
1812 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted)||
1814 {
1815 pContext = new XMLVariableDeclsImportContext(
1816 rImport, *this, VarTypeUserField);
1817 bContent = false;
1818 }
1819 break;
1821 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1823 {
1824 pContext = new XMLDdeFieldDeclsImportContext(rImport);
1825 bContent = false;
1826 }
1827 break;
1828 case XML_ELEMENT(DRAW, XML_FRAME):
1829 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1832 {
1833 TextContentAnchorType eAnchorType =
1834 XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME
1835 : TextContentAnchorType_AT_PAGE;
1836 pContext = new XMLTextFrameContext( rImport, xAttrList,
1837 eAnchorType );
1838 bContent = false;
1839 }
1840 break;
1841 case XML_ELEMENT(DRAW, XML_A):
1842 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1845 {
1846 TextContentAnchorType eAnchorType =
1847 XMLTextType::TextBox == eType ? TextContentAnchorType_AT_FRAME
1848 : TextContentAnchorType_AT_PAGE;
1849 pContext = new XMLTextFrameHyperlinkContext( rImport, nElement,
1850 xAttrList,
1851 eAnchorType );
1852 bContent = false;
1853 }
1854 break;
1857 pContext = new XMLSectionImportContext( rImport );
1858 break;
1866 if( XMLTextType::Shape != eType )
1867 pContext = new XMLIndexTOCContext( rImport, nElement );
1868 break;
1870 pContext = new XMLTrackedChangesImportContext( rImport );
1871 bContent = false;
1872 break;
1876 pContext = new XMLChangeImportContext(
1877 rImport,
1878 ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END))
1880 : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START))
1883 true);
1884 break;
1887 bContent = false;
1888 break;
1890 if( XMLTextType::Body == eType )
1891 {
1892 pContext = new XMLAutoMarkFileContext(rImport);
1893 }
1894 bContent = false;
1895 break;
1897 pContext = new XMLCalculationSettingsContext ( rImport, nElement, xAttrList);
1898 bContent = false;
1899 break;
1900
1901 default:
1902 if ((XMLTextType::Body == eType && m_xImpl->m_bBodyContentStarted) ||
1905 {
1906 Reference < XShapes > xShapes;
1908 rImport, nElement, xAttrList, xShapes );
1909 bContent = false;
1910 }
1911 }
1912
1913 // handle open redlines
1914 if ( (XML_ELEMENT(TEXT, XML_CHANGE) != nElement) &&
1915 (XML_ELEMENT(TEXT, XML_CHANGE_END) != nElement) &&
1916 (XML_ELEMENT(TEXT, XML_CHANGE_START) != nElement) )
1917 {
1918// ResetOpenRedlineId();
1919 }
1920
1921 if( XMLTextType::Body == eType && bContent )
1922 {
1923 m_xImpl->m_bBodyContentStarted = false;
1924 }
1925
1926 if( nElement != XML_ELEMENT(DRAW, XML_FRAME) )
1928
1929 if (!pContext)
1930 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1931
1932 return pContext;
1933}
1934
1936 SvXMLImport&,
1937 sal_Int32 /*nElement*/,
1938 const Reference< XFastAttributeList > & )
1939{
1940 return nullptr;
1941}
1942
1944sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName,
1945 bool* pIsSystemLanguage )
1946{
1947 if (!m_xImpl->m_xAutoStyles.is())
1948 return -1;
1949
1950 const SvXMLStyleContext* pStyle =
1951 m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::DATA_STYLE,
1952 sStyleName, true );
1953
1954 // get appropriate context
1955
1956
1957 // first check if it's an Impress and draw only number format
1958 // this is needed since it's also a SvXMLNumFormatContext,
1959 // that was needed to support them for controls in impress/draw also
1960 const SdXMLNumberFormatImportContext* pSdNumStyle = dynamic_cast<const SdXMLNumberFormatImportContext*>( pStyle );
1961 if( pSdNumStyle )
1962 {
1963 return pSdNumStyle->GetDrawKey();
1964 }
1965 else
1966 {
1967 SvXMLNumFormatContext* pNumStyle = const_cast<SvXMLNumFormatContext*>(dynamic_cast<const SvXMLNumFormatContext*>( pStyle ) );
1968 if( pNumStyle )
1969 {
1970 if( pIsSystemLanguage != nullptr )
1971 *pIsSystemLanguage = pNumStyle->IsSystemLanguage();
1972
1973 // return key
1974 return pNumStyle->GetKey();
1975 }
1976 }
1977 return -1;
1978}
1979
1981{
1982 const SvxXMLListStyleContext *pStyle = nullptr;
1983 if (m_xImpl->m_xAutoStyles.is())
1984 {
1985 const SvXMLStyleContext* pTempStyle =
1986 m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_LIST, rName,
1987 true );
1988 pStyle = dynamic_cast< const SvxXMLListStyleContext* >(pTempStyle);
1989 }
1990
1991 return pStyle;
1992}
1993
1995{
1996 XMLPropStyleContext *pStyle = nullptr;
1997 if (m_xImpl->m_xAutoStyles.is())
1998 {
1999 const SvXMLStyleContext* pTempStyle =
2000 m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::SD_GRAPHICS_ID, rName,
2001 true );
2002 pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
2003 }
2004
2005 return pStyle;
2006}
2007
2009 const OUString& rName ) const
2010{
2011 XMLPropStyleContext* pStyle = nullptr;
2012 if (m_xImpl->m_xAutoStyles.is())
2013 {
2014 const SvXMLStyleContext* pTempStyle =
2015 m_xImpl->m_xAutoStyles->FindStyleChildContext(
2017 rName, true );
2018 pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
2019 }
2020
2021 return pStyle;
2022}
2023
2025 const OUString& rName ) const
2026{
2027 XMLPropStyleContext* pStyle = nullptr;
2028 if (m_xImpl->m_xAutoStyles.is())
2029 {
2030 const SvXMLStyleContext* pTempStyle =
2031 m_xImpl->m_xAutoStyles->FindStyleChildContext(
2033 rName, true );
2034 pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle));
2035 }
2036
2037 return pStyle;
2038}
2039
2041{
2042 if (!m_xImpl->m_xAutoStyles)
2043 return nullptr;
2044 auto pStyle
2045 = m_xImpl->m_xAutoStyles->FindStyleChildContext(XmlStyleFamily::TEXT_TEXT, rName, true);
2046 return dynamic_cast<XMLPropStyleContext*>(const_cast<SvXMLStyleContext*>(pStyle));
2047}
2048
2050{
2051 if (!m_xImpl->m_xAutoStyles.is())
2052 {
2053 return nullptr;
2054 }
2055 SvXMLStyleContext const* pStyle(
2056 m_xImpl->m_xAutoStyles->FindStyleChildContext(
2057 XmlStyleFamily::SD_DRAWINGPAGE_ID, rName, true));
2058 assert(pStyle == nullptr || dynamic_cast<XMLPropStyleContext const*>(pStyle) != nullptr);
2059 return const_cast<XMLPropStyleContext*>(static_cast<XMLPropStyleContext const*>(pStyle));
2060}
2061
2063{
2065}
2066
2068{
2070}
2071
2072
2074{
2075 if (!m_xImpl->m_xRenameMap)
2076 {
2077 m_xImpl->m_xRenameMap.reset( new SvI18NMap );
2078 }
2079 return *m_xImpl->m_xRenameMap;
2080}
2081
2083 const OUString & sName,
2084 const Reference<XTextRange> & rRange,
2085 OUString const& i_rXmlId,
2086 std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes)
2087{
2088 m_xImpl->m_BookmarkStartRanges[sName] =
2089 std::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes);
2090 m_xImpl->m_BookmarkVector.push_back(sName);
2091}
2092
2094 const OUString & sName,
2095 Reference<XTextRange> & o_rRange,
2096 OUString & o_rXmlId,
2097 std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes)
2098{
2099 if (m_xImpl->m_BookmarkStartRanges.count(sName))
2100 {
2101 Impl::BookmarkMapEntry_t & rEntry =
2102 (*m_xImpl->m_BookmarkStartRanges.find(sName)).second;
2103 o_rRange.set(std::get<0>(rEntry));
2104 o_rXmlId = std::get<1>(rEntry);
2105 o_rpRDFaAttributes = std::get<2>(rEntry);
2106 m_xImpl->m_BookmarkStartRanges.erase(sName);
2107 auto it = std::find(m_xImpl->m_BookmarkVector.begin(), m_xImpl->m_BookmarkVector.end(), sName);
2108 if (it!=m_xImpl->m_BookmarkVector.end())
2109 {
2110 m_xImpl->m_BookmarkVector.erase(it);
2111 }
2112 return true;
2113 }
2114 else
2115 {
2116 return false;
2117 }
2118}
2119
2120void XMLTextImportHelper::pushFieldCtx( const OUString& name, const OUString& type )
2121{
2122 m_xImpl->m_FieldStack.push(Impl::field_stack_item_t(
2123 Impl::field_name_type_t(name, type), Impl::field_params_t(), uno::Reference<text::XFormField>{}, GetCursor()->getStart()));
2124}
2125
2126uno::Reference<text::XFormField>
2128{
2129 uno::Reference<text::XFormField> xRet;
2130 if ( !m_xImpl->m_FieldStack.empty() )
2131 {
2132 xRet = std::get<2>(m_xImpl->m_FieldStack.top());
2133 m_xImpl->m_FieldStack.pop();
2134 }
2135 else
2136 {
2137 SAL_INFO("xmloff.text", "unexpected fieldmark end");
2138 }
2139 return xRet;
2140}
2141
2142void XMLTextImportHelper::addFieldParam( const OUString& name, const OUString& value )
2143{
2144 assert(!m_xImpl->m_FieldStack.empty());
2145 Impl::field_stack_item_t & FieldStackItem(m_xImpl->m_FieldStack.top());
2146 std::get<1>(FieldStackItem).emplace_back( name, value );
2147}
2148
2149::std::pair<OUString, OUString> XMLTextImportHelper::getCurrentFieldType() const
2150{
2151 assert(!m_xImpl->m_FieldStack.empty());
2152 return std::get<0>(m_xImpl->m_FieldStack.top());
2153}
2154
2155uno::Reference<text::XTextRange> XMLTextImportHelper::getCurrentFieldStart() const
2156{
2157 assert(!m_xImpl->m_FieldStack.empty());
2158 return std::get<3>(m_xImpl->m_FieldStack.top());
2159}
2160
2162{
2163 assert(!m_xImpl->m_FieldStack.empty());
2164 return std::get<2>(m_xImpl->m_FieldStack.top()).is();
2165}
2166
2168{
2169 return !m_xImpl->m_FieldStack.empty();
2170}
2171
2172void XMLTextImportHelper::setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField)
2173{
2174 assert(!m_xImpl->m_FieldStack.empty());
2175 if (xFormField.is())
2176 {
2177 FieldParamImporter(&std::get<1>(m_xImpl->m_FieldStack.top()),
2178 xFormField->getParameters()).Import();
2179 std::get<2>(m_xImpl->m_FieldStack.top()) = xFormField;
2180 }
2181}
2182
2183
2185 const OUString& rFrmName,
2186 const OUString& rNextFrmName,
2187 const Reference < XPropertySet >& rFrmPropSet )
2188{
2189 if( rFrmName.isEmpty() )
2190 return;
2191
2192 if( !rNextFrmName.isEmpty() )
2193 {
2194 OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME,
2195 rNextFrmName ));
2196 if (m_xImpl->m_xTextFrames.is()
2197 && m_xImpl->m_xTextFrames->hasByName(sNextFrmName))
2198 {
2199 rFrmPropSet->setPropertyValue("ChainNextName",
2200 Any(sNextFrmName));
2201 }
2202 else
2203 {
2204 if (!m_xImpl->m_xPrevFrmNames)
2205 {
2206 m_xImpl->m_xPrevFrmNames.emplace();
2207 m_xImpl->m_xNextFrmNames.emplace();
2208 }
2209 m_xImpl->m_xPrevFrmNames->push_back(rFrmName);
2210 m_xImpl->m_xNextFrmNames->push_back(sNextFrmName);
2211 }
2212 }
2213 if (!m_xImpl->m_xPrevFrmNames || m_xImpl->m_xPrevFrmNames->empty())
2214 return;
2215
2216 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)
2217 {
2218 if((*j) == rFrmName)
2219 {
2220 // The previous frame must exist, because it existing than
2221 // inserting the entry
2222 rFrmPropSet->setPropertyValue("ChainPrevName", Any(*i));
2223
2224 i = m_xImpl->m_xPrevFrmNames->erase(i);
2225 j = m_xImpl->m_xNextFrmNames->erase(j);
2226
2227 // There cannot be more than one previous frames
2228 break;
2229 }
2230 }
2231}
2232
2234{
2235 static constexpr OUStringLiteral s_TextFrame = u"TextFrame";
2236
2237 bool bIsInFrame = false;
2238
2239 // are we currently in a text frame? yes, if the cursor has a
2240 // TextFrame property and it's non-NULL
2241 Reference<XPropertySet> xPropSet(const_cast<XMLTextImportHelper*>(this)->GetCursor(), UNO_QUERY);
2242 if (xPropSet.is())
2243 {
2244 if (xPropSet->getPropertySetInfo()->hasPropertyByName(s_TextFrame))
2245 {
2246 uno::Reference<XTextFrame> const xFrame(
2247 xPropSet->getPropertyValue(s_TextFrame), UNO_QUERY);
2248
2249 if (xFrame.is())
2250 {
2251 bIsInFrame = true;
2252 }
2253 }
2254 }
2255
2256 return bIsInFrame;
2257}
2258
2260{
2261 return false;
2262}
2263
2265 SvXMLImport&,
2266 const OUString& /*rHRef*/,
2267 const OUString& /*rStyleName*/,
2268 const OUString& /*rTblName*/,
2269 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2270{
2271 Reference< XPropertySet> xPropSet;
2272 return xPropSet;
2273}
2274
2276 SvXMLImport&,
2277 const OUString& /*rHRef*/,
2278 const OUString& /*rStyleName*/,
2279 const OUString& /*rTblName*/,
2280 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2281{
2282 Reference< XPropertySet> xPropSet;
2283 return xPropSet;
2284}
2285
2287 const OUString& /*rCode*/,
2288 const OUString& /*rName*/,
2289 bool /*bMayScript*/,
2290 const OUString& /*rHRef*/,
2291 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2292{
2293 Reference< XPropertySet> xPropSet;
2294 return xPropSet;
2295}
2297 const OUString& /*rMimeType*/,
2298 const OUString& /*rHRef*/,
2299 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2300{
2301 Reference< XPropertySet> xPropSet;
2302 return xPropSet;
2303}
2305 const OUString& /*rName*/,
2306 const OUString& /*rHRef*/,
2307 const OUString& /*rStyleName*/,
2308 sal_Int32 /*nWidth*/, sal_Int32 /*nHeight*/ )
2309{
2310 Reference< XPropertySet> xPropSet;
2311 return xPropSet;
2312}
2313
2315 const Reference < XPropertySet> &,
2316 std::map < const OUString, OUString > &)
2317{
2318}
2319// redline helper: dummy implementation to be overridden in sw/filter/xml
2320void XMLTextImportHelper::RedlineAdd( const OUString& /*rType*/,
2321 const OUString& /*rId*/,
2322 const OUString& /*rAuthor*/,
2323 const OUString& /*rComment*/,
2324 const util::DateTime& /*rDateTime*/,
2325 bool /*bMergeLastPara*/)
2326{
2327 // dummy implementation: do nothing
2328}
2329
2331 Reference<XTextCursor> & /*rOldCursor*/,
2332 const OUString& /*rId*/)
2333{
2334 // dummy implementation: do nothing
2335 Reference<XTextCursor> xRet;
2336 return xRet;
2337}
2338
2340 const OUString& /*rId*/,
2341 bool /*bStart*/,
2342 bool /*bIsOutsideOfParagraph*/)
2343{
2344 // dummy implementation: do nothing
2345}
2346
2348{
2349 // dummy implementation: do nothing
2350}
2351
2353{
2354 // dummy implementation: do nothing
2355}
2356
2358{
2359 // dummy implementation: do nothing
2360}
2361void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &)
2362{
2363 // dummy implementation: do nothing
2364}
2365
2366
2368{
2369 return m_xImpl->m_sOpenRedlineIdentifier;
2370}
2371
2372void XMLTextImportHelper::SetOpenRedlineId( OUString const & rId)
2373{
2374 m_xImpl->m_sOpenRedlineIdentifier = rId;
2375}
2376
2378{
2379 SetOpenRedlineId("");
2380}
2381
2382void
2384{
2385 m_xImpl->m_sCellParaStyleDefault = rNewValue;
2386}
2387
2389{
2390 return m_xImpl->m_sCellParaStyleDefault;
2391}
2392
2393void XMLTextImportHelper::AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo)
2394{
2395 if (!m_xImpl->m_xCrossRefHeadingBookmarkMap)
2396 {
2397 m_xImpl->m_xCrossRefHeadingBookmarkMap.emplace();
2398 }
2399 m_xImpl->m_xCrossRefHeadingBookmarkMap->insert(std::make_pair(rFrom, rTo));
2400}
2401
2402// tdf#94804: hack to map cross reference fields that reference duplicate marks
2403// note that we can't really check meta:generator for this since the file might
2404// be round-tripped by different versions preserving duplicates => always map
2406{
2407 if (!m_xImpl->m_xCrossRefHeadingBookmarkMap)
2408 {
2409 return;
2410 }
2411
2412 uno::Reference<text::XTextFieldsSupplier> const xFieldsSupplier(
2413 m_xImpl->m_rSvXMLImport.GetModel(), uno::UNO_QUERY);
2414 if (!xFieldsSupplier.is())
2415 {
2416 return;
2417 }
2418 uno::Reference<container::XEnumerationAccess> const xFieldsEA(
2419 xFieldsSupplier->getTextFields());
2420 uno::Reference<container::XEnumeration> const xFields(
2421 xFieldsEA->createEnumeration());
2422 while (xFields->hasMoreElements())
2423 {
2424 uno::Reference<lang::XServiceInfo> const xFieldInfo(
2425 xFields->nextElement(), uno::UNO_QUERY);
2426 if (!xFieldInfo->supportsService("com.sun.star.text.textfield.GetReference"))
2427 {
2428 continue;
2429 }
2430 uno::Reference<beans::XPropertySet> const xField(
2431 xFieldInfo, uno::UNO_QUERY);
2432 sal_uInt16 nType(0);
2433 xField->getPropertyValue("ReferenceFieldSource") >>= nType;
2434 if (text::ReferenceFieldSource::BOOKMARK != nType)
2435 {
2436 continue;
2437 }
2438 OUString name;
2439 xField->getPropertyValue("SourceName") >>= name;
2440 auto const iter(m_xImpl->m_xCrossRefHeadingBookmarkMap->find(name));
2441 if (iter == m_xImpl->m_xCrossRefHeadingBookmarkMap->end())
2442 {
2443 continue;
2444 }
2445 xField->setPropertyValue("SourceName", uno::Any(iter->second));
2446 }
2447}
2448
2449void XMLTextImportHelper::setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition)
2450{
2451 m_xImpl->m_bBookmarkHidden[bookmark] = hidden;
2452 m_xImpl->m_sBookmarkCondition[bookmark] = condition;
2453}
2454
2455bool XMLTextImportHelper::getBookmarkHidden(OUString const& bookmark) const
2456{
2457 return m_xImpl->m_bBookmarkHidden[bookmark];
2458}
2459
2460const OUString& XMLTextImportHelper::getBookmarkCondition(OUString const& bookmark) const
2461{
2462 return m_xImpl->m_sBookmarkCondition[bookmark];
2463}
2464
2465/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XMLPropertyMapEntry const g_XMLPageMasterDrawingPageStyleMap[]
PropertiesInfo aProperties
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:75
bool IsSystemLanguage() const
determine whether number format uses the system language
Definition: xmlnumfi.cxx:2168
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:102
const OUString & GetListId() const
Definition: txtparai.hxx:101
sal_Int16 GetLevel() const
Definition: txtparai.hxx:98
const css::uno::Reference< css::container::XIndexReplace > & GetNumRules() const
Definition: txtparai.hxx:99
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:2233
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:2275
void pushFieldCtx(const OUString &name, const OUString &type)
Definition: txtimp.cxx:2120
OUString ConvertStarFonts(const OUString &rChars, const OUString &rStyleName, sal_uInt8 &rFlags, bool bPara, SvXMLImport &rImport) const
Definition: txtimp.cxx:804
bool IsOrganizerMode() const
Definition: txtimp.cxx:241
void FindOutlineStyleName(OUString &rStyleName, sal_Int8 nOutlineLevel)
Find a suitable name for the given outline level.
Definition: txtimp.cxx:1464
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:2304
OUString const & GetCellParaStyleDefault() const
Definition: txtimp.cxx:2388
void InsertControlCharacter(sal_Int16 nControl)
Definition: txtimp.cxx:746
void InsertTextContent(css::uno::Reference< css::text::XTextContent > const &xContent)
Definition: txtimp.cxx:757
XMLTextListsHelper & GetTextListHelper()
Definition: txtimp.cxx:332
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:2320
XMLPropStyleContext * FindDrawingPage(OUString const &rName) const
Definition: txtimp.cxx:2049
static SvXMLImportPropertyMapper * CreateParaExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:559
bool getBookmarkHidden(OUString const &bookmark) const
Definition: txtimp.cxx:2455
const css::uno::Reference< css::container::XIndexReplace > & GetChapterNumbering() const
Definition: txtimp.cxx:288
void SetInsideDeleteContext(bool const bNew)
redlining : Setter to remember the fact we are inside/outside a <text:deletion> element (deleted redl...
Definition: txtimp.cxx:317
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:2093
virtual bool IsInHeaderFooter() const
Definition: txtimp.cxx:2259
rtl::Reference< SvXMLImportPropertyMapper > const & GetSectionImportPropertySetMapper() const
Definition: txtimp.cxx:306
bool IsBlockMode() const
Definition: txtimp.cxx:236
const css::uno::Reference< css::container::XNameContainer > & GetPageStyles() const
Definition: txtimp.cxx:276
void SetOutlineStyles(bool bSetEmpty)
Definition: txtimp.cxx:1525
css::uno::Reference< css::text::XTextCursor > & GetCursor()
Definition: txtimp.cxx:216
rtl::Reference< SvXMLImportPropertyMapper > const & GetTextImportPropertySetMapper() const
Definition: txtimp.cxx:300
rtl::Reference< SvXMLImportPropertyMapper > const & GetRubyImportPropertySetMapper() const
Definition: txtimp.cxx:312
css::uno::Reference< css::text::XText > & GetText()
Definition: txtimp.cxx:211
void setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField > const &xFormField)
Definition: txtimp.cxx:2172
static SvXMLImportPropertyMapper * CreateTableRowDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:589
virtual void SetShowChanges(bool bShowChanges)
Definition: txtimp.cxx:2352
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:1621
css::uno::Reference< css::text::XFormField > popFieldCtx()
Definition: txtimp.cxx:2127
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:2082
virtual void RedlineSetCursor(const OUString &rId, bool bStart, bool bIsOutsideOfParagraph)
Definition: txtimp.cxx:2339
virtual void endAppletOrPlugin(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, ::std::map< const OUString, OUString > &rParamMap)
Definition: txtimp.cxx:2314
void PopListContext()
pop the list context stack
Definition: txtimp.cxx:2067
void addFieldParam(const OUString &name, const OUString &value)
Definition: txtimp.cxx:2142
void SetOpenRedlineId(OUString const &rId)
modify the last open redline ID
Definition: txtimp.cxx:2372
SvI18NMap & GetRenameMap()
Definition: txtimp.cxx:2073
void PushListContext()
push a list context on the list context stack
Definition: txtimp.cxx:2062
static SvXMLImportPropertyMapper * CreateTableCellExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:598
void SetCellParaStyleDefault(OUString const &rNewValue)
Definition: txtimp.cxx:2383
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:1702
XMLPropStyleContext * FindSectionStyle(const OUString &rName) const
Definition: txtimp.cxx:2008
void AddOutlineStyleCandidate(const sal_Int8 nOutlineLevel, const OUString &rStyleName)
Definition: txtimp.cxx:1511
const css::uno::Reference< css::container::XNameContainer > & GetParaStyles() const
Definition: txtimp.cxx:252
static SvXMLImportPropertyMapper * CreateParaDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:566
css::uno::Reference< css::text::XTextRange > getCurrentFieldStart() const
Definition: txtimp.cxx:2155
XMLPropStyleContext * FindPageMaster(const OUString &rName) const
Definition: txtimp.cxx:2024
rtl::Reference< SvXMLImportPropertyMapper > const & GetParaImportPropertySetMapper() const
Definition: txtimp.cxx:294
XMLPropStyleContext * FindAutoCharStyle(const OUString &rName) const
Definition: txtimp.cxx:2040
bool HasFrameByName(const OUString &rName) const
Definition: txtimp.cxx:630
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:2296
virtual void SetRecordChanges(bool bRecordChanges)
Definition: txtimp.cxx:2357
static SvXMLImportPropertyMapper * CreateDrawingPageExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:607
bool IsDuplicateFrame(const OUString &sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const
Definition: txtimp.cxx:640
bool IsStylesOnlyMode() const
Definition: txtimp.cxx:231
bool hasCurrentFieldCtx() const
Definition: txtimp.cxx:2167
void StoreLastImportedFrameName(const OUString &rName)
Definition: txtimp.cxx:691
void SetCursor(const css::uno::Reference< css::text::XTextCursor > &rCursor)
Definition: txtimp.cxx:615
bool hasCurrentFieldSeparator() const
Definition: txtimp.cxx:2161
virtual ~XMLTextImportHelper() override
Definition: txtimp.cxx:542
bool IsProgress() const
Definition: txtimp.cxx:246
virtual void SetChangesProtectionKey(const css::uno::Sequence< sal_Int8 > &rProtectionKey)
Definition: txtimp.cxx:2361
::std::pair< OUString, OUString > getCurrentFieldType() const
Definition: txtimp.cxx:2149
void setBookmarkAttributes(OUString const &bookmark, bool hidden, OUString const &condition)
Definition: txtimp.cxx:2449
static SvXMLImportPropertyMapper * CreateTableDefaultExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:580
const OUString & getBookmarkCondition(OUString const &bookmark) const
Definition: txtimp.cxx:2460
XMLPropStyleContext * FindAutoFrameStyle(const OUString &rName) const
Definition: txtimp.cxx:1994
void AddCrossRefHeadingMapping(OUString const &rFrom, OUString const &rTo)
Definition: txtimp.cxx:2393
bool IsInsideDeleteContext() const
redlining : Getter to know if we are inside a <text:deletion> element (deleted redline section)
Definition: txtimp.cxx:322
SvXMLImport & GetXMLImport()
Definition: txtimp.cxx:327
void MapCrossRefHeadingFieldsHorribly()
Definition: txtimp.cxx:2405
std::unique_ptr< Impl > m_xImpl
Definition: txtimp.hxx:100
const css::uno::Reference< css::container::XNameContainer > & GetFrameStyles() const
Definition: txtimp.cxx:270
void ResetOpenRedlineId()
reset the last open redline ID
Definition: txtimp.cxx:2377
const SvxXMLListStyleContext * FindAutoListStyle(const OUString &rName) const
Definition: txtimp.cxx:1980
const css::uno::Reference< css::container::XNameContainer > & GetNumberingStyles() const
Definition: txtimp.cxx:264
const css::uno::Reference< css::container::XNameContainer > & GetTextStyles() const
Definition: txtimp.cxx:258
virtual void RedlineAdjustStartNodeCursor()
Definition: txtimp.cxx:2347
void ClearLastImportedTextFrameName()
Definition: txtimp.cxx:696
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
static SvXMLImportPropertyMapper * CreateShapeExtPropMapper(SvXMLImport &)
Definition: txtimp.cxx:552
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:1944
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:2264
const css::uno::Reference< css::container::XNameContainer > & GetCellStyles() const
Definition: txtimp.cxx:282
bool IsInsertMode() const
Definition: txtimp.cxx:226
void InsertString(const OUString &rChars)
Definition: txtimp.cxx:701
OUString const & GetOpenRedlineId() const
get the last open redline ID
Definition: txtimp.cxx:2367
SvXMLImportContext * CreateTextChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLTextType eType=XMLTextType::Shape)
Definition: txtimp.cxx:1752
void ConnectFrameChains(const OUString &rFrmName, const OUString &rNextFrmName, const css::uno::Reference< css::beans::XPropertySet > &rFrmPropSet)
Definition: txtimp.cxx:2184
virtual SvXMLImportContext * CreateTableChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: txtimp.cxx:1935
void SetAutoStyles(SvXMLStylesContext *pStyles)
Definition: txtimp.cxx:1747
css::uno::Reference< css::text::XTextRange > & GetCursorAsRange()
Definition: txtimp.cxx:221
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:2286
void DeleteParagraph()
Definition: txtimp.cxx:769
virtual css::uno::Reference< css::text::XTextCursor > RedlineCreateText(css::uno::Reference< css::text::XTextCursor > &rOldCursor, const OUString &rId)
Definition: txtimp.cxx:2330
const css::uno::Reference< css::container::XIndexReplace > & GetNumRules() const
bool HasListStyleName()
does this list have (possibly inherited from parent) list-style-name?
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:375
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 sName
OUString sDisplayName
const char * name
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
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:1073
@ XML_NUMBERED_PARAGRAPH
Definition: xmltoken.hxx:3227
@ XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE
Definition: xmltoken.hxx:237
@ XML_ALPHABETICAL_INDEX
Definition: xmltoken.hxx:236
@ XML_DDE_CONNECTION_DECLS
Definition: xmltoken.hxx:638
@ XML_CALCULATION_SETTINGS
Definition: xmltoken.hxx:390
constexpr OUStringLiteral ODF_FORMCHECKBOX_RESULT
Definition: odffields.hxx:30
constexpr OUStringLiteral ODF_FORMDROPDOWN_RESULT
Definition: odffields.hxx:34
constexpr OUStringLiteral ODF_FORMDROPDOWN_LISTENTRY
Definition: odffields.hxx:33
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:104
OUString m_sCellParaStyleDefault
Definition: txtimp.cxx:173
uno::Reference< container::XNameAccess > m_xObjects
Definition: txtimp.cxx:150
::std::vector< field_param_t > field_params_t
Definition: txtimp.cxx:167
OUString msLastImportedFrameName
Definition: txtimp.cxx:133
rtl::Reference< SvXMLImportPropertyMapper > m_xSectionImpPrMap
Definition: txtimp.cxx:105
std::tuple< uno::Reference< text::XTextRange >, OUString, std::shared_ptr< ::xmloff::ParsedRDFaAttributes > > BookmarkMapEntry_t
Definition: txtimp.cxx:123
std::vector< OUString > m_BookmarkVector
Definition: txtimp.cxx:127
OUString m_sOpenRedlineIdentifier
name of the last 'open' redline that started between paragraphs
Definition: txtimp.cxx:130
::std::pair< OUString, OUString > field_name_type_t
Definition: txtimp.cxx:165
std::optional< std::map< OUString, OUString > > m_xCrossRefHeadingBookmarkMap
Definition: txtimp.cxx:175
std::optional< std::vector< OUString > > m_xPrevFrmNames
Definition: txtimp.cxx:96
std::unique_ptr< SvI18NMap > m_xRenameMap
Definition: txtimp.cxx:108
::std::tuple< field_name_type_t, field_params_t, uno::Reference< text::XFormField >, uno::Reference< text::XTextRange > > field_stack_item_t
Definition: txtimp.cxx:168
uno::Reference< container::XNameAccess > m_xGraphics
Definition: txtimp.cxx:149
uno::Reference< container::XNameContainer > m_xCellStyles
Definition: txtimp.cxx:146
std::map< OUString, OUString > m_sBookmarkCondition
Definition: txtimp.cxx:136
std::map< OUString, BookmarkMapEntry_t > m_BookmarkStartRanges
start ranges for open bookmarks
Definition: txtimp.cxx:125
uno::Reference< container::XNameContainer > m_xFrameStyles
Definition: txtimp.cxx:144
Impl(const Impl &)=delete
uno::Reference< text::XTextCursor > m_xCursor
Definition: txtimp.cxx:139
std::unique_ptr< std::vector< OUString >[]> m_xOutlineStylesCandidates
Definition: txtimp.cxx:117
uno::Reference< text::XText > m_xText
Definition: txtimp.cxx:138
uno::Reference< container::XNameAccess > m_xTextFrames
Definition: txtimp.cxx:148
uno::Reference< text::XTextRange > m_xCursorAsRange
Definition: txtimp.cxx:140
rtl::Reference< SvXMLStylesContext > m_xAutoStyles
Definition: txtimp.cxx:100
uno::Reference< container::XNameContainer > m_xPageStyles
Definition: txtimp.cxx:145
Impl & operator=(const Impl &)=delete
SvXMLImport & m_rSvXMLImport
Definition: txtimp.cxx:153
rtl::Reference< SvXMLImportPropertyMapper > m_xTextImpPrMap
Definition: txtimp.cxx:103
void InitOutlineStylesCandidates()
Definition: txtimp.cxx:198
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
field_stack_t m_FieldStack
Definition: txtimp.cxx:171
uno::Reference< lang::XMultiServiceFactory > m_xServiceFactory
Definition: txtimp.cxx:151
std::optional< std::vector< OUString > > m_xNextFrmNames
Definition: txtimp.cxx:97
uno::Reference< container::XNameContainer > m_xParaStyles
Definition: txtimp.cxx:141
uno::Reference< container::XIndexReplace > m_xChapterNumbering
Definition: txtimp.cxx:147
std::unique_ptr< XMLTextListsHelper > m_xTextListsHelper
Definition: txtimp.cxx:98
rtl::Reference< SvXMLImportPropertyMapper > m_xRubyImpPrMap
Definition: txtimp.cxx:106
uno::Reference< container::XNameContainer > m_xTextStyles
Definition: txtimp.cxx:142
::std::stack< field_stack_item_t > field_stack_t
Definition: txtimp.cxx:169
rtl::Reference< SvXMLImportPropertyMapper > m_xParaImpPrMap
Definition: txtimp.cxx:102
std::map< OUString, bool > m_bBookmarkHidden
Definition: txtimp.cxx:135
bool m_bInsideDeleteContext
Are we inside a <text:deletion> element (deleted redline section)
Definition: txtimp.cxx:163
::std::pair< OUString, OUString > field_param_t
Definition: txtimp.cxx:166
uno::Reference< container::XNameContainer > m_xNumStyles
Definition: txtimp.cxx:143
Reference< XFrame > xFrame
TEXT
#define MAX_COMBINED_CHARACTERS
Definition: txtimp.cxx:92
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
@ 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:97