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_uInt16& 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_uInt16& 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_uInt16>(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_uInt16 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, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
809 bool bIsFirstPostIt = true;
810 for (SetGetExpFields::size_type i = 0; i < nPostItCount; ++i)
811 {
812 PostItField_& rPostIt = static_cast<PostItField_&>(*(*rData.m_pPostItFields)[ i ]);
813 nLastPageNum = nPhyPageNum;
814 nPhyPageNum = rPostIt.GetPageNo(
815 aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
816 if (nPhyPageNum)
817 {
818 // need to insert a page break?
819 // In SwPostItMode::EndPage mode for each document page the following
820 // post-it page needs to start on a new page
821 const bool bNewPage = nPostItMode == SwPostItMode::EndPage &&
822 !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
823
824 lcl_FormatPostIt( &rData.m_pPostItShell->GetDoc()->getIDocumentContentOperations(), aPam,
825 rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
826 bIsFirstPostIt = false;
827
828 if (nPostItMode == SwPostItMode::EndPage)
829 {
830 // get the correct number of current pages for the post-it document
831 rData.m_pPostItShell->CalcLayout();
832 const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount();
833 aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
834 }
835 }
836 }
837
838 // format post-it doc to get correct number of pages
839 rData.m_pPostItShell->CalcLayout();
840
841 SwRootFrame* pPostItRoot = rData.m_pPostItShell->GetLayout();
842 //tdf#103313 print dialog maxes out cpu as Idles never get to
843 //complete this postitshell's desire to complete formatting
844 pPostItRoot->ResetIdleFormat();
845
846 const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount();
847
848 if (nPostItMode == SwPostItMode::Only || nPostItMode == SwPostItMode::EndDoc)
849 {
850 // now add those post-it pages to the vector of pages to print
851 // or replace them if only post-its should be printed
852
853 if (nPostItMode == SwPostItMode::Only)
854 {
855 // no document page to be printed
856 rData.GetPagesToPrint().clear();
857 }
858
859 // now we just need to add the post-it pages to be printed to the
860 // end of the vector of pages to print
861 sal_Int32 nPageNum = 0;
862 const SwPageFrame * pPageFrame = static_cast<SwPageFrame*>(pPostItRoot->Lower());
863 while( pPageFrame && nPageNum < nPostItDocPageCount )
864 {
865 ++nPageNum;
866 // negative page number indicates page is from the post-it doc
867 rData.GetPagesToPrint().push_back( -nPageNum );
868 pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
869 }
870 OSL_ENSURE( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
871 }
872 else if (nPostItMode == SwPostItMode::EndPage)
873 {
874 // the next step is to find all the pages from the post-it
875 // document that should be printed for a given physical page
876 // of the document
877
878 std::vector< sal_Int32 > aTmpPagesToPrint;
879 sal_Int32 nLastPostItPage(0);
880 const size_t nNum = rData.GetPagesToPrint().size();
881 for (size_t i = 0 ; i < nNum; ++i)
882 {
883 // add the physical page to print from the document
884 const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
885 aTmpPagesToPrint.push_back( nPhysPage );
886
887 // add the post-it document pages to print, i.e those
888 // post-it pages that have the data for the above physical page
889 std::map<sal_Int32, sal_Int32>::const_iterator const iter(
890 aPostItLastStartPageNum.find(nPhysPage));
891 if (iter != aPostItLastStartPageNum.end())
892 {
893 for (sal_Int32 j = nLastPostItPage + 1;
894 j <= iter->second; ++j)
895 {
896 // negative page number indicates page is from the
897 aTmpPagesToPrint.push_back(-j); // post-it document
898 }
899 nLastPostItPage = iter->second;
900 }
901 }
902
903 // finally we need to assign those vectors to the resulting ones.
904 // swapping the data should be more efficient than assigning since
905 // we won't need the temporary vectors anymore
906 rData.GetPagesToPrint().swap( aTmpPagesToPrint );
907 }
908
909}
910
912 const SwRootFrame& rLayout,
913 /* out */ SwRenderData &rData,
914 const SwPrintUIOptions &rOptions,
915 sal_Int32 nDocPageCount )
916{
917 std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
918 o3tl::sorted_vector< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
919 std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
920 std::map< sal_Int32, const SwPageFrame * > validStartFrames;
921
922 rPagePairs.clear();
923 rValidPagesSet.clear();
924
925 OUString aPageRange;
926 // PageContent :
927 // 0 -> print all pages (default if aPageRange is empty)
928 // 1 -> print range according to PageRange
929 // 2 -> print selection
930 const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
931 if (nContent == 1)
932 aPageRange = rOptions.getStringValue( "PageRange" );
933 if (aPageRange.isEmpty()) // empty string -> print all
934 {
935 // set page range to print to 'all pages'
936 aPageRange = OUString::number( 1 ) + "-" + OUString::number( nDocPageCount );
937 }
938 StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
939
940 if ( aRange.size() <= 0)
941 return;
942
943 const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
944 for ( sal_Int32 i = 1; pStPage && i < nDocPageCount; ++i )
945 pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
946 if ( !pStPage ) // Then it was that
947 return;
948
949 // currently for prospect printing all pages are valid to be printed
950 // thus we add them all to the respective map and set for later use
951 sal_Int32 nPageNum = 0;
952 const SwPageFrame *pPageFrame = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
953 while( pPageFrame && nPageNum < nDocPageCount )
954 {
955 ++nPageNum;
956 rValidPagesSet.insert( nPageNum );
957 validStartFrames[ nPageNum ] = pPageFrame;
958 pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
959
960 rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
961 }
962 OSL_ENSURE( nPageNum == nDocPageCount, "unexpected number of pages" );
963
964 // properties to take into account when calculating the set of pages
965 // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
966 // of the prospect!
967 bool bPrintLeftPages = rOptions.IsPrintLeftPages();
968 bool bPrintRightPages = rOptions.IsPrintRightPages();
969 bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) != 0;
970
971 // get pages for prospect printing according to the 'PageRange'
972 // (duplicates and any order allowed!)
973 std::vector< sal_Int32 > aPagesToPrint;
975 aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
976
977 if (aPagesToPrint.empty())
978 return;
979
980 // now fill the vector for calculating the page pairs with the start frames
981 // from the above obtained vector
982 std::vector< const SwPageFrame * > aVec;
983 for (sal_Int32 nPage : aPagesToPrint)
984 {
985 const SwPageFrame *pFrame = validStartFrames[ nPage ];
986 aVec.push_back( pFrame );
987 }
988
989 // just one page is special ...
990 if ( 1 == aVec.size() )
991 aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page
992 else
993 {
994 // now extend the number of pages to fit a multiple of 4
995 // (4 'normal' pages are needed for a single prospect paper
996 // with back and front)
997 while( aVec.size() & 3 )
998 aVec.push_back( nullptr );
999 }
1000
1001 // make sure that all pages are in correct order
1002 std::vector< const SwPageFrame * >::size_type nSPg = 0;
1003 std::vector< const SwPageFrame * >::size_type nEPg = aVec.size();
1004 sal_Int32 nStep = 1;
1005 if ( 0 == (nEPg & 1 )) // there are no uneven ones!
1006 --nEPg;
1007
1008 if ( !bPrintLeftPages )
1009 ++nStep;
1010 else if ( !bPrintRightPages )
1011 {
1012 ++nStep;
1013 ++nSPg;
1014 --nEPg;
1015 }
1016
1017 // the number of 'virtual' pages to be printed
1018 sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
1019
1020 for ( sal_Int32 nPrintCount = 0; nSPg < nEPg &&
1021 nPrintCount < nCntPage; ++nPrintCount )
1022 {
1023 pStPage = aVec[ nSPg ];
1024 const SwPageFrame* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : nullptr;
1025
1026 short nRtlOfs = bPrintProspectRTL ? 1 : 0;
1027 if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
1028 {
1029 const SwPageFrame* pTmp = pStPage;
1030 pStPage = pNxtPage;
1031 pNxtPage = pTmp;
1032 }
1033
1034 sal_Int32 nFirst = -1, nSecond = -1;
1035 for ( int nC = 0; nC < 2; ++nC )
1036 {
1037 sal_Int32 nPage = -1;
1038 if ( pStPage )
1039 nPage = pStPage->GetPhyPageNum();
1040 if (nC == 0)
1041 nFirst = nPage;
1042 else
1043 nSecond = nPage;
1044
1045 pStPage = pNxtPage;
1046 }
1047 rPagePairs.emplace_back(nFirst, nSecond );
1048
1049 nSPg = nSPg + nStep;
1050 nEPg = nEPg - nStep;
1051 }
1052 OSL_ENSURE( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
1053
1054 // luckily prospect printing does not make use of post-its so far,
1055 // thus we are done here.
1056}
1057
1059const SwFormatRefMark* SwDoc::GetRefMark( std::u16string_view rName ) const
1060{
1061 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1062 {
1063 auto pFormatRef = dynamic_cast<const SwFormatRefMark*>(pItem);
1064 if(!pFormatRef)
1065 continue;
1066
1067 const SwTextRefMark* pTextRef = pFormatRef->GetTextRefMark();
1068 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() &&
1069 rName == pFormatRef->GetRefName() )
1070 return pFormatRef;
1071 }
1072 return nullptr;
1073}
1074
1076const SwFormatRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const
1077{
1078 const SwFormatRefMark* pRet = nullptr;
1079
1080 sal_uInt32 nCount = 0;
1081 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1082 {
1083 auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1084 if( !pRefMark )
1085 continue;
1086 const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark();
1087 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1088 {
1089 if(nCount == nIndex)
1090 {
1091 pRet = pRefMark;
1092 break;
1093 }
1094 nCount++;
1095 }
1096 }
1097 return pRet;
1098}
1099
1101//JP 24.06.96: If the array pointer is 0, then just return whether a RefMark is set in the Doc
1102// OS 25.06.96: From now on we always return the reference count
1103sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const
1104{
1105 sal_uInt16 nCount = 0;
1106 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1107 {
1108 auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1109 if( !pRefMark )
1110 continue;
1111 const SwTextRefMark* pTextRef = pRefMark->GetTextRefMark();
1112 if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1113 {
1114 if( pNames )
1115 {
1116 OUString aTmp(pRefMark->GetRefName());
1117 pNames->insert(pNames->begin() + nCount, aTmp);
1118 }
1119 ++nCount;
1120 }
1121 }
1122
1123 return nCount;
1124}
1125
1127{
1128 const SwTextRefMark* pTextRefMark = pFormatRefMark->GetTextRefMark();
1129 SwTextNode& rTextNd = const_cast<SwTextNode&>(pTextRefMark->GetTextNode());
1130 std::unique_ptr<SwRegHistory> aRegHistory;
1131 if (GetIDocumentUndoRedo().DoesUndo())
1132 {
1133 SwUndoResetAttr* pUndo = new SwUndoResetAttr(SwPosition(rTextNd, pTextRefMark->GetStart()),
1135 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
1136 aRegHistory.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory()));
1137 rTextNd.GetpSwpHints()->Register(aRegHistory.get());
1138 }
1139 rTextNd.DeleteAttribute(const_cast<SwTextRefMark*>(pTextRefMark));
1140 if (GetIDocumentUndoRedo().DoesUndo())
1141 {
1142 if (rTextNd.GetpSwpHints())
1143 rTextNd.GetpSwpHints()->DeRegister();
1144 }
1146}
1147
1148static bool lcl_SpellAndGrammarAgain( SwNode* pNd, void* pArgs )
1149{
1150 SwTextNode *pTextNode = pNd->GetTextNode();
1151 bool bOnlyWrong = *static_cast<sal_Bool*>(pArgs);
1152 if( pTextNode )
1153 {
1154 if( bOnlyWrong )
1155 {
1156 if( pTextNode->GetWrong() &&
1157 pTextNode->GetWrong()->InvalidateWrong() )
1159 if( pTextNode->GetGrammarCheck() &&
1160 pTextNode->GetGrammarCheck()->InvalidateWrong() )
1161 pTextNode->SetGrammarCheckDirty( true );
1162 }
1163 else
1164 {
1166 if( pTextNode->GetWrong() )
1167 pTextNode->GetWrong()->SetInvalid( 0, COMPLETE_STRING );
1168 pTextNode->SetGrammarCheckDirty( true );
1169 if( pTextNode->GetGrammarCheck() )
1170 pTextNode->GetGrammarCheck()->SetInvalid( 0, COMPLETE_STRING );
1171 }
1172 }
1173 return true;
1174}
1175
1176static bool lcl_CheckSmartTagsAgain( SwNode* pNd, void* )
1177{
1178 SwTextNode *pTextNode = pNd->GetTextNode();
1179 if( pTextNode )
1180 {
1181 pTextNode->SetSmartTagDirty( true );
1182 pTextNode->ClearSmartTags();
1183 }
1184 return true;
1185}
1186
1196void SwDoc::SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags )
1197{
1199 assert(getIDocumentLayoutAccess().GetCurrentLayout() && "SpellAgain: Where's my RootFrame?");
1200 if( bInvalid )
1201 {
1202 for ( auto aLayout : aAllLayouts )
1203 {
1204 aLayout->AllInvalidateSmartTagsOrSpelling(bSmartTags);
1205 aLayout->SetNeedGrammarCheck(true);
1206 }
1207 if ( bSmartTags )
1208 GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
1209 GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
1210 }
1211
1212 for ( auto aLayout : aAllLayouts )
1213 aLayout->SetIdleFlags();
1214}
1215
1217{
1219 if( !pTmpRoot )
1220 return;
1221
1223 for( auto aLayout : aAllLayouts )
1224 aLayout->AllInvalidateAutoCompleteWords();
1225 for( SwNodeOffset nNd(1), nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
1226 {
1227 SwTextNode* pTextNode = GetNodes()[ nNd ]->GetTextNode();
1228 if ( pTextNode ) pTextNode->SetAutoCompleteWordDirty( true );
1229 }
1230
1231 for( auto aLayout : aAllLayouts )
1232 aLayout->SetIdleFlags();
1233}
1234
1235const SwFormatINetFormat* SwDoc::FindINetAttr( std::u16string_view rName ) const
1236{
1237 for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
1238 {
1239 auto pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem);
1240 if( !pFormatItem || pFormatItem->GetName() != rName )
1241 continue;
1242 const SwTextINetFormat* pTextAttr = pFormatItem->GetTextINetFormat();
1243 if( !pTextAttr )
1244 continue;
1245 const SwTextNode* pTextNd = pTextAttr->GetpTextNode();
1246 if( pTextNd && &pTextNd->GetNodes() == &GetNodes() )
1247 {
1248 return pFormatItem;
1249 }
1250 }
1251 return nullptr;
1252}
1253
1254void SwDoc::Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
1255{
1256 const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
1257 if (rOutNds.empty())
1258 return;
1259
1260 ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
1261 SwNodeIndex aEndOfDoc( rExtDoc.GetNodes().GetEndOfContent(), -1 );
1262 for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
1263 {
1264 ::SetProgressState( static_cast<tools::Long>(i), GetDocShell() );
1265 const SwNodeOffset nIndex = rOutNds[ i ]->GetIndex();
1266
1267 const int nLvl = GetNodes()[ nIndex ]->GetTextNode()->GetAttrOutlineLevel()-1;
1268 if( nLvl > nLevel )
1269 continue;
1270 SwNodeOffset nEndOfs(1);
1271 sal_uInt8 nWish = nPara;
1272 SwNodeOffset nNextOutNd = i + 1 < rOutNds.size() ?
1273 rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
1274 bool bKeep = false;
1275 while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
1276 GetNodes()[ nIndex + nEndOfs ]->IsTextNode() )
1277 {
1278 SwTextNode* pTextNode = GetNodes()[ nIndex+nEndOfs ]->GetTextNode();
1279 if (pTextNode->GetText().getLength() && nWish)
1280 --nWish;
1281 bKeep = pTextNode->GetSwAttrSet().GetKeep().GetValue();
1282 ++nEndOfs;
1283 }
1284
1285 SwNodeRange aRange( *rOutNds[ i ], SwNodeOffset(0), *rOutNds[ i ], nEndOfs );
1286 GetNodes().Copy_( aRange, aEndOfDoc.GetNode() );
1287 }
1288 const SwTextFormatColls *pColl = rExtDoc.GetTextFormatColls();
1289 for( SwTextFormatColls::size_type i = 0; i < pColl->size(); ++i )
1290 (*pColl)[ i ]->ResetFormatAttr( RES_PAGEDESC, RES_BREAK );
1291 SwNodeIndex aIndx( rExtDoc.GetNodes().GetEndOfExtras() );
1292 ++aEndOfDoc;
1293 while( aIndx < aEndOfDoc )
1294 {
1295 bool bDelete = false;
1296 SwNode *pNode = &aIndx.GetNode();
1297 if( pNode->IsTextNode() )
1298 {
1299 SwTextNode *pNd = pNode->GetTextNode();
1300 if( pNd->HasSwAttrSet() )
1302 if( bImpress )
1303 {
1304 SwTextFormatColl* pMyColl = pNd->GetTextColl();
1305
1306 const sal_uInt16 nHeadLine = o3tl::narrowing<sal_uInt16>(
1310 pMyColl = rExtDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nHeadLine );
1311 pNd->ChgFormatColl( pMyColl );
1312 }
1313 if( !pNd->Len() &&
1315 {
1316 bDelete = true;
1317 rExtDoc.GetNodes().Delete( aIndx );
1318 }
1319 }
1320 if( !bDelete )
1321 ++aIndx;
1322 }
1324}
1325
1326namespace
1327{
1328void RemoveOrDeleteContents(SwTextNode* pTextNd, IDocumentContentOperations& xOperations)
1329{
1330 SwPaM aPam(*pTextNd, 0, *pTextNd, pTextNd->GetText().getLength());
1331
1332 // Remove hidden paragraph or delete contents:
1333 // Delete contents if
1334 // 1. removing the paragraph would result in an empty section or
1335 // 2. if the paragraph is the last paragraph in the section and
1336 // there is no paragraph in front of the paragraph:
1337 if ((SwNodeOffset(2) == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1338 || (SwNodeOffset(1) == pTextNd->EndOfSectionIndex() - pTextNd->GetIndex()
1339 && !pTextNd->GetNodes()[pTextNd->GetIndex() - 1]->GetTextNode()))
1340 {
1341 xOperations.DeleteRange(aPam);
1342 }
1343 else
1344 {
1345 aPam.DeleteMark();
1346 xOperations.DelFullPara(aPam);
1347 }
1348}
1349// Returns if the data was actually modified
1350bool HandleHidingField(SwFormatField& rFormatField, const SwNodes& rNodes,
1351 IDocumentContentOperations& xOperations)
1352{
1353 if( !rFormatField.GetTextField() )
1354 return false;
1355 SwTextNode* pTextNd = rFormatField.GetTextField()->GetpTextNode();
1356 if( pTextNd
1357 && pTextNd->GetpSwpHints() && pTextNd->IsHiddenByParaField()
1358 && &pTextNd->GetNodes() == &rNodes)
1359 {
1360 RemoveOrDeleteContents(pTextNd, xOperations);
1361 return true;
1362 }
1363 return false;
1364}
1365}
1366
1367// The greater the returned value, the more weight has this field type on deciding the final
1368// paragraph state
1370{
1371 switch (eFieldId)
1372 {
1374 return 20;
1377 ? 10
1378 : 0;
1379 default:
1380 return 0;
1381 }
1382}
1383
1384bool SwDoc::FieldHidesPara(const SwField& rField) const
1385{
1386 switch (rField.GetTyp()->Which())
1387 {
1389 return static_cast<const SwHiddenParaField&>(rField).IsHidden();
1392 && rField.ExpandField(true, nullptr).isEmpty();
1393 default:
1394 return false;
1395 }
1396}
1397
1399// Returns if the data was actually modified
1401{
1402 bool bRet = false;
1404
1405 {
1406 class FieldTypeGuard : public SwClient
1407 {
1408 public:
1409 explicit FieldTypeGuard(SwFieldType* pType)
1410 : SwClient(pType)
1411 {
1412 }
1413 const SwFieldType* get() const
1414 {
1415 return static_cast<const SwFieldType*>(GetRegisteredIn());
1416 }
1417 };
1418 // Removing some nodes for one SwFieldIds::Database type might remove the type from
1419 // document's field types, invalidating iterators. So, we need to create own list of
1420 // matching types prior to processing them.
1421 std::vector<std::unique_ptr<FieldTypeGuard>> aHidingFieldTypes;
1422 for (std::unique_ptr<SwFieldType> const & pType : *getIDocumentFieldsAccess().GetFieldTypes())
1423 {
1424 if (FieldCanHideParaWeight(pType->Which()))
1425 aHidingFieldTypes.push_back(std::make_unique<FieldTypeGuard>(pType.get()));
1426 }
1427 for (const auto& pTypeGuard : aHidingFieldTypes)
1428 {
1429 if (const SwFieldType* pType = pTypeGuard->get())
1430 {
1431 std::vector<SwFormatField*> vFields;
1432 pType->GatherFields(vFields);
1433 for(auto pFormatField: vFields)
1434 bRet |= HandleHidingField(*pFormatField, GetNodes(), getIDocumentContentOperations());
1435 }
1436 }
1437 }
1438
1439 // Remove any hidden paragraph (hidden text attribute)
1440 for( SwNodeOffset n = GetNodes().Count(); n; )
1441 {
1442 SwTextNode* pTextNd = GetNodes()[ --n ]->GetTextNode();
1443 if ( pTextNd )
1444 {
1445 bool bRemoved = false;
1446 if ( pTextNd->HasHiddenCharAttribute( true ) )
1447 {
1448 bRemoved = true;
1449 bRet = true;
1450
1451 if (SwNodeOffset(2) == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1452 {
1453 SwFrameFormat *const pFormat = pTextNd->StartOfSectionNode()->GetFlyFormat();
1454 if (nullptr != pFormat)
1455 {
1456 // remove hidden text frame
1458 }
1459 else
1460 {
1461 // default, remove hidden paragraph
1462 RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1463 }
1464 }
1465 else
1466 {
1467 // default, remove hidden paragraph
1468 RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1469 }
1470 }
1471 else if ( pTextNd->HasHiddenCharAttribute( false ) )
1472 {
1473 bRemoved = true;
1474 bRet = true;
1476 }
1477
1478 // Footnotes/Frames may have been removed, therefore we have
1479 // to reset n:
1480 if ( bRemoved )
1481 {
1482 // [n] has to be inside [0 .. GetNodes().Count()] range
1483 if (n > GetNodes().Count())
1484 n = GetNodes().Count();
1485 }
1486 }
1487 }
1488
1489 {
1490 // Delete/empty all hidden areas
1492 SwSectionFormats& rSectFormats = GetSections();
1493
1494 for( SwSectionFormats::size_type n = rSectFormats.size(); n; )
1495 {
1496 SwSectionFormat* pSectFormat = rSectFormats[ --n ];
1497 // don't add sections in Undo/Redo
1498 if( !pSectFormat->IsInNodesArr())
1499 continue;
1500 SwSection* pSect = pSectFormat->GetSection();
1501 if( pSect->CalcHiddenFlag() )
1502 {
1503 SwSection* pParent = pSect, *pTmp;
1504 while( nullptr != (pTmp = pParent->GetParent() ))
1505 {
1506 if( pTmp->IsHiddenFlag() )
1507 pSect = pTmp;
1508 pParent = pTmp;
1509 }
1510
1511 aSectFormats.insert( pSect->GetFormat() );
1512 }
1513 if( !pSect->GetCondition().isEmpty() )
1514 {
1515 SwSectionData aSectionData( *pSect );
1516 aSectionData.SetCondition( OUString() );
1517 aSectionData.SetHidden( false );
1518 UpdateSection( n, aSectionData );
1519 }
1520 }
1521
1522 auto n = aSectFormats.size();
1523
1524 if( 0 != n )
1525 {
1526 while( n )
1527 {
1528 SwSectionFormat* pSectFormat = aSectFormats[ --n ];
1529 SwSectionNode* pSectNd = pSectFormat->GetSectionNode();
1530 if( pSectNd )
1531 {
1532 bRet = true;
1533 SwPaM aPam( *pSectNd );
1534
1535 if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() ==
1536 pSectNd->GetIndex() - 1 &&
1537 pSectNd->StartOfSectionNode()->EndOfSectionIndex() ==
1538 pSectNd->EndOfSectionIndex() + 1 )
1539 {
1540 // only delete the content
1541 SwContentNode* pCNd = GetNodes().GoNext( aPam.GetPoint() );
1542 aPam.SetMark();
1543 aPam.GetPoint()->Assign( *pSectNd->EndOfSectionNode() );
1544 pCNd = SwNodes::GoPrevious( aPam.GetPoint() );
1545 assert(pCNd); // keep coverity happy
1546 aPam.GetPoint()->SetContent( pCNd->Len() );
1547
1549 }
1550 else
1551 {
1552 // delete the whole section
1553 aPam.SetMark();
1554 aPam.GetPoint()->Assign( *pSectNd->EndOfSectionNode() );
1556 }
1557
1558 }
1559 }
1560 }
1561 }
1562
1563 if( bRet )
1566 return bRet;
1567}
1568
1570{
1571 std::vector<SwFormatField*> vFields;
1573 if(vFields.size())
1574 return true;
1575
1576 // Search for any hidden paragraph (hidden text attribute)
1577 for( SwNodeOffset n = GetNodes().Count()-SwNodeOffset(1); n; --n)
1578 {
1579 SwTextNode* pTextNd = GetNodes()[ n ]->GetTextNode();
1580 if ( pTextNd &&
1581 ( pTextNd->HasHiddenCharAttribute( true ) || pTextNd->HasHiddenCharAttribute( false ) ) )
1582 return true;
1583 }
1584
1585 for(auto pSectFormat : GetSections())
1586 {
1587 // don't add sections in Undo/Redo
1588 if( !pSectFormat->IsInNodesArr())
1589 continue;
1590 SwSection* pSect = pSectFormat->GetSection();
1591 if( pSect->IsHidden() )
1592 return true;
1593 }
1594 return false;
1595}
1596
1598{
1599 SwUndoId nLastUndoId(SwUndoId::EMPTY);
1600 if (GetIDocumentUndoRedo().GetLastUndoInfo(nullptr, & nLastUndoId)
1601 && (SwUndoId::UI_DELETE_INVISIBLECNTNT == nLastUndoId))
1602 {
1603 GetIDocumentUndoRedo().Undo();
1604 GetIDocumentUndoRedo().ClearRedo();
1605 return true;
1606 }
1607 return false;
1608}
1609
1611{
1612 bool bRet = false;
1614 GetIDocumentUndoRedo().StartUndo( SwUndoId::UI_REPLACE, nullptr );
1615
1616 const SwFieldTypes* pMyFieldTypes = getIDocumentFieldsAccess().GetFieldTypes();
1617 const SwFieldTypes::size_type nCount = pMyFieldTypes->size();
1618 //go backward, field types are removed
1619 for(SwFieldTypes::size_type nType = nCount; nType > 0; --nType)
1620 {
1621 const SwFieldType *pCurType = (*pMyFieldTypes)[nType - 1].get();
1622
1623 if ( SwFieldIds::Postit == pCurType->Which() )
1624 continue;
1625
1626 std::vector<SwFormatField*> vFieldFormats;
1627 pCurType->GatherFields(vFieldFormats, false);
1628 for(const auto& rpFieldFormat : vFieldFormats)
1629 {
1630 const SwTextField *pTextField = rpFieldFormat->GetTextField();
1631 // skip fields that are currently not in the document
1632 // e.g. fields in undo or redo array
1633
1634 bool bSkip = !pTextField ||
1635 !pTextField->GetpTextNode()->GetNodes().IsDocNodes();
1636
1637 if (!bSkip)
1638 {
1639 bool bInHeaderFooter = IsInHeaderFooter(*pTextField->GetpTextNode());
1640 const SwFormatField& rFormatField = pTextField->GetFormatField();
1641 const SwField* pField = rFormatField.GetField();
1642
1643 //#i55595# some fields have to be excluded in headers/footers
1644 SwFieldIds nWhich = pField->GetTyp()->Which();
1645 if(!bInHeaderFooter ||
1646 (nWhich != SwFieldIds::PageNumber &&
1647 nWhich != SwFieldIds::Chapter &&
1648 nWhich != SwFieldIds::GetExp&&
1649 nWhich != SwFieldIds::SetExp&&
1650 nWhich != SwFieldIds::Input&&
1651 nWhich != SwFieldIds::RefPageGet&&
1652 nWhich != SwFieldIds::RefPageSet))
1653 {
1654 OUString sText = pField->ExpandField(true, &rLayout);
1655
1656 // database fields should not convert their command into text
1657 if( SwFieldIds::Database == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
1658 sText.clear();
1659
1660 SwPaM aInsertPam(*pTextField->GetpTextNode(), pTextField->GetStart());
1661 aInsertPam.SetMark();
1662
1663 // go to the end of the field
1664 const SwTextField *pFieldAtEnd = sw::DocumentFieldsManager::GetTextFieldAtPos(*aInsertPam.End());
1665 if (pFieldAtEnd && pFieldAtEnd->Which() == RES_TXTATR_INPUTFIELD)
1666 {
1667 SwPosition &rEndPos = *aInsertPam.GetPoint();
1668 rEndPos.SetContent( SwCursorShell::EndOfInputFieldAtPos( *aInsertPam.End() ) );
1669 }
1670 else
1671 {
1672 aInsertPam.Move();
1673 }
1674
1675 // first insert the text after field to keep the field's attributes,
1676 // then delete the field
1677 if (!sText.isEmpty())
1678 {
1679 // to keep the position after insert
1680 SwPaM aDelPam( *aInsertPam.GetMark(), *aInsertPam.GetPoint() );
1681 aDelPam.Move( fnMoveBackward );
1682 aInsertPam.DeleteMark();
1683
1684 getIDocumentContentOperations().InsertString( aInsertPam, sText );
1685
1686 aDelPam.Move();
1687 // finally remove the field
1689 }
1690 else
1691 {
1693 }
1694
1695 bRet = true;
1696 }
1697 }
1698 }
1699 }
1700
1701 if( bRet )
1703 GetIDocumentUndoRedo().EndUndo( SwUndoId::UI_REPLACE, nullptr );
1705 return bRet;
1706
1707}
1708
1710{
1711 return SW_MOD()->IsInsTableFormatNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1712}
1713
1715{
1716 return SW_MOD()->IsInsTableChangeNumFormat(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1717}
1718
1720{
1721 return SW_MOD()->IsInsTableAlignNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1722}
1723
1725{
1726 return SW_MOD()->IsSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1727}
1728
1730{
1731 SW_MOD()->SetSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE), value);
1732}
1733
1735void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable )
1736{
1737 if( bIsTable )
1738 {
1739 const SwTableNode* pTableNd = rPam.GetPoint()->GetNode().FindTableNode();
1740 if( pTableNd )
1741 {
1742 std::unique_ptr<SwUndoCpyTable> pUndo(new SwUndoCpyTable(*this));
1743 pUndo->SetTableSttIdx( pTableNd->GetIndex() );
1744 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1745 }
1746 }
1747 else if( rPam.HasMark() )
1748 {
1749 std::unique_ptr<SwUndoCpyDoc> pUndo(new SwUndoCpyDoc( rPam ));
1750 pUndo->SetInsertRange( rPam, false );
1751 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1752 }
1753}
1754
1755void SwDoc::ChangeTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
1756{
1757 assert(dynamic_cast<const SwTOXBaseSection*>(&rTOX));
1758 SwTOXBaseSection& rTOXSect(static_cast<SwTOXBaseSection&>(rTOX));
1759
1760 if (GetIDocumentUndoRedo().DoesUndo())
1761 {
1762 GetIDocumentUndoRedo().AppendUndo(
1763 std::make_unique<SwUndoTOXChange>(*this, rTOXSect, rNew));
1764 }
1765
1766 rTOX = rNew;
1767
1768 // note: do not Update the ToX here - the caller will do it, with a ViewShell!
1769}
1770
1771OUString SwDoc::GetPaMDescr(const SwPaM & rPam)
1772{
1773 if (&rPam.GetPointNode() == &rPam.GetMarkNode())
1774 {
1775 SwTextNode * pTextNode = rPam.GetPointNode().GetTextNode();
1776
1777 if (nullptr != pTextNode)
1778 {
1779 const sal_Int32 nStart = rPam.Start()->GetContentIndex();
1780 const sal_Int32 nEnd = rPam.End()->GetContentIndex();
1781
1782 return SwResId(STR_START_QUOTE)
1783 + ShortenString(pTextNode->GetText().copy(nStart, nEnd - nStart),
1785 SwResId(STR_LDOTS))
1786 + SwResId(STR_END_QUOTE);
1787 }
1788 }
1789 else
1790 {
1791 return SwResId(STR_PARAGRAPHS);
1792 }
1793
1794 return "??";
1795}
1796
1798{
1799 for( SwNodeOffset n = GetNodes().Count(); n; )
1800 {
1801 SwNode* pNd = GetNodes()[ --n ];
1802 if ( pNd->IsTextNode() && pNd->GetTextNode()->HasHiddenCharAttribute( false ) )
1803 return true;
1804 }
1805
1806 return false;
1807}
1808
1809std::shared_ptr<SwUnoCursor> SwDoc::CreateUnoCursor( const SwPosition& rPos, bool bTableCursor )
1810{
1811 std::shared_ptr<SwUnoCursor> pNew;
1812 if( bTableCursor )
1813 pNew = std::make_shared<SwUnoTableCursor>(rPos);
1814 else
1815 pNew = std::make_shared<SwUnoCursor>(rPos);
1816
1817 mvUnoCursorTable.push_back( pNew );
1818 return pNew;
1819}
1820
1822{
1824 {
1825 SwTextFormatColl *pColl = (*mpTextFormatCollTable)[n];
1826 if (RES_CONDTXTFMTCOLL == pColl->Which())
1827 pColl->CallSwClientNotify( SwAttrHint() );
1828 }
1829}
1830
1831uno::Reference< script::vba::XVBAEventProcessor > const &
1833{
1834 return mxVbaEvents;
1835}
1836
1838{
1839#if HAVE_FEATURE_SCRIPTING
1841 {
1842 try
1843 {
1844 uno::Reference< frame::XModel > xModel( mpDocShell->GetModel(), uno::UNO_SET_THROW );
1845 uno::Sequence< uno::Any > aArgs{ uno::Any(xModel) };
1846 mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW );
1847 }
1848 catch( uno::Exception& )
1849 {
1850 }
1851 }
1852#endif
1853}
1854
1855void SwDoc::SetMissingDictionaries( bool bIsMissing )
1856{
1857 if (!bIsMissing)
1858 meDictionaryMissing = MissingDictionary::False;
1859 else if (meDictionaryMissing == MissingDictionary::Undefined)
1860 meDictionaryMissing = MissingDictionary::True;
1861};
1862
1863void SwDoc::SetLanguage(const LanguageType eLang, const sal_uInt16 nId)
1864{
1865 mpAttrPool->SetPoolDefaultItem(SvxLanguageItem(eLang, nId));
1866}
1867
1869{
1870 uno::Reference<text::XTextRange> xRange(SwXTextRange::CreateXTextRange(rPos.GetDoc(), rPos,
1871 &rPos));
1872 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xRange, uno::UNO_QUERY_THROW);
1873 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
1874 uno::Reference<text::XTextRange> xThisParagraphRange(xParaEnum->nextElement(), uno::UNO_QUERY);
1875 if (xThisParagraphRange.is())
1876 {
1877 const std::vector<OUString> aHiddenProperties{ UNO_NAME_RSID,
1891
1894 SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
1895
1896 uno::Reference<beans::XPropertySet> xPropertySet(xThisParagraphRange,
1897 uno::UNO_QUERY_THROW);
1898 uno::Reference<beans::XPropertyState> xPropertyState(xThisParagraphRange,
1899 uno::UNO_QUERY_THROW);
1900 const uno::Sequence<beans::Property> aProperties
1901 = xPropertySet->getPropertySetInfo()->getProperties();
1902 for (const beans::Property& rProperty : aProperties)
1903 {
1904 const OUString& rPropName = rProperty.Name;
1905 if (!rMap.hasPropertyByName(rPropName))
1906 continue;
1907 if (std::find(aHiddenProperties.begin(), aHiddenProperties.end(), rPropName)
1908 != aHiddenProperties.end())
1909 continue;
1910 if (xPropertyState->getPropertyState(rPropName) == beans::PropertyState_DIRECT_VALUE)
1911 return true;
1912 }
1913 }
1914 return false;
1915}
1916
1917/* 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:1576
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:765
virtual sal_Int32 Len() const
Definition: node.cxx:1256
static sal_Int32 EndOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:1147
bool IsInitialized() const
Definition: dbfld.hxx:95
void CommitLastRegistrations()
Accept not committed registrations.
Definition: dbmgr.cxx:3270
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:1353
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:1235
bool FieldHidesPara(const SwField &rField) const
Definition: doc.cxx:1384
std::vector< std::weak_ptr< SwUnoCursor > > mvUnoCursorTable
Definition: doc.hxx:1667
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:1855
void SetSplitVerticalByDefault(bool value)
Definition: doc.cxx:1729
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:1863
o3tl::sorted_vector< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1680
void DeleteFormatRefMark(const SwFormatRefMark *pFormatRefMark)
Definition: doc.cxx:1126
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:1797
void AppendUndoForInsertFromDB(const SwPaM &rPam, bool bIsTable)
Set up the InsertDB as Undo table.
Definition: doc.cxx:1735
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:1196
sal_uInt32 getRsid() const
Definition: doc.cxx:210
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
Definition: doc.cxx:1103
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:1771
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
SwNodes & GetNodes()
Definition: doc.hxx:422
static bool HasParagraphDirectFormatting(const SwPosition &rPos)
Definition: doc.cxx:1868
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:1832
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:1216
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:1597
void ChangeTOX(SwTOXBase &rTOX, const SwTOXBase &rNew)
Definition: doc.cxx:1755
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:1821
const std::unique_ptr< ::sw::DocumentStatisticsManager > m_pDocumentStatisticsManager
Definition: doc.hxx:236
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:791
void SetVbaEventProcessor()
Definition: doc.cxx:1837
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:1724
int FieldCanHideParaWeight(SwFieldIds eFieldId) const
Definition: doc.cxx:1369
bool ConvertFieldsToText(SwRootFrame const &rLayout)
Definition: doc.cxx:1610
const SwFormatRefMark * GetRefMark(std::u16string_view rName) const
Definition: doc.cxx:1059
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1809
bool RemoveInvisibleContent()
Remove the invisible content from the document e.g. hidden areas, hidden paragraphs.
Definition: doc.cxx:1400
const std::unique_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager
Definition: doc.hxx:227
bool IsInsTableFormatNum() const
Definition: doc.cxx:1709
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:1334
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:1254
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:1367
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:1719
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:911
bool IsInsTableChangeNumFormat() const
Definition: doc.cxx:1714
IDocumentListsAccess const & getIDocumentListsAccess() const
Definition: doc.cxx:307
bool IsInHeaderFooter(const SwNode &) const
Definition: doclay.cxx:1563
bool HasInvisibleContent() const
Definition: doc.cxx:1569
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:744
SwNodeOffset StartOfSectionIndex() const
Definition: node.hxx:724
bool IsTextNode() const
Definition: node.hxx:687
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:733
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:143
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx: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:2538
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:59
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:205
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:144
bool GetResolved() const
Definition: docufld.cxx:1791
virtual OUString GetPar1() const override
Author.
Definition: docufld.cxx:1815
Date GetDate() const
Definition: docufld.hxx:485
virtual OUString GetPar2() const override
Text.
Definition: docufld.cxx:1827
bool IsPrintLeftPages() const
Definition: printdata.cxx: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:2034
void SetHidden(bool const bFlag)
Definition: section.hxx:99
void SetCondition(OUString const &rNew)
Definition: section.hxx:115
SwSection * GetSection() const
Definition: section.cxx:646
SwSectionNode * GetSectionNode()
Definition: section.cxx: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:4058
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:5291
const SwTextNode & GetTextNode() const
Definition: txtrfmrk.hxx:50
SwHistory & GetHistory()
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1083
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:2648
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:1201
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 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:1176
static void lcl_FormatPostIt(IDocumentContentOperations *pIDCO, SwPaM &aPam, const SwPostItField *pField, bool bNewPage, bool bIsFirstPostIt, sal_uInt16 nPageNo, sal_uInt16 nLineNo)
Definition: doc.cxx:547
static bool lcl_SpellAndGrammarAgain(SwNode *pNd, void *pArgs)
Definition: doc.cxx:1148
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)
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: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: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
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:88
#define PROPERTY_MAP_PARA_AUTO_STYLE
Definition: unomap.hxx:122
constexpr OUStringLiteral UNO_NAME_SORTED_TEXT_ID
Definition: unoprnms.hxx:415
constexpr OUStringLiteral UNO_NAME_PARA_IS_NUMBERING_RESTART
Definition: unoprnms.hxx:518
constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_THEME
constexpr OUStringLiteral UNO_NAME_NUMBERING_IS_NUMBER
Definition: unoprnms.hxx:165
constexpr OUStringLiteral UNO_NAME_PARA_CONDITIONAL_STYLE_NAME
Definition: unoprnms.hxx:489
constexpr OUStringLiteral UNO_NAME_PARA_STYLE_NAME
Definition: unoprnms.hxx:189
constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_TINT_OR_SHADE
constexpr OUStringLiteral UNO_NAME_RSID
Definition: unoprnms.hxx:849
constexpr OUStringLiteral UNO_NAME_NUMBERING_LEVEL
constexpr OUStringLiteral UNO_NAME_PAGE_STYLE_NAME
Definition: unoprnms.hxx:185
constexpr OUStringLiteral UNO_NAME_NUMBERING_START_VALUE
Definition: unoprnms.hxx:164
constexpr OUStringLiteral UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE
Definition: unoprnms.hxx:833
constexpr OUStringLiteral UNO_NAME_PARRSID
Definition: unoprnms.hxx:850
constexpr OUStringLiteral UNO_NAME_CHAR_STYLE_NAME