LCOV - code coverage report
Current view: top level - sd/source/ui/view - DocumentRenderer.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 881 0.0 %
Date: 2014-04-14 Functions: 0 93 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             : 
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : 
      23             : #include "DocumentRenderer.hxx"
      24             : #include "DocumentRenderer.hrc"
      25             : 
      26             : #include "drawdoc.hxx"
      27             : #include "optsitem.hxx"
      28             : #include "sdresid.hxx"
      29             : #include "strings.hrc"
      30             : #include "sdattr.hxx"
      31             : #include "Window.hxx"
      32             : #include "drawview.hxx"
      33             : #include "DrawViewShell.hxx"
      34             : #include "FrameView.hxx"
      35             : #include "Outliner.hxx"
      36             : #include "OutlineViewShell.hxx"
      37             : 
      38             : #include <basegfx/polygon/b2dpolygon.hxx>
      39             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      40             : #include <basegfx/matrix/b2dhommatrix.hxx>
      41             : #include <sfx2/printer.hxx>
      42             : #include <editeng/editstat.hxx>
      43             : #include <editeng/outlobj.hxx>
      44             : #include <svx/svdetc.hxx>
      45             : #include <svx/svditer.hxx>
      46             : #include <svx/svdopage.hxx>
      47             : #include <svx/svdopath.hxx>
      48             : #include <svx/xlnclit.hxx>
      49             : #include <toolkit/awt/vclxdevice.hxx>
      50             : #include <tools/resary.hxx>
      51             : #include <unotools/localedatawrapper.hxx>
      52             : #include <vcl/msgbox.hxx>
      53             : #include <unotools/moduleoptions.hxx>
      54             : 
      55             : #include <vector>
      56             : 
      57             : using namespace ::com::sun::star;
      58             : using namespace ::com::sun::star::uno;
      59             : 
      60             : 
      61             : namespace sd {
      62             : 
      63             : namespace {
      64             : 
      65             : 
      66             :     /** Convenience class to extract values from the sequence of properties
      67             :         given to one of the XRenderable methods.
      68             :     */
      69           0 :     class PrintOptions
      70             :     {
      71             :     public:
      72           0 :         PrintOptions (
      73             :             const vcl::PrinterOptionsHelper& rHelper,
      74             :             const ::std::vector<sal_Int32>& rSlidesPerPage)
      75             :             : mrProperties(rHelper),
      76           0 :               maSlidesPerPage(rSlidesPerPage)
      77             :         {
      78           0 :         }
      79             : 
      80           0 :         bool IsWarningOrientation() const
      81             :         {
      82           0 :             return GetBoolValue(NULL, true);
      83             :         }
      84             : 
      85           0 :         bool IsPrintPageName() const
      86             :         {
      87           0 :             return GetBoolValue("IsPrintName");
      88             :         }
      89             : 
      90           0 :         bool IsDate() const
      91             :         {
      92           0 :             return GetBoolValue("IsPrintDateTime");
      93             :         }
      94             : 
      95           0 :         bool IsTime() const
      96             :         {
      97           0 :             return GetBoolValue("IsPrintDateTime");
      98             :         }
      99             : 
     100           0 :         bool IsHiddenPages() const
     101             :         {
     102           0 :             return GetBoolValue("IsPrintHidden");
     103             :         }
     104             : 
     105           0 :         bool IsHandoutHorizontal() const
     106             :         {
     107           0 :             return GetBoolValue("SlidesPerPageOrder", sal_Int32(0));
     108             :         }
     109             : 
     110           0 :         sal_Int32 GetHandoutPageCount() const
     111             :         {
     112           0 :             sal_uInt32 nIndex = static_cast<sal_Int32>(mrProperties.getIntValue("SlidesPerPage", sal_Int32(0)));
     113           0 :             if (nIndex<maSlidesPerPage.size())
     114           0 :                 return maSlidesPerPage[nIndex];
     115           0 :             else if ( ! maSlidesPerPage.empty())
     116           0 :                 return maSlidesPerPage[0];
     117             :             else
     118           0 :                 return 0;
     119             :         }
     120             : 
     121           0 :         bool IsDraw() const
     122             :         {
     123           0 :             return GetBoolValue("PageContentType", sal_Int32(0));
     124             :         }
     125             : 
     126           0 :         bool IsHandout() const
     127             :         {
     128           0 :             return GetBoolValue("PageContentType", sal_Int32(1));
     129             :         }
     130             : 
     131           0 :         bool IsNotes() const
     132             :         {
     133           0 :             return GetBoolValue("PageContentType", sal_Int32(2));
     134             :         }
     135             : 
     136           0 :         bool IsOutline() const
     137             :         {
     138           0 :             return GetBoolValue("PageContentType", sal_Int32(3));
     139             :         }
     140             : 
     141           0 :         sal_uLong GetOutputQuality() const
     142             :         {
     143           0 :             sal_Int32 nQuality = static_cast<sal_Int32>(mrProperties.getIntValue( "Quality", sal_Int32(0) ));
     144           0 :             return nQuality;
     145             :         }
     146             : 
     147           0 :         bool IsPageSize() const
     148             :         {
     149           0 :             return GetBoolValue("PageOptions", sal_Int32(1));
     150             :         }
     151             : 
     152           0 :         bool IsTilePage() const
     153             :         {
     154           0 :             return GetBoolValue("PageOptions", sal_Int32(2)) || GetBoolValue("PageOptions", sal_Int32(3));
     155             :         }
     156             : 
     157           0 :         bool IsCutPage() const
     158             :         {
     159           0 :             return GetBoolValue("PageOptions", sal_Int32(0));
     160             :         }
     161             : 
     162           0 :         bool IsBooklet() const
     163             :         {
     164           0 :             return GetBoolValue("PrintProspect", false);
     165             :         }
     166             : 
     167           0 :         bool IsPrintExcluded() const
     168             :         {
     169           0 :             return (IsNotes() || IsDraw() || IsHandout()) &&  IsHiddenPages();
     170             :         }
     171             : 
     172           0 :         bool IsPrintFrontPage() const
     173             :         {
     174           0 :             sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
     175           0 :             return nInclude == 0 || nInclude == 1;
     176             :         }
     177             : 
     178           0 :         bool IsPrintBackPage() const
     179             :         {
     180           0 :             sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
     181           0 :             return nInclude == 0 || nInclude == 2;
     182             :         }
     183             : 
     184           0 :         bool IsPaperBin() const
     185             :         {
     186           0 :             return GetBoolValue("PrintPaperFromSetup", false);
     187             :         }
     188             : 
     189           0 :         bool IsPrintMarkedOnly() const
     190             :         {
     191           0 :             return GetBoolValue("PrintContent", sal_Int32(2));
     192             :         }
     193             : 
     194           0 :         OUString GetPrinterSelection (sal_Int32 nPageCount, sal_Int32 nCurrentPageIndex) const
     195             :         {
     196           0 :             sal_Int32 nContent = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
     197           0 :             OUString sFullRange = "1-" + OUString::number(nPageCount);
     198             : 
     199           0 :             if (nContent == 0) // all pages/slides
     200             :             {
     201           0 :                 return sFullRange;
     202             :             }
     203             : 
     204           0 :             if (nContent == 1) // range
     205             :             {
     206           0 :                 OUString sValue = mrProperties.getStringValue("PageRange");
     207           0 :                 return sValue.isEmpty() ? sFullRange : sValue;
     208             :             }
     209             : 
     210           0 :             if (nContent == 2 && // selection
     211             :                 nCurrentPageIndex >= 0)
     212             :             {
     213           0 :                 return OUString::number(nCurrentPageIndex + 1);
     214             :             }
     215             : 
     216           0 :             return OUString();
     217             :         }
     218             : 
     219             :     private:
     220             :         const vcl::PrinterOptionsHelper& mrProperties;
     221             :         const ::std::vector<sal_Int32> maSlidesPerPage;
     222             : 
     223             :         /** When the value of the property with name pName is a boolean then
     224             :             return its value. When the property is unknown then
     225             :             bDefaultValue is returned.  Otherwise <FALSE/> is returned.
     226             :         */
     227           0 :         bool GetBoolValue (
     228             :             const sal_Char* pName,
     229             :             const bool bDefaultValue = false) const
     230             :         {
     231           0 :             sal_Bool bValue = mrProperties.getBoolValue( pName, bDefaultValue );
     232           0 :             return bValue;
     233             :         }
     234             : 
     235             :         /** Return <TRUE/> when the value of the property with name pName is
     236             :             an integer and its value is nTriggerValue. Otherwise <FALSE/> is
     237             :             returned.
     238             :         */
     239           0 :         bool GetBoolValue (
     240             :             const sal_Char* pName,
     241             :             const sal_Int32 nTriggerValue) const
     242             :         {
     243           0 :             sal_Int32 nValue = static_cast<sal_Int32>(mrProperties.getIntValue( pName ));
     244           0 :             return nValue == nTriggerValue;
     245             :         }
     246             :     };
     247             : 
     248             : 
     249             : 
     250             :     /** A collection of values that helps to reduce the number of arguments
     251             :         given to some functions.  Note that not all values are set at the
     252             :         same time.
     253             :     */
     254           0 :     class PrintInfo
     255             :     {
     256             :     public:
     257           0 :         PrintInfo (
     258             :             const Printer* pPrinter,
     259             :             const bool bPrintMarkedOnly)
     260             :             : mpPrinter(pPrinter),
     261             :               mnDrawMode(DRAWMODE_DEFAULT),
     262             :               msTimeDate(),
     263             :               msPageString(),
     264             :               maPrintSize(0,0),
     265             :               maPageSize(0,0),
     266             :               meOrientation(ORIENTATION_PORTRAIT),
     267             :               maMap(),
     268           0 :               mbPrintMarkedOnly(bPrintMarkedOnly)
     269           0 :         {}
     270             : 
     271             :         const Printer* mpPrinter;
     272             :         sal_uLong mnDrawMode;
     273             :         OUString msTimeDate;
     274             :         OUString msPageString;
     275             :         Size maPrintSize;
     276             :         Size maPageSize;
     277             :         Orientation meOrientation;
     278             :         MapMode maMap;
     279             :         const bool mbPrintMarkedOnly;
     280             :     };
     281             : 
     282             : 
     283             : 
     284             :     /** Output one page of the document to the given printer.  Note that
     285             :         more than one document page may be output to one printer page.
     286             :     */
     287           0 :     void PrintPage (
     288             :         Printer& rPrinter,
     289             :         ::sd::View& rPrintView,
     290             :         SdPage& rPage,
     291             :         View* pView,
     292             :         const bool bPrintMarkedOnly,
     293             :         const SetOfByte& rVisibleLayers,
     294             :         const SetOfByte& rPrintableLayers)
     295             :     {
     296           0 :         rPrintView.ShowSdrPage(&rPage);
     297             : 
     298           0 :         const MapMode aOriginalMapMode (rPrinter.GetMapMode());
     299             : 
     300             :         // Set the visible layers
     301           0 :         SdrPageView* pPageView = rPrintView.GetSdrPageView();
     302             :         OSL_ASSERT(pPageView!=NULL);
     303           0 :         pPageView->SetVisibleLayers(rVisibleLayers);
     304           0 :         pPageView->SetPrintableLayers(rPrintableLayers);
     305             : 
     306           0 :         if (pView!=NULL && bPrintMarkedOnly)
     307           0 :             pView->DrawMarkedObj(rPrinter);
     308             :         else
     309             :             rPrintView.CompleteRedraw(&rPrinter,
     310           0 :                     Region(Rectangle(Point(0,0), rPage.GetSize())));
     311             : 
     312           0 :         rPrinter.SetMapMode(aOriginalMapMode);
     313             : 
     314           0 :         rPrintView.HideSdrPage();
     315           0 :     }
     316             : 
     317             : 
     318             : 
     319             : 
     320             :     /** Output a string (that typically is not part of a document page) to
     321             :         the given printer.
     322             :     */
     323           0 :     void PrintMessage (
     324             :         Printer& rPrinter,
     325             :         const OUString& rsPageString,
     326             :         const Point& rPageStringOffset)
     327             :     {
     328           0 :         const Font aOriginalFont (rPrinter.OutputDevice::GetFont());
     329           0 :         rPrinter.SetFont(Font(FAMILY_SWISS, Size(0, 423)));
     330           0 :         rPrinter.DrawText(rPageStringOffset, rsPageString);
     331           0 :         rPrinter.SetFont(aOriginalFont);
     332           0 :     }
     333             : 
     334             : 
     335             : 
     336             : 
     337             :     /** Read the resource file and process it into a sequence of properties
     338             :         that can be passed to the printing dialog.
     339             :     */
     340           0 :     class DialogCreator : Resource
     341             :     {
     342             :     public:
     343           0 :         DialogCreator (bool bImpress, sal_Int32 nCurPage)
     344             :             : Resource(SdResId(_STR_IMPRESS_PRINT_UI_OPTIONS))
     345             :             , mbImpress(bImpress)
     346           0 :             , mnCurPage(nCurPage)
     347             :         {
     348           0 :             ProcessResource();
     349           0 :         }
     350             : 
     351           0 :         Sequence< beans::PropertyValue > GetDialogControls() const
     352             :         {
     353           0 :             if (maProperties.empty())
     354           0 :                 return Sequence< beans::PropertyValue >();
     355             :             else
     356             :             {
     357             :                 return Sequence<beans::PropertyValue>(
     358           0 :                         &maProperties.front(),
     359           0 :                         maProperties.size());
     360             :             }
     361             :         }
     362             : 
     363           0 :         ::std::vector<sal_Int32> GetSlidesPerPage() const
     364             :         {
     365           0 :             return maSlidesPerPage;
     366             :         }
     367             : 
     368             :     private:
     369             :         Any maDialog;
     370             :         ::std::vector<beans::PropertyValue> maProperties;
     371             :         ::std::vector<sal_Int32> maSlidesPerPage;
     372             :         bool mbImpress;
     373             :         sal_Int32 mnCurPage;
     374             : 
     375           0 :         void ProcessResource()
     376             :         {
     377             :             // load the writer PrinterOptions into the custom tab
     378           0 :             beans::PropertyValue aOptionsUIFile;
     379           0 :             aOptionsUIFile.Name = "OptionsUIFile";
     380           0 :             if( mbImpress )
     381           0 :                 aOptionsUIFile.Value <<= OUString("modules/simpress/ui/printeroptions.ui");
     382             :             else
     383           0 :                 aOptionsUIFile.Value <<= OUString("modules/sdraw/ui/printeroptions.ui");
     384           0 :             maProperties.push_back(aOptionsUIFile);
     385             : 
     386           0 :             SvtModuleOptions aOpt;
     387           0 :             OUString aAppGroupname(SD_RESSTR(_STR_IMPRESS_PRINT_UI_GROUP_NAME));
     388           0 :             aAppGroupname = aAppGroupname.replaceFirst("%s", aOpt.GetModuleName(
     389           0 :                 mbImpress ? SvtModuleOptions::E_SIMPRESS : SvtModuleOptions::E_SDRAW));
     390           0 :             AddDialogControl(vcl::PrinterOptionsHelper::setGroupControlOpt("tabcontrol-page2", aAppGroupname, ".HelpID:vcl:PrintDialog:TabPage:AppPage"));
     391             : 
     392           0 :             uno::Sequence< OUString > aHelpIds, aWidgetIds;
     393           0 :             if( mbImpress )
     394             :             {
     395           0 :                 vcl::PrinterOptionsHelper::UIControlOptions aPrintOpt;
     396           0 :                 aPrintOpt.maGroupHint = "JobPage" ;
     397             :                 AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("extraimpressprintoptions",
     398             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_PRINT_GROUP),
     399             :                                     "",
     400           0 :                                     aPrintOpt ));
     401             : 
     402           0 :                 aHelpIds.realloc( 1 );
     403           0 :                 aHelpIds[0] = ".HelpID:vcl:PrintDialog:PageContentType:ListBox" ;
     404             :                 AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt(
     405             :                                     "impressdocument",
     406             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_CONTENT),
     407             :                                     aHelpIds,
     408             :                                     "PageContentType" ,
     409             :                                     CreateChoice(_STR_IMPRESS_PRINT_UI_CONTENT_CHOICES),
     410             :                                     0)
     411           0 :                                 );
     412             : 
     413           0 :                 aHelpIds[0] = ".HelpID:vcl:PrintDialog:SlidesPerPage:ListBox" ;
     414           0 :                 vcl::PrinterOptionsHelper::UIControlOptions aContentOpt( "PageContentType" , 1 );
     415             :                 AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt(
     416             :                                     "slidesperpage",
     417             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_SLIDESPERPAGE),
     418             :                                     aHelpIds,
     419             :                                     "SlidesPerPage" ,
     420             :                                     GetSlidesPerPageSequence(),
     421             :                                     0,
     422             :                                     Sequence< sal_Bool >(),
     423             :                                     aContentOpt
     424             :                                     )
     425           0 :                                 );
     426             : 
     427           0 :                 aHelpIds[0] = ".HelpID:vcl:PrintDialog:SlidesPerPageOrder:ListBox" ;
     428           0 :                 vcl::PrinterOptionsHelper::UIControlOptions aSlidesPerPageOpt( "SlidesPerPage" , -1, true );
     429             :                 AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt(
     430             :                                     "slidesperpageorder",
     431             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_ORDER),
     432             :                                     aHelpIds,
     433             :                                     "SlidesPerPageOrder" ,
     434             :                                     CreateChoice(_STR_IMPRESS_PRINT_UI_ORDER_CHOICES),
     435             :                                     0,
     436             :                                     Sequence< sal_Bool >(),
     437             :                                     aSlidesPerPageOpt )
     438           0 :                                 );
     439             :             }
     440             : 
     441             :             AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("contents",
     442           0 :                                SD_RESSTR(_STR_IMPRESS_PRINT_UI_INCLUDE_CONTENT), "" ) );
     443             : 
     444             : 
     445           0 :             if( mbImpress )
     446             :             {
     447             :                 AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("printname",
     448             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_IS_PRINT_NAME),
     449             :                                     ".HelpID:vcl:PrintDialog:IsPrintName:CheckBox" ,
     450             :                                     "IsPrintName" ,
     451             :                                     false
     452             :                                     )
     453           0 :                                 );
     454             :             }
     455             :             else
     456             :             {
     457             :                 AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("printname",
     458             :                                     SD_RESSTR(_STR_DRAW_PRINT_UI_IS_PRINT_NAME),
     459             :                                     ".HelpID:vcl:PrintDialog:IsPrintName:CheckBox" ,
     460             :                                     "IsPrintName" ,
     461             :                                     false
     462             :                                     )
     463           0 :                                 );
     464             :             }
     465             : 
     466             :             AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("printdatetime",
     467             :                                 SD_RESSTR(_STR_IMPRESS_PRINT_UI_IS_PRINT_DATE),
     468             :                                 ".HelpID:vcl:PrintDialog:IsPrintDateTime:CheckBox" ,
     469             :                                 "IsPrintDateTime" ,
     470             :                                 false
     471             :                                 )
     472           0 :                             );
     473             : 
     474           0 :             if( mbImpress )
     475             :             {
     476             :                 AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("printhidden",
     477             :                                     SD_RESSTR(_STR_IMPRESS_PRINT_UI_IS_PRINT_HIDDEN),
     478             :                                     ".HelpID:vcl:PrintDialog:IsPrintHidden:CheckBox" ,
     479             :                                     "IsPrintHidden" ,
     480             :                                     false
     481             :                                     )
     482           0 :                                 );
     483             :             }
     484             : 
     485             :             AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("color",
     486           0 :                                SD_RESSTR(_STR_IMPRESS_PRINT_UI_QUALITY), "" ) );
     487             : 
     488           0 :             aHelpIds.realloc( 3 );
     489           0 :             aHelpIds[0] = ".HelpID:vcl:PrintDialog:Quality:RadioButton:0" ;
     490           0 :             aHelpIds[1] = ".HelpID:vcl:PrintDialog:Quality:RadioButton:1" ;
     491           0 :             aHelpIds[2] = ".HelpID:vcl:PrintDialog:Quality:RadioButton:2" ;
     492           0 :             aWidgetIds.realloc( 3 );
     493           0 :             aWidgetIds[0] = "originalcolors";
     494           0 :             aWidgetIds[1] = "grayscale";
     495           0 :             aWidgetIds[2] = "blackandwhite";
     496             :             AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(
     497             :                                 aWidgetIds,
     498             :                                 "",
     499             :                                 aHelpIds,
     500             :                                 "Quality" ,
     501             :                                 CreateChoice(_STR_IMPRESS_PRINT_UI_QUALITY_CHOICES),
     502             :                                 0)
     503           0 :                             );
     504             : 
     505             :             AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("pagesizes",
     506           0 :                                SD_RESSTR(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS), "" ) );
     507             : 
     508           0 :             aHelpIds.realloc( 4 );
     509           0 :             aHelpIds[0] = ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:0" ;
     510           0 :             aHelpIds[1] = ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:1" ;
     511           0 :             aHelpIds[2] = ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:2" ;
     512           0 :             aHelpIds[3] = ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:3" ;
     513           0 :             aWidgetIds.realloc( 4 );
     514           0 :             aWidgetIds[0] = "originalsize";
     515           0 :             aWidgetIds[1] = "fittoprintable";
     516           0 :             aWidgetIds[2] = "distributeonmultiple";
     517           0 :             aWidgetIds[3] = "tilesheet";
     518           0 :             if( mbImpress )
     519             :             {
     520             :                 // FIXME: additional dependency on PrintProspect = false
     521           0 :                 vcl::PrinterOptionsHelper::UIControlOptions aPageOptionsOpt( "PageContentType" , 0 );
     522             :                 AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(
     523             :                                     aWidgetIds,
     524             :                                     "",
     525             :                                     aHelpIds,
     526             :                                     "PageOptions" ,
     527             :                                     CreateChoice(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES),
     528             :                                     0,
     529             :                                     Sequence< sal_Bool >(),
     530             :                                     aPageOptionsOpt
     531             :                                     )
     532           0 :                                 );
     533             :             }
     534             :             else
     535             :             {
     536           0 :                 vcl::PrinterOptionsHelper::UIControlOptions aPageOptionsOpt( "PrintProspect" , sal_False );
     537             :                 AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(
     538             :                                     aWidgetIds,
     539             :                                     "",
     540             :                                     aHelpIds,
     541             :                                     "PageOptions" ,
     542             :                                     CreateChoice(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW),
     543             :                                     0,
     544             :                                     Sequence< sal_Bool >(),
     545             :                                     aPageOptionsOpt
     546             :                                     )
     547           0 :                                 );
     548             :             }
     549             : 
     550           0 :             vcl::PrinterOptionsHelper::UIControlOptions aBrochureOpt;
     551           0 :             aBrochureOpt.maGroupHint = "LayoutPage" ;
     552             :             AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("pagesides",
     553             :                                SD_RESSTR(_STR_IMPRESS_PRINT_UI_PAGE_SIDES), "",
     554           0 :                                aBrochureOpt ) );
     555             : 
     556             :             // brochure printing
     557             :             AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("brochure",
     558             :                                 SD_RESSTR(_STR_IMPRESS_PRINT_UI_BROCHURE),
     559             :                                 ".HelpID:vcl:PrintDialog:PrintProspect:CheckBox" ,
     560             :                                 "PrintProspect" ,
     561             :                                 false,
     562             :                                 aBrochureOpt
     563             :                                 )
     564           0 :                             );
     565             : 
     566             :             vcl::PrinterOptionsHelper::UIControlOptions
     567           0 :                 aIncludeOpt( "PrintProspect" , -1, false );
     568           0 :             aIncludeOpt.maGroupHint =  "LayoutPage" ;
     569           0 :             aHelpIds.realloc( 1 );
     570           0 :             aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintProspectInclude:ListBox" ;
     571             :             AddDialogControl( vcl::PrinterOptionsHelper::setChoiceListControlOpt(
     572             :                                 "brochureinclude",
     573             :                                 SD_RESSTR(_STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE),
     574             :                                 aHelpIds,
     575             :                                 "PrintProspectInclude" ,
     576             :                                 CreateChoice(_STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST),
     577             :                                 0,
     578             :                                 Sequence< sal_Bool >(),
     579             :                                 aIncludeOpt
     580             :                                 )
     581           0 :                             );
     582             : 
     583             :             // paper tray (on options page)
     584           0 :             vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt;
     585           0 :             aPaperTrayOpt.maGroupHint = "OptionsPageOptGroup" ;
     586             :             AddDialogControl( vcl::PrinterOptionsHelper::setBoolControlOpt("printpaperfromsetup",
     587             :                                 SD_RESSTR(_STR_IMPRESS_PRINT_UI_PAPER_TRAY),
     588             :                                 ".HelpID:vcl:PrintDialog:PrintPaperFromSetup:CheckBox" ,
     589             :                                 "PrintPaperFromSetup" ,
     590             :                                 false,
     591             :                                 aPaperTrayOpt
     592             :                                 )
     593           0 :                             );
     594             :             // print range selection
     595           0 :             vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
     596           0 :             aPrintRangeOpt.mbInternalOnly = true;
     597           0 :             aPrintRangeOpt.maGroupHint = "PrintRange" ;
     598             :             AddDialogControl( vcl::PrinterOptionsHelper::setSubgroupControlOpt("printrange",
     599             :                                 SD_RESSTR(_STR_IMPRESS_PRINT_UI_PAGE_RANGE),
     600             :                                 "",
     601             :                                 aPrintRangeOpt )
     602           0 :                              );
     603             : 
     604             :             // create a choice for the content to create
     605           0 :             OUString aPrintRangeName( "PrintContent" );
     606           0 :             aHelpIds.realloc( 3 );
     607           0 :             aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ;
     608           0 :             aHelpIds[1] = ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ;
     609           0 :             aHelpIds[2] = ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ;
     610           0 :             aWidgetIds.realloc( 3 );
     611           0 :             aWidgetIds[0] = "printallpages";
     612           0 :             aWidgetIds[1] = "printpages";
     613           0 :             aWidgetIds[2] = "printselection";
     614             :             AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(aWidgetIds, "",
     615             :                                 aHelpIds,
     616             :                                 aPrintRangeName,
     617             :                                 CreateChoice(mbImpress
     618             :                                              ? _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE
     619             :                                              : _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE),
     620             :                                 0 )
     621           0 :                             );
     622             :             // create a an Edit dependent on "Pages" selected
     623           0 :             vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, true );
     624             :             AddDialogControl(vcl::PrinterOptionsHelper::setEditControlOpt("pagerange", "",
     625             :                                 ".HelpID:vcl:PrintDialog:PageRange:Edit", "PageRange",
     626           0 :                                 OUString::number(mnCurPage + 1), aPageRangeOpt));
     627             : 
     628           0 :             FreeResource();
     629           0 :         }
     630             : 
     631           0 :         void AddDialogControl( const Any& i_rCtrl )
     632             :         {
     633           0 :             beans::PropertyValue aVal;
     634           0 :             aVal.Value = i_rCtrl;
     635           0 :             maProperties.push_back( aVal );
     636           0 :         }
     637             : 
     638           0 :         Sequence<OUString> CreateChoice (const sal_uInt16 nResourceId) const
     639             :         {
     640           0 :             SdResId aResourceId (nResourceId);
     641           0 :             ResStringArray aChoiceStrings (aResourceId);
     642             : 
     643           0 :             const sal_uInt32 nCount (aChoiceStrings.Count());
     644           0 :             Sequence<OUString> aChoices (nCount);
     645           0 :             for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
     646           0 :                 aChoices[nIndex] = aChoiceStrings.GetString(nIndex);
     647             : 
     648           0 :             return aChoices;
     649             :         }
     650             : 
     651           0 :         Sequence<OUString> GetSlidesPerPageSequence()
     652             :         {
     653             :             const Sequence<OUString> aChoice (
     654           0 :                 CreateChoice(_STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES));
     655           0 :             maSlidesPerPage.clear();
     656           0 :             maSlidesPerPage.push_back(0); // first is using the default
     657           0 :             for (sal_Int32 nIndex=1,nCount=aChoice.getLength(); nIndex<nCount; ++nIndex)
     658           0 :                 maSlidesPerPage.push_back(aChoice[nIndex].toInt32());
     659           0 :             return aChoice;
     660             :         }
     661             :     };
     662             : 
     663             : 
     664             : 
     665             : 
     666             :     /** The Prepare... methods of the DocumentRenderer::Implementation class
     667             :         create a set of PrinterPage objects that contain all necessary
     668             :         information to do the actual printing.  There is one PrinterPage
     669             :         object per printed page.  Derived classes implement the actual, mode
     670             :         specific printing.
     671             : 
     672             :         This and all derived classes support the asynchronous printing
     673             :         process by not storing pointers to any data with lifetime shorter
     674             :         than the PrinterPage objects, i.e. slides, shapes, (one of) the
     675             :         outliner (of the document).
     676             :     */
     677             :     class PrinterPage
     678             :     {
     679             :     public:
     680           0 :         PrinterPage (
     681             :             const PageKind ePageKind,
     682             :             const MapMode& rMapMode,
     683             :             const bool bPrintMarkedOnly,
     684             :             const OUString& rsPageString,
     685             :             const Point& rPageStringOffset,
     686             :             const sal_uLong nDrawMode,
     687             :             const Orientation eOrientation,
     688             :             const sal_uInt16 nPaperTray)
     689             :             : mePageKind(ePageKind),
     690             :               maMap(rMapMode),
     691             :               mbPrintMarkedOnly(bPrintMarkedOnly),
     692             :               msPageString(rsPageString),
     693             :               maPageStringOffset(rPageStringOffset),
     694             :               mnDrawMode(nDrawMode),
     695             :               meOrientation(eOrientation),
     696           0 :               mnPaperTray(nPaperTray)
     697             :         {
     698           0 :         }
     699             : 
     700           0 :         virtual ~PrinterPage() {}
     701             : 
     702             :         virtual void Print (
     703             :             Printer& rPrinter,
     704             :             SdDrawDocument& rDocument,
     705             :             ViewShell& rViewShell,
     706             :             View* pView,
     707             :             DrawView& rPrintView,
     708             :             const SetOfByte& rVisibleLayers,
     709             :             const SetOfByte& rPrintableLayers) const = 0;
     710             : 
     711           0 :         sal_uLong GetDrawMode() const { return mnDrawMode; }
     712           0 :         Orientation GetOrientation() const { return meOrientation; }
     713           0 :         sal_uInt16 GetPaperTray() const { return mnPaperTray; }
     714             : 
     715             :     protected:
     716             :         const PageKind mePageKind;
     717             :         const MapMode maMap;
     718             :         const bool mbPrintMarkedOnly;
     719             :         const OUString msPageString;
     720             :         const Point maPageStringOffset;
     721             :         const sal_uLong mnDrawMode;
     722             :         const Orientation meOrientation;
     723             :         const sal_uInt16 mnPaperTray;
     724             :     };
     725             : 
     726             : 
     727             : 
     728             : 
     729             :     /** The RegularPrinterPage is used for printing one regular slide (no
     730             :         notes, handout, or outline) to one printer page.
     731             :     */
     732             :     class RegularPrinterPage : public PrinterPage
     733             :     {
     734             :     public:
     735           0 :         RegularPrinterPage (
     736             :             const sal_uInt16 nPageIndex,
     737             :             const PageKind ePageKind,
     738             :             const MapMode& rMapMode,
     739             :             const bool bPrintMarkedOnly,
     740             :             const OUString& rsPageString,
     741             :             const Point& rPageStringOffset,
     742             :             const sal_uLong nDrawMode,
     743             :             const Orientation eOrientation,
     744             :             const sal_uInt16 nPaperTray)
     745             :             : PrinterPage(ePageKind, rMapMode, bPrintMarkedOnly, rsPageString,
     746             :                 rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
     747           0 :               mnPageIndex(nPageIndex)
     748             :         {
     749           0 :         }
     750             : 
     751           0 :         virtual ~RegularPrinterPage() {}
     752             : 
     753           0 :         virtual void Print (
     754             :             Printer& rPrinter,
     755             :             SdDrawDocument& rDocument,
     756             :             ViewShell& rViewShell,
     757             :             View* pView,
     758             :             DrawView& rPrintView,
     759             :             const SetOfByte& rVisibleLayers,
     760             :             const SetOfByte& rPrintableLayers) const SAL_OVERRIDE
     761             :         {
     762             :             (void)rViewShell;
     763           0 :             SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
     764           0 :             rPrinter.SetMapMode(maMap);
     765             :             PrintPage(
     766             :                 rPrinter,
     767             :                 rPrintView,
     768             :                 *pPageToPrint,
     769             :                 pView,
     770             :                 mbPrintMarkedOnly,
     771             :                 rVisibleLayers,
     772           0 :                 rPrintableLayers);
     773             :             PrintMessage(
     774             :                 rPrinter,
     775             :                 msPageString,
     776           0 :                 maPageStringOffset);
     777           0 :         }
     778             : 
     779             :     private:
     780             :         const sal_uInt16 mnPageIndex;
     781             :     };
     782             : 
     783             : 
     784             : 
     785             : 
     786             :     /** Print one slide multiple times on a printer page so that the whole
     787             :         printer page is covered.
     788             :     */
     789             :     class TiledPrinterPage : public PrinterPage
     790             :     {
     791             :     public:
     792           0 :         TiledPrinterPage (
     793             :             const sal_uInt16 nPageIndex,
     794             :             const PageKind ePageKind,
     795             :             const sal_Int32 nGap,
     796             :             const bool bPrintMarkedOnly,
     797             :             const OUString& rsPageString,
     798             :             const Point& rPageStringOffset,
     799             :             const sal_uLong nDrawMode,
     800             :             const Orientation eOrientation,
     801             :             const sal_uInt16 nPaperTray)
     802             :             : PrinterPage(ePageKind, MapMode(), bPrintMarkedOnly, rsPageString,
     803             :                 rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
     804             :               mnPageIndex(nPageIndex),
     805           0 :               mnGap(nGap)
     806             :         {
     807           0 :         }
     808             : 
     809           0 :         virtual ~TiledPrinterPage() {}
     810             : 
     811           0 :         virtual void Print (
     812             :             Printer& rPrinter,
     813             :             SdDrawDocument& rDocument,
     814             :             ViewShell& rViewShell,
     815             :             View* pView,
     816             :             DrawView& rPrintView,
     817             :             const SetOfByte& rVisibleLayers,
     818             :             const SetOfByte& rPrintableLayers) const SAL_OVERRIDE
     819             :         {
     820             :             (void)rViewShell;
     821           0 :             SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
     822           0 :             if (pPageToPrint==NULL)
     823           0 :                 return;
     824           0 :             MapMode aMap (rPrinter.GetMapMode());
     825             : 
     826           0 :             const Size aPageSize (pPageToPrint->GetSize());
     827           0 :             const Size aPrintSize (rPrinter.GetOutputSize());
     828             : 
     829           0 :             const sal_Int32 nPageWidth (aPageSize.Width() + mnGap
     830           0 :                 - pPageToPrint->GetLftBorder() - pPageToPrint->GetRgtBorder());
     831           0 :             const sal_Int32 nPageHeight (aPageSize.Height() + mnGap
     832           0 :                 - pPageToPrint->GetUppBorder() - pPageToPrint->GetLwrBorder());
     833           0 :             if (nPageWidth<=0 || nPageHeight<=0)
     834           0 :                 return;
     835             : 
     836             :             // Print at least two rows and columns.  More if the document
     837             :             // page fits completely onto the printer page.
     838             :             const sal_Int32 nColumnCount (::std::max(sal_Int32(2),
     839           0 :                     sal_Int32(aPrintSize.Width() / nPageWidth)));
     840             :             const sal_Int32 nRowCount (::std::max(sal_Int32(2),
     841           0 :                     sal_Int32(aPrintSize.Height() / nPageHeight)));
     842           0 :             for (sal_Int32 nRow=0; nRow<nRowCount; ++nRow)
     843           0 :                 for (sal_Int32 nColumn=0; nColumn<nColumnCount; ++nColumn)
     844             :                 {
     845           0 :                     aMap.SetOrigin(Point(nColumn*nPageWidth,nRow*nPageHeight));
     846           0 :                     rPrinter.SetMapMode(aMap);
     847             :                     PrintPage(
     848             :                         rPrinter,
     849             :                         rPrintView,
     850             :                         *pPageToPrint,
     851             :                         pView,
     852             :                         mbPrintMarkedOnly,
     853             :                         rVisibleLayers,
     854           0 :                         rPrintableLayers);
     855             :                 }
     856             : 
     857             :             PrintMessage(
     858             :                 rPrinter,
     859             :                 msPageString,
     860           0 :                 maPageStringOffset);
     861             :         }
     862             : 
     863             :     private:
     864             :         const sal_uInt16 mnPageIndex;
     865             :         const sal_Int32 mnGap;
     866             :     };
     867             : 
     868             :     /** Print two slides to one printer page so that the resulting pages
     869             :         form a booklet.
     870             :     */
     871             :     class BookletPrinterPage : public PrinterPage
     872             :     {
     873             :     public:
     874           0 :         BookletPrinterPage (
     875             :             const sal_uInt16 nFirstPageIndex,
     876             :             const sal_uInt16 nSecondPageIndex,
     877             :             const Point& rFirstOffset,
     878             :             const Point& rSecondOffset,
     879             :             const PageKind ePageKind,
     880             :             const MapMode& rMapMode,
     881             :             const bool bPrintMarkedOnly,
     882             :             const sal_uLong nDrawMode,
     883             :             const Orientation eOrientation,
     884             :             const sal_uInt16 nPaperTray)
     885             :             : PrinterPage(ePageKind, rMapMode, bPrintMarkedOnly, "",
     886             :                 Point(), nDrawMode, eOrientation, nPaperTray),
     887             :               mnFirstPageIndex(nFirstPageIndex),
     888             :               mnSecondPageIndex(nSecondPageIndex),
     889             :               maFirstOffset(rFirstOffset),
     890           0 :               maSecondOffset(rSecondOffset)
     891             :         {
     892           0 :         }
     893             : 
     894           0 :         virtual ~BookletPrinterPage() {}
     895             : 
     896           0 :         virtual void Print (
     897             :             Printer& rPrinter,
     898             :             SdDrawDocument& rDocument,
     899             :             ViewShell& rViewShell,
     900             :             View* pView,
     901             :             DrawView& rPrintView,
     902             :             const SetOfByte& rVisibleLayers,
     903             :             const SetOfByte& rPrintableLayers) const SAL_OVERRIDE
     904             :         {
     905             :             (void)rViewShell;
     906           0 :             MapMode aMap (maMap);
     907           0 :             SdPage* pPageToPrint = rDocument.GetSdPage(mnFirstPageIndex, mePageKind);
     908           0 :             if (pPageToPrint)
     909             :             {
     910           0 :                 aMap.SetOrigin(maFirstOffset);
     911           0 :                 rPrinter.SetMapMode(aMap);
     912             :                 PrintPage(
     913             :                     rPrinter,
     914             :                     rPrintView,
     915             :                     *pPageToPrint,
     916             :                     pView,
     917             :                     mbPrintMarkedOnly,
     918             :                     rVisibleLayers,
     919           0 :                     rPrintableLayers);
     920             :             }
     921             : 
     922           0 :             pPageToPrint = rDocument.GetSdPage(mnSecondPageIndex, mePageKind);
     923           0 :             if( pPageToPrint )
     924             :             {
     925           0 :                 aMap.SetOrigin(maSecondOffset);
     926           0 :                 rPrinter.SetMapMode(aMap);
     927             :                 PrintPage(
     928             :                     rPrinter,
     929             :                     rPrintView,
     930             :                     *pPageToPrint,
     931             :                     pView,
     932             :                     mbPrintMarkedOnly,
     933             :                     rVisibleLayers,
     934           0 :                     rPrintableLayers);
     935           0 :             }
     936           0 :         }
     937             : 
     938             :     private:
     939             :         const sal_uInt16 mnFirstPageIndex;
     940             :         const sal_uInt16 mnSecondPageIndex;
     941             :         const Point maFirstOffset;
     942             :         const Point maSecondOffset;
     943             :     };
     944             : 
     945             : 
     946             : 
     947             : 
     948             :     /** One handout page displays one to nine slides.
     949             :     */
     950           0 :     class HandoutPrinterPage : public PrinterPage
     951             :     {
     952             :     public:
     953           0 :         HandoutPrinterPage (
     954             :             const sal_uInt16 nHandoutPageIndex,
     955             :             const ::std::vector<sal_uInt16>& rPageIndices,
     956             :             const MapMode& rMapMode,
     957             :             const OUString& rsPageString,
     958             :             const Point& rPageStringOffset,
     959             :             const sal_uLong nDrawMode,
     960             :             const Orientation eOrientation,
     961             :             const sal_uInt16 nPaperTray)
     962             :             : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
     963             :                 rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
     964             :               mnHandoutPageIndex(nHandoutPageIndex),
     965           0 :               maPageIndices(rPageIndices)
     966             :         {
     967           0 :         }
     968             : 
     969           0 :         virtual void Print (
     970             :             Printer& rPrinter,
     971             :             SdDrawDocument& rDocument,
     972             :             ViewShell& rViewShell,
     973             :             View* pView,
     974             :             DrawView& rPrintView,
     975             :             const SetOfByte& rVisibleLayers,
     976             :             const SetOfByte& rPrintableLayers) const SAL_OVERRIDE
     977             :         {
     978           0 :             SdPage& rHandoutPage (*rDocument.GetSdPage(0, PK_HANDOUT));
     979             : 
     980           0 :             Reference< com::sun::star::beans::XPropertySet > xHandoutPage( rHandoutPage.getUnoPage(), UNO_QUERY );
     981           0 :             const OUString sPageNumber( "Number" );
     982             : 
     983             :             // Collect the page objects of the handout master.
     984           0 :             std::vector<SdrPageObj*> aHandoutPageObjects;
     985           0 :             SdrObjListIter aShapeIter (rHandoutPage);
     986           0 :             while (aShapeIter.IsMore())
     987             :             {
     988           0 :                 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
     989           0 :                 if (pPageObj)
     990           0 :                     aHandoutPageObjects.push_back(pPageObj);
     991             :             }
     992           0 :             if (aHandoutPageObjects.empty())
     993           0 :                 return;
     994             : 
     995             :             // Connect page objects with pages.
     996           0 :             std::vector<SdrPageObj*>::iterator aPageObjIter (aHandoutPageObjects.begin());
     997           0 :             for (std::vector<sal_uInt16>::const_iterator
     998           0 :                      iPageIndex(maPageIndices.begin()),
     999           0 :                      iEnd(maPageIndices.end());
    1000           0 :                  iPageIndex!=iEnd && aPageObjIter!=aHandoutPageObjects.end();
    1001             :                  ++iPageIndex)
    1002             :             {
    1003             :                 // Check if the page still exists.
    1004           0 :                 if (*iPageIndex >= rDocument.GetSdPageCount(PK_STANDARD))
    1005           0 :                     continue;
    1006             : 
    1007           0 :                 SdrPageObj* pPageObj = (*aPageObjIter++);
    1008           0 :                 pPageObj->SetReferencedPage(rDocument.GetSdPage(*iPageIndex, PK_STANDARD));
    1009             :             }
    1010             : 
    1011             :             // if there are more page objects than pages left, set the rest to invisible
    1012           0 :             int nHangoverCount = 0;
    1013           0 :             while (aPageObjIter != aHandoutPageObjects.end())
    1014             :             {
    1015           0 :                 (*aPageObjIter++)->SetReferencedPage(0L);
    1016           0 :                 nHangoverCount++;
    1017             :             }
    1018             : 
    1019             :             // Hide outlines for objects that have pages attached.
    1020           0 :             if (nHangoverCount > 0)
    1021             :             {
    1022           0 :                 int nSkip = aHandoutPageObjects.size() - nHangoverCount;
    1023           0 :                 aShapeIter.Reset();
    1024           0 :                 while (aShapeIter.IsMore())
    1025             :                 {
    1026           0 :                     SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
    1027           0 :                     if (pPathObj)
    1028             :                     {
    1029           0 :                         if (nSkip > 0)
    1030           0 :                             --nSkip;
    1031             :                         else
    1032           0 :                             pPathObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
    1033             :                     }
    1034             :                 }
    1035             :             }
    1036             : 
    1037           0 :             if( xHandoutPage.is() ) try
    1038             :             {
    1039           0 :                 xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(mnHandoutPageIndex) ) );
    1040             :             }
    1041           0 :             catch( Exception& )
    1042             :             {
    1043             :             }
    1044           0 :             rViewShell.SetPrintedHandoutPageNum( mnHandoutPageIndex + 1 );
    1045             : 
    1046           0 :             MapMode aMap (rPrinter.GetMapMode());
    1047           0 :             rPrinter.SetMapMode(maMap);
    1048             : 
    1049             :             PrintPage(
    1050             :                 rPrinter,
    1051             :                 rPrintView,
    1052             :                 rHandoutPage,
    1053             :                 pView,
    1054             :                 false,
    1055             :                 rVisibleLayers,
    1056           0 :                 rPrintableLayers);
    1057             :             PrintMessage(
    1058             :                 rPrinter,
    1059             :                 msPageString,
    1060           0 :                 maPageStringOffset);
    1061             : 
    1062           0 :             if( xHandoutPage.is() ) try
    1063             :             {
    1064           0 :                 xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(0) ) );
    1065             :             }
    1066           0 :             catch( Exception& )
    1067             :             {
    1068             :             }
    1069           0 :             rViewShell.SetPrintedHandoutPageNum(1);
    1070             : 
    1071             :             // Restore outlines.
    1072           0 :             if (nHangoverCount > 0)
    1073             :             {
    1074           0 :                 aShapeIter.Reset();
    1075           0 :                 while (aShapeIter.IsMore())
    1076             :                 {
    1077           0 :                     SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
    1078           0 :                     if (pPathObj != NULL)
    1079           0 :                         pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
    1080             :                 }
    1081           0 :             }
    1082             : 
    1083             :        }
    1084             : 
    1085             :     private:
    1086             :         const sal_uInt16 mnHandoutPageIndex;
    1087             :         const ::std::vector<sal_uInt16> maPageIndices;
    1088             :     };
    1089             : 
    1090             : 
    1091             : 
    1092             : 
    1093             :     /** The outline information (title, subtitle, outline objects) of the
    1094             :         document.  There is no fixed mapping of slides to printer pages.
    1095             :     */
    1096             :     class OutlinerPrinterPage : public PrinterPage
    1097             :     {
    1098             :     public:
    1099           0 :         OutlinerPrinterPage (
    1100             :             OutlinerParaObject* pParaObject,
    1101             :             const MapMode& rMapMode,
    1102             :             const OUString& rsPageString,
    1103             :             const Point& rPageStringOffset,
    1104             :             const sal_uLong nDrawMode,
    1105             :             const Orientation eOrientation,
    1106             :             const sal_uInt16 nPaperTray)
    1107             :             : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
    1108             :                 rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
    1109           0 :               mpParaObject(pParaObject)
    1110             :         {
    1111           0 :         }
    1112             : 
    1113           0 :         virtual ~OutlinerPrinterPage()
    1114           0 :         {
    1115           0 :             mpParaObject.reset();
    1116           0 :         }
    1117             : 
    1118           0 :         virtual void Print (
    1119             :             Printer& rPrinter,
    1120             :             SdDrawDocument& rDocument,
    1121             :             ViewShell& rViewShell,
    1122             :             View* pView,
    1123             :             DrawView& rPrintView,
    1124             :             const SetOfByte& rVisibleLayers,
    1125             :             const SetOfByte& rPrintableLayers) const SAL_OVERRIDE
    1126             :         {
    1127             :             (void)rViewShell;
    1128             :             (void)pView;
    1129             :             (void)rPrintView;
    1130             :             (void)rVisibleLayers;
    1131             :             (void)rPrintableLayers;
    1132             : 
    1133             :             // Set up the printer.
    1134           0 :             rPrinter.SetMapMode(maMap);
    1135             : 
    1136             :             // Get and set up the outliner.
    1137           0 :             const Rectangle aOutRect (rPrinter.GetPageOffset(), rPrinter.GetOutputSize());
    1138           0 :             Outliner* pOutliner = rDocument.GetInternalOutliner();
    1139           0 :             const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
    1140           0 :             const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
    1141           0 :             const Size aSavedPaperSize (pOutliner->GetPaperSize());
    1142             : 
    1143           0 :             pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
    1144           0 :             pOutliner->SetPaperSize(aOutRect.GetSize());
    1145           0 :             pOutliner->SetUpdateMode(true);
    1146           0 :             pOutliner->Clear();
    1147           0 :             pOutliner->SetText(*mpParaObject);
    1148             : 
    1149           0 :             pOutliner->Draw(&rPrinter, aOutRect);
    1150             : 
    1151             :             PrintMessage(
    1152             :                 rPrinter,
    1153             :                 msPageString,
    1154           0 :                 maPageStringOffset);
    1155             : 
    1156             :             // Restore outliner and printer.
    1157           0 :             pOutliner->Clear();
    1158           0 :             pOutliner->SetUpdateMode(bSavedUpdateMode);
    1159           0 :             pOutliner->SetPaperSize(aSavedPaperSize);
    1160           0 :             pOutliner->Init(nSavedOutlMode);
    1161           0 :         }
    1162             : 
    1163             :     private:
    1164             :         ::boost::scoped_ptr<OutlinerParaObject> mpParaObject;
    1165             :     };
    1166             : }
    1167             : 
    1168             : 
    1169             : //===== DocumentRenderer::Implementation ======================================
    1170             : 
    1171             : class DocumentRenderer::Implementation
    1172             :     : public SfxListener,
    1173             :       public vcl::PrinterOptionsHelper
    1174             : {
    1175             : public:
    1176           0 :     Implementation (ViewShellBase& rBase)
    1177           0 :         : mxObjectShell(rBase.GetDocShell())
    1178             :         , mrBase(rBase)
    1179             :         , mbIsDisposed(false)
    1180             :         , mpPrinter(NULL)
    1181             :         , mpOptions()
    1182             :         , maPrinterPages()
    1183             :         , mpPrintView()
    1184           0 :         , mbHasOrientationWarningBeenShown(false)
    1185             :     {
    1186           0 :         DialogCreator aCreator( mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() );
    1187           0 :         m_aUIProperties = aCreator.GetDialogControls();
    1188           0 :         maSlidesPerPage = aCreator.GetSlidesPerPage();
    1189             : 
    1190           0 :         StartListening(mrBase);
    1191           0 :     }
    1192             : 
    1193             : 
    1194             : 
    1195             : 
    1196           0 :     virtual ~Implementation()
    1197           0 :     {
    1198           0 :         EndListening(mrBase);
    1199           0 :     }
    1200             : 
    1201             : 
    1202             : 
    1203             : 
    1204           0 :     virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint) SAL_OVERRIDE
    1205             :     {
    1206           0 :         const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
    1207           0 :         if (pSimpleHint != NULL
    1208           0 :             && pSimpleHint->GetId() == SFX_HINT_DYING
    1209           0 :             && &rBroadcaster == &static_cast<SfxBroadcaster&>(mrBase))
    1210             :         {
    1211           0 :             Dispose();
    1212             :         }
    1213           0 :     }
    1214             : 
    1215             : 
    1216             : 
    1217             :     /** Process the sequence of properties given to one of the XRenderable
    1218             :         methods.
    1219             :     */
    1220           0 :     void ProcessProperties (const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
    1221             :     {
    1222             :         OSL_ASSERT(!mbIsDisposed);
    1223           0 :         if (mbIsDisposed)
    1224           0 :             return;
    1225             : 
    1226           0 :         bool bIsValueChanged = processProperties( rOptions );
    1227           0 :         bool bIsPaperChanged = false;
    1228             : 
    1229             :         // The RenderDevice property is handled specially: its value is
    1230             :         // stored in mpPrinter instead of being retrieved on demand.
    1231           0 :         Any aDev( getValue( "RenderDevice" ) );
    1232           0 :         Reference<awt::XDevice> xRenderDevice;
    1233             : 
    1234           0 :         if (aDev >>= xRenderDevice)
    1235             :         {
    1236           0 :             VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
    1237           0 :             OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
    1238           0 :             mpPrinter = dynamic_cast<Printer*>(pOut);
    1239           0 :             Size aPageSizePixel = mpPrinter ? mpPrinter->GetPaperSizePixel() : Size();
    1240           0 :             if( aPageSizePixel != maPrinterPageSizePixel )
    1241             :             {
    1242           0 :                 bIsPaperChanged = true;
    1243           0 :                 maPrinterPageSizePixel = aPageSizePixel;
    1244             :             }
    1245             :         }
    1246             : 
    1247           0 :         if (bIsValueChanged)
    1248             :         {
    1249           0 :             if ( ! mpOptions )
    1250           0 :                 mpOptions.reset(new PrintOptions(*this, maSlidesPerPage));
    1251             :         }
    1252           0 :         if( bIsValueChanged || bIsPaperChanged )
    1253           0 :             PreparePages();
    1254             :     }
    1255             : 
    1256             : 
    1257             : 
    1258             :     /** Return the number of pages that are to be printed.
    1259             :     */
    1260           0 :     sal_Int32 GetPrintPageCount()
    1261             :     {
    1262             :         OSL_ASSERT(!mbIsDisposed);
    1263           0 :         if (mbIsDisposed)
    1264           0 :             return 0;
    1265             :         else
    1266           0 :             return maPrinterPages.size();
    1267             :     }
    1268             : 
    1269             : 
    1270             : 
    1271             :     /** Return a sequence of properties that can be returned by the
    1272             :         XRenderable::getRenderer() method.
    1273             :     */
    1274           0 :     css::uno::Sequence<css::beans::PropertyValue> GetProperties (
    1275             :         const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
    1276             :     {
    1277             :         (void)rOptions;
    1278             : 
    1279           0 :         css::uno::Sequence<css::beans::PropertyValue> aProperties (3);
    1280             : 
    1281           0 :         aProperties[0].Name = "ExtraPrintUIOptions";
    1282           0 :         aProperties[0].Value <<= m_aUIProperties;
    1283             : 
    1284           0 :         aProperties[1].Name = "PageSize";
    1285           0 :         aProperties[1].Value <<= maPrintSize;
    1286             : 
    1287             :         // FIXME: is this always true ?
    1288           0 :         aProperties[2].Name = "PageIncludesNonprintableArea";
    1289           0 :         aProperties[2].Value = makeAny( sal_True );
    1290             : 
    1291           0 :         return aProperties;
    1292             :     }
    1293             : 
    1294             : 
    1295             : 
    1296             : 
    1297             :     /** Print one of the prepared pages.
    1298             :     */
    1299           0 :     void PrintPage (const sal_Int32 nIndex)
    1300             :     {
    1301             :         OSL_ASSERT(!mbIsDisposed);
    1302           0 :         if (mbIsDisposed)
    1303           0 :             return;
    1304             : 
    1305           0 :         Printer& rPrinter (*mpPrinter);
    1306             : 
    1307           0 :         ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
    1308           0 :         if ( ! pViewShell)
    1309           0 :             return;
    1310             : 
    1311           0 :         SdDrawDocument* pDocument = pViewShell->GetDoc();
    1312             :         OSL_ASSERT(pDocument!=NULL);
    1313             : 
    1314             :         ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
    1315           0 :             ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
    1316             : 
    1317           0 :         if ( ! mpPrintView)
    1318           0 :             mpPrintView.reset(new DrawView(mrBase.GetDocShell(), &rPrinter, NULL));
    1319             : 
    1320           0 :         if (nIndex<0 || sal::static_int_cast<sal_uInt32>(nIndex)>=maPrinterPages.size())
    1321           0 :             return;
    1322             : 
    1323           0 :         const ::boost::shared_ptr<PrinterPage> pPage (maPrinterPages[nIndex]);
    1324             :         OSL_ASSERT(pPage);
    1325           0 :         if ( ! pPage)
    1326           0 :             return;
    1327             : 
    1328           0 :         const Orientation eSavedOrientation (rPrinter.GetOrientation());
    1329           0 :         const sal_uLong nSavedDrawMode (rPrinter.GetDrawMode());
    1330           0 :         const MapMode aSavedMapMode (rPrinter.GetMapMode());
    1331           0 :         const sal_uInt16 nSavedPaperBin (rPrinter.GetPaperBin());
    1332             : 
    1333             : 
    1334             :         // Set page orientation.
    1335           0 :         if ( ! rPrinter.SetOrientation(pPage->GetOrientation()))
    1336             :         {
    1337           0 :             if ( ! mbHasOrientationWarningBeenShown
    1338           0 :                 && mpOptions->IsWarningOrientation())
    1339             :             {
    1340           0 :                 mbHasOrientationWarningBeenShown = true;
    1341             :                 // Show warning that the orientation could not be set.
    1342           0 :                 if (pViewShell)
    1343             :                 {
    1344             :                     WarningBox aWarnBox(
    1345           0 :                         pViewShell->GetActiveWindow(),
    1346             :                         (WinBits)(WB_OK_CANCEL | WB_DEF_CANCEL),
    1347           0 :                         SD_RESSTR(STR_WARN_PRINTFORMAT_FAILURE));
    1348           0 :                     if (aWarnBox.Execute() != RET_OK)
    1349           0 :                         return;
    1350             :                 }
    1351             :             }
    1352             :         }
    1353             : 
    1354             :         // Set the draw mode.
    1355           0 :         rPrinter.SetDrawMode(pPage->GetDrawMode());
    1356             : 
    1357             :         // Set paper tray.
    1358           0 :         rPrinter.SetPaperBin(pPage->GetPaperTray());
    1359             : 
    1360             :         // Print the actual page.
    1361           0 :         pPage->Print(
    1362             :             rPrinter,
    1363             :             *pDocument,
    1364           0 :             *pViewShell,
    1365           0 :             pDrawViewShell ? pDrawViewShell->GetView() : NULL,
    1366           0 :             *mpPrintView,
    1367           0 :             pViewShell->GetFrameView()->GetVisibleLayers(),
    1368           0 :             pViewShell->GetFrameView()->GetPrintableLayers());
    1369             : 
    1370           0 :         rPrinter.SetOrientation(eSavedOrientation);
    1371           0 :         rPrinter.SetDrawMode(nSavedDrawMode);
    1372           0 :         rPrinter.SetMapMode(aSavedMapMode);
    1373           0 :         rPrinter.SetPaperBin(nSavedPaperBin);
    1374             :     }
    1375             : 
    1376             : 
    1377             : 
    1378             : 
    1379             : private:
    1380             :     // rhbz#657394: keep the document alive: prevents crash when
    1381             :     SfxObjectShellRef mxObjectShell; // destroying mpPrintView
    1382             :     ViewShellBase& mrBase;
    1383             :     bool mbIsDisposed;
    1384             :     Printer* mpPrinter;
    1385             :     Size maPrinterPageSizePixel;
    1386             :     ::boost::scoped_ptr<PrintOptions> mpOptions;
    1387             :     ::std::vector< ::boost::shared_ptr< ::sd::PrinterPage> > maPrinterPages;
    1388             :     ::boost::scoped_ptr<DrawView> mpPrintView;
    1389             :     bool mbHasOrientationWarningBeenShown;
    1390             :     ::std::vector<sal_Int32> maSlidesPerPage;
    1391             :     awt::Size maPrintSize;
    1392             : 
    1393           0 :     void Dispose()
    1394             :     {
    1395           0 :         mbIsDisposed = true;
    1396           0 :     }
    1397             : 
    1398           0 :     sal_Int32 GetCurrentPageIndex() const
    1399             :     {
    1400           0 :         const ViewShell *pShell = mrBase.GetMainViewShell().get();
    1401           0 :         const SdPage *pCurrentPage = pShell ? pShell->getCurrentPage() : NULL;
    1402           0 :         return pCurrentPage ? (pCurrentPage->GetPageNum()-1)/2 : -1;
    1403             :     }
    1404             : 
    1405             :     /** Determine and set the paper orientation.
    1406             :     */
    1407           0 :     bool SetupPaperOrientation (
    1408             :         const PageKind ePageKind,
    1409             :         PrintInfo& rInfo)
    1410             :     {
    1411           0 :         SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
    1412           0 :         rInfo.meOrientation = ORIENTATION_PORTRAIT;
    1413             : 
    1414           0 :         if( ! mpOptions->IsBooklet())
    1415             :         {
    1416           0 :             rInfo.meOrientation = pDocument->GetSdPage(0, ePageKind)->GetOrientation();
    1417             :         }
    1418           0 :         else if (rInfo.maPageSize.Width() < rInfo.maPageSize.Height())
    1419           0 :             rInfo.meOrientation = ORIENTATION_LANDSCAPE;
    1420             : 
    1421           0 :         const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
    1422           0 :         if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
    1423           0 :               (aPaperSize.Width() < aPaperSize.Height()))
    1424           0 :            ||
    1425           0 :             (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
    1426           0 :               (aPaperSize.Width() > aPaperSize.Height()))
    1427             :           )
    1428             :         {
    1429           0 :             maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
    1430             :         }
    1431             :         else
    1432             :         {
    1433           0 :             maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
    1434             :         }
    1435             : 
    1436           0 :         return true;
    1437             :     }
    1438             : 
    1439             : 
    1440             : 
    1441             :     /** Top most method for preparing printer pages.  In this and the other
    1442             :         Prepare... methods the various special cases are detected and
    1443             :         handled.
    1444             :         For every page that is to be printed (that may contain several
    1445             :         slides) one PrinterPage object is created and inserted into
    1446             :         maPrinterPages.
    1447             :     */
    1448           0 :     void PreparePages()
    1449             :     {
    1450           0 :         mpPrintView.reset();
    1451           0 :         maPrinterPages.clear();
    1452           0 :         mbHasOrientationWarningBeenShown = false;
    1453             : 
    1454           0 :         ViewShell* pShell = mrBase.GetMainViewShell().get();
    1455             : 
    1456           0 :         PrintInfo aInfo (mpPrinter, mpOptions->IsPrintMarkedOnly());
    1457             : 
    1458           0 :         if (aInfo.mpPrinter!=NULL && pShell!=NULL)
    1459             :         {
    1460             : 
    1461           0 :             MapMode aMap (aInfo.mpPrinter->GetMapMode());
    1462           0 :             aMap.SetMapUnit(MAP_100TH_MM);
    1463           0 :             aInfo.maMap = aMap;
    1464           0 :             mpPrinter->SetMapMode(aMap);
    1465             : 
    1466           0 :             ::Outliner& rOutliner = mrBase.GetDocument()->GetDrawOutliner();
    1467           0 :             const sal_uLong nSavedControlWord (rOutliner.GetControlWord());
    1468           0 :             sal_uLong nCntrl = nSavedControlWord;
    1469           0 :             nCntrl &= ~EE_CNTRL_MARKFIELDS;
    1470           0 :             nCntrl &= ~EE_CNTRL_ONLINESPELLING;
    1471           0 :             rOutliner.SetControlWord( nCntrl );
    1472             : 
    1473             :             // When in outline view then apply all pending changes to the model.
    1474           0 :             if (pShell->ISA(OutlineViewShell))
    1475           0 :                 static_cast<OutlineViewShell*>(pShell)->PrepareClose (sal_False);
    1476             : 
    1477             :             // Collect some frequently used data.
    1478           0 :             if (mpOptions->IsDate())
    1479             :             {
    1480           0 :                 aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getDate( Date( Date::SYSTEM ) );
    1481           0 :                 aInfo.msTimeDate += " ";
    1482             :             }
    1483             : 
    1484           0 :             if (mpOptions->IsTime())
    1485           0 :                 aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getTime( Time( Time::SYSTEM ), false, false );
    1486           0 :             aInfo.maPrintSize = aInfo.mpPrinter->GetOutputSize();
    1487             :             maPrintSize = awt::Size(
    1488           0 :                 aInfo.mpPrinter->GetPaperSize().Width(),
    1489           0 :                 aInfo.mpPrinter->GetPaperSize().Height());
    1490             : 
    1491           0 :             switch (mpOptions->GetOutputQuality())
    1492             :             {
    1493             :                 case 1: // Grayscale
    1494             :                     aInfo.mnDrawMode = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL
    1495             :                         | DRAWMODE_GRAYTEXT | DRAWMODE_GRAYBITMAP
    1496           0 :                         | DRAWMODE_GRAYGRADIENT;
    1497           0 :                     break;
    1498             : 
    1499             :                 case 2: // Black & White
    1500             :                     aInfo.mnDrawMode = DRAWMODE_BLACKLINE | DRAWMODE_WHITEFILL
    1501             :                         | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP
    1502           0 :                         | DRAWMODE_WHITEGRADIENT;
    1503           0 :                     break;
    1504             : 
    1505             :                 default:
    1506           0 :                     aInfo.mnDrawMode = DRAWMODE_DEFAULT;
    1507             :             }
    1508             : 
    1509           0 :             if (mpOptions->IsDraw())
    1510           0 :                 PrepareStdOrNotes(PK_STANDARD, aInfo);
    1511           0 :             if (mpOptions->IsNotes())
    1512           0 :                 PrepareStdOrNotes(PK_NOTES, aInfo);
    1513           0 :             if (mpOptions->IsHandout())
    1514             :             {
    1515           0 :                 InitHandoutTemplate();
    1516           0 :                 PrepareHandout(aInfo);
    1517             :             }
    1518           0 :             if (mpOptions->IsOutline())
    1519           0 :                 PrepareOutline(aInfo);
    1520             : 
    1521           0 :             rOutliner.SetControlWord(nSavedControlWord);
    1522           0 :         }
    1523           0 :     }
    1524             : 
    1525             : 
    1526             : 
    1527             : 
    1528             :     /** Create the page objects of the handout template.  When the actual
    1529             :         printing takes place then the page objects are assigned different
    1530             :         sets of slides for each printed page (see HandoutPrinterPage::Print).
    1531             :     */
    1532           0 :     void InitHandoutTemplate()
    1533             :     {
    1534           0 :         const sal_Int32 nSlidesPerHandout (mpOptions->GetHandoutPageCount());
    1535           0 :         const bool bHandoutHorizontal (mpOptions->IsHandoutHorizontal());
    1536             : 
    1537           0 :         AutoLayout eLayout = AUTOLAYOUT_HANDOUT6;
    1538           0 :         switch (nSlidesPerHandout)
    1539             :         {
    1540           0 :             case 1: eLayout = AUTOLAYOUT_HANDOUT1; break;
    1541           0 :             case 2: eLayout = AUTOLAYOUT_HANDOUT2; break;
    1542           0 :             case 3: eLayout = AUTOLAYOUT_HANDOUT3; break;
    1543           0 :             case 4: eLayout = AUTOLAYOUT_HANDOUT4; break;
    1544           0 :             case 9: eLayout = AUTOLAYOUT_HANDOUT9; break;
    1545             :             default:
    1546             :             case 0:
    1547           0 :             case 6: break; // use the default
    1548             :         }
    1549             : 
    1550           0 :         if( !mrBase.GetDocument() )
    1551           0 :             return;
    1552             : 
    1553           0 :         SdDrawDocument& rModel = *mrBase.GetDocument();
    1554             : 
    1555             :         // first, prepare handout page (not handout master)
    1556             : 
    1557           0 :         SdPage* pHandout = rModel.GetSdPage(0, PK_HANDOUT);
    1558           0 :         if( !pHandout )
    1559           0 :             return;
    1560             : 
    1561             :         // delete all previous shapes from handout page
    1562           0 :         while( pHandout->GetObjCount() )
    1563             :         {
    1564           0 :             SdrObject* pObj = pHandout->NbcRemoveObject(0);
    1565           0 :             if( pObj )
    1566           0 :                 SdrObject::Free( pObj  );
    1567             :         }
    1568             : 
    1569           0 :         const bool bDrawLines (eLayout == AUTOLAYOUT_HANDOUT3);
    1570             : 
    1571           0 :         std::vector< Rectangle > aAreas;
    1572           0 :         SdPage::CalculateHandoutAreas( rModel, eLayout, bHandoutHorizontal, aAreas );
    1573             : 
    1574           0 :         std::vector< Rectangle >::iterator iter( aAreas.begin() );
    1575           0 :         while( iter != aAreas.end() )
    1576             :         {
    1577           0 :             pHandout->NbcInsertObject( new SdrPageObj((*iter++)) );
    1578             : 
    1579           0 :             if( bDrawLines && (iter != aAreas.end())  )
    1580             :             {
    1581           0 :                 Rectangle aRect( (*iter++) );
    1582             : 
    1583           0 :                 basegfx::B2DPolygon aPoly;
    1584           0 :                 aPoly.insert(0, basegfx::B2DPoint( aRect.Left(), aRect.Top() ) );
    1585           0 :                 aPoly.insert(1, basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
    1586             : 
    1587           0 :                 basegfx::B2DHomMatrix aMatrix;
    1588           0 :                 aMatrix.translate( 0.0, static_cast< double >( aRect.GetHeight() / 7 ) );
    1589             : 
    1590           0 :                 basegfx::B2DPolyPolygon aPathPoly;
    1591           0 :                 for( sal_uInt16 nLine = 0; nLine < 7; nLine++ )
    1592             :                 {
    1593           0 :                     aPoly.transform( aMatrix );
    1594           0 :                     aPathPoly.append( aPoly );
    1595             :                 }
    1596             : 
    1597           0 :                 SdrPathObj* pPathObj = new SdrPathObj(OBJ_PATHLINE, aPathPoly );
    1598           0 :                 pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
    1599           0 :                 pPathObj->SetMergedItem(XLineColorItem(OUString(), Color(COL_BLACK)));
    1600             : 
    1601           0 :                 pHandout->NbcInsertObject( pPathObj );
    1602             :             }
    1603           0 :         }
    1604             :     }
    1605             : 
    1606             : 
    1607             : 
    1608             : 
    1609             :     /** Detect whether the specified slide is to be printed.
    1610             :         @return
    1611             :             When the slide is not to be printed then <NULL/> is returned.
    1612             :             Otherwise a pointer to the slide is returned.
    1613             :     */
    1614           0 :     SdPage* GetFilteredPage (
    1615             :         const sal_Int32 nPageIndex,
    1616             :         const PageKind ePageKind) const
    1617             :     {
    1618             :         OSL_ASSERT(mrBase.GetDocument() != NULL);
    1619             :         OSL_ASSERT(nPageIndex>=0);
    1620             :         SdPage* pPage = mrBase.GetDocument()->GetSdPage(
    1621           0 :             sal::static_int_cast<sal_uInt16>(nPageIndex),
    1622           0 :             ePageKind);
    1623           0 :         if (pPage == NULL)
    1624           0 :             return NULL;
    1625           0 :         if ( ! pPage->IsExcluded() || mpOptions->IsPrintExcluded())
    1626           0 :             return pPage;
    1627             :         else
    1628           0 :             return NULL;
    1629             :     }
    1630             : 
    1631             : 
    1632             : 
    1633             : 
    1634             :     /** Prepare the outline of the document for printing.  There is no fixed
    1635             :         number of slides whose outline data is put onto one printer page.
    1636             :         If the current printer page has enough room for the outline of the
    1637             :         current slide then that is added.  Otherwise a new printer page is
    1638             :         started.
    1639             :     */
    1640           0 :     void PrepareOutline (PrintInfo& rInfo)
    1641             :     {
    1642           0 :         MapMode aMap (rInfo.maMap);
    1643           0 :         Point aPageOfs (rInfo.mpPrinter->GetPageOffset() );
    1644           0 :         aMap.SetScaleX(Fraction(1,2));
    1645           0 :         aMap.SetScaleY(Fraction(1,2));
    1646           0 :         mpPrinter->SetMapMode(aMap);
    1647             : 
    1648           0 :         Rectangle aOutRect(aPageOfs, rInfo.mpPrinter->GetOutputSize());
    1649           0 :         if( aOutRect.GetWidth() > aOutRect.GetHeight() )
    1650             :         {
    1651           0 :             Size aPaperSize( rInfo.mpPrinter->PixelToLogic( rInfo.mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
    1652           0 :             maPrintSize.Width  = aPaperSize.Height();
    1653           0 :             maPrintSize.Height = aPaperSize.Width();
    1654           0 :             aOutRect = Rectangle( Point( aPageOfs.Y(), aPageOfs.X() ),
    1655           0 :                                   Size( aOutRect.GetHeight(), aOutRect.GetWidth() ) );
    1656             :         }
    1657             : 
    1658           0 :         Link aOldLink;
    1659           0 :         Outliner* pOutliner = mrBase.GetDocument()->GetInternalOutliner();
    1660           0 :         pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
    1661           0 :         const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
    1662           0 :         const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
    1663           0 :         const Size aSavedPaperSize (pOutliner->GetPaperSize());
    1664           0 :         const MapMode aSavedMapMode (pOutliner->GetRefMapMode());
    1665           0 :         pOutliner->SetPaperSize(aOutRect.GetSize());
    1666           0 :         pOutliner->SetUpdateMode(true);
    1667             : 
    1668           0 :         long nPageH = aOutRect.GetHeight();
    1669             : 
    1670           0 :         ::std::vector< sal_Int32 > aPages;
    1671           0 :         sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
    1672             :         StringRangeEnumerator::getRangesFromString(
    1673             :             mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
    1674           0 :             aPages, 0, nPageCount-1);
    1675             : 
    1676           0 :         for (size_t nIndex = 0, nCount = aPages.size(); nIndex < nCount;)
    1677             :         {
    1678           0 :             pOutliner->Clear();
    1679           0 :             pOutliner->SetFirstPageNumber(aPages[nIndex]+1);
    1680             : 
    1681           0 :             Paragraph* pPara = NULL;
    1682           0 :             sal_Int32 nH (0);
    1683           0 :             while (nH < nPageH && nIndex<nCount)
    1684             :             {
    1685           0 :                 SdPage* pPage = GetFilteredPage(aPages[nIndex], PK_STANDARD);
    1686           0 :                 ++nIndex;
    1687           0 :                 if (pPage == NULL)
    1688           0 :                     continue;
    1689             : 
    1690           0 :                 SdrTextObj* pTextObj = NULL;
    1691           0 :                 sal_uInt32 nObj (0);
    1692             : 
    1693           0 :                 while (pTextObj==NULL && nObj < pPage->GetObjCount())
    1694             :                 {
    1695           0 :                     SdrObject* pObj = pPage->GetObj(nObj++);
    1696           0 :                     if (pObj->GetObjInventor() == SdrInventor
    1697           0 :                         && pObj->GetObjIdentifier() == OBJ_TITLETEXT)
    1698             :                     {
    1699           0 :                         pTextObj = dynamic_cast<SdrTextObj*>(pObj);
    1700             :                     }
    1701             :                 }
    1702             : 
    1703           0 :                 pPara = pOutliner->GetParagraph(pOutliner->GetParagraphCount() - 1);
    1704             : 
    1705           0 :                 if (pTextObj!=NULL
    1706           0 :                     && !pTextObj->IsEmptyPresObj()
    1707           0 :                     && pTextObj->GetOutlinerParaObject())
    1708             :                 {
    1709           0 :                     pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
    1710             :                 }
    1711             :                 else
    1712           0 :                     pOutliner->Insert(OUString());
    1713             : 
    1714           0 :                 pTextObj = NULL;
    1715           0 :                 nObj = 0;
    1716             : 
    1717           0 :                 while (pTextObj==NULL && nObj<pPage->GetObjCount())
    1718             :                 {
    1719           0 :                     SdrObject* pObj = pPage->GetObj(nObj++);
    1720           0 :                     if (pObj->GetObjInventor() == SdrInventor
    1721           0 :                         && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
    1722             :                     {
    1723           0 :                         pTextObj = dynamic_cast<SdrTextObj*>(pObj);
    1724             :                     }
    1725             :                 }
    1726             : 
    1727           0 :                 bool bSubTitle (false);
    1728           0 :                 if (!pTextObj)
    1729             :                 {
    1730           0 :                     bSubTitle = true;
    1731           0 :                     pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT));  // Untertitel vorhanden?
    1732             :                 }
    1733             : 
    1734           0 :                 sal_Int32 nParaCount1 = pOutliner->GetParagraphCount();
    1735             : 
    1736           0 :                 if (pTextObj!=NULL
    1737           0 :                     && !pTextObj->IsEmptyPresObj()
    1738           0 :                     && pTextObj->GetOutlinerParaObject())
    1739             :                 {
    1740           0 :                     pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
    1741             :                 }
    1742             : 
    1743           0 :                 if (bSubTitle )
    1744             :                 {
    1745           0 :                     const sal_Int32 nParaCount2 (pOutliner->GetParagraphCount());
    1746           0 :                     for (sal_Int32 nPara=nParaCount1; nPara<nParaCount2; ++nPara)
    1747             :                     {
    1748           0 :                         Paragraph* pP = pOutliner->GetParagraph(nPara);
    1749           0 :                         if (pP!=NULL && pOutliner->GetDepth(nPara) > 0)
    1750           0 :                             pOutliner->SetDepth(pP, 0);
    1751             :                     }
    1752             :                 }
    1753             : 
    1754           0 :                 nH = pOutliner->GetTextHeight();
    1755             :             }
    1756             : 
    1757             :             // Remove the last paragraph when that does not fit completely on
    1758             :             // the current page.
    1759           0 :             if (nH > nPageH && pPara!=NULL)
    1760             :             {
    1761             :                 sal_Int32 nCnt = pOutliner->GetAbsPos(
    1762           0 :                     pOutliner->GetParagraph( pOutliner->GetParagraphCount() - 1 ) );
    1763           0 :                 sal_Int32 nParaPos = pOutliner->GetAbsPos( pPara );
    1764           0 :                 nCnt -= nParaPos;
    1765           0 :                 pPara = pOutliner->GetParagraph( ++nParaPos );
    1766           0 :                 if ( nCnt && pPara )
    1767             :                 {
    1768           0 :                     pOutliner->Remove(pPara, nCnt);
    1769           0 :                     --nIndex;
    1770             :                 }
    1771             :             }
    1772             : 
    1773             :             maPrinterPages.push_back(
    1774             :                 ::boost::shared_ptr<PrinterPage>(
    1775             :                     new OutlinerPrinterPage(
    1776           0 :                         pOutliner->CreateParaObject(),
    1777             :                         aMap,
    1778             :                         rInfo.msTimeDate,
    1779             :                         aPageOfs,
    1780             :                         rInfo.mnDrawMode,
    1781             :                         rInfo.meOrientation,
    1782           0 :                         rInfo.mpPrinter->GetPaperBin())));
    1783             :         }
    1784             : 
    1785           0 :         pOutliner->SetRefMapMode(aSavedMapMode);
    1786           0 :         pOutliner->SetUpdateMode(bSavedUpdateMode);
    1787           0 :         pOutliner->SetPaperSize(aSavedPaperSize);
    1788           0 :         pOutliner->Init(nSavedOutlMode);
    1789           0 :     }
    1790             : 
    1791             : 
    1792             : 
    1793             : 
    1794             :     /** Prepare handout pages for slides that are to be printed.
    1795             :     */
    1796           0 :     void PrepareHandout (PrintInfo& rInfo)
    1797             :     {
    1798           0 :         SdDrawDocument* pDocument = mrBase.GetDocument();
    1799             :         OSL_ASSERT(pDocument != NULL);
    1800           0 :         SdPage& rHandoutPage (*pDocument->GetSdPage(0, PK_HANDOUT));
    1801             : 
    1802           0 :         const bool bScalePage (mpOptions->IsPageSize());
    1803             : 
    1804             :         sal_uInt16 nPaperBin;
    1805           0 :         if ( ! mpOptions->IsPaperBin())
    1806           0 :             nPaperBin = rHandoutPage.GetPaperBin();
    1807             :         else
    1808           0 :             nPaperBin = rInfo.mpPrinter->GetPaperBin();
    1809             : 
    1810             :         // Change orientation?
    1811           0 :         SdPage& rMaster (dynamic_cast<SdPage&>(rHandoutPage.TRG_GetMasterPage()));
    1812           0 :         rInfo.meOrientation = rMaster.GetOrientation();
    1813             : 
    1814           0 :         const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
    1815           0 :         if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
    1816           0 :               (aPaperSize.Width() < aPaperSize.Height()))
    1817           0 :            ||
    1818           0 :             (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
    1819           0 :               (aPaperSize.Width() > aPaperSize.Height()))
    1820             :           )
    1821             :         {
    1822           0 :             maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
    1823             :         }
    1824             :         else
    1825             :         {
    1826           0 :             maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
    1827             :         }
    1828             : 
    1829           0 :         MapMode aMap (rInfo.maMap);
    1830           0 :         const Point aPageOfs (rInfo.mpPrinter->GetPageOffset());
    1831             : 
    1832           0 :         if ( bScalePage )
    1833             :         {
    1834           0 :             const Size aPageSize (rHandoutPage.GetSize());
    1835           0 :             const Size aPrintSize (rInfo.mpPrinter->GetOutputSize());
    1836             : 
    1837           0 :             const double fHorz = (double) aPrintSize.Width()    / aPageSize.Width();
    1838           0 :             const double fVert = (double) aPrintSize.Height() / aPageSize.Height();
    1839             : 
    1840           0 :             Fraction    aFract;
    1841           0 :             if ( fHorz < fVert )
    1842           0 :                 aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
    1843             :             else
    1844           0 :                 aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
    1845             : 
    1846           0 :             aMap.SetScaleX(aFract);
    1847           0 :             aMap.SetScaleY(aFract);
    1848           0 :             aMap.SetOrigin(Point());
    1849             :         }
    1850             : 
    1851           0 :         ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
    1852           0 :         pViewShell->WriteFrameViewData();
    1853             : 
    1854             :         // Count page shapes.
    1855           0 :         sal_uInt32 nShapeCount (0);
    1856           0 :         SdrObjListIter aShapeIter (rHandoutPage);
    1857           0 :         while (aShapeIter.IsMore())
    1858             :         {
    1859           0 :             SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
    1860           0 :             if (pPageObj)
    1861           0 :                 ++nShapeCount;
    1862             :         }
    1863             : 
    1864           0 :         const sal_uInt16 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
    1865           0 :         const sal_uInt16 nHandoutPageCount = nShapeCount ? (nPageCount + nShapeCount - 1) / nShapeCount : 0;
    1866           0 :         pViewShell->SetPrintedHandoutPageCount( nHandoutPageCount );
    1867           0 :         mrBase.GetDocument()->setHandoutPageCount( nHandoutPageCount );
    1868             : 
    1869             :         // Distribute pages to handout pages.
    1870             :         StringRangeEnumerator aRangeEnum(
    1871             :             mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
    1872           0 :             0, nPageCount-1);
    1873           0 :         ::std::vector<sal_uInt16> aPageIndices;
    1874           0 :         sal_uInt16 nPrinterPageIndex = 0;
    1875           0 :         StringRangeEnumerator::Iterator it = aRangeEnum.begin(), itEnd = aRangeEnum.end();
    1876           0 :         bool bLastLoop = (it == itEnd);
    1877           0 :         while (!bLastLoop)
    1878             :         {
    1879           0 :             sal_Int32 nPageIndex = *it;
    1880           0 :             ++it;
    1881           0 :             bLastLoop = (it == itEnd);
    1882             : 
    1883           0 :             if (GetFilteredPage(nPageIndex, PK_STANDARD))
    1884           0 :                 aPageIndices.push_back(nPageIndex);
    1885           0 :             else if (!bLastLoop)
    1886           0 :                 continue;
    1887             : 
    1888             :             // Create a printer page when we have found one page for each
    1889             :             // placeholder or when this is the last (and special) loop.
    1890           0 :             if (!aPageIndices.empty() && (aPageIndices.size() == nShapeCount || bLastLoop))
    1891             :             {
    1892             :                 maPrinterPages.push_back(
    1893             :                     ::boost::shared_ptr<PrinterPage>(
    1894             :                         new HandoutPrinterPage(
    1895             :                             nPrinterPageIndex++,
    1896             :                             aPageIndices,
    1897             :                             aMap,
    1898             :                             rInfo.msTimeDate,
    1899             :                             aPageOfs,
    1900             :                             rInfo.mnDrawMode,
    1901             :                             rInfo.meOrientation,
    1902           0 :                             nPaperBin)));
    1903           0 :                 aPageIndices.clear();
    1904             :             }
    1905           0 :         }
    1906           0 :     }
    1907             : 
    1908             : 
    1909             : 
    1910             : 
    1911             :     /** Prepare the notes pages or regular slides.
    1912             :     */
    1913           0 :     void PrepareStdOrNotes (
    1914             :         const PageKind ePageKind,
    1915             :         PrintInfo& rInfo)
    1916             :     {
    1917             :         OSL_ASSERT(rInfo.mpPrinter != NULL);
    1918             : 
    1919             :         // Fill in page kind specific data.
    1920           0 :         SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
    1921           0 :         if (pDocument->GetSdPageCount(ePageKind) == 0)
    1922           0 :             return;
    1923           0 :         SdPage* pRefPage = pDocument->GetSdPage(0, ePageKind);
    1924           0 :         rInfo.maPageSize = pRefPage->GetSize();
    1925             : 
    1926           0 :         if ( ! SetupPaperOrientation(ePageKind, rInfo))
    1927           0 :             return;
    1928             : 
    1929           0 :         MapMode aMap (rInfo.maMap);
    1930           0 :         rInfo.maMap = aMap;
    1931             : 
    1932           0 :         if (mpOptions->IsBooklet())
    1933           0 :             PrepareBooklet(ePageKind, rInfo);
    1934             :         else
    1935           0 :             PrepareRegularPages(ePageKind, rInfo);
    1936             :     }
    1937             : 
    1938             : 
    1939             : 
    1940             : 
    1941             :     /** Prepare slides in a non-booklet way: one slide per one to many
    1942             :         printer pages.
    1943             :     */
    1944           0 :     void PrepareRegularPages (
    1945             :         const PageKind ePageKind,
    1946             :         PrintInfo& rInfo)
    1947             :     {
    1948           0 :         ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
    1949           0 :         pViewShell->WriteFrameViewData();
    1950             : 
    1951           0 :         sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
    1952             :         StringRangeEnumerator aRangeEnum(
    1953             :             mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
    1954           0 :             0, nPageCount-1);
    1955           0 :         for (StringRangeEnumerator::Iterator
    1956           0 :                  it = aRangeEnum.begin(),
    1957           0 :                  itEnd = aRangeEnum.end();
    1958             :              it != itEnd;
    1959             :              ++it)
    1960             :         {
    1961           0 :             SdPage* pPage = GetFilteredPage(*it, ePageKind);
    1962           0 :             if (pPage == NULL)
    1963           0 :                 continue;
    1964             : 
    1965           0 :             MapMode aMap (rInfo.maMap);
    1966             :             // is it possible that the page size changed?
    1967           0 :             const Size aPageSize = pPage->GetSize();
    1968             : 
    1969           0 :             if (mpOptions->IsPageSize())
    1970             :             {
    1971           0 :                 const double fHorz ((double) rInfo.maPrintSize.Width()  / aPageSize.Width());
    1972           0 :                 const double fVert ((double) rInfo.maPrintSize.Height() / aPageSize.Height());
    1973             : 
    1974           0 :                 Fraction aFract;
    1975           0 :                 if (fHorz < fVert)
    1976           0 :                     aFract = Fraction(rInfo.maPrintSize.Width(), aPageSize.Width());
    1977             :                 else
    1978           0 :                     aFract = Fraction(rInfo.maPrintSize.Height(), aPageSize.Height());
    1979             : 
    1980           0 :                 aMap.SetScaleX(aFract);
    1981           0 :                 aMap.SetScaleY(aFract);
    1982           0 :                 aMap.SetOrigin(Point());
    1983             :             }
    1984             : 
    1985           0 :             if (mpOptions->IsPrintPageName())
    1986             :             {
    1987           0 :                 rInfo.msPageString = pPage->GetName();
    1988           0 :                 rInfo.msPageString += " ";
    1989             :             }
    1990             :             else
    1991           0 :                 rInfo.msPageString = "";
    1992           0 :             rInfo.msPageString += rInfo.msTimeDate;
    1993             : 
    1994           0 :             long aPageWidth   = aPageSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder();
    1995           0 :             long aPageHeight  = aPageSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder();
    1996             :             // Bugfix for 44530:
    1997             :             // if it was implicitly changed (Landscape/Portrait),
    1998             :             // this is considered for tiling, respectively for the splitting up
    1999             :             // (Poster)
    2000           0 :             if( ( rInfo.maPrintSize.Width() > rInfo.maPrintSize.Height()
    2001           0 :                     && aPageWidth < aPageHeight )
    2002           0 :                 || ( rInfo.maPrintSize.Width() < rInfo.maPrintSize.Height()
    2003           0 :                     && aPageWidth > aPageHeight ) )
    2004             :             {
    2005           0 :                 const sal_Int32 nTmp (rInfo.maPrintSize.Width());
    2006           0 :                 rInfo.maPrintSize.Width() = rInfo.maPrintSize.Height();
    2007           0 :                 rInfo.maPrintSize.Height() = nTmp;
    2008             :             }
    2009             : 
    2010           0 :             if (mpOptions->IsTilePage()
    2011           0 :                 && aPageWidth < rInfo.maPrintSize.Width()
    2012           0 :                 && aPageHeight < rInfo.maPrintSize.Height())
    2013             :             {
    2014             :                 // Put multiple slides on one printer page.
    2015           0 :                 PrepareTiledPage(*it, *pPage, ePageKind, rInfo);
    2016             :             }
    2017             :             else
    2018             :             {
    2019           0 :                 rInfo.maMap = aMap;
    2020           0 :                 PrepareScaledPage(*it, *pPage, ePageKind, rInfo);
    2021             :             }
    2022           0 :         }
    2023           0 :     }
    2024             : 
    2025             : 
    2026             : 
    2027             : 
    2028             :     /** Put two slides on one printer page.
    2029             :     */
    2030           0 :     void PrepareBooklet (
    2031             :         const PageKind ePageKind,
    2032             :         const PrintInfo& rInfo)
    2033             :     {
    2034           0 :         MapMode aStdMap (rInfo.maMap);
    2035           0 :         Point aOffset;
    2036           0 :         Size aPrintSize_2 (rInfo.maPrintSize);
    2037           0 :         Size aPageSize_2 (rInfo.maPageSize);
    2038             : 
    2039           0 :         if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
    2040           0 :             aPrintSize_2.Width() >>= 1;
    2041             :         else
    2042           0 :             aPrintSize_2.Height() >>= 1;
    2043             : 
    2044           0 :         const double fPageWH = (double) aPageSize_2.Width() / aPageSize_2.Height();
    2045           0 :         const double fPrintWH = (double) aPrintSize_2.Width() / aPrintSize_2.Height();
    2046             : 
    2047           0 :         if( fPageWH < fPrintWH )
    2048             :         {
    2049           0 :             aPageSize_2.Width() = (long) ( aPrintSize_2.Height() * fPageWH );
    2050           0 :             aPageSize_2.Height()= aPrintSize_2.Height();
    2051             :         }
    2052             :         else
    2053             :         {
    2054           0 :             aPageSize_2.Width() = aPrintSize_2.Width();
    2055           0 :             aPageSize_2.Height() = (long) ( aPrintSize_2.Width() / fPageWH );
    2056             :         }
    2057             : 
    2058           0 :         MapMode aMap (rInfo.maMap);
    2059           0 :         aMap.SetScaleX( Fraction( aPageSize_2.Width(), rInfo.maPageSize.Width() ) );
    2060           0 :         aMap.SetScaleY( Fraction( aPageSize_2.Height(), rInfo.maPageSize.Height() ) );
    2061             : 
    2062             :         // calculate adjusted print size
    2063             :         const Size aAdjustedPrintSize (OutputDevice::LogicToLogic(
    2064             :             rInfo.maPrintSize,
    2065             :             aStdMap,
    2066           0 :             aMap));
    2067             : 
    2068           0 :         if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
    2069             :         {
    2070           0 :             aOffset.X() = ( ( aAdjustedPrintSize.Width() >> 1 ) - rInfo.maPageSize.Width() ) >> 1;
    2071           0 :             aOffset.Y() = ( aAdjustedPrintSize.Height() - rInfo.maPageSize.Height() ) >> 1;
    2072             :         }
    2073             :         else
    2074             :         {
    2075           0 :             aOffset.X() = ( aAdjustedPrintSize.Width() - rInfo.maPageSize.Width() ) >> 1;
    2076           0 :             aOffset.Y() = ( ( aAdjustedPrintSize.Height() >> 1 ) - rInfo.maPageSize.Height() ) >> 1;
    2077             :         }
    2078             : 
    2079             :         // create vector of pages to print
    2080           0 :         sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(ePageKind);
    2081             :         StringRangeEnumerator aRangeEnum(
    2082             :             mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
    2083           0 :             0, nPageCount-1);
    2084           0 :         ::std::vector< sal_uInt16 > aPageVector;
    2085           0 :         for (StringRangeEnumerator::Iterator
    2086           0 :                  it = aRangeEnum.begin(),
    2087           0 :                  itEnd = aRangeEnum.end();
    2088             :              it != itEnd;
    2089             :              ++it)
    2090             :         {
    2091           0 :             SdPage* pPage = GetFilteredPage(*it, ePageKind);
    2092           0 :             if (pPage != NULL)
    2093           0 :                 aPageVector.push_back(*it);
    2094             :         }
    2095             : 
    2096             :         // create pairs of pages to print on each page
    2097             :         typedef ::std::vector< ::std::pair< sal_uInt16, sal_uInt16 > > PairVector;
    2098           0 :         PairVector aPairVector;
    2099           0 :         if ( ! aPageVector.empty())
    2100             :         {
    2101           0 :             sal_uInt32 nFirstIndex = 0, nLastIndex = aPageVector.size() - 1;
    2102             : 
    2103           0 :             if( aPageVector.size() & 1 )
    2104           0 :                 aPairVector.push_back( ::std::make_pair( (sal_uInt16) 65535, aPageVector[ nFirstIndex++ ] ) );
    2105             :             else
    2106           0 :                 aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
    2107             : 
    2108           0 :             while( nFirstIndex < nLastIndex )
    2109             :             {
    2110           0 :                 if( nFirstIndex & 1 )
    2111           0 :                     aPairVector.push_back( ::std::make_pair( aPageVector[ nFirstIndex++ ], aPageVector[ nLastIndex-- ] ) );
    2112             :                 else
    2113           0 :                     aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
    2114             :             }
    2115             :         }
    2116             : 
    2117           0 :         for (sal_uInt32
    2118           0 :                  nIndex=0,
    2119           0 :                  nCount=aPairVector.size();
    2120             :              nIndex < nCount;
    2121             :              ++nIndex)
    2122             :         {
    2123           0 :             const bool bIsIndexOdd (nIndex & 1);
    2124           0 :             if ((!bIsIndexOdd && mpOptions->IsPrintFrontPage())
    2125           0 :                 || (bIsIndexOdd && mpOptions->IsPrintBackPage()))
    2126             :             {
    2127           0 :                 const ::std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]);
    2128           0 :                 Point aSecondOffset (aOffset);
    2129           0 :                 if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
    2130           0 :                     aSecondOffset.X() += aAdjustedPrintSize.Width() / 2;
    2131             :                 else
    2132           0 :                     aSecondOffset.Y() += aAdjustedPrintSize.Height() / 2;
    2133             :                 maPrinterPages.push_back(
    2134             :                     ::boost::shared_ptr<PrinterPage>(
    2135             :                         new BookletPrinterPage(
    2136             :                             aPair.first,
    2137             :                             aPair.second,
    2138             :                             aOffset,
    2139             :                             aSecondOffset,
    2140             :                             ePageKind,
    2141             :                             aMap,
    2142             :                             rInfo.mbPrintMarkedOnly,
    2143             :                             rInfo.mnDrawMode,
    2144             :                             rInfo.meOrientation,
    2145           0 :                             rInfo.mpPrinter->GetPaperBin())));
    2146             : 
    2147             :             }
    2148           0 :         }
    2149           0 :     }
    2150             : 
    2151             : 
    2152             : 
    2153             : 
    2154             :     /** Print one slide multiple times on one printer page so that the whole
    2155             :         printer page is covered.
    2156             :     */
    2157           0 :     void PrepareTiledPage (
    2158             :         const sal_Int32 nPageIndex,
    2159             :         const SdPage& rPage,
    2160             :         const PageKind ePageKind,
    2161             :         const PrintInfo& rInfo)
    2162             :     {
    2163             :         sal_uInt16 nPaperBin;
    2164           0 :         if ( ! mpOptions->IsPaperBin())
    2165           0 :             nPaperBin = rPage.GetPaperBin();
    2166             :         else
    2167           0 :             nPaperBin = rInfo.mpPrinter->GetPaperBin();
    2168             : 
    2169             :         maPrinterPages.push_back(
    2170             :             ::boost::shared_ptr<PrinterPage>(
    2171             :                 new TiledPrinterPage(
    2172           0 :                     sal::static_int_cast<sal_uInt16>(nPageIndex),
    2173             :                     ePageKind,
    2174             :                     500,
    2175             :                     rInfo.mbPrintMarkedOnly,
    2176             :                     rInfo.msPageString,
    2177           0 :                     rInfo.mpPrinter->GetPageOffset(),
    2178             :                     rInfo.mnDrawMode,
    2179             :                     rInfo.meOrientation,
    2180           0 :                     nPaperBin)));
    2181           0 :     }
    2182             : 
    2183             : 
    2184             : 
    2185             :     /** Print one standard slide or notes page on one to many printer
    2186             :         pages.  More than on printer page is used when the slide is larger
    2187             :         than the printable area.
    2188             :     */
    2189           0 :     void PrepareScaledPage (
    2190             :         const sal_Int32 nPageIndex,
    2191             :         const SdPage& rPage,
    2192             :         const PageKind ePageKind,
    2193             :         const PrintInfo& rInfo)
    2194             :     {
    2195           0 :         const Point aPageOffset (rInfo.mpPrinter->GetPageOffset());
    2196             : 
    2197             :         sal_uInt16 nPaperBin;
    2198           0 :         if ( ! mpOptions->IsPaperBin())
    2199           0 :             nPaperBin = rPage.GetPaperBin();
    2200             :         else
    2201           0 :             nPaperBin = rInfo.mpPrinter->GetPaperBin();
    2202             : 
    2203             :         // For pages larger then the printable area there
    2204             :         // are three options:
    2205             :         // 1. Scale down to the page to the printable area.
    2206             :         // 2. Print only the upper left part of the page
    2207             :         //    (without the unprintable borders).
    2208             :         // 3. Split the page into parts of the size of the
    2209             :         // printable area.
    2210           0 :         const bool bScalePage (mpOptions->IsPageSize());
    2211           0 :         const bool bCutPage (mpOptions->IsCutPage());
    2212           0 :         MapMode aMap (rInfo.maMap);
    2213           0 :         if (bScalePage || bCutPage)
    2214             :         {
    2215             :             // Handle 1 and 2.
    2216             : 
    2217             :             // if CutPage is set then do not move it, otherwise move the
    2218             :             // scaled page to printable area
    2219             :             maPrinterPages.push_back(
    2220             :                 ::boost::shared_ptr<PrinterPage>(
    2221             :                     new RegularPrinterPage(
    2222           0 :                         sal::static_int_cast<sal_uInt16>(nPageIndex),
    2223             :                         ePageKind,
    2224             :                         aMap,
    2225             :                         rInfo.mbPrintMarkedOnly,
    2226             :                         rInfo.msPageString,
    2227             :                         aPageOffset,
    2228             :                         rInfo.mnDrawMode,
    2229             :                         rInfo.meOrientation,
    2230           0 :                         nPaperBin)));
    2231             :         }
    2232             :         else
    2233             :         {
    2234             :             // Handle 3.  Print parts of the page in the size of the
    2235             :             // printable area until the whole page is covered.
    2236             : 
    2237             :             // keep the page content at its position if it fits, otherwise
    2238             :             // move it to the printable area
    2239             :             const long nPageWidth (
    2240           0 :                 rInfo.maPageSize.Width() - rPage.GetLftBorder() - rPage.GetRgtBorder());
    2241             :             const long nPageHeight (
    2242           0 :                 rInfo.maPageSize.Height() - rPage.GetUppBorder() - rPage.GetLwrBorder());
    2243             : 
    2244           0 :             Point aOrigin ( 0, 0 );
    2245             : 
    2246           0 :             for (Point aPageOrigin = aOrigin;
    2247           0 :                  -aPageOrigin.Y()<nPageHeight;
    2248           0 :                  aPageOrigin.Y() -= rInfo.maPrintSize.Height())
    2249             :             {
    2250           0 :                 for (aPageOrigin.X()=aOrigin.X();
    2251           0 :                      -aPageOrigin.X()<nPageWidth;
    2252           0 :                      aPageOrigin.X() -= rInfo.maPrintSize.Width())
    2253             :                 {
    2254           0 :                     aMap.SetOrigin(aPageOrigin);
    2255             :                     maPrinterPages.push_back(
    2256             :                         ::boost::shared_ptr<PrinterPage>(
    2257             :                             new RegularPrinterPage(
    2258           0 :                                 sal::static_int_cast<sal_uInt16>(nPageIndex),
    2259             :                                 ePageKind,
    2260             :                                 aMap,
    2261             :                                 rInfo.mbPrintMarkedOnly,
    2262             :                                 rInfo.msPageString,
    2263             :                                 aPageOffset,
    2264             :                                 rInfo.mnDrawMode,
    2265             :                                 rInfo.meOrientation,
    2266           0 :                                 nPaperBin)));
    2267             :                 }
    2268             :             }
    2269           0 :         }
    2270           0 :     }
    2271             : };
    2272             : 
    2273             : 
    2274             : 
    2275             : 
    2276             : //===== DocumentRenderer ======================================================
    2277             : 
    2278           0 : DocumentRenderer::DocumentRenderer (ViewShellBase& rBase)
    2279             :     : DocumentRendererInterfaceBase(m_aMutex),
    2280           0 :       mpImpl(new Implementation(rBase))
    2281             : {
    2282           0 : }
    2283             : 
    2284             : 
    2285             : 
    2286             : 
    2287           0 : DocumentRenderer::~DocumentRenderer()
    2288             : {
    2289           0 : }
    2290             : 
    2291             : 
    2292             : 
    2293             : 
    2294             : //----- XRenderable -----------------------------------------------------------
    2295             : 
    2296           0 : sal_Int32 SAL_CALL DocumentRenderer::getRendererCount (
    2297             :     const css::uno::Any& aSelection,
    2298             :     const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
    2299             :     throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
    2300             : {
    2301             :     (void)aSelection;
    2302           0 :     mpImpl->ProcessProperties(rOptions);
    2303           0 :     return mpImpl->GetPrintPageCount();
    2304             : }
    2305             : 
    2306             : 
    2307             : 
    2308             : 
    2309           0 : Sequence<beans::PropertyValue> SAL_CALL DocumentRenderer::getRenderer (
    2310             :     sal_Int32 nRenderer,
    2311             :     const css::uno::Any& rSelection,
    2312             :     const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
    2313             :     throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
    2314             : {
    2315             :     (void)nRenderer;
    2316             :     (void)rSelection;
    2317           0 :     mpImpl->ProcessProperties(rOptions);
    2318           0 :     return mpImpl->GetProperties(rOptions);
    2319             : }
    2320             : 
    2321             : 
    2322             : 
    2323             : 
    2324           0 : void SAL_CALL DocumentRenderer::render (
    2325             :     sal_Int32 nRenderer,
    2326             :     const css::uno::Any& rSelection,
    2327             :     const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
    2328             :     throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception)
    2329             : {
    2330             :     (void)rSelection;
    2331           0 :     mpImpl->ProcessProperties(rOptions);
    2332           0 :     mpImpl->PrintPage(nRenderer);
    2333           0 : }
    2334             : 
    2335             : 
    2336             : 
    2337           0 : } // end of namespace sd
    2338             : 
    2339             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10