LibreOffice Module sw (master) 1
doc.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 <config_features.h>
21
22#include <doc.hxx>
23#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
24#include <com/sun/star/frame/XModel.hpp>
42#include <UndoManager.hxx>
43#include <dbmgr.hxx>
44#include <hintids.hxx>
45
46#include <comphelper/random.hxx>
47#include <tools/multisel.hxx>
48#include <rtl/ustring.hxx>
49#include <svl/poolitem.hxx>
51#include <editeng/keepitem.hxx>
53#include <editeng/pbinitem.hxx>
55
56#include <swatrset.hxx>
57#include <swmodule.hxx>
58#include <fmtrfmrk.hxx>
59#include <fmtinfmt.hxx>
60#include <fmtfld.hxx>
61#include <txtfld.hxx>
62#include <dbfld.hxx>
63#include <txtinet.hxx>
64#include <txtrfmrk.hxx>
65#include <frmatr.hxx>
66#include <pagefrm.hxx>
67#include <rootfrm.hxx>
68#include <pam.hxx>
69#include <ndtxt.hxx>
70#include <swundo.hxx>
71#include <rolbck.hxx>
72#include <UndoAttribute.hxx>
73#include <UndoCore.hxx>
74#include <UndoTable.hxx>
75#include <pagedesc.hxx>
76#include <doctxm.hxx>
77#include <poolfmt.hxx>
78#include <SwGrammarMarkUp.hxx>
79#include <scriptinfo.hxx>
80#include <mdiexp.hxx>
81#include <docary.hxx>
82#include <printdata.hxx>
83#include <strings.hrc>
84#include <SwUndoTOXChange.hxx>
85#include <unocrsr.hxx>
86#include <docfld.hxx>
87#include <docufld.hxx>
88#include <viewsh.hxx>
89#include <shellres.hxx>
90#include <txtfrm.hxx>
91#include <attrhint.hxx>
92
93#include <vector>
94#include <map>
95#include <o3tl/string_view.hxx>
96#include <osl/diagnose.h>
97#include <osl/interlck.h>
99#include <editeng/langitem.hxx>
100#include <calbck.hxx>
101#include <crsrsh.hxx>
102
103/* @@@MAINTAINABILITY-HORROR@@@
104 Probably unwanted dependency on SwDocShell
105*/
106#include <docsh.hxx>
107
108using namespace ::com::sun::star;
109
110sal_Int32 SwDoc::acquire()
111{
112 assert(mReferenceCount >= 0);
113 return osl_atomic_increment(&mReferenceCount);
114}
115
116sal_Int32 SwDoc::release()
117{
118 assert(mReferenceCount >= 1);
119 auto x = osl_atomic_decrement(&mReferenceCount);
120 if (x == 0)
121 delete this;
122 return x;
123}
124
126{
127 assert(mReferenceCount >= 0);
128 return mReferenceCount;
129}
130
132{
133 return *m_pMetaFieldManager;
134}
135
137{
139}
140
142{
143 return *m_pUndoManager;
144}
145
147{
148 return *m_pUndoManager;
149}
150
151
152IDocumentUndoRedo & SwDoc::GetIDocumentUndoRedo()
153{
154 return *m_pUndoManager;
155}
156
157IDocumentUndoRedo const & SwDoc::GetIDocumentUndoRedo() const
158{
159 return *m_pUndoManager;
160}
161
162/* IDocumentDrawModelAccess */
164{
166}
167
169{
171}
172
174{
176}
177
179{
181}
182
183/* IDocumentSettingAccess */
185{
187}
188
190{
192}
193
195{
197}
198
200{
202}
203
204sal_uInt32 SwDoc::getRsid() const
205{
206 return mnRsid;
207}
208
209void SwDoc::setRsid( sal_uInt32 nVal )
210{
211 static bool bHack = (getenv("LIBO_ONEWAY_STABLE_ODF_EXPORT") != nullptr);
212
213 sal_uInt32 nIncrease = 0;
214 if (!bHack)
215 {
216 // Increase the rsid with a random number smaller than 2^17. This way we
217 // expect to be able to edit a document 2^12 times before rsid overflows.
218 // start from 1 to ensure the new rsid is not the same
219 nIncrease = comphelper::rng::uniform_uint_distribution(1, (1 << 17) - 1);
220 }
221 mnRsid = nVal + nIncrease;
222}
223
224sal_uInt32 SwDoc::getRsidRoot() const
225{
226 return mnRsidRoot;
227}
228
229void SwDoc::setRsidRoot( sal_uInt32 nVal )
230{
231 mnRsidRoot = nVal;
232}
233
234/* IDocumentChartDataProviderAccess */
236{
238}
239
241{
243}
244
245// IDocumentDeviceAccess
247{
248 return *m_pDeviceAccess;
249}
250
252{
253 return *m_pDeviceAccess;
254}
255
256//IDocumentTimerAccess
258{
260}
261
263{
265}
266
267// IDocumentLinksAdministration
269{
271}
272
274{
276}
277
279{
281}
282
284{
286}
287
288//IDocumentListItems
290{
292}
293
294//IDocumentListItems
296{
298}
299
300//IDocumentListsAccess
302{
304}
305
307{
309}
310
311//IDocumentOutlinesNodes
313{
315}
316
318{
320}
321
322//IDocumentContentOperations
324{
326}
327
329{
331}
332
334{
336}
338{
340}
341
342//IDocumentRedlineAccess
344{
346}
347
349{
351}
352
354{
356}
357
359{
361}
362
363//IDocumentFieldsAccess
364
366{
368}
369
371{
373}
374
376{
378}
379
380//IDocumentStatistics
382{
384}
385
387{
389}
390
392{
394}
395
397{
399}
400
401//IDocumentState
403{
405}
406
408{
410}
411
412//IDocumentLayoutAccess
414{
416}
417
419{
421}
422
424{
426}
427
429{
431}
432
433//IDocumentStylePoolAccess
435{
437}
438
440{
442}
443
444//IDocumentExternalData
446{
448}
449
451{
453}
454
455/* Implementations the next Interface here */
456
457/*
458 * Document editing (Doc-SS) to fill the document
459 * by the RTF parser and for the EditShell.
460 */
461void SwDoc::ChgDBData(const SwDBData& rNewData)
462{
463 if( rNewData != maDBData )
464 {
465 maDBData = rNewData;
467 if (m_pDBManager)
469 }
471}
472
473namespace {
474
475struct PostItField_ : public SetGetExpField
476{
477 PostItField_( const SwNode& rNd, const SwTextField* pField )
478 : SetGetExpField( rNd, pField, std::nullopt ) {}
479
480 sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
481 const o3tl::sorted_vector< sal_Int32 > &rPossiblePages,
482 sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo );
483
484 const SwPostItField* GetPostIt() const
485 {
486 return static_cast<const SwPostItField*>( GetTextField()->GetFormatField().GetField() );
487 }
488};
489
490}
491
492sal_uInt16 PostItField_::GetPageNo(
493 const StringRangeEnumerator &rRangeEnum,
494 const o3tl::sorted_vector< sal_Int32 > &rPossiblePages,
495 /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_uInt16& rLineNo )
496{
497 //Problem: If a PostItField is contained in a Node that is represented
498 //by more than one layout instance,
499 //we have to decide whether it should be printed once or n-times.
500 //Probably only once. For the page number we don't select a random one,
501 //but the PostIt's first occurrence in the selected area.
502 rVirtPgNo = 0;
504 for( SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next() )
505 {
506 TextFrameIndex const nPos = pFrame->MapModelToView(
507 &GetTextField()->GetTextNode(), GetContent());
508 if( pFrame->GetOffset() > nPos ||
509 (pFrame->HasFollow() && pFrame->GetFollow()->GetOffset() <= nPos) )
510 continue;
511 sal_uInt16 nPgNo = pFrame->GetPhyPageNum();
512 if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
513 {
514 rLineNo = o3tl::narrowing<sal_uInt16>(pFrame->GetLineCount( nPos ) +
515 pFrame->GetAllLines() - pFrame->GetThisLines());
516 rVirtPgNo = pFrame->GetVirtPageNum();
517 return nPgNo;
518 }
519 }
520 return 0;
521}
522
524{
526 assert(pFieldType);
527
528 std::vector<SwFormatField*> vFields;
529 pFieldType->GatherFields(vFields);
530 if(pSrtLst)
531 for(auto pField: vFields)
532 {
533 auto pTextField = pField->GetTextField();
534 std::unique_ptr<PostItField_> pNew(new PostItField_(pTextField->GetTextNode(), pTextField));
535 pSrtLst->insert(std::move(pNew));
536
537 }
538 return vFields.size()>0;
539}
540
543 SwPaM& aPam,
544 const SwPostItField* pField,
545 bool bNewPage, bool bIsFirstPostIt,
546 sal_uInt16 nPageNo, sal_uInt16 nLineNo )
547{
548 static char const sTmp[] = " : ";
549
550 assert(SwViewShell::GetShellRes());
551
552 if (bNewPage)
553 {
554 pIDCO->InsertPoolItem( aPam, SvxFormatBreakItem( SvxBreak::PageAfter, RES_BREAK ) );
555 pIDCO->SplitNode( *aPam.GetPoint(), false );
556 }
557 else if (!bIsFirstPostIt)
558 {
559 // add an empty line between different notes
560 pIDCO->SplitNode( *aPam.GetPoint(), false );
561 pIDCO->SplitNode( *aPam.GetPoint(), false );
562 }
563
564 OUString aStr( SwViewShell::GetShellRes()->aPostItPage );
565 aStr += sTmp +
566 OUString::number( nPageNo ) +
567 " ";
568 if( nLineNo )
569 {
571 aStr += sTmp +
572 OUString::number( nLineNo ) +
573 " ";
574 }
576 aStr += sTmp + pField->GetPar1() + " ";
577 SvtSysLocale aSysLocale;
578 aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() );
579 if(pField->GetResolved())
580 aStr += " " + SwResId(STR_RESOLVED);
581 pIDCO->InsertString( aPam, aStr );
582
583 pIDCO->SplitNode( *aPam.GetPoint(), false );
584 aStr = pField->GetPar2();
585#if defined(_WIN32)
586 // Throw out all CR in Windows
587 aStr = aStr.replaceAll("\r", "");
588#endif
589 pIDCO->InsertString( aPam, aStr );
590}
591
594static sal_Int32 lcl_GetPaperBin( const SwPageFrame *pStartFrame )
595{
596 sal_Int32 nRes = -1;
597
598 const SwFrameFormat &rFormat = pStartFrame->GetPageDesc()->GetMaster();
599 const SfxPoolItem *pItem = nullptr;
600 SfxItemState eState = rFormat.GetItemState( RES_PAPER_BIN, false, &pItem );
601 const SvxPaperBinItem *pPaperBinItem = dynamic_cast< const SvxPaperBinItem * >(pItem);
602 if (eState > SfxItemState::DEFAULT && pPaperBinItem)
603 nRes = pPaperBinItem->GetValue();
604
605 return nRes;
606}
607
608namespace
609{
610// tdf#:114663 Translates a range string from user input (with page numbering possibly not
611// taking blank pages into account) to equivalent string which references physical page numbers.
612// rUIPages2PhyPagesMap must contain a contiguous sequence of UI page numbers
613OUString UIPages2PhyPages(const OUString& rUIPageRange, const std::map< sal_Int32, sal_Int32 >& rUIPages2PhyPagesMap)
614{
615 if (rUIPages2PhyPagesMap.empty())
616 return OUString();
617 auto iMin = rUIPages2PhyPagesMap.begin();
618 const sal_Int32 nUIPageMin = iMin->first, nPhyPageMin = iMin->second;
619 auto iMax = rUIPages2PhyPagesMap.rbegin();
620 const sal_Int32 nUIPageMax = iMax->first, nPhyPageMax = iMax->second;
621 OUStringBuffer aOut(rUIPageRange.getLength());
622 OUStringBuffer aNumber(16);
623 const sal_Unicode* pInput = rUIPageRange.getStr();
624 while (*pInput)
625 {
626 while (*pInput >= '0' && *pInput <= '9')
627 aNumber.append(*pInput++);
628 if (!aNumber.isEmpty())
629 {
630 sal_Int32 nNumber = o3tl::toInt32(aNumber);
631 aNumber.setLength(0);
632 if (nNumber < nUIPageMin)
633 nNumber = nPhyPageMin-1;
634 else if (nNumber > nUIPageMax)
635 nNumber = nPhyPageMax+1;
636 else
637 nNumber = rUIPages2PhyPagesMap.at(nNumber);
638 aOut.append(nNumber);
639 }
640
641 while (*pInput && (*pInput < '0' || *pInput > '9'))
642 aOut.append(*pInput++);
643 }
644
645 return aOut.makeStringAndClear();
646}
647}
648
649// tdf#52316 remove blank pages from page count and actual page number
651 const SwRootFrame& rLayout,
652 sal_uInt16& nDocPageCount,
653 sal_uInt16& nActualPage)
654{
655 sal_uInt16 nDocPageCountWithBlank = nDocPageCount;
656 sal_uInt16 nActualPageWithBlank = nActualPage;
657 sal_uInt16 nPageNum = 1;
658 const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
659 while (pStPage && nPageNum <= nDocPageCountWithBlank)
660 {
661 if ( pStPage->getFrameArea().Height() == 0 )
662 {
663 --nDocPageCount;
664 if (nPageNum <= nActualPageWithBlank)
665 --nActualPage;
666 }
667 ++nPageNum;
668 pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
669 }
670}
671
673 const SwRootFrame& rLayout,
674 /* out */ SwRenderData &rData,
675 const SwPrintUIOptions &rOptions,
676 bool bIsPDFExport,
677 sal_Int32 nDocPageCount )
678{
679 const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
680 const bool bPrintSelection = nContent == 2;
681
682 // properties to take into account when calculating the set of pages
683 // (PDF export UI does not allow for selecting left or right pages only)
684 bool bPrintLeftPages = bIsPDFExport || rOptions.IsPrintLeftPages();
685 bool bPrintRightPages = bIsPDFExport || rOptions.IsPrintRightPages();
686 // #i103700# printing selections should not allow for automatic inserting empty pages
687 bool bPrintEmptyPages = !bPrintSelection && rOptions.IsPrintEmptyPages( bIsPDFExport );
688
689 std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
691 // Map page numbers from user input (possibly ignoring blanks) to physical page numbers
692 std::map< sal_Int32, sal_Int32 > aUIPages2PhyPagesMap;
693 rValidPages.clear();
694
695 sal_Int32 nPageNum = 1, nUIPageNum = 1;
696 const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
697 while (pStPage && nPageNum <= nDocPageCount)
698 {
699 const bool bNonEmptyPage = pStPage->getFrameArea().Height() != 0;
700 const bool bPrintThisPage =
701 ( (bPrintRightPages && pStPage->OnRightPage()) ||
702 (bPrintLeftPages && !pStPage->OnRightPage()) ) &&
703 ( bPrintEmptyPages || bNonEmptyPage );
704
705 if (bPrintThisPage)
706 {
707 rValidPages.insert( nPageNum );
708 rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
709 }
710
711 if ( bPrintEmptyPages || bNonEmptyPage )
712 {
713 aUIPages2PhyPagesMap[nUIPageNum++] = nPageNum;
714 }
715 ++nPageNum;
716 pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
717 }
718
719 // now that we have identified the valid pages for printing according
720 // to the print settings we need to get the PageRange to use and
721 // use both results to get the actual pages to be printed
722 // (post-it settings need to be taken into account later on!)
723
724 // get PageRange value to use
725 OUString aPageRange;
726 // #i116085# - adjusting fix for i113919
727 if ( !bIsPDFExport )
728 {
729 // PageContent :
730 // 0 -> print all pages (default if aPageRange is empty)
731 // 1 -> print range according to PageRange
732 // 2 -> print selection
733 if (1 == nContent)
734 aPageRange = rOptions.getStringValue( "PageRange" );
735
736 if (2 == nContent)
737 {
738 // note that printing selections is actually implemented by copying
739 // the selection to a new temporary document and printing all of that one.
740 // Thus for Writer "PrintContent" must never be 2.
741 // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
742 // printed and for creating the temporary document.
743 }
744
745 // please note
746 }
747 if (aPageRange.isEmpty()) // empty string -> print all
748 {
749 // set page range to print to 'all pages'
750 aPageRange = OUString::number( 1 ) + "-" + OUString::number( nDocPageCount );
751 }
752 else
753 {
754 // Convert page numbers from user input to physical page numbers
755 aPageRange = UIPages2PhyPages(aPageRange, aUIPages2PhyPagesMap);
756 }
757 rData.SetPageRange( aPageRange );
758
759 // get vector of pages to print according to PageRange and valid pages set from above
760 // (result may be an empty vector, for example if the range string is not correct)
761 // If excluding empty pages, allow range to specify range of printable pages
763 1, nDocPageCount, 0, &rData.GetValidPagesSet() );
764}
765
767 /* out */ SwRenderData &rData,
768 const SwPrintUIOptions &rOptions,
769 sal_Int32 nDocPageCount )
770{
771
772 SwPostItMode nPostItMode = static_cast<SwPostItMode>( rOptions.getIntValue( "PrintAnnotationMode", 0 ) );
773 assert((nPostItMode == SwPostItMode::NONE || rData.HasPostItData())
774 && "print post-its without post-it data?");
775 const SetGetExpFields::size_type nPostItCount =
776 rData.HasPostItData() ? rData.m_pPostItFields->size() : 0;
777 if (nPostItMode == SwPostItMode::NONE || nPostItCount <= 0)
778 return;
779
780 CurrShell aCurr( rData.m_pPostItShell.get() );
781
782 // clear document and move to end of it
783 SwDoc & rPostItDoc(*rData.m_pPostItShell->GetDoc());
784 SwPaM aPam(rPostItDoc.GetNodes().GetEndOfContent());
785 aPam.Move( fnMoveBackward, GoInDoc );
786 aPam.SetMark();
787 aPam.Move( fnMoveForward, GoInDoc );
788 rPostItDoc.getIDocumentContentOperations().DeleteRange( aPam );
789
790 const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
791
792 // For mode SwPostItMode::EndPage:
793 // maps a physical page number to the page number in post-it document that holds
794 // the first post-it for that physical page . Needed to relate the correct start frames
795 // from the post-it doc to the physical page of the document
796 std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum;
797
798 // add all post-its on valid pages within the page range to the
799 // temporary post-it document.
800 // Since the array of post-it fields is sorted by page and line number we will
801 // already get them in the correct order
802 sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
803 bool bIsFirstPostIt = true;
804 for (SetGetExpFields::size_type i = 0; i < nPostItCount; ++i)
805 {
806 PostItField_& rPostIt = static_cast<PostItField_&>(*(*rData.m_pPostItFields)[ i ]);
807 nLastPageNum = nPhyPageNum;
808 nPhyPageNum = rPostIt.GetPageNo(
809 aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
810 if (nPhyPageNum)
811 {
812 // need to insert a page break?
813 // In SwPostItMode::EndPage mode for each document page the following
814 // post-it page needs to start on a new page
815 const bool bNewPage = nPostItMode == SwPostItMode::EndPage &&
816 !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
817
818 lcl_FormatPostIt( &rData.m_pPostItShell->GetDoc()->getIDocumentContentOperations(), aPam,
819 rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
820 bIsFirstPostIt = false;
821
822 if (nPostItMode == SwPostItMode::EndPage)
823 {
824 // get the correct number of current pages for the post-it document
825 rData.m_pPostItShell->CalcLayout();
826 const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount();
827 aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
828 }
829 }
830 }
831
832 // format post-it doc to get correct number of pages
833 rData.m_pPostItShell->CalcLayout();
834
835 SwRootFrame* pPostItRoot = rData.m_pPostItShell->GetLayout();
836 //tdf#103313 print dialog maxes out cpu as Idles never get to
837 //complete this postitshell's desire to complete formatting
838 pPostItRoot->ResetIdleFormat();
839
840 const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount();
841
842 if (nPostItMode == SwPostItMode::Only || nPostItMode == SwPostItMode::EndDoc)
843 {
844 // now add those post-it pages to the vector of pages to print
845 // or replace them if only post-its should be printed
846
847 if (nPostItMode == SwPostItMode::Only)
848 {
849 // no document page to be printed
850 rData.GetPagesToPrint().clear();
851 }
852
853 // now we just need to add the post-it pages to be printed to the
854 // end of the vector of pages to print
855 sal_Int32 nPageNum = 0;
856 const SwPageFrame * pPageFrame = static_cast<SwPageFrame*>(pPostItRoot->Lower());
857 while( pPageFrame && nPageNum < nPostItDocPageCount )
858 {
859 ++nPageNum;
860 // negative page number indicates page is from the post-it doc
861 rData.GetPagesToPrint().push_back( -nPageNum );
862 pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
863 }
864 OSL_ENSURE( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
865 }
866 else if (nPostItMode == SwPostItMode::EndPage)
867 {
868 // the next step is to find all the pages from the post-it
869 // document that should be printed for a given physical page
870 // of the document
871
872 std::vector< sal_Int32 > aTmpPagesToPrint;
873 sal_Int32 nLastPostItPage(0);
874 const size_t nNum = rData.GetPagesToPrint().size();
875 for (size_t i = 0 ; i < nNum; ++i)
876 {
877 // add the physical page to print from the document
878 const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
879 aTmpPagesToPrint.push_back( nPhysPage );
880
881 // add the post-it document pages to print, i.e those
882 // post-it pages that have the data for the above physical page
883 std::map<sal_Int32, sal_Int32>::const_iterator const iter(
884 aPostItLastStartPageNum.find(nPhysPage));
885 if (iter != aPostItLastStartPageNum.end())
886 {
887 for (sal_Int32 j = nLastPostItPage + 1;
888 j <= iter->second; ++j)
889 {
890 // negative page number indicates page is from the
891 aTmpPagesToPrint.push_back(-j); // post-it document
892 }
893 nLastPostItPage = iter->second;
894 }
895 }
896
897 // finally we need to assign those vectors to the resulting ones.
898 // swapping the data should be more efficient than assigning since
899 // we won't need the temporary vectors anymore
900 rData.GetPagesToPrint().swap( aTmpPagesToPrint );
901 }
902
903}
904
906 const SwRootFrame& rLayout,
907 /* out */ SwRenderData &rData,
908 const SwPrintUIOptions &rOptions,
909 sal_Int32 nDocPageCount )
910{
911 std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
912 o3tl::sorted_vector< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
913 std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
914 std::map< sal_Int32, const SwPageFrame * > validStartFrames;
915
916 rPagePairs.clear();
917 rValidPagesSet.clear();
918
919 OUString aPageRange;
920 // PageContent :
921 // 0 -> print all pages (default if aPageRange is empty)
922 // 1 -> print range according to PageRange
923 // 2 -> print selection
924 const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
925 if (nContent == 1)
926 aPageRange = rOptions.getStringValue( "PageRange" );
927 if (aPageRange.isEmpty()) // empty string -> print all
928 {
929 // set page range to print to 'all pages'
930 aPageRange = OUString::number( 1 ) + "-" + OUString::number( nDocPageCount );
931 }
932 StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
933
934 if ( aRange.size() <= 0)
935 return;
936
937 const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
938 for ( sal_Int32 i = 1; pStPage && i < nDocPageCount; ++i )
939 pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
940 if ( !pStPage ) // Then it was that
941 return;
942
943 // currently for prospect printing all pages are valid to be printed
944 // thus we add them all to the respective map and set for later use
945 sal_Int32 nPageNum = 0;
946 const SwPageFrame *pPageFrame = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
947 while( pPageFrame && nPageNum < nDocPageCount )
948 {
949 ++nPageNum;
950 rValidPagesSet.insert( nPageNum );
951 validStartFrames[ nPageNum ] = pPageFrame;
952 pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
953
954 rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
955 }
956 OSL_ENSURE( nPageNum == nDocPageCount, "unexpected number of pages" );
957
958 // properties to take into account when calculating the set of pages
959 // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
960 // of the prospect!
961 bool bPrintLeftPages = rOptions.IsPrintLeftPages();
962 bool bPrintRightPages = rOptions.IsPrintRightPages();
963 bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) != 0;
964
965 // get pages for prospect printing according to the 'PageRange'
966 // (duplicates and any order allowed!)
967 std::vector< sal_Int32 > aPagesToPrint;
969 aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
970
971 if (aPagesToPrint.empty())
972 return;
973
974 // now fill the vector for calculating the page pairs with the start frames
975 // from the above obtained vector
976 std::vector< const SwPageFrame * > aVec;
977 for (sal_Int32 nPage : aPagesToPrint)
978 {
979 const SwPageFrame *pFrame = validStartFrames[ nPage ];
980 aVec.push_back( pFrame );
981 }
982
983 // just one page is special ...
984 if ( 1 == aVec.size() )
985 aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page
986 else
987 {
988 // now extend the number of pages to fit a multiple of 4
989 // (4 'normal' pages are needed for a single prospect paper
990 // with back and front)
991 while( aVec.size() & 3 )
992 aVec.push_back( nullptr );
993 }
994
995 // make sure that all pages are in correct order
996 std::vector< const SwPageFrame * >::size_type nSPg = 0;
997 std::vector< const SwPageFrame * >::size_type nEPg = aVec.size();
998 sal_Int32 nStep = 1;
999 if ( 0 == (nEPg & 1 )) // there are no uneven ones!
1000 --nEPg;
1001
1002 if ( !bPrintLeftPages )
1003 ++nStep;
1004 else if ( !bPrintRightPages )
1005 {
1006 ++nStep;
1007 ++nSPg;
1008 --nEPg;
1009 }
1010
1011 // the number of 'virtual' pages to be printed
1012 sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
1013
1014 for ( sal_Int32 nPrintCount = 0; nSPg < nEPg &&
1015 nPrintCount < nCntPage; ++nPrintCount )
1016 {
1017 pStPage = aVec[ nSPg ];
1018 const SwPageFrame* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : nullptr;
1019
1020 short nRtlOfs = bPrintProspectRTL ? 1 : 0;
1021 if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
1022 {
1023 const SwPageFrame* pTmp = pStPage;
1024 pStPage = pNxtPage;
1025 pNxtPage = pTmp;
1026 }
1027
1028 sal_Int32 nFirst = -1, nSecond = -1;
1029 for ( int nC = 0; nC < 2; ++nC )
1030 {
1031 sal_Int32 nPage = -1;
1032 if ( pStPage )
1033 nPage = pStPage->GetPhyPageNum();
1034 if (nC == 0)
1035 nFirst = nPage;
1036 else
1037 nSecond = nPage;
1038
1039 pStPage = pNxtPage;
1040 }
1041 rPagePairs.emplace_back(nFirst, nSecond );
1042
1043 nSPg = nSPg + nStep;
1044 nEPg = nEPg - nStep;
1045 }
1046 OSL_ENSURE( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
1047
1048 // luckily prospect printing does not make use of post-its so far,
1049 // thus we are done here.
1050}
1051
1053const SwFormatRefMark* SwDoc::GetRefMark( std::u16string_view rName ) const
1054{
1055 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1056 {
1057 auto pFormatRef = dynamic_cast<const SwFormatRefMark*>(pItem);
1058 if(!pFormatRef)
1059 continue;
1060
1061 const SwTextRefMark* pTextRef = pFormatRef->GetTextRefMark();
1062 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() &&
1063 rName == pFormatRef->GetRefName() )
1064 return pFormatRef;
1065 }
1066 return nullptr;
1067}
1068
1070const SwFormatRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const
1071{
1072 const SwFormatRefMark* pRet = nullptr;
1073
1074 sal_uInt32 nCount = 0;
1075 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1076 {
1077 auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1078 if( !pRefMark )
1079 continue;
1080 const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark();
1081 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1082 {
1083 if(nCount == nIndex)
1084 {
1085 pRet = pRefMark;
1086 break;
1087 }
1088 nCount++;
1089 }
1090 }
1091 return pRet;
1092}
1093
1095//JP 24.06.96: If the array pointer is 0, then just return whether a RefMark is set in the Doc
1096// OS 25.06.96: From now on we always return the reference count
1097sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const
1098{
1099 sal_uInt16 nCount = 0;
1100 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1101 {
1102 auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1103 if( !pRefMark )
1104 continue;
1105 const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark();
1106 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1107 {
1108 if( pNames )
1109 {
1110 OUString aTmp(pRefMark->GetRefName());
1111 pNames->insert(pNames->begin() + nCount, aTmp);
1112 }
1113 ++nCount;
1114 }
1115 }
1116
1117 return nCount;
1118}
1119
1121{
1122 const SwTextRefMark* pTextRefMark = pFormatRefMark->GetTextRefMark();
1123 SwTextNode& rTextNd = const_cast<SwTextNode&>(pTextRefMark->GetTextNode());
1124 std::unique_ptr<SwRegHistory> aRegHistory;
1125 if (GetIDocumentUndoRedo().DoesUndo())
1126 {
1127 SwUndoResetAttr* pUndo = new SwUndoResetAttr(SwPosition(rTextNd, pTextRefMark->GetStart()),
1129 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
1130 aRegHistory.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory()));
1131 rTextNd.GetpSwpHints()->Register(aRegHistory.get());
1132 }
1133 rTextNd.DeleteAttribute(const_cast<SwTextRefMark*>(pTextRefMark));
1134 if (GetIDocumentUndoRedo().DoesUndo())
1135 {
1136 if (rTextNd.GetpSwpHints())
1137 rTextNd.GetpSwpHints()->DeRegister();
1138 }
1140}
1141
1142static bool lcl_SpellAndGrammarAgain( SwNode* pNd, void* pArgs )
1143{
1144 SwTextNode *pTextNode = pNd->GetTextNode();
1145 bool bOnlyWrong = *static_cast<sal_Bool*>(pArgs);
1146 if( pTextNode )
1147 {
1148 if( bOnlyWrong )
1149 {
1150 if( pTextNode->GetWrong() &&
1151 pTextNode->GetWrong()->InvalidateWrong() )
1153 if( pTextNode->GetGrammarCheck() &&
1154 pTextNode->GetGrammarCheck()->InvalidateWrong() )
1155 pTextNode->SetGrammarCheckDirty( true );
1156 }
1157 else
1158 {
1160 if( pTextNode->GetWrong() )
1161 pTextNode->GetWrong()->SetInvalid( 0, COMPLETE_STRING );
1162 pTextNode->SetGrammarCheckDirty( true );
1163 if( pTextNode->GetGrammarCheck() )
1164 pTextNode->GetGrammarCheck()->SetInvalid( 0, COMPLETE_STRING );
1165 }
1166 }
1167 return true;
1168}
1169
1170static bool lcl_CheckSmartTagsAgain( SwNode* pNd, void* )
1171{
1172 SwTextNode *pTextNode = pNd->GetTextNode();
1173 if( pTextNode )
1174 {
1175 pTextNode->SetSmartTagDirty( true );
1176 pTextNode->ClearSmartTags();
1177 }
1178 return true;
1179}
1180
1190void SwDoc::SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags )
1191{
1193 assert(getIDocumentLayoutAccess().GetCurrentLayout() && "SpellAgain: Where's my RootFrame?");
1194 if( bInvalid )
1195 {
1196 for ( auto aLayout : aAllLayouts )
1197 {
1198 aLayout->AllInvalidateSmartTagsOrSpelling(bSmartTags);
1199 aLayout->SetNeedGrammarCheck(true);
1200 }
1201 if ( bSmartTags )
1202 GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
1203 GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
1204 }
1205
1206 for ( auto aLayout : aAllLayouts )
1207 aLayout->SetIdleFlags();
1208}
1209
1211{
1213 if( !pTmpRoot )
1214 return;
1215
1217 for( auto aLayout : aAllLayouts )
1218 aLayout->AllInvalidateAutoCompleteWords();
1219 for( SwNodeOffset nNd(1), nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
1220 {
1221 SwTextNode* pTextNode = GetNodes()[ nNd ]->GetTextNode();
1222 if ( pTextNode ) pTextNode->SetAutoCompleteWordDirty( true );
1223 }
1224
1225 for( auto aLayout : aAllLayouts )
1226 aLayout->SetIdleFlags();
1227}
1228
1229const SwFormatINetFormat* SwDoc::FindINetAttr( std::u16string_view rName ) const
1230{
1231 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
1232 {
1233 auto pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem);
1234 if( !pFormatItem || pFormatItem->GetName() != rName )
1235 continue;
1236 const SwTextINetFormat* pTextAttr = pFormatItem->GetTextINetFormat();
1237 if( !pTextAttr )
1238 continue;
1239 const SwTextNode* pTextNd = pTextAttr->GetpTextNode();
1240 if( pTextNd && &pTextNd->GetNodes() == &GetNodes() )
1241 {
1242 return pFormatItem;
1243 }
1244 }
1245 return nullptr;
1246}
1247
1248void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
1249{
1250 const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
1251 if (rOutNds.empty())
1252 return;
1253
1254 ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
1255 SwNodeIndex aEndOfDoc( rExtDoc.GetNodes().GetEndOfContent(), -1 );
1256 for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
1257 {
1258 ::SetProgressState( static_cast<tools::Long>(i), GetDocShell() );
1259 const SwNodeOffset nIndex = rOutNds[ i ]->GetIndex();
1260
1261 const int nLvl = GetNodes()[ nIndex ]->GetTextNode()->GetAttrOutlineLevel()-1;
1262 if( nLvl > nLevel )
1263 continue;
1264 SwNodeOffset nEndOfs(1);
1265 sal_uInt8 nWish = nPara;
1266 SwNodeOffset nNextOutNd = i + 1 < rOutNds.size() ?
1267 rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
1268 bool bKeep = false;
1269 while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
1270 GetNodes()[ nIndex + nEndOfs ]->IsTextNode() )
1271 {
1272 SwTextNode* pTextNode = GetNodes()[ nIndex+nEndOfs ]->GetTextNode();
1273 if (pTextNode->GetText().getLength() && nWish)
1274 --nWish;
1275 bKeep = pTextNode->GetSwAttrSet().GetKeep().GetValue();
1276 ++nEndOfs;
1277 }
1278
1279 SwNodeRange aRange( *rOutNds[ i ], SwNodeOffset(0), *rOutNds[ i ], nEndOfs );
1280 GetNodes().Copy_( aRange, aEndOfDoc.GetNode() );
1281 }
1282 const SwTextFormatColls *pColl = rExtDoc.GetTextFormatColls();
1283 for( SwTextFormatColls::size_type i = 0; i < pColl->size(); ++i )
1284 (*pColl)[ i ]->ResetFormatAttr( RES_PAGEDESC, RES_BREAK );
1285 SwNodeIndex aIndx( rExtDoc.GetNodes().GetEndOfExtras() );
1286 ++aEndOfDoc;
1287 while( aIndx < aEndOfDoc )
1288 {
1289 bool bDelete = false;
1290 SwNode *pNode = &aIndx.GetNode();
1291 if( pNode->IsTextNode() )
1292 {
1293 SwTextNode *pNd = pNode->GetTextNode();
1294 if( pNd->HasSwAttrSet() )
1296 if( bImpress )
1297 {
1298 SwTextFormatColl* pMyColl = pNd->GetTextColl();
1299
1300 const sal_uInt16 nHeadLine = o3tl::narrowing<sal_uInt16>(
1304 pMyColl = rExtDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nHeadLine );
1305 pNd->ChgFormatColl( pMyColl );
1306 }
1307 if( !pNd->Len() &&
1309 {
1310 bDelete = true;
1311 rExtDoc.GetNodes().Delete( aIndx );
1312 }
1313 }
1314 if( !bDelete )
1315 ++aIndx;
1316 }
1318}
1319
1320namespace
1321{
1322void RemoveOrDeleteContents(SwTextNode* pTextNd, IDocumentContentOperations& xOperations)
1323{
1324 SwPaM aPam(*pTextNd, 0, *pTextNd, pTextNd->GetText().getLength());
1325
1326 // Remove hidden paragraph or delete contents:
1327 // Delete contents if
1328 // 1. removing the paragraph would result in an empty section or
1329 // 2. if the paragraph is the last paragraph in the section and
1330 // there is no paragraph in front of the paragraph:
1331 if ((SwNodeOffset(2) == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1332 || (SwNodeOffset(1) == pTextNd->EndOfSectionIndex() - pTextNd->GetIndex()
1333 && !pTextNd->GetNodes()[pTextNd->GetIndex() - 1]->GetTextNode()))
1334 {
1335 xOperations.DeleteRange(aPam);
1336 }
1337 else
1338 {
1339 aPam.DeleteMark();
1340 xOperations.DelFullPara(aPam);
1341 }
1342}
1343// Returns if the data was actually modified
1344bool HandleHidingField(SwFormatField& rFormatField, const SwNodes& rNodes,
1345 IDocumentContentOperations& xOperations)
1346{
1347 if( !rFormatField.GetTextField() )
1348 return false;
1349 SwTextNode* pTextNd = rFormatField.GetTextField()->GetpTextNode();
1350 if( pTextNd
1351 && pTextNd->GetpSwpHints() && pTextNd->IsHiddenByParaField()
1352 && &pTextNd->GetNodes() == &rNodes)
1353 {
1354 RemoveOrDeleteContents(pTextNd, xOperations);
1355 return true;
1356 }
1357 return false;
1358}
1359}
1360
1361// The greater the returned value, the more weight has this field type on deciding the final
1362// paragraph state
1364{
1365 switch (eFieldId)
1366 {
1368 return 20;
1371 ? 10
1372 : 0;
1373 default:
1374 return 0;
1375 }
1376}
1377
1378bool SwDoc::FieldHidesPara(const SwField& rField) const
1379{
1380 switch (rField.GetTyp()->Which())
1381 {
1383 return static_cast<const SwHiddenParaField&>(rField).IsHidden();
1386 && rField.ExpandField(true, nullptr).isEmpty();
1387 default:
1388 return false;
1389 }
1390}
1391
1393// Returns if the data was actually modified
1395{
1396 bool bRet = false;
1398
1399 {
1400 class FieldTypeGuard : public SwClient
1401 {
1402 public:
1403 explicit FieldTypeGuard(SwFieldType* pType)
1404 : SwClient(pType)
1405 {
1406 }
1407 const SwFieldType* get() const
1408 {
1409 return static_cast<const SwFieldType*>(GetRegisteredIn());
1410 }
1411 };
1412 // Removing some nodes for one SwFieldIds::Database type might remove the type from
1413 // document's field types, invalidating iterators. So, we need to create own list of
1414 // matching types prior to processing them.
1415 std::vector<std::unique_ptr<FieldTypeGuard>> aHidingFieldTypes;
1416 for (std::unique_ptr<SwFieldType> const & pType : *getIDocumentFieldsAccess().GetFieldTypes())
1417 {
1418 if (FieldCanHideParaWeight(pType->Which()))
1419 aHidingFieldTypes.push_back(std::make_unique<FieldTypeGuard>(pType.get()));
1420 }
1421 for (const auto& pTypeGuard : aHidingFieldTypes)
1422 {
1423 if (const SwFieldType* pType = pTypeGuard->get())
1424 {
1425 std::vector<SwFormatField*> vFields;
1426 pType->GatherFields(vFields);
1427 for(auto pFormatField: vFields)
1428 bRet |= HandleHidingField(*pFormatField, GetNodes(), getIDocumentContentOperations());
1429 }
1430 }
1431 }
1432
1433 // Remove any hidden paragraph (hidden text attribute)
1434 for( SwNodeOffset n = GetNodes().Count(); n; )
1435 {
1436 SwTextNode* pTextNd = GetNodes()[ --n ]->GetTextNode();
1437 if ( pTextNd )
1438 {
1439 bool bRemoved = false;
1440 if ( pTextNd->HasHiddenCharAttribute( true ) )
1441 {
1442 bRemoved = true;
1443 bRet = true;
1444
1445 if (SwNodeOffset(2) == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1446 {
1447 SwFrameFormat *const pFormat = pTextNd->StartOfSectionNode()->GetFlyFormat();
1448 if (nullptr != pFormat)
1449 {
1450 // remove hidden text frame
1452 }
1453 else
1454 {
1455 // default, remove hidden paragraph
1456 RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1457 }
1458 }
1459 else
1460 {
1461 // default, remove hidden paragraph
1462 RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1463 }
1464 }
1465 else if ( pTextNd->HasHiddenCharAttribute( false ) )
1466 {
1467 bRemoved = true;
1468 bRet = true;
1470 }
1471
1472 // Footnotes/Frames may have been removed, therefore we have
1473 // to reset n:
1474 if ( bRemoved )
1475 {
1476 // [n] has to be inside [0 .. GetNodes().Count()] range
1477 if (n > GetNodes().Count())
1478 n = GetNodes().Count();
1479 }
1480 }
1481 }
1482
1483 {
1484 // Delete/empty all hidden areas
1486 SwSectionFormats& rSectFormats = GetSections();
1487
1488 for( SwSectionFormats::size_type n = rSectFormats.size(); n; )
1489 {
1490 SwSectionFormat* pSectFormat = rSectFormats[ --n ];
1491 // don't add sections in Undo/Redo
1492 if( !pSectFormat->IsInNodesArr())
1493 continue;
1494 SwSection* pSect = pSectFormat->GetSection();
1495 if( pSect->CalcHiddenFlag() )
1496 {
1497 SwSection* pParent = pSect, *pTmp;
1498 while( nullptr != (pTmp = pParent->GetParent() ))
1499 {
1500 if( pTmp->IsHiddenFlag() )
1501 pSect = pTmp;
1502 pParent = pTmp;
1503 }
1504
1505 aSectFormats.insert( pSect->GetFormat() );
1506 }
1507 if( !pSect->GetCondition().isEmpty() )
1508 {
1509 SwSectionData aSectionData( *pSect );
1510 aSectionData.SetCondition( OUString() );
1511 aSectionData.SetHidden( false );
1512 UpdateSection( n, aSectionData );
1513 }
1514 }
1515
1516 auto n = aSectFormats.size();
1517
1518 if( 0 != n )
1519 {
1520 while( n )
1521 {
1522 SwSectionFormat* pSectFormat = aSectFormats[ --n ];
1523 SwSectionNode* pSectNd = pSectFormat->GetSectionNode();
1524 if( pSectNd )
1525 {
1526 bRet = true;
1527 SwPaM aPam( *pSectNd );
1528
1529 if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() ==
1530 pSectNd->GetIndex() - 1 &&
1531 pSectNd->StartOfSectionNode()->EndOfSectionIndex() ==
1532 pSectNd->EndOfSectionIndex() + 1 )
1533 {
1534 // only delete the content
1535 SwContentNode* pCNd = GetNodes().GoNext( aPam.GetPoint() );
1536 aPam.SetMark();
1537 aPam.GetPoint()->Assign( *pSectNd->EndOfSectionNode() );
1538 pCNd = SwNodes::GoPrevious( aPam.GetPoint() );
1539 assert(pCNd); // keep coverity happy
1540 aPam.GetPoint()->SetContent( pCNd->Len() );
1541
1543 }
1544 else
1545 {
1546 // delete the whole section
1547 aPam.SetMark();
1548 aPam.GetPoint()->Assign( *pSectNd->EndOfSectionNode() );
1550 }
1551
1552 }
1553 }
1554 }
1555 }
1556
1557 if( bRet )
1560 return bRet;
1561}
1562
1564{
1565 std::vector<SwFormatField*> vFields;
1567 if(vFields.size())
1568 return true;
1569
1570 // Search for any hidden paragraph (hidden text attribute)
1571 for( SwNodeOffset n = GetNodes().Count()-SwNodeOffset(1); n; --n)
1572 {
1573 SwTextNode* pTextNd = GetNodes()[ n ]->GetTextNode();
1574 if ( pTextNd &&
1575 ( pTextNd->HasHiddenCharAttribute( true ) || pTextNd->HasHiddenCharAttribute( false ) ) )
1576 return true;
1577 }
1578
1579 for(auto pSectFormat : GetSections())
1580 {
1581 // don't add sections in Undo/Redo
1582 if( !pSectFormat->IsInNodesArr())
1583 continue;
1584 SwSection* pSect = pSectFormat->GetSection();
1585 if( pSect->IsHidden() )
1586 return true;
1587 }
1588 return false;
1589}
1590
1592{
1593 SwUndoId nLastUndoId(SwUndoId::EMPTY);
1594 if (GetIDocumentUndoRedo().GetLastUndoInfo(nullptr, & nLastUndoId)
1595 && (SwUndoId::UI_DELETE_INVISIBLECNTNT == nLastUndoId))
1596 {
1597 GetIDocumentUndoRedo().Undo();
1598 GetIDocumentUndoRedo().ClearRedo();
1599 return true;
1600 }
1601 return false;
1602}
1603
1605{
1606 bool bRet = false;
1608 GetIDocumentUndoRedo().StartUndo( SwUndoId::UI_REPLACE, nullptr );
1609
1610 const SwFieldTypes* pMyFieldTypes = getIDocumentFieldsAccess().GetFieldTypes();
1611 const SwFieldTypes::size_type nCount = pMyFieldTypes->size();
1612 //go backward, field types are removed
1613 for(SwFieldTypes::size_type nType = nCount; nType > 0; --nType)
1614 {
1615 const SwFieldType *pCurType = (*pMyFieldTypes)[nType - 1].get();
1616
1617 if ( SwFieldIds::Postit == pCurType->Which() )
1618 continue;
1619
1620 std::vector<SwFormatField*> vFieldFormats;
1621 pCurType->GatherFields(vFieldFormats, false);
1622 for(const auto& rpFieldFormat : vFieldFormats)
1623 {
1624 const SwTextField *pTextField = rpFieldFormat->GetTextField();
1625 // skip fields that are currently not in the document
1626 // e.g. fields in undo or redo array
1627
1628 bool bSkip = !pTextField ||
1629 !pTextField->GetpTextNode()->GetNodes().IsDocNodes();
1630
1631 if (!bSkip)
1632 {
1633 bool bInHeaderFooter = IsInHeaderFooter(*pTextField->GetpTextNode());
1634 const SwFormatField& rFormatField = pTextField->GetFormatField();
1635 const SwField* pField = rFormatField.GetField();
1636
1637 //#i55595# some fields have to be excluded in headers/footers
1638 SwFieldIds nWhich = pField->GetTyp()->Which();
1639 if(!bInHeaderFooter ||
1640 (nWhich != SwFieldIds::PageNumber &&
1641 nWhich != SwFieldIds::Chapter &&
1642 nWhich != SwFieldIds::GetExp&&
1643 nWhich != SwFieldIds::SetExp&&
1644 nWhich != SwFieldIds::Input&&
1645 nWhich != SwFieldIds::RefPageGet&&
1646 nWhich != SwFieldIds::RefPageSet))
1647 {
1648 OUString sText = pField->ExpandField(true, &rLayout);
1649
1650 // database fields should not convert their command into text
1651 if( SwFieldIds::Database == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
1652 sText.clear();
1653
1654 SwPaM aInsertPam(*pTextField->GetpTextNode(), pTextField->GetStart());
1655 aInsertPam.SetMark();
1656
1657 // go to the end of the field
1658 const SwTextField *pFieldAtEnd = sw::DocumentFieldsManager::GetTextFieldAtPos(*aInsertPam.End());
1659 if (pFieldAtEnd && pFieldAtEnd->Which() == RES_TXTATR_INPUTFIELD)
1660 {
1661 SwPosition &rEndPos = *aInsertPam.GetPoint();
1662 rEndPos.SetContent( SwCursorShell::EndOfInputFieldAtPos( *aInsertPam.End() ) );
1663 }
1664 else
1665 {
1666 aInsertPam.Move();
1667 }
1668
1669 // first insert the text after field to keep the field's attributes,
1670 // then delete the field
1671 if (!sText.isEmpty())
1672 {
1673 // to keep the position after insert
1674 SwPaM aDelPam( *aInsertPam.GetMark(), *aInsertPam.GetPoint() );
1675 aDelPam.Move( fnMoveBackward );
1676 aInsertPam.DeleteMark();
1677
1678 getIDocumentContentOperations().InsertString( aInsertPam, sText );
1679
1680 aDelPam.Move();
1681 // finally remove the field
1683 }
1684 else
1685 {
1687 }
1688
1689 bRet = true;
1690 }
1691 }
1692 }
1693 }
1694
1695 if( bRet )
1697 GetIDocumentUndoRedo().EndUndo( SwUndoId::UI_REPLACE, nullptr );
1699 return bRet;
1700
1701}
1702
1704{
1705 return SW_MOD()->IsInsTableFormatNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1706}
1707
1709{
1710 return SW_MOD()->IsInsTableChangeNumFormat(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1711}
1712
1714{
1715 return SW_MOD()->IsInsTableAlignNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1716}
1717
1719{
1720 return SW_MOD()->IsSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1721}
1722
1724{
1725 SW_MOD()->SetSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE), value);
1726}
1727
1729void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable )
1730{
1731 if( bIsTable )
1732 {
1733 const SwTableNode* pTableNd = rPam.GetPoint()->GetNode().FindTableNode();
1734 if( pTableNd )
1735 {
1736 std::unique_ptr<SwUndoCpyTable> pUndo(new SwUndoCpyTable(*this));
1737 pUndo->SetTableSttIdx( pTableNd->GetIndex() );
1738 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1739 }
1740 }
1741 else if( rPam.HasMark() )
1742 {
1743 std::unique_ptr<SwUndoCpyDoc> pUndo(new SwUndoCpyDoc( rPam ));
1744 pUndo->SetInsertRange( rPam, false );
1745 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1746 }
1747}
1748
1749void SwDoc::ChangeTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
1750{
1751 assert(dynamic_cast<const SwTOXBaseSection*>(&rTOX));
1752 SwTOXBaseSection& rTOXSect(static_cast<SwTOXBaseSection&>(rTOX));
1753
1754 if (GetIDocumentUndoRedo().DoesUndo())
1755 {
1756 GetIDocumentUndoRedo().AppendUndo(
1757 std::make_unique<SwUndoTOXChange>(*this, rTOXSect, rNew));
1758 }
1759
1760 rTOX = rNew;
1761
1762 // note: do not Update the ToX here - the caller will do it, with a ViewShell!
1763}
1764
1765OUString SwDoc::GetPaMDescr(const SwPaM & rPam)
1766{
1767 if (&rPam.GetPointNode() == &rPam.GetMarkNode())
1768 {
1769 SwTextNode * pTextNode = rPam.GetPointNode().GetTextNode();
1770
1771 if (nullptr != pTextNode)
1772 {
1773 const sal_Int32 nStart = rPam.Start()->GetContentIndex();
1774 const sal_Int32 nEnd = rPam.End()->GetContentIndex();
1775
1776 return SwResId(STR_START_QUOTE)
1777 + ShortenString(pTextNode->GetText().copy(nStart, nEnd - nStart),
1779 SwResId(STR_LDOTS))
1780 + SwResId(STR_END_QUOTE);
1781 }
1782 }
1783 else
1784 {
1785 return SwResId(STR_PARAGRAPHS);
1786 }
1787
1788 return "??";
1789}
1790
1792{
1793 for( SwNodeOffset n = GetNodes().Count(); n; )
1794 {
1795 SwNode* pNd = GetNodes()[ --n ];
1796 if ( pNd->IsTextNode() && pNd->GetTextNode()->HasHiddenCharAttribute( false ) )
1797 return true;
1798 }
1799
1800 return false;
1801}
1802
1803std::shared_ptr<SwUnoCursor> SwDoc::CreateUnoCursor( const SwPosition& rPos, bool bTableCursor )
1804{
1805 std::shared_ptr<SwUnoCursor> pNew;
1806 if( bTableCursor )
1807 pNew = std::make_shared<SwUnoTableCursor>(rPos);
1808 else
1809 pNew = std::make_shared<SwUnoCursor>(rPos);
1810
1811 mvUnoCursorTable.push_back( pNew );
1812 return pNew;
1813}
1814
1816{
1818 {
1819 SwTextFormatColl *pColl = (*mpTextFormatCollTable)[n];
1820 if (RES_CONDTXTFMTCOLL == pColl->Which())
1821 pColl->CallSwClientNotify( SwAttrHint() );
1822 }
1823}
1824
1825uno::Reference< script::vba::XVBAEventProcessor > const &
1827{
1828 return mxVbaEvents;
1829}
1830
1832{
1833#if HAVE_FEATURE_SCRIPTING
1835 {
1836 try
1837 {
1838 uno::Reference< frame::XModel > xModel( mpDocShell->GetModel(), uno::UNO_SET_THROW );
1839 uno::Sequence< uno::Any > aArgs{ uno::Any(xModel) };
1840 mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW );
1841 }
1842 catch( uno::Exception& )
1843 {
1844 }
1845 }
1846#endif
1847}
1848
1849void SwDoc::SetMissingDictionaries( bool bIsMissing )
1850{
1851 if (!bIsMissing)
1852 meDictionaryMissing = MissingDictionary::False;
1853 else if (meDictionaryMissing == MissingDictionary::Undefined)
1854 meDictionaryMissing = MissingDictionary::True;
1855};
1856
1857void SwDoc::SetLanguage(const LanguageType eLang, const sal_uInt16 nId)
1858{
1859 mpAttrPool->SetPoolDefaultItem(SvxLanguageItem(eLang, nId));
1860}
1861
1862/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FieldId eFieldId
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, std::u16string_view aFillStr)
Shortens a string to a maximum length.
Definition: undobj.cxx:1540
const int nUndoStringLength
Definition: UndoCore.hxx:243
Give access to the data-provider for chart.
Text operation/manipulation interface.
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, SwTextAttr **ppNewTextAttr=nullptr)=0
Insert an attribute.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
Provides access to the formatting devices of a document.
Document fields related interfaces.
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
virtual const SwFieldTypes * GetFieldTypes() const =0
virtual void LockExpFields()=0
virtual void UnlockExpFields()=0
Provides access to the layout of a document.
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
Document links administration interface.
Provides numbered items of a document.
Provides access to the lists of a document.
Provides outline nodes of a document.
Provides access to settings of a document.
Get information about the current document state.
virtual void SetModified()=0
Must be called manually at changes of format.
Document statistics information.
Access to the style pool.
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
Handle the background jobs of a Writer document.
OUString getDate(const Date &rDate) const
const SwTextField * GetTextField() const
Definition: docfld.hxx:94
css::uno::Reference< css::frame::XModel3 > GetModel() const
bool hasValue(sal_Int32 nValue, const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
sal_Int32 size() const
static bool getRangesFromString(std::u16string_view i_rPageRange, std::vector< sal_Int32 > &o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset=-1, o3tl::sorted_vector< sal_Int32 > const *i_pPossibleValues=nullptr)
const LocaleDataWrapper & GetLocaleData() const
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
Knows all the text content controls in the document.
bool HasSwAttrSet() const
Definition: node.hxx:494
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:765
virtual sal_Int32 Len() const
Definition: node.cxx:1263
static sal_Int32 EndOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1015
bool IsInitialized() const
Definition: dbfld.hxx:95
void CommitLastRegistrations()
Accept not committed registrations.
Definition: dbmgr.cxx:3265
Definition: doc.hxx:195
const std::unique_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager
Definition: doc.hxx:218
oslInterlockedCount mReferenceCount
Definition: doc.hxx:308
::sw::DocumentLinksAdministrationManager const & GetDocumentLinksAdministrationManager() const
Definition: doc.cxx:278
SwSectionFormats & GetSections()
Definition: doc.hxx:1348
const std::unique_ptr< ::sw::DocumentFieldsManager > m_pDocumentFieldsManager
Definition: doc.hxx:233
const std::unique_ptr< ::sw::DocumentStateManager > m_pDocumentStateManager
Definition: doc.hxx:222
const std::unique_ptr< ::SwContentControlManager > m_pContentControlManager
Definition: doc.hxx:219
SwDocShell * mpDocShell
Definition: doc.hxx:267
MissingDictionary meDictionaryMissing
Definition: doc.hxx:333
::sw::DocumentDrawModelManager const & GetDocumentDrawModelManager() const
Definition: doc.cxx:173
const SwFormatINetFormat * FindINetAttr(std::u16string_view rName) const
Definition: doc.cxx:1229
bool FieldHidesPara(const SwField &rField) const
Definition: doc.cxx:1378
std::vector< std::weak_ptr< SwUnoCursor > > mvUnoCursorTable
Definition: doc.hxx:1662
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:402
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
Definition: doc.cxx:235
void SetMissingDictionaries(bool bIsMissing)
Use to notify if the dictionary can be found for a single content portion (has to be called for all p...
Definition: doc.cxx:1849
void SetSplitVerticalByDefault(bool value)
Definition: doc.cxx:1723
std::unique_ptr< SwTextFormatColls > mpTextFormatCollTable
Definition: doc.hxx:252
const std::unique_ptr< ::sw::UndoManager > m_pUndoManager
Definition: doc.hxx:223
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:246
void SetLanguage(const LanguageType eLang, const sal_uInt16 nId)
Definition: doc.cxx:1857
o3tl::sorted_vector< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1683
void DeleteFormatRefMark(const SwFormatRefMark *pFormatRefMark)
Definition: doc.cxx:1120
const std::unique_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager
Definition: doc.hxx:229
IDocumentExternalData const & getIDocumentExternalData() const
Definition: doc.cxx:445
const std::unique_ptr< ::sw::DocumentLayoutManager > m_pDocumentLayoutManager
Definition: doc.hxx:235
rtl::Reference< SwAttrPool > mpAttrPool
Definition: doc.hxx:203
bool ContainsHiddenChars() const
Checks if any of the text node contains hidden characters.
Definition: doc.cxx:1791
void AppendUndoForInsertFromDB(const SwPaM &rPam, bool bIsTable)
Set up the InsertDB as Undo table.
Definition: doc.cxx:1729
sal_Int32 getReferenceCount() const
Returns the current reference count.
Definition: doc.cxx:125
::sw::DocumentFieldsManager & GetDocumentFieldsManager()
Definition: doc.cxx:375
std::unique_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess
Definition: doc.hxx:226
void SpellItAgainSam(bool bInvalid, bool bOnlyWrong, bool bSmartTags)
Re-trigger spelling in the idle handler.
Definition: doc.cxx:1190
sal_uInt32 getRsid() const
Definition: doc.cxx:204
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
Definition: doc.cxx:1097
sal_uInt32 getRsidRoot() const
Definition: doc.cxx:224
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:268
SwDBData maDBData
Definition: doc.hxx:210
IDocumentListItems const & getIDocumentListItems() const
Definition: doc.cxx:289
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:323
static OUString GetPaMDescr(const SwPaM &rPaM)
Returns a textual description of a PaM.
Definition: doc.cxx:1765
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:152
SwNodes & GetNodes()
Definition: doc.hxx:418
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:365
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:343
css::uno::Reference< css::script::vba::XVBAEventProcessor > const & GetVbaEventProcessor()
Definition: doc.cxx:1826
sal_uInt32 mnRsid
Definition: doc.hxx:305
sal_uInt32 mnRsidRoot
Definition: doc.hxx:306
const std::unique_ptr< ::sw::DocumentDrawModelManager > m_pDocumentDrawModelManager
Definition: doc.hxx:220
IDocumentOutlineNodes const & getIDocumentOutlineNodes() const
Definition: doc.cxx:312
const std::unique_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager
Definition: doc.hxx:230
void setRsidRoot(sal_uInt32 nVal)
Definition: doc.cxx:229
void InvalidateAutoCompleteFlag()
Definition: doc.cxx:1210
static void UpdatePagesForPrintingWithPostItData(SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:766
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
bool RestoreInvisibleContent()
Definition: doc.cxx:1591
void ChangeTOX(SwTOXBase &rTOX, const SwTOXBase &rNew)
Definition: doc.cxx:1749
static void CalculateNonBlankPages(const SwRootFrame &rLayout, sal_uInt16 &nDocPageCount, sal_uInt16 &nActualPage)
Definition: doc.cxx:650
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
Definition: doc.cxx:353
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:184
const std::unique_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager
Definition: doc.hxx:228
void ChkCondColls()
Definition: doc.cxx:1815
const std::unique_ptr< ::sw::DocumentStatisticsManager > m_pDocumentStatisticsManager
Definition: doc.hxx:234
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:787
void SetVbaEventProcessor()
Definition: doc.cxx:1831
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:434
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
Definition: doc.cxx:333
void UpdateSection(size_t const nSect, SwSectionData &, SfxItemSet const *const =nullptr, bool const bPreventLinkUpdate=false)
Definition: ndsect.cxx:600
css::uno::Reference< css::script::vba::XVBAEventProcessor > mxVbaEvents
Definition: doc.hxx:292
bool IsSplitVerticalByDefault() const
Definition: doc.cxx:1718
int FieldCanHideParaWeight(SwFieldIds eFieldId) const
Definition: doc.cxx:1363
bool ConvertFieldsToText(SwRootFrame const &rLayout)
Definition: doc.cxx:1604
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
Definition: doc.cxx:1053
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1803
bool RemoveInvisibleContent()
Remove the invisible content from the document e.g. hidden areas, hidden paragraphs.
Definition: doc.cxx:1394
const std::unique_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager
Definition: doc.hxx:225
bool IsInsTableFormatNum() const
Definition: doc.cxx:1703
const std::unique_ptr< ::sw::DocumentExternalDataManager > m_pDocumentExternalDataManager
Definition: doc.hxx:237
sal_Int32 acquire()
Acquire a reference to an instance.
Definition: doc.cxx:110
void setRsid(sal_uInt32 nVal)
Definition: doc.cxx:209
static void CalculatePagesForPrinting(const SwRootFrame &rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, bool bIsPDFExport, sal_Int32 nDocPageCount)
get the set of printable pages for the XRenderable API by evaluating the respective settings (see imp...
Definition: doc.cxx:672
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1329
const std::unique_ptr< ::sw::DocumentRedlineManager > m_pDocumentRedlineManager
Definition: doc.hxx:221
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:163
sal_Int32 release()
Releases a reference to an instance.
Definition: doc.cxx:116
void ChgDBData(const SwDBData &rNewData)
Definition: doc.cxx:461
::sw::DocumentLayoutManager const & GetDocumentLayoutManager() const
Definition: doc.cxx:423
void Summary(SwDoc &rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
Definition: doc.cxx:1248
const std::unique_ptr< ::sw::DocumentStylePoolManager > m_pDocumentStylePoolManager
Definition: doc.hxx:236
const std::unique_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager
Definition: doc.hxx:224
::sw::DocumentStatisticsManager const & GetDocumentStatisticsManager() const
Definition: doc.cxx:391
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:194
::sw::MetaFieldManager & GetMetaFieldManager()
Definition: doc.cxx:131
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:257
SwDocShell * GetDocShell()
Definition: doc.hxx:1362
const std::unique_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager
Definition: doc.hxx:231
::sw::UndoManager & GetUndoManager()
Definition: doc.cxx:141
const std::unique_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager
Definition: doc.hxx:232
bool IsInsTableAlignNum() const
Definition: doc.cxx:1713
const std::unique_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager
Definition: doc.hxx:227
SwDBManager * m_pDBManager
Definition: doc.hxx:259
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:381
::SwContentControlManager & GetContentControlManager()
Definition: doc.cxx:136
static void CalculatePagePairsForProspectPrinting(const SwRootFrame &rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:905
bool IsInsTableChangeNumFormat() const
Definition: doc.cxx:1708
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:301
bool IsInHeaderFooter(const SwNode &) const
Definition: doclay.cxx:1566
bool HasInvisibleContent() const
Definition: doc.cxx:1563
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:243
virtual void UpdateFields()
Definition: fldbas.cxx:213
SwFieldIds Which() const
Definition: fldbas.hxx:274
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
Definition: fldbas.cxx:203
Base class of all fields.
Definition: fldbas.hxx:293
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:484
SwFieldType * GetTyp() const
Definition: fldbas.hxx:399
const SwField * GetField() const
Definition: fmtfld.hxx:130
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:148
const SwTextRefMark * GetTextRefMark() const
Definition: fmtrfmrk.hxx:61
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:385
const SwRect & getFrameArea() const
Definition: frame.hxx:179
Style of a layout element.
Definition: frmfmt.hxx:62
bool OnRightPage() const
Definition: frame.hxx:733
SwFrame * GetNext()
Definition: frame.hxx:676
const SwFrame * Lower() const
Definition: layfrm.hxx:101
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:136
Base class of the Writer document model elements.
Definition: node.hxx:98
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:739
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:744
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:724
bool IsTextNode() const
Definition: node.hxx:687
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:733
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:143
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:240
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:165
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2543
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
Definition: nodes.cxx:1070
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1333
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1299
void Copy_(const SwNodeRange &rRg, SwNode &rInsPos, bool bNewFrames=true) const
Definition: ndarr.hxx:179
SwNodeOffset Count() const
Definition: ndarr.hxx:142
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
SwNode & GetPointNode() const
Definition: pam.hxx:283
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:668
const SwPosition * End() const
Definition: pam.hxx:271
void DeleteMark()
Definition: pam.hxx:231
SwNode & GetMarkNode() const
Definition: pam.hxx:284
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
A page of the document layout.
Definition: pagefrm.hxx:58
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
bool GetResolved() const
Definition: docufld.cxx:1791
virtual OUString GetPar1() const override
Author.
Definition: docufld.cxx:1815
Date GetDate() const
Definition: docufld.hxx:485
virtual OUString GetPar2() const override
Text.
Definition: docufld.cxx:1827
bool IsPrintLeftPages() const
Definition: printdata.cxx:370
bool IsPrintRightPages() const
Definition: printdata.cxx:384
bool IsPrintEmptyPages(bool bIsPDFExport) const
Definition: printdata.cxx:395
void Height(tools::Long nNew)
Definition: swrect.hxx:193
A class that stores temporary data that is needed for rendering the document.
Definition: printdata.hxx:204
PagePairsVec_t & GetPagePairsForProspectPrinting()
used for prospect printing only
Definition: printdata.hxx:280
bool HasPostItData() const
Definition: printdata.hxx:244
std::unique_ptr< SetGetExpFields > m_pPostItFields
an array of "SetGetExpField *" sorted by page and line numbers
Definition: printdata.hxx:236
void SetPageRange(const OUString &rRange)
Definition: printdata.hxx:284
std::map< sal_Int32, sal_Int32 > & GetPrinterPaperTrays()
a map for printer paper tray numbers to use for each document page a value of -1 for the tray means t...
Definition: printdata.hxx:270
std::unique_ptr< SwViewShell > m_pPostItShell
this contains a SwDoc with the post-it content
Definition: printdata.hxx:238
o3tl::sorted_vector< sal_Int32 > & GetValidPagesSet()
Definition: printdata.hxx:265
std::vector< sal_Int32 > & GetPagesToPrint()
used for 'normal' printing A page value of 0 as entry indicates that this page is not from the docume...
Definition: printdata.hxx:276
const OUString & GetPageRange() const
Definition: printdata.hxx:283
The root element of a Writer document layout.
Definition: rootfrm.hxx:83
void ResetIdleFormat()
Definition: rootfrm.hxx:261
static void DeleteHiddenRanges(SwTextNode &rNode)
Hidden text attribute handling.
Definition: porlay.cxx:2034
void SetHidden(bool const bFlag)
Definition: section.hxx:99
void SetCondition(OUString const &rNew)
Definition: section.hxx:115
SwSection * GetSection() const
Definition: section.cxx:646
SwSectionNode * GetSectionNode()
Definition: section.cxx:931
bool IsInNodesArr() const
Definition: section.cxx:893
Array of Undo-history.
Definition: docary.hxx:192
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
OUString const & GetCondition() const
Definition: section.hxx:201
bool IsHidden() const
Definition: section.hxx:181
SwSection * GetParent() const
Definition: section.hxx:349
SwSectionFormat * GetFormat()
Definition: section.hxx:339
bool CalcHiddenFlag() const
Definition: section.cxx:323
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
sal_uInt16 Which() const
Definition: txatbase.hxx:116
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:199
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:122
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
const SwTextNode * GetpTextNode() const
Definition: txtinet.hxx:45
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
void SetWrongDirty(sw::WrongState eNew) const
Definition: txtedt.cxx:2299
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:291
void ClearSmartTags()
Definition: txtedt.cxx:2269
void DeleteAttribute(SwTextAttr *const pTextAttr)
delete the attribute pTextAttr
Definition: thints.cxx:1763
bool IsHiddenByParaField() const
is the paragraph visible?
Definition: ndtxt.hxx:765
SwWrongList * GetWrong()
Definition: txtedt.cxx:2225
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2314
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2324
virtual SwFormatColl * ChgFormatColl(SwFormatColl *) override
Definition: ndtxt.cxx:4052
void SetAutoCompleteWordDirty(bool bNew) const
Definition: txtedt.cxx:2334
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2251
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:250
const OUString & GetText() const
Definition: ndtxt.hxx:242
bool HasHiddenCharAttribute(bool bWholePara) const
Hidden Paragraph Field:
Definition: ndtxt.hxx:770
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:891
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: ndtxt.cxx:5271
const SwTextNode & GetTextNode() const
Definition: txtrfmrk.hxx:47
SwHistory & GetHistory()
std::vector< SwTextFormatColl * >::size_type size_type
Definition: docary.hxx:66
size_t size() const
Definition: docary.hxx:87
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2654
bool InvalidateWrong()
Definition: wrong.cxx:434
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:254
void DeRegister()
deregister the currently registered History
Definition: ndhints.hxx:197
void Register(SwRegHistory *pHist)
register a History, which receives all attribute changes (for Undo)
Definition: ndhints.hxx:195
bool empty() const
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
static SwTextField * GetTextFieldAtPos(const SwPosition &rPos)
Returns the field at a certain position.
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
knows all meta-fields in the document.
Definition: fmtmeta.hxx:195
Stores the undo/redo information, implementing the IDocumentUndoRedo interface.
Definition: UndoManager.hxx:44
OUString getStringValue(const OUString &i_rPropertyName) const
sal_Int64 getIntValue(const OUString &i_rPropertyName, sal_Int64 i_nDefault) const
Any value
int nCount
static sal_Int32 lcl_GetPaperBin(const SwPageFrame *pStartFrame)
provide the paper tray to use according to the page style in use, but do that only if the respective ...
Definition: doc.cxx:594
bool sw_GetPostIts(const IDocumentFieldsAccess &rIDFA, SetGetExpFields *pSrtLst)
Definition: doc.cxx:523
static bool lcl_CheckSmartTagsAgain(SwNode *pNd, void *)
Definition: doc.cxx:1170
static void lcl_FormatPostIt(IDocumentContentOperations *pIDCO, SwPaM &aPam, const SwPostItField *pField, bool bNewPage, bool bIsFirstPostIt, sal_uInt16 nPageNo, sal_uInt16 nLineNo)
Definition: doc.cxx:541
static bool lcl_SpellAndGrammarAgain(SwNode *pNd, void *pArgs)
Definition: doc.cxx:1142
float x
constexpr OUStringLiteral IsHidden(u"IsHidden")
SwFieldIds
Definition: fldbas.hxx:45
@ Database
For old documents the Field-Which IDs must be preserved !!!
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(160)
constexpr TypedWhichId< SvxPaperBinItem > RES_PAPER_BIN(90)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
sal_Int32 nIndex
sal_Int64 n
sal_uInt16 nPos
void StartProgress(TranslateId pMessResId, tools::Long nStartValue, tools::Long nEndValue, SwDocShell *pDocShell)
Definition: mainwn.cxx:52
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:92
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:82
aStr
unsigned int uniform_uint_distribution(unsigned int a, unsigned int b)
int i
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
bool isAlienWordDoc(SfxObjectShell const &rDocShell)
css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs(SfxObjectShell const *pShell, const char *_pAsciiName, const css::uno::Sequence< css::uno::Any > &aArgs)
Count
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
long Long
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
sal_Int16 nId
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1159
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
@ RES_POOLCOLL_HEADLINE2
Heading 2.
Definition: poolfmt.hxx:263
@ RES_POOLCOLL_HEADLINE1
Heading 1.
Definition: poolfmt.hxx:262
SfxItemState
SwPostItMode
this must match the definitions in css::text::NotePrintMode
Definition: printdata.hxx:43
QPRO_FUNC_TYPE nType
OUString aPostItLine
Definition: shellres.hxx:32
OUString aPostItAuthor
Definition: shellres.hxx:30
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:266
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
Reference< XModel > xModel
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
#define SW_MOD()
Definition: swmodule.hxx:256
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:57
SwUndoId
Definition: swundo.hxx:30
@ UI_DELETE_INVISIBLECNTNT
unsigned char sal_uInt8
unsigned char sal_Bool
sal_uInt16 sal_Unicode