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