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