LCOV - code coverage report
Current view: top level - sw/source/core/view - vprint.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 278 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <com/sun/star/uno/Sequence.hxx>
      21             : #include <com/sun/star/uno/Any.hxx>
      22             : #include <com/sun/star/view/XRenderable.hpp>
      23             : 
      24             : #include <hintids.hxx>
      25             : #include <rtl/ustring.hxx>
      26             : #include <sfx2/app.hxx>
      27             : #include <sfx2/objsh.hxx>
      28             : #include <sfx2/prnmon.hxx>
      29             : #include <svl/languageoptions.hxx>
      30             : #include <editeng/paperinf.hxx>
      31             : #include <editeng/pbinitem.hxx>
      32             : #include <svx/svdview.hxx>
      33             : #include <toolkit/awt/vclxdevice.hxx>
      34             : #include <unotools/localedatawrapper.hxx>
      35             : #include <unotools/moduleoptions.hxx>
      36             : #include <unotools/syslocale.hxx>
      37             : #include <vcl/oldprintadaptor.hxx>
      38             : 
      39             : #include <unotxdoc.hxx>
      40             : #include <docsh.hxx>
      41             : #include <txtfld.hxx>
      42             : #include <fmtfld.hxx>
      43             : #include <fmtfsize.hxx>
      44             : #include <frmatr.hxx>
      45             : #include <rootfrm.hxx>
      46             : #include <pagefrm.hxx>
      47             : #include <cntfrm.hxx>
      48             : #include <doc.hxx>
      49             : #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 <statstr.hrc>
      66             : #include <ptqueue.hxx>
      67             : #include <tabfrm.hxx>
      68             : #include <txtfrm.hxx>
      69             : #include <viscrs.hxx>
      70             : #include <fmtpdsc.hxx>
      71             : #include <globals.hrc>
      72             : 
      73             : using namespace ::com::sun::star;
      74             : 
      75             : /// Painting buffer
      76             : class SwQueuedPaint
      77             : {
      78             : public:
      79             :     SwQueuedPaint *pNext;
      80             :     SwViewShell      *pSh;
      81             :     SwRect          aRect;
      82             : 
      83           0 :     SwQueuedPaint( SwViewShell *pNew, const SwRect &rRect ) :
      84             :         pNext( 0 ),
      85             :         pSh( pNew ),
      86           0 :         aRect( rRect )
      87           0 :     {}
      88             : };
      89             : 
      90             : SwQueuedPaint *SwPaintQueue::pQueue = 0;
      91             : 
      92             : // saves some settings from the draw view
      93             : class SwDrawViewSave
      94             : {
      95             :     OUString sLayerNm;
      96             :     SdrView* pDV;
      97             :     sal_Bool bPrintControls;
      98             : public:
      99             :     SwDrawViewSave( SdrView* pSdrView );
     100             :     ~SwDrawViewSave();
     101             : };
     102             : 
     103           0 : void SwPaintQueue::Add( SwViewShell *pNew, const SwRect &rNew )
     104             : {
     105             :     SwQueuedPaint *pPt;
     106           0 :     if ( 0 != (pPt = pQueue) )
     107             :     {
     108           0 :         while ( pPt->pSh != pNew && pPt->pNext )
     109           0 :             pPt = pPt->pNext;
     110           0 :         if ( pPt->pSh == pNew )
     111             :         {
     112           0 :             pPt->aRect.Union( rNew );
     113           0 :             return;
     114             :         }
     115             :     }
     116           0 :     SwQueuedPaint *pNQ = new SwQueuedPaint( pNew, rNew );
     117           0 :     if ( pPt )
     118           0 :         pPt->pNext = pNQ;
     119             :     else
     120           0 :         pQueue = pNQ;
     121             : }
     122             : 
     123           0 : void SwPaintQueue::Repaint()
     124             : {
     125           0 :     if ( !SwRootFrm::IsInPaint() && pQueue )
     126             :     {
     127           0 :         SwQueuedPaint *pPt = pQueue;
     128           0 :         do
     129           0 :         {   SwViewShell *pSh = pPt->pSh;
     130           0 :             SET_CURR_SHELL( pSh );
     131           0 :             if ( pSh->IsPreview() )
     132             :             {
     133           0 :                 if ( pSh->GetWin() )
     134             :                 {
     135             :                     // for previewing, since rows/columns are known in PaintHdl (UI)
     136           0 :                     pSh->GetWin()->Invalidate();
     137           0 :                     pSh->GetWin()->Update();
     138             :                 }
     139             :             }
     140             :             else
     141           0 :                 pSh->Paint( pPt->aRect.SVRect() );
     142           0 :             pPt = pPt->pNext;
     143             :         } while ( pPt );
     144             : 
     145           0 :         do
     146           0 :         {   pPt = pQueue;
     147           0 :             pQueue = pQueue->pNext;
     148           0 :             delete pPt;
     149             :         } while ( pQueue );
     150             :     }
     151           0 : }
     152             : 
     153           0 : void SwPaintQueue::Remove( SwViewShell *pSh )
     154             : {
     155             :     SwQueuedPaint *pPt;
     156           0 :     if ( 0 != (pPt = pQueue) )
     157             :     {
     158           0 :         SwQueuedPaint *pPrev = 0;
     159           0 :         while ( pPt && pPt->pSh != pSh )
     160             :         {
     161           0 :             pPrev = pPt;
     162           0 :             pPt = pPt->pNext;
     163             :         }
     164           0 :         if ( pPt )
     165             :         {
     166           0 :             if ( pPrev )
     167           0 :                 pPrev->pNext = pPt->pNext;
     168           0 :             else if ( pPt == pQueue )
     169           0 :                 pQueue = 0;
     170           0 :             delete pPt;
     171             :         }
     172             :     }
     173           0 : }
     174             : 
     175           0 : void SetSwVisArea( SwViewShell *pSh, const SwRect &rRect )
     176             : {
     177             :     OSL_ENSURE( !pSh->GetWin(), "Drucken mit Window?" );
     178           0 :     pSh->maVisArea = rRect;
     179           0 :     pSh->Imp()->SetFirstVisPageInvalid();
     180           0 :     Point aPt( rRect.Pos() );
     181             : 
     182             :     // calculate an offset for the rectangle of the n-th page to
     183             :     // move the start point of the output operation to a position
     184             :     // such that in the output device all pages will be painted
     185             :     // at the same position
     186           0 :     aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
     187             : 
     188           0 :     OutputDevice *pOut = pSh->GetOut();
     189             : 
     190           0 :     MapMode aMapMode( pOut->GetMapMode() );
     191           0 :     aMapMode.SetOrigin( aPt );
     192           0 :     pOut->SetMapMode( aMapMode );
     193           0 : }
     194             : 
     195           0 : void SwViewShell::InitPrt( OutputDevice *pOutDev )
     196             : {
     197             :     // For printing we use a negative offset (exactly the offset of OutputSize).
     198             :     // This is necessary because the origin is in the upper left corner of the
     199             :     // physical page while the output uses OutputOffset as origin.
     200           0 :     if ( pOutDev )
     201             :     {
     202           0 :         maPrtOffst = Point();
     203             : 
     204           0 :         maPrtOffst += pOutDev->GetMapMode().GetOrigin();
     205           0 :         MapMode aMapMode( pOutDev->GetMapMode() );
     206           0 :         aMapMode.SetMapUnit( MAP_TWIP );
     207           0 :         pOutDev->SetMapMode( aMapMode );
     208           0 :         pOutDev->SetLineColor();
     209           0 :         pOutDev->SetFillColor();
     210             :     }
     211             :     else
     212           0 :         maPrtOffst.X() = maPrtOffst.Y() = 0;
     213             : 
     214           0 :     if ( !mpWin )
     215           0 :         mpOut = pOutDev;
     216           0 : }
     217             : 
     218           0 : void SwViewShell::ChgAllPageOrientation( sal_uInt16 eOri )
     219             : {
     220             :     OSL_ENSURE( mnStartAction, "missing an Action" );
     221           0 :     SET_CURR_SHELL( this );
     222             : 
     223           0 :     sal_uInt16 nAll = GetDoc()->GetPageDescCnt();
     224           0 :     sal_Bool bNewOri = Orientation(eOri) == ORIENTATION_PORTRAIT ? sal_False : sal_True;
     225             : 
     226           0 :     for( sal_uInt16 i = 0; i < nAll; ++ i )
     227             :     {
     228           0 :         const SwPageDesc& rOld = GetDoc()->GetPageDesc( i );
     229             : 
     230           0 :         if( rOld.GetLandscape() != bNewOri )
     231             :         {
     232           0 :             SwPageDesc aNew( rOld );
     233             :             {
     234           0 :                 ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
     235           0 :                 GetDoc()->CopyPageDesc(rOld, aNew);
     236             :             }
     237           0 :             aNew.SetLandscape( bNewOri );
     238           0 :             SwFrmFmt& rFmt = aNew.GetMaster();
     239           0 :             SwFmtFrmSize aSz( rFmt.GetFrmSize() );
     240             :             // adjust size
     241             :             // PORTRAIT  -> higher than wide
     242             :             // LANDSCAPE -> wider than high
     243             :             // Height is the VarSize, width the FixSize (per Def.)
     244           0 :             if( bNewOri ? aSz.GetHeight() > aSz.GetWidth()
     245           0 :                         : aSz.GetHeight() < aSz.GetWidth() )
     246             :             {
     247           0 :                 SwTwips aTmp = aSz.GetHeight();
     248           0 :                 aSz.SetHeight( aSz.GetWidth() );
     249           0 :                 aSz.SetWidth( aTmp );
     250           0 :                 rFmt.SetFmtAttr( aSz );
     251             :             }
     252           0 :             GetDoc()->ChgPageDesc( i, aNew );
     253             :         }
     254           0 :     }
     255           0 : }
     256             : 
     257           0 : void SwViewShell::ChgAllPageSize( Size &rSz )
     258             : {
     259             :     OSL_ENSURE( mnStartAction, "missing an Action" );
     260           0 :     SET_CURR_SHELL( this );
     261             : 
     262           0 :     SwDoc* pMyDoc = GetDoc();
     263           0 :     sal_uInt16 nAll = pMyDoc->GetPageDescCnt();
     264             : 
     265           0 :     for( sal_uInt16 i = 0; i < nAll; ++i )
     266             :     {
     267           0 :         const SwPageDesc &rOld = pMyDoc->GetPageDesc( i );
     268           0 :         SwPageDesc aNew( rOld );
     269             :         {
     270           0 :             ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
     271           0 :             GetDoc()->CopyPageDesc( rOld, aNew );
     272             :         }
     273           0 :         SwFrmFmt& rPgFmt = aNew.GetMaster();
     274           0 :         Size aSz( rSz );
     275           0 :         const sal_Bool bOri = aNew.GetLandscape();
     276           0 :         if( bOri  ? aSz.Height() > aSz.Width()
     277           0 :                   : aSz.Height() < aSz.Width() )
     278             :         {
     279           0 :             SwTwips aTmp = aSz.Height();
     280           0 :             aSz.Height() = aSz.Width();
     281           0 :             aSz.Width()  = aTmp;
     282             :         }
     283             : 
     284           0 :         SwFmtFrmSize aFrmSz( rPgFmt.GetFrmSize() );
     285           0 :         aFrmSz.SetSize( aSz );
     286           0 :         rPgFmt.SetFmtAttr( aFrmSz );
     287           0 :         pMyDoc->ChgPageDesc( i, aNew );
     288           0 :     }
     289           0 : }
     290             : 
     291           0 : void SwViewShell::CalcPagesForPrint( sal_uInt16 nMax )
     292             : {
     293           0 :     SET_CURR_SHELL( this );
     294             : 
     295           0 :     SwRootFrm* pMyLayout = GetLayout();
     296             : 
     297           0 :     const SwFrm *pPage = pMyLayout->Lower();
     298           0 :     SwLayAction aAction( pMyLayout, Imp() );
     299             : 
     300           0 :     pMyLayout->StartAllAction();
     301           0 :     for ( sal_uInt16 i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i )
     302             :     {
     303           0 :         pPage->Calc();
     304           0 :         SwRect aOldVis( VisArea() );
     305           0 :         maVisArea = pPage->Frm();
     306           0 :         Imp()->SetFirstVisPageInvalid();
     307           0 :         aAction.Reset();
     308           0 :         aAction.SetPaint( sal_False );
     309           0 :         aAction.SetWaitAllowed( sal_False );
     310           0 :         aAction.SetReschedule( sal_True );
     311             : 
     312           0 :         aAction.Action();
     313             : 
     314           0 :         maVisArea = aOldVis; //reset due to the paints
     315           0 :         Imp()->SetFirstVisPageInvalid();
     316             :     }
     317             : 
     318           0 :     pMyLayout->EndAllAction();
     319           0 : }
     320             : 
     321           0 : SwDoc * SwViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
     322             : {
     323             :     OSL_ENSURE( this->IsA( TYPE(SwFEShell) ),"SwViewShell::Prt for FEShell only");
     324           0 :     SwFEShell* pFESh = (SwFEShell*)this;
     325           0 :     pPrtDoc->LockExpFlds();
     326             : 
     327             :     // use given printer
     328             :     //! Make a copy of it since it gets destroyed with the temporary document
     329             :     //! used for PDF export
     330           0 :     if (pPrt)
     331           0 :         pPrtDoc->setPrinter( new SfxPrinter(*pPrt), true, true );
     332             : 
     333             :     const SfxPoolItem* pCpyItem;
     334           0 :     const SfxItemPool& rPool = GetAttrPool();
     335           0 :     for( sal_uInt16 nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh )
     336           0 :         if( 0 != ( pCpyItem = rPool.GetPoolDefaultItem( nWh ) ) )
     337           0 :             pPrtDoc->GetAttrPool().SetPoolDefaultItem( *pCpyItem );
     338             : 
     339             :     // JP 29.07.99 - Bug 67951 - set all Styles from the SourceDoc into
     340             :     //                              the PrintDoc - will be replaced!
     341           0 :     pPrtDoc->ReplaceStyles( *GetDoc() );
     342             : 
     343           0 :     SwShellCrsr *pActCrsr = pFESh->_GetCrsr();
     344           0 :     SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext());
     345           0 :     if( !pActCrsr->HasMark() ) // with a multi-selection the current cursor might be empty
     346             :     {
     347           0 :         pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev());
     348             :     }
     349             : 
     350             :     // Y-position of the first selection
     351           0 :     Point aSelPoint;
     352           0 :     if( pFESh->IsTableMode() )
     353             :     {
     354           0 :         SwShellTableCrsr* pShellTblCrsr = pFESh->GetTableCrsr();
     355             : 
     356           0 :         const SwCntntNode* pCntntNode = pShellTblCrsr->GetNode()->GetCntntNode();
     357           0 :         const SwCntntFrm *pCntntFrm = pCntntNode ? pCntntNode->getLayoutFrm( GetLayout(), 0, pShellTblCrsr->Start() ) : 0;
     358           0 :         if( pCntntFrm )
     359             :         {
     360           0 :             SwRect aCharRect;
     361           0 :             SwCrsrMoveState aTmpState( MV_NONE );
     362           0 :             pCntntFrm->GetCharRect( aCharRect, *pShellTblCrsr->Start(), &aTmpState );
     363           0 :             aSelPoint = Point( aCharRect.Left(), aCharRect.Top() );
     364             :         }
     365             :     }
     366             :     else
     367             :     {
     368           0 :        aSelPoint = pFirstCrsr->GetSttPos();
     369             :     }
     370             : 
     371           0 :     const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aSelPoint );
     372             :     OSL_ENSURE( pPage, "no page found!" );
     373             : 
     374             :     // get page descriptor - fall back to the first one if pPage could not be found
     375             :     const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDescByName(
     376           0 :         pPage->GetPageDesc()->GetName() ) : &pPrtDoc->GetPageDesc( (sal_uInt16)0 );
     377             : 
     378           0 :     if( !pFESh->IsTableMode() && pActCrsr->HasMark() )
     379             :     {   // Tweak paragraph attributes of last paragraph
     380           0 :         SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     381           0 :         SwTxtNode* pTxtNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx )->GetTxtNode();
     382             :         SwCntntNode *pLastNd =
     383           0 :             pActCrsr->GetCntntNode( (*pActCrsr->GetMark()) <= (*pActCrsr->GetPoint()) );
     384             :         // copy the paragraph attributes of the first paragraph
     385           0 :         if( pLastNd && pLastNd->IsTxtNode() )
     386           0 :             ((SwTxtNode*)pLastNd)->CopyCollFmt( *pTxtNd );
     387             :     }
     388             : 
     389             :     // fill it with the selected content
     390           0 :     pFESh->Copy( pPrtDoc );
     391             : 
     392             :     // set the page style at the first paragraph
     393             :     {
     394           0 :         SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     395           0 :         SwCntntNode* pCNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx ); // go to 1st ContentNode
     396           0 :         if( pFESh->IsTableMode() )
     397             :         {
     398           0 :             SwTableNode* pTNd = pCNd->FindTableNode();
     399           0 :             if( pTNd )
     400           0 :                 pTNd->GetTable().GetFrmFmt()->SetFmtAttr( SwFmtPageDesc( pPageDesc ) );
     401             :         }
     402             :         else
     403             :         {
     404           0 :             pCNd->SetAttr( SwFmtPageDesc( pPageDesc ) );
     405           0 :             if( pFirstCrsr->HasMark() )
     406             :             {
     407           0 :                 SwTxtNode *pTxtNd = pCNd->GetTxtNode();
     408           0 :                 if( pTxtNd )
     409             :                 {
     410             :                     SwCntntNode *pFirstNd =
     411           0 :                         pFirstCrsr->GetCntntNode( (*pFirstCrsr->GetMark()) > (*pFirstCrsr->GetPoint()) );
     412             :                     // copy paragraph attributes of the first paragraph
     413           0 :                     if( pFirstNd && pFirstNd->IsTxtNode() )
     414           0 :                         ((SwTxtNode*)pFirstNd)->CopyCollFmt( *pTxtNd );
     415             :                 }
     416             :             }
     417           0 :         }
     418             :     }
     419           0 :     return pPrtDoc;
     420             : }
     421             : 
     422             : // TODO: there is already a GetPageByPageNum, but it checks some physical page
     423             : // number; unsure if we want that here, should find out what that is...
     424             : SwPageFrm const*
     425           0 : sw_getPage(SwRootFrm const& rLayout, sal_Int32 const nPage)
     426             : {
     427             :     // yes this is O(n^2) but at least it does not crash...
     428           0 :     SwPageFrm const* pPage = dynamic_cast<const SwPageFrm*>(rLayout.Lower());
     429           0 :     for (sal_Int32 i = nPage; pPage && (i > 0); --i)
     430             :     {
     431           0 :         if (1 == i) { // note: nPage is 1-based, i.e. 0 is invalid!
     432           0 :             return pPage;
     433             :         }
     434           0 :         pPage = dynamic_cast<SwPageFrm const*>(pPage->GetNext());
     435             :     }
     436             :     OSL_ENSURE(pPage, "ERROR: SwPageFrm expected");
     437             :     OSL_FAIL("non-existent page requested");
     438           0 :     return 0;
     439             : }
     440             : 
     441           0 : sal_Bool SwViewShell::PrintOrPDFExport(
     442             :     OutputDevice *pOutDev,
     443             :     SwPrintData const& rPrintData,
     444             :     sal_Int32 nRenderer     /* the index in the vector of pages to be printed */ )
     445             : {
     446             :     // CAUTION: Do also always update the printing routines in viewpg.cxx (PrintProspect)!
     447             : 
     448           0 :     const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
     449             :     OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
     450           0 :     if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
     451           0 :         return sal_False;
     452             : 
     453             :     // save settings of OutputDevice (should be done always since the
     454             :     // output device is now provided by a call from outside the Writer)
     455           0 :     pOutDev->Push();
     456             : 
     457             :     // Print/PDF export for (multi-)selection has already generated a
     458             :     // temporary document with the selected text.
     459             :     // (see XRenderable implementation in unotxdoc.cxx)
     460             :     // It is implemented this way because PDF export calls this Prt function
     461             :     // once per page and we do not like to always have the temporary document
     462             :     // to be created that often here.
     463           0 :     SwViewShell *pShell = new SwViewShell( *this, 0, pOutDev );
     464             : 
     465           0 :     SdrView *pDrawView = pShell->GetDrawView();
     466           0 :     if (pDrawView)
     467             :     {
     468           0 :         pDrawView->SetBufferedOutputAllowed( false );
     469           0 :         pDrawView->SetBufferedOverlayAllowed( false );
     470             :     }
     471             : 
     472             :     {   // additional scope so that the CurrShell is reset before destroying the shell
     473             : 
     474           0 :         SET_CURR_SHELL( pShell );
     475             : 
     476             :         //JP 01.02.99: Bug 61335 - the ReadOnly flag is never copied
     477           0 :         if( mpOpt->IsReadonly() )
     478           0 :             pShell->mpOpt->SetReadonly( sal_True );
     479             : 
     480             :         // save options at draw view:
     481           0 :         SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
     482             : 
     483           0 :         pShell->PrepareForPrint( rPrintData );
     484             : 
     485           0 :         const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
     486             :         OSL_ENSURE( nPage < 0 ||
     487             :             rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1,
     488             :             "SwViewShell::PrintOrPDFExport: nPage not valid" );
     489             :         SwViewShell *const pViewSh2 = (nPage < 0)
     490           0 :                 ? rPrintData.GetRenderData().m_pPostItShell.get()// post-it page
     491           0 :                 : pShell; // a 'regular' page, not one from the post-it doc
     492             : 
     493             :         SwPageFrm const*const pStPage =
     494           0 :             sw_getPage(*pViewSh2->GetLayout(), abs(nPage));
     495             :         OSL_ENSURE( pStPage, "failed to get start page" );
     496           0 :         if (!pStPage)
     497             :         {
     498           0 :             return sal_False;
     499             :         }
     500             : 
     501             :         //!! applying view options and formatting the document should now only be done in getRendererCount!
     502             : 
     503           0 :         ::SetSwVisArea( pViewSh2, pStPage->Frm() );
     504             : 
     505           0 :         pShell->InitPrt( pOutDev );
     506             : 
     507           0 :         ::SetSwVisArea( pViewSh2, pStPage->Frm() );
     508             : 
     509           0 :         pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData );
     510             : 
     511           0 :         SwPaintQueue::Repaint();
     512             :     }
     513             : 
     514           0 :     delete pShell;
     515             : 
     516             :     // restore settings of OutputDevice (should be done always now since the
     517             :     // output device is now provided by a call from outside the Writer)
     518           0 :     pOutDev->Pop();
     519             : 
     520           0 :     return sal_True;
     521             : }
     522             : 
     523           0 : void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
     524             :                          OutputDevice* pOleOut, const Rectangle& rRect )
     525             : {
     526             :     // For printing a shell is needed. Either the Doc already has one, than we
     527             :     // create a new view, or it has none, than we create the first view.
     528             :     SwViewShell *pSh;
     529           0 :     if( pDoc->GetCurrentViewShell() )
     530           0 :         pSh = new SwViewShell( *pDoc->GetCurrentViewShell(), 0, pOleOut,VSHELLFLAG_SHARELAYOUT );
     531             :     else
     532           0 :         pSh = new SwViewShell( *pDoc, 0, pOpt, pOleOut);
     533             : 
     534             :     {
     535           0 :         SET_CURR_SHELL( pSh );
     536           0 :         pSh->PrepareForPrint( rOptions );
     537           0 :         pSh->SetPrtFormatOption( sal_True );
     538             : 
     539           0 :         SwRect aSwRect( rRect );
     540           0 :         pSh->maVisArea = aSwRect;
     541             : 
     542           0 :         if ( pSh->GetViewOptions()->getBrowseMode() &&
     543           0 :              pSh->GetNext() == pSh )
     544             :         {
     545           0 :             pSh->CheckBrowseView( sal_False );
     546           0 :             pSh->GetLayout()->Lower()->InvalidateSize();
     547             :         }
     548             : 
     549             :         // CalcPagesForPrint() should not be necessary here. The pages in the
     550             :         // visible area will be formatted in SwRootFrm::Paint().
     551             :         // Removing this gives us a performance gain during saving the
     552             :         // document because the thumbnail creation will not trigger a complete
     553             :         // formatting of the document.
     554             : 
     555           0 :         pOleOut->Push( PUSH_CLIPREGION );
     556           0 :         pOleOut->IntersectClipRegion( aSwRect.SVRect() );
     557           0 :         pSh->GetLayout()->Paint( aSwRect );
     558             : 
     559           0 :         pOleOut->Pop();
     560             :         // first the CurrShell object needs to be destroyed!
     561             :     }
     562           0 :     delete pSh;
     563           0 : }
     564             : 
     565             : /// Check if the DocNodesArray contains fields.
     566           0 : sal_Bool SwViewShell::IsAnyFieldInDoc() const
     567             : {
     568             :     const SfxPoolItem* pItem;
     569           0 :     sal_uInt32 nMaxItems = mpDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD );
     570           0 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
     571             :     {
     572           0 :         if( 0 != (pItem = mpDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n )))
     573             :         {
     574           0 :             const SwFmtFld* pFmtFld = (SwFmtFld*)pItem;
     575           0 :             const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
     576           0 :             if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
     577             :             {
     578           0 :                 return sal_True;
     579             :             }
     580             :         }
     581             :     }
     582             : 
     583           0 :     nMaxItems = mpDoc->GetAttrPool().GetItemCount2( RES_TXTATR_INPUTFIELD );
     584           0 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
     585             :     {
     586           0 :         if( 0 != (pItem = mpDoc->GetAttrPool().GetItem2( RES_TXTATR_INPUTFIELD, n )))
     587             :         {
     588           0 :             const SwFmtFld* pFmtFld = (SwFmtFld*)pItem;
     589           0 :             const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
     590           0 :             if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
     591             :             {
     592           0 :                 return sal_True;
     593             :             }
     594             :         }
     595             :     }
     596             : 
     597           0 :     return sal_False;
     598             : }
     599             : 
     600             : ///  Saves some settings at the draw view
     601           0 : SwDrawViewSave::SwDrawViewSave( SdrView* pSdrView )
     602             :     : pDV( pSdrView )
     603           0 :     , bPrintControls(true)
     604             : {
     605           0 :     if ( pDV )
     606             :     {
     607           0 :         sLayerNm = "Controls";
     608           0 :         bPrintControls = pDV->IsLayerPrintable( sLayerNm );
     609             :     }
     610           0 : }
     611             : 
     612           0 : SwDrawViewSave::~SwDrawViewSave()
     613             : {
     614           0 :     if ( pDV )
     615             :     {
     616           0 :         pDV->SetLayerPrintable( sLayerNm, bPrintControls );
     617             :     }
     618           0 : }
     619             : 
     620             : // OD 09.01.2003 #i6467# - method also called for page preview
     621           0 : void SwViewShell::PrepareForPrint( const SwPrintData &rOptions )
     622             : {
     623           0 :     mpOpt->SetGraphic ( sal_True == rOptions.bPrintGraphic );
     624           0 :     mpOpt->SetTable   ( sal_True == rOptions.bPrintTable );
     625           0 :     mpOpt->SetDraw    ( sal_True == rOptions.bPrintDraw  );
     626           0 :     mpOpt->SetControl ( sal_True == rOptions.bPrintControl );
     627           0 :     mpOpt->SetPageBack( sal_True == rOptions.bPrintPageBackground );
     628           0 :     mpOpt->SetBlackFont( sal_True == rOptions.bPrintBlackFont );
     629             : 
     630           0 :     if ( HasDrawView() )
     631             :     {
     632           0 :         SdrView *pDrawView = GetDrawView();
     633           0 :         OUString sLayerNm;
     634           0 :         sLayerNm = "Controls";
     635             :         // OD 09.01.2003 #i6467# - consider, if view shell belongs to page preview
     636           0 :         if ( !IsPreview() )
     637             :         {
     638           0 :             pDrawView->SetLayerPrintable( sLayerNm, rOptions.bPrintControl );
     639             :         }
     640             :         else
     641             :         {
     642           0 :             pDrawView->SetLayerVisible( sLayerNm, rOptions.bPrintControl );
     643           0 :         }
     644             :     }
     645           0 : }
     646             : 
     647             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10