1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <rtl/ustring.hxx>
25 #include "tools/errcode.hxx"
26 #include "tools/solar.h"
27 #include "vcl/dllapi.h"
28 #include "vcl/outdev.hxx"
29 #include "vcl/prntypes.hxx"
30 #include "vcl/jobset.hxx"
31 #include "vcl/gdimtf.hxx"
32 #include "tools/stream.hxx"
33 #include "tools/multisel.hxx"
35 #include "com/sun/star/beans/PropertyValue.hpp"
36 #include "com/sun/star/view/PrintableState.hpp"
38 #include <boost/shared_ptr.hpp>
39 #include <boost/unordered_map.hpp>
43 struct SalPrinterQueueInfo
;
49 class PrinterController
;
57 #define PAGEQUEUE_ALLPAGES 0xFFFF
59 enum PrinterSupport
{ SUPPORT_SET_ORIENTATION
, SUPPORT_SET_PAPERBIN
,
60 SUPPORT_SET_PAPERSIZE
, SUPPORT_SET_PAPER
,
61 SUPPORT_COPY
, SUPPORT_COLLATECOPY
,
62 SUPPORT_SETUPDIALOG
, SUPPORT_FAX
, SUPPORT_PDF
};
68 class VCL_DLLPUBLIC PrinterPage
72 sal_uInt16 mbNewJobSetup
;
76 PrinterPage() : mpMtf( new GDIMetaFile() ) {}
77 PrinterPage( GDIMetaFile
* pMtf
, sal_Bool bNewJobSetup
, const JobSetup
& rSetup
) :
78 mpMtf( pMtf
), maJobSetup( rSetup
), mbNewJobSetup( bNewJobSetup
) {}
79 ~PrinterPage() { delete mpMtf
; }
81 GDIMetaFile
* GetGDIMetaFile() const { return mpMtf
; }
82 const JobSetup
& GetJobSetup() const { return maJobSetup
; }
83 sal_Bool
IsNewJobSetup() const { return (mbNewJobSetup
!= 0); }
91 class VCL_DLLPUBLIC QueueInfo
96 OUString maPrinterName
;
105 QueueInfo( const QueueInfo
& rInfo
);
108 const OUString
& GetPrinterName() const { return maPrinterName
; }
109 const OUString
& GetDriver() const { return maDriver
; }
110 const OUString
& GetLocation() const { return maLocation
; }
111 const OUString
& GetComment() const { return maComment
; }
112 sal_uInt32
GetStatus() const { return mnStatus
; }
113 sal_uInt32
GetJobs() const { return mnJobs
; }
115 bool operator==( const QueueInfo
& rInfo
) const;
117 friend VCL_DLLPUBLIC SvStream
& operator>>( SvStream
& rIStream
, QueueInfo
& rInfo
);
118 friend VCL_DLLPUBLIC SvStream
& operator<<( SvStream
& rOStream
, const QueueInfo
& rInfo
);
121 // ------------------
122 // - PrinterOptions -
123 // ------------------
125 enum PrinterTransparencyMode
127 PRINTER_TRANSPARENCY_AUTO
= 0,
128 PRINTER_TRANSPARENCY_NONE
= 1
131 // -----------------------------------------------------------------------------
133 enum PrinterGradientMode
135 PRINTER_GRADIENT_STRIPES
= 0,
136 PRINTER_GRADIENT_COLOR
= 1
139 // -----------------------------------------------------------------------------
141 enum PrinterBitmapMode
143 PRINTER_BITMAP_OPTIMAL
= 0,
144 PRINTER_BITMAP_NORMAL
= 1,
145 PRINTER_BITMAP_RESOLUTION
= 2
148 // -----------------------------------------------------------------------------
150 class VCL_DLLPUBLIC PrinterOptions
154 sal_Bool mbReduceTransparency
;
155 PrinterTransparencyMode meReducedTransparencyMode
;
156 sal_Bool mbReduceGradients
;
157 PrinterGradientMode meReducedGradientsMode
;
158 sal_uInt16 mnReducedGradientStepCount
;
159 sal_Bool mbReduceBitmaps
;
160 PrinterBitmapMode meReducedBitmapMode
;
161 sal_uInt16 mnReducedBitmapResolution
;
162 sal_Bool mbReducedBitmapsIncludeTransparency
;
163 sal_Bool mbConvertToGreyscales
;
164 sal_Bool mbPDFAsStandardPrintJobFormat
;
171 sal_Bool
IsReduceTransparency() const { return mbReduceTransparency
; }
172 void SetReduceTransparency( sal_Bool bSet
) { mbReduceTransparency
= bSet
; }
174 PrinterTransparencyMode
GetReducedTransparencyMode() const { return meReducedTransparencyMode
; }
175 void SetReducedTransparencyMode( PrinterTransparencyMode eMode
) { meReducedTransparencyMode
= eMode
; }
177 sal_Bool
IsReduceGradients() const { return mbReduceGradients
; }
178 void SetReduceGradients( sal_Bool bSet
) { mbReduceGradients
= bSet
; }
180 PrinterGradientMode
GetReducedGradientMode() const { return meReducedGradientsMode
; }
181 void SetReducedGradientMode( PrinterGradientMode eMode
) { meReducedGradientsMode
= eMode
; }
183 sal_uInt16
GetReducedGradientStepCount() const { return mnReducedGradientStepCount
; }
184 void SetReducedGradientStepCount( sal_uInt16 nStepCount
) { mnReducedGradientStepCount
= nStepCount
; }
186 sal_Bool
IsReduceBitmaps() const { return mbReduceBitmaps
; }
187 void SetReduceBitmaps( sal_Bool bSet
) { mbReduceBitmaps
= bSet
; }
189 PrinterBitmapMode
GetReducedBitmapMode() const { return meReducedBitmapMode
; }
190 void SetReducedBitmapMode( PrinterBitmapMode eMode
) { meReducedBitmapMode
= eMode
; }
192 sal_uInt16
GetReducedBitmapResolution() const { return mnReducedBitmapResolution
; }
193 void SetReducedBitmapResolution( sal_uInt16 nResolution
) { mnReducedBitmapResolution
= nResolution
; }
195 sal_Bool
IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency
; }
196 void SetReducedBitmapIncludesTransparency( sal_Bool bSet
) { mbReducedBitmapsIncludeTransparency
= bSet
; }
198 sal_Bool
IsConvertToGreyscales() const { return mbConvertToGreyscales
; }
199 void SetConvertToGreyscales( sal_Bool bSet
) { mbConvertToGreyscales
= bSet
; }
201 sal_Bool
IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat
; }
202 void SetPDFAsStandardPrintJobFormat( sal_Bool bSet
) { mbPDFAsStandardPrintJobFormat
= bSet
; }
204 // read printer options from configuration, parameter decides whether the set for
205 // print "to printer" or "to file" should be read.
206 // returns true if config was read, false if an error occurred
207 bool ReadFromConfig( bool bFile
);
214 class VCL_DLLPUBLIC Printer
: public OutputDevice
216 friend class OutputDevice
;
219 SalInfoPrinter
* mpInfoPrinter
;
220 SalPrinter
* mpPrinter
;
221 SalGraphics
* mpJobGraphics
;
224 VirtualDevice
* mpDisplayDev
;
225 PrinterOptions
* mpPrinterOptions
;
226 OUString maPrinterName
;
228 OUString maPrintFile
;
234 sal_uInt16 mnCurPage
;
235 sal_uInt16 mnCurPrintPage
;
236 sal_uInt16 mnPageQueueSize
;
237 sal_uInt16 mnCopyCount
;
238 sal_Bool mbDefPrinter
;
240 sal_Bool mbJobActive
;
241 sal_Bool mbCollateCopy
;
242 sal_Bool mbPrintFile
;
243 sal_Bool mbInPrintPage
;
244 sal_Bool mbNewJobSetup
;
245 sal_Bool mbIsQueuePrinter
;
246 sal_Bool mbUserSetupCompleted
;
247 sal_Bool mbUserSetupResult
;
250 SAL_DLLPRIVATE
void ImplInitData();
251 SAL_DLLPRIVATE
void ImplInit( SalPrinterQueueInfo
* pInfo
);
252 SAL_DLLPRIVATE
void ImplInitDisplay( const Window
* pWindow
);
253 SAL_DLLPRIVATE
static SalPrinterQueueInfo
* ImplGetQueueInfo( const OUString
& rPrinterName
,
254 const OUString
* pDriver
);
255 SAL_DLLPRIVATE
void ImplUpdatePageData();
256 SAL_DLLPRIVATE
void ImplUpdateFontList();
257 SAL_DLLPRIVATE
void ImplFindPaperFormatForUserSize( JobSetup
&, bool bMatchNearest
);
259 SAL_DLLPRIVATE
bool StartJob( const OUString
& rJobName
, boost::shared_ptr
<vcl::PrinterController
>& );
261 static SAL_DLLPRIVATE sal_uLong
ImplSalPrinterErrorCodeToVCL( sal_uLong nError
);
264 SAL_DLLPRIVATE sal_Bool
EndJob();
265 SAL_DLLPRIVATE
Printer( const Printer
& rPrinter
);
266 SAL_DLLPRIVATE Printer
& operator =( const Printer
& rPrinter
);
268 SAL_DLLPRIVATE
void ImplStartPage();
269 SAL_DLLPRIVATE
void ImplEndPage();
271 void DrawGradientEx( OutputDevice
* pOut
, const Rectangle
& rRect
, const Gradient
& rGradient
);
275 void SetSelfAsQueuePrinter( sal_Bool bQueuePrinter
) { mbIsQueuePrinter
= bQueuePrinter
; }
276 sal_Bool
IsQueuePrinter() const { return mbIsQueuePrinter
; }
280 Printer( const JobSetup
& rJobSetup
);
281 Printer( const QueueInfo
& rQueueInfo
);
282 Printer( const OUString
& rPrinterName
);
285 static const std::vector
< OUString
>& GetPrinterQueues();
286 static const QueueInfo
* GetQueueInfo( const OUString
& rPrinterName
, bool bStatusUpdate
);
287 static OUString
GetDefaultPrinterName();
289 virtual void Error();
291 const OUString
& GetName() const { return maPrinterName
; }
292 const OUString
& GetDriverName() const { return maDriver
; }
293 sal_Bool
IsDefPrinter() const { return mbDefPrinter
; }
294 sal_Bool
IsDisplayPrinter() const { return mpDisplayDev
!= NULL
; }
295 sal_Bool
IsValid() const { return !IsDisplayPrinter(); }
297 sal_uLong
GetCapabilities( sal_uInt16 nType
) const;
298 sal_Bool
HasSupport( PrinterSupport eFeature
) const;
300 sal_Bool
SetJobSetup( const JobSetup
& rSetup
);
301 const JobSetup
& GetJobSetup() const { return maJobSetup
; }
302 void SetJobValue( const OUString
& rKey
, const OUString
& rValue
) { maJobSetup
.SetValue( rKey
, rValue
); }
304 sal_Bool
Setup( Window
* pWindow
= NULL
);
305 sal_Bool
SetPrinterProps( const Printer
* pPrinter
);
307 // SetPrinterOptions is used internally only now
308 // in earlier times it was used only to set the options loaded directly from the configuration
309 // in SfxPrinter::InitJob, this is now handled internally
310 // should the need arise to set the printer options outside vcl, also a method would have to be devised
311 // to not override these again internally
312 SAL_DLLPRIVATE
void SetPrinterOptions( const PrinterOptions
& rOptions
);
313 const PrinterOptions
& GetPrinterOptions() const { return( *mpPrinterOptions
); }
315 sal_Bool
SetOrientation( Orientation eOrient
);
316 Orientation
GetOrientation() const;
317 sal_Bool
SetDuplexMode( DuplexMode
);
318 // returns the angle that a landscape page will be turned counterclockwise
319 // wrt to portrait. The return value may be only valid for
321 int GetLandscapeAngle() const;
322 sal_Bool
SetPaperBin( sal_uInt16 nPaperBin
);
323 sal_uInt16
GetPaperBin() const;
324 sal_Bool
SetPaper( Paper ePaper
);
325 sal_Bool
SetPaperSizeUser( const Size
& rSize
);
326 sal_Bool
SetPaperSizeUser( const Size
& rSize
, bool bMatchNearest
);
327 Paper
GetPaper() const;
328 static OUString
GetPaperName( Paper ePaper
);
329 // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
330 OUString
GetPaperName( bool i_bPaperUser
= true ) const;
332 // returns number of available paper formats
333 int GetPaperInfoCount() const;
334 // returns info about paper format nPaper
335 const PaperInfo
& GetPaperInfo( int nPaper
) const;
336 sal_uInt16
GetPaperBinCount() const;
337 OUString
GetPaperBinName( sal_uInt16 nPaperBin
) const;
339 const Size
& GetPaperSizePixel() const { return maPaperSize
; }
340 Size
GetPaperSize() const { return PixelToLogic( maPaperSize
); }
341 const Point
& GetPageOffsetPixel() const { return maPageOffset
; }
342 Point
GetPageOffset() const { return PixelToLogic( maPageOffset
); }
344 sal_Bool
SetCopyCount( sal_uInt16 nCopy
, sal_Bool bCollate
= sal_False
);
345 sal_uInt16
GetCopyCount() const { return mnCopyCount
; }
346 sal_Bool
IsCollateCopy() const { return mbCollateCopy
; }
348 sal_Bool
IsPrinting() const { return mbPrinting
; }
350 const OUString
& GetCurJobName() const { return maJobName
; }
351 sal_uInt16
GetCurPage() const { return mnCurPage
; }
352 sal_Bool
IsJobActive() const { return mbJobActive
; }
354 sal_uLong
GetError() const { return ERRCODE_TOERROR(mnError
); }
355 sal_uLong
GetErrorCode() const { return mnError
; }
357 void SetErrorHdl( const Link
& rLink
) { maErrorHdl
= rLink
; }
358 const Link
& GetErrorHdl() const { return maErrorHdl
; }
360 /** checks the printer list and updates it necessary
362 * sends a DataChanged event of type DATACHANGED_PRINTER
363 * if the printer list changed
365 static void updatePrinters();
367 /** execute a print job
369 starts a print job asynchronously (that is will return
372 static void PrintJob( const boost::shared_ptr
<vcl::PrinterController
>& i_pController
,
373 const JobSetup
& i_rInitSetup
376 // implementation detail of PrintJob being asynchronous
377 // not exported, not usable outside vcl
378 static void SAL_DLLPRIVATE
ImplPrintJob( const boost::shared_ptr
<vcl::PrinterController
>& i_pController
,
379 const JobSetup
& i_rInitSetup
385 class ImplPrinterControllerData
;
387 class VCL_DLLPUBLIC PrinterController
389 ImplPrinterControllerData
* mpImplData
;
391 PrinterController( const boost::shared_ptr
<Printer
>& );
394 { LRTB
, TBLR
, TBRL
, RLTB
};
395 struct MultiPageSetup
397 // all metrics in 100th mm
406 long nHorizontalSpacing
;
407 long nVerticalSpacing
;
409 PrinterController::NupOrderType nOrder
;
412 : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 )
413 , nLeftMargin( 0 ), nTopMargin( 0 )
414 , nRightMargin( 0 ), nBottomMargin( 0 )
415 , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 )
416 , bDrawBorder( false )
424 Size aSize
; // in 100th mm
425 bool bFullPaper
; // full paper, not only imageable area is printed
427 PageSize( const Size
& i_rSize
= Size( 21000, 29700 ),
428 bool i_bFullPaper
= false
429 ) : aSize( i_rSize
), bFullPaper( i_bFullPaper
) {}
432 virtual ~PrinterController();
434 const boost::shared_ptr
<Printer
>& getPrinter() const;
435 /* for implementations: get current job properties as changed by e.g. print dialog
436 this gets the current set of properties initially told to Printer::PrintJob
438 For convenience a second sequence will be merged in to get a combined sequence.
439 In case of duplicate property names, the value of i_MergeList wins.
441 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>
442 getJobProperties( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& i_rMergeList
) const;
444 /* get the PropertyValue of a Property
446 com::sun::star::beans::PropertyValue
* getValue( const OUString
& i_rPropertyName
);
447 const com::sun::star::beans::PropertyValue
* getValue( const OUString
& i_rPropertyName
) const;
448 /* get a bool property
449 in case the property is unknown or not convertible to bool, i_bFallback is returned
451 sal_Bool
getBoolProperty( const OUString
& i_rPropertyName
, sal_Bool i_bFallback
) const;
452 /* get an int property
453 in case the property is unknown or not convertible to bool, i_nFallback is returned
455 sal_Int32
getIntProperty( const OUString
& i_rPropertyName
, sal_Int32 i_nFallback
) const;
457 /* set a property value - can also be used to add another UI property
459 void setValue( const OUString
& i_rPropertyName
, const com::sun::star::uno::Any
& i_rValue
);
460 void setValue( const com::sun::star::beans::PropertyValue
& i_rValue
);
462 /* return the currently active UI options. These are the same that were passed to setUIOptions.
464 const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& getUIOptions() const;
465 /* set possible UI options. should only be done once before passing the PrinterListener
468 void setUIOptions( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& );
469 /* enable/disable an option; this can be used to implement dialog logic.
471 bool isUIOptionEnabled( const OUString
& rPropName
) const;
472 bool isUIChoiceEnabled( const OUString
& rPropName
, sal_Int32 nChoice
) const;
473 /* returns the property name rPropName depends on or an empty string
474 if no dependency exists.
476 OUString
getDependency( const OUString
& rPropName
) const;
477 /* makeEnabled will chage the property rPropName depends on to the value
478 that makes rPropName enabled. If the dependency itself is also disabled,
479 no action will be performed.
481 returns the property name rPropName depends on or an empty string
482 if no change was made.
484 OUString
makeEnabled( const OUString
& rPropName
);
486 virtual int getPageCount() const = 0; // must be overloaded by the app
487 /* get the page parameters, namely the jobsetup that should be active for the page
488 (describing among others the physical page size) and the "page size". In writer
489 case this would probably be the same as the JobSetup since writer sets the page size
490 draw/impress for example print their page on the paper set on the printer,
491 possibly adjusting the page size to fit. That means the page size can be different from
494 // must be overloaded by the app, return page size in 1/100th mm
495 virtual com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> getPageParameters( int i_nPage
) const = 0;
496 virtual void printPage( int i_nPage
) const = 0; // must be overloaded by the app
497 virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts
498 virtual void jobFinished( com::sun::star::view::PrintableState
);
500 com::sun::star::view::PrintableState
getJobState() const;
504 bool isShowDialogs() const;
505 bool isDirectPrint() const;
507 // implementation details, not usable outside vcl
508 // don't use outside vcl. Some of these are exported for
509 // the benefit of vcl's plugins.
510 // Still: DO NOT USE OUTSIDE VCL
511 VCL_PLUGIN_PUBLIC
int getFilteredPageCount();
512 SAL_DLLPRIVATE PageSize
getPageFile( int i_inUnfilteredPage
, GDIMetaFile
& rMtf
, bool i_bMayUseCache
= false );
513 VCL_PLUGIN_PUBLIC PageSize
getFilteredPageFile( int i_nFilteredPage
, GDIMetaFile
& o_rMtf
, bool i_bMayUseCache
= false );
514 VCL_PLUGIN_PUBLIC
void printFilteredPage( int i_nPage
);
515 SAL_DLLPRIVATE
void setPrinter( const boost::shared_ptr
<Printer
>& );
516 SAL_DLLPRIVATE
void setOptionChangeHdl( const Link
& );
517 VCL_PLUGIN_PUBLIC
void createProgressDialog();
518 VCL_PLUGIN_PUBLIC
bool isProgressCanceled() const;
519 SAL_DLLPRIVATE
void setMultipage( const MultiPageSetup
& );
520 SAL_DLLPRIVATE
const MultiPageSetup
& getMultipage() const;
521 VCL_PLUGIN_PUBLIC
void setLastPage( sal_Bool i_bLastPage
);
522 SAL_DLLPRIVATE
void setReversePrint( sal_Bool i_bReverse
);
523 SAL_DLLPRIVATE
bool getReversePrint() const;
524 SAL_DLLPRIVATE
void setPapersizeFromSetup( sal_Bool i_bPapersizeFromSetup
);
525 SAL_DLLPRIVATE
bool getPapersizeFromSetup() const;
526 SAL_DLLPRIVATE
void pushPropertiesToPrinter();
527 SAL_DLLPRIVATE
void resetPaperToLastConfigured();
528 VCL_PLUGIN_PUBLIC
void setJobState( com::sun::star::view::PrintableState
);
529 SAL_DLLPRIVATE
bool setupPrinter( Window
* i_pDlgParent
);
531 SAL_DLLPRIVATE
int getPageCountProtected() const;
532 SAL_DLLPRIVATE
com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> getPageParametersProtected( int i_nPage
) const;
534 SAL_DLLPRIVATE sal_uLong
removeTransparencies( GDIMetaFile
& i_rIn
, GDIMetaFile
& o_rOut
);
535 SAL_DLLPRIVATE
void resetPrinterOptions( bool i_bFileOutput
);
538 class VCL_DLLPUBLIC PrinterOptionsHelper
541 boost::unordered_map
< OUString
, com::sun::star::uno::Any
, OUStringHash
> m_aPropertyMap
;
542 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> m_aUIProperties
;
545 PrinterOptionsHelper() {} // create without ui properties
546 PrinterOptionsHelper( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& i_rUIProperties
)
547 : m_aUIProperties( i_rUIProperties
)
549 ~PrinterOptionsHelper()
552 /* process a new set of properties
553 * merges changed properties and returns "true" if any occurred
554 * if the optional output set is not NULL then the names of the changed properties are returned
556 bool processProperties( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& i_rNewProp
,
557 std::set
< OUString
>* o_pChangeProp
= NULL
);
558 /* append to a sequence of property values the ui property sequence passed at creation
559 * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property
562 void appendPrintUIOptions( com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& io_rProps
) const;
564 // returns an empty Any for not existing properties
565 com::sun::star::uno::Any
getValue( const OUString
& i_rPropertyName
) const;
567 sal_Bool
getBoolValue( const OUString
& i_rPropertyName
, sal_Bool i_bDefault
= sal_False
) const;
568 // convenience for fixed strings
569 sal_Bool
getBoolValue( const char* i_pPropName
, sal_Bool i_bDefault
= sal_False
) const
570 { return getBoolValue( OUString::createFromAscii( i_pPropName
), i_bDefault
); }
572 sal_Int64
getIntValue( const OUString
& i_rPropertyName
, sal_Int64 i_nDefault
= 0 ) const;
573 // convenience for fixed strings
574 sal_Int64
getIntValue( const char* i_pPropName
, sal_Int64 i_nDefault
= 0 ) const
575 { return getIntValue( OUString::createFromAscii( i_pPropName
), i_nDefault
); }
577 OUString
getStringValue( const OUString
& i_rPropertyName
, const OUString
& i_rDefault
= OUString() ) const;
578 // convenience for fixed strings
579 OUString
getStringValue( const char* i_pPropName
, const OUString
& i_rDefault
= OUString() ) const
580 { return getStringValue( OUString::createFromAscii( i_pPropName
), i_rDefault
); }
582 // helper functions for user to create a single control
583 struct UIControlOptions
585 OUString maDependsOnName
;
586 sal_Int32 mnDependsOnEntry
;
587 sal_Bool mbAttachToDependency
;
588 OUString maGroupHint
;
589 sal_Bool mbInternalOnly
;
591 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> maAddProps
;
593 UIControlOptions( const OUString
& i_rDependsOnName
= OUString(),
594 sal_Int32 i_nDependsOnEntry
= -1,
595 sal_Bool i_bAttachToDependency
= sal_False
,
596 const OUString
& i_rGroupHint
= OUString(),
597 sal_Bool i_bInternalOnly
= sal_False
,
598 sal_Bool i_bEnabled
= sal_True
600 : maDependsOnName( i_rDependsOnName
)
601 , mnDependsOnEntry( i_nDependsOnEntry
)
602 , mbAttachToDependency( i_bAttachToDependency
)
603 , maGroupHint( i_rGroupHint
)
604 , mbInternalOnly( i_bInternalOnly
)
605 , mbEnabled( i_bEnabled
) {}
608 // note: in the following helper functions HelpIds are expected as an OUString
609 // the normal HelpId form is OString (byte string instead of UTF16 string)
610 // this is because the whole interface is base on UNO properties; in fact the structures
611 // are passed over UNO interfaces. UNO does not know a byte string, hence the string is
612 // transported via UTF16 strings.
614 // Show general control
615 static com::sun::star::uno::Any
setUIControlOpt( const com::sun::star::uno::Sequence
< OUString
>& i_rIDs
,
616 const OUString
& i_rTitle
,
617 const com::sun::star::uno::Sequence
< OUString
>& i_rHelpId
,
618 const OUString
& i_rType
,
619 const com::sun::star::beans::PropertyValue
* i_pValue
= NULL
,
620 const UIControlOptions
& i_rControlOptions
= UIControlOptions()
623 // Show and set the title of a TagPage of id i_rID
624 static com::sun::star::uno::Any
setGroupControlOpt(const OUString
& i_rID
,
625 const OUString
& i_rTitle
,
626 const OUString
& i_rHelpId
);
628 // Show and set the label of a VclFrame of id i_rID
629 static com::sun::star::uno::Any
setSubgroupControlOpt(const OUString
& i_rID
,
630 const OUString
& i_rTitle
,
631 const OUString
& i_rHelpId
,
632 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
634 // Show a bool option as a checkbox
635 static com::sun::star::uno::Any
setBoolControlOpt(const OUString
& i_rID
,
636 const OUString
& i_rTitle
,
637 const OUString
& i_rHelpId
,
638 const OUString
& i_rProperty
,
640 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
642 // Show a set of choices in a list box
643 static com::sun::star::uno::Any
setChoiceListControlOpt(const OUString
& i_rID
,
644 const OUString
& i_rTitle
,
645 const com::sun::star::uno::Sequence
< OUString
>& i_rHelpId
,
646 const OUString
& i_rProperty
,
647 const com::sun::star::uno::Sequence
< OUString
>& i_rChoices
,
649 const com::sun::star::uno::Sequence
< sal_Bool
>& i_rDisabledChoices
= com::sun::star::uno::Sequence
< sal_Bool
>(),
650 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
652 // show a set of choices as radio buttons
653 static com::sun::star::uno::Any
setChoiceRadiosControlOpt(const com::sun::star::uno::Sequence
< OUString
>& i_rIDs
,
654 const OUString
& i_rTitle
,
655 const com::sun::star::uno::Sequence
< OUString
>& i_rHelpId
,
656 const OUString
& i_rProperty
,
657 const com::sun::star::uno::Sequence
< OUString
>& i_rChoices
,
659 const com::sun::star::uno::Sequence
< sal_Bool
>& i_rDisabledChoices
= com::sun::star::uno::Sequence
< sal_Bool
>(),
660 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
663 // show an integer range (e.g. a spin field)
664 // note: max value < min value means do not apply min/max values
665 static com::sun::star::uno::Any
setRangeControlOpt(const OUString
& i_rID
,
666 const OUString
& i_rTitle
,
667 const OUString
& i_rHelpId
,
668 const OUString
& i_rProperty
,
670 sal_Int32 i_nMinValue
= -1,
671 sal_Int32 i_nMaxValue
= -2,
672 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
674 // show a string field
675 // note: max value < min value means do not apply min/max values
676 static com::sun::star::uno::Any
setEditControlOpt(const OUString
& i_rID
,
677 const OUString
& i_rTitle
,
678 const OUString
& i_rHelpId
,
679 const OUString
& i_rProperty
,
680 const OUString
& i_rValue
,
681 const UIControlOptions
& i_rControlOptions
= UIControlOptions());
687 #endif // _SV_PRINT_HXX
689 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */