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