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