LCOV - code coverage report
Current view: top level - sw/source/core/view - vprint.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 33 272 12.1 %
Date: 2012-08-25 Functions: 3 17 17.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 24 440 5.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /**************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/uno/Sequence.hxx>
      30                 :            : #include <com/sun/star/uno/Any.hxx>
      31                 :            : #include <com/sun/star/view/XRenderable.hpp>
      32                 :            : 
      33                 :            : #include <hintids.hxx>
      34                 :            : #include <rtl/ustring.hxx>
      35                 :            : #include <sfx2/app.hxx>
      36                 :            : #include <sfx2/objsh.hxx>
      37                 :            : #include <sfx2/prnmon.hxx>
      38                 :            : #include <svl/languageoptions.hxx>
      39                 :            : #include <editeng/paperinf.hxx>
      40                 :            : #include <editeng/pbinitem.hxx>
      41                 :            : #include <svx/svdview.hxx>
      42                 :            : #include <toolkit/awt/vclxdevice.hxx>
      43                 :            : #include <unotools/localedatawrapper.hxx>
      44                 :            : #include <unotools/moduleoptions.hxx>
      45                 :            : #include <unotools/syslocale.hxx>
      46                 :            : #include <vcl/oldprintadaptor.hxx>
      47                 :            : 
      48                 :            : #include <unotxdoc.hxx>
      49                 :            : #include <docsh.hxx>
      50                 :            : #include <txtfld.hxx>
      51                 :            : #include <fmtfld.hxx>
      52                 :            : #include <fmtfsize.hxx>
      53                 :            : #include <frmatr.hxx>
      54                 :            : #include <rootfrm.hxx>
      55                 :            : #include <pagefrm.hxx>
      56                 :            : #include <cntfrm.hxx>
      57                 :            : #include <doc.hxx>
      58                 :            : #include <IDocumentUndoRedo.hxx>
      59                 :            : #include <wdocsh.hxx>
      60                 :            : #include <fesh.hxx>
      61                 :            : #include <pam.hxx>
      62                 :            : #include <viewimp.hxx>      // Imp->SetFirstVisPageInvalid()
      63                 :            : #include <layact.hxx>
      64                 :            : #include <ndtxt.hxx>
      65                 :            : #include <fldbas.hxx>
      66                 :            : #include <docfld.hxx>       // _SetGetExpFld
      67                 :            : #include <docufld.hxx>      // PostItFld /-Type
      68                 :            : #include <shellres.hxx>
      69                 :            : #include <viewopt.hxx>
      70                 :            : #include <printdata.hxx>    // SwPrintData
      71                 :            : #include <pagedesc.hxx>
      72                 :            : #include <poolfmt.hxx>      // fuer RES_POOLPAGE_JAKET
      73                 :            : #include <mdiexp.hxx>       // Ansteuern der Statusleiste
      74                 :            : #include <statstr.hrc>      //      -- " --
      75                 :            : #include <ptqueue.hxx>
      76                 :            : #include <tabfrm.hxx>
      77                 :            : #include <txtfrm.hxx>       // MinPrtLine
      78                 :            : #include <viscrs.hxx>       // SwShellCrsr
      79                 :            : #include <fmtpdsc.hxx>      // SwFmtPageDesc
      80                 :            : #include <globals.hrc>
      81                 :            : 
      82                 :            : 
      83                 :            : using namespace ::com::sun::star;
      84                 :            : 
      85                 :            : //--------------------------------------------------------------------
      86                 :            : //Klasse zum Puffern von Paints
      87                 :            : class SwQueuedPaint
      88                 :            : {
      89                 :            : public:
      90                 :            :     SwQueuedPaint *pNext;
      91                 :            :     ViewShell      *pSh;
      92                 :            :     SwRect          aRect;
      93                 :            : 
      94                 :          0 :     SwQueuedPaint( ViewShell *pNew, const SwRect &rRect ) :
      95                 :            :         pNext( 0 ),
      96                 :            :         pSh( pNew ),
      97                 :          0 :         aRect( rRect )
      98                 :          0 :     {}
      99                 :            : };
     100                 :            : 
     101                 :            : SwQueuedPaint *SwPaintQueue::pQueue = 0;
     102                 :            : 
     103                 :            : // saves some settings from the draw view
     104                 :            : class SwDrawViewSave
     105                 :            : {
     106                 :            :     String sLayerNm;
     107                 :            :     SdrView* pDV;
     108                 :            :     sal_Bool bPrintControls;
     109                 :            : public:
     110                 :            :     SwDrawViewSave( SdrView* pSdrView );
     111                 :            :     ~SwDrawViewSave();
     112                 :            : };
     113                 :            : 
     114                 :            : 
     115                 :          0 : void SwPaintQueue::Add( ViewShell *pNew, const SwRect &rNew )
     116                 :            : {
     117                 :            :     SwQueuedPaint *pPt;
     118         [ #  # ]:          0 :     if ( 0 != (pPt = pQueue) )
     119                 :            :     {
     120 [ #  # ][ #  # ]:          0 :         while ( pPt->pSh != pNew && pPt->pNext )
                 [ #  # ]
     121                 :          0 :             pPt = pPt->pNext;
     122         [ #  # ]:          0 :         if ( pPt->pSh == pNew )
     123                 :            :         {
     124                 :          0 :             pPt->aRect.Union( rNew );
     125                 :          0 :             return;
     126                 :            :         }
     127                 :            :     }
     128                 :          0 :     SwQueuedPaint *pNQ = new SwQueuedPaint( pNew, rNew );
     129         [ #  # ]:          0 :     if ( pPt )
     130                 :          0 :         pPt->pNext = pNQ;
     131                 :            :     else
     132                 :          0 :         pQueue = pNQ;
     133                 :            : }
     134                 :            : 
     135                 :            : 
     136                 :            : 
     137                 :          0 : void SwPaintQueue::Repaint()
     138                 :            : {
     139 [ #  # ][ #  # ]:          0 :     if ( !SwRootFrm::IsInPaint() && pQueue )
                 [ #  # ]
     140                 :            :     {
     141                 :          0 :         SwQueuedPaint *pPt = pQueue;
     142         [ #  # ]:          0 :         do
     143                 :          0 :         {   ViewShell *pSh = pPt->pSh;
     144         [ #  # ]:          0 :             SET_CURR_SHELL( pSh );
     145         [ #  # ]:          0 :             if ( pSh->IsPreView() )
     146                 :            :             {
     147         [ #  # ]:          0 :                 if ( pSh->GetWin() )
     148                 :            :                 {
     149                 :            :                     //Fuer PreView aussenherum, weil im PaintHdl (UI) die
     150                 :            :                     //Zeilen/Spalten bekannt sind.
     151         [ #  # ]:          0 :                     pSh->GetWin()->Invalidate();
     152         [ #  # ]:          0 :                     pSh->GetWin()->Update();
     153                 :            :                 }
     154                 :            :             }
     155                 :            :             else
     156 [ #  # ][ #  # ]:          0 :                 pSh->Paint( pPt->aRect.SVRect() );
     157         [ #  # ]:          0 :             pPt = pPt->pNext;
     158                 :            :         } while ( pPt );
     159                 :            : 
     160         [ #  # ]:          0 :         do
     161                 :          0 :         {   pPt = pQueue;
     162                 :          0 :             pQueue = pQueue->pNext;
     163                 :          0 :             delete pPt;
     164                 :            :         } while ( pQueue );
     165                 :            :     }
     166                 :          0 : }
     167                 :            : 
     168                 :            : 
     169                 :            : 
     170                 :       1250 : void SwPaintQueue::Remove( ViewShell *pSh )
     171                 :            : {
     172                 :            :     SwQueuedPaint *pPt;
     173         [ -  + ]:       1250 :     if ( 0 != (pPt = pQueue) )
     174                 :            :     {
     175                 :          0 :         SwQueuedPaint *pPrev = 0;
     176 [ #  # ][ #  # ]:          0 :         while ( pPt && pPt->pSh != pSh )
                 [ #  # ]
     177                 :            :         {
     178                 :          0 :             pPrev = pPt;
     179                 :          0 :             pPt = pPt->pNext;
     180                 :            :         }
     181         [ #  # ]:          0 :         if ( pPt )
     182                 :            :         {
     183         [ #  # ]:          0 :             if ( pPrev )
     184                 :          0 :                 pPrev->pNext = pPt->pNext;
     185         [ #  # ]:          0 :             else if ( pPt == pQueue )
     186                 :          0 :                 pQueue = 0;
     187                 :          0 :             delete pPt;
     188                 :            :         }
     189                 :            :     }
     190                 :       1250 : }
     191                 :            : 
     192                 :            : /******************************************************************************
     193                 :            :  *  Methode     :   void SetSwVisArea( ViewShell *pSh, Point aPrtOffset, ...
     194                 :            :  *  Beschreibung:
     195                 :            :  *  Erstellt    :   OK 04.11.94 16:27
     196                 :            :  *  Aenderung   :
     197                 :            :  ******************************************************************************/
     198                 :            : 
     199                 :          0 : void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, sal_Bool /*bPDFExport*/ )
     200                 :            : {
     201                 :            :     OSL_ENSURE( !pSh->GetWin(), "Drucken mit Window?" );
     202                 :          0 :     pSh->aVisArea = rRect;
     203                 :          0 :     pSh->Imp()->SetFirstVisPageInvalid();
     204                 :          0 :     Point aPt( rRect.Pos() );
     205                 :            : 
     206                 :            :     // calculate an offset for the rectangle of the n-th page to
     207                 :            :     // move the start point of the output operation to a position
     208                 :            :     // such that in the output device all pages will be painted
     209                 :            :     // at the same position
     210                 :          0 :     aPt.X() = -aPt.X(); aPt.Y() = -aPt.Y();
     211                 :            : 
     212                 :          0 :     OutputDevice *pOut = pSh->GetOut();
     213                 :            : 
     214         [ #  # ]:          0 :     MapMode aMapMode( pOut->GetMapMode() );
     215         [ #  # ]:          0 :     aMapMode.SetOrigin( aPt );
     216 [ #  # ][ #  # ]:          0 :     pOut->SetMapMode( aMapMode );
     217                 :          0 : }
     218                 :            : 
     219                 :            : /******************************************************************************/
     220                 :            : 
     221                 :          0 : void ViewShell::InitPrt( OutputDevice *pOutDev )
     222                 :            : {
     223                 :            :     //Fuer den Printer merken wir uns einen negativen Offset, der
     224                 :            :     //genau dem Offset de OutputSize entspricht. Das ist notwendig,
     225                 :            :     //weil unser Ursprung der linken ober Ecke der physikalischen
     226                 :            :     //Seite ist, die Ausgaben (SV) aber den Outputoffset als Urstprung
     227                 :            :     //betrachten.
     228         [ #  # ]:          0 :     if ( pOutDev )
     229                 :            :     {
     230                 :          0 :         aPrtOffst = Point();
     231                 :            : 
     232                 :          0 :         aPrtOffst += pOutDev->GetMapMode().GetOrigin();
     233         [ #  # ]:          0 :         MapMode aMapMode( pOutDev->GetMapMode() );
     234         [ #  # ]:          0 :         aMapMode.SetMapUnit( MAP_TWIP );
     235         [ #  # ]:          0 :         pOutDev->SetMapMode( aMapMode );
     236         [ #  # ]:          0 :         pOutDev->SetLineColor();
     237 [ #  # ][ #  # ]:          0 :         pOutDev->SetFillColor();
     238                 :            :     }
     239                 :            :     else
     240                 :          0 :         aPrtOffst.X() = aPrtOffst.Y() = 0;
     241                 :            : 
     242         [ #  # ]:          0 :     if ( !pWin )
     243                 :          0 :         pOut = pOutDev;    //Oder was sonst?
     244                 :          0 : }
     245                 :            : 
     246                 :            : /******************************************************************************
     247                 :            :  *  Methode     :   void ViewShell::ChgAllPageOrientation
     248                 :            :  *  Erstellt    :   MA 08. Aug. 95
     249                 :            :  *  Aenderung   :
     250                 :            :  ******************************************************************************/
     251                 :            : 
     252                 :            : 
     253                 :          0 : void ViewShell::ChgAllPageOrientation( sal_uInt16 eOri )
     254                 :            : {
     255                 :            :     OSL_ENSURE( nStartAction, "missing an Action" );
     256         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     257                 :            : 
     258                 :          0 :     sal_uInt16 nAll = GetDoc()->GetPageDescCnt();
     259                 :          0 :     sal_Bool bNewOri = Orientation(eOri) == ORIENTATION_PORTRAIT ? sal_False : sal_True;
     260                 :            : 
     261         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nAll; ++ i )
     262                 :            :     {
     263         [ #  # ]:          0 :         const SwPageDesc& rOld = GetDoc()->GetPageDesc( i );
     264                 :            : 
     265         [ #  # ]:          0 :         if( rOld.GetLandscape() != bNewOri )
     266                 :            :         {
     267         [ #  # ]:          0 :             SwPageDesc aNew( rOld );
     268                 :            :             {
     269 [ #  # ][ #  # ]:          0 :                 ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
     270 [ #  # ][ #  # ]:          0 :                 GetDoc()->CopyPageDesc(rOld, aNew);
     271                 :            :             }
     272                 :          0 :             aNew.SetLandscape( bNewOri );
     273                 :          0 :             SwFrmFmt& rFmt = aNew.GetMaster();
     274 [ #  # ][ #  # ]:          0 :             SwFmtFrmSize aSz( rFmt.GetFrmSize() );
     275                 :            :             // Groesse anpassen.
     276                 :            :             // PORTRAIT  -> Hoeher als Breit
     277                 :            :             // LANDSCAPE -> Breiter als Hoch
     278                 :            :             // Hoehe ist die VarSize, Breite ist die FixSize (per Def.)
     279 [ #  # ][ #  # ]:          0 :             if( bNewOri ? aSz.GetHeight() > aSz.GetWidth()
     280                 :          0 :                         : aSz.GetHeight() < aSz.GetWidth() )
     281                 :            :             {
     282                 :          0 :                 SwTwips aTmp = aSz.GetHeight();
     283                 :          0 :                 aSz.SetHeight( aSz.GetWidth() );
     284                 :          0 :                 aSz.SetWidth( aTmp );
     285         [ #  # ]:          0 :                 rFmt.SetFmtAttr( aSz );
     286                 :            :             }
     287 [ #  # ][ #  # ]:          0 :             GetDoc()->ChgPageDesc( i, aNew );
                 [ #  # ]
     288                 :            :         }
     289         [ #  # ]:          0 :     }
     290                 :          0 : }
     291                 :            : 
     292                 :            : /******************************************************************************
     293                 :            :  *  Methode     :   void ViewShell::ChgAllPageOrientation
     294                 :            :  *  Erstellt    :   MA 08. Aug. 95
     295                 :            :  *  Aenderung   :
     296                 :            :  ******************************************************************************/
     297                 :            : 
     298                 :            : 
     299                 :          0 : void ViewShell::ChgAllPageSize( Size &rSz )
     300                 :            : {
     301                 :            :     OSL_ENSURE( nStartAction, "missing an Action" );
     302         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     303                 :            : 
     304                 :          0 :     SwDoc* pMyDoc = GetDoc();
     305                 :          0 :     sal_uInt16 nAll = pMyDoc->GetPageDescCnt();
     306                 :            : 
     307         [ #  # ]:          0 :     for( sal_uInt16 i = 0; i < nAll; ++i )
     308                 :            :     {
     309         [ #  # ]:          0 :         const SwPageDesc &rOld = pMyDoc->GetPageDesc( i );
     310         [ #  # ]:          0 :         SwPageDesc aNew( rOld );
     311                 :            :         {
     312 [ #  # ][ #  # ]:          0 :             ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo());
     313 [ #  # ][ #  # ]:          0 :             GetDoc()->CopyPageDesc( rOld, aNew );
     314                 :            :         }
     315                 :          0 :         SwFrmFmt& rPgFmt = aNew.GetMaster();
     316                 :          0 :         Size aSz( rSz );
     317                 :          0 :         const sal_Bool bOri = aNew.GetLandscape();
     318 [ #  # ][ #  # ]:          0 :         if( bOri  ? aSz.Height() > aSz.Width()
     319                 :          0 :                   : aSz.Height() < aSz.Width() )
     320                 :            :         {
     321                 :          0 :             SwTwips aTmp = aSz.Height();
     322                 :          0 :             aSz.Height() = aSz.Width();
     323                 :          0 :             aSz.Width()  = aTmp;
     324                 :            :         }
     325                 :            : 
     326 [ #  # ][ #  # ]:          0 :         SwFmtFrmSize aFrmSz( rPgFmt.GetFrmSize() );
     327                 :          0 :         aFrmSz.SetSize( aSz );
     328         [ #  # ]:          0 :         rPgFmt.SetFmtAttr( aFrmSz );
     329         [ #  # ]:          0 :         pMyDoc->ChgPageDesc( i, aNew );
     330 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     331                 :          0 : }
     332                 :            : 
     333                 :            : 
     334                 :          0 : void ViewShell::CalcPagesForPrint( sal_uInt16 nMax )
     335                 :            : {
     336         [ #  # ]:          0 :     SET_CURR_SHELL( this );
     337                 :            : 
     338         [ #  # ]:          0 :     SwRootFrm* pMyLayout = GetLayout();
     339                 :            :     // ULONG nStatMax = pLayout->GetPageNum();
     340                 :            : 
     341                 :          0 :     const SwFrm *pPage = pMyLayout->Lower();
     342         [ #  # ]:          0 :     SwLayAction aAction( pMyLayout, Imp() );
     343                 :            : 
     344         [ #  # ]:          0 :     pMyLayout->StartAllAction();
     345 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 i = 1; pPage && i <= nMax; pPage = pPage->GetNext(), ++i )
                 [ #  # ]
     346                 :            :     {
     347         [ #  # ]:          0 :         pPage->Calc();
     348                 :          0 :         SwRect aOldVis( VisArea() );
     349                 :          0 :         aVisArea = pPage->Frm();
     350                 :          0 :         Imp()->SetFirstVisPageInvalid();
     351         [ #  # ]:          0 :         aAction.Reset();
     352                 :          0 :         aAction.SetPaint( sal_False );
     353                 :          0 :         aAction.SetWaitAllowed( sal_False );
     354                 :          0 :         aAction.SetReschedule( sal_True );
     355                 :            : 
     356         [ #  # ]:          0 :         aAction.Action();
     357                 :            : 
     358                 :          0 :         aVisArea = aOldVis;             //Zuruecksetzen wg. der Paints!
     359                 :          0 :         Imp()->SetFirstVisPageInvalid();
     360                 :            : //       SwPaintQueue::Repaint();
     361                 :            :     }
     362                 :            : 
     363 [ #  # ][ #  # ]:          0 :     pMyLayout->EndAllAction();
                 [ #  # ]
     364                 :          0 : }
     365                 :            : 
     366                 :            : /******************************************************************************/
     367                 :            : 
     368                 :          0 : SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
     369                 :            : {
     370                 :            :     OSL_ENSURE( this->IsA( TYPE(SwFEShell) ),"ViewShell::Prt for FEShell only");
     371                 :          0 :     SwFEShell* pFESh = (SwFEShell*)this;
     372                 :            :     // Wir bauen uns ein neues Dokument
     373                 :            : //    SwDoc *pPrtDoc = new SwDoc;
     374                 :            : //    pPrtDoc->acquire();
     375                 :            : //    pPrtDoc->SetRefForDocShell( (SvEmbeddedObjectRef*)&(long&)rDocShellRef );
     376         [ #  # ]:          0 :     pPrtDoc->LockExpFlds();
     377                 :            : 
     378                 :            :     // Der Drucker wird uebernommen
     379                 :            :     //! Make a copy of it since it gets destroyed with the temporary document
     380                 :            :     //! used for PDF export
     381         [ #  # ]:          0 :     if (pPrt)
     382 [ #  # ][ #  # ]:          0 :         pPrtDoc->setPrinter( new SfxPrinter(*pPrt), true, true );
                 [ #  # ]
     383                 :            : 
     384                 :            :     const SfxPoolItem* pCpyItem;
     385         [ #  # ]:          0 :     const SfxItemPool& rPool = GetAttrPool();
     386         [ #  # ]:          0 :     for( sal_uInt16 nWh = POOLATTR_BEGIN; nWh < POOLATTR_END; ++nWh )
     387 [ #  # ][ #  # ]:          0 :         if( 0 != ( pCpyItem = rPool.GetPoolDefaultItem( nWh ) ) )
     388         [ #  # ]:          0 :             pPrtDoc->GetAttrPool().SetPoolDefaultItem( *pCpyItem );
     389                 :            : 
     390                 :            :     // JP 29.07.99 - Bug 67951 - set all Styles from the SourceDoc into
     391                 :            :     //                              the PrintDoc - will be replaced!
     392         [ #  # ]:          0 :     pPrtDoc->ReplaceStyles( *GetDoc() );
     393                 :            : 
     394                 :          0 :     SwShellCrsr *pActCrsr = pFESh->_GetCrsr();
     395         [ #  # ]:          0 :     SwShellCrsr *pFirstCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetNext());
     396         [ #  # ]:          0 :     if( !pActCrsr->HasMark() ) // bei Multiselektion kann der aktuelle Cursor leer sein
     397                 :            :     {
     398         [ #  # ]:          0 :         pActCrsr = dynamic_cast<SwShellCrsr*>(pActCrsr->GetPrev());
     399                 :            :     }
     400                 :            : 
     401                 :            :     // Die Y-Position der ersten Selektion
     402                 :          0 :     Point aSelPoint;
     403         [ #  # ]:          0 :     if( pFESh->IsTableMode() )
     404                 :            :     {
     405                 :          0 :         SwShellTableCrsr* pShellTblCrsr = pFESh->GetTableCrsr();
     406                 :            : 
     407                 :          0 :         const SwCntntNode* pCntntNode = pShellTblCrsr->GetNode()->GetCntntNode();
     408 [ #  # ][ #  # ]:          0 :         const SwCntntFrm *pCntntFrm = pCntntNode ? pCntntNode->getLayoutFrm( GetLayout(), 0, pShellTblCrsr->Start() ) : 0;
         [ #  # ][ #  # ]
     409         [ #  # ]:          0 :         if( pCntntFrm )
     410                 :            :         {
     411                 :          0 :             SwRect aCharRect;
     412                 :          0 :             SwCrsrMoveState aTmpState( MV_NONE );
     413 [ #  # ][ #  # ]:          0 :             pCntntFrm->GetCharRect( aCharRect, *pShellTblCrsr->Start(), &aTmpState );
     414                 :          0 :             aSelPoint = Point( aCharRect.Left(), aCharRect.Top() );
     415                 :            :         }
     416                 :            :     }
     417                 :            :     else
     418                 :            :     {
     419         [ #  # ]:          0 :        aSelPoint = pFirstCrsr->GetSttPos();
     420                 :            :     }
     421                 :            : 
     422 [ #  # ][ #  # ]:          0 :     const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aSelPoint );
     423                 :            :     OSL_ENSURE( pPage, "no page found!" );
     424                 :            : 
     425                 :            :     // get page descriptor - fall back to the first one if pPage could not be found
     426                 :            :     const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDescByName(
     427 [ #  # ][ #  # ]:          0 :         pPage->GetPageDesc()->GetName() ) : &pPrtDoc->GetPageDesc( (sal_uInt16)0 );
                 [ #  # ]
     428                 :            : 
     429 [ #  # ][ #  # ]:          0 :     if( !pFESh->IsTableMode() && pActCrsr->HasMark() )
                 [ #  # ]
     430                 :            :     {   // Am letzten Absatz die Absatzattribute richten:
     431 [ #  # ][ #  # ]:          0 :         SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     432 [ #  # ][ #  # ]:          0 :         SwTxtNode* pTxtNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx )->GetTxtNode();
     433                 :            :         SwCntntNode *pLastNd =
     434         [ #  # ]:          0 :             pActCrsr->GetCntntNode( (*pActCrsr->GetMark()) <= (*pActCrsr->GetPoint()) );
     435                 :            :         // Hier werden die Absatzattribute des ersten Absatzes uebertragen
     436 [ #  # ][ #  # ]:          0 :         if( pLastNd && pLastNd->IsTxtNode() )
                 [ #  # ]
     437 [ #  # ][ #  # ]:          0 :             ((SwTxtNode*)pLastNd)->CopyCollFmt( *pTxtNd );
     438                 :            :     }
     439                 :            : 
     440                 :            :     // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!)
     441                 :            : //      if( aDocShellRef.Is() )
     442                 :            : //          SwDataExchange::InitOle( aDocShellRef, pPrtDoc );
     443                 :            :     // und fuellen es mit dem selektierten Bereich
     444         [ #  # ]:          0 :     pFESh->Copy( pPrtDoc );
     445                 :            : 
     446                 :            :     //Jetzt noch am ersten Absatz die Seitenvorlage setzen
     447                 :            :     {
     448 [ #  # ][ #  # ]:          0 :         SwNodeIndex aNodeIdx( *pPrtDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     449 [ #  # ][ #  # ]:          0 :         SwCntntNode* pCNd = pPrtDoc->GetNodes().GoNext( &aNodeIdx ); // gehe zum 1. ContentNode
     450         [ #  # ]:          0 :         if( pFESh->IsTableMode() )
     451                 :            :         {
     452         [ #  # ]:          0 :             SwTableNode* pTNd = pCNd->FindTableNode();
     453         [ #  # ]:          0 :             if( pTNd )
     454 [ #  # ][ #  # ]:          0 :                 pTNd->GetTable().GetFrmFmt()->SetFmtAttr( SwFmtPageDesc( pPageDesc ) );
                 [ #  # ]
     455                 :            :         }
     456                 :            :         else
     457                 :            :         {
     458 [ #  # ][ #  # ]:          0 :             pCNd->SetAttr( SwFmtPageDesc( pPageDesc ) );
                 [ #  # ]
     459         [ #  # ]:          0 :             if( pFirstCrsr->HasMark() )
     460                 :            :             {
     461                 :          0 :                 SwTxtNode *pTxtNd = pCNd->GetTxtNode();
     462         [ #  # ]:          0 :                 if( pTxtNd )
     463                 :            :                 {
     464                 :            :                     SwCntntNode *pFirstNd =
     465         [ #  # ]:          0 :                         pFirstCrsr->GetCntntNode( (*pFirstCrsr->GetMark()) > (*pFirstCrsr->GetPoint()) );
     466                 :            :                     // Hier werden die Absatzattribute des ersten Absatzes uebertragen
     467 [ #  # ][ #  # ]:          0 :                     if( pFirstNd && pFirstNd->IsTxtNode() )
                 [ #  # ]
     468         [ #  # ]:          0 :                         ((SwTxtNode*)pFirstNd)->CopyCollFmt( *pTxtNd );
     469                 :            :                 }
     470                 :            :             }
     471         [ #  # ]:          0 :         }
     472                 :            :     }
     473                 :          0 :     return pPrtDoc;
     474                 :            : }
     475                 :            : 
     476                 :            : // TODO: there is already a GetPageByPageNum, but it checks some physical page
     477                 :            : // number; unsure if we want that here, should find out what that is...
     478                 :            : SwPageFrm const*
     479                 :          0 : lcl_getPage(SwRootFrm const& rLayout, sal_Int32 const nPage)
     480                 :            : {
     481                 :            :     // yes this is O(n^2) but at least it does not crash...
     482         [ #  # ]:          0 :     SwPageFrm const* pPage = dynamic_cast<const SwPageFrm*>(rLayout.Lower());
     483 [ #  # ][ #  # ]:          0 :     for (sal_Int32 i = nPage; pPage && (i > 0); --i)
                 [ #  # ]
     484                 :            :     {
     485         [ #  # ]:          0 :         if (1 == i) { // note: nPage is 1-based, i.e. 0 is invalid!
     486                 :          0 :             return pPage;
     487                 :            :         }
     488         [ #  # ]:          0 :         pPage = dynamic_cast<SwPageFrm const*>(pPage->GetNext());
     489                 :            :     }
     490                 :            :     OSL_ENSURE(pPage, "ERROR: SwPageFrm expected");
     491                 :            :     OSL_FAIL("non-existent page requested");
     492                 :          0 :     return 0;
     493                 :            : }
     494                 :            : 
     495                 :          0 : sal_Bool ViewShell::PrintOrPDFExport(
     496                 :            :     OutputDevice *pOutDev,
     497                 :            :     SwPrintData const& rPrintData,
     498                 :            :     sal_Int32 nRenderer     /* the index in the vector of pages to be printed */ )
     499                 :            : {
     500                 :            : //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     501                 :            : //Immer die Druckroutinen in viewpg.cxx (PrintProspect) mitpflegen!!
     502                 :            : //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     503                 :            : 
     504                 :          0 :     const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagesToPrint().size() - 1;
     505                 :            :     OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
     506 [ #  # ][ #  # ]:          0 :     if (!pOutDev || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
         [ #  # ][ #  # ]
     507                 :          0 :         return sal_False;
     508                 :            : 
     509                 :            :     // save settings of OutputDevice (should be done always since the
     510                 :            :     // output device is now provided by a call from outside the Writer)
     511                 :          0 :     pOutDev->Push();
     512                 :            : 
     513                 :            :     // Print/PDF export for (multi-)selection has already generated a
     514                 :            :     // temporary document with the selected text.
     515                 :            :     // (see XRenderable implementation in unotxdoc.cxx)
     516                 :            :     // It is implemented this way because PDF export calls this Prt function
     517                 :            :     // once per page and we do not like to always have the temporary document
     518                 :            :     // to be created that often here.
     519         [ #  # ]:          0 :     ViewShell *pShell = new ViewShell( *this, 0, pOutDev );
     520                 :            : 
     521                 :          0 :     SdrView *pDrawView = pShell->GetDrawView();
     522         [ #  # ]:          0 :     if (pDrawView)
     523                 :            :     {
     524                 :          0 :         pDrawView->SetBufferedOutputAllowed( false );
     525                 :          0 :         pDrawView->SetBufferedOverlayAllowed( false );
     526                 :            :     }
     527                 :            : 
     528                 :            :     {   //Zusaetzlicher Scope, damit die CurrShell vor dem zerstoeren der
     529                 :            :         //Shell zurueckgesetzt wird.
     530                 :            : 
     531         [ #  # ]:          0 :         SET_CURR_SHELL( pShell );
     532                 :            : 
     533                 :            :         //JP 01.02.99: das ReadOnly Flag wird NIE mitkopiert; Bug 61335
     534         [ #  # ]:          0 :         if( pOpt->IsReadonly() )
     535                 :          0 :             pShell->pOpt->SetReadonly( sal_True );
     536                 :            : 
     537                 :            :         // save options at draw view:
     538 [ #  # ][ #  # ]:          0 :         SwDrawViewSave aDrawViewSave( pShell->GetDrawView() );
     539                 :            : 
     540         [ #  # ]:          0 :         pShell->PrepareForPrint( rPrintData );
     541                 :            : 
     542         [ #  # ]:          0 :         const sal_Int32 nPage = rPrintData.GetRenderData().GetPagesToPrint()[ nRenderer ];
     543                 :            :         OSL_ENSURE( nPage < 0 ||
     544                 :            :             rPrintData.GetRenderData().GetValidPagesSet().count( nPage ) == 1,
     545                 :            :             "ViewShell::PrintOrPDFExport: nPage not valid" );
     546                 :            :         ViewShell *const pViewSh2 = (nPage < 0)
     547                 :          0 :                 ? rPrintData.GetRenderData().m_pPostItShell.get()// post-it page
     548         [ #  # ]:          0 :                 : pShell; // a 'regular' page, not one from the post-it doc
     549                 :            : 
     550                 :            :         SwPageFrm const*const pStPage =
     551         [ #  # ]:          0 :             lcl_getPage(*pViewSh2->GetLayout(), abs(nPage));
     552                 :            :         OSL_ENSURE( pStPage, "failed to get start page" );
     553         [ #  # ]:          0 :         if (!pStPage)
     554                 :            :         {
     555                 :          0 :             return sal_False;
     556                 :            :         }
     557                 :            : 
     558                 :            :         //!! applying view options and formatting the document should now only be done in getRendererCount!
     559                 :            : 
     560         [ #  # ]:          0 :         ::SetSwVisArea( pViewSh2, pStPage->Frm() );
     561                 :            : 
     562                 :            : // FIXME disabled because rPrintData.aOffset is always (0,0)
     563                 :            : #if 0
     564                 :            :         //  wenn wir einen Umschlag drucken wird ein Offset beachtet
     565                 :            :         if( pStPage->GetFmt()->GetPoolFmtId() == RES_POOLPAGE_JAKET )
     566                 :            :         {
     567                 :            :             Point aNewOrigin = pOutDev->GetMapMode().GetOrigin();
     568                 :            :             aNewOrigin += rPrintData.aOffset;
     569                 :            :             MapMode aTmp( pOutDev->GetMapMode() );
     570                 :            :             aTmp.SetOrigin( aNewOrigin );
     571                 :            :             pOutDev->SetMapMode( aTmp );
     572                 :            :         }
     573                 :            : #endif
     574                 :            : 
     575         [ #  # ]:          0 :         pShell->InitPrt( pOutDev );
     576                 :            : 
     577         [ #  # ]:          0 :         ::SetSwVisArea( pViewSh2, pStPage->Frm() );
     578                 :            : 
     579         [ #  # ]:          0 :         pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData );
     580                 :            : 
     581 [ #  # ][ #  # ]:          0 :         SwPaintQueue::Repaint();
         [ #  # ][ #  # ]
                 [ #  # ]
     582                 :            :     }  //Zus. Scope wg. CurShell!
     583                 :            : 
     584         [ #  # ]:          0 :     delete pShell;
     585                 :            : 
     586                 :            :     // restore settings of OutputDevice (should be done always now since the
     587                 :            :     // output device is now provided by a call from outside the Writer)
     588                 :          0 :     pOutDev->Pop();
     589                 :            : 
     590                 :          0 :     return sal_True;
     591                 :            : }
     592                 :            : 
     593                 :            : /******************************************************************************
     594                 :            :  *  Methode     :   PrtOle2()
     595                 :            :  *  Beschreibung:
     596                 :            :  *  Erstellt    :   PK 07.12.94
     597                 :            :  *  Aenderung   :   MA 16. Feb. 95
     598                 :            :  ******************************************************************************/
     599                 :            : 
     600                 :            : 
     601                 :            : 
     602                 :         19 : void ViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintData& rOptions,
     603                 :            :                          OutputDevice* pOleOut, const Rectangle& rRect )
     604                 :            : {
     605                 :            :   //Wir brauchen eine Shell fuer das Drucken. Entweder hat das Doc schon
     606                 :            :     //eine, dann legen wir uns eine neue Sicht an, oder das Doc hat noch
     607                 :            :     //keine, dann erzeugen wir die erste Sicht.
     608                 :            :     ViewShell *pSh;
     609         [ +  - ]:         19 :     if( pDoc->GetCurrentViewShell() )
     610         [ +  - ]:         19 :         pSh = new ViewShell( *pDoc->GetCurrentViewShell(), 0, pOleOut,VSHELLFLAG_SHARELAYOUT );//swmod 080129
     611                 :            :     else    //swmod 071108//swmod 071225
     612         [ #  # ]:          0 :         pSh = new ViewShell( *pDoc, 0, pOpt, pOleOut);//swmod 080129
     613                 :            : 
     614                 :            :     {
     615         [ +  - ]:         19 :         SET_CURR_SHELL( pSh );
     616         [ +  - ]:         19 :         pSh->PrepareForPrint( rOptions );
     617         [ +  - ]:         19 :         pSh->SetPrtFormatOption( sal_True );
     618                 :            : 
     619         [ +  - ]:         19 :         SwRect aSwRect( rRect );
     620                 :         19 :         pSh->aVisArea = aSwRect;
     621                 :            : 
     622         [ -  + ]:         19 :         if ( pSh->GetViewOptions()->getBrowseMode() &&
           [ -  +  #  # ]
     623                 :          0 :              pSh->GetNext() == pSh )
     624                 :            :         {
     625         [ #  # ]:          0 :             pSh->CheckBrowseView( sal_False );
     626 [ #  # ][ #  # ]:          0 :             pSh->GetLayout()->Lower()->InvalidateSize();
     627                 :            :         }
     628                 :            : 
     629                 :            :         // CalcPagesForPrint() should not be necessary here. The pages in the
     630                 :            :         // visible area will be formatted in SwRootFrm::Paint().
     631                 :            :         // Removing this gives us a performance gain during saving the
     632                 :            :         // document because the thumbnail creation will not trigger a complete
     633                 :            :         // formatting of the document.
     634                 :            :         // Seiten fuers Drucken formatieren
     635                 :            :         // pSh->CalcPagesForPrint( SHRT_MAX );
     636                 :            :         //#39275# jetzt will der Meyer doch ein Clipping
     637         [ +  - ]:         19 :         pOleOut->Push( PUSH_CLIPREGION );
     638 [ +  - ][ +  - ]:         19 :         pOleOut->IntersectClipRegion( aSwRect.SVRect() );
     639 [ +  - ][ +  - ]:         19 :         pSh->GetLayout()->Paint( aSwRect );
     640                 :            : //      SFX_APP()->SpoilDemoOutput( *pOleOut, rRect );
     641                 :            : 
     642 [ +  - ][ +  - ]:         19 :         pOleOut->Pop();
     643                 :            :         // erst muss das CurrShell Object zerstoert werden!!
     644                 :            :     }
     645         [ +  - ]:         19 :     delete pSh;
     646                 :         19 : }
     647                 :            : 
     648                 :            : /******************************************************************************
     649                 :            :  *  Methode     :   IsAnyFieldInDoc()
     650                 :            :  *  Beschreibung:   Stellt fest, ob im DocNodesArray Felder verankert sind
     651                 :            :  *  Erstellt    :   JP 27.07.95
     652                 :            :  *  Aenderung   :   JP 10.12.97
     653                 :            :  ******************************************************************************/
     654                 :            : 
     655                 :            : 
     656                 :            : 
     657                 :          0 : sal_Bool ViewShell::IsAnyFieldInDoc() const
     658                 :            : {
     659                 :            :     const SfxPoolItem* pItem;
     660                 :          0 :     sal_uInt32 nMaxItems = pDoc->GetAttrPool().GetItemCount2( RES_TXTATR_FIELD );
     661         [ #  # ]:          0 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
     662         [ #  # ]:          0 :         if( 0 != (pItem = pDoc->GetAttrPool().GetItem2( RES_TXTATR_FIELD, n )))
     663                 :            :         {
     664                 :          0 :             const SwFmtFld* pFmtFld = (SwFmtFld*)pItem;
     665                 :          0 :             const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
     666                 :            :             //#i101026# mod: do not include postits in field check
     667                 :          0 :             const SwField* pFld = pFmtFld->GetFld();
     668 [ #  # ][ #  # ]:          0 :             if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() && (pFld->Which() != RES_POSTITFLD))
         [ #  # ][ #  # ]
     669                 :          0 :                 return sal_True;
     670                 :            :         }
     671                 :          0 :     return sal_False;
     672                 :            : }
     673                 :            : 
     674                 :            : 
     675                 :            : 
     676                 :            : /******************************************************************************
     677                 :            :  *  SwDrawViewSave
     678                 :            :  *
     679                 :            :  *  Saves some settings at the draw view
     680                 :            :  ******************************************************************************/
     681                 :            : 
     682                 :          0 : SwDrawViewSave::SwDrawViewSave( SdrView* pSdrView )
     683                 :          0 :     : pDV( pSdrView )
     684                 :            : {
     685         [ #  # ]:          0 :     if ( pDV )
     686                 :            :     {
     687         [ #  # ]:          0 :         sLayerNm.AssignAscii( RTL_CONSTASCII_STRINGPARAM("Controls" ) );
     688         [ #  # ]:          0 :         bPrintControls = pDV->IsLayerPrintable( sLayerNm );
     689                 :            :     }
     690                 :          0 : }
     691                 :            : 
     692                 :          0 : SwDrawViewSave::~SwDrawViewSave()
     693                 :            : {
     694         [ #  # ]:          0 :     if ( pDV )
     695                 :            :     {
     696         [ #  # ]:          0 :         pDV->SetLayerPrintable( sLayerNm, bPrintControls );
     697                 :            :     }
     698                 :          0 : }
     699                 :            : 
     700                 :            : 
     701                 :            : // OD 09.01.2003 #i6467# - method also called for page preview
     702                 :         19 : void ViewShell::PrepareForPrint( const SwPrintData &rOptions )
     703                 :            : {
     704                 :         19 :     pOpt->SetGraphic ( sal_True == rOptions.bPrintGraphic );
     705                 :         19 :     pOpt->SetTable   ( sal_True == rOptions.bPrintTable );
     706                 :         19 :     pOpt->SetDraw    ( sal_True == rOptions.bPrintDraw  );
     707                 :         19 :     pOpt->SetControl ( sal_True == rOptions.bPrintControl );
     708                 :         19 :     pOpt->SetPageBack( sal_True == rOptions.bPrintPageBackground );
     709                 :         19 :     pOpt->SetBlackFont( sal_True == rOptions.bPrintBlackFont );
     710                 :            : 
     711         [ +  - ]:         19 :     if ( HasDrawView() )
     712                 :            :     {
     713         [ +  - ]:         19 :         SdrView *pDrawView = GetDrawView();
     714         [ +  - ]:         19 :         String sLayerNm;
     715         [ +  - ]:         19 :         sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Controls" ));
     716                 :            :         // OD 09.01.2003 #i6467# - consider, if view shell belongs to page preview
     717         [ +  - ]:         19 :         if ( !IsPreView() )
     718                 :            :         {
     719         [ +  - ]:         19 :             pDrawView->SetLayerPrintable( sLayerNm, rOptions.bPrintControl );
     720                 :            :         }
     721                 :            :         else
     722                 :            :         {
     723         [ #  # ]:          0 :             pDrawView->SetLayerVisible( sLayerNm, rOptions.bPrintControl );
     724         [ +  - ]:         19 :         }
     725                 :            :     }
     726                 :         19 : }
     727                 :            : 
     728                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10