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