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 :
60 :
61 : namespace sd {
62 :
63 : namespace {
64 :
65 :
66 : /** Convenience class to extract values from the sequence of properties
67 : given to one of the XRenderable methods.
68 : */
69 0 : class PrintOptions
70 : {
71 : public:
72 0 : PrintOptions (
73 : const vcl::PrinterOptionsHelper& rHelper,
74 : const ::std::vector<sal_Int32>& rSlidesPerPage)
75 : : mrProperties(rHelper),
76 0 : maSlidesPerPage(rSlidesPerPage)
77 : {
78 0 : }
79 :
80 0 : bool IsWarningOrientation() const
81 : {
82 0 : return GetBoolValue(NULL, true);
83 : }
84 :
85 0 : bool IsPrintPageName() const
86 : {
87 0 : return GetBoolValue("IsPrintName");
88 : }
89 :
90 0 : bool IsDate() const
91 : {
92 0 : return GetBoolValue("IsPrintDateTime");
93 : }
94 :
95 0 : bool IsTime() const
96 : {
97 0 : return GetBoolValue("IsPrintDateTime");
98 : }
99 :
100 0 : bool IsHiddenPages() const
101 : {
102 0 : return GetBoolValue("IsPrintHidden");
103 : }
104 :
105 0 : bool IsHandoutHorizontal() const
106 : {
107 0 : return GetBoolValue("SlidesPerPageOrder", sal_Int32(0));
108 : }
109 :
110 0 : sal_Int32 GetHandoutPageCount() const
111 : {
112 0 : sal_uInt32 nIndex = static_cast<sal_Int32>(mrProperties.getIntValue("SlidesPerPage", sal_Int32(0)));
113 0 : if (nIndex<maSlidesPerPage.size())
114 0 : return maSlidesPerPage[nIndex];
115 0 : else if ( ! maSlidesPerPage.empty())
116 0 : return maSlidesPerPage[0];
117 : else
118 0 : return 0;
119 : }
120 :
121 0 : bool IsDraw() const
122 : {
123 0 : return GetBoolValue("PageContentType", sal_Int32(0));
124 : }
125 :
126 0 : bool IsHandout() const
127 : {
128 0 : return GetBoolValue("PageContentType", sal_Int32(1));
129 : }
130 :
131 0 : bool IsNotes() const
132 : {
133 0 : return GetBoolValue("PageContentType", sal_Int32(2));
134 : }
135 :
136 0 : bool IsOutline() const
137 : {
138 0 : return GetBoolValue("PageContentType", sal_Int32(3));
139 : }
140 :
141 0 : sal_uLong GetOutputQuality() const
142 : {
143 0 : sal_Int32 nQuality = static_cast<sal_Int32>(mrProperties.getIntValue( "Quality", sal_Int32(0) ));
144 0 : return nQuality;
145 : }
146 :
147 0 : bool IsPageSize() const
148 : {
149 0 : return GetBoolValue("PageOptions", sal_Int32(1));
150 : }
151 :
152 0 : bool IsTilePage() const
153 : {
154 0 : return GetBoolValue("PageOptions", sal_Int32(2)) || GetBoolValue("PageOptions", sal_Int32(3));
155 : }
156 :
157 0 : bool IsCutPage() const
158 : {
159 0 : return GetBoolValue("PageOptions", sal_Int32(0));
160 : }
161 :
162 0 : bool IsBooklet() const
163 : {
164 0 : return GetBoolValue("PrintProspect", false);
165 : }
166 :
167 0 : bool IsPrintExcluded() const
168 : {
169 0 : return (IsNotes() || IsDraw() || IsHandout()) && IsHiddenPages();
170 : }
171 :
172 0 : bool IsPrintFrontPage() const
173 : {
174 0 : sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
175 0 : return nInclude == 0 || nInclude == 1;
176 : }
177 :
178 0 : bool IsPrintBackPage() const
179 : {
180 0 : sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
181 0 : return nInclude == 0 || nInclude == 2;
182 : }
183 :
184 0 : bool IsPaperBin() const
185 : {
186 0 : return GetBoolValue("PrintPaperFromSetup", false);
187 : }
188 :
189 0 : bool IsPrintMarkedOnly() const
190 : {
191 0 : return GetBoolValue("PrintContent", sal_Int32(2));
192 : }
193 :
194 0 : OUString GetPrinterSelection (sal_Int32 nPageCount, sal_Int32 nCurrentPageIndex) const
195 : {
196 0 : sal_Int32 nContent = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
197 : OUString sFullRange = OUStringBuffer()
198 0 : .append(static_cast<sal_Int32>(1))
199 0 : .append(static_cast<sal_Unicode>('-'))
200 0 : .append(nPageCount).makeStringAndClear();
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::valueOf(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 : sal_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 : a string and its value equals pValue. When the property is
240 : unknown then bDefaultValue is returned. Otherwise <FALSE/> is
241 : returned.
242 : */
243 : bool GetBoolValue (
244 : const sal_Char* pName,
245 : const sal_Char* pValue,
246 : const bool bDefaultValue = false) const
247 : {
248 : OUString sValue( mrProperties.getStringValue( pName ) );
249 : if (!sValue.isEmpty())
250 : return sValue.equalsAscii(pValue);
251 : else
252 : return bDefaultValue;
253 : }
254 :
255 : /** Return <TRUE/> when the value of the property with name pName is
256 : an integer and its value is nTriggerValue. Otherwise <FALSE/> is
257 : returned.
258 : */
259 0 : bool GetBoolValue (
260 : const sal_Char* pName,
261 : const sal_Int32 nTriggerValue) const
262 : {
263 0 : sal_Int32 nValue = static_cast<sal_Int32>(mrProperties.getIntValue( pName ));
264 0 : return nValue == nTriggerValue;
265 : }
266 : };
267 :
268 :
269 :
270 : /** A collection of values that helps to reduce the number of arguments
271 : given to some functions. Note that not all values are set at the
272 : same time.
273 : */
274 0 : class PrintInfo
275 : {
276 : public:
277 0 : PrintInfo (
278 : const Printer* pPrinter,
279 : const bool bPrintMarkedOnly)
280 : : mpPrinter(pPrinter),
281 : mnDrawMode(DRAWMODE_DEFAULT),
282 : msTimeDate(),
283 : msPageString(),
284 : maPrintSize(0,0),
285 : maPageSize(0,0),
286 : meOrientation(ORIENTATION_PORTRAIT),
287 : maMap(),
288 0 : mbPrintMarkedOnly(bPrintMarkedOnly)
289 0 : {}
290 :
291 : const Printer* mpPrinter;
292 : sal_uLong mnDrawMode;
293 : OUString msTimeDate;
294 : OUString msPageString;
295 : Size maPrintSize;
296 : Size maPageSize;
297 : Orientation meOrientation;
298 : MapMode maMap;
299 : const bool mbPrintMarkedOnly;
300 : };
301 :
302 :
303 :
304 : /** Output one page of the document to the given printer. Note that
305 : more than one document page may be output to one printer page.
306 : */
307 0 : void PrintPage (
308 : Printer& rPrinter,
309 : ::sd::View& rPrintView,
310 : SdPage& rPage,
311 : View* pView,
312 : const bool bPrintMarkedOnly,
313 : const SetOfByte& rVisibleLayers,
314 : const SetOfByte& rPrintableLayers)
315 : {
316 0 : rPrintView.ShowSdrPage(&rPage);
317 :
318 0 : const MapMode aOriginalMapMode (rPrinter.GetMapMode());
319 :
320 : // Set the visible layers
321 0 : SdrPageView* pPageView = rPrintView.GetSdrPageView();
322 : OSL_ASSERT(pPageView!=NULL);
323 0 : pPageView->SetVisibleLayers(rVisibleLayers);
324 0 : pPageView->SetPrintableLayers(rPrintableLayers);
325 :
326 0 : if (pView!=NULL && bPrintMarkedOnly)
327 0 : pView->DrawMarkedObj(rPrinter);
328 : else
329 : rPrintView.CompleteRedraw(&rPrinter,
330 0 : Region(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 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 = OUString("OptionsUIFile");
400 0 : if( mbImpress )
401 0 : aOptionsUIFile.Value <<= OUString("modules/simpress/ui/printeroptions.ui");
402 : else
403 0 : aOptionsUIFile.Value <<= 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( "%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< 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 : 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<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<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<OUString> GetSlidesPerPageSequence()
672 : {
673 : const Sequence<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 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 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 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 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 0 : 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 0 : 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 : for (sal_Int32 nRow=0; nRow<nRowCount; ++nRow)
863 0 : for (sal_Int32 nColumn=0; nColumn<nColumnCount; ++nColumn)
864 : {
865 0 : aMap.SetOrigin(Point(nColumn*nPageWidth,nRow*nPageHeight));
866 0 : rPrinter.SetMapMode(aMap);
867 : PrintPage(
868 : rPrinter,
869 : rPrintView,
870 : *pPageToPrint,
871 : pView,
872 : mbPrintMarkedOnly,
873 : rVisibleLayers,
874 0 : rPrintableLayers);
875 : }
876 :
877 : PrintMessage(
878 : rPrinter,
879 : msPageString,
880 0 : maPageStringOffset);
881 : }
882 :
883 : private:
884 : const sal_uInt16 mnPageIndex;
885 : const sal_Int32 mnGap;
886 : };
887 :
888 : /** Print two slides to one printer page so that the resulting pages
889 : form a booklet.
890 : */
891 : class BookletPrinterPage : public PrinterPage
892 : {
893 : public:
894 0 : BookletPrinterPage (
895 : const sal_uInt16 nFirstPageIndex,
896 : const sal_uInt16 nSecondPageIndex,
897 : const Point& rFirstOffset,
898 : const Point& rSecondOffset,
899 : const PageKind ePageKind,
900 : const MapMode& rMapMode,
901 : const bool bPrintMarkedOnly,
902 : const sal_uLong nDrawMode,
903 : const Orientation eOrientation,
904 : const sal_uInt16 nPaperTray)
905 : : PrinterPage(ePageKind, rMapMode, bPrintMarkedOnly, "",
906 : Point(), nDrawMode, eOrientation, nPaperTray),
907 : mnFirstPageIndex(nFirstPageIndex),
908 : mnSecondPageIndex(nSecondPageIndex),
909 : maFirstOffset(rFirstOffset),
910 0 : maSecondOffset(rSecondOffset)
911 : {
912 0 : }
913 :
914 0 : virtual ~BookletPrinterPage() {}
915 :
916 0 : virtual void Print (
917 : Printer& rPrinter,
918 : SdDrawDocument& rDocument,
919 : ViewShell& rViewShell,
920 : View* pView,
921 : DrawView& rPrintView,
922 : const SetOfByte& rVisibleLayers,
923 : const SetOfByte& rPrintableLayers) const
924 : {
925 : (void)rViewShell;
926 0 : MapMode aMap (maMap);
927 0 : SdPage* pPageToPrint = rDocument.GetSdPage(mnFirstPageIndex, mePageKind);
928 0 : if (pPageToPrint)
929 : {
930 0 : aMap.SetOrigin(maFirstOffset);
931 0 : rPrinter.SetMapMode(aMap);
932 : PrintPage(
933 : rPrinter,
934 : rPrintView,
935 : *pPageToPrint,
936 : pView,
937 : mbPrintMarkedOnly,
938 : rVisibleLayers,
939 0 : rPrintableLayers);
940 : }
941 :
942 0 : pPageToPrint = rDocument.GetSdPage(mnSecondPageIndex, mePageKind);
943 0 : if( pPageToPrint )
944 : {
945 0 : aMap.SetOrigin(maSecondOffset);
946 0 : rPrinter.SetMapMode(aMap);
947 : PrintPage(
948 : rPrinter,
949 : rPrintView,
950 : *pPageToPrint,
951 : pView,
952 : mbPrintMarkedOnly,
953 : rVisibleLayers,
954 0 : rPrintableLayers);
955 0 : }
956 0 : }
957 :
958 : private:
959 : const sal_uInt16 mnFirstPageIndex;
960 : const sal_uInt16 mnSecondPageIndex;
961 : const Point maFirstOffset;
962 : const Point maSecondOffset;
963 : };
964 :
965 :
966 :
967 :
968 : /** One handout page displays one to nine slides.
969 : */
970 0 : class HandoutPrinterPage : public PrinterPage
971 : {
972 : public:
973 0 : HandoutPrinterPage (
974 : const sal_uInt16 nHandoutPageIndex,
975 : const ::std::vector<sal_uInt16>& rPageIndices,
976 : const MapMode& rMapMode,
977 : const OUString& rsPageString,
978 : const Point& rPageStringOffset,
979 : const sal_uLong nDrawMode,
980 : const Orientation eOrientation,
981 : const sal_uInt16 nPaperTray)
982 : : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
983 : rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
984 : mnHandoutPageIndex(nHandoutPageIndex),
985 0 : maPageIndices(rPageIndices)
986 : {
987 0 : }
988 :
989 0 : virtual void Print (
990 : Printer& rPrinter,
991 : SdDrawDocument& rDocument,
992 : ViewShell& rViewShell,
993 : View* pView,
994 : DrawView& rPrintView,
995 : const SetOfByte& rVisibleLayers,
996 : const SetOfByte& rPrintableLayers) const
997 : {
998 0 : SdPage& rHandoutPage (*rDocument.GetSdPage(0, PK_HANDOUT));
999 :
1000 0 : Reference< com::sun::star::beans::XPropertySet > xHandoutPage( rHandoutPage.getUnoPage(), UNO_QUERY );
1001 0 : const OUString sPageNumber( "Number" );
1002 :
1003 : // Collect the page objects of the handout master.
1004 0 : std::vector<SdrPageObj*> aHandoutPageObjects;
1005 0 : SdrObjListIter aShapeIter (rHandoutPage);
1006 0 : while (aShapeIter.IsMore())
1007 : {
1008 0 : SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
1009 0 : if (pPageObj)
1010 0 : aHandoutPageObjects.push_back(pPageObj);
1011 : }
1012 0 : if (aHandoutPageObjects.empty())
1013 0 : return;
1014 :
1015 : // Connect page objects with pages.
1016 0 : std::vector<SdrPageObj*>::iterator aPageObjIter (aHandoutPageObjects.begin());
1017 0 : for (std::vector<sal_uInt16>::const_iterator
1018 0 : iPageIndex(maPageIndices.begin()),
1019 0 : iEnd(maPageIndices.end());
1020 0 : iPageIndex!=iEnd && aPageObjIter!=aHandoutPageObjects.end();
1021 : ++iPageIndex)
1022 : {
1023 : // Check if the page still exists.
1024 0 : if (*iPageIndex >= rDocument.GetSdPageCount(PK_STANDARD))
1025 0 : continue;
1026 :
1027 0 : SdrPageObj* pPageObj = (*aPageObjIter++);
1028 0 : pPageObj->SetReferencedPage(rDocument.GetSdPage(*iPageIndex, PK_STANDARD));
1029 : }
1030 :
1031 : // if there are more page objects than pages left, set the rest to invisible
1032 0 : int nHangoverCount = 0;
1033 0 : while (aPageObjIter != aHandoutPageObjects.end())
1034 : {
1035 0 : (*aPageObjIter++)->SetReferencedPage(0L);
1036 0 : nHangoverCount++;
1037 : }
1038 :
1039 : // Hide outlines for objects that have pages attached.
1040 0 : if (nHangoverCount > 0)
1041 : {
1042 0 : int nSkip = aHandoutPageObjects.size() - nHangoverCount;
1043 0 : aShapeIter.Reset();
1044 0 : while (aShapeIter.IsMore())
1045 : {
1046 0 : SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
1047 0 : if (pPathObj)
1048 : {
1049 0 : if (nSkip > 0)
1050 0 : --nSkip;
1051 : else
1052 0 : pPathObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
1053 : }
1054 : }
1055 : }
1056 :
1057 0 : if( xHandoutPage.is() ) try
1058 : {
1059 0 : xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(mnHandoutPageIndex) ) );
1060 : }
1061 0 : catch( Exception& )
1062 : {
1063 : }
1064 0 : rViewShell.SetPrintedHandoutPageNum( mnHandoutPageIndex + 1 );
1065 :
1066 0 : MapMode aMap (rPrinter.GetMapMode());
1067 0 : rPrinter.SetMapMode(maMap);
1068 :
1069 : PrintPage(
1070 : rPrinter,
1071 : rPrintView,
1072 : rHandoutPage,
1073 : pView,
1074 : false,
1075 : rVisibleLayers,
1076 0 : rPrintableLayers);
1077 : PrintMessage(
1078 : rPrinter,
1079 : msPageString,
1080 0 : maPageStringOffset);
1081 :
1082 0 : if( xHandoutPage.is() ) try
1083 : {
1084 0 : xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(0) ) );
1085 : }
1086 0 : catch( Exception& )
1087 : {
1088 : }
1089 0 : rViewShell.SetPrintedHandoutPageNum(1);
1090 :
1091 : // Restore outlines.
1092 0 : if (nHangoverCount > 0)
1093 : {
1094 0 : aShapeIter.Reset();
1095 0 : while (aShapeIter.IsMore())
1096 : {
1097 0 : SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
1098 0 : if (pPathObj != NULL)
1099 0 : pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
1100 : }
1101 0 : }
1102 :
1103 : }
1104 :
1105 : private:
1106 : const sal_uInt16 mnHandoutPageIndex;
1107 : const ::std::vector<sal_uInt16> maPageIndices;
1108 : };
1109 :
1110 :
1111 :
1112 :
1113 : /** The outline information (title, subtitle, outline objects) of the
1114 : document. There is no fixed mapping of slides to printer pages.
1115 : */
1116 : class OutlinerPrinterPage : public PrinterPage
1117 : {
1118 : public:
1119 0 : OutlinerPrinterPage (
1120 : OutlinerParaObject* pParaObject,
1121 : const MapMode& rMapMode,
1122 : const OUString& rsPageString,
1123 : const Point& rPageStringOffset,
1124 : const sal_uLong nDrawMode,
1125 : const Orientation eOrientation,
1126 : const sal_uInt16 nPaperTray)
1127 : : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
1128 : rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
1129 0 : mpParaObject(pParaObject)
1130 : {
1131 0 : }
1132 :
1133 0 : ~OutlinerPrinterPage()
1134 0 : {
1135 0 : mpParaObject.reset();
1136 0 : }
1137 :
1138 0 : virtual void Print (
1139 : Printer& rPrinter,
1140 : SdDrawDocument& rDocument,
1141 : ViewShell& rViewShell,
1142 : View* pView,
1143 : DrawView& rPrintView,
1144 : const SetOfByte& rVisibleLayers,
1145 : const SetOfByte& rPrintableLayers) const
1146 : {
1147 : (void)rViewShell;
1148 : (void)pView;
1149 : (void)rPrintView;
1150 : (void)rVisibleLayers;
1151 : (void)rPrintableLayers;
1152 :
1153 : // Set up the printer.
1154 0 : rPrinter.SetMapMode(maMap);
1155 :
1156 : // Get and set up the outliner.
1157 0 : const Rectangle aOutRect (rPrinter.GetPageOffset(), rPrinter.GetOutputSize());
1158 0 : Outliner* pOutliner = rDocument.GetInternalOutliner();
1159 0 : const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
1160 0 : const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
1161 0 : const Size aSavedPaperSize (pOutliner->GetPaperSize());
1162 :
1163 0 : pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
1164 0 : pOutliner->SetPaperSize(aOutRect.GetSize());
1165 0 : pOutliner->SetUpdateMode(sal_True);
1166 0 : pOutliner->Clear();
1167 0 : pOutliner->SetText(*mpParaObject);
1168 :
1169 0 : pOutliner->Draw(&rPrinter, aOutRect);
1170 :
1171 : PrintMessage(
1172 : rPrinter,
1173 : msPageString,
1174 0 : maPageStringOffset);
1175 :
1176 : // Restore outliner and printer.
1177 0 : pOutliner->Clear();
1178 0 : pOutliner->SetUpdateMode(bSavedUpdateMode);
1179 0 : pOutliner->SetPaperSize(aSavedPaperSize);
1180 0 : pOutliner->Init(nSavedOutlMode);
1181 0 : }
1182 :
1183 : private:
1184 : ::boost::scoped_ptr<OutlinerParaObject> mpParaObject;
1185 : };
1186 : }
1187 :
1188 :
1189 : //===== DocumentRenderer::Implementation ======================================
1190 :
1191 : class DocumentRenderer::Implementation
1192 : : public SfxListener,
1193 : public vcl::PrinterOptionsHelper
1194 : {
1195 : public:
1196 0 : Implementation (ViewShellBase& rBase)
1197 0 : : mxObjectShell(rBase.GetDocShell())
1198 : , mrBase(rBase)
1199 : , mbIsDisposed(false)
1200 : , mpPrinter(NULL)
1201 : , mpOptions()
1202 : , maPrinterPages()
1203 : , mpPrintView()
1204 0 : , mbHasOrientationWarningBeenShown(false)
1205 : {
1206 0 : DialogCreator aCreator( mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() );
1207 0 : m_aUIProperties = aCreator.GetDialogControls();
1208 0 : maSlidesPerPage = aCreator.GetSlidesPerPage();
1209 :
1210 0 : StartListening(mrBase);
1211 0 : }
1212 :
1213 :
1214 :
1215 :
1216 0 : virtual ~Implementation()
1217 0 : {
1218 0 : EndListening(mrBase);
1219 0 : }
1220 :
1221 :
1222 :
1223 :
1224 0 : virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint)
1225 : {
1226 0 : const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
1227 0 : if (pSimpleHint != NULL
1228 0 : && pSimpleHint->GetId() == SFX_HINT_DYING
1229 0 : && &rBroadcaster == &static_cast<SfxBroadcaster&>(mrBase))
1230 : {
1231 0 : Dispose();
1232 : }
1233 0 : }
1234 :
1235 :
1236 :
1237 : /** Process the sequence of properties given to one of the XRenderable
1238 : methods.
1239 : */
1240 0 : void ProcessProperties (const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
1241 : {
1242 : OSL_ASSERT(!mbIsDisposed);
1243 0 : if (mbIsDisposed)
1244 0 : return;
1245 :
1246 0 : bool bIsValueChanged = processProperties( rOptions );
1247 0 : bool bIsPaperChanged = false;
1248 :
1249 : // The RenderDevice property is handled specially: its value is
1250 : // stored in mpPrinter instead of being retrieved on demand.
1251 0 : Any aDev( getValue( "RenderDevice" ) );
1252 0 : Reference<awt::XDevice> xRenderDevice;
1253 :
1254 0 : if (aDev >>= xRenderDevice)
1255 : {
1256 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
1257 0 : OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
1258 0 : mpPrinter = dynamic_cast<Printer*>(pOut);
1259 0 : Size aPageSizePixel = mpPrinter ? mpPrinter->GetPaperSizePixel() : Size();
1260 0 : if( aPageSizePixel != maPrinterPageSizePixel )
1261 : {
1262 0 : bIsPaperChanged = true;
1263 0 : maPrinterPageSizePixel = aPageSizePixel;
1264 : }
1265 : }
1266 :
1267 0 : if (bIsValueChanged)
1268 : {
1269 0 : if ( ! mpOptions )
1270 0 : mpOptions.reset(new PrintOptions(*this, maSlidesPerPage));
1271 : }
1272 0 : if( bIsValueChanged || bIsPaperChanged )
1273 0 : PreparePages();
1274 : }
1275 :
1276 :
1277 :
1278 : /** Return the number of pages that are to be printed.
1279 : */
1280 0 : sal_Int32 GetPrintPageCount()
1281 : {
1282 : OSL_ASSERT(!mbIsDisposed);
1283 0 : if (mbIsDisposed)
1284 0 : return 0;
1285 : else
1286 0 : return maPrinterPages.size();
1287 : }
1288 :
1289 :
1290 :
1291 : /** Return a sequence of properties that can be returned by the
1292 : XRenderable::getRenderer() method.
1293 : */
1294 0 : css::uno::Sequence<css::beans::PropertyValue> GetProperties (
1295 : const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
1296 : {
1297 : (void)rOptions;
1298 :
1299 0 : css::uno::Sequence<css::beans::PropertyValue> aProperties (3);
1300 :
1301 0 : aProperties[0].Name = "ExtraPrintUIOptions";
1302 0 : aProperties[0].Value <<= m_aUIProperties;
1303 :
1304 0 : aProperties[1].Name = "PageSize";
1305 0 : aProperties[1].Value <<= maPrintSize;
1306 :
1307 : // FIXME: is this always true ?
1308 0 : aProperties[2].Name = "PageIncludesNonprintableArea";
1309 0 : aProperties[2].Value = makeAny( sal_True );
1310 :
1311 0 : return aProperties;
1312 : }
1313 :
1314 :
1315 :
1316 :
1317 : /** Print one of the prepared pages.
1318 : */
1319 0 : void PrintPage (const sal_Int32 nIndex)
1320 : {
1321 : OSL_ASSERT(!mbIsDisposed);
1322 0 : if (mbIsDisposed)
1323 0 : return;
1324 :
1325 0 : Printer& rPrinter (*mpPrinter);
1326 :
1327 0 : ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
1328 0 : if ( ! pViewShell)
1329 0 : return;
1330 :
1331 0 : SdDrawDocument* pDocument = pViewShell->GetDoc();
1332 : OSL_ASSERT(pDocument!=NULL);
1333 :
1334 : ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
1335 0 : ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
1336 :
1337 0 : if ( ! mpPrintView)
1338 0 : mpPrintView.reset(new DrawView(mrBase.GetDocShell(), &rPrinter, NULL));
1339 :
1340 0 : if (nIndex<0 || sal::static_int_cast<sal_uInt32>(nIndex)>=maPrinterPages.size())
1341 0 : return;
1342 :
1343 0 : const ::boost::shared_ptr<PrinterPage> pPage (maPrinterPages[nIndex]);
1344 : OSL_ASSERT(pPage);
1345 0 : if ( ! pPage)
1346 0 : return;
1347 :
1348 0 : const Orientation eSavedOrientation (rPrinter.GetOrientation());
1349 0 : const sal_uLong nSavedDrawMode (rPrinter.GetDrawMode());
1350 0 : const MapMode aSavedMapMode (rPrinter.GetMapMode());
1351 0 : const sal_uInt16 nSavedPaperBin (rPrinter.GetPaperBin());
1352 :
1353 :
1354 : // Set page orientation.
1355 0 : if ( ! rPrinter.SetOrientation(pPage->GetOrientation()))
1356 : {
1357 0 : if ( ! mbHasOrientationWarningBeenShown
1358 0 : && mpOptions->IsWarningOrientation())
1359 : {
1360 0 : mbHasOrientationWarningBeenShown = true;
1361 : // Show warning that the orientation could not be set.
1362 0 : if (pViewShell)
1363 : {
1364 : WarningBox aWarnBox(
1365 0 : pViewShell->GetActiveWindow(),
1366 : (WinBits)(WB_OK_CANCEL | WB_DEF_CANCEL),
1367 0 : String(SdResId(STR_WARN_PRINTFORMAT_FAILURE)));
1368 0 : if (aWarnBox.Execute() != RET_OK)
1369 0 : return;
1370 : }
1371 : }
1372 : }
1373 :
1374 : // Set the draw mode.
1375 0 : rPrinter.SetDrawMode(pPage->GetDrawMode());
1376 :
1377 : // Set paper tray.
1378 0 : rPrinter.SetPaperBin(pPage->GetPaperTray());
1379 :
1380 : // Print the actual page.
1381 0 : pPage->Print(
1382 : rPrinter,
1383 : *pDocument,
1384 0 : *pViewShell,
1385 0 : pDrawViewShell ? pDrawViewShell->GetView() : NULL,
1386 0 : *mpPrintView,
1387 0 : pViewShell->GetFrameView()->GetVisibleLayers(),
1388 0 : pViewShell->GetFrameView()->GetPrintableLayers());
1389 :
1390 0 : rPrinter.SetOrientation(eSavedOrientation);
1391 0 : rPrinter.SetDrawMode(nSavedDrawMode);
1392 0 : rPrinter.SetMapMode(aSavedMapMode);
1393 0 : rPrinter.SetPaperBin(nSavedPaperBin);
1394 : }
1395 :
1396 :
1397 :
1398 :
1399 : private:
1400 : // rhbz#657394: keep the document alive: prevents crash when
1401 : SfxObjectShellRef mxObjectShell; // destroying mpPrintView
1402 : ViewShellBase& mrBase;
1403 : bool mbIsDisposed;
1404 : Printer* mpPrinter;
1405 : Size maPrinterPageSizePixel;
1406 : ::boost::scoped_ptr<PrintOptions> mpOptions;
1407 : ::std::vector< ::boost::shared_ptr< ::sd::PrinterPage> > maPrinterPages;
1408 : ::boost::scoped_ptr<DrawView> mpPrintView;
1409 : bool mbHasOrientationWarningBeenShown;
1410 : ::std::vector<sal_Int32> maSlidesPerPage;
1411 : awt::Size maPrintSize;
1412 :
1413 0 : void Dispose()
1414 : {
1415 0 : mbIsDisposed = true;
1416 0 : }
1417 :
1418 0 : sal_Int32 GetCurrentPageIndex() const
1419 : {
1420 0 : const ViewShell *pShell = mrBase.GetMainViewShell().get();
1421 0 : const SdPage *pCurrentPage = pShell ? pShell->getCurrentPage() : NULL;
1422 0 : return pCurrentPage ? (pCurrentPage->GetPageNum()-1)/2 : -1;
1423 : }
1424 :
1425 : /** Determine and set the paper orientation.
1426 : */
1427 0 : bool SetupPaperOrientation (
1428 : const PageKind ePageKind,
1429 : PrintInfo& rInfo)
1430 : {
1431 0 : SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
1432 0 : rInfo.meOrientation = ORIENTATION_PORTRAIT;
1433 :
1434 0 : if( ! mpOptions->IsBooklet())
1435 : {
1436 0 : rInfo.meOrientation = pDocument->GetSdPage(0, ePageKind)->GetOrientation();
1437 : }
1438 0 : else if (rInfo.maPageSize.Width() < rInfo.maPageSize.Height())
1439 0 : rInfo.meOrientation = ORIENTATION_LANDSCAPE;
1440 :
1441 0 : const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
1442 0 : if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
1443 0 : (aPaperSize.Width() < aPaperSize.Height()))
1444 0 : ||
1445 0 : (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
1446 0 : (aPaperSize.Width() > aPaperSize.Height()))
1447 : )
1448 : {
1449 0 : maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
1450 : }
1451 : else
1452 : {
1453 0 : maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
1454 : }
1455 :
1456 0 : return true;
1457 : }
1458 :
1459 :
1460 :
1461 : /** Top most method for preparing printer pages. In this and the other
1462 : Prepare... methods the various special cases are detected and
1463 : handled.
1464 : For every page that is to be printed (that may contain several
1465 : slides) one PrinterPage object is created and inserted into
1466 : maPrinterPages.
1467 : */
1468 0 : void PreparePages()
1469 : {
1470 0 : mpPrintView.reset();
1471 0 : maPrinterPages.clear();
1472 0 : mbHasOrientationWarningBeenShown = false;
1473 :
1474 0 : ViewShell* pShell = mrBase.GetMainViewShell().get();
1475 :
1476 0 : PrintInfo aInfo (mpPrinter, mpOptions->IsPrintMarkedOnly());
1477 :
1478 0 : if (aInfo.mpPrinter!=NULL && pShell!=NULL)
1479 : {
1480 :
1481 0 : MapMode aMap (aInfo.mpPrinter->GetMapMode());
1482 0 : aMap.SetMapUnit(MAP_100TH_MM);
1483 0 : aInfo.maMap = aMap;
1484 0 : mpPrinter->SetMapMode(aMap);
1485 :
1486 0 : ::Outliner& rOutliner = mrBase.GetDocument()->GetDrawOutliner();
1487 0 : const sal_uLong nSavedControlWord (rOutliner.GetControlWord());
1488 0 : sal_uLong nCntrl = nSavedControlWord;
1489 0 : nCntrl &= ~EE_CNTRL_MARKFIELDS;
1490 0 : nCntrl &= ~EE_CNTRL_ONLINESPELLING;
1491 0 : rOutliner.SetControlWord( nCntrl );
1492 :
1493 : // When in outline view then apply all pending changes to the model.
1494 0 : if (pShell->ISA(OutlineViewShell))
1495 0 : static_cast<OutlineViewShell*>(pShell)->PrepareClose (sal_False, sal_False);
1496 :
1497 : // Collect some frequently used data.
1498 0 : if (mpOptions->IsDate())
1499 : {
1500 0 : aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getDate( Date( Date::SYSTEM ) );
1501 0 : aInfo.msTimeDate += OUString((sal_Unicode)' ');
1502 : }
1503 :
1504 0 : if (mpOptions->IsTime())
1505 0 : aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getTime( Time( Time::SYSTEM ), sal_False, sal_False );
1506 0 : aInfo.maPrintSize = aInfo.mpPrinter->GetOutputSize();
1507 : maPrintSize = awt::Size(
1508 0 : aInfo.mpPrinter->GetPaperSize().Width(),
1509 0 : aInfo.mpPrinter->GetPaperSize().Height());
1510 :
1511 0 : switch (mpOptions->GetOutputQuality())
1512 : {
1513 : case 1:
1514 : aInfo.mnDrawMode = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL
1515 : | DRAWMODE_GRAYTEXT | DRAWMODE_GRAYBITMAP
1516 0 : | DRAWMODE_GRAYGRADIENT;
1517 0 : break;
1518 :
1519 : case 2:
1520 : aInfo.mnDrawMode = DRAWMODE_BLACKLINE | DRAWMODE_WHITEFILL
1521 : | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEBITMAP
1522 0 : | DRAWMODE_WHITEGRADIENT;
1523 0 : break;
1524 :
1525 : default:
1526 0 : aInfo.mnDrawMode = DRAWMODE_DEFAULT;
1527 : }
1528 :
1529 0 : if (mpOptions->IsDraw())
1530 0 : PrepareStdOrNotes(PK_STANDARD, aInfo);
1531 0 : if (mpOptions->IsNotes())
1532 0 : PrepareStdOrNotes(PK_NOTES, aInfo);
1533 0 : if (mpOptions->IsHandout())
1534 : {
1535 0 : InitHandoutTemplate();
1536 0 : PrepareHandout(aInfo);
1537 : }
1538 0 : if (mpOptions->IsOutline())
1539 0 : PrepareOutline(aInfo);
1540 :
1541 0 : rOutliner.SetControlWord(nSavedControlWord);
1542 0 : }
1543 0 : }
1544 :
1545 :
1546 :
1547 :
1548 : /** Create the page objects of the handout template. When the actual
1549 : printing takes place then the page objects are assigned different
1550 : sets of slides for each printed page (see HandoutPrinterPage::Print).
1551 : */
1552 0 : void InitHandoutTemplate()
1553 : {
1554 0 : const sal_Int32 nSlidesPerHandout (mpOptions->GetHandoutPageCount());
1555 0 : const bool bHandoutHorizontal (mpOptions->IsHandoutHorizontal());
1556 :
1557 0 : AutoLayout eLayout = AUTOLAYOUT_HANDOUT6;
1558 0 : switch (nSlidesPerHandout)
1559 : {
1560 0 : case 0: eLayout = AUTOLAYOUT_NONE; break; // AUTOLAYOUT_HANDOUT1; break;
1561 0 : case 1: eLayout = AUTOLAYOUT_HANDOUT1; break;
1562 0 : case 2: eLayout = AUTOLAYOUT_HANDOUT2; break;
1563 0 : case 3: eLayout = AUTOLAYOUT_HANDOUT3; break;
1564 0 : case 4: eLayout = AUTOLAYOUT_HANDOUT4; break;
1565 : default:
1566 0 : case 6: eLayout = AUTOLAYOUT_HANDOUT6; break;
1567 0 : case 9: eLayout = AUTOLAYOUT_HANDOUT9; break;
1568 : }
1569 :
1570 0 : if( !mrBase.GetDocument() )
1571 0 : return;
1572 :
1573 0 : SdDrawDocument& rModel = *mrBase.GetDocument();
1574 :
1575 : // first, prepare handout page (not handout master)
1576 :
1577 0 : SdPage* pHandout = rModel.GetSdPage(0, PK_HANDOUT);
1578 0 : if( !pHandout )
1579 0 : return;
1580 :
1581 : // delete all previous shapes from handout page
1582 0 : while( pHandout->GetObjCount() )
1583 : {
1584 0 : SdrObject* pObj = pHandout->NbcRemoveObject(0);
1585 0 : if( pObj )
1586 0 : SdrObject::Free( pObj );
1587 : }
1588 :
1589 0 : const bool bDrawLines (eLayout == AUTOLAYOUT_HANDOUT3);
1590 :
1591 0 : std::vector< Rectangle > aAreas;
1592 0 : SdPage::CalculateHandoutAreas( rModel, eLayout, bHandoutHorizontal, aAreas );
1593 :
1594 0 : std::vector< Rectangle >::iterator iter( aAreas.begin() );
1595 0 : while( iter != aAreas.end() )
1596 : {
1597 0 : pHandout->NbcInsertObject( new SdrPageObj((*iter++)) );
1598 :
1599 0 : if( bDrawLines && (iter != aAreas.end()) )
1600 : {
1601 0 : Rectangle aRect( (*iter++) );
1602 :
1603 0 : basegfx::B2DPolygon aPoly;
1604 0 : aPoly.insert(0, basegfx::B2DPoint( aRect.Left(), aRect.Top() ) );
1605 0 : aPoly.insert(1, basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
1606 :
1607 0 : basegfx::B2DHomMatrix aMatrix;
1608 0 : aMatrix.translate( 0.0, static_cast< double >( aRect.GetHeight() / 7 ) );
1609 :
1610 0 : basegfx::B2DPolyPolygon aPathPoly;
1611 0 : for( sal_uInt16 nLine = 0; nLine < 7; nLine++ )
1612 : {
1613 0 : aPoly.transform( aMatrix );
1614 0 : aPathPoly.append( aPoly );
1615 : }
1616 :
1617 0 : SdrPathObj* pPathObj = new SdrPathObj(OBJ_PATHLINE, aPathPoly );
1618 0 : pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
1619 0 : pPathObj->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
1620 :
1621 0 : pHandout->NbcInsertObject( pPathObj );
1622 : }
1623 0 : }
1624 : }
1625 :
1626 :
1627 :
1628 :
1629 : /** Detect whether the specified slide is to be printed.
1630 : @return
1631 : When the slide is not to be printed then <NULL/> is returned.
1632 : Otherwise a pointer to the slide is returned.
1633 : */
1634 0 : SdPage* GetFilteredPage (
1635 : const sal_Int32 nPageIndex,
1636 : const PageKind ePageKind) const
1637 : {
1638 : OSL_ASSERT(mrBase.GetDocument() != NULL);
1639 : OSL_ASSERT(nPageIndex>=0);
1640 : SdPage* pPage = mrBase.GetDocument()->GetSdPage(
1641 0 : sal::static_int_cast<sal_uInt16>(nPageIndex),
1642 0 : ePageKind);
1643 0 : if (pPage == NULL)
1644 0 : return NULL;
1645 0 : if ( ! pPage->IsExcluded() || mpOptions->IsPrintExcluded())
1646 0 : return pPage;
1647 : else
1648 0 : return NULL;
1649 : }
1650 :
1651 :
1652 :
1653 :
1654 : /** Prepare the outline of the document for printing. There is no fixed
1655 : number of slides whose outline data is put onto one printer page.
1656 : If the current printer page has enough room for the outline of the
1657 : current slide then that is added. Otherwise a new printer page is
1658 : started.
1659 : */
1660 0 : void PrepareOutline (PrintInfo& rInfo)
1661 : {
1662 0 : MapMode aMap (rInfo.maMap);
1663 0 : Point aPageOfs (rInfo.mpPrinter->GetPageOffset() );
1664 0 : aMap.SetScaleX(Fraction(1,2));
1665 0 : aMap.SetScaleY(Fraction(1,2));
1666 0 : mpPrinter->SetMapMode(aMap);
1667 :
1668 0 : Rectangle aOutRect(aPageOfs, rInfo.mpPrinter->GetOutputSize());
1669 0 : if( aOutRect.GetWidth() > aOutRect.GetHeight() )
1670 : {
1671 0 : Size aPaperSize( rInfo.mpPrinter->PixelToLogic( rInfo.mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
1672 0 : maPrintSize.Width = aPaperSize.Height();
1673 0 : maPrintSize.Height = aPaperSize.Width();
1674 0 : aOutRect = Rectangle( Point( aPageOfs.Y(), aPageOfs.X() ),
1675 0 : Size( aOutRect.GetHeight(), aOutRect.GetWidth() ) );
1676 : }
1677 :
1678 0 : Link aOldLink;
1679 0 : Outliner* pOutliner = mrBase.GetDocument()->GetInternalOutliner();
1680 0 : pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
1681 0 : const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
1682 0 : const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
1683 0 : const Size aSavedPaperSize (pOutliner->GetPaperSize());
1684 0 : const MapMode aSavedMapMode (pOutliner->GetRefMapMode());
1685 0 : pOutliner->SetPaperSize(aOutRect.GetSize());
1686 0 : pOutliner->SetUpdateMode(sal_True);
1687 :
1688 0 : long nPageH = aOutRect.GetHeight();
1689 :
1690 0 : ::std::vector< sal_Int32 > aPages;
1691 0 : sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
1692 : StringRangeEnumerator::getRangesFromString(
1693 : mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
1694 0 : aPages, 0, nPageCount-1);
1695 :
1696 0 : for (size_t nIndex = 0, nCount = aPages.size(); nIndex < nCount;)
1697 : {
1698 0 : pOutliner->Clear();
1699 0 : pOutliner->SetFirstPageNumber(aPages[nIndex]+1);
1700 :
1701 0 : Paragraph* pPara = NULL;
1702 0 : sal_Int32 nH (0);
1703 0 : while (nH < nPageH && nIndex<nCount)
1704 : {
1705 0 : SdPage* pPage = GetFilteredPage(aPages[nIndex], PK_STANDARD);
1706 0 : ++nIndex;
1707 0 : if (pPage == NULL)
1708 0 : continue;
1709 :
1710 0 : SdrTextObj* pTextObj = NULL;
1711 0 : sal_uInt32 nObj (0);
1712 :
1713 0 : while (pTextObj==NULL && nObj < pPage->GetObjCount())
1714 : {
1715 0 : SdrObject* pObj = pPage->GetObj(nObj++);
1716 0 : if (pObj->GetObjInventor() == SdrInventor
1717 0 : && pObj->GetObjIdentifier() == OBJ_TITLETEXT)
1718 : {
1719 0 : pTextObj = dynamic_cast<SdrTextObj*>(pObj);
1720 : }
1721 : }
1722 :
1723 0 : pPara = pOutliner->GetParagraph(pOutliner->GetParagraphCount() - 1);
1724 :
1725 0 : if (pTextObj!=NULL
1726 0 : && !pTextObj->IsEmptyPresObj()
1727 0 : && pTextObj->GetOutlinerParaObject())
1728 : {
1729 0 : pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
1730 : }
1731 : else
1732 0 : pOutliner->Insert(String());
1733 :
1734 0 : pTextObj = NULL;
1735 0 : nObj = 0;
1736 :
1737 0 : while (pTextObj==NULL && nObj<pPage->GetObjCount())
1738 : {
1739 0 : SdrObject* pObj = pPage->GetObj(nObj++);
1740 0 : if (pObj->GetObjInventor() == SdrInventor
1741 0 : && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
1742 : {
1743 0 : pTextObj = dynamic_cast<SdrTextObj*>(pObj);
1744 : }
1745 : }
1746 :
1747 0 : bool bSubTitle (false);
1748 0 : if (!pTextObj)
1749 : {
1750 0 : bSubTitle = true;
1751 0 : pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT)); // Untertitel vorhanden?
1752 : }
1753 :
1754 0 : sal_Int32 nParaCount1 = pOutliner->GetParagraphCount();
1755 :
1756 0 : if (pTextObj!=NULL
1757 0 : && !pTextObj->IsEmptyPresObj()
1758 0 : && pTextObj->GetOutlinerParaObject())
1759 : {
1760 0 : pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
1761 : }
1762 :
1763 0 : if (bSubTitle )
1764 : {
1765 0 : const sal_Int32 nParaCount2 (pOutliner->GetParagraphCount());
1766 0 : for (sal_Int32 nPara=nParaCount1; nPara<nParaCount2; ++nPara)
1767 : {
1768 0 : Paragraph* pP = pOutliner->GetParagraph(nPara);
1769 0 : if (pP!=NULL && pOutliner->GetDepth(nPara) > 0)
1770 0 : pOutliner->SetDepth(pP, 0);
1771 : }
1772 : }
1773 :
1774 0 : nH = pOutliner->GetTextHeight();
1775 : }
1776 :
1777 : // Remove the last paragraph when that does not fit completely on
1778 : // the current page.
1779 0 : if (nH > nPageH && pPara!=NULL)
1780 : {
1781 : sal_Int32 nCnt = pOutliner->GetAbsPos(
1782 0 : pOutliner->GetParagraph( pOutliner->GetParagraphCount() - 1 ) );
1783 0 : sal_Int32 nParaPos = pOutliner->GetAbsPos( pPara );
1784 0 : nCnt -= nParaPos;
1785 0 : pPara = pOutliner->GetParagraph( ++nParaPos );
1786 0 : if ( nCnt && pPara )
1787 : {
1788 0 : pOutliner->Remove(pPara, nCnt);
1789 0 : --nIndex;
1790 : }
1791 : }
1792 :
1793 : maPrinterPages.push_back(
1794 : ::boost::shared_ptr<PrinterPage>(
1795 : new OutlinerPrinterPage(
1796 0 : pOutliner->CreateParaObject(),
1797 : aMap,
1798 : rInfo.msTimeDate,
1799 : aPageOfs,
1800 : rInfo.mnDrawMode,
1801 : rInfo.meOrientation,
1802 0 : rInfo.mpPrinter->GetPaperBin())));
1803 : }
1804 :
1805 0 : pOutliner->SetRefMapMode(aSavedMapMode);
1806 0 : pOutliner->SetUpdateMode(bSavedUpdateMode);
1807 0 : pOutliner->SetPaperSize(aSavedPaperSize);
1808 0 : pOutliner->Init(nSavedOutlMode);
1809 0 : }
1810 :
1811 :
1812 :
1813 :
1814 : /** Prepare handout pages for slides that are to be printed.
1815 : */
1816 0 : void PrepareHandout (PrintInfo& rInfo)
1817 : {
1818 0 : SdDrawDocument* pDocument = mrBase.GetDocument();
1819 : OSL_ASSERT(pDocument != NULL);
1820 0 : SdPage& rHandoutPage (*pDocument->GetSdPage(0, PK_HANDOUT));
1821 :
1822 0 : const bool bScalePage (mpOptions->IsPageSize());
1823 :
1824 : sal_uInt16 nPaperBin;
1825 0 : if ( ! mpOptions->IsPaperBin())
1826 0 : nPaperBin = rHandoutPage.GetPaperBin();
1827 : else
1828 0 : nPaperBin = rInfo.mpPrinter->GetPaperBin();
1829 :
1830 : // Change orientation?
1831 0 : SdPage& rMaster (dynamic_cast<SdPage&>(rHandoutPage.TRG_GetMasterPage()));
1832 0 : rInfo.meOrientation = rMaster.GetOrientation();
1833 :
1834 0 : const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
1835 0 : if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
1836 0 : (aPaperSize.Width() < aPaperSize.Height()))
1837 0 : ||
1838 0 : (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
1839 0 : (aPaperSize.Width() > aPaperSize.Height()))
1840 : )
1841 : {
1842 0 : maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
1843 : }
1844 : else
1845 : {
1846 0 : maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
1847 : }
1848 :
1849 0 : MapMode aMap (rInfo.maMap);
1850 0 : const Point aPageOfs (rInfo.mpPrinter->GetPageOffset());
1851 :
1852 0 : if ( bScalePage )
1853 : {
1854 0 : const Size aPageSize (rHandoutPage.GetSize());
1855 0 : const Size aPrintSize (rInfo.mpPrinter->GetOutputSize());
1856 :
1857 0 : const double fHorz = (double) aPrintSize.Width() / aPageSize.Width();
1858 0 : const double fVert = (double) aPrintSize.Height() / aPageSize.Height();
1859 :
1860 0 : Fraction aFract;
1861 0 : if ( fHorz < fVert )
1862 0 : aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
1863 : else
1864 0 : aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
1865 :
1866 0 : aMap.SetScaleX(aFract);
1867 0 : aMap.SetScaleY(aFract);
1868 0 : aMap.SetOrigin(Point());
1869 : }
1870 :
1871 0 : ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
1872 0 : pViewShell->WriteFrameViewData();
1873 :
1874 : // Count page shapes.
1875 0 : sal_uInt32 nShapeCount (0);
1876 0 : SdrObjListIter aShapeIter (rHandoutPage);
1877 0 : while (aShapeIter.IsMore())
1878 : {
1879 0 : SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
1880 0 : if (pPageObj)
1881 0 : ++nShapeCount;
1882 : }
1883 :
1884 0 : const sal_uInt16 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
1885 0 : const sal_uInt16 nHandoutPageCount = nShapeCount ? (nPageCount + nShapeCount - 1) / nShapeCount : 0;
1886 0 : pViewShell->SetPrintedHandoutPageCount( nHandoutPageCount );
1887 0 : mrBase.GetDocument()->setHandoutPageCount( nHandoutPageCount );
1888 :
1889 : // Distribute pages to handout pages.
1890 : StringRangeEnumerator aRangeEnum(
1891 : mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
1892 0 : 0, nPageCount-1);
1893 0 : ::std::vector<sal_uInt16> aPageIndices;
1894 0 : sal_uInt16 nPrinterPageIndex = 0;
1895 0 : StringRangeEnumerator::Iterator it = aRangeEnum.begin(), itEnd = aRangeEnum.end();
1896 0 : bool bLastLoop = (it == itEnd);
1897 0 : while (!bLastLoop)
1898 : {
1899 0 : sal_Int32 nPageIndex = *it;
1900 0 : ++it;
1901 0 : bLastLoop = (it == itEnd);
1902 :
1903 0 : if (GetFilteredPage(nPageIndex, PK_STANDARD))
1904 0 : aPageIndices.push_back(nPageIndex);
1905 0 : else if (!bLastLoop)
1906 0 : continue;
1907 :
1908 : // Create a printer page when we have found one page for each
1909 : // placeholder or when this is the last (and special) loop.
1910 0 : if (!aPageIndices.empty() && (aPageIndices.size() == nShapeCount || bLastLoop))
1911 : {
1912 : maPrinterPages.push_back(
1913 : ::boost::shared_ptr<PrinterPage>(
1914 : new HandoutPrinterPage(
1915 : nPrinterPageIndex++,
1916 : aPageIndices,
1917 : aMap,
1918 : rInfo.msTimeDate,
1919 : aPageOfs,
1920 : rInfo.mnDrawMode,
1921 : rInfo.meOrientation,
1922 0 : nPaperBin)));
1923 0 : aPageIndices.clear();
1924 : }
1925 0 : }
1926 0 : }
1927 :
1928 :
1929 :
1930 :
1931 : /** Prepare the notes pages or regular slides.
1932 : */
1933 0 : void PrepareStdOrNotes (
1934 : const PageKind ePageKind,
1935 : PrintInfo& rInfo)
1936 : {
1937 : OSL_ASSERT(rInfo.mpPrinter != NULL);
1938 :
1939 : // Fill in page kind specific data.
1940 0 : SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
1941 0 : if (pDocument->GetSdPageCount(ePageKind) == 0)
1942 0 : return;
1943 0 : SdPage* pRefPage = pDocument->GetSdPage(0, ePageKind);
1944 0 : rInfo.maPageSize = pRefPage->GetSize();
1945 :
1946 0 : if ( ! SetupPaperOrientation(ePageKind, rInfo))
1947 0 : return;
1948 :
1949 0 : MapMode aMap (rInfo.maMap);
1950 0 : rInfo.maMap = aMap;
1951 :
1952 0 : if (mpOptions->IsBooklet())
1953 0 : PrepareBooklet(ePageKind, rInfo);
1954 : else
1955 0 : PrepareRegularPages(ePageKind, rInfo);
1956 : }
1957 :
1958 :
1959 :
1960 :
1961 : /** Prepare slides in a non-booklet way: one slide per one to many
1962 : printer pages.
1963 : */
1964 0 : void PrepareRegularPages (
1965 : const PageKind ePageKind,
1966 : PrintInfo& rInfo)
1967 : {
1968 0 : ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
1969 0 : pViewShell->WriteFrameViewData();
1970 :
1971 0 : sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
1972 : StringRangeEnumerator aRangeEnum(
1973 : mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
1974 0 : 0, nPageCount-1);
1975 0 : for (StringRangeEnumerator::Iterator
1976 0 : it = aRangeEnum.begin(),
1977 0 : itEnd = aRangeEnum.end();
1978 : it != itEnd;
1979 : ++it)
1980 : {
1981 0 : SdPage* pPage = GetFilteredPage(*it, ePageKind);
1982 0 : if (pPage == NULL)
1983 0 : continue;
1984 :
1985 0 : MapMode aMap (rInfo.maMap);
1986 : // is it possible that the page size changed?
1987 0 : const Size aPageSize = pPage->GetSize();
1988 :
1989 0 : if (mpOptions->IsPageSize())
1990 : {
1991 0 : const double fHorz ((double) rInfo.maPrintSize.Width() / aPageSize.Width());
1992 0 : const double fVert ((double) rInfo.maPrintSize.Height() / aPageSize.Height());
1993 :
1994 0 : Fraction aFract;
1995 0 : if (fHorz < fVert)
1996 0 : aFract = Fraction(rInfo.maPrintSize.Width(), aPageSize.Width());
1997 : else
1998 0 : aFract = Fraction(rInfo.maPrintSize.Height(), aPageSize.Height());
1999 :
2000 0 : aMap.SetScaleX(aFract);
2001 0 : aMap.SetScaleY(aFract);
2002 0 : aMap.SetOrigin(Point());
2003 : }
2004 :
2005 0 : if (mpOptions->IsPrintPageName())
2006 : {
2007 0 : rInfo.msPageString = pPage->GetName();
2008 0 : rInfo.msPageString += OUString(sal_Unicode(' '));
2009 : }
2010 : else
2011 0 : rInfo.msPageString = "";
2012 0 : rInfo.msPageString += rInfo.msTimeDate;
2013 :
2014 0 : long aPageWidth = aPageSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder();
2015 0 : long aPageHeight = aPageSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder();
2016 : // Bugfix for 44530:
2017 : // if it was implicitly changed (Landscape/Portrait),
2018 : // this is considered for tiling, respectively for the splitting up
2019 : // (Poster)
2020 0 : if( ( rInfo.maPrintSize.Width() > rInfo.maPrintSize.Height()
2021 0 : && aPageWidth < aPageHeight )
2022 0 : || ( rInfo.maPrintSize.Width() < rInfo.maPrintSize.Height()
2023 0 : && aPageWidth > aPageHeight ) )
2024 : {
2025 0 : const sal_Int32 nTmp (rInfo.maPrintSize.Width());
2026 0 : rInfo.maPrintSize.Width() = rInfo.maPrintSize.Height();
2027 0 : rInfo.maPrintSize.Height() = nTmp;
2028 : }
2029 :
2030 0 : if (mpOptions->IsTilePage()
2031 0 : && aPageWidth < rInfo.maPrintSize.Width()
2032 0 : && aPageHeight < rInfo.maPrintSize.Height())
2033 : {
2034 : // Put multiple slides on one printer page.
2035 0 : PrepareTiledPage(*it, *pPage, ePageKind, rInfo);
2036 : }
2037 : else
2038 : {
2039 0 : rInfo.maMap = aMap;
2040 0 : PrepareScaledPage(*it, *pPage, ePageKind, rInfo);
2041 : }
2042 0 : }
2043 0 : }
2044 :
2045 :
2046 :
2047 :
2048 : /** Put two slides on one printer page.
2049 : */
2050 0 : void PrepareBooklet (
2051 : const PageKind ePageKind,
2052 : const PrintInfo& rInfo)
2053 : {
2054 0 : MapMode aStdMap (rInfo.maMap);
2055 0 : Point aOffset;
2056 0 : Size aPrintSize_2 (rInfo.maPrintSize);
2057 0 : Size aPageSize_2 (rInfo.maPageSize);
2058 :
2059 0 : if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
2060 0 : aPrintSize_2.Width() >>= 1;
2061 : else
2062 0 : aPrintSize_2.Height() >>= 1;
2063 :
2064 0 : const double fPageWH = (double) aPageSize_2.Width() / aPageSize_2.Height();
2065 0 : const double fPrintWH = (double) aPrintSize_2.Width() / aPrintSize_2.Height();
2066 :
2067 0 : if( fPageWH < fPrintWH )
2068 : {
2069 0 : aPageSize_2.Width() = (long) ( aPrintSize_2.Height() * fPageWH );
2070 0 : aPageSize_2.Height()= aPrintSize_2.Height();
2071 : }
2072 : else
2073 : {
2074 0 : aPageSize_2.Width() = aPrintSize_2.Width();
2075 0 : aPageSize_2.Height() = (long) ( aPrintSize_2.Width() / fPageWH );
2076 : }
2077 :
2078 0 : MapMode aMap (rInfo.maMap);
2079 0 : aMap.SetScaleX( Fraction( aPageSize_2.Width(), rInfo.maPageSize.Width() ) );
2080 0 : aMap.SetScaleY( Fraction( aPageSize_2.Height(), rInfo.maPageSize.Height() ) );
2081 :
2082 : // calculate adjusted print size
2083 : const Size aAdjustedPrintSize (OutputDevice::LogicToLogic(
2084 : rInfo.maPrintSize,
2085 : aStdMap,
2086 0 : aMap));
2087 :
2088 0 : if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
2089 : {
2090 0 : aOffset.X() = ( ( aAdjustedPrintSize.Width() >> 1 ) - rInfo.maPageSize.Width() ) >> 1;
2091 0 : aOffset.Y() = ( aAdjustedPrintSize.Height() - rInfo.maPageSize.Height() ) >> 1;
2092 : }
2093 : else
2094 : {
2095 0 : aOffset.X() = ( aAdjustedPrintSize.Width() - rInfo.maPageSize.Width() ) >> 1;
2096 0 : aOffset.Y() = ( ( aAdjustedPrintSize.Height() >> 1 ) - rInfo.maPageSize.Height() ) >> 1;
2097 : }
2098 :
2099 : // create vector of pages to print
2100 0 : sal_Int32 nPageCount = mrBase.GetDocument()->GetSdPageCount(ePageKind);
2101 : StringRangeEnumerator aRangeEnum(
2102 : mpOptions->GetPrinterSelection(nPageCount, GetCurrentPageIndex()),
2103 0 : 0, nPageCount-1);
2104 0 : ::std::vector< sal_uInt16 > aPageVector;
2105 0 : for (StringRangeEnumerator::Iterator
2106 0 : it = aRangeEnum.begin(),
2107 0 : itEnd = aRangeEnum.end();
2108 : it != itEnd;
2109 : ++it)
2110 : {
2111 0 : SdPage* pPage = GetFilteredPage(*it, ePageKind);
2112 0 : if (pPage != NULL)
2113 0 : aPageVector.push_back(*it);
2114 : }
2115 :
2116 : // create pairs of pages to print on each page
2117 : typedef ::std::vector< ::std::pair< sal_uInt16, sal_uInt16 > > PairVector;
2118 0 : PairVector aPairVector;
2119 0 : if ( ! aPageVector.empty())
2120 : {
2121 0 : sal_uInt32 nFirstIndex = 0, nLastIndex = aPageVector.size() - 1;
2122 :
2123 0 : if( aPageVector.size() & 1 )
2124 0 : aPairVector.push_back( ::std::make_pair( (sal_uInt16) 65535, aPageVector[ nFirstIndex++ ] ) );
2125 : else
2126 0 : aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
2127 :
2128 0 : while( nFirstIndex < nLastIndex )
2129 : {
2130 0 : if( nFirstIndex & 1 )
2131 0 : aPairVector.push_back( ::std::make_pair( aPageVector[ nFirstIndex++ ], aPageVector[ nLastIndex-- ] ) );
2132 : else
2133 0 : aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
2134 : }
2135 : }
2136 :
2137 0 : for (sal_uInt32
2138 0 : nIndex=0,
2139 0 : nCount=aPairVector.size();
2140 : nIndex < nCount;
2141 : ++nIndex)
2142 : {
2143 0 : const bool bIsIndexOdd (nIndex & 1);
2144 0 : if ((!bIsIndexOdd && mpOptions->IsPrintFrontPage())
2145 0 : || (bIsIndexOdd && mpOptions->IsPrintBackPage()))
2146 : {
2147 0 : const ::std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]);
2148 0 : Point aSecondOffset (aOffset);
2149 0 : if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
2150 0 : aSecondOffset.X() += aAdjustedPrintSize.Width() / 2;
2151 : else
2152 0 : aSecondOffset.Y() += aAdjustedPrintSize.Height() / 2;
2153 : maPrinterPages.push_back(
2154 : ::boost::shared_ptr<PrinterPage>(
2155 : new BookletPrinterPage(
2156 : aPair.first,
2157 : aPair.second,
2158 : aOffset,
2159 : aSecondOffset,
2160 : ePageKind,
2161 : aMap,
2162 : rInfo.mbPrintMarkedOnly,
2163 : rInfo.mnDrawMode,
2164 : rInfo.meOrientation,
2165 0 : rInfo.mpPrinter->GetPaperBin())));
2166 :
2167 : }
2168 0 : }
2169 0 : }
2170 :
2171 :
2172 :
2173 :
2174 : /** Print one slide multiple times on one printer page so that the whole
2175 : printer page is covered.
2176 : */
2177 0 : void PrepareTiledPage (
2178 : const sal_Int32 nPageIndex,
2179 : const SdPage& rPage,
2180 : const PageKind ePageKind,
2181 : const PrintInfo& rInfo)
2182 : {
2183 : sal_uInt16 nPaperBin;
2184 0 : if ( ! mpOptions->IsPaperBin())
2185 0 : nPaperBin = rPage.GetPaperBin();
2186 : else
2187 0 : nPaperBin = rInfo.mpPrinter->GetPaperBin();
2188 :
2189 : maPrinterPages.push_back(
2190 : ::boost::shared_ptr<PrinterPage>(
2191 : new TiledPrinterPage(
2192 0 : sal::static_int_cast<sal_uInt16>(nPageIndex),
2193 : ePageKind,
2194 : 500,
2195 : rInfo.mbPrintMarkedOnly,
2196 : rInfo.msPageString,
2197 0 : rInfo.mpPrinter->GetPageOffset(),
2198 : rInfo.mnDrawMode,
2199 : rInfo.meOrientation,
2200 0 : nPaperBin)));
2201 0 : }
2202 :
2203 :
2204 :
2205 : /** Print one standard slide or notes page on one to many printer
2206 : pages. More than on printer page is used when the slide is larger
2207 : than the printable area.
2208 : */
2209 0 : void PrepareScaledPage (
2210 : const sal_Int32 nPageIndex,
2211 : const SdPage& rPage,
2212 : const PageKind ePageKind,
2213 : const PrintInfo& rInfo)
2214 : {
2215 0 : const Point aPageOffset (rInfo.mpPrinter->GetPageOffset());
2216 :
2217 : sal_uInt16 nPaperBin;
2218 0 : if ( ! mpOptions->IsPaperBin())
2219 0 : nPaperBin = rPage.GetPaperBin();
2220 : else
2221 0 : nPaperBin = rInfo.mpPrinter->GetPaperBin();
2222 :
2223 : // For pages larger then the printable area there
2224 : // are three options:
2225 : // 1. Scale down to the page to the printable area.
2226 : // 2. Print only the upper left part of the page
2227 : // (without the unprintable borders).
2228 : // 3. Split the page into parts of the size of the
2229 : // printable area.
2230 0 : const bool bScalePage (mpOptions->IsPageSize());
2231 0 : const bool bCutPage (mpOptions->IsCutPage());
2232 0 : MapMode aMap (rInfo.maMap);
2233 0 : if (bScalePage || bCutPage)
2234 : {
2235 : // Handle 1 and 2.
2236 :
2237 : // if CutPage is set then do not move it, otherwise move the
2238 : // scaled page to printable area
2239 : maPrinterPages.push_back(
2240 : ::boost::shared_ptr<PrinterPage>(
2241 : new RegularPrinterPage(
2242 0 : sal::static_int_cast<sal_uInt16>(nPageIndex),
2243 : ePageKind,
2244 : aMap,
2245 : rInfo.mbPrintMarkedOnly,
2246 : rInfo.msPageString,
2247 : aPageOffset,
2248 : rInfo.mnDrawMode,
2249 : rInfo.meOrientation,
2250 0 : nPaperBin)));
2251 : }
2252 : else
2253 : {
2254 : // Handle 3. Print parts of the page in the size of the
2255 : // printable area until the whole page is covered.
2256 :
2257 : // keep the page content at its position if it fits, otherwise
2258 : // move it to the printable area
2259 : const long nPageWidth (
2260 0 : rInfo.maPageSize.Width() - rPage.GetLftBorder() - rPage.GetRgtBorder());
2261 : const long nPageHeight (
2262 0 : rInfo.maPageSize.Height() - rPage.GetUppBorder() - rPage.GetLwrBorder());
2263 :
2264 0 : Point aOrigin ( 0, 0 );
2265 :
2266 0 : for (Point aPageOrigin = aOrigin;
2267 0 : -aPageOrigin.Y()<nPageHeight;
2268 0 : aPageOrigin.Y() -= rInfo.maPrintSize.Height())
2269 : {
2270 0 : for (aPageOrigin.X()=aOrigin.X();
2271 0 : -aPageOrigin.X()<nPageWidth;
2272 0 : aPageOrigin.X() -= rInfo.maPrintSize.Width())
2273 : {
2274 0 : aMap.SetOrigin(aPageOrigin);
2275 : maPrinterPages.push_back(
2276 : ::boost::shared_ptr<PrinterPage>(
2277 : new RegularPrinterPage(
2278 0 : sal::static_int_cast<sal_uInt16>(nPageIndex),
2279 : ePageKind,
2280 : aMap,
2281 : rInfo.mbPrintMarkedOnly,
2282 : rInfo.msPageString,
2283 : aPageOffset,
2284 : rInfo.mnDrawMode,
2285 : rInfo.meOrientation,
2286 0 : nPaperBin)));
2287 : }
2288 : }
2289 0 : }
2290 0 : }
2291 : };
2292 :
2293 :
2294 :
2295 :
2296 : //===== DocumentRenderer ======================================================
2297 :
2298 0 : DocumentRenderer::DocumentRenderer (ViewShellBase& rBase)
2299 : : DocumentRendererInterfaceBase(m_aMutex),
2300 0 : mpImpl(new Implementation(rBase))
2301 : {
2302 0 : }
2303 :
2304 :
2305 :
2306 :
2307 0 : DocumentRenderer::~DocumentRenderer()
2308 : {
2309 0 : }
2310 :
2311 :
2312 :
2313 :
2314 : //----- XRenderable -----------------------------------------------------------
2315 :
2316 0 : sal_Int32 SAL_CALL DocumentRenderer::getRendererCount (
2317 : const css::uno::Any& aSelection,
2318 : const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
2319 : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
2320 : {
2321 : (void)aSelection;
2322 0 : mpImpl->ProcessProperties(rOptions);
2323 0 : return mpImpl->GetPrintPageCount();
2324 : }
2325 :
2326 :
2327 :
2328 :
2329 0 : Sequence<beans::PropertyValue> SAL_CALL DocumentRenderer::getRenderer (
2330 : sal_Int32 nRenderer,
2331 : const css::uno::Any& rSelection,
2332 : const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
2333 : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
2334 : {
2335 : (void)nRenderer;
2336 : (void)rSelection;
2337 0 : mpImpl->ProcessProperties(rOptions);
2338 0 : return mpImpl->GetProperties(rOptions);
2339 : }
2340 :
2341 :
2342 :
2343 :
2344 0 : void SAL_CALL DocumentRenderer::render (
2345 : sal_Int32 nRenderer,
2346 : const css::uno::Any& rSelection,
2347 : const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
2348 : throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
2349 : {
2350 : (void)rSelection;
2351 0 : mpImpl->ProcessProperties(rOptions);
2352 0 : mpImpl->PrintPage(nRenderer);
2353 0 : }
2354 :
2355 :
2356 :
2357 33 : } // end of namespace sd
2358 :
2359 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|