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