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