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