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