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