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