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()->nNode.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->GetContentNode( (*pActCursor->GetMark()) <= (*pActCursor->GetPoint()) );
372 // copy the paragraph attributes of the first paragraph
373 if( pLastNd && pLastNd->IsTextNode() )
374 static_cast<SwTextNode*>(pLastNd)->CopyCollFormat( *pTextNd );
375 }
376
377 // fill it with the selected content
378 pFESh->Copy(rPrtDoc);
379
380 // set the page style at the first paragraph
381 {
382 SwNodeIndex aNodeIdx( *rPrtDoc.GetNodes().GetEndOfContent().StartOfSectionNode() );
383 SwContentNode* pCNd = rPrtDoc.GetNodes().GoNext( &aNodeIdx ); // go to 1st ContentNode
384 if( pFESh->IsTableMode() )
385 {
386 SwTableNode* pTNd = pCNd->FindTableNode();
387 if( pTNd )
388 pTNd->GetTable().GetFrameFormat()->SetFormatAttr( SwFormatPageDesc( pPageDesc ) );
389 }
390 else
391 {
392 pCNd->SetAttr( SwFormatPageDesc( pPageDesc ) );
393 if( pFirstCursor && pFirstCursor->HasMark() )
394 {
395 SwTextNode *pTextNd = pCNd->GetTextNode();
396 if( pTextNd )
397 {
398 SwContentNode *pFirstNd =
399 pFirstCursor->GetContentNode( (*pFirstCursor->GetMark()) > (*pFirstCursor->GetPoint()) );
400 // copy paragraph attributes of the first paragraph
401 if( pFirstNd && pFirstNd->IsTextNode() )
402 static_cast<SwTextNode*>(pFirstNd)->CopyCollFormat( *pTextNd );
403 }
404 }
405 }
406 }
407}
408
409// TODO: there is already a GetPageByPageNum, but it checks some physical page
410// number; unsure if we want that here, should find out what that is...
411SwPageFrame const*
412sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage)
413{
414 // yes this is O(n^2) but at least it does not crash...
415 SwPageFrame const* pPage = dynamic_cast<const SwPageFrame*>(rLayout.Lower());
416 for (sal_Int32 i = nPage; pPage && (i > 0); --i)
417 {
418 if (1 == i) { // note: nPage is 1-based, i.e. 0 is invalid!
419 return pPage;
420 }
421 pPage = dynamic_cast<SwPageFrame const*>(pPage->GetNext());
422 }
423 OSL_ENSURE(pPage, "ERROR: SwPageFrame expected");
424 OSL_FAIL("non-existent page requested");
425 return nullptr;
426}
427
429 OutputDevice *pOutDev,
430 SwPrintData const& rPrintData,
431 sal_Int32 nRenderer, /* the index in the vector of pages to be printed */
432 bool bIsPDFExport )
433{
434 // CAUTION: Do also always update the printing routines in viewpg.cxx (PrintProspect)!
435
436 const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
437 OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
438 if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
439 return false;
440
441 // save settings of OutputDevice (should be done always since the
442 // output device is now provided by a call from outside the Writer)
443 pOutDev->Push();
444
445 // fdo#36815 for comments in margins print to a metafile
446 // and then scale that metafile down so that the comments
447 // will fit on the real page, and replay that scaled
448 // output to the real outputdevice
449 GDIMetaFile *pOrigRecorder(nullptr);
450 std::unique_ptr<GDIMetaFile> pMetaFile;
451 SwPostItMode nPostItMode = rPrintData.GetPrintPostIts();
452
453 // tdf#91680 Reserve space in margin for comments only if there are comments
454 const bool bHasPostItsToPrintInMargins = ( nPostItMode == SwPostItMode::InMargins ) &&
456
457 if ( bHasPostItsToPrintInMargins )
458 {
459 //get and disable the existing recorder
460 pOrigRecorder = pOutDev->GetConnectMetaFile();
461 pOutDev->SetConnectMetaFile(nullptr);
462 // turn off output to the device
463 pOutDev->EnableOutput(false);
464 // just record the rendering commands to the metafile
465 // instead
466 pMetaFile.reset(new GDIMetaFile);
467 pMetaFile->SetPrefSize(pOutDev->GetOutputSize());
468 pMetaFile->SetPrefMapMode(pOutDev->GetMapMode());
469 pMetaFile->Record(pOutDev);
470 }
471
472 // Print/PDF export for (multi-)selection has already generated a
473 // temporary document with the selected text.
474 // (see XRenderable implementation in unotxdoc.cxx)
475 // It is implemented this way because PDF export calls this Prt function
476 // once per page and we do not like to always have the temporary document
477 // to be created that often here.
478 std::unique_ptr<SwViewShell> pShell(new SwViewShell(*this, nullptr, pOutDev));
479
480 SdrView *pDrawView = pShell->GetDrawView();
481 if (pDrawView)
482 {
483 pDrawView->SetBufferedOutputAllowed( false );
484 pDrawView->SetBufferedOverlayAllowed( false );
485 }
486
487 { // additional scope so that the CurrShell is reset before destroying the shell
488
489 CurrShell aCurr( pShell.get() );
490
491 //JP 01.02.99: Bug 61335 - the ReadOnly flag is never copied
492 if( mpOpt->IsReadonly() )
493 pShell->mpOpt->SetReadonly( true );
494
495 // save options at draw view:
496 SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
497 pShell->PrepareForPrint( rPrintData, bIsPDFExport );
498
499 const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
500 OSL_ENSURE( nPage < 0 ||
501 rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1,
502 "SwViewShell::PrintOrPDFExport: nPage not valid" );
503 SwViewShell *const pViewSh2 = (nPage < 0)
504 ? rPrintData.GetRenderData().m_pPostItShell.get()// post-it page
505 : pShell.get(); // a 'regular' page, not one from the post-it doc
506
507 SwPageFrame const*const pStPage =
508 sw_getPage(*pViewSh2->GetLayout(), abs(nPage));
509 OSL_ENSURE( pStPage, "failed to get start page" );
510 if (!pStPage)
511 {
512 return false;
513 }
514
516
517 ::SetSwVisArea( pViewSh2, pStPage->getFrameArea() );
518
519 pShell->InitPrt(pOutDev);
520
521 ::SetSwVisArea( pViewSh2, pStPage->getFrameArea() );
522
523 pStPage->GetUpper()->PaintSwFrame( *pOutDev, pStPage->getFrameArea(), &rPrintData );
524
526
527 SwPostItMgr *pPostItManager = bHasPostItsToPrintInMargins ? pShell->GetPostItMgr() : nullptr;
528
529 if (pPostItManager)
530 {
531 pPostItManager->CalcRects();
532 pPostItManager->LayoutPostIts();
533 pPostItManager->DrawNotesForPage(pOutDev, nPage-1);
534
535 //Stop recording now
536 pMetaFile->Stop();
537 pMetaFile->WindStart();
538 //Enable output to the device again
539 pOutDev->EnableOutput();
540 //Restore the original recorder
541 pOutDev->SetConnectMetaFile(pOrigRecorder);
542
543 //Now scale the recorded page down so the notes
544 //will fit in the final page
545 double fScale = 0.75;
546 tools::Long nOrigHeight = pStPage->getFrameArea().Height();
547 tools::Long nNewHeight = nOrigHeight*fScale;
548 tools::Long nShiftY = (nOrigHeight-nNewHeight)/2;
549 pMetaFile->Scale( fScale, fScale );
550 pMetaFile->WindStart();
551 //Move the scaled page down to center it
552 //the other variant of Move does not map pixels
553 //back to the logical units correctly
554 pMetaFile->Move(0, convertTwipToMm100(nShiftY), pOutDev->GetDPIX(), pOutDev->GetDPIY());
555 pMetaFile->WindStart();
556
557 //play back the scaled page
558 pMetaFile->Play(*pOutDev);
559 pMetaFile.reset();
560 }
561 }
562
563 pShell.reset();
564
565 // restore settings of OutputDevice (should be done always now since the
566 // output device is now provided by a call from outside the Writer)
567 pOutDev->Pop();
568
569 return true;
570}
571
572void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
573 vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
574{
575 // For printing a shell is needed. Either the Doc already has one, then we
576 // create a new view, or it has none, then we create the first view.
577 std::unique_ptr<SwViewShell> pSh;
579 pSh.reset(new SwViewShell( *pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(), nullptr, &rRenderContext,VSHELLFLAG_SHARELAYOUT ));
580 else
581 pSh.reset(new SwViewShell( *pDoc, nullptr, pOpt, &rRenderContext));
582
583 {
584 CurrShell aCurr( pSh.get() );
585 pSh->PrepareForPrint( rOptions );
586 pSh->SetPrtFormatOption( true );
587
588 SwRect aSwRect( rRect );
589 pSh->maVisArea = aSwRect;
590
591 if ( pSh->GetViewOptions()->getBrowseMode() &&
592 pSh->GetRingContainer().size() == 1 )
593 {
594 pSh->InvalidateLayout( false );
595 pSh->GetLayout()->Lower()->InvalidateSize();
596 }
597
598 // CalcPagesForPrint() should not be necessary here. The pages in the
599 // visible area will be formatted in SwRootFrame::PaintSwFrame().
600 // Removing this gives us a performance gain during saving the
601 // document because the thumbnail creation will not trigger a complete
602 // formatting of the document.
603
604 rRenderContext.Push( vcl::PushFlags::CLIPREGION );
605 rRenderContext.IntersectClipRegion( aSwRect.SVRect() );
606 pSh->GetLayout()->PaintSwFrame( rRenderContext, aSwRect );
607
608 rRenderContext.Pop();
609 // first the CurrShell object needs to be destroyed!
610 }
611}
612
615{
616 for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_FIELD))
617 {
618 auto pFormatField = dynamic_cast<const SwFormatField*>(pItem);
619 if(pFormatField)
620 {
621 const SwTextField* pTextField = pFormatField->GetTextField();
622 if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() )
623 {
624 return true;
625 }
626 }
627 }
628
629 for (const SfxPoolItem* pItem : mxDoc->GetAttrPool().GetItemSurrogates(RES_TXTATR_INPUTFIELD))
630 {
631 const SwFormatField* pFormatField = dynamic_cast<const SwFormatField*>(pItem);
632 if(pFormatField)
633 {
634 const SwTextField* pTextField = pFormatField->GetTextField();
635 if( pTextField && pTextField->GetTextNode().GetNodes().IsDocNodes() )
636 {
637 return true;
638 }
639 }
640 }
641
642 return false;
643}
644
646SwDrawViewSave::SwDrawViewSave( SdrView* pSdrView )
647 : pDV( pSdrView )
648 , bPrintControls(true)
649{
650 if ( pDV )
651 {
652 bPrintControls = pDV->IsLayerPrintable( "Controls" );
653 }
654}
655
656SwDrawViewSave::~SwDrawViewSave()
657{
658 if ( pDV )
659 {
660 pDV->SetLayerPrintable( "Controls", bPrintControls );
661 }
662}
663
664// OD 09.01.2003 #i6467# - method also called for page preview
665void SwViewShell::PrepareForPrint( const SwPrintData &rOptions, bool bIsPDFExport )
666 {
667 mpOpt->SetGraphic ( rOptions.m_bPrintGraphic );
668 mpOpt->SetTable ( rOptions.m_bPrintTable );
669 mpOpt->SetDraw ( rOptions.m_bPrintDraw );
670 mpOpt->SetControl ( rOptions.m_bPrintControl );
671 mpOpt->SetPageBack ( rOptions.m_bPrintPageBackground );
672 // Font should not be black if it's a PDF Export
673 mpOpt->SetBlackFont( rOptions.m_bPrintBlackFont && !bIsPDFExport );
674
675 if ( !HasDrawView() )
676 return;
677
678 SdrView *pDrawView = GetDrawView();
679 // OD 09.01.2003 #i6467# - consider, if view shell belongs to page preview
680 if ( !IsPreview() )
681 {
682 pDrawView->SetLayerPrintable( "Controls", rOptions.m_bPrintControl );
683 }
684 else
685 {
686 pDrawView->SetLayerVisible( "Controls", rOptions.m_bPrintControl );
687 }
688}
689
690/* 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:58
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1204
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1566
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:333
const SwShellTableCursor * GetTableCursor() const
Definition: crsrsh.hxx:650
bool IsTableMode() const
Definition: crsrsh.hxx:648
Definition: doc.hxx:188
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:1426
SwPageDesc * FindPageDesc(const OUString &rName, size_t *pPos=nullptr) const
Definition: docdesc.cxx:953
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
size_t GetPageDescCnt() const
Definition: doc.hxx:879
SwNodes & GetNodes()
Definition: doc.hxx:408
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:984
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1318
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
Definition: docfmt.cxx:1558
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:880
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:134
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:448
const SwRect & getFrameArea() const
Definition: frame.hxx:179
Style of a layout element.
Definition: frmfmt.hxx:61
Base class of the Writer layout elements.
Definition: frame.hxx:315
SwFrame * GetNext()
Definition: frame.hxx:676
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1802
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
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:3492
const SwFrame * Lower() const
Definition: layfrm.hxx:101
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNode & GetNode() const
Definition: ndindex.hxx:128
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:871
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:705
bool IsTextNode() const
Definition: node.hxx:648
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
SwContentNode * GetContentNode()
Definition: node.hxx:627
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:162
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2379
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
const SwPosition * GetMark() const
Definition: pam.hxx:210
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:230
const SwPosition * GetPoint() const
Definition: pam.hxx:208
const SwPosition * Start() const
Definition: pam.hxx:213
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
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:58
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
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:695
bool CalcRects()
Definition: PostItMgr.cxx:540
void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage)
Definition: PostItMgr.cxx:967
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:82
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1911
static bool IsInPaint()
Definition: rootfrm.hxx:365
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1923
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:627
const Point & GetSttPos() const
Definition: viscrs.hxx:157
SwShellCursor * GetNext()
Definition: viscrs.hxx:176
SwShellCursor * GetPrev()
Definition: viscrs.hxx:178
const SwTable & GetTable() const
Definition: node.hxx:506
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:204
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
void SetFirstVisPageInvalid()
Definition: viewimp.hxx:148
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:339
VclPtr< vcl::Window > mpWin
= 0 during printing or pdf export
Definition: viewsh.hxx:114
bool IsPreview() const
Definition: viewsh.hxx:493
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:1860
VclPtr< OutputDevice > mpOut
Window, Printer, VirtDev, ...
Definition: viewsh.hxx:115
void ChgAllPageOrientation(Orientation eOri)
Definition: vprint.cxx:203
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
static void PrtOle2(SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData &rOptions, vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: vprint.cxx:572
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:182
bool IsAnyFieldInDoc() const
Check if the DocNodesArray contains fields.
Definition: vprint.cxx:614
std::unique_ptr< SwViewOption > mpOpt
Definition: viewsh.hxx:117
Point maPrtOffset
Definition: viewsh.hxx:104
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2172
SwRect maVisArea
The modern version of VisArea.
Definition: viewsh.hxx:169
vcl::Window * GetWin() const
Definition: viewsh.hxx:338
const SwRect & VisArea() const
Definition: viewsh.cxx:630
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2795
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:173
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
bool PrintOrPDFExport(OutputDevice *pOutDev, SwPrintData const &rPrintData, sal_Int32 nRenderer, bool bIsPDFExport)
Definition: vprint.cxx:428
SAL_DLLPRIVATE void PrepareForPrint(const SwPrintData &rOptions, bool bIsPDFExport=false)
Definition: vprint.cxx:665
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:617
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:515
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
SwNodeIndex nNode
Definition: pam.hxx:38
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:412
oslFileHandle & pOut