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