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