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