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->GetOfst() > nPos ||
500  (pFrame->HasFollow() && pFrame->GetFollow()->GetOfst() <= 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  IDocumentFieldsAccess const * pIDFA,
516  SetGetExpFields * pSrtLst )
517 {
518  bool bHasPostIts = false;
519 
520  SwFieldType* pFieldType = pIDFA->GetSysFieldType( SwFieldIds::Postit );
521  assert(pFieldType);
522 
523  if( pFieldType->HasWriterListeners() )
524  {
525  // Found modify object; insert all fields into the array
526  SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
527  for( SwFormatField* pField = aIter.First(); pField; pField = aIter.Next() )
528  {
529  const SwTextField* pTextField;
530  if( nullptr != ( pTextField = pField->GetTextField() ) &&
531  pTextField->GetTextNode().GetNodes().IsDocNodes() )
532  {
533  bHasPostIts = true;
534  if (pSrtLst)
535  {
536  SwNodeIndex aIdx( pTextField->GetTextNode() );
537  std::unique_ptr<PostItField_> pNew(new PostItField_( aIdx, pTextField ));
538  pSrtLst->insert( std::move(pNew) );
539  }
540  else
541  break; // we just wanted to check for the existence of postits ...
542  }
543  }
544  }
545 
546  return bHasPostIts;
547 }
548 
549 static void lcl_FormatPostIt(
551  SwPaM& aPam,
552  const SwPostItField* pField,
553  bool bNewPage, bool bIsFirstPostIt,
554  sal_uInt16 nPageNo, sal_uInt16 nLineNo )
555 {
556  static char const sTmp[] = " : ";
557 
558  assert(SwViewShell::GetShellRes());
559 
560  if (bNewPage)
561  {
562  pIDCO->InsertPoolItem( aPam, SvxFormatBreakItem( SvxBreak::PageAfter, RES_BREAK ) );
563  pIDCO->SplitNode( *aPam.GetPoint(), false );
564  }
565  else if (!bIsFirstPostIt)
566  {
567  // add an empty line between different notes
568  pIDCO->SplitNode( *aPam.GetPoint(), false );
569  pIDCO->SplitNode( *aPam.GetPoint(), false );
570  }
571 
572  OUString aStr( SwViewShell::GetShellRes()->aPostItPage );
573  aStr += sTmp +
574  OUString::number( nPageNo ) +
575  " ";
576  if( nLineNo )
577  {
579  aStr += sTmp +
580  OUString::number( nLineNo ) +
581  " ";
582  }
584  aStr += sTmp;
585  aStr += pField->GetPar1() + " ";
586  SvtSysLocale aSysLocale;
587  aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() );
588  if(pField->GetResolved())
589  aStr += " " + SwResId(STR_RESOLVED);
590  pIDCO->InsertString( aPam, aStr );
591 
592  pIDCO->SplitNode( *aPam.GetPoint(), false );
593  aStr = pField->GetPar2();
594 #if defined(_WIN32)
595  // Throw out all CR in Windows
596  aStr = aStr.replaceAll("\r", "");
597 #endif
598  pIDCO->InsertString( aPam, aStr );
599 }
600 
603 static sal_Int32 lcl_GetPaperBin( const SwPageFrame *pStartFrame )
604 {
605  sal_Int32 nRes = -1;
606 
607  const SwFrameFormat &rFormat = pStartFrame->GetPageDesc()->GetMaster();
608  const SfxPoolItem *pItem = nullptr;
609  SfxItemState eState = rFormat.GetItemState( RES_PAPER_BIN, false, &pItem );
610  const SvxPaperBinItem *pPaperBinItem = dynamic_cast< const SvxPaperBinItem * >(pItem);
611  if (eState > SfxItemState::DEFAULT && pPaperBinItem)
612  nRes = pPaperBinItem->GetValue();
613 
614  return nRes;
615 }
616 
617 namespace
618 {
619 // tdf#:114663 Translates a range string from user input (with page numbering possibly not
620 // taking blank pages into account) to equivalent string which references physical page numbers.
621 // rUIPages2PhyPagesMap must contain a contiguous sequence of UI page numbers
622 OUString UIPages2PhyPages(const OUString& rUIPageRange, const std::map< sal_Int32, sal_Int32 >& rUIPages2PhyPagesMap)
623 {
624  if (rUIPages2PhyPagesMap.empty())
625  return OUString();
626  auto iMin = rUIPages2PhyPagesMap.begin();
627  const sal_Int32 nUIPageMin = iMin->first, nPhyPageMin = iMin->second;
628  auto iMax = rUIPages2PhyPagesMap.rbegin();
629  const sal_Int32 nUIPageMax = iMax->first, nPhyPageMax = iMax->second;
630  OUStringBuffer aOut(rUIPageRange.getLength());
631  OUStringBuffer aNumber(16);
632  const sal_Unicode* pInput = rUIPageRange.getStr();
633  while (*pInput)
634  {
635  while (*pInput >= '0' && *pInput <= '9')
636  aNumber.append(*pInput++);
637  if (!aNumber.isEmpty())
638  {
639  sal_Int32 nNumber = aNumber.makeStringAndClear().toInt32();
640  if (nNumber < nUIPageMin)
641  nNumber = nPhyPageMin-1;
642  else if (nNumber > nUIPageMax)
643  nNumber = nPhyPageMax+1;
644  else
645  nNumber = rUIPages2PhyPagesMap.at(nNumber);
646  aOut.append(nNumber);
647  }
648 
649  while (*pInput && (*pInput < '0' || *pInput > '9'))
650  aOut.append(*pInput++);
651  }
652 
653  return aOut.makeStringAndClear();
654 }
655 }
656 
657 // tdf#52316 remove blank pages from page count and actual page number
659  const SwRootFrame& rLayout,
660  sal_uInt16& nDocPageCount,
661  sal_uInt16& nActualPage)
662 {
663  sal_uInt16 nDocPageCountWithBlank = nDocPageCount;
664  sal_uInt16 nActualPageWithBlank = nActualPage;
665  sal_uInt16 nPageNum = 1;
666  const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
667  while (pStPage && nPageNum <= nDocPageCountWithBlank)
668  {
669  if ( pStPage->getFrameArea().Height() == 0 )
670  {
671  --nDocPageCount;
672  if (nPageNum <= nActualPageWithBlank)
673  --nActualPage;
674  }
675  ++nPageNum;
676  pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
677  }
678 }
679 
681  const SwRootFrame& rLayout,
682  /* out */ SwRenderData &rData,
683  const SwPrintUIOptions &rOptions,
684  bool bIsPDFExport,
685  sal_Int32 nDocPageCount )
686 {
687  const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
688  const bool bPrintSelection = nContent == 4;
689 
690  // properties to take into account when calculating the set of pages
691  // (PDF export UI does not allow for selecting left or right pages only)
692  bool bPrintLeftPages = bIsPDFExport || rOptions.IsPrintLeftPages();
693  bool bPrintRightPages = bIsPDFExport || rOptions.IsPrintRightPages();
694  // #i103700# printing selections should not allow for automatic inserting empty pages
695  bool bPrintEmptyPages = !bPrintSelection && rOptions.IsPrintEmptyPages( bIsPDFExport );
696 
697  std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
698  std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
699  // Map page numbers from user input (possibly ignoring blanks) to physical page numbers
700  std::map< sal_Int32, sal_Int32 > aUIPages2PhyPagesMap;
701  rValidPages.clear();
702 
703  sal_Int32 nPageNum = 1, nUIPageNum = 1;
704  const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
705  while (pStPage && nPageNum <= nDocPageCount)
706  {
707  const bool bNonEmptyPage = pStPage->getFrameArea().Height() != 0;
708  const bool bPrintThisPage =
709  ( (bPrintRightPages && pStPage->OnRightPage()) ||
710  (bPrintLeftPages && !pStPage->OnRightPage()) ) &&
711  ( bPrintEmptyPages || bNonEmptyPage );
712 
713  if (bPrintThisPage)
714  {
715  rValidPages.insert( nPageNum );
716  rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
717  }
718 
719  if ( bPrintEmptyPages || bNonEmptyPage )
720  {
721  aUIPages2PhyPagesMap[nUIPageNum++] = nPageNum;
722  }
723  ++nPageNum;
724  pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
725  }
726 
727  // now that we have identified the valid pages for printing according
728  // to the print settings we need to get the PageRange to use and
729  // use both results to get the actual pages to be printed
730  // (post-it settings need to be taken into account later on!)
731 
732  // get PageRange value to use
733  OUString aPageRange;
734  // #i116085# - adjusting fix for i113919
735  if ( !bIsPDFExport )
736  {
737  // PageContent :
738  // 0 -> print all pages (default if aPageRange is empty)
739  // 1 -> print range according to PageRange
740  // 2 -> print even pages
741  // 3 -> print odd pages
742  // 4 -> print selection
743  if (1 == nContent)
744  aPageRange = rOptions.getStringValue( "PageRange" );
745  if (4 == nContent)
746  {
747  // note that printing selections is actually implemented by copying
748  // the selection to a new temporary document and printing all of that one.
749  // Thus for Writer "PrintContent" must never be 4.
750  // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
751  // printed and for creating the temporary document.
752  }
753 
754  // please note
755  }
756  if (aPageRange.isEmpty()) // empty string -> print all
757  {
758  // set page range to print to 'all pages'
759  aPageRange = OUString::number( 1 ) + "-" + OUString::number( nDocPageCount );
760  }
761  else
762  {
763  // Convert page numbers from user input to physical page numbers
764  aPageRange = UIPages2PhyPages(aPageRange, aUIPages2PhyPagesMap);
765  }
766  rData.SetPageRange( aPageRange );
767 
768  // get vector of pages to print according to PageRange and valid pages set from above
769  // (result may be an empty vector, for example if the range string is not correct)
770  // If excluding empty pages, allow range to specify range of printable pages
772  1, nDocPageCount, 0, &rData.GetValidPagesSet() );
773 }
774 
776  /* out */ SwRenderData &rData,
777  const SwPrintUIOptions &rOptions,
778  sal_Int32 nDocPageCount )
779 {
780 
781  SwPostItMode nPostItMode = static_cast<SwPostItMode>( rOptions.getIntValue( "PrintAnnotationMode", 0 ) );
782  assert((nPostItMode == SwPostItMode::NONE || rData.HasPostItData())
783  && "print post-its without post-it data?");
784  const SetGetExpFields::size_type nPostItCount =
785  rData.HasPostItData() ? rData.m_pPostItFields->size() : 0;
786  if (nPostItMode == SwPostItMode::NONE || nPostItCount <= 0)
787  return;
788 
789  SET_CURR_SHELL( rData.m_pPostItShell.get() );
790 
791  // clear document and move to end of it
792  SwDoc & rPostItDoc(*rData.m_pPostItShell->GetDoc());
793  SwPaM aPam(rPostItDoc.GetNodes().GetEndOfContent());
794  aPam.Move( fnMoveBackward, GoInDoc );
795  aPam.SetMark();
796  aPam.Move( fnMoveForward, GoInDoc );
797  rPostItDoc.getIDocumentContentOperations().DeleteRange( aPam );
798 
799  const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
800 
801  // For mode SwPostItMode::EndPage:
802  // maps a physical page number to the page number in post-it document that holds
803  // the first post-it for that physical page . Needed to relate the correct start frames
804  // from the post-it doc to the physical page of the document
805  std::map< sal_Int32, sal_Int32 > aPostItLastStartPageNum;
806 
807  // add all post-its on valid pages within the page range to the
808  // temporary post-it document.
809  // Since the array of post-it fields is sorted by page and line number we will
810  // already get them in the correct order
811  sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
812  bool bIsFirstPostIt = true;
813  for (SetGetExpFields::size_type i = 0; i < nPostItCount; ++i)
814  {
815  PostItField_& rPostIt = static_cast<PostItField_&>(*(*rData.m_pPostItFields)[ i ]);
816  nLastPageNum = nPhyPageNum;
817  nPhyPageNum = rPostIt.GetPageNo(
818  aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
819  if (nPhyPageNum)
820  {
821  // need to insert a page break?
822  // In SwPostItMode::EndPage mode for each document page the following
823  // post-it page needs to start on a new page
824  const bool bNewPage = nPostItMode == SwPostItMode::EndPage &&
825  !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
826 
827  lcl_FormatPostIt( &rData.m_pPostItShell->GetDoc()->getIDocumentContentOperations(), aPam,
828  rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
829  bIsFirstPostIt = false;
830 
831  if (nPostItMode == SwPostItMode::EndPage)
832  {
833  // get the correct number of current pages for the post-it document
834  rData.m_pPostItShell->CalcLayout();
835  const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount();
836  aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
837  }
838  }
839  }
840 
841  // format post-it doc to get correct number of pages
842  rData.m_pPostItShell->CalcLayout();
843 
844  SwRootFrame* pPostItRoot = rData.m_pPostItShell->GetLayout();
845  //tdf#103313 print dialog maxes out cpu as Idles never get to
846  //complete this postitshell's desire to complete formatting
847  pPostItRoot->ResetIdleFormat();
848 
849  const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount();
850 
851  if (nPostItMode == SwPostItMode::Only || nPostItMode == SwPostItMode::EndDoc)
852  {
853  // now add those post-it pages to the vector of pages to print
854  // or replace them if only post-its should be printed
855 
856  if (nPostItMode == SwPostItMode::Only)
857  {
858  // no document page to be printed
859  rData.GetPagesToPrint().clear();
860  }
861 
862  // now we just need to add the post-it pages to be printed to the
863  // end of the vector of pages to print
864  sal_Int32 nPageNum = 0;
865  const SwPageFrame * pPageFrame = static_cast<SwPageFrame*>(pPostItRoot->Lower());
866  while( pPageFrame && nPageNum < nPostItDocPageCount )
867  {
868  ++nPageNum;
869  // negative page number indicates page is from the post-it doc
870  rData.GetPagesToPrint().push_back( -nPageNum );
871  pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
872  }
873  OSL_ENSURE( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
874  }
875  else if (nPostItMode == SwPostItMode::EndPage)
876  {
877  // the next step is to find all the pages from the post-it
878  // document that should be printed for a given physical page
879  // of the document
880 
881  std::vector< sal_Int32 > aTmpPagesToPrint;
882  sal_Int32 nLastPostItPage(0);
883  const size_t nNum = rData.GetPagesToPrint().size();
884  for (size_t i = 0 ; i < nNum; ++i)
885  {
886  // add the physical page to print from the document
887  const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
888  aTmpPagesToPrint.push_back( nPhysPage );
889 
890  // add the post-it document pages to print, i.e those
891  // post-it pages that have the data for the above physical page
892  std::map<sal_Int32, sal_Int32>::const_iterator const iter(
893  aPostItLastStartPageNum.find(nPhysPage));
894  if (iter != aPostItLastStartPageNum.end())
895  {
896  for (sal_Int32 j = nLastPostItPage + 1;
897  j <= iter->second; ++j)
898  {
899  // negative page number indicates page is from the
900  aTmpPagesToPrint.push_back(-j); // post-it document
901  }
902  nLastPostItPage = iter->second;
903  }
904  }
905 
906  // finally we need to assign those vectors to the resulting ones.
907  // swapping the data should be more efficient than assigning since
908  // we won't need the temporary vectors anymore
909  rData.GetPagesToPrint().swap( aTmpPagesToPrint );
910  }
911 
912 }
913 
915  const SwRootFrame& rLayout,
916  /* out */ SwRenderData &rData,
917  const SwPrintUIOptions &rOptions,
918  sal_Int32 nDocPageCount )
919 {
920  std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
921  std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
922  std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
923  std::map< sal_Int32, const SwPageFrame * > validStartFrames;
924 
925  rPagePairs.clear();
926  rValidPagesSet.clear();
927 
928  OUString aPageRange;
929  // PageContent :
930  // 0 -> print all pages (default if aPageRange is empty)
931  // 1 -> print range according to PageRange
932  // 2 -> print even pages
933  // 3 -> print odd pages
934  // 4 -> print selection
935  const sal_Int64 nContent = rOptions.getIntValue( "PrintContent", 0 );
936  if (nContent == 1)
937  aPageRange = rOptions.getStringValue( "PageRange" );
938  if (aPageRange.isEmpty()) // empty string -> print all
939  {
940  // set page range to print to 'all pages'
941  aPageRange = OUString::number( 1 ) + "-" + OUString::number( nDocPageCount );
942  }
943  StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
944 
945  if ( aRange.size() <= 0)
946  return;
947 
948  const SwPageFrame *pStPage = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
949  for ( sal_Int32 i = 1; pStPage && i < nDocPageCount; ++i )
950  pStPage = static_cast<const SwPageFrame*>(pStPage->GetNext());
951  if ( !pStPage ) // Then it was that
952  return;
953 
954  // currently for prospect printing all pages are valid to be printed
955  // thus we add them all to the respective map and set for later use
956  sal_Int32 nPageNum = 0;
957  const SwPageFrame *pPageFrame = dynamic_cast<const SwPageFrame*>( rLayout.Lower() );
958  while( pPageFrame && nPageNum < nDocPageCount )
959  {
960  ++nPageNum;
961  rValidPagesSet.insert( nPageNum );
962  validStartFrames[ nPageNum ] = pPageFrame;
963  pPageFrame = static_cast<const SwPageFrame*>(pPageFrame->GetNext());
964 
965  rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
966  }
967  OSL_ENSURE( nPageNum == nDocPageCount, "unexpected number of pages" );
968 
969  // properties to take into account when calculating the set of pages
970  // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
971  // of the prospect!
972  bool bPrintLeftPages = rOptions.IsPrintLeftPages();
973  bool bPrintRightPages = rOptions.IsPrintRightPages();
974  bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL", 0 ) != 0;
975 
976  // get pages for prospect printing according to the 'PageRange'
977  // (duplicates and any order allowed!)
978  std::vector< sal_Int32 > aPagesToPrint;
980  aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
981 
982  if (aPagesToPrint.empty())
983  return;
984 
985  // now fill the vector for calculating the page pairs with the start frames
986  // from the above obtained vector
987  std::vector< const SwPageFrame * > aVec;
988  for (sal_Int32 nPage : aPagesToPrint)
989  {
990  const SwPageFrame *pFrame = validStartFrames[ nPage ];
991  aVec.push_back( pFrame );
992  }
993 
994  // just one page is special ...
995  if ( 1 == aVec.size() )
996  aVec.insert( aVec.begin() + 1, nullptr ); // insert a second empty page
997  else
998  {
999  // now extend the number of pages to fit a multiple of 4
1000  // (4 'normal' pages are needed for a single prospect paper
1001  // with back and front)
1002  while( aVec.size() & 3 )
1003  aVec.push_back( nullptr );
1004  }
1005 
1006  // make sure that all pages are in correct order
1007  std::vector< const SwPageFrame * >::size_type nSPg = 0;
1008  std::vector< const SwPageFrame * >::size_type nEPg = aVec.size();
1009  sal_Int32 nStep = 1;
1010  if ( 0 == (nEPg & 1 )) // there are no uneven ones!
1011  --nEPg;
1012 
1013  if ( !bPrintLeftPages )
1014  ++nStep;
1015  else if ( !bPrintRightPages )
1016  {
1017  ++nStep;
1018  ++nSPg;
1019  --nEPg;
1020  }
1021 
1022  // the number of 'virtual' pages to be printed
1023  sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
1024 
1025  for ( sal_Int32 nPrintCount = 0; nSPg < nEPg &&
1026  nPrintCount < nCntPage; ++nPrintCount )
1027  {
1028  pStPage = aVec[ nSPg ];
1029  const SwPageFrame* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : nullptr;
1030 
1031  short nRtlOfs = bPrintProspectRTL ? 1 : 0;
1032  if ( 0 == (( nSPg + nRtlOfs) & 1 ) ) // switch for odd number in LTR, even number in RTL
1033  {
1034  const SwPageFrame* pTmp = pStPage;
1035  pStPage = pNxtPage;
1036  pNxtPage = pTmp;
1037  }
1038 
1039  sal_Int32 nFirst = -1, nSecond = -1;
1040  for ( int nC = 0; nC < 2; ++nC )
1041  {
1042  sal_Int32 nPage = -1;
1043  if ( pStPage )
1044  nPage = pStPage->GetPhyPageNum();
1045  if (nC == 0)
1046  nFirst = nPage;
1047  else
1048  nSecond = nPage;
1049 
1050  pStPage = pNxtPage;
1051  }
1052  rPagePairs.emplace_back(nFirst, nSecond );
1053 
1054  nSPg = nSPg + nStep;
1055  nEPg = nEPg - nStep;
1056  }
1057  OSL_ENSURE( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
1058 
1059  // luckily prospect printing does not make use of post-its so far,
1060  // thus we are done here.
1061 }
1062 
1064 const SwFormatRefMark* SwDoc::GetRefMark( const OUString& rName ) const
1065 {
1066  for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1067  {
1068  auto pFormatRef = dynamic_cast<const SwFormatRefMark*>(pItem);
1069  if(!pFormatRef)
1070  continue;
1071 
1072  const SwTextRefMark* pTextRef = pFormatRef->GetTextRefMark();
1073  if( pTextRef && &pTextRef->GetTextNode().GetNodes() == &GetNodes() &&
1074  rName == pFormatRef->GetRefName() )
1075  return pFormatRef;
1076  }
1077  return nullptr;
1078 }
1079 
1081 const SwFormatRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const
1082 {
1083  const SwTextRefMark* pTextRef;
1084  const SwFormatRefMark* pRet = nullptr;
1085 
1086  sal_uInt32 nCount = 0;
1087  for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1088  {
1089  auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1090 
1091  if( pRefMark &&
1092  nullptr != (pTextRef = pRefMark->GetTextRefMark()) &&
1093  &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1094  {
1095  if(nCount == nIndex)
1096  {
1097  pRet = pRefMark;
1098  break;
1099  }
1100  nCount++;
1101  }
1102  }
1103  return pRet;
1104 }
1105 
1107 //JP 24.06.96: If the array pointer is 0, then just return whether a RefMark is set in the Doc
1108 // OS 25.06.96: From now on we always return the reference count
1109 sal_uInt16 SwDoc::GetRefMarks( std::vector<OUString>* pNames ) const
1110 {
1111  const SwTextRefMark* pTextRef;
1112 
1113  sal_uInt16 nCount = 0;
1114  for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_REFMARK))
1115  {
1116  auto pRefMark = dynamic_cast<const SwFormatRefMark*>(pItem);
1117 
1118  if( pRefMark &&
1119  nullptr != (pTextRef = pRefMark->GetTextRefMark()) &&
1120  &pTextRef->GetTextNode().GetNodes() == &GetNodes() )
1121  {
1122  if( pNames )
1123  {
1124  OUString aTmp(pRefMark->GetRefName());
1125  pNames->insert(pNames->begin() + nCount, aTmp);
1126  }
1127  ++nCount;
1128  }
1129  }
1130 
1131  return nCount;
1132 }
1133 
1134 static bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs )
1135 {
1136  SwTextNode *pTextNode = rpNd->GetTextNode();
1137  bool bOnlyWrong = *static_cast<sal_Bool*>(pArgs);
1138  if( pTextNode )
1139  {
1140  if( bOnlyWrong )
1141  {
1142  if( pTextNode->GetWrong() &&
1143  pTextNode->GetWrong()->InvalidateWrong() )
1145  if( pTextNode->GetGrammarCheck() &&
1146  pTextNode->GetGrammarCheck()->InvalidateWrong() )
1147  pTextNode->SetGrammarCheckDirty( true );
1148  }
1149  else
1150  {
1152  if( pTextNode->GetWrong() )
1153  pTextNode->GetWrong()->SetInvalid( 0, COMPLETE_STRING );
1154  pTextNode->SetGrammarCheckDirty( true );
1155  if( pTextNode->GetGrammarCheck() )
1156  pTextNode->GetGrammarCheck()->SetInvalid( 0, COMPLETE_STRING );
1157  }
1158  }
1159  return true;
1160 }
1161 
1162 static bool lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void* )
1163 {
1164  SwTextNode *pTextNode = rpNd->GetTextNode();
1165  if( pTextNode )
1166  {
1167  pTextNode->SetSmartTagDirty( true );
1168  if( pTextNode->GetSmartTags() )
1169  {
1170  pTextNode->SetSmartTags( nullptr );
1171  }
1172  }
1173  return true;
1174 }
1175 
1185 void SwDoc::SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags )
1186 {
1187  std::set<SwRootFrame*> aAllLayouts = GetAllLayouts();
1188  assert(getIDocumentLayoutAccess().GetCurrentLayout() && "SpellAgain: Where's my RootFrame?");
1189  if( bInvalid )
1190  {
1191  for ( auto aLayout : aAllLayouts )
1192  {
1193  aLayout->AllInvalidateSmartTagsOrSpelling(bSmartTags);
1194  aLayout->SetNeedGrammarCheck(true);
1195  }
1196  if ( bSmartTags )
1197  GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
1198  GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
1199  }
1200 
1201  for ( auto aLayout : aAllLayouts )
1202  aLayout->SetIdleFlags();
1203 }
1204 
1206 {
1208  if( pTmpRoot )
1209  {
1210  std::set<SwRootFrame*> aAllLayouts = GetAllLayouts();
1211  for( auto aLayout : aAllLayouts )
1212  aLayout->AllInvalidateAutoCompleteWords();
1213  for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
1214  {
1215  SwTextNode* pTextNode = GetNodes()[ nNd ]->GetTextNode();
1216  if ( pTextNode ) pTextNode->SetAutoCompleteWordDirty( true );
1217  }
1218 
1219  for( auto aLayout : aAllLayouts )
1220  aLayout->SetIdleFlags();
1221  }
1222 }
1223 
1224 const SwFormatINetFormat* SwDoc::FindINetAttr( const OUString& rName ) const
1225 {
1226  const SwTextINetFormat* pTextAttr;
1227  const SwTextNode* pTextNd;
1228  for (const SfxPoolItem* pItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_INETFMT))
1229  {
1230  auto pFormatItem = dynamic_cast<const SwFormatINetFormat*>(pItem);
1231  if( pFormatItem &&
1232  pFormatItem->GetName() == rName &&
1233  nullptr != ( pTextAttr = pFormatItem->GetTextINetFormat()) &&
1234  nullptr != ( pTextNd = pTextAttr->GetpTextNode() ) &&
1235  &pTextNd->GetNodes() == &GetNodes() )
1236  {
1237  return pFormatItem;
1238  }
1239  }
1240  return nullptr;
1241 }
1242 
1243 void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress )
1244 {
1245  const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
1246  if( pExtDoc && !rOutNds.empty() )
1247  {
1248  ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
1249  SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
1250  for( SwOutlineNodes::size_type i = 0; i < rOutNds.size(); ++i )
1251  {
1252  ::SetProgressState( static_cast<long>(i), GetDocShell() );
1253  const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
1254 
1255  const int nLvl = GetNodes()[ nIndex ]->GetTextNode()->GetAttrOutlineLevel()-1;
1256  if( nLvl > nLevel )
1257  continue;
1258  long nEndOfs = 1;
1259  sal_uInt8 nWish = nPara;
1260  sal_uLong nNextOutNd = i + 1 < rOutNds.size() ?
1261  rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
1262  bool bKeep = false;
1263  while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
1264  GetNodes()[ nIndex + nEndOfs ]->IsTextNode() )
1265  {
1266  SwTextNode* pTextNode = GetNodes()[ nIndex+nEndOfs ]->GetTextNode();
1267  if (pTextNode->GetText().getLength() && nWish)
1268  --nWish;
1269  bKeep = pTextNode->GetSwAttrSet().GetKeep().GetValue();
1270  ++nEndOfs;
1271  }
1272 
1273  SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs );
1274  GetNodes().Copy_( aRange, aEndOfDoc );
1275  }
1276  const SwTextFormatColls *pColl = pExtDoc->GetTextFormatColls();
1277  for( SwTextFormatColls::size_type i = 0; i < pColl->size(); ++i )
1278  (*pColl)[ i ]->ResetFormatAttr( RES_PAGEDESC, RES_BREAK );
1279  SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
1280  ++aEndOfDoc;
1281  while( aIndx < aEndOfDoc )
1282  {
1283  SwNode *pNode;
1284  bool bDelete = false;
1285  if( (pNode = &aIndx.GetNode())->IsTextNode() )
1286  {
1287  SwTextNode *pNd = pNode->GetTextNode();
1288  if( pNd->HasSwAttrSet() )
1289  pNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
1290  if( bImpress )
1291  {
1292  SwTextFormatColl* pMyColl = pNd->GetTextColl();
1293 
1294  const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
1298  pMyColl = pExtDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nHeadLine );
1299  pNd->ChgFormatColl( pMyColl );
1300  }
1301  if( !pNd->Len() &&
1302  pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
1303  {
1304  bDelete = true;
1305  pExtDoc->GetNodes().Delete( aIndx );
1306  }
1307  }
1308  if( !bDelete )
1309  ++aIndx;
1310  }
1312  }
1313 }
1314 
1315 namespace
1316 {
1317 void RemoveOrDeleteContents(SwTextNode* pTextNd, IDocumentContentOperations& xOperations)
1318 {
1319  SwPaM aPam(*pTextNd, 0, *pTextNd, pTextNd->GetText().getLength());
1320 
1321  // Remove hidden paragraph or delete contents:
1322  // Delete contents if
1323  // 1. removing the paragraph would result in an empty section or
1324  // 2. if the paragraph is the last paragraph in the section and
1325  // there is no paragraph in front of the paragraph:
1326  if ((2 == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1327  || (1 == pTextNd->EndOfSectionIndex() - pTextNd->GetIndex()
1328  && !pTextNd->GetNodes()[pTextNd->GetIndex() - 1]->GetTextNode()))
1329  {
1330  xOperations.DeleteRange(aPam);
1331  }
1332  else
1333  {
1334  aPam.DeleteMark();
1335  xOperations.DelFullPara(aPam);
1336  }
1337 }
1338 // Returns if the data was actually modified
1339 bool HandleHidingField(SwFormatField& rFormatField, const SwNodes& rNodes,
1340  IDocumentContentOperations& xOperations)
1341 {
1342  SwTextNode* pTextNd;
1343  if (rFormatField.GetTextField()
1344  && nullptr != (pTextNd = rFormatField.GetTextField()->GetpTextNode())
1345  && pTextNd->GetpSwpHints() && pTextNd->IsHiddenByParaField()
1346  && &pTextNd->GetNodes() == &rNodes)
1347  {
1348  RemoveOrDeleteContents(pTextNd, xOperations);
1349  return true;
1350  }
1351  return false;
1352 }
1353 }
1354 
1355 // The greater the returned value, the more weight has this field type on deciding the final
1356 // paragraph state
1358 {
1359  switch (eFieldId)
1360  {
1362  return 20;
1363  case SwFieldIds::Database:
1365  ? 10
1366  : 0;
1367  default:
1368  return 0;
1369  }
1370 }
1371 
1372 bool SwDoc::FieldHidesPara(const SwField& rField) const
1373 {
1374  switch (rField.GetTyp()->Which())
1375  {
1377  return static_cast<const SwHiddenParaField&>(rField).IsHidden();
1378  case SwFieldIds::Database:
1380  && rField.ExpandField(true, nullptr).isEmpty();
1381  default:
1382  return false;
1383  }
1384 }
1385 
1387 // Returns if the data was actually modified
1389 {
1390  bool bRet = false;
1392 
1393  {
1394  class FieldTypeGuard : public SwClient
1395  {
1396  public:
1397  explicit FieldTypeGuard(SwFieldType* pType)
1398  : SwClient(pType)
1399  {
1400  }
1401  const SwFieldType* get() const
1402  {
1403  return static_cast<const SwFieldType*>(GetRegisteredIn());
1404  }
1405  };
1406  // Removing some nodes for one SwFieldIds::Database type might remove the type from
1407  // document's field types, invalidating iterators. So, we need to create own list of
1408  // matching types prior to processing them.
1409  std::vector<std::unique_ptr<FieldTypeGuard>> aHidingFieldTypes;
1410  for (std::unique_ptr<SwFieldType> const & pType : *getIDocumentFieldsAccess().GetFieldTypes())
1411  {
1412  if (FieldCanHideParaWeight(pType->Which()))
1413  aHidingFieldTypes.push_back(std::make_unique<FieldTypeGuard>(pType.get()));
1414  }
1415  for (const auto& pTypeGuard : aHidingFieldTypes)
1416  {
1417  if (const SwFieldType* pType = pTypeGuard->get())
1418  {
1420  for (SwFormatField* pFormatField = aIter.First(); pFormatField;
1421  pFormatField = aIter.Next())
1422  bRet |= HandleHidingField(*pFormatField, GetNodes(),
1424  }
1425  }
1426  }
1427 
1428  // Remove any hidden paragraph (hidden text attribute)
1429  for( sal_uLong n = GetNodes().Count(); n; )
1430  {
1431  SwTextNode* pTextNd = GetNodes()[ --n ]->GetTextNode();
1432  if ( pTextNd )
1433  {
1434  bool bRemoved = false;
1435  if ( pTextNd->HasHiddenCharAttribute( true ) )
1436  {
1437  bRemoved = true;
1438  bRet = true;
1439 
1440  if (2 == pTextNd->EndOfSectionIndex() - pTextNd->StartOfSectionIndex())
1441  {
1442  SwFrameFormat *const pFormat = pTextNd->StartOfSectionNode()->GetFlyFormat();
1443  if (nullptr != pFormat)
1444  {
1445  // remove hidden text frame
1447  }
1448  else
1449  {
1450  // default, remove hidden paragraph
1451  RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1452  }
1453  }
1454  else
1455  {
1456  // default, remove hidden paragraph
1457  RemoveOrDeleteContents(pTextNd, getIDocumentContentOperations());
1458  }
1459  }
1460  else if ( pTextNd->HasHiddenCharAttribute( false ) )
1461  {
1462  bRemoved = true;
1463  bRet = true;
1465  }
1466 
1467  // Footnotes/Frames may have been removed, therefore we have
1468  // to reset n:
1469  if ( bRemoved )
1470  {
1471  // [n] has to be inside [0 .. GetNodes().Count()] range
1472  if (n > GetNodes().Count())
1473  n = GetNodes().Count();
1474  }
1475  }
1476  }
1477 
1478  {
1479  // Delete/empty all hidden areas
1481  SwSectionFormats& rSectFormats = GetSections();
1482 
1483  for( SwSectionFormats::size_type n = rSectFormats.size(); n; )
1484  {
1485  SwSectionFormat* pSectFormat = rSectFormats[ --n ];
1486  // don't add sections in Undo/Redo
1487  if( !pSectFormat->IsInNodesArr())
1488  continue;
1489  SwSection* pSect = pSectFormat->GetSection();
1490  if( pSect->CalcHiddenFlag() )
1491  {
1492  SwSection* pParent = pSect, *pTmp;
1493  while( nullptr != (pTmp = pParent->GetParent() ))
1494  {
1495  if( pTmp->IsHiddenFlag() )
1496  pSect = pTmp;
1497  pParent = pTmp;
1498  }
1499 
1500  aSectFormats.insert( pSect->GetFormat() );
1501  }
1502  if( !pSect->GetCondition().isEmpty() )
1503  {
1504  SwSectionData aSectionData( *pSect );
1505  aSectionData.SetCondition( OUString() );
1506  aSectionData.SetHidden( false );
1507  UpdateSection( n, aSectionData );
1508  }
1509  }
1510 
1511  auto n = aSectFormats.size();
1512 
1513  if( 0 != n )
1514  {
1515  while( n )
1516  {
1517  SwSectionFormat* pSectFormat = aSectFormats[ --n ];
1518  SwSectionNode* pSectNd = pSectFormat->GetSectionNode();
1519  if( pSectNd )
1520  {
1521  bRet = true;
1522  SwPaM aPam( *pSectNd );
1523 
1524  if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() ==
1525  pSectNd->GetIndex() - 1 &&
1526  pSectNd->StartOfSectionNode()->EndOfSectionIndex() ==
1527  pSectNd->EndOfSectionIndex() + 1 )
1528  {
1529  // only delete the content
1530  SwContentNode* pCNd = GetNodes().GoNext(
1531  &aPam.GetPoint()->nNode );
1532  aPam.GetPoint()->nContent.Assign( pCNd, 0 );
1533  aPam.SetMark();
1534  aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
1535  pCNd = SwNodes::GoPrevious(
1536  &aPam.GetPoint()->nNode );
1537  aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1538 
1540  }
1541  else
1542  {
1543  // delete the whole section
1544  aPam.SetMark();
1545  aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
1547  }
1548 
1549  }
1550  }
1551  }
1552  }
1553 
1554  if( bRet )
1557  return bRet;
1558 }
1559 
1561 {
1563  return true;
1564 
1565  // Search for any hidden paragraph (hidden text attribute)
1566  for( sal_uLong n = GetNodes().Count()-1; n; --n)
1567  {
1568  SwTextNode* pTextNd = GetNodes()[ n ]->GetTextNode();
1569  if ( pTextNd &&
1570  ( pTextNd->HasHiddenCharAttribute( true ) || pTextNd->HasHiddenCharAttribute( false ) ) )
1571  return true;
1572  }
1573 
1574  for(auto pSectFormat : GetSections())
1575  {
1576  // don't add sections in Undo/Redo
1577  if( !pSectFormat->IsInNodesArr())
1578  continue;
1579  SwSection* pSect = pSectFormat->GetSection();
1580  if( pSect->IsHidden() )
1581  return true;
1582  }
1583  return false;
1584 }
1585 
1587 {
1588  SwUndoId nLastUndoId(SwUndoId::EMPTY);
1589  if (GetIDocumentUndoRedo().GetLastUndoInfo(nullptr, & nLastUndoId)
1590  && (SwUndoId::UI_DELETE_INVISIBLECNTNT == nLastUndoId))
1591  {
1594  return true;
1595  }
1596  return false;
1597 }
1598 
1600 {
1601  bool bRet = false;
1604 
1605  const SwFieldTypes* pMyFieldTypes = getIDocumentFieldsAccess().GetFieldTypes();
1606  const SwFieldTypes::size_type nCount = pMyFieldTypes->size();
1607  //go backward, field types are removed
1608  for(SwFieldTypes::size_type nType = nCount; nType > 0; --nType)
1609  {
1610  const SwFieldType *pCurType = (*pMyFieldTypes)[nType - 1].get();
1611 
1612  if ( SwFieldIds::Postit == pCurType->Which() )
1613  continue;
1614 
1615  SwIterator<SwFormatField,SwFieldType> aIter( *pCurType );
1616  std::vector<const SwFormatField*> aFieldFormats;
1617  for( SwFormatField* pCurFieldFormat = aIter.First(); pCurFieldFormat; pCurFieldFormat = aIter.Next() )
1618  aFieldFormats.push_back(pCurFieldFormat);
1619 
1620  for(const auto& rpFieldFormat : aFieldFormats)
1621  {
1622  const SwTextField *pTextField = rpFieldFormat->GetTextField();
1623  // skip fields that are currently not in the document
1624  // e.g. fields in undo or redo array
1625 
1626  bool bSkip = !pTextField ||
1627  !pTextField->GetpTextNode()->GetNodes().IsDocNodes();
1628 
1629  if (!bSkip)
1630  {
1631  bool bInHeaderFooter = IsInHeaderFooter(SwNodeIndex(*pTextField->GetpTextNode()));
1632  const SwFormatField& rFormatField = pTextField->GetFormatField();
1633  const SwField* pField = rFormatField.GetField();
1634 
1635  //#i55595# some fields have to be excluded in headers/footers
1636  SwFieldIds nWhich = pField->GetTyp()->Which();
1637  if(!bInHeaderFooter ||
1638  (nWhich != SwFieldIds::PageNumber &&
1639  nWhich != SwFieldIds::Chapter &&
1640  nWhich != SwFieldIds::GetExp&&
1641  nWhich != SwFieldIds::SetExp&&
1642  nWhich != SwFieldIds::Input&&
1643  nWhich != SwFieldIds::RefPageGet&&
1644  nWhich != SwFieldIds::RefPageSet))
1645  {
1646  OUString sText = pField->ExpandField(true, &rLayout);
1647 
1648  // database fields should not convert their command into text
1649  if( SwFieldIds::Database == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
1650  sText.clear();
1651 
1652  SwPaM aInsertPam(*pTextField->GetpTextNode(), pTextField->GetStart());
1653  aInsertPam.SetMark();
1654 
1655  // go to the end of the field
1656  const SwTextField *pFieldAtEnd = sw::DocumentFieldsManager::GetTextFieldAtPos(*aInsertPam.End());
1657  if (pFieldAtEnd && pFieldAtEnd->Which() == RES_TXTATR_INPUTFIELD)
1658  {
1659  SwPosition &rEndPos = *aInsertPam.GetPoint();
1660  rEndPos.nContent = SwCursorShell::EndOfInputFieldAtPos( *aInsertPam.End() );
1661  }
1662  else
1663  {
1664  aInsertPam.Move();
1665  }
1666 
1667  // first insert the text after field to keep the field's attributes,
1668  // then delete the field
1669  if (!sText.isEmpty())
1670  {
1671  // to keep the position after insert
1672  SwPaM aDelPam( *aInsertPam.GetMark(), *aInsertPam.GetPoint() );
1673  aDelPam.Move( fnMoveBackward );
1674  aInsertPam.DeleteMark();
1675 
1676  getIDocumentContentOperations().InsertString( aInsertPam, sText );
1677 
1678  aDelPam.Move();
1679  // finally remove the field
1681  }
1682  else
1683  {
1685  }
1686 
1687  bRet = true;
1688  }
1689  }
1690  }
1691  }
1692 
1693  if( bRet )
1697  return bRet;
1698 
1699 }
1700 
1702 {
1703  return SW_MOD()->IsInsTableFormatNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1704 }
1705 
1707 {
1708  return SW_MOD()->IsInsTableChangeNumFormat(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1709 }
1710 
1712 {
1713  return SW_MOD()->IsInsTableAlignNum(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1714 }
1715 
1717 {
1718  return SW_MOD()->IsSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE));
1719 }
1720 
1722 {
1723  SW_MOD()->SetSplitVerticalByDefault(GetDocumentSettingManager().get(DocumentSettingId::HTML_MODE), value);
1724 }
1725 
1727 void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable )
1728 {
1729  if( bIsTable )
1730  {
1731  const SwTableNode* pTableNd = rPam.GetPoint()->nNode.GetNode().FindTableNode();
1732  if( pTableNd )
1733  {
1734  std::unique_ptr<SwUndoCpyTable> pUndo(new SwUndoCpyTable(this));
1735  pUndo->SetTableSttIdx( pTableNd->GetIndex() );
1736  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1737  }
1738  }
1739  else if( rPam.HasMark() )
1740  {
1741  std::unique_ptr<SwUndoCpyDoc> pUndo(new SwUndoCpyDoc( rPam ));
1742  pUndo->SetInsertRange( rPam, false );
1743  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1744  }
1745 }
1746 
1747 void SwDoc::ChangeTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
1748 {
1749  assert(dynamic_cast<const SwTOXBaseSection*>(&rTOX));
1750  SwTOXBaseSection& rTOXSect(static_cast<SwTOXBaseSection&>(rTOX));
1751 
1752  if (GetIDocumentUndoRedo().DoesUndo())
1753  {
1755  std::make_unique<SwUndoTOXChange>(this, rTOXSect, rNew));
1756  }
1757 
1758  rTOX = rNew;
1759 
1760  // note: do not Update the ToX here - the caller will do it, with a ViewShell!
1761 }
1762 
1763 OUString SwDoc::GetPaMDescr(const SwPaM & rPam)
1764 {
1765  if (&rPam.GetNode() == &rPam.GetNode(false))
1766  {
1767  SwTextNode * pTextNode = rPam.GetNode().GetTextNode();
1768 
1769  if (nullptr != pTextNode)
1770  {
1771  const sal_Int32 nStart = rPam.Start()->nContent.GetIndex();
1772  const sal_Int32 nEnd = rPam.End()->nContent.GetIndex();
1773 
1774  return SwResId(STR_START_QUOTE)
1775  + ShortenString(pTextNode->GetText().copy(nStart, nEnd - nStart),
1777  SwResId(STR_LDOTS))
1778  + SwResId(STR_END_QUOTE);
1779  }
1780  }
1781  else
1782  {
1783  return SwResId(STR_PARAGRAPHS);
1784  }
1785 
1786  return "??";
1787 }
1788 
1790 {
1791  for( sal_uLong n = GetNodes().Count(); n; )
1792  {
1793  SwNode* pNd = GetNodes()[ --n ];
1794  if ( pNd->IsTextNode() && pNd->GetTextNode()->HasHiddenCharAttribute( false ) )
1795  return true;
1796  }
1797 
1798  return false;
1799 }
1800 
1801 std::shared_ptr<SwUnoCursor> SwDoc::CreateUnoCursor( const SwPosition& rPos, bool bTableCursor )
1802 {
1803  std::shared_ptr<SwUnoCursor> pNew;
1804  if( bTableCursor )
1805  pNew = std::make_shared<SwUnoTableCursor>(rPos);
1806  else
1807  pNew = std::make_shared<SwUnoCursor>(rPos);
1808 
1809  mvUnoCursorTable.push_back( pNew );
1810  return pNew;
1811 }
1812 
1814 {
1815  for (SwTextFormatColls::size_type n = 0; n < mpTextFormatCollTable->size(); ++n)
1816  {
1817  SwTextFormatColl *pColl = (*mpTextFormatCollTable)[n];
1818  if (RES_CONDTXTFMTCOLL == pColl->Which())
1819  pColl->CallSwClientNotify( SwAttrHint() );
1820  }
1821 }
1822 
1823 uno::Reference< script::vba::XVBAEventProcessor > const &
1825 {
1826 #if HAVE_FEATURE_SCRIPTING
1828  {
1829  try
1830  {
1831  uno::Reference< frame::XModel > xModel( mpDocShell->GetModel(), uno::UNO_SET_THROW );
1832  uno::Sequence< uno::Any > aArgs(1);
1833  aArgs[0] <<= xModel;
1834  mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW );
1835  }
1836  catch( uno::Exception& )
1837  {
1838  }
1839  }
1840 #endif
1841  return mxVbaEvents;
1842 }
1843 
1844 void SwDoc::SetMissingDictionaries( bool bIsMissing )
1845 {
1846  if (!bIsMissing)
1847  meDictionaryMissing = MissingDictionary::False;
1848  else if (meDictionaryMissing == MissingDictionary::Undefined)
1849  meDictionaryMissing = MissingDictionary::True;
1850 };
1851 
1852 
1853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsInsTableChangeNumFormat() const
Definition: doc.cxx:1706
Date GetDate() const
Definition: docufld.hxx:474
void AppendUndoForInsertFromDB(const SwPaM &rPam, bool bIsTable)
Set up the InsertDB as Undo table.
Definition: doc.cxx:1727
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
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:775
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:1801
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_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:1813
#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:1701
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:2480
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:1346
bool HasInvisibleContent() const
Definition: doc.cxx:1560
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:1711
const std::unique_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager
Definition: doc.hxx:222
SwNodeIndex nNode
Definition: pam.hxx:37
SwDBManager * m_pDBManager
Definition: doc.hxx:249
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:273
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
sal_Int64 n
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:1294
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
Definition: doc.cxx:344
bool ConvertFieldsToText(SwRootFrame const &rLayout)
Definition: doc.cxx:1599
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:1586
SwSectionFormat * GetFormat()
Definition: section.hxx:337
SwSection * GetParent() const
Definition: section.hxx:347
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:2190
float x
bool HasWriterListeners() const
Definition: calbck.hxx:208
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2246
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: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:1065
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: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: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:914
bool HasHiddenCharAttribute(bool bWholePara) const
Hidden Paragraph Field:
Definition: ndtxt.hxx:720
int nCount
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
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:711
void CommitLastRegistrations()
Accept not committed registrations.
Definition: dbmgr.cxx:3289
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:549
virtual bool Undo()=0
Execute Undo.
void SetWrongDirty(WrongState eNew) const
Definition: txtedt.cxx:2228
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:603
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:56
void SetProgressState(long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:82
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:201
static OUString GetPaMDescr(const SwPaM &rPaM)
Returns a textual description of a PaM.
Definition: doc.cxx:1763
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:495
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:1789
css::uno::Reference< css::script::vba::XVBAEventProcessor > const & GetVbaEventProcessor()
Definition: doc.cxx:1824
MissingDictionary meDictionaryMissing
Definition: doc.hxx:318
void ResetIdleFormat()
Definition: rootfrm.hxx:257
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2259
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: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:1630
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:1721
Count
const SwFormatRefMark * GetRefMark(const OUString &rName) const
Definition: doc.cxx:1064
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
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:2272
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2180
size_t size() const
Definition: docary.hxx:91
unsigned char sal_Bool
virtual SwFormatColl * ChgFormatColl(SwFormatColl *) override
Definition: ndtxt.cxx:3920
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:1109
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:1844
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:2205
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:894
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:1357
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:680
void ChangeTOX(SwTOXBase &rTOX, const SwTOXBase &rNew)
Definition: doc.cxx:1747
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:1185
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: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: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:514
bool HasPostItData() const
Definition: printdata.hxx:244
const SwFormatINetFormat * FindINetAttr(const OUString &rName) const
Definition: doc.cxx:1224
static bool lcl_SpellAndGrammarAgain(const SwNodePtr &rpNd, void *pArgs)
Definition: doc.cxx:1134
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:658
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:1498
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:227
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:185
bool FieldHidesPara(const SwField &rField) const
Definition: doc.cxx:1372
::sw::MetaFieldManager & GetMetaFieldManager()
Definition: doc.cxx:127
Get information about the current document state.
SwWrongList * GetWrong()
Definition: txtedt.cxx:2157
::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:1388
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:1522
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:2313
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:1162
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:469
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:671
std::pair< const_iterator, bool > insert(Value &&x)
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: ndtxt.cxx:5113
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:161
::sw::DocumentFieldsManager & GetDocumentFieldsManager()
Definition: doc.cxx:366
SwSectionFormats & GetSections()
Definition: doc.hxx:1332
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:1716
aStr
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61
void SetInvalid(sal_Int32 nBegin, sal_Int32 nEnd)
Definition: wrong.cxx:253
const int nUndoStringLength
Definition: UndoCore.hxx:224
bool GetResolved() const
Definition: docufld.cxx:1774
sal_Int64 getIntValue(const OUString &i_rPropertyName, sal_Int64 i_nDefault) const
sal_uInt16 nPos
void InvalidateAutoCompleteFlag()
Definition: doc.cxx:1205
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1313
bool IsPrintEmptyPages(bool bIsPDFExport) const
Definition: printdata.cxx:405
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:248
void Summary(SwDoc *pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress)
Definition: doc.cxx:1243
SwFrame * GetNext()
Definition: frame.hxx:654
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:836