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