LibreOffice Module sw (master)  1
vprint.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 
21 #include <hintids.hxx>
22 #include <sfx2/printer.hxx>
23 #include <svx/svdview.hxx>
24 
25 #include <txtfld.hxx>
26 #include <fmtfld.hxx>
27 #include <fmtfsize.hxx>
28 #include <rootfrm.hxx>
29 #include <pagefrm.hxx>
30 #include <cntfrm.hxx>
31 #include <doc.hxx>
32 #include <IDocumentUndoRedo.hxx>
36 #include <fesh.hxx>
37 #include <pam.hxx>
38 #include <viewimp.hxx>
39 #include <layact.hxx>
40 #include <ndtxt.hxx>
41 #include <viewopt.hxx>
42 #include <printdata.hxx>
43 #include <pagedesc.hxx>
44 #include <ptqueue.hxx>
45 #include <viscrs.hxx>
46 #include <fmtpdsc.hxx>
47 #include <PostItMgr.hxx>
48 #include "vprint.hxx"
49 
50 using namespace ::com::sun::star;
51 
54 {
55 public:
57  SwViewShell* const pSh;
59 
60  SwQueuedPaint( SwViewShell *pNew, const SwRect &rRect ) :
61  pNext( nullptr ),
62  pSh( pNew ),
63  aRect( rRect )
64  {}
65 };
66 
68 
69 namespace {
70 
71 // saves some settings from the draw view
72 class SwDrawViewSave
73 {
74  SdrView* pDV;
75  bool bPrintControls;
76 public:
77  explicit SwDrawViewSave( SdrView* pSdrView );
78  ~SwDrawViewSave();
79 };
80 
81 }
82 
83 void SwPaintQueue::Add( SwViewShell *pNew, const SwRect &rNew )
84 {
85  SwQueuedPaint *pPt;
86  if (nullptr != (pPt = s_pPaintQueue))
87  {
88  while ( pPt->pSh != pNew && pPt->pNext )
89  pPt = pPt->pNext;
90  if ( pPt->pSh == pNew )
91  {
92  pPt->aRect.Union( rNew );
93  return;
94  }
95  }
96  SwQueuedPaint *pNQ = new SwQueuedPaint( pNew, rNew );
97  if ( pPt )
98  pPt->pNext = pNQ;
99  else
100  s_pPaintQueue = pNQ;
101 }
102 
104 {
106  {
108  do
109  { SwViewShell *pSh = pPt->pSh;
110  SET_CURR_SHELL( pSh );
111  if ( pSh->IsPreview() )
112  {
113  if ( pSh->GetWin() )
114  {
115  // for previewing, since rows/columns are known in PaintHdl (UI)
116  pSh->GetWin()->Invalidate();
117  pSh->GetWin()->Update();
118  }
119  }
120  else
121  pSh->Paint(*pSh->GetOut(), pPt->aRect.SVRect());
122  pPt = pPt->pNext;
123  } while ( pPt );
124 
125  do
126  {
127  pPt = s_pPaintQueue;
129  delete pPt;
130  } while (s_pPaintQueue);
131  }
132 }
133 
135 {
136  SwQueuedPaint *pPt;
137  if (nullptr != (pPt = s_pPaintQueue))
138  {
139  SwQueuedPaint *pPrev = nullptr;
140  while ( pPt && pPt->pSh != pSh )
141  {
142  pPrev = pPt;
143  pPt = pPt->pNext;
144  }
145  if ( pPt )
146  {
147  if ( pPrev )
148  pPrev->pNext = pPt->pNext;
149  else if (pPt == s_pPaintQueue)
150  s_pPaintQueue = nullptr;
151  delete pPt;
152  }
153  }
154 }
155 
156 void SetSwVisArea( SwViewShell *pSh, const SwRect &rRect )
157 {
158  OSL_ENSURE( !pSh->GetWin(), "Print with window?" );
159  pSh->maVisArea = rRect;
160  pSh->Imp()->SetFirstVisPageInvalid();
161  Point aPt( rRect.Pos() );
162 
163  // calculate an offset for the rectangle of the n-th page to
164  // move the start point of the output operation to a position
165  // such that in the output device all pages will be painted
166  // at the same position
167  aPt.setX( -aPt.X() ); aPt.setY( -aPt.Y() );
168 
169  vcl::RenderContext *pOut = pSh->GetOut();
170 
171  MapMode aMapMode( pOut->GetMapMode() );
172  aMapMode.SetOrigin( aPt );
173  pOut->SetMapMode( aMapMode );
174 }
175 
177 {
178  // For printing we use a negative offset (exactly the offset of OutputSize).
179  // This is necessary because the origin is in the upper left corner of the
180  // physical page while the output uses OutputOffset as origin.
181  if ( pOutDev )
182  {
183  maPrtOffset = Point();
184 
185  maPrtOffset += pOutDev->GetMapMode().GetOrigin();
186  MapMode aMapMode( pOutDev->GetMapMode() );
187  aMapMode.SetMapUnit( MapUnit::MapTwip );
188  pOutDev->SetMapMode( aMapMode );
189  pOutDev->SetLineColor();
190  pOutDev->SetFillColor();
191  }
192  else
193  {
194  maPrtOffset.setX(0);
195  maPrtOffset.setY(0);
196  }
197 
198  if ( !mpWin )
199  mpOut = pOutDev;
200 }
201 
203 {
204  OSL_ENSURE( mnStartAction, "missing an Action" );
205  SET_CURR_SHELL( this );
206 
207  const size_t nAll = GetDoc()->GetPageDescCnt();
208  bool bNewOri = eOri != Orientation::Portrait;
209 
210  for( size_t i = 0; i < nAll; ++ i )
211  {
212  const SwPageDesc& rOld = GetDoc()->GetPageDesc( i );
213 
214  if( rOld.GetLandscape() != bNewOri )
215  {
216  SwPageDesc aNew( rOld );
217  {
219  GetDoc()->CopyPageDesc(rOld, aNew);
220  }
221  aNew.SetLandscape( bNewOri );
222  SwFrameFormat& rFormat = aNew.GetMaster();
223  SwFormatFrameSize aSz( rFormat.GetFrameSize() );
224  // adjust size
225  // PORTRAIT -> higher than wide
226  // LANDSCAPE -> wider than high
227  // Height is the VarSize, width the FixSize (per Def.)
228  if( bNewOri ? aSz.GetHeight() > aSz.GetWidth()
229  : aSz.GetHeight() < aSz.GetWidth() )
230  {
231  SwTwips aTmp = aSz.GetHeight();
232  aSz.SetHeight( aSz.GetWidth() );
233  aSz.SetWidth( aTmp );
234  rFormat.SetFormatAttr( aSz );
235  }
236  GetDoc()->ChgPageDesc( i, aNew );
237  }
238  }
239 }
240 
242 {
243  OSL_ENSURE( mnStartAction, "missing an Action" );
244  SET_CURR_SHELL( this );
245 
246  SwDoc* pMyDoc = GetDoc();
247  const size_t nAll = pMyDoc->GetPageDescCnt();
248 
249  for( size_t i = 0; i < nAll; ++i )
250  {
251  const SwPageDesc &rOld = pMyDoc->GetPageDesc( i );
252  SwPageDesc aNew( rOld );
253  {
255  GetDoc()->CopyPageDesc( rOld, aNew );
256  }
257  SwFrameFormat& rPgFormat = aNew.GetMaster();
258  Size aSz( rSz );
259  const bool bOri = aNew.GetLandscape();
260  if( bOri ? aSz.Height() > aSz.Width()
261  : aSz.Height() < aSz.Width() )
262  {
263  SwTwips aTmp = aSz.Height();
264  aSz.setHeight( aSz.Width() );
265  aSz.setWidth( aTmp );
266  }
267 
268  SwFormatFrameSize aFrameSz( rPgFormat.GetFrameSize() );
269  aFrameSz.SetSize( aSz );
270  rPgFormat.SetFormatAttr( aFrameSz );
271  pMyDoc->ChgPageDesc( i, aNew );
272  }
273 }
274 
275 void SwViewShell::CalcPagesForPrint( sal_uInt16 nMax )
276 {
277  SET_CURR_SHELL( this );
278 
279  SwRootFrame* pMyLayout = GetLayout();
280 
281  const SwFrame *pPage = pMyLayout->Lower();
282  SwLayAction aAction( pMyLayout, Imp() );
283 
284  pMyLayout->StartAllAction();
285  for ( sal_uInt16 i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i )
286  {
287  pPage->Calc(GetOut());
288  SwRect aOldVis( VisArea() );
289  maVisArea = pPage->getFrameArea();
291  aAction.Reset();
292  aAction.SetPaint( false );
293  aAction.SetWaitAllowed( false );
294  aAction.SetReschedule( true );
295 
296  aAction.Action(GetOut());
297 
298  maVisArea = aOldVis; //reset due to the paints
300  }
301 
302  pMyLayout->EndAllAction();
303 }
304 
305 void SwViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
306 {
307  OSL_ENSURE( dynamic_cast<const SwFEShell*>( this) != nullptr,"SwViewShell::Prt for FEShell only");
308  SwFEShell* pFESh = static_cast<SwFEShell*>(this);
310 
311  // use given printer
314  if (pPrt)
315  pPrtDoc->getIDocumentDeviceAccess().setPrinter( VclPtr<SfxPrinter>::Create(*pPrt), true, true );
316 
317  const SfxItemPool& rPool = GetAttrPool();
318  for( sal_uInt16 nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh )
319  {
320  const SfxPoolItem* pCpyItem = rPool.GetPoolDefaultItem( nWh );
321  if( nullptr != pCpyItem )
322  pPrtDoc->GetAttrPool().SetPoolDefaultItem( *pCpyItem );
323  }
324 
325  // JP 29.07.99 - Bug 67951 - set all Styles from the SourceDoc into
326  // the PrintDoc - will be replaced!
327  pPrtDoc->ReplaceStyles( *GetDoc() );
328 
329  SwShellCursor *pActCursor = pFESh->GetCursor_();
330  SwShellCursor *pFirstCursor = pActCursor->GetNext();
331  if( !pActCursor->HasMark() ) // with a multi-selection the current cursor might be empty
332  {
333  pActCursor = pActCursor->GetPrev();
334  }
335 
336  // Y-position of the first selection
337  Point aSelPoint;
338  if( pFESh->IsTableMode() )
339  {
340  SwShellTableCursor* pShellTableCursor = pFESh->GetTableCursor();
341 
342  const SwContentNode *const pContentNode =
343  pShellTableCursor->Start()->nNode.GetNode().GetContentNode();
344  const SwContentFrame *const pContentFrame = pContentNode ? pContentNode->getLayoutFrame(GetLayout(), pShellTableCursor->Start()) : nullptr;
345  if( pContentFrame )
346  {
347  SwRect aCharRect;
348  SwCursorMoveState aTmpState( MV_NONE );
349  pContentFrame->GetCharRect( aCharRect, *pShellTableCursor->Start(), &aTmpState );
350  aSelPoint = Point( aCharRect.Left(), aCharRect.Top() );
351  }
352  }
353  else if (pFirstCursor)
354  {
355  aSelPoint = pFirstCursor->GetSttPos();
356  }
357 
358  const SwPageFrame* pPage = GetLayout()->GetPageAtPos( aSelPoint );
359  OSL_ENSURE( pPage, "no page found!" );
360 
361  // get page descriptor - fall back to the first one if pPage could not be found
362  const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDesc(
363  pPage->GetPageDesc()->GetName() ) : &pPrtDoc->GetPageDesc( 0 );
364 
365  if( !pFESh->IsTableMode() && pActCursor && pActCursor->HasMark() )
366  { // Tweak paragraph attributes of last paragraph
367  SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
368  SwTextNode* pTextNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx )->GetTextNode();
369  SwContentNode *pLastNd =
370  pActCursor->GetContentNode( (*pActCursor->GetMark()) <= (*pActCursor->GetPoint()) );
371  // copy the paragraph attributes of the first paragraph
372  if( pLastNd && pLastNd->IsTextNode() )
373  static_cast<SwTextNode*>(pLastNd)->CopyCollFormat( *pTextNd );
374  }
375 
376  // fill it with the selected content
377  pFESh->Copy( pPrtDoc );
378 
379  // set the page style at the first paragraph
380  {
381  SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
382  SwContentNode* pCNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx ); // go to 1st ContentNode
383  if( pFESh->IsTableMode() )
384  {
385  SwTableNode* pTNd = pCNd->FindTableNode();
386  if( pTNd )
387  pTNd->GetTable().GetFrameFormat()->SetFormatAttr( SwFormatPageDesc( pPageDesc ) );
388  }
389  else
390  {
391  pCNd->SetAttr( SwFormatPageDesc( pPageDesc ) );
392  if( pFirstCursor && pFirstCursor->HasMark() )
393  {
394  SwTextNode *pTextNd = pCNd->GetTextNode();
395  if( pTextNd )
396  {
397  SwContentNode *pFirstNd =
398  pFirstCursor->GetContentNode( (*pFirstCursor->GetMark()) > (*pFirstCursor->GetPoint()) );
399  // copy paragraph attributes of the first paragraph
400  if( pFirstNd && pFirstNd->IsTextNode() )
401  static_cast<SwTextNode*>(pFirstNd)->CopyCollFormat( *pTextNd );
402  }
403  }
404  }
405  }
406 }
407 
408 // TODO: there is already a GetPageByPageNum, but it checks some physical page
409 // number; unsure if we want that here, should find out what that is...
410 SwPageFrame const*
411 sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage)
412 {
413  // yes this is O(n^2) but at least it does not crash...
414  SwPageFrame const* pPage = dynamic_cast<const SwPageFrame*>(rLayout.Lower());
415  for (sal_Int32 i = nPage; pPage && (i > 0); --i)
416  {
417  if (1 == i) { // note: nPage is 1-based, i.e. 0 is invalid!
418  return pPage;
419  }
420  pPage = dynamic_cast<SwPageFrame const*>(pPage->GetNext());
421  }
422  OSL_ENSURE(pPage, "ERROR: SwPageFrame expected");
423  OSL_FAIL("non-existent page requested");
424  return nullptr;
425 }
426 
428  OutputDevice *pOutDev,
429  SwPrintData const& rPrintData,
430  sal_Int32 nRenderer, /* the index in the vector of pages to be printed */
431  bool bIsPDFExport )
432 {
433  // CAUTION: Do also always update the printing routines in viewpg.cxx (PrintProspect)!
434 
435  const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
436  OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
437  if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
438  return false;
439 
440  // save settings of OutputDevice (should be done always since the
441  // output device is now provided by a call from outside the Writer)
442  pOutDev->Push();
443 
444  // fdo#36815 for comments in margins print to a metafile
445  // and then scale that metafile down so that the comments
446  // will fit on the real page, and replay that scaled
447  // output to the real outputdevice
448  GDIMetaFile *pOrigRecorder(nullptr);
449  std::unique_ptr<GDIMetaFile> pMetaFile;
450  SwPostItMode nPostItMode = rPrintData.GetPrintPostIts();
451 
452  // tdf#91680 Reserve space in margin for comments only if there are comments
453  const bool bHasPostItsToPrintInMargins = ( nPostItMode == SwPostItMode::InMargins ) &&
455 
456  if ( bHasPostItsToPrintInMargins )
457  {
458  //get and disable the existing recorder
459  pOrigRecorder = pOutDev->GetConnectMetaFile();
460  pOutDev->SetConnectMetaFile(nullptr);
461  // turn off output to the device
462  pOutDev->EnableOutput(false);
463  // just record the rendering commands to the metafile
464  // instead
465  pMetaFile.reset(new GDIMetaFile);
466  pMetaFile->SetPrefSize(pOutDev->GetOutputSize());
467  pMetaFile->SetPrefMapMode(pOutDev->GetMapMode());
468  pMetaFile->Record(pOutDev);
469  }
470 
471  // Print/PDF export for (multi-)selection has already generated a
472  // temporary document with the selected text.
473  // (see XRenderable implementation in unotxdoc.cxx)
474  // It is implemented this way because PDF export calls this Prt function
475  // once per page and we do not like to always have the temporary document
476  // to be created that often here.
477  std::unique_ptr<SwViewShell> pShell(new SwViewShell(*this, nullptr, pOutDev));
478 
479  SdrView *pDrawView = pShell->GetDrawView();
480  if (pDrawView)
481  {
482  pDrawView->SetBufferedOutputAllowed( false );
483  pDrawView->SetBufferedOverlayAllowed( false );
484  }
485 
486  { // additional scope so that the CurrShell is reset before destroying the shell
487 
488  SET_CURR_SHELL( pShell.get() );
489 
490  //JP 01.02.99: Bug 61335 - the ReadOnly flag is never copied
491  if( mpOpt->IsReadonly() )
492  pShell->mpOpt->SetReadonly( true );
493 
494  // save options at draw view:
495  SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
496  pShell->PrepareForPrint( rPrintData, bIsPDFExport );
497 
498  const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
499  OSL_ENSURE( nPage < 0 ||
500  rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1,
501  "SwViewShell::PrintOrPDFExport: nPage not valid" );
502  SwViewShell *const pViewSh2 = (nPage < 0)
503  ? rPrintData.GetRenderData().m_pPostItShell.get()// post-it page
504  : pShell.get(); // a 'regular' page, not one from the post-it doc
505 
506  SwPageFrame const*const pStPage =
507  sw_getPage(*pViewSh2->GetLayout(), abs(nPage));
508  OSL_ENSURE( pStPage, "failed to get start page" );
509  if (!pStPage)
510  {
511  return false;
512  }
513 
515 
516  ::SetSwVisArea( pViewSh2, pStPage->getFrameArea() );
517 
518  pShell->InitPrt(pOutDev);
519 
520  ::SetSwVisArea( pViewSh2, pStPage->getFrameArea() );
521 
522  pStPage->GetUpper()->PaintSwFrame( *pOutDev, pStPage->getFrameArea(), &rPrintData );
523 
525 
526  SwPostItMgr *pPostItManager = bHasPostItsToPrintInMargins ? pShell->GetPostItMgr() : nullptr;
527 
528  if (pPostItManager)
529  {
530  pPostItManager->CalcRects();
531  pPostItManager->LayoutPostIts();
532  pPostItManager->DrawNotesForPage(pOutDev, nPage-1);
533 
534  //Stop recording now
535  pMetaFile->Stop();
536  pMetaFile->WindStart();
537  //Enable output to the device again
538  pOutDev->EnableOutput();
539  //Restore the original recorder
540  pOutDev->SetConnectMetaFile(pOrigRecorder);
541 
542  //Now scale the recorded page down so the notes
543  //will fit in the final page
544  double fScale = 0.75;
545  long nOrigHeight = pStPage->getFrameArea().Height();
546  long nNewHeight = nOrigHeight*fScale;
547  long nShiftY = (nOrigHeight-nNewHeight)/2;
548  pMetaFile->Scale( fScale, fScale );
549  pMetaFile->WindStart();
550  //Move the scaled page down to center it
551  //the other variant of Move does not map pixels
552  //back to the logical units correctly
553  pMetaFile->Move(0, convertTwipToMm100(nShiftY), pOutDev->GetDPIX(), pOutDev->GetDPIY());
554  pMetaFile->WindStart();
555 
556  //play back the scaled page
557  pMetaFile->Play(pOutDev);
558  pMetaFile.reset();
559  }
560  }
561 
562  pShell.reset();
563 
564  // restore settings of OutputDevice (should be done always now since the
565  // output device is now provided by a call from outside the Writer)
566  pOutDev->Pop();
567 
568  return true;
569 }
570 
571 void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
572  vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
573 {
574  // For printing a shell is needed. Either the Doc already has one, then we
575  // create a new view, or it has none, then we create the first view.
576  std::unique_ptr<SwViewShell> pSh;
578  pSh.reset(new SwViewShell( *pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(), nullptr, &rRenderContext,VSHELLFLAG_SHARELAYOUT ));
579  else
580  pSh.reset(new SwViewShell( *pDoc, nullptr, pOpt, &rRenderContext));
581 
582  {
583  SET_CURR_SHELL( pSh.get() );
584  pSh->PrepareForPrint( rOptions );
585  pSh->SetPrtFormatOption( true );
586 
587  SwRect aSwRect( rRect );
588  pSh->maVisArea = aSwRect;
589 
590  if ( pSh->GetViewOptions()->getBrowseMode() &&
591  pSh->GetRingContainer().size() == 1 )
592  {
593  pSh->InvalidateLayout( false );
594  pSh->GetLayout()->Lower()->InvalidateSize();
595  }
596 
597  // CalcPagesForPrint() should not be necessary here. The pages in the
598  // visible area will be formatted in SwRootFrame::PaintSwFrame().
599  // Removing this gives us a performance gain during saving the
600  // document because the thumbnail creation will not trigger a complete
601  // formatting of the document.
602 
603  rRenderContext.Push( PushFlags::CLIPREGION );
604  rRenderContext.IntersectClipRegion( aSwRect.SVRect() );
605  pSh->GetLayout()->PaintSwFrame( rRenderContext, aSwRect );
606 
607  rRenderContext.Pop();
608  // first the CurrShell object needs to be destroyed!
609  }
610 }
611 
614 {
615  for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_FIELD))
616  {
617  auto pFormatField = dynamic_cast<const SwFormatField*>(pItem);
618  if(pFormatField)
619  {
620  const SwTextField* pTextField = pFormatField->GetTextField();
621  if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() )
622  {
623  return true;
624  }
625  }
626  }
627 
628  for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INPUTFIELD))
629  {
630  const SwFormatField* pFormatField = dynamic_cast<const SwFormatField*>(pItem);
631  if(pFormatField)
632  {
633  const SwTextField* pTextField = pFormatField->GetTextField();
634  if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() )
635  {
636  return true;
637  }
638  }
639  }
640 
641  return false;
642 }
643 
645 SwDrawViewSave::SwDrawViewSave( SdrView* pSdrView )
646  : pDV( pSdrView )
647  , bPrintControls(true)
648 {
649  if ( pDV )
650  {
651  bPrintControls = pDV->IsLayerPrintable( "Controls" );
652  }
653 }
654 
655 SwDrawViewSave::~SwDrawViewSave()
656 {
657  if ( pDV )
658  {
659  pDV->SetLayerPrintable( "Controls", bPrintControls );
660  }
661 }
662 
663 // OD 09.01.2003 #i6467# - method also called for page preview
664 void SwViewShell::PrepareForPrint( const SwPrintData &rOptions, bool bIsPDFExport )
665  {
666  mpOpt->SetGraphic ( rOptions.m_bPrintGraphic );
667  mpOpt->SetTable ( rOptions.m_bPrintTable );
668  mpOpt->SetDraw ( rOptions.m_bPrintDraw );
669  mpOpt->SetControl ( rOptions.m_bPrintControl );
670  mpOpt->SetPageBack ( rOptions.m_bPrintPageBackground );
671  // Font should not be black if it's a PDF Export
672  mpOpt->SetBlackFont( rOptions.m_bPrintBlackFont && !bIsPDFExport );
673 
674  if ( HasDrawView() )
675  {
676  SdrView *pDrawView = GetDrawView();
677  // OD 09.01.2003 #i6467# - consider, if view shell belongs to page preview
678  if ( !IsPreview() )
679  {
680  pDrawView->SetLayerPrintable( "Controls", rOptions.m_bPrintControl );
681  }
682  else
683  {
684  pDrawView->SetLayerVisible( "Controls", rOptions.m_bPrintControl );
685  }
686  }
687 }
688 
689 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:341
void EnableOutput(bool bEnable=true)
long Width() const
Base class of the Writer layout elements.
Definition: frame.hxx:295
SAL_DLLPRIVATE void PrepareForPrint(const SwPrintData &rOptions, bool bIsPDFExport=false)
Definition: vprint.cxx:664
Orientation
SdrView * GetDrawView()
Definition: vnew.cxx:375
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
Definition: findfrm.cxx:572
SwRect & Union(const SwRect &rRect)
Definition: swrect.cxx:39
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwPostItMode GetPrintPostIts() const
Definition: printdata.hxx:145
SwViewShellImp * Imp()
Definition: viewsh.hxx:185
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:237
static bool IsInPaint()
Definition: rootfrm.hxx:360
long Height() const
std::unique_ptr< SwViewShell > m_pPostItShell
this contains a SwDoc with the post-it content
Definition: printdata.hxx:238
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsTableMode() const
Definition: crsrsh.hxx:647
const SfxPoolItem * GetPoolDefaultItem(sal_uInt16 nWhich) const
void Copy(SwDoc *pClpDoc, const OUString *pNewClpText=nullptr)
Copy and Paste methods for internal clipboard.
Definition: fecopy.cxx:76
default
Definition: crstate.hxx:123
std::set< sal_Int32 > & GetValidPagesSet()
Definition: printdata.hxx:265
const SwPosition * GetMark() const
Definition: pam.hxx:209
SwQueuedPaint(SwViewShell *pNew, const SwRect &rRect)
Definition: vprint.cxx:60
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1147
Definition: doc.hxx:185
Painting buffer.
Definition: vprint.cxx:53
const SwShellTableCursor * GetTableCursor() const
Definition: crsrsh.hxx:649
static void PrtOle2(SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData &rOptions, vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: vprint.cxx:571
void Height(long nNew)
Definition: swrect.hxx:189
VclPtr< OutputDevice > mpOut
Window, Printer, VirtDev, ...
Definition: viewsh.hxx:117
SwRect aRect
Definition: vprint.cxx:58
VclPtr< vcl::Window > mpWin
= 0 during printing or pdf export
Definition: viewsh.hxx:116
bool HasDrawView() const
Definition: vnew.cxx:360
const Point & GetSttPos() const
Definition: viscrs.hxx:146
const MapMode & GetMapMode() const
SwNode & GetNode() const
Definition: ndindex.hxx:119
long SwTwips
Definition: swtypes.hxx:49
void IntersectClipRegion(const tools::Rectangle &rRect)
GDIMetaFile * GetConnectMetaFile() const
void Pos(const Point &rNew)
Definition: swrect.hxx:167
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1791
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwShellCursor * GetPrev()
Definition: viscrs.hxx:167
#define VSHELLFLAG_SHARELAYOUT
Definition: viewsh.hxx:79
void SetLayerPrintable(const OUString &rName, bool bPrn)
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
void SetMapMode()
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
bool IsAnyFieldInDoc() const
Check if the DocNodesArray contains fields.
Definition: vprint.cxx:613
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
Definition: docfmt.cxx:1520
void SetLayerVisible(const OUString &rName, bool bShow)
const OUString & GetName() const
Definition: pagedesc.hxx:187
virtual void LockExpFields()=0
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
void SetBufferedOutputAllowed(bool bNew)
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
#define POOLATTR_END
Definition: hintids.hxx:158
void SetFirstVisPageInvalid()
Definition: viewimp.hxx:148
Point maPrtOffset
Definition: viewsh.hxx:106
virtual void PaintSwFrame(vcl::RenderContext &rRenderContext, SwRect const &, SwPrintData const *const pPrintData=nullptr) const override
Definition: paintfrm.cxx:3366
void Top(const long nTop)
Definition: swrect.hxx:202
bool m_bPrintGraphic
Definition: printdata.hxx:58
SwViewShell *const pSh
Definition: vprint.cxx:57
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:174
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
void CalcPagesForPrint(sal_uInt16 nMax)
Definition: vprint.cxx:275
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:88
void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage)
Definition: PostItMgr.cxx:955
void SetLandscape(bool bNew)
Definition: pagedesc.hxx:191
void InitPrt(OutputDevice *pOutDev)
Definition: vprint.cxx:176
SwRect maVisArea
The modern version of VisArea.
Definition: viewsh.hxx:172
oslFileHandle & pOut
void Action(OutputDevice *pRenderContext)
Definition: layact.cxx:320
const SwTable & GetTable() const
Definition: node.hxx:497
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
void setY(long nY)
bool m_bPrintPageBackground
Definition: printdata.hxx:58
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:71
const SwRenderData & GetRenderData() const
Note: in the context where this class is used the pointers should always be valid during the lifetime...
Definition: printdata.hxx:128
SwPageDesc * FindPageDesc(const OUString &rName, size_t *pPos=nullptr) const
Definition: docdesc.cxx:822
void Update()
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:332
#define POOLATTR_BEGIN
Definition: hintids.hxx:157
bool CalcRects()
Definition: PostItMgr.cxx:524
void ChgAllPageOrientation(Orientation eOri)
Definition: vprint.cxx:202
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
void SetLineColor()
void SetConnectMetaFile(GDIMetaFile *pMtf)
Style of a layout element.
Definition: frmfmt.hxx:57
void Reset()
Definition: layact.cxx:282
void SetBufferedOverlayAllowed(bool bNew)
const SwRect & VisArea() const
Definition: viewsh.cxx:558
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const SwPosition * GetPoint() const
Definition: pam.hxx:207
The usage of LayAction is always the same:
Definition: layact.hxx:56
static void Repaint()
Definition: vprint.cxx:103
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:878
bool GetLandscape() const
Definition: pagedesc.hxx:190
const SwFrame * Lower() const
Definition: layfrm.hxx:101
int i
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
SwContentNode * GetContentNode()
Definition: node.hxx:615
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
bool IsPreview() const
Definition: viewsh.hxx:491
Size GetOutputSize() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
bool m_bPrintDraw
Definition: printdata.hxx:58
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
void SetFillColor()
size_t GetPageDescCnt() const
Definition: doc.hxx:877
bool m_bPrintTable
Definition: printdata.hxx:58
SwPageFrame const * sw_getPage(SwRootFrame const &rLayout, sal_Int32 const nPage)
Definition: vprint.cxx:411
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:853
#define SET_CURR_SHELL(shell)
Definition: swtypes.hxx:101
bool m_bPrintControl
Definition: printdata.hxx:58
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
A page of the document layout.
Definition: pagefrm.hxx:40
virtual void setPrinter(SfxPrinter *pP, bool bDeleteOld, bool bCallPrtDataChanged)=0
Set the printer at the document.
SwPostItMode
this must match the definitions in css::text::NotePrintMode
Definition: printdata.hxx:42
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
const SwPosition * Start() const
Definition: pam.hxx:212
bool m_bPrintBlackFont
Definition: printdata.hxx:58
void LayoutPostIts()
Definition: PostItMgr.cxx:679
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
SwViewShell(SwViewShell &, vcl::Window *pWin, OutputDevice *pOut=nullptr, long nFlags=0)
CTor for further Shells on a document.
Definition: vnew.cxx:214
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2596
void Left(const long nLeft)
Definition: swrect.hxx:193
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId, -HlpId can be prevented.
Definition: docfmt.cxx:1399
void ChgAllPageSize(Size const &rSz)
Definition: vprint.cxx:241
friend void SetSwVisArea(SwViewShell *pSh, const SwRect &)
Definition: vprint.cxx:156
static void Add(SwViewShell *pSh, const SwRect &rNew)
Definition: vprint.cxx:83
#define RES_TXTATR_FIELD
Definition: hintids.hxx:244
void FillPrtDoc(SwDoc *pPrtDoc, const SfxPrinter *pPrt)
Definition: vprint.cxx:305
static SwQueuedPaint * s_pPaintQueue
Definition: ptqueue.hxx:48
bool sw_GetPostIts(IDocumentFieldsAccess const *pIDFA, SetGetExpFields *pSrtLst)
Definition: doc.cxx:514
static void Remove(SwViewShell const *pSh)
Definition: vprint.cxx:134
tools::Rectangle SVRect() const
Definition: swrect.hxx:282
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
vcl::Window * GetWin() const
Definition: viewsh.hxx:340
SwShellCursor * GetNext()
Definition: viscrs.hxx:165
void SetReschedule(bool bNew)
Definition: layact.hxx:148
SwNodes & GetNodes()
Definition: doc.hxx:403
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: viewsh.cxx:1751
void SetWaitAllowed(bool bNew)
Definition: layact.hxx:149
void SetSize(const Size &rSize)
SwQueuedPaint * pNext
Definition: vprint.cxx:56
const Point & GetOrigin() const
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
void SetPaint(bool bNew)
Definition: layact.hxx:144
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
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2313
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1864
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
bool PrintOrPDFExport(OutputDevice *pOutDev, SwPrintData const &rPrintData, sal_Int32 nRenderer, bool bIsPDFExport)
Definition: vprint.cxx:427
std::unique_ptr< SwViewOption > mpOpt
Definition: viewsh.hxx:119
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1876
long GetHeight() const
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
void Push(PushFlags nFlags=PushFlags::ALL)
bool IsTextNode() const
Definition: node.hxx:636
void setWidth(long nWidth)
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
#define RES_TXTATR_INPUTFIELD
Definition: hintids.hxx:239
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
sal_uInt16 mnStartAction
!= 0 if at least one Action is active.
Definition: viewsh.hxx:176
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
void SetSwVisArea(SwViewShell *pSh, const SwRect &rRect)
Definition: vprint.cxx:156
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1313
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
void SetPoolDefaultItem(const SfxPoolItem &)
SwFrame * GetNext()
Definition: frame.hxx:654
void setHeight(long nHeight)