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