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