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 <printdata.hxx>
22 :
23 : #include <globals.hrc>
24 : #include <doc.hxx>
25 : #include <unotxdoc.hxx>
26 : #include <wdocsh.hxx>
27 : #include <viewsh.hxx>
28 : #include <docfld.hxx>
29 :
30 : #include <svl/languageoptions.hxx>
31 : #include <toolkit/awt/vclxdevice.hxx>
32 : #include <tools/string.hxx>
33 : #include <tools/resary.hxx>
34 : #include <unotools/moduleoptions.hxx>
35 : #include <vcl/outdev.hxx>
36 :
37 :
38 : extern bool sw_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
39 :
40 :
41 : using namespace ::com::sun::star;
42 : using ::rtl::OUString;
43 :
44 :
45 : //////////////////////////////////////////////////////////////////////
46 :
47 0 : SwRenderData::SwRenderData()
48 : {
49 0 : }
50 :
51 :
52 0 : SwRenderData::~SwRenderData()
53 : {
54 : OSL_ENSURE( !m_pPostItShell, "m_pPostItShell should already have been deleted" );
55 : OSL_ENSURE( !m_pPostItFields, " should already have been deleted" );
56 0 : }
57 :
58 :
59 0 : void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev )
60 : {
61 0 : DeletePostItData();
62 0 : m_pPostItFields.reset(new _SetGetExpFlds);
63 0 : sw_GetPostIts( pDoc, m_pPostItFields.get() );
64 :
65 : //!! Disable spell and grammar checking in the temporary document.
66 : //!! Otherwise the grammar checker might process it and crash if we later on
67 : //!! simply delete this document while he is still at it.
68 0 : SwViewOption aViewOpt( *pViewOpt );
69 0 : aViewOpt.SetOnlineSpell( sal_False );
70 :
71 0 : m_pPostItShell.reset(new ViewShell(*new SwDoc, 0, &aViewOpt, pOutDev));
72 0 : }
73 :
74 :
75 0 : void SwRenderData::DeletePostItData()
76 : {
77 0 : if (HasPostItData())
78 : {
79 : // printer needs to remain at the real document
80 0 : m_pPostItShell->GetDoc()->setPrinter( 0, false, false );
81 0 : m_pPostItShell.reset();
82 0 : m_pPostItFields.reset();
83 : }
84 0 : }
85 :
86 0 : SfxObjectShellLock const& SwRenderData::GetTempDocShell() const
87 : {
88 0 : return m_xTempDocShell;
89 : }
90 0 : void SwRenderData::SetTempDocShell(SfxObjectShellLock const& xShell)
91 : {
92 0 : m_xTempDocShell = xShell;
93 0 : }
94 :
95 0 : bool SwRenderData::NeedNewViewOptionAdjust( const ViewShell& rCompare ) const
96 : {
97 0 : return m_pViewOptionAdjust ? ! m_pViewOptionAdjust->checkShell( rCompare ) : true;
98 : }
99 :
100 :
101 0 : void SwRenderData::ViewOptionAdjustStart(
102 : ViewShell &rSh, const SwViewOption &rViewOptions)
103 : {
104 0 : if (m_pViewOptionAdjust)
105 : {
106 : OSL_FAIL("error: there should be no ViewOptionAdjust active when calling this function" );
107 : }
108 : m_pViewOptionAdjust.reset(
109 0 : new SwViewOptionAdjust_Impl( rSh, rViewOptions ));
110 0 : }
111 :
112 :
113 0 : void SwRenderData::ViewOptionAdjust(SwPrintData const*const pPrtOptions)
114 : {
115 0 : m_pViewOptionAdjust->AdjustViewOptions( pPrtOptions );
116 0 : }
117 :
118 :
119 0 : void SwRenderData::ViewOptionAdjustStop()
120 : {
121 0 : m_pViewOptionAdjust.reset();
122 0 : }
123 :
124 0 : void SwRenderData::ViewOptionAdjustCrashPreventionKludge()
125 : {
126 0 : m_pViewOptionAdjust->DontTouchThatViewShellItSmellsFunny();
127 0 : }
128 :
129 :
130 0 : void SwRenderData::MakeSwPrtOptions(
131 : SwDocShell const*const pDocShell,
132 : SwPrintUIOptions const*const pOpt,
133 : bool const bIsPDFExport)
134 : {
135 0 : if (!pDocShell || !pOpt)
136 0 : return;
137 :
138 0 : m_pPrtOptions.reset(new SwPrintData);
139 0 : SwPrintData & rOptions(*m_pPrtOptions);
140 :
141 : // get default print options
142 0 : const TypeId aSwWebDocShellTypeId = TYPE(SwWebDocShell);
143 0 : sal_Bool bWeb = pDocShell->IsA( aSwWebDocShellTypeId );
144 0 : ::sw::InitPrintOptionsFromApplication(rOptions, bWeb);
145 :
146 : // get print options to use from provided properties
147 0 : rOptions.bPrintGraphic = pOpt->IsPrintGraphics();
148 0 : rOptions.bPrintTable = pOpt->IsPrintTables();
149 0 : rOptions.bPrintDraw = pOpt->IsPrintDrawings();
150 0 : rOptions.bPrintControl = pOpt->IsPrintFormControls();
151 0 : rOptions.bPrintLeftPages = pOpt->IsPrintLeftPages();
152 0 : rOptions.bPrintRightPages = pOpt->IsPrintRightPages();
153 0 : rOptions.bPrintPageBackground = pOpt->IsPrintPageBackground();
154 0 : rOptions.bPrintEmptyPages = pOpt->IsPrintEmptyPages( bIsPDFExport );
155 : // bUpdateFieldsInPrinting <-- not set here; mail merge only
156 0 : rOptions.bPaperFromSetup = pOpt->IsPaperFromSetup();
157 0 : rOptions.bPrintReverse = pOpt->IsPrintReverse();
158 0 : rOptions.bPrintProspect = pOpt->IsPrintProspect();
159 0 : rOptions.bPrintProspectRTL = pOpt->IsPrintProspectRTL();
160 : // bPrintSingleJobs <-- not set here; mail merge and or configuration
161 : // bModified <-- not set here; mail merge only
162 0 : rOptions.bPrintBlackFont = pOpt->IsPrintWithBlackTextColor();
163 0 : rOptions.bPrintHiddenText = pOpt->IsPrintHiddenText();
164 0 : rOptions.bPrintTextPlaceholder = pOpt->IsPrintTextPlaceholders();
165 0 : rOptions.nPrintPostIts = pOpt->GetPrintPostItsType();
166 :
167 : //! needs to be set after MakeOptions since the assignment operation in that
168 : //! function will destroy the pointers
169 0 : rOptions.SetPrintUIOptions( pOpt );
170 0 : rOptions.SetRenderData( this );
171 : }
172 :
173 :
174 : //////////////////////////////////////////////////////////////////////
175 :
176 0 : SwPrintUIOptions::SwPrintUIOptions(
177 : sal_uInt16 nCurrentPage,
178 : bool bWeb,
179 : bool bSwSrcView,
180 : bool bHasSelection,
181 : bool bHasPostIts,
182 : const SwPrintData &rDefaultPrintData ) :
183 : m_pLast( NULL ),
184 0 : m_rDefaultPrintData( rDefaultPrintData )
185 : {
186 0 : ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) );
187 :
188 : OSL_ENSURE( aLocalizedStrings.Count() >= 30, "resource incomplete" );
189 0 : if( aLocalizedStrings.Count() < 30 ) // bad resource ?
190 : return;
191 :
192 : // printing HTML sources does not have any valid UI options.
193 : // Its just the source code that gets printed ...
194 0 : if (bSwSrcView)
195 : {
196 0 : m_aUIProperties.realloc( 0 );
197 : return;
198 : }
199 :
200 : // check if CTL is enabled
201 0 : SvtLanguageOptions aLangOpt;
202 0 : bool bCTL = aLangOpt.IsCTLFontEnabled();
203 :
204 : // create sequence of print UI options
205 : // (5 options are not available for Writer-Web)
206 0 : const int nCTLOpts = bCTL ? 1 : 0;
207 0 : const int nNumProps = nCTLOpts + (bWeb ? 15 : 21);
208 0 : m_aUIProperties.realloc( nNumProps );
209 0 : int nIdx = 0;
210 :
211 : // load the writer PrinterOptions into the custom tab
212 0 : m_aUIProperties[nIdx].Name = rtl::OUString("OptionsUIFile");
213 0 : m_aUIProperties[nIdx++].Value <<= rtl::OUString("modules/swriter/ui/printeroptions.ui");
214 :
215 : // create "writer" section (new tab page in dialog)
216 0 : SvtModuleOptions aModOpt;
217 0 : String aAppGroupname( aLocalizedStrings.GetString( 0 ) );
218 : aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
219 0 : aModOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) );
220 0 : m_aUIProperties[ nIdx++ ].Value = setGroupControlOpt("tabcontrol-page2", aAppGroupname, ".HelpID:vcl:PrintDialog:TabPage:AppPage");
221 :
222 : // create sub section for Contents
223 0 : m_aUIProperties[ nIdx++ ].Value = setSubgroupControlOpt("contents", aLocalizedStrings.GetString(1), rtl::OUString());
224 :
225 : // create a bool option for background
226 0 : bool bDefaultVal = rDefaultPrintData.IsPrintPageBackground();
227 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("pagebackground", aLocalizedStrings.GetString( 2 ),
228 : ".HelpID:vcl:PrintDialog:PrintPageBackground:CheckBox",
229 : "PrintPageBackground",
230 0 : bDefaultVal);
231 :
232 : // create a bool option for pictures/graphics AND OLE and drawing objects as well
233 0 : bDefaultVal = rDefaultPrintData.IsPrintGraphic() || rDefaultPrintData.IsPrintDraw();
234 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("pictures", aLocalizedStrings.GetString( 3 ),
235 : ".HelpID:vcl:PrintDialog:PrintPicturesAndObjects:CheckBox",
236 : "PrintPicturesAndObjects",
237 0 : bDefaultVal);
238 0 : if (!bWeb)
239 : {
240 : // create a bool option for hidden text
241 0 : bDefaultVal = rDefaultPrintData.IsPrintHiddenText();
242 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("hiddentext", aLocalizedStrings.GetString( 4 ),
243 : ".HelpID:vcl:PrintDialog:PrintHiddenText:CheckBox",
244 : "PrintHiddenText",
245 0 : bDefaultVal);
246 :
247 : // create a bool option for place holder
248 0 : bDefaultVal = rDefaultPrintData.IsPrintTextPlaceholder();
249 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("placeholders", aLocalizedStrings.GetString( 5 ),
250 : ".HelpID:vcl:PrintDialog:PrintTextPlaceholder:CheckBox",
251 : "PrintTextPlaceholder",
252 0 : bDefaultVal);
253 : }
254 :
255 : // create a bool option for controls
256 0 : bDefaultVal = rDefaultPrintData.IsPrintControl();
257 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("formcontrols", aLocalizedStrings.GetString( 6 ),
258 : ".HelpID:vcl:PrintDialog:PrintControls:CheckBox",
259 : "PrintControls",
260 0 : bDefaultVal);
261 :
262 : // create sub section for Color
263 0 : m_aUIProperties[ nIdx++ ].Value = setSubgroupControlOpt("color", aLocalizedStrings.GetString(7), rtl::OUString());
264 :
265 : // create a bool option for printing text with black font color
266 0 : bDefaultVal = rDefaultPrintData.IsPrintBlackFont();
267 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("textinblack", aLocalizedStrings.GetString( 8 ),
268 : ".HelpID:vcl:PrintDialog:PrintBlackFonts:CheckBox",
269 : "PrintBlackFonts",
270 0 : bDefaultVal);
271 :
272 0 : if (!bWeb)
273 : {
274 : // create subgroup for misc options
275 0 : m_aUIProperties[ nIdx++ ].Value = setSubgroupControlOpt("pages", rtl::OUString(aLocalizedStrings.GetString(9)), rtl::OUString());
276 :
277 : // create a bool option for printing automatically inserted blank pages
278 0 : bDefaultVal = rDefaultPrintData.IsPrintEmptyPages();
279 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("autoblankpages", aLocalizedStrings.GetString( 10 ),
280 : ".HelpID:vcl:PrintDialog:PrintEmptyPages:CheckBox",
281 : "PrintEmptyPages",
282 0 : bDefaultVal);
283 : }
284 :
285 : // create a bool option for paper tray
286 0 : bDefaultVal = rDefaultPrintData.IsPaperFromSetup();
287 0 : vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt;
288 0 : aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) );
289 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("printpaperfromsetup", aLocalizedStrings.GetString( 11 ),
290 : ".HelpID:vcl:PrintDialog:PrintPaperFromSetup:CheckBox",
291 : "PrintPaperFromSetup",
292 : bDefaultVal,
293 0 : aPaperTrayOpt);
294 :
295 : // print range selection
296 0 : vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
297 0 : aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
298 0 : aPrintRangeOpt.mbInternalOnly = sal_True;
299 0 : m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("printrange", rtl::OUString(aLocalizedStrings.GetString(26)),
300 : rtl::OUString(),
301 0 : aPrintRangeOpt);
302 :
303 : // create a choice for the content to create
304 0 : rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) );
305 0 : uno::Sequence< rtl::OUString > aChoices( 3 );
306 0 : uno::Sequence< sal_Bool > aChoicesDisabled( 3 );
307 0 : uno::Sequence< rtl::OUString > aHelpIds( 3 );
308 0 : uno::Sequence< rtl::OUString > aWidgetIds( 3 );
309 0 : aChoices[0] = aLocalizedStrings.GetString( 27 );
310 0 : aChoicesDisabled[0] = sal_False;
311 0 : aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) );
312 0 : aWidgetIds[0] = "printallpages";
313 0 : aChoices[1] = aLocalizedStrings.GetString( 28 );
314 0 : aChoicesDisabled[1] = sal_False;
315 0 : aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) );
316 0 : aWidgetIds[1] = "printpages";
317 0 : aChoices[2] = aLocalizedStrings.GetString( 29 );
318 0 : aChoicesDisabled[2] = sal_Bool(! bHasSelection);
319 0 : aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) );
320 0 : aWidgetIds[2] = "printselection";
321 0 : m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, rtl::OUString(),
322 : aHelpIds, aPrintRangeName,
323 : aChoices, 0 /* always default to 'All pages' */,
324 0 : aChoicesDisabled);
325 : // show an Edit dependent on "Pages" selected
326 0 : vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True );
327 0 : m_aUIProperties[nIdx++].Value = setEditControlOpt("pagerange", rtl::OUString(),
328 : ".HelpID:vcl:PrintDialog:PageRange:Edit",
329 : "PageRange",
330 : rtl::OUString::valueOf( sal_Int32( nCurrentPage ) ) /* set text box to current page number */,
331 0 : aPageRangeOpt);
332 : // print content selection
333 0 : vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt;
334 0 : aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) );
335 0 : m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("extrawriterprintoptions", rtl::OUString(aLocalizedStrings.GetString(12)),
336 0 : rtl::OUString(), aContentsOpt);
337 : // create a list box for notes content
338 0 : const sal_Int16 nPrintPostIts = rDefaultPrintData.GetPrintPostIts();
339 0 : aChoices.realloc( 4 );
340 0 : aChoices[0] = aLocalizedStrings.GetString( 13 );
341 0 : aChoices[1] = aLocalizedStrings.GetString( 14 );
342 0 : aChoices[2] = aLocalizedStrings.GetString( 15 );
343 0 : aChoices[3] = aLocalizedStrings.GetString( 16 );
344 0 : aHelpIds.realloc( 2 );
345 0 : aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintAnnotationMode:FixedText" ) );
346 0 : aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintAnnotationMode:ListBox" ) );
347 0 : vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 0, sal_False );
348 0 : aAnnotOpt.mbEnabled = bHasPostIts;
349 0 : m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt("writercomments",
350 : aLocalizedStrings.GetString( 17 ),
351 : aHelpIds,
352 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ),
353 : aChoices,
354 : nPrintPostIts,
355 : uno::Sequence< sal_Bool >(),
356 0 : aAnnotOpt);
357 :
358 : // create subsection for Page settings
359 0 : vcl::PrinterOptionsHelper::UIControlOptions aPageSetOpt;
360 0 : aPageSetOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
361 :
362 0 : if (!bWeb)
363 : {
364 0 : m_aUIProperties[nIdx++].Value = setSubgroupControlOpt("pagesides", rtl::OUString(aLocalizedStrings.GetString(18)),
365 0 : rtl::OUString(), aPageSetOpt);
366 0 : uno::Sequence< rtl::OUString > aRLChoices( 3 );
367 0 : aRLChoices[0] = aLocalizedStrings.GetString( 19 );
368 0 : aRLChoices[1] = aLocalizedStrings.GetString( 20 );
369 0 : aRLChoices[2] = aLocalizedStrings.GetString( 21 );
370 0 : uno::Sequence< rtl::OUString > aRLHelp( 1 );
371 0 : aRLHelp[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintLeftRightPages:ListBox" ) );
372 : // create a choice option for all/left/right pages
373 : // 0 : all pages (left & right)
374 : // 1 : left pages
375 : // 2 : right pages
376 : OSL_ENSURE( rDefaultPrintData.IsPrintLeftPage() || rDefaultPrintData.IsPrintRightPage(),
377 : "unexpected value combination" );
378 0 : sal_Int16 nPagesChoice = 0;
379 0 : if (rDefaultPrintData.IsPrintLeftPage() && !rDefaultPrintData.IsPrintRightPage())
380 0 : nPagesChoice = 1;
381 0 : else if (!rDefaultPrintData.IsPrintLeftPage() && rDefaultPrintData.IsPrintRightPage())
382 0 : nPagesChoice = 2;
383 0 : m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt("brochureinclude",
384 : aLocalizedStrings.GetString(22),
385 : aRLHelp,
386 : "PrintLeftRightPages",
387 : aRLChoices,
388 0 : nPagesChoice);
389 : }
390 :
391 : // create a bool option for brochure
392 0 : bDefaultVal = rDefaultPrintData.IsPrintProspect();
393 0 : rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) );
394 0 : m_aUIProperties[ nIdx++ ].Value = setBoolControlOpt("brochure", aLocalizedStrings.GetString( 23 ),
395 : ".HelpID:vcl:PrintDialog:PrintProspect:CheckBox",
396 : aBrochurePropertyName,
397 : bDefaultVal,
398 0 : aPageSetOpt);
399 :
400 0 : if (bCTL)
401 : {
402 : // create a bool option for brochure RTL dependent on brochure
403 0 : uno::Sequence< rtl::OUString > aBRTLChoices( 2 );
404 0 : aBRTLChoices[0] = aLocalizedStrings.GetString( 24 );
405 0 : aBRTLChoices[1] = aLocalizedStrings.GetString( 25 );
406 0 : vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True );
407 0 : uno::Sequence< rtl::OUString > aBRTLHelpIds( 1 );
408 0 : aBRTLHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintProspectRTL:ListBox" ) );
409 0 : aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
410 : // RTL brochure choices
411 : // 0 : left-to-right
412 : // 1 : right-to-left
413 0 : const sal_Int16 nBRTLChoice = rDefaultPrintData.IsPrintProspectRTL() ? 1 : 0;
414 0 : m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt("scriptdirection",
415 : rtl::OUString(),
416 : aBRTLHelpIds,
417 : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ),
418 : aBRTLChoices,
419 : nBRTLChoice,
420 : uno::Sequence< sal_Bool >(),
421 0 : aBrochureRTLOpt);
422 : }
423 :
424 0 : assert(nIdx == nNumProps);
425 : }
426 :
427 :
428 0 : SwPrintUIOptions::~SwPrintUIOptions()
429 : {
430 0 : }
431 :
432 0 : bool SwPrintUIOptions::IsPrintLeftPages() const
433 : {
434 : // take care of different property names for the option.
435 : // for compatibility the old name should win (may still be used for PDF export or via Uno API)
436 :
437 : // 0: left and right pages
438 : // 1: left pages only
439 : // 2: right pages only
440 0 : sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
441 0 : bool bRes = nLRPages == 0 || nLRPages == 1;
442 0 : bRes = getBoolValue( "PrintLeftPages", bRes /* <- default value if property is not found */ );
443 0 : return bRes;
444 : }
445 :
446 0 : bool SwPrintUIOptions::IsPrintRightPages() const
447 : {
448 : // take care of different property names for the option.
449 : // for compatibility the old name should win (may still be used for PDF export or via Uno API)
450 :
451 0 : sal_Int64 nLRPages = getIntValue( "PrintLeftRightPages", 0 /* default: all */ );
452 0 : bool bRes = nLRPages == 0 || nLRPages == 2;
453 0 : bRes = getBoolValue( "PrintRightPages", bRes /* <- default value if property is not found */ );
454 0 : return bRes;
455 : }
456 :
457 0 : bool SwPrintUIOptions::IsPrintEmptyPages( bool bIsPDFExport ) const
458 : {
459 : // take care of different property names for the option.
460 :
461 : bool bRes = bIsPDFExport ?
462 0 : !getBoolValue( "IsSkipEmptyPages", sal_True ) :
463 0 : getBoolValue( "PrintEmptyPages", sal_True );
464 0 : return bRes;
465 : }
466 :
467 0 : bool SwPrintUIOptions::IsPrintTables() const
468 : {
469 : // take care of different property names currently in use for this option.
470 : // for compatibility the old name should win (may still be used for PDF export or via Uno API)
471 :
472 : // bool bRes = getBoolValue( "PrintTablesGraphicsAndDiagrams", sal_True );
473 : // bRes = getBoolValue( "PrintTables", bRes );
474 : // return bRes;
475 : // for now it was decided that tables should always be printed
476 0 : return true;
477 : }
478 :
479 0 : bool SwPrintUIOptions::IsPrintGraphics() const
480 : {
481 : // take care of different property names for the option.
482 : // for compatibility the old name should win (may still be used for PDF export or via Uno API)
483 :
484 0 : bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True );
485 0 : bRes = getBoolValue( "PrintGraphics", bRes );
486 0 : return bRes;
487 : }
488 :
489 0 : bool SwPrintUIOptions::IsPrintDrawings() const
490 : {
491 : // take care of different property names for the option.
492 : // for compatibility the old name should win (may still be used for PDF export or via Uno API)
493 :
494 0 : bool bRes = getBoolValue( "PrintPicturesAndObjects", sal_True );
495 0 : bRes = getBoolValue( "PrintDrawings", bRes );
496 0 : return bRes;
497 : }
498 :
499 0 : bool SwPrintUIOptions::processPropertiesAndCheckFormat( const uno::Sequence< beans::PropertyValue >& i_rNewProp )
500 : {
501 0 : bool bChanged = processProperties( i_rNewProp );
502 :
503 0 : uno::Reference< awt::XDevice > xRenderDevice;
504 0 : uno::Any aVal( getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) );
505 0 : aVal >>= xRenderDevice;
506 :
507 0 : OutputDevice* pOut = 0;
508 0 : if (xRenderDevice.is())
509 : {
510 0 : VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
511 0 : pOut = pDevice ? pDevice->GetOutputDevice() : 0;
512 : }
513 0 : bChanged = bChanged || (pOut != m_pLast);
514 0 : if( pOut )
515 0 : m_pLast = pOut;
516 :
517 0 : return bChanged;
518 : }
519 :
520 : //////////////////////////////////////////////////////////////////////
521 :
522 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|