From 9d58db011e379ce337096be6e4d2b7978e9f2f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Timm?= Date: Fri, 26 Sep 2008 07:04:59 +0000 Subject: [PATCH 001/283] Create DEV300_m32 milestone tag From 91d8ce3ea93f43360addbf52701a46d091e152c8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 1 Oct 2008 18:22:22 +0000 Subject: [PATCH 002/283] #i92516# migrate CWS printerpullpages to svn --- vcl/aqua/inc/aquaprintview.h | 9 +- vcl/aqua/inc/salprn.h | 18 +- vcl/aqua/source/gdi/aquaprintview.mm | 10 +- vcl/aqua/source/gdi/salprn.cxx | 133 ++++----- vcl/inc/vcl/print.h | 13 +- vcl/inc/vcl/print.hxx | 92 +++++- vcl/inc/vcl/prndlg.hxx | 125 +++++++- vcl/inc/vcl/salprn.hxx | 6 +- vcl/inc/vcl/svdata.hxx | 3 +- vcl/inc/vcl/svids.hrc | 43 ++- vcl/prj/d.lst | 1 - vcl/source/app/salvtables.cxx | 2 +- vcl/source/app/svdata.cxx | 11 +- vcl/source/gdi/impprn.cxx | 4 +- vcl/source/gdi/makefile.mk | 4 +- vcl/source/gdi/print.cxx | 4 +- vcl/source/gdi/print3.cxx | 408 +++++++++++++++++++++++++++ vcl/source/src/makefile.mk | 5 +- vcl/source/src/print.src | 247 ++++++++++++++++ vcl/source/src/stdtext.src | 7 +- vcl/source/window/makefile.mk | 3 +- vcl/source/window/printdlg.cxx | 405 ++++++++++++++++++++++++++ 22 files changed, 1419 insertions(+), 134 deletions(-) create mode 100644 vcl/source/gdi/print3.cxx create mode 100644 vcl/source/src/print.src create mode 100644 vcl/source/window/printdlg.cxx diff --git a/vcl/aqua/inc/aquaprintview.h b/vcl/aqua/inc/aquaprintview.h index c5ce20c17425..f879936d1435 100755 --- a/vcl/aqua/inc/aquaprintview.h +++ b/vcl/aqua/inc/aquaprintview.h @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: aquaprintview.h,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.114.1 $ * * This file is part of OpenOffice.org. * @@ -37,13 +37,14 @@ class ImplQPrinter; class AquaSalInfoPrinter; +namespace vcl { class PrinterListener; } @interface AquaPrintView : NSView { - ImplQPrinter* mpQPrinter; - AquaSalInfoPrinter* mpInfoPrinter; + vcl::PrinterListener* mpListener; + AquaSalInfoPrinter* mpInfoPrinter; } --(id)initWithQPrinter: (ImplQPrinter*)pPrinter withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter; +-(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter; -(MacOSBOOL)knowsPageRange: (NSRangePointer)range; -(NSRect)rectForPage: (int)page; -(NSPoint)locationOfPrintRect: (NSRect)aRect; diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index ec08261e8321..8bfa8ac98cae 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salprn.h,v $ - * $Revision: 1.12 $ + * $Revision: 1.12.56.1 $ * * This file is part of OpenOffice.org. * @@ -104,10 +104,10 @@ class AquaSalInfoPrinter : public SalInfoPrinter // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter // and concentrate the real work in one class // implement pull model print system - BOOL StartJob( const String* pFileName, - const String& rAppName, - ImplJobSetup* pSetupData, - ImplQPrinter* pQPrinter, + BOOL StartJob( const String* i_pFileName, + const String& i_rAppName, + ImplJobSetup* i_pSetupData, + vcl::PrinterListener& i_rListener, bool bIsQuickJob ); BOOL EndJob(); BOOL AbortJob(); @@ -142,10 +142,10 @@ class AquaSalPrinter : public SalPrinter ULONG i_nCopies, BOOL i_bCollate, ImplJobSetup* i_pSetupData ); // implement pull model print system - virtual BOOL StartJob( const String* pFileName, - const String& rAppName, - ImplJobSetup* pSetupData, - ImplQPrinter* pQPrinter ); + virtual BOOL StartJob( const String* i_pFileName, + const String& i_rAppName, + ImplJobSetup* i_pSetupData, + vcl::PrinterListener& i_rListener ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/aqua/source/gdi/aquaprintview.mm b/vcl/aqua/source/gdi/aquaprintview.mm index 6099fbaed741..79efb9c80941 100755 --- a/vcl/aqua/source/gdi/aquaprintview.mm +++ b/vcl/aqua/source/gdi/aquaprintview.mm @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: aquaprintview.mm,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.56.1 $ * * This file is part of OpenOffice.org. * @@ -33,15 +33,15 @@ #include "aquaprintview.h" #include "salprn.h" -#include "vcl/impprn.hxx" +#include "vcl/print.hxx" @implementation AquaPrintView --(id)initWithQPrinter: (ImplQPrinter*)pPrinter withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter +-(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter { NSRect aRect = { { 0, 0 }, [pInfoPrinter->getPrintInfo() paperSize] }; if( (self = [super initWithFrame: aRect]) != nil ) { - mpQPrinter = pPrinter; + mpListener = pListener; mpInfoPrinter = pInfoPrinter; } return self; @@ -76,6 +76,6 @@ int nPage = (int)(aPaperSize.width * rect.origin.y + rect.origin.x); // page count is 1 based - mpQPrinter->PrintPage( nPage-1 + mpInfoPrinter->getCurPageRangeStart() ); + mpListener->printFilteredPage( nPage-1 ); } @end diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 0bbc190de546..09227c549874 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salprn.cxx,v $ - * $Revision: 1.16 $ + * $Revision: 1.16.56.2 $ * * This file is part of OpenOffice.org. * @@ -125,8 +125,8 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const if( mePageOrientation == ORIENTATION_PORTRAIT ) { double dX = 0, dY = aPaperSize.height; - dX += [mpPrintInfo leftMargin]; - dY -= [mpPrintInfo topMargin]; + // dX += [mpPrintInfo leftMargin]; + // dY -= [mpPrintInfo topMargin]; CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY ); CGContextScaleCTM( i_rContext, 0.1, -0.1 ); } @@ -134,8 +134,8 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const { CGContextRotateCTM( i_rContext, M_PI/2 ); double dX = aPaperSize.height, dY = -aPaperSize.width; - dY += [mpPrintInfo topMargin]; - dX -= [mpPrintInfo rightMargin]; + // dY += [mpPrintInfo topMargin]; + // dX -= [mpPrintInfo rightMargin]; CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX ); CGContextScaleCTM( i_rContext, -0.1, 0.1 ); @@ -447,77 +447,68 @@ void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*, } } -BOOL AquaSalInfoPrinter::StartJob( const String* pFileName, - const String& rAppName, - ImplJobSetup* pSetupData, - ImplQPrinter* pQPrinter, +BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, + const String& i_rAppName, + ImplJobSetup* i_pSetupData, + vcl::PrinterListener& i_rListener, bool bIsQuickJob ) { if( mbJob ) return FALSE; BOOL bSuccess = FALSE; - std::vector aPaperRanges; - if( ! pQPrinter->GetPaperRanges( aPaperRanges, true ) ) - return FALSE; - size_t nRanges = aPaperRanges.size(); + // FIXME: make paper ranges work again + mnCurPageRangeStart = 1; + mnCurPageRangeCount = i_rListener.getPageCount(); + AquaSalInstance* pInst = GetSalData()->mpFirstInstance; - for( ULONG nCurRange = 0; nCurRange < nRanges-1; nCurRange++ ) + mnStartPageOffsetX = mnStartPageOffsetY = 0; + + // update job data + if( i_pSetupData ) + SetData( ~0, i_pSetupData ); + + // create view + NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this]; + + NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; + + // set filename + if( i_pFileName ) { - mnStartPageOffsetX = mnStartPageOffsetY = 0; - - // update job data - ImplJobSetup* pSetup = pQPrinter->GetPageSetup( aPaperRanges[ nCurRange ] ); - if( pSetup ) - SetData( ~0, pSetup ); - DBG_ASSERT( pSetup, "no job setup for range" ); - - mnCurPageRangeStart = aPaperRanges[nCurRange]; - mnCurPageRangeCount = aPaperRanges[nCurRange+1] - aPaperRanges[nCurRange]; - // create view - NSView* pPrintView = [[AquaPrintView alloc] initWithQPrinter: pQPrinter withInfoPrinter: this]; - - NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; - - // set filename - if( pFileName ) - { - [mpPrintInfo setJobDisposition: NSPrintSaveJob]; - NSString* pPath = CreateNSString( *pFileName ); - [pPrintDict setObject: pPath forKey: NSPrintSavePath]; - [pPath release]; - - // in this case we can only deliver the print job in one file - mnCurPageRangeStart = 0; - mnCurPageRangeCount = aPaperRanges.back(); - nCurRange = nRanges; - } - - [pPrintDict setObject: [[NSNumber numberWithInt: (int)pQPrinter->GetCopyCount()] autorelease] forKey: NSPrintCopies]; - [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; - [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; - [pPrintDict setObject: [[NSNumber numberWithInt: (int)mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; - - - // create print operation - NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; - - if( pPrintOperation ) - { - bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); - [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; - // [pPrintOperation setShowsProgressPanel: NO]; - bSuccess = TRUE; - mbJob = true; - pInst->startedPrintJob(); - [pPrintOperation runOperation]; - pInst->endedPrintJob(); - mbJob = false; - } + [mpPrintInfo setJobDisposition: NSPrintSaveJob]; + NSString* pPath = CreateNSString( *i_pFileName ); + [pPrintDict setObject: pPath forKey: NSPrintSavePath]; + [pPath release]; } + // FIXME copies + // [pPrintDict setObject: [[NSNumber numberWithInt: (int)pQPrinter->GetCopyCount()] autorelease] forKey: NSPrintCopies]; + [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; + [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; + [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; + + + // create print operation + NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; + + if( pPrintOperation ) + { + bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); + [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; + [pPrintOperation setShowsProgressPanel: bShowPanel ? YES : NO]; + bSuccess = TRUE; + mbJob = true; + pInst->startedPrintJob(); + [pPrintOperation runOperation]; + pInst->endedPrintJob(); + mbJob = false; + } + + mnCurPageRangeStart = mnCurPageRangeCount = 0; + return bSuccess; } @@ -583,22 +574,22 @@ AquaSalPrinter::~AquaSalPrinter() // ----------------------------------------------------------------------- -BOOL AquaSalPrinter::StartJob( const String* pFileName, - const String& rAppName, - ImplJobSetup* pSetupData, - ImplQPrinter* pQPrinter ) +BOOL AquaSalPrinter::StartJob( const String* i_pFileName, + const String& i_rAppName, + ImplJobSetup* i_pSetupData, + vcl::PrinterListener& i_rListener ) { bool bIsQuickJob = false; std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator quick_it = - pSetupData->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ); + i_pSetupData->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ); - if( quick_it != pSetupData->maValueMap.end() ) + if( quick_it != i_pSetupData->maValueMap.end() ) { if( quick_it->second.equalsIgnoreAsciiCaseAscii( "true" ) ) bIsQuickJob = true; } - return mpInfoPrinter->StartJob( pFileName, rAppName, pSetupData, pQPrinter, bIsQuickJob ); + return mpInfoPrinter->StartJob( i_pFileName, i_rAppName, i_pSetupData, i_rListener, bIsQuickJob ); } // ----------------------------------------------------------------------- diff --git a/vcl/inc/vcl/print.h b/vcl/inc/vcl/print.h index 51cbb5dee0cf..bc74b6441f28 100644 --- a/vcl/inc/vcl/print.h +++ b/vcl/inc/vcl/print.h @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: print.h,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.114.2 $ * * This file is part of OpenOffice.org. * @@ -31,15 +31,18 @@ #ifndef _SV_PRINT_H #define _SV_PRINT_H -#include -#include -#include +#include "vcl/sv.h" +#include "vcl/dllapi.h" #include #include struct SalPrinterQueueInfo; class QueueInfo; +class JobSetup; + +namespace vcl +{ class PrinterListener; } // ------------------------ // - private printer data - @@ -87,5 +90,7 @@ public: // -------------- void ImplDeletePrnQueueList(); +void SAL_DLLPRIVATE ImplUpdateJobSetupPaper( JobSetup& rJobSetup ); + #endif // _SV_PRINT_H diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index c6a4a6c1adf9..e6199437ca4a 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: print.hxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.114.5 $ * * This file is part of OpenOffice.org. * @@ -31,14 +31,19 @@ #ifndef _SV_PRINT_HXX #define _SV_PRINT_HXX -#include -#include -#include -#include -#include -#include -#include -#include +#include "tools/errcode.hxx" +#include "vcl/sv.h" +#include "vcl/dllapi.h" +#include "vcl/outdev.hxx" +#include "vcl/prntypes.hxx" +#include "vcl/jobset.hxx" +#include "vcl/gdimtf.hxx" +#include "tools/stream.hxx" +#include "tools/multisel.hxx" + +#include "com/sun/star/beans/XPropertySet.hpp" + +#include struct SalPrinterInfoQueue; class SalInfoPrinter; @@ -47,12 +52,12 @@ class SalPrinter; class VirtualDevice; class Window; class ImplQPrinter; -class RmPrinter; struct ImplPrivatePrinterData; -namespace com { namespace sun { namespace star { namespace uno { - class Any; -} } } } +namespace vcl { + class PrinterListener; + class PrintDialog; +} // ----------------- // - Printer-Types - @@ -264,6 +269,11 @@ private: SAL_DLLPRIVATE void ImplUpdateFontList(); SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& ); DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); + + SAL_DLLPRIVATE bool StartJob( const XubString& rJobName, boost::shared_ptr& ); + + static SAL_DLLPRIVATE ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError ); + public: SAL_DLLPRIVATE void ImplEndPrint(); SAL_DLLPRIVATE void ImplUpdateQuickStatus(); @@ -421,6 +431,62 @@ public: * if the printer list changed */ static void updatePrinters(); + + /** execute a print job + + starts a print job asynchronously (that is will return + + */ + static void PrintJob( const boost::shared_ptr& i_pListener, + const JobSetup& i_rInitSetup, + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions + ); + + // implementation detail of PrintJob being asynchronous + // not exported, not usable outside vcl + static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr& i_pListener, + const JobSetup& i_rInitSetup, + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions + ); }; +namespace vcl +{ +class ImplPrinterListenerData; + +class VCL_DLLPUBLIC PrinterListener +{ + ImplPrinterListenerData* mpImplData; +public: + PrinterListener(); + virtual ~PrinterListener(); + + const boost::shared_ptr& getPrinter() const; + const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& getJobParameters() const; + const MultiSelection& getPageSelection() const; + + virtual int getPageCount() const = 0; // must be overloaded by the app + /* get the page parameters, namely the jobsetup that should be active for the page + (describing among others the physical page size) and the "page size". In writer + case this would probably be the same as the JobSetup since writer sets the page size + draw/impress for example print their page on the paper set on the printer, + possibly adjusting the page size to fit. That means the page size can be different from + the paper size. + */ + virtual void getPageParameters( int i_nPage, JobSetup& o_rPageSetup, Size& o_rPageSize ) const = 0; // must be overloaded by the app, return page size in 1/100th mm + virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app + virtual void setListeners(); // optionally set listeners on mxJobParameters + virtual void jobFinished(); // optionally release resources bound to the job + + void printFilteredPage( int i_nPage ); + + // implementation details, not usable outsid vcl + void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); + void SAL_DLLPRIVATE setJobParameters( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& ); + void SAL_DLLPRIVATE setPageSelection( const MultiSelection& ); +}; + +} + + #endif // _SV_PRINT_HXX diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 4fd6eaa999da..f5b4a35e0331 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: prndlg.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.114.5 $ * * This file is part of OpenOffice.org. * @@ -33,19 +33,122 @@ #include -#include +#include "vcl/print.hxx" +#include "vcl/print.h" -class Printer; +#include "vcl/dialog.hxx" +#include "vcl/fixed.hxx" +#include "vcl/button.hxx" +#include "vcl/scrbar.hxx" +#include "vcl/gdimtf.hxx" +#include "vcl/lstbox.hxx" +#include "vcl/field.hxx" +#include "vcl/tabctrl.hxx" +#include "vcl/tabpage.hxx" -class VCL_DLLPUBLIC SystemDialog : public ModalDialog +#include "tools/multisel.hxx" + +#include + + +namespace vcl { -public: - SystemDialog( Window* pParent, WinBits nWinStyle ) : - ModalDialog( pParent, nWinStyle ) {} - SystemDialog( Window* pParent, const ResId& rResId ) : - ModalDialog( pParent, rResId ) {} + class PrintDialog : public ModalDialog + { + class PrintPreviewWindow : public Window + { + GDIMetaFile maMtf; + public: + PrintPreviewWindow( Window* pParent, const ResId& ); + virtual ~PrintPreviewWindow(); + + virtual void Paint( const Rectangle& rRect ); + + void setPreview( const GDIMetaFile& ); + }; + + class PrinterTabPage : public TabPage + { + public: + ListBox maPrinters; + PushButton maSetupButton; + FixedText maType; + FixedText maTypeText; + FixedText maStatus; + FixedText maStatusText; + FixedText maLocation; + FixedText maLocText; + FixedText maComment; + FixedText maCommentText; + CheckBox maToFileBox; + + PrinterTabPage( Window*, const ResId& ); + virtual ~PrinterTabPage(); + }; + + class JobTabPage : public TabPage + { + public: + FixedLine maPrintRange; + RadioButton maAllButton; + RadioButton maPagesButton; + RadioButton maSelectionButton; + Edit maPagesEdit; + + FixedLine maCopies; + FixedText maCopyCount; + NumericField maCopyCountField; + CheckBox maCollateBox; + FixedImage maCollateImage; + + Image maCollateImg; + Image maCollateHCImg; + Image maNoCollateImg; + Image maNoCollateHCImg; + + JobTabPage( Window*, const ResId& ); + virtual ~JobTabPage(); + }; + + OKButton maOKButton; + CancelButton maCancelButton; + PrintPreviewWindow maPreviewWindow; + FixedText maPageText; + ScrollBar maPageScrollbar; + + TabControl maTabCtrl; + PrinterTabPage maPrinterPage; + JobTabPage maJobPage; + + FixedLine maButtonLine; + + boost::shared_ptr< PrinterListener > maPListener; + + rtl::OUString maPageStr; + sal_Int32 mnCurPage; + sal_Int32 mnCachedPages; + Rectangle maPreviewSpace; + + void preparePreview(); + void setPreviewText( sal_Int32 ); + void updatePrinterText(); + void checkControlDependencies(); + + DECL_LINK( ScrollHdl, ScrollBar* ); + DECL_LINK( ScrollEndHdl, ScrollBar* ); + DECL_LINK( SelectHdl, ListBox* ); + DECL_LINK( ClickHdl, Button* ); + DECL_LINK( ModifyHdl, Edit* ); + public: + PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& ); + virtual ~PrintDialog(); + + bool isPrintToFile(); + MultiSelection getPageSelection(); + int getCopyCount(); + bool isCollate(); + }; +} - virtual short Execute() { return 0; } -}; #endif // _SV_PRNDLG_HXX diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx index a80c5873cbfb..d76040f8cb8b 100644 --- a/vcl/inc/vcl/salprn.hxx +++ b/vcl/inc/vcl/salprn.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salprn.hxx,v $ - * $Revision: 1.5 $ + * $Revision: 1.5.114.1 $ * * This file is part of OpenOffice.org. * @@ -41,7 +41,7 @@ class SalGraphics; class SalFrame; struct ImplJobSetup; -class ImplQPrinter; +namespace vcl { class PrinterListener; } // ----------------------- // - SalPrinterQueueInfo - @@ -125,7 +125,7 @@ public: // public for Sal Implementation virtual BOOL StartJob( const String* pFileName, const String& rAppName, ImplJobSetup* pSetupData, - ImplQPrinter* pQPrinter ); + vcl::PrinterListener& rListener ); virtual BOOL EndJob() = 0; virtual BOOL AbortJob() = 0; diff --git a/vcl/inc/vcl/svdata.hxx b/vcl/inc/vcl/svdata.hxx index 536f629bfa9e..e252cb5793f1 100644 --- a/vcl/inc/vcl/svdata.hxx +++ b/vcl/inc/vcl/svdata.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: svdata.hxx,v $ - * $Revision: 1.13 $ + * $Revision: 1.13.16.1 $ * * This file is part of OpenOffice.org. * @@ -352,6 +352,7 @@ void ImplDeInitSVData(); void ImplDestroySVData(); Window* ImplGetDefaultWindow(); VCL_DLLPUBLIC ResMgr* ImplGetResMgr(); +VCL_DLLPUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr DockingManager* ImplGetDockingManager(); void ImplWindowAutoMnemonic( Window* pWindow ); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 47654c33bfd5..93a8b5cf3d46 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: svids.hrc,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.84.3 $ * * This file is part of OpenOffice.org. * @@ -73,6 +73,44 @@ #define SV_MENU_MAC_SHOWALL 2005 #define SV_MENU_MAC_QUITAPP 2006 +#define SV_DLG_PRINT 2048 +#define SV_PRINT_OK 1 +#define SV_PRINT_CANCEL 2 +#define SV_PRINT_PAGE_TXT 3 +#define SV_PRINT_PAGE_PREVIEW 4 +#define SV_PRINT_PAGE_SCROLL 5 +#define SV_PRINT_TABCTRL 6 + +#define SV_PRINT_TAB_PRINTER 1 +#define SV_PRINT_PRINTERS 1 +#define SV_PRINT_PRT_TYPE 2 +#define SV_PRINT_PRT_TYPE_TXT 3 +#define SV_PRINT_PRT_STATUS 4 +#define SV_PRINT_PRT_STATUS_TXT 5 +#define SV_PRINT_PRT_LOCATION 6 +#define SV_PRINT_PRT_LOCATION_TXT 7 +#define SV_PRINT_PRT_COMMENT 8 +#define SV_PRINT_PRT_COMMENT_TXT 9 +#define SV_PRINT_PRT_TOFILE 10 +#define SV_PRINT_PRT_SETUP 11 + +#define SV_PRINT_TAB_JOB 2 +#define SV_PRINT_RANGE 1 +#define SV_PRINT_ALL 2 +#define SV_PRINT_PAGERANGE 3 +#define SV_PRINT_SELECTION 4 +#define SV_PRINT_PAGERANGE_EDIT 5 +#define SV_PRINT_COPIES 6 +#define SV_PRINT_COPYCOUNT 7 +#define SV_PRINT_COPYCOUNT_FIELD 8 +#define SV_PRINT_COLLATE 9 +#define SV_PRINT_COLLATE_IMAGE 10 +#define SV_PRINT_BUTTONLINE 11 +#define SV_PRINT_COLLATE_IMG 12 +#define SV_PRINT_NOCOLLATE_IMG 13 +#define SV_PRINT_COLLATE_HC_IMG 14 +#define SV_PRINT_NOCOLLATE_HC_IMG 15 + #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 #define SV_HELPTEXT_MAXIMIZE 10002 @@ -107,7 +145,8 @@ #define SV_STDTEXT_ABOUT 10204 #define SV_STDTEXT_PREFERENCES 10205 #define SV_MAC_SCREENNNAME 10206 -#define SV_STDTEXT_LAST SV_MAC_SCREENNNAME +#define SV_STDTEXT_ALLFILETYPES 10207 +#define SV_STDTEXT_LAST SV_STDTEXT_ALLFILETYPES #define SV_ACCESSERROR_FIRST SV_ACCESSERROR_WRONG_VERSION #define SV_ACCESSERROR_WRONG_VERSION 10500 diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst index 919fdc5f944e..39d3e8aa9c02 100644 --- a/vcl/prj/d.lst +++ b/vcl/prj/d.lst @@ -87,7 +87,6 @@ mkdir: %_DEST%\inc%_EXT%\vcl\plug\vcl ..\inc\vcl\outdev3d.hxx %_DEST%\inc%_EXT%\vcl\outdev3d.hxx ..\inc\vcl\pointr.hxx %_DEST%\inc%_EXT%\vcl\pointr.hxx ..\inc\vcl\print.hxx %_DEST%\inc%_EXT%\vcl\print.hxx -..\inc\vcl\prndlg.hxx %_DEST%\inc%_EXT%\vcl\prndlg.hxx ..\inc\vcl\prntypes.hxx %_DEST%\inc%_EXT%\vcl\prntypes.hxx ..\inc\vcl\ptrstyle.hxx %_DEST%\inc%_EXT%\vcl\ptrstyle.hxx ..\inc\vcl\regband.hxx %_DEST%\inc%_EXT%\vcl\regband.hxx diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 69868ed38e55..cd169fc81fe7 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -91,7 +91,7 @@ SalPrinter::~SalPrinter() } BOOL SalPrinter::StartJob( const String*, const String&, - ImplJobSetup*, ImplQPrinter* ) + ImplJobSetup*, vcl::PrinterListener& ) { return FALSE; } diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index edfd6a24bff9..56ba933e3931 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: svdata.cxx,v $ - * $Revision: 1.56 $ + * $Revision: 1.56.114.1 $ * * This file is part of OpenOffice.org. * @@ -220,6 +220,15 @@ ResMgr* ImplGetResMgr() return pSVData->mpResMgr; } +ResId VclResId( sal_Int32 nId ) +{ + ResMgr* pMgr = ImplGetResMgr(); + if( ! pMgr ) + throw std::bad_alloc(); + + return ResId( nId, *pMgr ); +} + DockingManager* ImplGetDockingManager() { ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/gdi/impprn.cxx b/vcl/source/gdi/impprn.cxx index 5da5f951f203..a40357f003dc 100644 --- a/vcl/source/gdi/impprn.cxx +++ b/vcl/source/gdi/impprn.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: impprn.cxx,v $ - * $Revision: 1.19 $ + * $Revision: 1.19.54.1 $ * * This file is part of OpenOffice.org. * @@ -464,10 +464,12 @@ void ImplQPrinter::EndQueuePrint() DBG_ASSERT( mpPrinter, "no SalPrinter in ImplQPrinter" ); if( mpPrinter ) { + #if 0 mpPrinter->StartJob( mbPrintFile ? &maPrintFile : NULL, Application::GetDisplayName(), maJobSetup.ImplGetConstData(), this ); + #endif EndJob(); mpParent->ImplEndPrint(); } diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 7d68fbe40d3f..6a856df59d02 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.33 $ +# $Revision: 1.33.92.1 $ # # This file is part of OpenOffice.org. # @@ -96,6 +96,7 @@ SLOFILES= $(SLO)$/salmisc.obj \ $(SLO)$/fontcvt.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ + $(SLO)$/print3.obj \ $(SLO)$/regband.obj \ $(SLO)$/region.obj \ $(SLO)$/wall.obj \ @@ -121,6 +122,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/gfxlink.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ + $(SLO)$/print3.obj \ $(SLO)$/sallayout.obj \ $(SLO)$/image.obj \ $(SLO)$/impimage.obj \ diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 11bed4b7ae67..45f6a5c7d0c2 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: print.cxx,v $ - * $Revision: 1.65 $ + * $Revision: 1.65.114.1 $ * * This file is part of OpenOffice.org. * @@ -1309,7 +1309,7 @@ void Printer::PrintPage() // ----------------------------------------------------------------------- -ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError ) +ULONG Printer::ImplSalPrinterErrorCodeToVCL( ULONG nError ) { ULONG nVCLError; switch ( nError ) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx new file mode 100644 index 000000000000..e92d5c250112 --- /dev/null +++ b/vcl/source/gdi/print3.cxx @@ -0,0 +1,408 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: print3.cxx,v $ + * $Revision: 1.1.2.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_vcl.hxx" + +#include "vcl/print.hxx" +#include "vcl/prndlg.hxx" +#include "vcl/svapp.hxx" +#include "vcl/svdata.hxx" +#include "vcl/salinst.hxx" +#include "vcl/salprn.hxx" +#include "vcl/svids.hrc" + +#include "tools/urlobj.hxx" +#include "tools/multisel.hxx" + +#include "com/sun/star/ui/dialogs/XFilePicker.hpp" +#include "com/sun/star/ui/dialogs/XFilterManager.hpp" +#include "com/sun/star/ui/dialogs/TemplateDescription.hpp" +#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "comphelper/processfactory.hxx" + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace vcl; + +class vcl::ImplPrinterListenerData +{ +public: + boost::shared_ptr mpPrinter; + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxJobParameters; + MultiSelection maSelection; +}; + +PrinterListener::PrinterListener() + : mpImplData( new ImplPrinterListenerData ) +{ +} + +static rtl::OUString queryFile( Printer* pPrinter ) +{ + rtl::OUString aResult; + + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + if( xFactory.is() ) + { + uno::Sequence< uno::Any > aTempl( 1 ); + aTempl.getArray()[0] <<= ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION; + uno::Reference< ui::dialogs::XFilePicker > xFilePicker( + xFactory->createInstanceWithArguments( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), + aTempl ), uno::UNO_QUERY ); + DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" ); + + uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY ); + if( xFilePicker.is() && xFilterMgr.is() ) + { + try + { +#ifdef UNX + // add PostScript and PDF + bool bPS = true, bPDF = true; + if( pPrinter ) + { + if( pPrinter->GetCapabilities( PRINTER_CAPABILITIES_PDF ) ) + bPS = false; + else + bPDF = false; + } + if( bPS ) + xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) ); + if( bPDF ) + xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Portable Document Format" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.pdf" ) ) ); +#elif defined WNT + (void)pPrinter; + xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.PRN" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) ); +#endif + // add arbitrary files + xFilterMgr->appendFilter( String( VclResId( SV_STDTEXT_ALLFILETYPES ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) ); + } + catch( lang::IllegalArgumentException rExc ) + { + DBG_ERRORFILE( "caught IllegalArgumentException when registering filter\n" ); + } + + if( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK ) + { + uno::Sequence< ::rtl::OUString > aPathSeq( xFilePicker->getFiles() ); + INetURLObject aObj( aPathSeq[0] ); + aResult = aObj.PathToFileName(); + } + } + } + return aResult; +} + +struct PrintJobAsync +{ + boost::shared_ptr mpListener; + JobSetup maInitSetup; + Reference< beans::XPropertySet > mxJobOptions; + + PrintJobAsync( const boost::shared_ptr& i_pListener, + const JobSetup& i_rInitSetup, + const Reference< beans::XPropertySet >& i_xJobOptions + ) + : mpListener( i_pListener ), maInitSetup( i_rInitSetup ), mxJobOptions( i_xJobOptions ) + {} + + DECL_LINK( ExecJob, void* ); +}; + +IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG ) +{ + Printer::ImplPrintJob( mpListener, maInitSetup, mxJobOptions ); + + // clean up, do not access members after this + delete this; + + return 0; +} + +void Printer::PrintJob( const boost::shared_ptr& i_pListener, + const JobSetup& i_rInitSetup, + const Reference< beans::XPropertySet >& i_xJobOptions + ) +{ + PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup, i_xJobOptions ); + Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) ); +} + +void Printer::ImplPrintJob( const boost::shared_ptr& i_pListener, + const JobSetup& i_rInitSetup, + const Reference< beans::XPropertySet >& /*i_xJobOptions*/ + ) +{ + // setup printer + boost::shared_ptr pListener( i_pListener ); + boost::shared_ptr pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); + pListener->setPrinter( pPrinter ); + + // setup page range selection + MultiSelection aSel; + int nPages = i_pListener->getPageCount(); + aSel.SetTotalRange( Range( 1, nPages ) ); + aSel.SelectAll(); + + // check if the printer brings up its own dialog + // in that case leave the work to that dialog + if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) ) + { + try + { + PrintDialog aDlg( NULL, i_pListener ); + if( ! aDlg.Execute() ) + return; + if( aDlg.isPrintToFile() ) + { + rtl::OUString aFile = queryFile( pListener->getPrinter().get() ); + if( ! aFile.getLength() ) + return; + pListener->getPrinter()->EnablePrintFile( TRUE ); + pListener->getPrinter()->SetPrintFile( aFile ); + } + aSel = aDlg.getPageSelection(); + pListener->getPrinter()->SetCopyCount( aDlg.getCopyCount(), aDlg.isCollate() ); + } + catch( std::bad_alloc& ) + { + } + } + + pListener->setPageSelection( aSel ); + pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ), + pListener ); + + pListener->jobFinished(); +} + +bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptr& i_pListener ) +{ + mnError = PRINTER_OK; + + if ( IsDisplayPrinter() ) + return FALSE; + + if ( IsJobActive() || IsPrinting() ) + return FALSE; + + if( mpPrinterData->mbNextJobIsQuick ) + { + String aKey( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ); + if( maJobSetup.GetValue( aKey ).Len() == 0 ) + maJobSetup.SetValue( aKey, String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); + } + + ULONG nCopies = mnCopyCount; + BOOL bCollateCopy = mbCollateCopy; + BOOL bUserCopy = FALSE; + + if ( nCopies > 1 ) + { + ULONG nDevCopy; + + if ( bCollateCopy ) + nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COLLATECOPIES ); + else + nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COPIES ); + + // Muessen Kopien selber gemacht werden? + if ( nCopies > nDevCopy ) + { + bUserCopy = TRUE; + nCopies = 1; + bCollateCopy = FALSE; + } + } + else + bCollateCopy = FALSE; + + + ImplSVData* pSVData = ImplGetSVData(); + mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); + + if ( !mpPrinter ) + return FALSE; + + XubString* pPrintFile; + if ( mbPrintFile ) + pPrintFile = &maPrintFile; + else + pPrintFile = NULL; + + maJobName = i_rJobName; + mnCurPage = 1; + mnCurPrintPage = 1; + mbPrinting = TRUE; + if( ImplGetSVData()->maGDIData.mbPrinterPullModel ) + { + mbJobActive = TRUE; + // sallayer does all necesseary page printing + if( mpPrinter->StartJob( pPrintFile, + Application::GetDisplayName(), + maJobSetup.ImplGetConstData(), + *i_pListener ) ) + { + EndJob(); + } + else + { + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); + if ( !mnError ) + mnError = PRINTER_GENERALERROR; + pSVData->mpDefInst->DestroyPrinter( mpPrinter ); + mnCurPage = 0; + mnCurPrintPage = 0; + mbPrinting = FALSE; + mpPrinter = NULL; + + return false; + } + } + else + { + if( mpPrinter->StartJob( pPrintFile, + i_rJobName, + Application::GetDisplayName(), + nCopies, bCollateCopy, + maJobSetup.ImplGetConstData() ) ) + { + mbJobActive = TRUE; + MultiSelection aSel( i_pListener->getPageSelection() ); + for( long nPage = aSel.FirstSelected(); nPage != long(SFX_ENDOFSELECTION); nPage = aSel.NextSelected() ) + { + // remember MultiSelection is 1 based (due to user input) + i_pListener->printFilteredPage( static_cast(nPage-1) ); + } + EndJob(); + } + else + { + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); + if ( !mnError ) + mnError = PRINTER_GENERALERROR; + pSVData->mpDefInst->DestroyPrinter( mpPrinter ); + mnCurPage = 0; + mnCurPrintPage = 0; + mbPrinting = FALSE; + mpPrinter = NULL; + + return false; + } + } + + return true; +} + +PrinterListener::~PrinterListener() +{ + delete mpImplData; +} + +const boost::shared_ptr& PrinterListener::getPrinter() const +{ + return mpImplData->mpPrinter; +} + +const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& PrinterListener::getJobParameters() const +{ + return mpImplData->mxJobParameters; +} + +const MultiSelection& PrinterListener::getPageSelection() const +{ + return mpImplData->maSelection; +} + +void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) +{ + mpImplData->mpPrinter = i_rPrinter; +} + +void PrinterListener::setJobParameters( const Reference< beans::XPropertySet >& i_pParams ) +{ + mpImplData->mxJobParameters = i_pParams; +} + +void PrinterListener::setPageSelection( const MultiSelection& i_rSel ) +{ + mpImplData->maSelection = i_rSel; +} + +void PrinterListener::printFilteredPage( int i_nPage ) +{ + // get page parameters + JobSetup aPageSetup; + Size aPageSize; + getPageParameters( i_nPage, aPageSetup, aPageSize ); + const MapMode aMapMode( MAP_100TH_MM ); + + + mpImplData->mpPrinter->Push(); + mpImplData->mpPrinter->EnableOutput( FALSE ); + mpImplData->mpPrinter->SetMapMode( aMapMode ); + + GDIMetaFile aMtf; + aMtf.Record( mpImplData->mpPrinter.get() ); + + printPage( i_nPage ); + + aMtf.Stop(); + aMtf.WindStart(); + mpImplData->mpPrinter->Pop(); + + // FIXME: do transparency filtering here when vcl92 is integrated + + mpImplData->mpPrinter->EnableOutput( TRUE ); + if( aPageSetup != mpImplData->mpPrinter->GetJobSetup() ) // set new setup if changed + mpImplData->mpPrinter->SetJobSetup( aPageSetup ); + + // actually print the page + mpImplData->mpPrinter->StartPage(); + + mpImplData->mpPrinter->Push(); + mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); + aMtf.WindStart(); + aMtf.Play( mpImplData->mpPrinter.get() ); + mpImplData->mpPrinter->Pop(); + + mpImplData->mpPrinter->EndPage(); +} + +void PrinterListener::setListeners() +{ +} + +void PrinterListener::jobFinished() +{ +} + diff --git a/vcl/source/src/makefile.mk b/vcl/source/src/makefile.mk index cf01c74b977d..7772af5a0978 100644 --- a/vcl/source/src/makefile.mk +++ b/vcl/source/src/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.8.114.1 $ # # This file is part of OpenOffice.org. # @@ -47,7 +47,8 @@ SRC1FILES= images.src \ stdtext.src \ helptext.src \ units.src \ - btntext.src + btntext.src \ + print.src RESLIB1NAME= $(RESTARGET) RESLIB1IMAGES= $(PRJ)$/source/src diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src new file mode 100644 index 000000000000..b85783b02ddd --- /dev/null +++ b/vcl/source/src/print.src @@ -0,0 +1,247 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: print.src,v $ + * $Revision: 1.1.2.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vcl/svids.hrc" + +ModalDialog SV_DLG_PRINT +{ + Text [en-US] = "Printing"; + Closeable = TRUE; + Sizeable = FALSE; + Moveable = TRUE; + SVLook = TRUE; + + Size = MAP_APPFONT( 350, 195 ); + + OKButton SV_PRINT_OK + { + DefButton = TRUE; + Pos = MAP_APPFONT( 240, 175 ); + Size = MAP_APPFONT( 50, 15 ); + }; + CancelButton SV_PRINT_CANCEL + { + Pos = MAP_APPFONT( 295, 175 ); + Size = MAP_APPFONT( 50, 15 ); + }; + + Window SV_PRINT_PAGE_PREVIEW + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 130, 130 ); + Border = TRUE; + }; + ScrollBar SV_PRINT_PAGE_SCROLL + { + Pos = MAP_APPFONT( 5, 140 ); + Size = MAP_APPFONT( 130, 10 ); + SVLook = TRUE; + HScroll = TRUE; + TabStop = TRUE; + }; + FixedText SV_PRINT_PAGE_TXT + { + Pos = MAP_APPFONT( 5,150 ); + Size = MAP_APPFONT( 130, 10 ); + Text [ en-US ] = "Page %p of %n"; + Center = TRUE; + }; + TabControl SV_PRINT_TABCTRL + { + Pos = MAP_APPFONT( 140, 5 ); + Size = MAP_APPFONT( 205, 155 ); + }; + FixedLine SV_PRINT_BUTTONLINE + { + Pos = MAP_APPFONT( 0, 165 ); + Size = MAP_APPFONT( 350, 8 ); + }; + + TabPage SV_PRINT_TAB_PRINTER + { + Text [en-US] = "Printer"; + Hide = TRUE; + + ListBox SV_PRINT_PRINTERS + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 200 ); + DropDown = TRUE; + }; + PushButton SV_PRINT_PRT_SETUP + { + Pos = MAP_APPFONT( 115, 5 ); + Size = MAP_APPFONT( 50, 15 ); + Text [en-US] = "Properties..."; + }; + FixedText SV_PRINT_PRT_TYPE + { + Pos = MAP_APPFONT( 5, 30 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "Type"; + }; + FixedText SV_PRINT_PRT_TYPE_TXT + { + Pos = MAP_APPFONT( 50, 30 ); + Size = MAP_APPFONT( 200, 10 ); + }; + FixedText SV_PRINT_PRT_STATUS + { + Pos = MAP_APPFONT( 5, 42 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "Status"; + }; + FixedText SV_PRINT_PRT_STATUS_TXT + { + Pos = MAP_APPFONT( 50, 42 ); + Size = MAP_APPFONT( 200, 10 ); + }; + FixedText SV_PRINT_PRT_LOCATION + { + Pos = MAP_APPFONT( 5, 54 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "Location"; + }; + FixedText SV_PRINT_PRT_LOCATION_TXT + { + Pos = MAP_APPFONT( 50, 54 ); + Size = MAP_APPFONT( 200, 10 ); + }; + FixedText SV_PRINT_PRT_COMMENT + { + Pos = MAP_APPFONT( 5, 66 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "Comment"; + }; + FixedText SV_PRINT_PRT_COMMENT_TXT + { + Pos = MAP_APPFONT( 50, 66 ); + Size = MAP_APPFONT( 200, 10 ); + }; + CheckBox SV_PRINT_PRT_TOFILE + { + Pos = MAP_APPFONT( 5, 80 ); + Size = MAP_APPFONT( 200, 12 ); + Text [en-US] = "Print to file"; + }; + }; + + TabPage SV_PRINT_TAB_JOB + { + Text [en-US] = "Job Setup"; + Hide = TRUE; + + FixedLine SV_PRINT_RANGE + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 150, 10 ); + Text [en-US] = "Print range"; + }; + RadioButton SV_PRINT_ALL + { + Pos = MAP_APPFONT( 10, 15 ); + Size = MAP_APPFONT( 145, 15 ); + Text [en-US] = "All pages"; + Check = TRUE; + }; + RadioButton SV_PRINT_PAGERANGE + { + Pos = MAP_APPFONT( 10, 30 ); + Size = MAP_APPFONT( 60, 15 ); + Text [en-US] = "Pages"; + }; + Edit SV_PRINT_PAGERANGE_EDIT + { + Pos = MAP_APPFONT( 70, 30 ); + Size = MAP_APPFONT( 80, 15 ); + Border = TRUE; + }; + RadioButton SV_PRINT_SELECTION + { + Pos = MAP_APPFONT( 10, 45 ); + Size = MAP_APPFONT( 145, 15 ); + Text [en-US] = "Selection"; + }; + + FixedLine SV_PRINT_COPIES + { + Pos = MAP_APPFONT( 5, 70 ); + Size = MAP_APPFONT( 150, 10 ); + Text [en-US] = "Copies"; + }; + FixedText SV_PRINT_COPYCOUNT + { + Pos = MAP_APPFONT( 10, 80 ); + Size = MAP_APPFONT( 80, 10 ); + Text [en-US] = "Number of copies"; + }; + NumericField SV_PRINT_COPYCOUNT_FIELD + { + Pos = MAP_APPFONT( 90, 80 ); + Size = MAP_APPFONT( 40, 10 ); + Border = TRUE; + Spin = TRUE; + Minimum = 1; + Maximum = 16384; + Value = 1; + }; + FixedImage SV_PRINT_COLLATE_IMAGE + { + Pos = MAP_APPFONT( 10, 100 ); + Size = MAP_PIXEL( 80, 30 ); + }; + CheckBox SV_PRINT_COLLATE + { + Pos = MAP_APPFONT( 80, 100 ); + Size = MAP_APPFONT( 70, 10 ); + Text [en-US] = "Collate"; + }; + + Image SV_PRINT_COLLATE_IMG + { + ImageBitmap = Bitmap { File = "collate.png" ; }; + }; + + Image SV_PRINT_NOCOLLATE_IMG + { + ImageBitmap = Bitmap { File = "ncollate.png" ; }; + }; + + Image SV_PRINT_COLLATE_HC_IMG + { + ImageBitmap = Bitmap { File = "collate_h.png" ; }; + }; + + Image SV_PRINT_NOCOLLATE_HC_IMG + { + ImageBitmap = Bitmap { File = "ncollate_h.png" ; }; + }; + }; +}; diff --git a/vcl/source/src/stdtext.src b/vcl/source/src/stdtext.src index 5ad1cdceeb61..d4dca4915b6b 100644 --- a/vcl/source/src/stdtext.src +++ b/vcl/source/src/stdtext.src @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: stdtext.src,v $ - * $Revision: 1.53 $ + * $Revision: 1.53.84.1 $ * * This file is part of OpenOffice.org. * @@ -123,3 +123,8 @@ String SV_MAC_SCREENNNAME { Text [en-US] = "Screen %d"; }; + +String SV_STDTEXT_ALLFILETYPES +{ + Text [en-US] = "Any type"; +}; diff --git a/vcl/source/window/makefile.mk b/vcl/source/window/makefile.mk index cdd4aef73bb0..cadea48f6f7a 100644 --- a/vcl/source/window/makefile.mk +++ b/vcl/source/window/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.25 $ +# $Revision: 1.25.114.1 $ # # This file is part of OpenOffice.org. # @@ -70,6 +70,7 @@ SLOFILES= \ $(SLO)$/mnemonicengine.obj \ $(SLO)$/msgbox.obj \ $(SLO)$/scrwnd.obj \ + $(SLO)$/printdlg.obj \ $(SLO)$/seleng.obj \ $(SLO)$/split.obj \ $(SLO)$/splitwin.obj \ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx new file mode 100644 index 000000000000..9270562358be --- /dev/null +++ b/vcl/source/window/printdlg.cxx @@ -0,0 +1,405 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: printdlg.cxx,v $ + * $Revision: 1.1.2.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_vcl.hxx" + +#include "vcl/print.hxx" +#include "vcl/prndlg.hxx" +#include "vcl/dialog.hxx" +#include "vcl/button.hxx" +#include "vcl/svdata.hxx" +#include "vcl/svids.hrc" +#include "vcl/wall.hxx" +#include "vcl/jobset.h" + +#include "rtl/ustrbuf.hxx" + +using namespace vcl; + +PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) + : Window( i_pParent, i_rId ) +{ +} + +PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() +{ +} + +void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect ) +{ + Window::Paint( i_rRect ); + + SetFillColor( Color( COL_WHITE ) ); + SetLineColor(); + DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() )); + Push(); + SetMapMode( MAP_100TH_MM ); + maMtf.WindStart(); + maMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ); + Pop(); +} + +void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview ) +{ + maMtf = i_rNewPreview; + Invalidate(); +} + +PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rResId ) + : TabPage( i_pParent, rResId ) + , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) + , maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) ) + , maType( this, VclResId( SV_PRINT_PRT_TYPE ) ) + , maTypeText( this, VclResId( SV_PRINT_PRT_TYPE_TXT ) ) + , maStatus( this, VclResId( SV_PRINT_PRT_STATUS ) ) + , maStatusText(this, VclResId( SV_PRINT_PRT_STATUS_TXT ) ) + , maLocation( this, VclResId( SV_PRINT_PRT_LOCATION ) ) + , maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) ) + , maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) ) + , maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) ) + , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) +{ + FreeResource(); +} + +PrintDialog::PrinterTabPage::~PrinterTabPage() +{ +} + +PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) + : TabPage( i_pParent, rResId ) + , maPrintRange( this, VclResId( SV_PRINT_RANGE ) ) + , maAllButton( this, VclResId( SV_PRINT_ALL ) ) + , maPagesButton( this, VclResId( SV_PRINT_PAGERANGE ) ) + , maSelectionButton( this, VclResId( SV_PRINT_SELECTION ) ) + , maPagesEdit( this, VclResId( SV_PRINT_PAGERANGE_EDIT ) ) + , maCopies( this, VclResId( SV_PRINT_COPIES ) ) + , maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) ) + , maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) ) + , maCollateBox( this, VclResId( SV_PRINT_COLLATE ) ) + , maCollateImage( this, VclResId( SV_PRINT_COLLATE_IMAGE ) ) + , maCollateImg( VclResId( SV_PRINT_COLLATE_IMG ) ) + , maCollateHCImg( VclResId( SV_PRINT_COLLATE_HC_IMG ) ) + , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) + , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) +{ + FreeResource(); +} + +PrintDialog::JobTabPage::~JobTabPage() +{ +} + +PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rListener ) + : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) + , maOKButton( this, VclResId( SV_PRINT_OK ) ) + , maCancelButton( this, VclResId( SV_PRINT_CANCEL ) ) + , maPreviewWindow( this, VclResId( SV_PRINT_PAGE_PREVIEW ) ) + , maPageText( this, VclResId( SV_PRINT_PAGE_TXT ) ) + , maPageScrollbar( this, VclResId( SV_PRINT_PAGE_SCROLL ) ) + , maTabCtrl( this, VclResId( SV_PRINT_TABCTRL ) ) + , maPrinterPage( &maTabCtrl, VclResId( SV_PRINT_TAB_PRINTER ) ) + , maJobPage( &maTabCtrl, VclResId( SV_PRINT_TAB_JOB ) ) + , maButtonLine( this, VclResId( SV_PRINT_BUTTONLINE ) ) + , maPListener( i_rListener ) + , mnCurPage( 0 ) + , mnCachedPages( 0 ) +{ + FreeResource(); + + // insert the tab pages + maTabCtrl.InsertPage( SV_PRINT_PAGE_PREVIEW, maPrinterPage.GetText() ); + maTabCtrl.SetTabPage( SV_PRINT_PAGE_PREVIEW, &maPrinterPage ); + maTabCtrl.InsertPage( SV_PRINT_TAB_JOB, maJobPage.GetText() ); + maTabCtrl.SetTabPage( SV_PRINT_TAB_JOB, &maJobPage ); + + maPageStr = maPageText.GetText(); + // save space for the preview window + maPreviewSpace = Rectangle( maPreviewWindow.GetPosPixel(), maPreviewWindow.GetSizePixel() ); + // get the first page + preparePreview(); + + // set up the scrollbar for the preview pages + maPageScrollbar.SetScrollHdl( LINK( this, PrintDialog, ScrollHdl ) ); + maPageScrollbar.SetEndScrollHdl( LINK( this, PrintDialog, ScrollEndHdl ) ); + maPageScrollbar.EnableDrag( TRUE ); + + // fill printer listbox + const std::vector< rtl::OUString >& rQueues( Printer::GetPrinterQueues() ); + for( std::vector< rtl::OUString >::const_iterator it = rQueues.begin(); + it != rQueues.end(); ++it ) + { + maPrinterPage.maPrinters.InsertEntry( *it ); + } + // select current printer + if( maPrinterPage.maPrinters.GetEntryPos( maPListener->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) + maPrinterPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); + else + { + // fall back to default printer + maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); + maPListener->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); + } + // update the text fields for the printer + updatePrinterText(); + + // set a select handler + maPrinterPage.maPrinters.SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); + + // setup page range edit + rtl::OUStringBuffer aBuf( 16 ); + aBuf.append( sal_Unicode('1') ); + if( mnCachedPages > 1 ) + { + aBuf.append( sal_Unicode('-') ); + aBuf.append( mnCachedPages ); + } + maJobPage.maPagesEdit.SetText( aBuf.makeStringAndClear() ); + + // setup click handler on the various buttons + maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maJobPage.maAllButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maJobPage.maSelectionButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maJobPage.maPagesButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + + // setup modify hdl + maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); + + // setup dependencies + checkControlDependencies(); +} + +PrintDialog::~PrintDialog() +{ +} + +bool PrintDialog::isPrintToFile() +{ + return maPrinterPage.maToFileBox.IsChecked(); +} + +int PrintDialog::getCopyCount() +{ + return maJobPage.maCopyCountField.GetValue(); +} + +bool PrintDialog::isCollate() +{ + return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE; +} + +MultiSelection PrintDialog::getPageSelection() +{ + if( maJobPage.maPagesButton.IsChecked() ) + return MultiSelection( maJobPage.maPagesEdit.GetText() ); + else if( maJobPage.maAllButton.IsChecked() ) + { + MultiSelection aSel( Range( 1, maPListener->getPageCount() ) ); + aSel.SelectAll(); + return aSel; + } + DBG_ERROR( "NYI: Selection" ); + return MultiSelection(); +} + +void PrintDialog::checkControlDependencies() +{ + if( maJobPage.maCopyCountField.GetValue() > 1 ) + maJobPage.maCollateBox.Enable( TRUE ); + else + maJobPage.maCollateBox.Enable( FALSE ); + + maJobPage.maPagesEdit.Enable( maJobPage.maPagesButton.IsChecked() ); + Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg ); + if( GetSettings().GetStyleSettings().GetFieldColor().IsDark() ) + aImg = maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg; + + // adjust position and size of image + maJobPage.maCollateImage.SetSizePixel( aImg.GetSizePixel() ); + Point aPos( maJobPage.maCollateImage.GetPosPixel() ); + aPos.Y() = maJobPage.maCollateBox.GetPosPixel().Y(); + aPos.Y() -= (aImg.GetSizePixel().Height() - maJobPage.maCollateBox.GetSizePixel().Height())/2; + maJobPage.maCollateImage.SetPosPixel( aPos ); + maJobPage.maCollateImage.SetImage( aImg ); + + // enable setup button only for printers that can be setup + maPrinterPage.maSetupButton.Enable( maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ) ); +} + +void PrintDialog::updatePrinterText() +{ + const QueueInfo* pInfo = Printer::GetQueueInfo( maPrinterPage.maPrinters.GetSelectEntry(), true ); + if( pInfo ) + { + maPrinterPage.maTypeText.SetText( pInfo->GetDriver() ); + // FIXME: status message + // maJobPage.maStatusText.SetText(); + maPrinterPage.maLocText.SetText( pInfo->GetLocation() ); + maPrinterPage.maCommentText.SetText( pInfo->GetComment() ); + } +} + +static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, sal_Int32 i_nReplacement ) +{ + sal_Int32 nPos = i_rOrig.indexOfAsciiL( i_pRepl, i_nReplLen ); + if( nPos != -1 ) + { + rtl::OUStringBuffer aBuf( i_rOrig.getLength() ); + aBuf.append( i_rOrig.getStr(), nPos ); + aBuf.append( i_nReplacement ); + if( nPos + i_nReplLen < i_rOrig.getLength() ) + aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen ); + return aBuf.makeStringAndClear(); + } + return i_rOrig; +} + +void PrintDialog::setPreviewText( sal_Int32 nSetPage ) +{ + rtl::OUString aNewText( searchAndReplace( maPageStr, "%p", 2, nSetPage+1 ) ); + aNewText = searchAndReplace( aNewText, "%n", 2, mnCachedPages ); + maPageText.SetText( aNewText ); +} + +void PrintDialog::preparePreview() +{ + sal_Int32 nPages = maPListener->getPageCount(); + mnCachedPages = nPages; + + setPreviewText( mnCurPage ); + + maPageScrollbar.SetRange( Range( 0, nPages-1 ) ); + maPageScrollbar.SetThumbPos( mnCurPage ); + + boost::shared_ptr aPrt( maPListener->getPrinter() ); + + + const MapMode aMapMode( MAP_100TH_MM ); + Size aPageSize; + JobSetup aPageSetup( aPrt->GetJobSetup() ); + maPListener->getPageParameters( mnCurPage, aPageSetup, aPageSize ); + ImplUpdateJobSetupPaper( aPageSetup ); // fill in physical paper size + Size aPaperSize( aPageSetup.ImplGetConstData()->mnPaperWidth, + aPageSetup.ImplGetConstData()->mnPaperHeight ); + if( aPageSetup.ImplGetConstData()->meOrientation == ORIENTATION_LANDSCAPE ) + { + aPaperSize.Width() = aPageSetup.ImplGetConstData()->mnPaperHeight; + aPaperSize.Height() = aPageSetup.ImplGetConstData()->mnPaperWidth; + } + + aPrt->Push(); + aPrt->EnableOutput( FALSE ); + aPrt->SetMapMode( aMapMode ); + + GDIMetaFile aMtf; + aMtf.SetPrefSize( aPageSize ); + aMtf.SetPrefMapMode( aMapMode ); + aMtf.Record( &(*aPrt) ); + + maPListener->printPage( mnCurPage ); + + aMtf.Stop(); + aMtf.WindStart(); + aPrt->Pop(); + + Size aPreviewSize; + Point aPreviewPos = maPreviewSpace.TopLeft(); + const long nW = maPreviewSpace.GetSize().Width(); + const long nH = maPreviewSpace.GetSize().Height(); + if( aPaperSize.Width() > aPaperSize.Height() ) + { + aPreviewSize = Size( nW, nW * aPaperSize.Height() / aPaperSize.Width() ); + aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2; + } + else + { + aPreviewSize = Size( nH * aPaperSize.Width() / aPaperSize.Height(), nH ); + aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2; + } + maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize ); + const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) ); + aMtf.Scale( double(aLogicSize.Width())/double(aPaperSize.Width()), + double(aLogicSize.Height())/double(aPaperSize.Height()) ); + maPreviewWindow.setPreview( aMtf ); +} + +IMPL_LINK( PrintDialog, ScrollHdl, ScrollBar*, pScrBar ) +{ + if( pScrBar == &maPageScrollbar ) + { + sal_Int32 nNewPage = static_cast( maPageScrollbar.GetThumbPos() ); + setPreviewText( nNewPage ); + } + return 0; +} + +IMPL_LINK( PrintDialog, ScrollEndHdl, ScrollBar*, pScrBar ) +{ + if( pScrBar == &maPageScrollbar ) + { + sal_Int32 nNewPage = static_cast( maPageScrollbar.GetThumbPos() ); + if( nNewPage != mnCurPage ) + { + mnCurPage = nNewPage; + preparePreview(); + } + } + return 0; +} + +IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) +{ + if( pBox == &maPrinterPage.maPrinters ) + { + // set new printer + maPListener->setPrinter( boost::shared_ptr( new Printer( maPrinterPage.maPrinters.GetSelectEntry() ) ) ); + // update text fields + updatePrinterText(); + } + return 0; +} + +IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) +{ + if( pButton == &maPrinterPage.maSetupButton ) + { + maPListener->getPrinter()->Setup( this ); + } + checkControlDependencies(); + return 0; +} + +IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG ) +{ + checkControlDependencies(); + return 0; +} + From d47140e61cc0f58dec4c93a2eb801b03be3fa0ff Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Oct 2008 14:31:29 +0000 Subject: [PATCH 003/283] #i92516# prepare app specific print dialog elements --- vcl/inc/vcl/print.hxx | 40 ++++-- vcl/inc/vcl/prndlg.hxx | 8 +- vcl/source/gdi/print3.cxx | 179 +++++++++++++++++++----- vcl/source/window/printdlg.cxx | 239 ++++++++++++++++++++++++++++++--- 4 files changed, 406 insertions(+), 60 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index e6199437ca4a..e939c5a09705 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -41,7 +41,7 @@ #include "tools/stream.hxx" #include "tools/multisel.hxx" -#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" #include @@ -438,15 +438,13 @@ public: */ static void PrintJob( const boost::shared_ptr& i_pListener, - const JobSetup& i_rInitSetup, - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions + const JobSetup& i_rInitSetup ); // implementation detail of PrintJob being asynchronous // not exported, not usable outside vcl static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr& i_pListener, - const JobSetup& i_rInitSetup, - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& i_xJobOptions + const JobSetup& i_rInitSetup ); }; @@ -462,9 +460,33 @@ public: virtual ~PrinterListener(); const boost::shared_ptr& getPrinter() const; - const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& getJobParameters() const; const MultiSelection& getPageSelection() const; + /* for implementations: get current job properties as changed by e.g. print dialog + this gets the current set of properties initially told to Printer::PrintJob + + For convenience a second sequence will be merged in to get a combined sequence. + In case of duplicate property names, the value of i_MergeList wins. + */ + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > + getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const; + + /* get the PorpertyValue of a Property + */ + com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); + + /* return the currently active UI options. These are the same passed to setUIOptions. + */ + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& getUIOptions() const; + /* set possible UI options. should only be done once before passing the PrinterListener + to Printer::PrintJob + */ + void setUIOptions( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& ); + /* enable/disable an option; this can be used to implement dialog logic. + */ + void enableUIOption( const rtl::OUString& rPropName, bool bEnable ); + bool isUIOptionEnabled( const rtl::OUString& rPropName ) const; + virtual int getPageCount() const = 0; // must be overloaded by the app /* get the page parameters, namely the jobsetup that should be active for the page (describing among others the physical page size) and the "page size". In writer @@ -473,17 +495,17 @@ public: possibly adjusting the page size to fit. That means the page size can be different from the paper size. */ - virtual void getPageParameters( int i_nPage, JobSetup& o_rPageSetup, Size& o_rPageSize ) const = 0; // must be overloaded by the app, return page size in 1/100th mm + // must be overloaded by the app, return page size in 1/100th mm + virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0; virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app - virtual void setListeners(); // optionally set listeners on mxJobParameters virtual void jobFinished(); // optionally release resources bound to the job void printFilteredPage( int i_nPage ); // implementation details, not usable outsid vcl void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); - void SAL_DLLPRIVATE setJobParameters( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& ); void SAL_DLLPRIVATE setPageSelection( const MultiSelection& ); + void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); }; } diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index f5b4a35e0331..cbd6125aaca9 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -49,7 +49,7 @@ #include "tools/multisel.hxx" #include - +#include namespace vcl { @@ -129,16 +129,22 @@ namespace vcl sal_Int32 mnCachedPages; Rectangle maPreviewSpace; + std::list< Window* > maControls; + std::map< Window*, rtl::OUString > maControlToPropertyMap; + std::multimap< rtl::OUString, Window* > maPropertyToWindowMap; + void preparePreview(); void setPreviewText( sal_Int32 ); void updatePrinterText(); void checkControlDependencies(); + void setupOptionalUI(); DECL_LINK( ScrollHdl, ScrollBar* ); DECL_LINK( ScrollEndHdl, ScrollBar* ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); DECL_LINK( ModifyHdl, Edit* ); + DECL_LINK( UIOptionsChanged, void* ); public: PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& ); virtual ~PrintDialog(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e92d5c250112..4aecf29770d9 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -46,18 +46,28 @@ #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/awt/Size.hpp" #include "comphelper/processfactory.hxx" +#include +#include + using namespace com::sun::star; using namespace com::sun::star::uno; +using namespace com::sun::star::beans; using namespace vcl; class vcl::ImplPrinterListenerData { public: - boost::shared_ptr mpPrinter; - com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxJobParameters; - MultiSelection maSelection; + + boost::shared_ptr mpPrinter; + MultiSelection maSelection; + Sequence< PropertyValue > maUIOptions; + std::vector< PropertyValue > maUIProperties; + std::vector< bool > maUIPropertyEnabled; + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash > maPropertyToIndex; + Link maOptionChangeHdl; }; PrinterListener::PrinterListener() @@ -126,13 +136,11 @@ struct PrintJobAsync { boost::shared_ptr mpListener; JobSetup maInitSetup; - Reference< beans::XPropertySet > mxJobOptions; PrintJobAsync( const boost::shared_ptr& i_pListener, - const JobSetup& i_rInitSetup, - const Reference< beans::XPropertySet >& i_xJobOptions + const JobSetup& i_rInitSetup ) - : mpListener( i_pListener ), maInitSetup( i_rInitSetup ), mxJobOptions( i_xJobOptions ) + : mpListener( i_pListener ), maInitSetup( i_rInitSetup ) {} DECL_LINK( ExecJob, void* ); @@ -140,7 +148,7 @@ struct PrintJobAsync IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG ) { - Printer::ImplPrintJob( mpListener, maInitSetup, mxJobOptions ); + Printer::ImplPrintJob( mpListener, maInitSetup ); // clean up, do not access members after this delete this; @@ -149,17 +157,15 @@ IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG ) } void Printer::PrintJob( const boost::shared_ptr& i_pListener, - const JobSetup& i_rInitSetup, - const Reference< beans::XPropertySet >& i_xJobOptions + const JobSetup& i_rInitSetup ) { - PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup, i_xJobOptions ); + PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup ); Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) ); } void Printer::ImplPrintJob( const boost::shared_ptr& i_pListener, - const JobSetup& i_rInitSetup, - const Reference< beans::XPropertySet >& /*i_xJobOptions*/ + const JobSetup& i_rInitSetup ) { // setup printer @@ -333,11 +339,6 @@ const boost::shared_ptr& PrinterListener::getPrinter() const return mpImplData->mpPrinter; } -const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& PrinterListener::getJobParameters() const -{ - return mpImplData->mxJobParameters; -} - const MultiSelection& PrinterListener::getPageSelection() const { return mpImplData->maSelection; @@ -348,29 +349,44 @@ void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) mpImplData->mpPrinter = i_rPrinter; } -void PrinterListener::setJobParameters( const Reference< beans::XPropertySet >& i_pParams ) -{ - mpImplData->mxJobParameters = i_pParams; -} - void PrinterListener::setPageSelection( const MultiSelection& i_rSel ) { mpImplData->maSelection = i_rSel; } +static void modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) +{ + for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) + { + if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) + { + Size aPageSize; + awt::Size aSize; + i_rProps[ nProperty].Value >>= aSize; + aPageSize.Width() = aSize.Width; + aPageSize.Height() = aSize.Height; + + Size aCurSize( pPrinter->GetPaperSize() ); + if( aPageSize != aCurSize ) + pPrinter->SetPaperSizeUser( aPageSize ); + } + } +} + void PrinterListener::printFilteredPage( int i_nPage ) { // get page parameters - JobSetup aPageSetup; - Size aPageSize; - getPageParameters( i_nPage, aPageSetup, aPageSize ); + Sequence< PropertyValue > aPageParm( getPageParameters( i_nPage ) ); const MapMode aMapMode( MAP_100TH_MM ); - mpImplData->mpPrinter->Push(); - mpImplData->mpPrinter->EnableOutput( FALSE ); mpImplData->mpPrinter->SetMapMode( aMapMode ); + // modify job setup if necessary + modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); + + mpImplData->mpPrinter->EnableOutput( FALSE ); + GDIMetaFile aMtf; aMtf.Record( mpImplData->mpPrinter.get() ); @@ -383,8 +399,6 @@ void PrinterListener::printFilteredPage( int i_nPage ) // FIXME: do transparency filtering here when vcl92 is integrated mpImplData->mpPrinter->EnableOutput( TRUE ); - if( aPageSetup != mpImplData->mpPrinter->GetJobSetup() ) // set new setup if changed - mpImplData->mpPrinter->SetJobSetup( aPageSetup ); // actually print the page mpImplData->mpPrinter->StartPage(); @@ -398,11 +412,108 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->EndPage(); } -void PrinterListener::setListeners() -{ -} - void PrinterListener::jobFinished() { } +Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const +{ + std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; + size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size(); + for( int i = 0; i < i_rMergeList.getLength(); i++ ) + aMergeSet.insert( i_rMergeList[i].Name ); + + Sequence< PropertyValue > aResult( nResultLen ); + for( int i = 0; i < i_rMergeList.getLength(); i++ ) + aResult[i] = i_rMergeList[i]; + int nCur = i_rMergeList.getLength(); + for( size_t i = 0; i < mpImplData->maUIProperties.size(); i++ ) + { + if( aMergeSet.find( mpImplData->maUIProperties[i].Name ) == aMergeSet.end() ) + aResult[nCur++] = mpImplData->maUIProperties[i]; + } + aResult.realloc( nCur ); + return aResult; +} + +const Sequence< beans::PropertyValue >& PrinterListener::getUIOptions() const +{ + return mpImplData->maUIOptions; +} + +com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl::OUString& i_rProperty ) +{ + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + mpImplData->maPropertyToIndex.find( i_rProperty ); + return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; +} + +void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rOptions ) +{ + DBG_ASSERT( mpImplData->maUIOptions.getLength() == 0, "setUIOptions called twice !" ); + + mpImplData->maUIOptions = i_rOptions; + mpImplData->maUIProperties.clear(); + mpImplData->maPropertyToIndex.clear(); + mpImplData->maUIPropertyEnabled.clear(); + + for( int i = 0; i < i_rOptions.getLength(); i++ ) + { + Sequence< beans::PropertyValue > aOptProp; + i_rOptions[i].Value >>= aOptProp; + bool bIsEnabled = true; + bool bHaveProperty = false; + for( int n = 0; n < aOptProp.getLength(); n++ ) + { + const beans::PropertyValue& rEntry( aOptProp[ n ] ); + if( rEntry.Name.equalsAscii( "Property" ) ) + { + PropertyValue aVal; + rEntry.Value >>= aVal; + DBG_ASSERT( mpImplData->maPropertyToIndex.find( aVal.Name ) + == mpImplData->maPropertyToIndex.end(), "duplicate property entry" ); + mpImplData->maPropertyToIndex[ aVal.Name ] = i; + mpImplData->maUIProperties.push_back( aVal ); + bHaveProperty = true; + } + else if( rEntry.Name.equalsAscii( "Enabled" ) ) + { + sal_Bool bValue = sal_True; + rEntry.Value >>= bValue; + bIsEnabled = bValue; + } + } + if( bHaveProperty ) + mpImplData->maUIPropertyEnabled.push_back( bIsEnabled ); + } +} + +void PrinterListener::enableUIOption( const rtl::OUString& i_rProperty, bool i_bEnable ) +{ + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + mpImplData->maPropertyToIndex.find( i_rProperty ); + if( it != mpImplData->maPropertyToIndex.end() ) + { + // call handler only for actual changes + if( ( mpImplData->maUIPropertyEnabled[ it->second ] && ! i_bEnable ) || + ( ! mpImplData->maUIPropertyEnabled[ it->second ] && i_bEnable ) ) + { + mpImplData->maUIPropertyEnabled[ it->second ] = i_bEnable; + rtl::OUString aPropName( i_rProperty ); + mpImplData->maOptionChangeHdl.Call( &aPropName ); + } + } +} + +bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) const +{ + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + mpImplData->maPropertyToIndex.find( i_rProperty ); + return it != mpImplData->maPropertyToIndex.end() ? mpImplData->maUIPropertyEnabled[it->second] : false; +} + +void PrinterListener::setOptionChangeHdl( const Link& i_rHdl ) +{ + mpImplData->maOptionChangeHdl = i_rHdl; +} + diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9270562358be..29f9bcee7c71 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -41,7 +41,12 @@ #include "rtl/ustrbuf.hxx" +#include "com/sun/star/awt/Size.hpp" + using namespace vcl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ) @@ -193,12 +198,23 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); + // setup dependencies checkControlDependencies(); } PrintDialog::~PrintDialog() { + while( ! maControls.empty() ) + { + delete maControls.front(); + maControls.pop_front(); + } } bool PrintDialog::isPrintToFile() @@ -230,6 +246,177 @@ MultiSelection PrintDialog::getPageSelection() return MultiSelection(); } +void PrintDialog::setupOptionalUI() +{ + Window* pCurParent = 0; + long nCurY = 0; + USHORT nOptPageId = 9; + MapMode aFontMapMode( MAP_APPFONT ); + + Size aTabSize = maTabCtrl.GetSizePixel(); + const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); + for( int i = 0; i < rOptions.getLength(); i++ ) + { + Sequence< beans::PropertyValue > aOptProp; + rOptions[i].Value >>= aOptProp; + + // extract ui element + bool bEnabled = true; + rtl::OUString aCtrlType; + rtl::OUString aText; + rtl::OUString aPropertyName; + Sequence< rtl::OUString > aChoices; + + for( int n = 0; n < aOptProp.getLength(); n++ ) + { + const beans::PropertyValue& rEntry( aOptProp[ n ] ); + if( rEntry.Name.equalsAscii( "Text" ) ) + { + rEntry.Value >>= aText; + } + else if( rEntry.Name.equalsAscii( "ControlType" ) ) + { + rEntry.Value >>= aCtrlType; + } + else if( rEntry.Name.equalsAscii( "Choices" ) ) + { + rEntry.Value >>= aChoices; + } + else if( rEntry.Name.equalsAscii( "Property" ) ) + { + PropertyValue aVal; + rEntry.Value >>= aVal; + aPropertyName = aVal.Name; + } + else if( rEntry.Name.equalsAscii( "Enabled" ) ) + { + sal_Bool bValue = sal_True; + rEntry.Value >>= bValue; + bEnabled = bValue; + } + } + if( aCtrlType.equalsAscii( "Group" ) || + aCtrlType.equalsAscii( "Radio" ) || + aCtrlType.equalsAscii( "List" ) || + aCtrlType.equalsAscii( "Bool" ) ) + { + if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) + { + // add new tab page + TabPage* pNewGroup = new TabPage( &maTabCtrl ); + maControls.push_front( pNewGroup ); + pCurParent = pNewGroup; + nCurY = 5; + pNewGroup->SetText( aText ); + maTabCtrl.InsertPage( ++nOptPageId, aText ); + maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); + } + + if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) + { + // add a check box + CheckBox* pNewBox = new CheckBox( pCurParent ); + maControls.push_front( pNewBox ); + pNewBox->SetText( aText ); + + // FIXME: measure text + pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) ); + nCurY += 15; + + pNewBox->Show(); + sal_Bool bVal = sal_False; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal ) + pVal->Value >>= bVal; + pNewBox->Check( bVal ); + pNewBox->Enable( maPListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); + } + else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) + { + long nXPos = 5; + + if( aText.getLength() ) + { + // add a FixedText: + FixedText* pHeading = new FixedText( pCurParent ); + maControls.push_front( pHeading ); + pHeading->SetText( aText ); + Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + aPixelSize ); + pHeading->Show(); + + nXPos = 15; + nCurY += 12; + } + + // iterate options + rtl::OUString aSelectVal; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal ) + pVal->Value >>= aSelectVal; + for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) + { + RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); + maControls.push_front( pBtn ); + pBtn->SetText( aChoices[m] ); + pBtn->Check( aChoices[m] == aSelectVal ); + Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos, 12 ), aFontMapMode ) ); + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( 15, nCurY ), aFontMapMode ), + aPixelSize ); + pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pBtn->Show(); + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) ); + nCurY += 12; + } + } + else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) + { + // add a FixedText: + FixedText* pHeading = new FixedText( pCurParent ); + maControls.push_front( pHeading ); + pHeading->SetText( aText ); + Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + aPixelSize ); + pHeading->Show(); + nCurY += 12; + + ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); + maControls.push_front( pList ); + aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + pList->SetPosSizePixel( pList->LogicToPixel( Point( 15, nCurY ), aFontMapMode), + aPixelSize ); + pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pList->Show(); + + // iterate options + for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) + { + pList->InsertEntry( aChoices[m] ); + } + rtl::OUString aSelectVal; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal ) + pVal->Value >>= aSelectVal; + pList->SelectEntry( aSelectVal ); + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); + } + } + else + { + DBG_ERROR( "Unsupported UI option" ); + } + } +} + void PrintDialog::checkControlDependencies() { if( maJobPage.maCopyCountField.GetValue() > 1 ) @@ -303,21 +490,23 @@ void PrintDialog::preparePreview() const MapMode aMapMode( MAP_100TH_MM ); - Size aPageSize; - JobSetup aPageSetup( aPrt->GetJobSetup() ); - maPListener->getPageParameters( mnCurPage, aPageSetup, aPageSize ); - ImplUpdateJobSetupPaper( aPageSetup ); // fill in physical paper size - Size aPaperSize( aPageSetup.ImplGetConstData()->mnPaperWidth, - aPageSetup.ImplGetConstData()->mnPaperHeight ); - if( aPageSetup.ImplGetConstData()->meOrientation == ORIENTATION_LANDSCAPE ) + aPrt->Push(); + aPrt->SetMapMode( aMapMode ); + + Size aPageSize( aPrt->GetPaperSize() ); + Sequence< PropertyValue > aPageParms( maPListener->getPageParameters( mnCurPage ) ); + for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty ) { - aPaperSize.Width() = aPageSetup.ImplGetConstData()->mnPaperHeight; - aPaperSize.Height() = aPageSetup.ImplGetConstData()->mnPaperWidth; + if( aPageParms[ nProperty ].Name.equalsIgnoreAsciiCaseAscii( "PageSize" ) ) + { + awt::Size aSize; + aPageParms[ nProperty ].Value >>= aSize; + aPageSize.Width() = aSize.Width; + aPageSize.Height() = aSize.Height; + } } - aPrt->Push(); aPrt->EnableOutput( FALSE ); - aPrt->SetMapMode( aMapMode ); GDIMetaFile aMtf; aMtf.SetPrefSize( aPageSize ); @@ -334,20 +523,20 @@ void PrintDialog::preparePreview() Point aPreviewPos = maPreviewSpace.TopLeft(); const long nW = maPreviewSpace.GetSize().Width(); const long nH = maPreviewSpace.GetSize().Height(); - if( aPaperSize.Width() > aPaperSize.Height() ) + if( aPageSize.Width() > aPageSize.Height() ) { - aPreviewSize = Size( nW, nW * aPaperSize.Height() / aPaperSize.Width() ); + aPreviewSize = Size( nW, nW * aPageSize.Height() / aPageSize.Width() ); aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2; } else { - aPreviewSize = Size( nH * aPaperSize.Width() / aPaperSize.Height(), nH ); + aPreviewSize = Size( nH * aPageSize.Width() / aPageSize.Height(), nH ); aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2; } maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize ); const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) ); - aMtf.Scale( double(aLogicSize.Width())/double(aPaperSize.Width()), - double(aLogicSize.Height())/double(aPaperSize.Height()) ); + aMtf.Scale( double(aLogicSize.Width())/double(aPageSize.Width()), + double(aLogicSize.Height())/double(aPageSize.Height()) ); maPreviewWindow.setPreview( aMtf ); } @@ -403,3 +592,21 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG ) return 0; } +IMPL_LINK( PrintDialog, UIOptionsChanged, void*, i_pOption ) +{ + PropertyValue* pVal = maPListener->getValue( *reinterpret_cast< rtl::OUString* >(i_pOption) ); + if( pVal ) + { + std::pair< std::multimap< rtl::OUString, Window* >::iterator, + std::multimap< rtl::OUString, Window* >::iterator > aWindows = + maPropertyToWindowMap.equal_range( pVal->Name ); + for( std::multimap< rtl::OUString, Window* >::const_iterator it = + aWindows.first; it != aWindows.second; ++it ) + { + it->second->Enable( maPListener->isUIOptionEnabled( pVal->Name ) ); + } + } + return 0; +} + + From d46badbea2b4235f6bad54db177869163877eb2e Mon Sep 17 00:00:00 2001 From: Release Engineers Date: Mon, 3 Nov 2008 12:53:04 +0000 Subject: [PATCH 004/283] Create DEV300_m35 milestone tag From 45f81056f07d8f007e29bd13c839e65b920a24f1 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Nov 2008 14:54:11 +0000 Subject: [PATCH 005/283] #i92516# fix some up prop issues, add put back values --- vcl/inc/vcl/prndlg.hxx | 6 ++ vcl/source/gdi/print3.cxx | 4 +- vcl/source/window/printdlg.cxx | 102 +++++++++++++++++++++++++++++---- 3 files changed, 99 insertions(+), 13 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index cbd6125aaca9..245d0bd9748c 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -138,6 +138,7 @@ namespace vcl void updatePrinterText(); void checkControlDependencies(); void setupOptionalUI(); + com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; DECL_LINK( ScrollHdl, ScrollBar* ); DECL_LINK( ScrollEndHdl, ScrollBar* ); @@ -145,6 +146,11 @@ namespace vcl DECL_LINK( ClickHdl, Button* ); DECL_LINK( ModifyHdl, Edit* ); DECL_LINK( UIOptionsChanged, void* ); + + DECL_LINK( UIOption_CheckHdl, CheckBox* ); + DECL_LINK( UIOption_RadioHdl, RadioButton* ); + DECL_LINK( UIOption_SelectHdl, ListBox* ); + public: PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& ); virtual ~PrintDialog(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 4aecf29770d9..e9468f7fe0f0 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -472,7 +472,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO rEntry.Value >>= aVal; DBG_ASSERT( mpImplData->maPropertyToIndex.find( aVal.Name ) == mpImplData->maPropertyToIndex.end(), "duplicate property entry" ); - mpImplData->maPropertyToIndex[ aVal.Name ] = i; + mpImplData->maPropertyToIndex[ aVal.Name ] = mpImplData->maUIProperties.size(); mpImplData->maUIProperties.push_back( aVal ); bHaveProperty = true; } @@ -509,7 +509,7 @@ bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) cons { std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rProperty ); - return it != mpImplData->maPropertyToIndex.end() ? mpImplData->maUIPropertyEnabled[it->second] : false; + return ((it != mpImplData->maPropertyToIndex.end()) ? mpImplData->maUIPropertyEnabled[it->second] : false); } void PrinterListener::setOptionChangeHdl( const Link& i_rHdl ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 29f9bcee7c71..6f80cd9059f6 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -295,6 +295,7 @@ void PrintDialog::setupOptionalUI() bEnabled = bValue; } } + if( aCtrlType.equalsAscii( "Group" ) || aCtrlType.equalsAscii( "Radio" ) || aCtrlType.equalsAscii( "List" ) || @@ -357,7 +358,7 @@ void PrintDialog::setupOptionalUI() // iterate options rtl::OUString aSelectVal; PropertyValue* pVal = maPListener->getValue( aPropertyName ); - if( pVal ) + if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { @@ -375,38 +376,56 @@ void PrintDialog::setupOptionalUI() nCurY += 12; } } - else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) + else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) { // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + aPixelSize.Width() += pHeading->GetTextWidth( aText ); pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); - nCurY += 12; ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); maControls.push_front( pList ); - aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); - pList->SetPosSizePixel( pList->LogicToPixel( Point( 15, nCurY ), aFontMapMode), - aPixelSize ); - pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); - pList->Show(); // iterate options + long nMaxTextWidth = 0; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { pList->InsertEntry( aChoices[m] ); + long nEntryWidth = pList->GetTextWidth( aChoices[m] ); + if( nEntryWidth > nMaxTextWidth ) + nMaxTextWidth = nEntryWidth; } + nMaxTextWidth += 30; rtl::OUString aSelectVal; PropertyValue* pVal = maPListener->getValue( aPropertyName ); - if( pVal ) + if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aSelectVal; pList->SelectEntry( aSelectVal ); + + Point aListPos; + if( nMaxTextWidth + aPixelSize.Width() < aTabSize.Width() - 10 ) + { + aListPos = pHeading->GetPosPixel(); + aListPos.X() += pHeading->GetSizePixel().Width() + 5; + } + else + { + nCurY += 12; + aListPos = pCurParent->LogicToPixel( Point( 15, nCurY ), aFontMapMode ); + } + + aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); + aPixelSize.Width() = nMaxTextWidth; + aPixelSize.Height() *= aChoices.getLength() > 15 ? 15 : aChoices.getLength(); + pList->SetPosSizePixel( aListPos, aPixelSize ); + pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pList->Show(); + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); } } @@ -478,9 +497,13 @@ void PrintDialog::setPreviewText( sal_Int32 nSetPage ) void PrintDialog::preparePreview() { + // page range may have changed depending on options sal_Int32 nPages = maPListener->getPageCount(); mnCachedPages = nPages; + if( mnCurPage >= nPages ) + mnCurPage = nPages-1; + setPreviewText( mnCurPage ); maPageScrollbar.SetRange( Range( 0, nPages-1 ) ); @@ -609,4 +632,61 @@ IMPL_LINK( PrintDialog, UIOptionsChanged, void*, i_pOption ) return 0; } +PropertyValue* PrintDialog::getValueForWindow( Window* i_pWindow ) const +{ + PropertyValue* pVal = NULL; + std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow ); + if( it != maControlToPropertyMap.end() ) + { + pVal = maPListener->getValue( it->second ); + DBG_ASSERT( pVal, "property value not found" ); + } + else + { + DBG_ERROR( "changed control not in property map" ); + } + return pVal; +} + +IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) +{ + PropertyValue* pVal = getValueForWindow( i_pBox ); + if( pVal ) + { + sal_Bool bVal = i_pBox->IsChecked(); + pVal->Value <<= bVal; + + // update preview and page settings + preparePreview(); + } + return 0; +} + +IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) +{ + PropertyValue* pVal = getValueForWindow( i_pBtn ); + if( pVal ) + { + rtl::OUString aVal( i_pBtn->GetText() );; + pVal->Value <<= aVal; + + // update preview and page settings + preparePreview(); + } + return 0; +} + +IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) +{ + PropertyValue* pVal = getValueForWindow( i_pBox ); + if( pVal ) + { + rtl::OUString aVal( i_pBox->GetSelectEntry() );; + pVal->Value <<= aVal; + + // update preview and page settings + preparePreview(); + } + return 0; +} From b83950b29bfd4aeadf0d6dd9b1da28d48163d6f3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Nov 2008 15:52:15 +0000 Subject: [PATCH 006/283] #i92516# begin sd work --- vcl/source/window/printdlg.cxx | 39 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 6f80cd9059f6..306001e2e7a2 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -297,6 +297,7 @@ void PrintDialog::setupOptionalUI() } if( aCtrlType.equalsAscii( "Group" ) || + aCtrlType.equalsAscii( "Subgroup" ) || aCtrlType.equalsAscii( "Radio" ) || aCtrlType.equalsAscii( "List" ) || aCtrlType.equalsAscii( "Bool" ) ) @@ -313,7 +314,21 @@ void PrintDialog::setupOptionalUI() maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); } - if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) + if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) + { + FixedLine* pNewSub = new FixedLine( pCurParent ); + maControls.push_front( pNewSub ); + pNewSub->SetText( aText ); + nCurY += 4; + Size aPixelSize( aTabSize ); + aPixelSize.Width() /= 2; + aPixelSize.Height() = pCurParent->GetTextHeight() + 4; + pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + aPixelSize ); + pNewSub->Show(); + nCurY += 12; + } + else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { // add a check box CheckBox* pNewBox = new CheckBox( pCurParent ); @@ -323,7 +338,7 @@ void PrintDialog::setupOptionalUI() // FIXME: measure text pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) ); - nCurY += 15; + nCurY += 12; pNewBox->Show(); sal_Bool bVal = sal_False; @@ -407,11 +422,19 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= aSelectVal; pList->SelectEntry( aSelectVal ); + aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); + aPixelSize.Width() = nMaxTextWidth; + aPixelSize.Height() *= aChoices.getLength() > 15 ? 15 : aChoices.getLength(); + Point aListPos; + bool bDoAlign = false; if( nMaxTextWidth + aPixelSize.Width() < aTabSize.Width() - 10 ) { aListPos = pHeading->GetPosPixel(); aListPos.X() += pHeading->GetSizePixel().Width() + 5; + + // align heading and list box + bDoAlign = true; } else { @@ -419,14 +442,20 @@ void PrintDialog::setupOptionalUI() aListPos = pCurParent->LogicToPixel( Point( 15, nCurY ), aFontMapMode ); } - aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); - aPixelSize.Width() = nMaxTextWidth; - aPixelSize.Height() *= aChoices.getLength() > 15 ? 15 : aChoices.getLength(); pList->SetPosSizePixel( aListPos, aPixelSize ); pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pList->Show(); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); + nCurY += 16; + + if( bDoAlign ) + { + Point aPos = pHeading->GetPosPixel(); + Size aSize = pHeading->GetSizePixel(); + aPos.Y() += (pList->GetSizePixel().Height() - aSize.Height())/2; + pHeading->SetPosSizePixel( aPos, aSize ); + } } } else From 15d5931e21971aa6e48ed4d79d460ffadf04af82 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 6 Nov 2008 15:44:05 +0000 Subject: [PATCH 007/283] fix a warning --- vcl/source/gdi/print3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e9468f7fe0f0..bba5c5ad979f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -197,7 +197,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->getPrinter()->SetPrintFile( aFile ); } aSel = aDlg.getPageSelection(); - pListener->getPrinter()->SetCopyCount( aDlg.getCopyCount(), aDlg.isCollate() ); + pListener->getPrinter()->SetCopyCount( static_cast(aDlg.getCopyCount()), aDlg.isCollate() ); } catch( std::bad_alloc& ) { From 35de9888cc5aabdd5e0541872bcf160ea8fd99b4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 6 Nov 2008 15:54:09 +0000 Subject: [PATCH 008/283] fix a warning --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 306001e2e7a2..f87ea73f6f4f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -224,7 +224,7 @@ bool PrintDialog::isPrintToFile() int PrintDialog::getCopyCount() { - return maJobPage.maCopyCountField.GetValue(); + return static_cast(maJobPage.maCopyCountField.GetValue()); } bool PrintDialog::isCollate() From adf0066a17538a394550237a54f6fc0027f6ed29 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 10 Nov 2008 19:55:35 +0000 Subject: [PATCH 009/283] #i91478# aqua implementation (continued) --- vcl/aqua/inc/aquaprintview.h | 9 +- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 596 ++++++++++++++++++ vcl/aqua/source/gdi/makefile.mk | 1 + vcl/aqua/source/gdi/salprn.cxx | 5 + 4 files changed, 610 insertions(+), 1 deletion(-) create mode 100644 vcl/aqua/source/gdi/aquaprintaccessoryview.mm diff --git a/vcl/aqua/inc/aquaprintview.h b/vcl/aqua/inc/aquaprintview.h index f879936d1435..294a6492869d 100755 --- a/vcl/aqua/inc/aquaprintview.h +++ b/vcl/aqua/inc/aquaprintview.h @@ -35,7 +35,8 @@ #include #include "postmac.h" -class ImplQPrinter; +#include "vcl/print.hxx" + class AquaSalInfoPrinter; namespace vcl { class PrinterListener; } @@ -51,5 +52,11 @@ namespace vcl { class PrinterListener; } -(void)drawRect: (NSRect)rect; @end +@interface AquaPrintAccessoryView : NSObject +{ +} ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener; +@end + #endif diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm new file mode 100644 index 000000000000..b7aa9f660dbd --- /dev/null +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -0,0 +1,596 @@ +/************************************************************************ + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: aquaprintview.mm,v $ + * $Revision: 1.5.56.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_vcl.hxx" + +#include "aquaprintview.h" +#include "salinst.h" +#include "vcl/print.hxx" + +#include + +using namespace vcl; +using namespace com::sun::star; +using namespace com::sun::star::beans; +using namespace com::sun::star::uno; + +#if 0 +/* below is some dark magic to inherit an NSViewController if running + on MacOS 10.5. However this is futile since as long as our base line is 10.4 + can use the deprecated method NSPrintOperation:setAccessoryView anyway. + The problem here is that as long as we're linked for 10.4, the print panel + will never show a preview and our accessory view at the same time. This is awful, + but since it was dictated by Apple that IT MUST BE SO it cannot be bad + + Anyway the code below (the load method) is really ugly, so perhaps it's better this way. +*/ + +#import + +APPKIT_EXTERN NSString *NSPrintPanelAccessorySummaryItemNameKey; +APPKIT_EXTERN NSString *NSPrintPanelAccessorySummaryItemDescriptionKey; + +#include "osl/module.h" + +@interface AquaPrintViewController : NSObject +{ + NSArray* pAry; +} ++(void)load; +-(id)init; +-(void)dealloc; +-(NSArray *)localizedSummaryItems; +-(NSSet*)keyPathsForValuesAffectingPreview; +@end + +@implementation AquaPrintViewController ++(void)load +{ + struct objc_class *pClass = (struct objc_class *)[self class]; + Class superclass = NSClassFromString(@"NSViewController"); + + if(superclass != NULL) + { + pClass->super_class = superclass; + pClass->instance_size += superclass->instance_size; + } +} + +-(id)init +{ + if( (self = [super performSelector: @selector(initWithNibName:bundle:) withObject: nil withObject: nil]) ) + { + NSObject* pKeys[] = { NSPrintPanelAccessorySummaryItemNameKey, NSPrintPanelAccessorySummaryItemDescriptionKey }; + NSObject* pVals[] = { @"the Name", @"the summary value" }; + NSDictionary* pDict = [NSDictionary dictionaryWithObjects: pVals forKeys: pKeys count: 2]; + pAry = [NSArray arrayWithObject: pDict]; + } + return self; +} + +-(void)dealloc +{ + [pAry release]; + [super dealloc]; +} + +-(NSArray *)localizedSummaryItems +{ + return pAry; +} +-(NSSet*)keyPathsForValuesAffectingPreview +{ + return [NSSet set]; +} +@end + +#endif + +class ListenerProperties +{ + vcl::PrinterListener* mpListener; + std::map< int, rtl::OUString > maTagToPropertyName; + std::map< int, rtl::OUString > maTagToValueName; + int mnNextTag; + public: + ListenerProperties( vcl::PrinterListener* i_pListener ) + : mpListener( i_pListener ), mnNextTag( 0 ) + {} + + void updatePrintJob() + { + // TODO: refresh page count etc from mpListener + } + + int addNameTag( const rtl::OUString& i_rPropertyName ) + { + int nNewTag = mnNextTag++; + maTagToPropertyName[ nNewTag ] = i_rPropertyName; + return nNewTag; + } + + int addNameAndValueTag( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rValue ) + { + int nNewTag = mnNextTag++; + maTagToPropertyName[ nNewTag ] = i_rPropertyName; + maTagToValueName[ nNewTag ] = i_rValue; + return nNewTag; + } + + void changePropertyWithNamedValue( int i_nTag ) + { + std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); + std::map< int, rtl::OUString >::const_iterator value_it = maTagToValueName.find( i_nTag ); + if( name_it != maTagToPropertyName.end() && value_it != maTagToValueName.end() ) + { + PropertyValue* pVal = mpListener->getValue( name_it->second ); + if( pVal ) + { + pVal->Value <<= value_it->second; + updatePrintJob(); + } + } + } + + void changePropertyWithBoolValue( int i_nTag, sal_Bool i_bValue ) + { + std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); + if( name_it != maTagToPropertyName.end() ) + { + PropertyValue* pVal = mpListener->getValue( name_it->second ); + if( pVal ) + { + pVal->Value <<= i_bValue; + updatePrintJob(); + } + } + } +}; + +@interface ControlTarget : NSObject +{ + ListenerProperties* mpListener; +} +-(id)initWithListenerMap: (ListenerProperties*)pListener; +-(void)triggered:(id)pSender; +-(void)dealloc; +@end + +@implementation ControlTarget +-(id)initWithListenerMap: (ListenerProperties*)pListener +{ + if( (self = [super init]) ) + { + mpListener = pListener; + } + return self; +} +-(void)triggered:(id)pSender; +{ + if( [pSender isMemberOfClass: [NSPopUpButton class]] ) + { + NSPopUpButton* pBtn = (NSPopUpButton*)pSender; + NSMenuItem* pSelected = [pBtn selectedItem]; + if( pSelected ) + { + int nTag = [pSelected tag]; + mpListener->changePropertyWithNamedValue( nTag ); + } + } + else if( [pSender isMemberOfClass: [NSButton class]] ) + { + NSButton* pBtn = (NSButton*)pSender; + int nTag = [pBtn tag]; + mpListener->changePropertyWithBoolValue( nTag, [pBtn state] == NSOnState ); + } + else if( [pSender isMemberOfClass: [NSMatrix class]] ) + { + NSObject* pObj = [(NSMatrix*)pSender selectedCell]; + if( [pObj isMemberOfClass: [NSButtonCell class]] ) + { + NSButtonCell* pCell = (NSButtonCell*)pObj; + int nTag = [pCell tag]; + mpListener->changePropertyWithNamedValue( nTag ); + } + } + else + { + DBG_ERROR( "unsupported class" ); + } +} +-(void)dealloc +{ + delete mpListener; + [super dealloc]; +} +@end + +static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) +{ + NSArray* pSubViews = [pView subviews]; + unsigned int nViews = [pSubViews count]; + NSRect aUnion = { { 0, 0 }, { 0, 0 } }; + + // get the combined frame of all subviews + for( unsigned int n = 0; n < nViews; n++ ) + { + aUnion = NSUnionRect( aUnion, [[pSubViews objectAtIndex: n] frame] ); + } + + // move everything so it will fit + for( unsigned int n = 0; n < nViews; n++ ) + { + NSView* pCurSubView = [pSubViews objectAtIndex: n]; + NSRect aFrame = [pCurSubView frame]; + aFrame.origin.x -= aUnion.origin.x - 5; + aFrame.origin.y -= aUnion.origin.y - 5; + [pCurSubView setFrame: aFrame]; + } + + // resize the view itself + aUnion.size.height += 10; + aUnion.size.width += 10; + [pView setFrameSize: aUnion.size]; + + if( aUnion.size.width > rMaxSize.width ) + rMaxSize.width = aUnion.size.width; + if( aUnion.size.height > rMaxSize.height ) + rMaxSize.height = aUnion.size.height; +} + +@implementation AquaPrintAccessoryView ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener; +{ + ListenerProperties* pListenerProperties = new ListenerProperties( pListener ); + ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; + + NSView* pCurParent = 0; + long nCurY = 0; + long nCurX = 0; + NSRect aViewFrame = { { 0, 0 }, {400, 400 } }; + NSSize aMaxTabSize = { 0, 0 }; + NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aViewFrame]; + + const Sequence< PropertyValue >& rOptions( pListener->getUIOptions() ); + for( int i = 0; i < rOptions.getLength(); i++ ) + { + Sequence< beans::PropertyValue > aOptProp; + rOptions[i].Value >>= aOptProp; + + // extract ui element + bool bEnabled = true; + rtl::OUString aCtrlType; + rtl::OUString aText; + rtl::OUString aPropertyName; + Sequence< rtl::OUString > aChoices; + + for( int n = 0; n < aOptProp.getLength(); n++ ) + { + const beans::PropertyValue& rEntry( aOptProp[ n ] ); + if( rEntry.Name.equalsAscii( "Text" ) ) + { + rEntry.Value >>= aText; + } + else if( rEntry.Name.equalsAscii( "ControlType" ) ) + { + rEntry.Value >>= aCtrlType; + } + else if( rEntry.Name.equalsAscii( "Choices" ) ) + { + rEntry.Value >>= aChoices; + } + else if( rEntry.Name.equalsAscii( "Property" ) ) + { + PropertyValue aVal; + rEntry.Value >>= aVal; + aPropertyName = aVal.Name; + } + else if( rEntry.Name.equalsAscii( "Enabled" ) ) + { + sal_Bool bValue = sal_True; + rEntry.Value >>= bValue; + bEnabled = bValue; + } + } + + if( aCtrlType.equalsAscii( "Group" ) || + aCtrlType.equalsAscii( "Subgroup" ) || + aCtrlType.equalsAscii( "Radio" ) || + aCtrlType.equalsAscii( "List" ) || + aCtrlType.equalsAscii( "Bool" ) ) + { + // since our build target is MacOSX 10.4 we can have only one accessory view + // so we have a single accessory view that is tabbed for grouping + if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) + { + // set size of current parent + if( pCurParent ) + adjustViewAndChildren( pCurParent, aMaxTabSize ); + + // new tab item + if( ! aText.getLength() ) + aText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OOo" ) ); + NSString* pLabel = CreateNSString( aText ); + NSTabViewItem* pItem = [[NSTabViewItem alloc] initWithIdentifier: pLabel ]; + [pItem setLabel: pLabel]; + [pTabView addTabViewItem: pItem]; + pCurParent = [[NSView alloc] initWithFrame: aViewFrame]; + [pItem setView: pCurParent]; + [pLabel release]; + + // reset indent + nCurX = 0; + } + + if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) + { + NSString* pText = CreateNSString( aText ); + NSRect aTextRect = { { 0, 0 }, { 300, 15 } }; + NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setEditable: NO]; + [pTextView setSelectable: NO]; + [pTextView setDrawsBackground: NO]; + [pTextView setString: pText]; + [pTextView sizeToFit]; // FIXME: this does nothing + [pCurParent addSubview: pTextView]; + + aTextRect = [pTextView frame]; + // move to nCurY + aTextRect.origin.y = nCurY - aTextRect.size.height; + [pTextView setFrame: aTextRect]; + + // update nCurY + nCurY = aTextRect.origin.y - 5; + + // set indent + nCurX = 20; + + // cleanup + [pText release]; + } + else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) + { + NSString* pText = CreateNSString( aText ); + NSRect aCheckRect = { { nCurX, 0 }, { 0, 15 } }; + NSButton* pBtn = [[NSButton alloc] initWithFrame: aCheckRect]; + [pBtn setButtonType: NSSwitchButton]; + [pBtn setTitle: pText]; + sal_Bool bVal = sal_False; + PropertyValue* pVal = pListener->getValue( aPropertyName ); + if( pVal ) + pVal->Value >>= bVal; + [pBtn setState: bVal ? NSOnState : NSOffState]; + [pBtn setEnabled: (pListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL) ? YES : NO]; + [pBtn sizeToFit]; + [pCurParent addSubview: pBtn]; + + // connect target + [pBtn setTarget: pCtrlTarget]; + [pBtn setAction: @selector(triggered:)]; + int nTag = pListenerProperties->addNameTag( aPropertyName ); + [pBtn setTag: nTag]; + + aCheckRect = [pBtn frame]; + + // move to nCurY + aCheckRect.origin.y = nCurY - aCheckRect.size.height; + [pBtn setFrame: aCheckRect]; + + // update nCurY + nCurY = aCheckRect.origin.y - 5; + + // cleanup + [pText release]; + } + else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) + { + if( aText.getLength() ) + { + // add a label + NSString* pText = CreateNSString( aText ); + NSRect aTextRect = { { nCurX, 0 }, { 300, 15 } }; + NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setEditable: NO]; + [pTextView setSelectable: NO]; + [pTextView setDrawsBackground: NO]; + [pTextView setString: pText]; + [pTextView sizeToFit]; // FIXME: this does nothing + [pCurParent addSubview: pTextView]; + + // move to nCurY + aTextRect.origin.y = nCurY - aTextRect.size.height; + [pTextView setFrame: aTextRect]; + + // update nCurY + nCurY = aTextRect.origin.y - 5; + + // cleanup + [pText release]; + } + + // setup radio matrix + NSButtonCell* pProto = [[NSButtonCell alloc] init]; + + NSRect aRadioRect = { { nCurX + 20, 0 }, { 280 - nCurX, 5*aChoices.getLength() } }; + [pProto setTitle: @"RadioButtonGroup"]; + [pProto setButtonType: NSRadioButton]; + NSMatrix* pMatrix = [[NSMatrix alloc] initWithFrame: aRadioRect + mode: NSRadioModeMatrix + prototype: (NSCell*)pProto + numberOfRows: aChoices.getLength() + numberOfColumns: 1]; + // get currently selected value + rtl::OUString aSelectVal; + PropertyValue* pVal = pListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= aSelectVal; + // set individual titles + NSArray* pCells = [pMatrix cells]; + for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) + { + NSCell* pCell = [pCells objectAtIndex: m]; + NSString* pTitle = CreateNSString( aChoices[m] ); + [pCell setTitle: pTitle]; + // connect target and action + [pCell setTarget: pCtrlTarget]; + [pCell setAction: @selector(triggered:)]; + int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, aChoices[ m ] ); + [pCell setTag: nTag]; + [pTitle release]; + // set current selection + if( aSelectVal == aChoices[m] ) + [pMatrix selectCellAtRow: m column: 0]; + } + [pMatrix sizeToFit]; + aRadioRect = [pMatrix frame]; + + // move it down, so it comes to the correct position + aRadioRect.origin.y = nCurY - aRadioRect.size.height; + [pMatrix setFrame: aRadioRect]; + [pCurParent addSubview: pMatrix]; + + // update nCurY + nCurY = aRadioRect.origin.y - 5; + + + [pProto release]; + } + else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) + { + NSString* pText = CreateNSString( aText ); + + // measure the text + NSFont* pFont = [NSFont labelFontOfSize: 0]; + NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont + forKey: NSFontAttributeName]; + + NSSize aTextSize = [pText sizeWithAttributes: pDict]; + // FIXME: the only thing reliable about sizeWithAttributes is + // that the size it outputs is way too small for our NSTextView + // that would not matter so much if NSTextView's fitToSize actually + // did something out of the box, alas it doesn't. This probably needs more + // fiddling with NSTextView's and NSTextContainer's parameters, however + // since this already almost cost me my sanity a Murphy factor of 1.5 + // will have to suffice for the time being. + aTextSize.width *= 1.5; + aTextSize.height += 3; + NSRect aTextRect = { { nCurX, 0 }, aTextSize }; + NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setEditable: NO]; + [pTextView setSelectable: NO]; + [pTextView setDrawsBackground: NO]; + [pTextView setString: pText]; + [pTextView setVerticallyResizable: NO]; + [pTextView setHorizontallyResizable: YES]; + [pTextView sizeToFit]; // FIXME: this actually does nothing + [pCurParent addSubview: pTextView]; + aTextRect = [pTextView frame]; + + + NSRect aBtnRect = { { nCurX + aTextRect.size.width, 0 }, { 0, 15 } }; + NSPopUpButton* pBtn = [[NSPopUpButton alloc] initWithFrame: aBtnRect pullsDown: NO]; + // iterate options + for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) + { + NSString* pItemText = CreateNSString( aChoices[m] ); + [pBtn addItemWithTitle: pItemText]; + NSMenuItem* pItem = [pBtn itemWithTitle: pItemText]; + int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, aChoices[m] ); + [pItem setTag: nTag]; + [pItemText release]; + } + + PropertyValue* pVal = pListener->getValue( aPropertyName ); + rtl::OUString aSelectVal; + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= aSelectVal; + NSString* pSelectText = CreateNSString( aSelectVal ); + [pBtn setTitle: pSelectText]; + [pSelectText release]; + [pBtn setEnabled: (pListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL) ? YES : NO]; + + [pBtn sizeToFit]; + [pCurParent addSubview: pBtn]; + + // connect target and action + [pBtn setTarget: pCtrlTarget]; + [pBtn setAction: @selector(triggered:)]; + + // move to nCurY + aBtnRect = [pBtn frame]; + aBtnRect.origin.y = nCurY - aBtnRect.size.height; + [pBtn setFrame: aBtnRect]; + + // align label + aTextRect.origin.y = aBtnRect.origin.y + (aBtnRect.size.height - aTextRect.size.height)/2; + [pTextView setFrame: aTextRect]; + + // update nCurY + nCurY = aBtnRect.origin.y - 5; + + // cleanup + [pText release]; + } + } + else + { + DBG_ERROR( "Unsupported UI option" ); + } + } + adjustViewAndChildren( pCurParent, aMaxTabSize ); + + // find the minimum needed tab size + NSSize aTabCtrlSize = [pTabView minimumSize]; + aTabCtrlSize.height += aMaxTabSize.height + 10; + if( aTabCtrlSize.width < aMaxTabSize.width + 10 ) + aTabCtrlSize.width = aMaxTabSize.width + 10; + [pTabView setFrameSize: aTabCtrlSize]; + + // set the accessory view + #if 0 + NSPrintPanel* pPanel = [pOp printPanel]; + if( [pPanel respondsToSelector: @selector(addAccessoryController:)] ) + { + // 10.5 and upward case + AquaPrintViewController* pCtrl = [[AquaPrintViewController alloc] init]; + [pCtrl performSelector: @selector(setView:) withObject: pTabView]; + [pCtrl performSelector: @selector(setTitle:) withObject: @"Test OOOOO"]; + [pPanel performSelector: @selector(addAccessoryController:) withObject: pCtrl]; + [pPanel performSelector: @selector(setOptions:) withObject: (id)(0x20001)]; + } + else + #endif + [pOp setAccessoryView: pTabView]; + + return pCtrlTarget; +} + +@end diff --git a/vcl/aqua/source/gdi/makefile.mk b/vcl/aqua/source/gdi/makefile.mk index deb6832a5525..90b5e55b82db 100644 --- a/vcl/aqua/source/gdi/makefile.mk +++ b/vcl/aqua/source/gdi/makefile.mk @@ -62,6 +62,7 @@ SLOFILES= $(SLO)$/salmathutils.obj \ $(SLO)$/salvd.obj \ $(SLO)$/salprn.obj \ $(SLO)$/aquaprintview.obj \ + $(SLO)$/aquaprintaccessoryview.obj \ $(SLO)$/salbmp.obj .IF "$(ENABLE_CAIRO)" == "TRUE" diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 09227c549874..620fc2647482 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -496,15 +496,20 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( pPrintOperation ) { + NSObject* pReleaseAfterUse = nil; bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: bShowPanel ? YES : NO]; + if( bShowPanel ) + pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener]; + bSuccess = TRUE; mbJob = true; pInst->startedPrintJob(); [pPrintOperation runOperation]; pInst->endedPrintJob(); mbJob = false; + [pReleaseAfterUse release]; } mnCurPageRangeStart = mnCurPageRangeCount = 0; From 040311c76f5f997fe4a0cc6e06e87e439ee9cbab Mon Sep 17 00:00:00 2001 From: Release Engineers Date: Mon, 26 Jan 2009 16:51:30 +0000 Subject: [PATCH 010/283] Create DEV300_m40 milestone tag from trunk@266942 From 76209b6a59fd6fdd8f2301c889989d06515fbdae Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Mon, 16 Mar 2009 12:27:57 +0000 Subject: [PATCH 011/283] #i92516# Added handlers and propery map. --- vcl/source/window/printdlg.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f87ea73f6f4f..599f27f7ae45 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -347,8 +347,10 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= bVal; pNewBox->Check( bVal ); pNewBox->Enable( maPListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); + pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) ); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); + maControlToPropertyMap[pNewBox] = aPropertyName; } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -386,8 +388,11 @@ void PrintDialog::setupOptionalUI() pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( 15, nCurY ), aFontMapMode ), aPixelSize ); pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); pBtn->Show(); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) ); + maControlToPropertyMap[pBtn] = aPropertyName; + nCurY += 12; } } @@ -444,9 +449,11 @@ void PrintDialog::setupOptionalUI() pList->SetPosSizePixel( aListPos, aPixelSize ); pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); pList->Show(); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); + maControlToPropertyMap[pList] = aPropertyName; nCurY += 16; if( bDoAlign ) From e26c7a2da1f71d947332886157b0f6b381f20d0d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 16 Mar 2009 13:18:23 +0000 Subject: [PATCH 012/283] #i92516# UI property value for lists and radio button groups is now numerical index in value list --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/source/window/printdlg.cxx | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 245d0bd9748c..0a953c5d25dc 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -132,6 +132,7 @@ namespace vcl std::list< Window* > maControls; std::map< Window*, rtl::OUString > maControlToPropertyMap; std::multimap< rtl::OUString, Window* > maPropertyToWindowMap; + std::map< Window*, sal_Int32 > maControlToNumValMap; void preparePreview(); void setPreviewText( sal_Int32 ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 599f27f7ae45..9c814da63a40 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -373,16 +373,16 @@ void PrintDialog::setupOptionalUI() } // iterate options - rtl::OUString aSelectVal; + sal_Int32 nSelectVal = 0; PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= aSelectVal; + pVal->Value >>= nSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); - pBtn->Check( aChoices[m] == aSelectVal ); + pBtn->Check( m == nSelectVal ); Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos, 12 ), aFontMapMode ) ); aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( 15, nCurY ), aFontMapMode ), @@ -392,6 +392,7 @@ void PrintDialog::setupOptionalUI() pBtn->Show(); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) ); maControlToPropertyMap[pBtn] = aPropertyName; + maControlToNumValMap[pBtn] = m; nCurY += 12; } @@ -421,11 +422,11 @@ void PrintDialog::setupOptionalUI() nMaxTextWidth = nEntryWidth; } nMaxTextWidth += 30; - rtl::OUString aSelectVal; + sal_Int32 nSelectVal = 0; PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= aSelectVal; - pList->SelectEntry( aSelectVal ); + pVal->Value >>= nSelectVal; + pList->SelectEntryPos( nSelectVal ); aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); aPixelSize.Width() = nMaxTextWidth; @@ -701,10 +702,12 @@ IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) { PropertyValue* pVal = getValueForWindow( i_pBtn ); - if( pVal ) + std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn ); + if( pVal && it != maControlToNumValMap.end() ) { - rtl::OUString aVal( i_pBtn->GetText() );; - pVal->Value <<= aVal; + + sal_Int32 nVal = it->second; + pVal->Value <<= nVal; // update preview and page settings preparePreview(); @@ -717,8 +720,8 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) PropertyValue* pVal = getValueForWindow( i_pBox ); if( pVal ) { - rtl::OUString aVal( i_pBox->GetSelectEntry() );; - pVal->Value <<= aVal; + sal_Int32 nVal( i_pBox->GetSelectEntryPos() ); + pVal->Value <<= nVal; // update preview and page settings preparePreview(); From 3c85687a7431d6cd21e09c74169258d2e4e3f2ae Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Mon, 16 Mar 2009 13:51:45 +0000 Subject: [PATCH 013/283] #i92516# Fixed minor compilation problem. --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9c814da63a40..389e7965d416 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -426,7 +426,7 @@ void PrintDialog::setupOptionalUI() PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; - pList->SelectEntryPos( nSelectVal ); + pList->SelectEntryPos( static_cast(nSelectVal) ); aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); aPixelSize.Width() = nMaxTextWidth; From 60608f2a8dbdb4fac768de164aba0ef8b1b1b0b5 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 16 Mar 2009 15:13:59 +0000 Subject: [PATCH 014/283] #i92516# add: control dependencies (round 1) --- vcl/inc/vcl/print.hxx | 1 + vcl/inc/vcl/prndlg.hxx | 1 + vcl/source/gdi/print3.cxx | 82 +++++++++++++++++++++++++++++++++- vcl/source/window/printdlg.cxx | 66 +++++++++++++++++++-------- 4 files changed, 129 insertions(+), 21 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 9249594abb87..5acb8176213a 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -456,6 +456,7 @@ public: /* get the PorpertyValue of a Property */ com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); + const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ) const; /* return the currently active UI options. These are the same passed to setUIOptions. */ diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 0a953c5d25dc..40bd28cdf5c3 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -138,6 +138,7 @@ namespace vcl void setPreviewText( sal_Int32 ); void updatePrinterText(); void checkControlDependencies(); + void checkOptionalControlDependencies(); void setupOptionalUI(); com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index bba5c5ad979f..4fd8d0581d3c 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -60,14 +60,25 @@ using namespace vcl; class vcl::ImplPrinterListenerData { public: + struct ControlDependency + { + rtl::OUString maDependsOnName; + sal_Int32 mnDependsOnEntry; + + ControlDependency() : mnDependsOnEntry( -1 ) {} + }; + + typedef std::hash_map< rtl::OUString, size_t, rtl::OUStringHash > PropertyToIndexMap; + typedef std::hash_map< rtl::OUString, ControlDependency, rtl::OUStringHash > ControlDependencyMap; boost::shared_ptr mpPrinter; MultiSelection maSelection; Sequence< PropertyValue > maUIOptions; std::vector< PropertyValue > maUIProperties; std::vector< bool > maUIPropertyEnabled; - std::hash_map< rtl::OUString, size_t, rtl::OUStringHash > maPropertyToIndex; + PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; + ControlDependencyMap maControlDependencies; }; PrinterListener::PrinterListener() @@ -448,6 +459,13 @@ com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl::OUSt return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; } +const com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl::OUString& i_rProperty ) const +{ + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + mpImplData->maPropertyToIndex.find( i_rProperty ); + return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; +} + void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rOptions ) { DBG_ASSERT( mpImplData->maUIOptions.getLength() == 0, "setUIOptions called twice !" ); @@ -463,6 +481,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO i_rOptions[i].Value >>= aOptProp; bool bIsEnabled = true; bool bHaveProperty = false; + vcl::ImplPrinterListenerData::ControlDependency aDep; for( int n = 0; n < aOptProp.getLength(); n++ ) { const beans::PropertyValue& rEntry( aOptProp[ n ] ); @@ -482,9 +501,21 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO rEntry.Value >>= bValue; bIsEnabled = bValue; } + else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) + { + rEntry.Value >>= aDep.maDependsOnName; + } + else if( rEntry.Name.equalsAscii( "DependsOnEntry" ) ) + { + rEntry.Value >>= aDep.mnDependsOnEntry; + } } if( bHaveProperty ) + { mpImplData->maUIPropertyEnabled.push_back( bIsEnabled ); + if( aDep.maDependsOnName.getLength() > 0 ) + mpImplData->maControlDependencies[ mpImplData->maUIProperties.back().Name ] = aDep; + } } } @@ -507,9 +538,56 @@ void PrinterListener::enableUIOption( const rtl::OUString& i_rProperty, bool i_b bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) const { + bool bEnabled = false; std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rProperty ); - return ((it != mpImplData->maPropertyToIndex.end()) ? mpImplData->maUIPropertyEnabled[it->second] : false); + if( it != mpImplData->maPropertyToIndex.end() ) + { + bEnabled = mpImplData->maUIPropertyEnabled[it->second]; + + if( bEnabled ) + { + // check control dependencies + vcl::ImplPrinterListenerData::ControlDependencyMap::const_iterator it = + mpImplData->maControlDependencies.find( i_rProperty ); + if( it != mpImplData->maControlDependencies.end() ) + { + // check if the dependency is enabled + // if the dependency is disabled, we are too + bEnabled = isUIOptionEnabled( it->second.maDependsOnName ); + + if( bEnabled ) + { + // does the dependency have the correct value ? + const com::sun::star::beans::PropertyValue* pVal = getValue( it->second.maDependsOnName ); + OSL_ENSURE( pVal, "unknown property in dependency" ); + if( pVal ) + { + sal_Int32 nDepVal; + sal_Bool bDepVal; + if( pVal->Value >>= nDepVal ) + { + bEnabled = (nDepVal == it->second.mnDependsOnEntry); + } + else if( pVal->Value >>= bDepVal ) + { + // could be a dependency on a checked boolean + // in this case the dependency is on a non zero for checked value + bEnabled = ( bDepVal && it->second.mnDependsOnEntry != 0) || + ( ! bDepVal && it->second.mnDependsOnEntry == 0); + } + else + { + // if the type does not match something is awry + OSL_ENSURE( 0, "strange type in control dependency" ); + bEnabled = false; + } + } + } + } + } + } + return bEnabled; } void PrinterListener::setOptionChangeHdl( const Link& i_rHdl ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 389e7965d416..afe5f699c634 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -249,7 +249,7 @@ MultiSelection PrintDialog::getPageSelection() void PrintDialog::setupOptionalUI() { Window* pCurParent = 0; - long nCurY = 0; + long nCurY = 0, nXPos = 5; USHORT nOptPageId = 9; MapMode aFontMapMode( MAP_APPFONT ); @@ -266,6 +266,7 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + bool bDependency = false; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -294,6 +295,10 @@ void PrintDialog::setupOptionalUI() rEntry.Value >>= bValue; bEnabled = bValue; } + else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) + { + bDependency = true; + } } if( aCtrlType.equalsAscii( "Group" ) || @@ -309,6 +314,7 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pNewGroup ); pCurParent = pNewGroup; nCurY = 5; + nXPos = 5; pNewGroup->SetText( aText ); maTabCtrl.InsertPage( ++nOptPageId, aText ); maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); @@ -316,6 +322,7 @@ void PrintDialog::setupOptionalUI() if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) { + nXPos = 5; FixedLine* pNewSub = new FixedLine( pCurParent ); maControls.push_front( pNewSub ); pNewSub->SetText( aText ); @@ -323,20 +330,24 @@ void PrintDialog::setupOptionalUI() Size aPixelSize( aTabSize ); aPixelSize.Width() /= 2; aPixelSize.Height() = pCurParent->GetTextHeight() + 4; - pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), aPixelSize ); pNewSub->Show(); nCurY += 12; + nXPos += 5; } else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { + if( bDependency ) + nXPos += 5; + // add a check box CheckBox* pNewBox = new CheckBox( pCurParent ); maControls.push_front( pNewBox ); pNewBox->SetText( aText ); // FIXME: measure text - pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) ); nCurY += 12; @@ -351,11 +362,13 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); maControlToPropertyMap[pNewBox] = aPropertyName; + + if( bDependency ) + nXPos -= 5; } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { - long nXPos = 5; - + long nOldXPos = nXPos; if( aText.getLength() ) { // add a FixedText: @@ -368,7 +381,7 @@ void PrintDialog::setupOptionalUI() aPixelSize ); pHeading->Show(); - nXPos = 15; + nXPos += 10; nCurY += 12; } @@ -396,16 +409,20 @@ void PrintDialog::setupOptionalUI() nCurY += 12; } + nXPos = nOldXPos; } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) { + if( bDependency ) + nXPos += 5; + // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( 5, nCurY ), aFontMapMode ), + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); @@ -464,6 +481,9 @@ void PrintDialog::setupOptionalUI() aPos.Y() += (pList->GetSizePixel().Height() - aSize.Height())/2; pHeading->SetPosSizePixel( aPos, aSize ); } + + if( bDependency ) + nXPos -= 5; } } else @@ -497,6 +517,19 @@ void PrintDialog::checkControlDependencies() maPrinterPage.maSetupButton.Enable( maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ) ); } +void PrintDialog::checkOptionalControlDependencies() +{ + for( std::map< Window*, rtl::OUString >::iterator it = maControlToPropertyMap.begin(); + it != maControlToPropertyMap.end(); ++it ) + { + bool bShouldbeEnabled = maPListener->isUIOptionEnabled( it->second ); + bool bIsEnabled = it->first->IsEnabled(); + // Enable does not do a change check first, so can be less cheap than expected + if( bShouldbeEnabled != bIsEnabled ) + it->first->Enable( bShouldbeEnabled ); + } +} + void PrintDialog::updatePrinterText() { const QueueInfo* pInfo = Printer::GetQueueInfo( maPrinterPage.maPrinters.GetSelectEntry(), true ); @@ -654,18 +687,7 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG ) IMPL_LINK( PrintDialog, UIOptionsChanged, void*, i_pOption ) { - PropertyValue* pVal = maPListener->getValue( *reinterpret_cast< rtl::OUString* >(i_pOption) ); - if( pVal ) - { - std::pair< std::multimap< rtl::OUString, Window* >::iterator, - std::multimap< rtl::OUString, Window* >::iterator > aWindows = - maPropertyToWindowMap.equal_range( pVal->Name ); - for( std::multimap< rtl::OUString, Window* >::const_iterator it = - aWindows.first; it != aWindows.second; ++it ) - { - it->second->Enable( maPListener->isUIOptionEnabled( pVal->Name ) ); - } - } + checkOptionalControlDependencies(); return 0; } @@ -693,6 +715,8 @@ IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) sal_Bool bVal = i_pBox->IsChecked(); pVal->Value <<= bVal; + checkOptionalControlDependencies(); + // update preview and page settings preparePreview(); } @@ -709,6 +733,8 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) sal_Int32 nVal = it->second; pVal->Value <<= nVal; + checkOptionalControlDependencies(); + // update preview and page settings preparePreview(); } @@ -723,6 +749,8 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) sal_Int32 nVal( i_pBox->GetSelectEntryPos() ); pVal->Value <<= nVal; + checkOptionalControlDependencies(); + // update preview and page settings preparePreview(); } From ccb652059ab56dd52dc72d91b5bc49cdbfe18d37 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 16 Mar 2009 15:22:03 +0000 Subject: [PATCH 015/283] #i92516# call handler only once for radio button change --- vcl/source/window/printdlg.cxx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index afe5f699c634..ac08b8429991 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -725,18 +725,24 @@ IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) { - PropertyValue* pVal = getValueForWindow( i_pBtn ); - std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn ); - if( pVal && it != maControlToNumValMap.end() ) + // this handler gets called for all radiobuttons that get unchecked, too + // however we only want one notificaction for the new value (that is for + // the button that gets checked) + if( i_pBtn->IsChecked() ) { + PropertyValue* pVal = getValueForWindow( i_pBtn ); + std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn ); + if( pVal && it != maControlToNumValMap.end() ) + { - sal_Int32 nVal = it->second; - pVal->Value <<= nVal; + sal_Int32 nVal = it->second; + pVal->Value <<= nVal; - checkOptionalControlDependencies(); + checkOptionalControlDependencies(); - // update preview and page settings - preparePreview(); + // update preview and page settings + preparePreview(); + } } return 0; } From 012730f704b81d31471afbe90b93915b8ce14a8d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 16 Mar 2009 17:48:45 +0000 Subject: [PATCH 016/283] #i92516# add range control --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/source/window/printdlg.cxx | 109 +++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 40bd28cdf5c3..426a9f87ed8c 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -152,6 +152,7 @@ namespace vcl DECL_LINK( UIOption_CheckHdl, CheckBox* ); DECL_LINK( UIOption_RadioHdl, RadioButton* ); DECL_LINK( UIOption_SelectHdl, ListBox* ); + DECL_LINK( UIOption_ModifyHdl, Edit* ); public: PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index ac08b8429991..24a861d4cc2f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -266,6 +266,7 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + sal_Int64 nMinValue = 0, nMaxValue = 0; bool bDependency = false; for( int n = 0; n < aOptProp.getLength(); n++ ) @@ -299,12 +300,21 @@ void PrintDialog::setupOptionalUI() { bDependency = true; } + else if( rEntry.Name.equalsAscii( "MinValue" ) ) + { + rEntry.Value >>= nMinValue; + } + else if( rEntry.Name.equalsAscii( "MaxValue" ) ) + { + rEntry.Value >>= nMaxValue; + } } if( aCtrlType.equalsAscii( "Group" ) || aCtrlType.equalsAscii( "Subgroup" ) || aCtrlType.equalsAscii( "Radio" ) || aCtrlType.equalsAscii( "List" ) || + aCtrlType.equalsAscii( "Range" ) || aCtrlType.equalsAscii( "Bool" ) ) { if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) @@ -482,6 +492,74 @@ void PrintDialog::setupOptionalUI() pHeading->SetPosSizePixel( aPos, aSize ); } + if( bDependency ) + nXPos -= 5; + } + else if( aCtrlType.equalsAscii( "Range" ) && pCurParent ) + { + if( bDependency ) + nXPos += 5; + + // add a FixedText: + FixedText* pHeading = new FixedText( pCurParent ); + maControls.push_front( pHeading ); + pHeading->SetText( aText ); + Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); + aPixelSize.Width() += pHeading->GetTextWidth( aText ); + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + aPixelSize ); + pHeading->Show(); + + NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); + maControls.push_front( pField ); + + // set min/max and current value + if( nMinValue != nMaxValue ) + { + pField->SetMin( nMinValue ); + pField->SetMax( nMaxValue ); + } + sal_Int64 nCurVal = 0; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= nCurVal; + pField->SetValue( nCurVal ); + + aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) ); + + Point aFieldPos; + bool bDoAlign = false; + if( aPixelSize.Width() < aTabSize.Width() - 10 ) + { + aFieldPos = pHeading->GetPosPixel(); + aFieldPos.X() += pHeading->GetSizePixel().Width() + 5; + + // align heading and list box + bDoAlign = true; + } + else + { + nCurY += 12; + aFieldPos = pCurParent->LogicToPixel( Point( 15, nCurY ), aFontMapMode ); + } + + pField->SetPosSizePixel( aFieldPos, aPixelSize ); + pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); + pField->Show(); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maControlToPropertyMap[pField] = aPropertyName; + nCurY += 16; + + if( bDoAlign ) + { + Point aPos = pHeading->GetPosPixel(); + Size aSize = pHeading->GetSizePixel(); + aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2; + pHeading->SetPosSizePixel( aPos, aSize ); + } + if( bDependency ) nXPos -= 5; } @@ -763,3 +841,34 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) return 0; } +IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) +{ + PropertyValue* pVal = getValueForWindow( i_pBox ); + if( pVal ) + { + NumericField* pNum = dynamic_cast(i_pBox); + MetricField* pMetric = dynamic_cast(i_pBox); + if( pNum ) + { + sal_Int64 nVal = pNum->GetValue(); + pVal->Value <<= nVal; + } + else if( pMetric ) + { + sal_Int64 nVal = pMetric->GetValue(); + pVal->Value <<= nVal; + } + else + { + rtl::OUString aVal( i_pBox->GetText() ); + pVal->Value <<= aVal; + } + + checkOptionalControlDependencies(); + + // update preview and page settings + preparePreview(); + } + return 0; +} + From 38caca6fb87a3627747266a2af766f64c456a946 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 16 Mar 2009 18:11:54 +0000 Subject: [PATCH 017/283] #i92516# reorder jobsetup and printer controls for better usability --- vcl/inc/vcl/prndlg.hxx | 3 ++- vcl/source/src/print.src | 38 ++++++++++++++++++++-------------- vcl/source/window/printdlg.cxx | 22 ++++++++++++++------ 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 426a9f87ed8c..24695cfc20b4 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -80,7 +80,6 @@ namespace vcl FixedText maLocText; FixedText maComment; FixedText maCommentText; - CheckBox maToFileBox; PrinterTabPage( Window*, const ResId& ); virtual ~PrinterTabPage(); @@ -89,6 +88,8 @@ namespace vcl class JobTabPage : public TabPage { public: + ListBox maPrinters; + CheckBox maToFileBox; FixedLine maPrintRange; RadioButton maAllButton; RadioButton maPagesButton; diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index b85783b02ddd..61913b68a730 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -145,12 +145,6 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 50, 66 ); Size = MAP_APPFONT( 200, 10 ); }; - CheckBox SV_PRINT_PRT_TOFILE - { - Pos = MAP_APPFONT( 5, 80 ); - Size = MAP_APPFONT( 200, 12 ); - Text [en-US] = "Print to file"; - }; }; TabPage SV_PRINT_TAB_JOB @@ -158,53 +152,65 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "Job Setup"; Hide = TRUE; - FixedLine SV_PRINT_RANGE + ListBox SV_PRINT_PRINTERS { Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 200 ); + DropDown = TRUE; + }; + CheckBox SV_PRINT_PRT_TOFILE + { + Pos = MAP_APPFONT( 15, 20 ); + Size = MAP_APPFONT( 200, 12 ); + Text [en-US] = "Print to file"; + }; + FixedLine SV_PRINT_RANGE + { + Pos = MAP_APPFONT( 5, 30 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Print range"; }; RadioButton SV_PRINT_ALL { - Pos = MAP_APPFONT( 10, 15 ); + Pos = MAP_APPFONT( 10, 40 ); Size = MAP_APPFONT( 145, 15 ); Text [en-US] = "All pages"; Check = TRUE; }; RadioButton SV_PRINT_PAGERANGE { - Pos = MAP_APPFONT( 10, 30 ); + Pos = MAP_APPFONT( 10, 55 ); Size = MAP_APPFONT( 60, 15 ); Text [en-US] = "Pages"; }; Edit SV_PRINT_PAGERANGE_EDIT { - Pos = MAP_APPFONT( 70, 30 ); + Pos = MAP_APPFONT( 70, 55 ); Size = MAP_APPFONT( 80, 15 ); Border = TRUE; }; RadioButton SV_PRINT_SELECTION { - Pos = MAP_APPFONT( 10, 45 ); + Pos = MAP_APPFONT( 10, 70 ); Size = MAP_APPFONT( 145, 15 ); Text [en-US] = "Selection"; }; FixedLine SV_PRINT_COPIES { - Pos = MAP_APPFONT( 5, 70 ); + Pos = MAP_APPFONT( 5, 90 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Copies"; }; FixedText SV_PRINT_COPYCOUNT { - Pos = MAP_APPFONT( 10, 80 ); + Pos = MAP_APPFONT( 10, 100 ); Size = MAP_APPFONT( 80, 10 ); Text [en-US] = "Number of copies"; }; NumericField SV_PRINT_COPYCOUNT_FIELD { - Pos = MAP_APPFONT( 90, 80 ); + Pos = MAP_APPFONT( 90, 100 ); Size = MAP_APPFONT( 40, 10 ); Border = TRUE; Spin = TRUE; @@ -214,12 +220,12 @@ ModalDialog SV_DLG_PRINT }; FixedImage SV_PRINT_COLLATE_IMAGE { - Pos = MAP_APPFONT( 10, 100 ); + Pos = MAP_APPFONT( 10, 120 ); Size = MAP_PIXEL( 80, 30 ); }; CheckBox SV_PRINT_COLLATE { - Pos = MAP_APPFONT( 80, 100 ); + Pos = MAP_APPFONT( 80, 120 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 24a861d4cc2f..e078063dc57b 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -89,7 +89,6 @@ PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rRe , maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) ) , maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) ) , maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) ) - , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) { FreeResource(); } @@ -100,6 +99,8 @@ PrintDialog::PrinterTabPage::~PrinterTabPage() PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) + , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) + , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) , maPrintRange( this, VclResId( SV_PRINT_RANGE ) ) , maAllButton( this, VclResId( SV_PRINT_ALL ) ) , maPagesButton( this, VclResId( SV_PRINT_PAGERANGE ) ) @@ -140,10 +141,10 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) + { maPrinterPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); + maJobPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); + } else { // fall back to default printer maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); + maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); maPListener->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); } // update the text fields for the printer @@ -177,6 +183,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrGetSelectEntry() ); + maJobPage.maPrinters.SelectEntry( aNewPrinter ); + maPrinterPage.maPrinters.SelectEntry( aNewPrinter ); // set new printer - maPListener->setPrinter( boost::shared_ptr( new Printer( maPrinterPage.maPrinters.GetSelectEntry() ) ) ); + maPListener->setPrinter( boost::shared_ptr( new Printer( aNewPrinter ) ) ); // update text fields updatePrinterText(); } From 5783a05227e2cd847680dc731c65c8f8e0587a15 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 17 Mar 2009 12:27:26 +0000 Subject: [PATCH 018/283] #i92516# make dialog resizeable --- vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/src/print.src | 2 +- vcl/source/window/printdlg.cxx | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 24695cfc20b4..a42b36dee61a 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -143,6 +143,8 @@ namespace vcl void setupOptionalUI(); com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; + virtual void Resize(); + DECL_LINK( ScrollHdl, ScrollBar* ); DECL_LINK( ScrollEndHdl, ScrollBar* ); DECL_LINK( SelectHdl, ListBox* ); diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 61913b68a730..cd214dbfd77c 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -34,7 +34,7 @@ ModalDialog SV_DLG_PRINT { Text [en-US] = "Printing"; Closeable = TRUE; - Sizeable = FALSE; + Sizeable = TRUE; Moveable = TRUE; SVLook = TRUE; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index e078063dc57b..1b8e044658a7 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -211,6 +211,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); + // set min size pixel to current size + SetMinOutputSizePixel( GetOutputSizePixel() ); + // setup dependencies checkControlDependencies(); } @@ -882,3 +885,55 @@ IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) return 0; } +void PrintDialog::Resize() +{ + Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + Size aWindowSize( GetOutputSizePixel() ); + + // position buttons from lower end, right to left + Size aBtnSize( maCancelButton.GetSizePixel() ); + Rectangle aBtnRect( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(), + aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ), + aBtnSize ); + maCancelButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + aBtnSize = maOKButton.GetSizePixel(); + aBtnRect = Rectangle( Point( aBtnRect.Left() - aPixDiff.Width() - aBtnSize.Width(), + aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ), + aBtnSize ); + maOKButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + aBtnSize = maButtonLine.GetSizePixel(); + + // position fixed line above buttons + aBtnRect = Rectangle( Point( 0, aBtnRect.Top() - aPixDiff.Width() - aBtnSize.Height()/2 ), + Size( aWindowSize.Width(), aBtnSize.Height() ) ); + maButtonLine.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + + // position tab control on upper right + aBtnSize = maTabCtrl.GetSizePixel(); + aBtnRect = Rectangle( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(), + aPixDiff.Height() ), + Size( aBtnSize.Width(), maButtonLine.GetPosPixel().Y() - 2*aPixDiff.Height() ) ); + maTabCtrl.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + + // set size for preview + long nMaxX = maTabCtrl.GetPosPixel().X() - 2*aPixDiff.Width(); + long nMaxY = maButtonLine.GetPosPixel().Y() + - 2 * aPixDiff.Height() + - maPageText.GetSizePixel().Height() + - maPageScrollbar.GetSizePixel().Height(); + long nPreviewLength = std::min( nMaxX, nMaxY ); + maPreviewSpace = Rectangle( Point( aPixDiff.Width(), aPixDiff.Height() ), + Size( nPreviewLength, nPreviewLength ) ); + + // position text and scrollbar below preview + aBtnRect = Rectangle( Point( aPixDiff.Width(), 2*aPixDiff.Height() + nPreviewLength ), + Size( nPreviewLength, maPageScrollbar.GetSizePixel().Height() ) ); + maPageScrollbar.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + + aBtnRect.Top() = aBtnRect.Bottom() + aPixDiff.Height()/2; + aBtnRect.Bottom() = aBtnRect.Top() + maPageText.GetSizePixel().Height() - 1; + maPageText.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + + // and do the preview + preparePreview(); +} From 26b3a7682ef493f20c59ae583345fcf6cc58f3d4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 14:46:10 +0000 Subject: [PATCH 019/283] #i92516# add progress during printing --- vcl/aqua/source/gdi/salprn.cxx | 2 +- vcl/inc/vcl/print.hxx | 6 +-- vcl/inc/vcl/prndlg.hxx | 25 ++++++++++ vcl/inc/vcl/svids.hrc | 4 ++ vcl/source/gdi/print3.cxx | 21 +++++++++ vcl/source/src/print.src | 24 ++++++++++ vcl/source/window/printdlg.cxx | 86 ++++++++++++++++++++++++++++++++++ 7 files changed, 164 insertions(+), 4 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 7c24e5098f2d..959d421ae978 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -511,7 +511,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, NSObject* pReleaseAfterUse = nil; bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; - [pPrintOperation setShowsProgressPanel: bShowPanel ? YES : NO]; + [pPrintOperation setShowsProgressPanel: YES]; if( bShowPanel ) pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener]; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 5acb8176213a..5f53dd6e4a28 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -483,12 +483,12 @@ public: virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app virtual void jobFinished(); // optionally release resources bound to the job - void printFilteredPage( int i_nPage ); - - // implementation details, not usable outsid vcl + // implementation details, not usable outside vcl + void SAL_DLLPRIVATE printFilteredPage( int i_nPage ); void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); void SAL_DLLPRIVATE setPageSelection( const MultiSelection& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); + void SAL_DLLPRIVATE createProgressDialog(); }; } diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index a42b36dee61a..b832156891ed 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -166,6 +166,31 @@ namespace vcl int getCopyCount(); bool isCollate(); }; + + class PrintProgressDialog : public ModelessDialog + { + String maStr; + FixedText maText; + CancelButton maButton; + + bool mbCanceled; + int mnCur; + int mnMax; + Rectangle maProgressRect; + + DECL_LINK( ClickHdl, Button* ); + + void implCalcProgressRect(); + public: + PrintProgressDialog( Window* i_pParent, int i_nMax ); + ~PrintProgressDialog(); + + void isCanceled(); + void setProgress( int i_nCurrent, int i_nMax = -1 ); + void tick(); + + virtual void Paint( const Rectangle& ); + }; } diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index da34f04abd2c..ef4b021e1919 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -95,6 +95,10 @@ #define SV_PRINT_PRT_TOFILE 10 #define SV_PRINT_PRT_SETUP 11 +#define SV_DLG_PRINT_PROGRESS 2048 +#define SV_PRINT_PROGRESS_CANCEL 1 +#define SV_PRINT_PROGRESS_TEXT 2 + #define SV_PRINT_TAB_JOB 2 #define SV_PRINT_RANGE 1 #define SV_PRINT_ALL 2 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 4fd8d0581d3c..eb6a05e4e78e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -79,6 +79,11 @@ public: PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; + + vcl::PrintProgressDialog* mpProgress; + + ImplPrinterListenerData() : mpProgress( NULL ) {} + ~ImplPrinterListenerData() { delete mpProgress; } }; PrinterListener::PrinterListener() @@ -315,6 +320,7 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrgetPageSelection() ); + i_pListener->createProgressDialog(); for( long nPage = aSel.FirstSelected(); nPage != long(SFX_ENDOFSELECTION); nPage = aSel.NextSelected() ) { // remember MultiSelection is 1 based (due to user input) @@ -386,6 +392,13 @@ static void modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& void PrinterListener::printFilteredPage( int i_nPage ) { + // update progress if necessary + if( mpImplData->mpProgress ) + { + mpImplData->mpProgress->tick(); + Application::Reschedule( true ); + } + // get page parameters Sequence< PropertyValue > aPageParm( getPageParameters( i_nPage ) ); const MapMode aMapMode( MAP_100TH_MM ); @@ -595,3 +608,11 @@ void PrinterListener::setOptionChangeHdl( const Link& i_rHdl ) mpImplData->maOptionChangeHdl = i_rHdl; } +void PrinterListener::createProgressDialog() +{ + if( ! mpImplData->mpProgress ) + { + mpImplData->mpProgress = new PrintProgressDialog( NULL, mpImplData->maSelection.GetSelectCount() ); + mpImplData->mpProgress->Show(); + } +} diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index cd214dbfd77c..eebcdfd02298 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -251,3 +251,27 @@ ModalDialog SV_DLG_PRINT }; }; }; + +ModelessDialog SV_DLG_PRINT_PROGRESS +{ + Text [en-US] = "Printing"; + Closeable = FALSE; + Sizeable = FALSE; + Moveable = TRUE; + SVLook = TRUE; + + Size = MAP_APPFONT( 150, 100 ); + + CancelButton SV_PRINT_PROGRESS_CANCEL + { + Pos = MAP_APPFONT( 50, 80 ); + Size = MAP_APPFONT( 50, 15 ); + }; + FixedText SV_PRINT_PAGE_TXT + { + Pos = MAP_APPFONT( 5,10 ); + Size = MAP_APPFONT( 140, 10 ); + Text [ en-US ] = "Page %p of %n"; + Center = TRUE; + }; +}; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1b8e044658a7..b7ef34578964 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -38,6 +38,7 @@ #include "vcl/svids.hrc" #include "vcl/wall.hxx" #include "vcl/jobset.h" +#include "vcl/status.hxx" #include "rtl/ustrbuf.hxx" @@ -937,3 +938,88 @@ void PrintDialog::Resize() // and do the preview preparePreview(); } + +// ----------------------------------------------------------------------------- +// +// PrintProgressDialog +// +// ----------------------------------------------------------------------------- + +PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) : + ModelessDialog( i_pParent, VclResId( SV_DLG_PRINT_PROGRESS ) ), + maText( this, VclResId( SV_PRINT_PROGRESS_TEXT ) ), + maButton( this, VclResId( SV_PRINT_PROGRESS_CANCEL ) ), + mbCanceled( false ), + mnCur( 0 ), + mnMax( i_nMax ) +{ + maStr = maText.GetText(); + + maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) ); + +} + +PrintProgressDialog::~PrintProgressDialog() +{ +} + +IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton ) +{ + if( pButton == &maButton ) + mbCanceled = true; + + return 0; +} + +void PrintProgressDialog::implCalcProgressRect() +{ + long nProgressHeight = 15; + if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) + { + ImplControlValue aValue; + Region aControlRegion( Rectangle( Point(), Size( 100, nProgressHeight ) ) ); + Region aNativeControlRegion, aNativeContentRegion; + if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, + CTRL_STATE_ENABLED, aValue, rtl::OUString(), + aNativeControlRegion, aNativeContentRegion ) ) + { + nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + } + } + maProgressRect = Rectangle( Point( 10, maText.GetPosPixel().Y() + maText.GetSizePixel().Height() + 8 ), + Size( GetSizePixel().Width() - 20, nProgressHeight ) ); +} + +void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) +{ + mnCur = i_nCurrent; + if( i_nMax != -1 ) + mnMax = i_nMax; + + rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur+1 ) ); + aNewText = searchAndReplace( aNewText, "%n", 2, mnMax ); + maText.SetText( aNewText ); + + // update progress + Invalidate(); +} + +void PrintProgressDialog::tick() +{ + if( mnCur < mnMax ) + setProgress( ++mnCur ); +} + +void PrintProgressDialog::Paint( const Rectangle& i_rRect ) +{ + DrawProgress( this, maProgressRect.TopLeft(), + 0, + maProgressRect.GetWidth(), + maProgressRect.GetHeight(), + static_cast(0), + static_cast(mnCur), + static_cast(mnMax), + maProgressRect + ); + +} From f234c2134928e11c9e08e4c97fd4e725e4675320 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 14:52:24 +0000 Subject: [PATCH 020/283] fix some warnings --- vcl/source/gdi/print3.cxx | 6 +++--- vcl/source/window/printdlg.cxx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index eb6a05e4e78e..dd5de1b70482 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -552,11 +552,11 @@ void PrinterListener::enableUIOption( const rtl::OUString& i_rProperty, bool i_b bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) const { bool bEnabled = false; - std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator prop_it = mpImplData->maPropertyToIndex.find( i_rProperty ); - if( it != mpImplData->maPropertyToIndex.end() ) + if( prop_it != mpImplData->maPropertyToIndex.end() ) { - bEnabled = mpImplData->maUIPropertyEnabled[it->second]; + bEnabled = mpImplData->maUIPropertyEnabled[prop_it->second]; if( bEnabled ) { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b7ef34578964..a70e205dc9da 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -777,7 +777,7 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG ) return 0; } -IMPL_LINK( PrintDialog, UIOptionsChanged, void*, i_pOption ) +IMPL_LINK( PrintDialog, UIOptionsChanged, void*, EMPTYARG ) { checkOptionalControlDependencies(); return 0; @@ -1010,7 +1010,7 @@ void PrintProgressDialog::tick() setProgress( ++mnCur ); } -void PrintProgressDialog::Paint( const Rectangle& i_rRect ) +void PrintProgressDialog::Paint( const Rectangle& ) { DrawProgress( this, maProgressRect.TopLeft(), 0, From 293e5da2a08ee302ead25400eea0b6f95d35c36e Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 16:16:06 +0000 Subject: [PATCH 021/283] #i92516# add progress during printing --- vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/src/print.src | 8 ++--- vcl/source/window/printdlg.cxx | 53 ++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index b832156891ed..11ec85c37174 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -176,7 +176,9 @@ namespace vcl bool mbCanceled; int mnCur; int mnMax; + long mnProgressHeight; Rectangle maProgressRect; + bool mbNativeProgress; DECL_LINK( ClickHdl, Button* ); diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index eebcdfd02298..e8543515d68c 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -260,17 +260,17 @@ ModelessDialog SV_DLG_PRINT_PROGRESS Moveable = TRUE; SVLook = TRUE; - Size = MAP_APPFONT( 150, 100 ); + Size = MAP_APPFONT( 120, 70 ); CancelButton SV_PRINT_PROGRESS_CANCEL { - Pos = MAP_APPFONT( 50, 80 ); + Pos = MAP_APPFONT( 35, 50 ); Size = MAP_APPFONT( 50, 15 ); }; - FixedText SV_PRINT_PAGE_TXT + FixedText SV_PRINT_PROGRESS_TEXT { Pos = MAP_APPFONT( 5,10 ); - Size = MAP_APPFONT( 140, 10 ); + Size = MAP_APPFONT( 110, 10 ); Text [ en-US ] = "Page %p of %n"; Center = TRUE; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a70e205dc9da..3d543715532a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -39,6 +39,7 @@ #include "vcl/wall.hxx" #include "vcl/jobset.h" #include "vcl/status.hxx" +#include "vcl/decoview.hxx" #include "rtl/ustrbuf.hxx" @@ -951,7 +952,9 @@ PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) : maButton( this, VclResId( SV_PRINT_PROGRESS_CANCEL ) ), mbCanceled( false ), mnCur( 0 ), - mnMax( i_nMax ) + mnMax( i_nMax ), + mnProgressHeight( 15 ), + mbNativeProgress( false ) { maStr = maText.GetText(); @@ -973,35 +976,38 @@ IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton ) void PrintProgressDialog::implCalcProgressRect() { - long nProgressHeight = 15; if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) ) { ImplControlValue aValue; - Region aControlRegion( Rectangle( Point(), Size( 100, nProgressHeight ) ) ); + Region aControlRegion( Rectangle( Point(), Size( 100, mnProgressHeight ) ) ); Region aNativeControlRegion, aNativeContentRegion; if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion, CTRL_STATE_ENABLED, aValue, rtl::OUString(), aNativeControlRegion, aNativeContentRegion ) ) { - nProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); + mnProgressHeight = aNativeControlRegion.GetBoundRect().GetHeight(); } + mbNativeProgress = true; } maProgressRect = Rectangle( Point( 10, maText.GetPosPixel().Y() + maText.GetSizePixel().Height() + 8 ), - Size( GetSizePixel().Width() - 20, nProgressHeight ) ); + Size( GetSizePixel().Width() - 20, mnProgressHeight ) ); } void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) { + if( maProgressRect.IsEmpty() ) + implCalcProgressRect(); + mnCur = i_nCurrent; if( i_nMax != -1 ) mnMax = i_nMax; - rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur+1 ) ); + rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur ) ); aNewText = searchAndReplace( aNewText, "%n", 2, mnMax ); maText.SetText( aNewText ); // update progress - Invalidate(); + Invalidate( INVALIDATE_UPDATE | INVALIDATE_CHILDREN ); } void PrintProgressDialog::tick() @@ -1012,14 +1018,37 @@ void PrintProgressDialog::tick() void PrintProgressDialog::Paint( const Rectangle& ) { + Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + Color aPrgsColor = rStyleSettings.GetHighlightColor(); + if ( aPrgsColor == rStyleSettings.GetFaceColor() ) + aPrgsColor = rStyleSettings.GetDarkShadowColor(); + SetLineColor(); + SetFillColor( aPrgsColor ); + + const int nOffset = 3; + const long nWidth = 3*mnProgressHeight/2; + const long nFullWidth = nWidth + nOffset; + const long nMaxCount = maProgressRect.GetWidth() / nFullWidth; DrawProgress( this, maProgressRect.TopLeft(), - 0, - maProgressRect.GetWidth(), - maProgressRect.GetHeight(), + nOffset, + nWidth, + mnProgressHeight, static_cast(0), - static_cast(mnCur), - static_cast(mnMax), + static_cast(10000*mnCur/mnMax), + static_cast(10000/nMaxCount), maProgressRect ); + Pop(); + if( ! mbNativeProgress ) + { + DecorationView aDecoView( this ); + Rectangle aFrameRect( maProgressRect ); + aFrameRect.Left() -= nOffset; + aFrameRect.Right() += nOffset; + aFrameRect.Top() -= nOffset; + aFrameRect.Bottom() += nOffset; + aDecoView.DrawFrame( aFrameRect ); + } } From bc2ad9920bb0d88a9058a57364335938cfee99c7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 17:58:15 +0000 Subject: [PATCH 022/283] #i92516# filter transparencies, react on user cancel --- vcl/inc/vcl/prndlg.hxx | 2 +- vcl/source/gdi/print3.cxx | 68 +++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 11ec85c37174..cba6b59e81f5 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -187,7 +187,7 @@ namespace vcl PrintProgressDialog( Window* i_pParent, int i_nMax ); ~PrintProgressDialog(); - void isCanceled(); + bool isCanceled() const { return mbCanceled; } void setProgress( int i_nCurrent, int i_nMax = -1 ); void tick(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index dd5de1b70482..887fa2ce39dd 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -395,6 +395,9 @@ void PrinterListener::printFilteredPage( int i_nPage ) // update progress if necessary if( mpImplData->mpProgress ) { + // do nothing if printing is canceled + if( mpImplData->mpProgress->isCanceled() ) + return; mpImplData->mpProgress->tick(); Application::Reschedule( true ); } @@ -411,16 +414,65 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->EnableOutput( FALSE ); - GDIMetaFile aMtf; - aMtf.Record( mpImplData->mpPrinter.get() ); + GDIMetaFile aPageFile; + aPageFile.Record( mpImplData->mpPrinter.get() ); printPage( i_nPage ); - aMtf.Stop(); - aMtf.WindStart(); + aPageFile.Stop(); + aPageFile.WindStart(); mpImplData->mpPrinter->Pop(); - // FIXME: do transparency filtering here when vcl92 is integrated + ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); + sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); + sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); + + const PrinterOptions& rPrinterOptions = mpImplData->mpPrinter->GetPrinterOptions(); + + static const sal_Int32 OPTIMAL_BMP_RESOLUTION = 300; + static const sal_Int32 NORMAL_BMP_RESOLUTION = 200; + + + if( rPrinterOptions.IsReduceBitmaps() ) + { + // calculate maximum resolution for bitmap graphics + if( PRINTER_BITMAP_OPTIMAL == rPrinterOptions.GetReducedBitmapMode() ) + { + nMaxBmpDPIX = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIX ); + nMaxBmpDPIY = std::min( sal_Int32(OPTIMAL_BMP_RESOLUTION), nMaxBmpDPIY ); + } + else if( PRINTER_BITMAP_NORMAL == rPrinterOptions.GetReducedBitmapMode() ) + { + nMaxBmpDPIX = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIX ); + nMaxBmpDPIY = std::min( sal_Int32(NORMAL_BMP_RESOLUTION), nMaxBmpDPIY ); + } + else + { + nMaxBmpDPIX = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIX ); + nMaxBmpDPIY = std::min( sal_Int32(rPrinterOptions.GetReducedBitmapResolution()), nMaxBmpDPIY ); + } + } + + // convert to greysacles + if( rPrinterOptions.IsConvertToGreyscales() ) + { + mpImplData->mpPrinter->SetDrawMode( mpImplData->mpPrinter->GetDrawMode() | + ( DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_GRAYTEXT | + DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT ) ); + } + + // disable transparency output + if( rPrinterOptions.IsReduceTransparency() && ( PRINTER_TRANSPARENCY_NONE == rPrinterOptions.GetReducedTransparencyMode() ) ) + { + mpImplData->mpPrinter->SetDrawMode( mpImplData->mpPrinter->GetDrawMode() | DRAWMODE_NOTRANSPARENCY ); + } + + GDIMetaFile aCleanedFile; + mpImplData->mpPrinter->RemoveTransparenciesFromMetaFile( aPageFile, aCleanedFile, nMaxBmpDPIX, nMaxBmpDPIY, + rPrinterOptions.IsReduceTransparency(), + rPrinterOptions.GetReducedTransparencyMode() == PRINTER_TRANSPARENCY_AUTO, + rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency() + ); mpImplData->mpPrinter->EnableOutput( TRUE ); @@ -429,11 +481,13 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->Push(); mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); - aMtf.WindStart(); - aMtf.Play( mpImplData->mpPrinter.get() ); + aCleanedFile.WindStart(); + aCleanedFile.Play( mpImplData->mpPrinter.get() ); mpImplData->mpPrinter->Pop(); mpImplData->mpPrinter->EndPage(); + + mpImplData->mpPrinter->SetDrawMode( nRestoreDrawMode ); } void PrinterListener::jobFinished() From 66aed8209ab069db511c8007f7bb3ce99a77814b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 18:04:53 +0000 Subject: [PATCH 023/283] #i92516# less flicker --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 3d543715532a..17e6bcd15668 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1007,7 +1007,7 @@ void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) maText.SetText( aNewText ); // update progress - Invalidate( INVALIDATE_UPDATE | INVALIDATE_CHILDREN ); + Invalidate( maProgressRect, INVALIDATE_UPDATE ); } void PrintProgressDialog::tick() From c5046bc3c7966022c3688e930f0a8937e9cc563b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 18 Mar 2009 18:05:51 +0000 Subject: [PATCH 024/283] #i92516# avoid warning --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 17e6bcd15668..739e9c036794 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1026,7 +1026,7 @@ void PrintProgressDialog::Paint( const Rectangle& ) SetLineColor(); SetFillColor( aPrgsColor ); - const int nOffset = 3; + const long nOffset = 3; const long nWidth = 3*mnProgressHeight/2; const long nFullWidth = nWidth + nOffset; const long nMaxCount = maProgressRect.GetWidth() / nFullWidth; From 59637e019af5e391557f4a897c64d5bb0744f662 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 21 Mar 2009 14:18:07 +0000 Subject: [PATCH 025/283] solve a warning --- vcl/source/gdi/print3.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 887fa2ce39dd..88a4606dfd1a 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -630,8 +630,8 @@ bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) cons OSL_ENSURE( pVal, "unknown property in dependency" ); if( pVal ) { - sal_Int32 nDepVal; - sal_Bool bDepVal; + sal_Int32 nDepVal = 0; + sal_Bool bDepVal = sal_False; if( pVal->Value >>= nDepVal ) { bEnabled = (nDepVal == it->second.mnDependsOnEntry); From 26be0416191c63110e51077f70c1df99ddb7525b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 24 Mar 2009 13:59:11 +0000 Subject: [PATCH 026/283] #i92516# page selection needs to be handled by application --- vcl/inc/vcl/print.hxx | 4 +--- vcl/inc/vcl/prndlg.hxx | 3 --- vcl/source/gdi/print3.cxx | 43 ++++++++++++++++------------------ vcl/source/window/printdlg.cxx | 28 +++++++++++----------- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index cf491dc1b4f6..66a17a14bc81 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -445,8 +445,6 @@ public: virtual ~PrinterListener(); const boost::shared_ptr& getPrinter() const; - const MultiSelection& getPageSelection() const; - /* for implementations: get current job properties as changed by e.g. print dialog this gets the current set of properties initially told to Printer::PrintJob @@ -489,9 +487,9 @@ public: // implementation details, not usable outside vcl void SAL_DLLPRIVATE printFilteredPage( int i_nPage ); void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); - void SAL_DLLPRIVATE setPageSelection( const MultiSelection& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); void SAL_DLLPRIVATE createProgressDialog(); + void SAL_DLLPRIVATE setPrintSelection( const rtl::OUString& ); }; } diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index cba6b59e81f5..3802818a3bc2 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -46,8 +46,6 @@ #include "vcl/tabctrl.hxx" #include "vcl/tabpage.hxx" -#include "tools/multisel.hxx" - #include #include @@ -162,7 +160,6 @@ namespace vcl virtual ~PrintDialog(); bool isPrintToFile(); - MultiSelection getPageSelection(); int getCopyCount(); bool isCollate(); }; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 88a4606dfd1a..6400320e0d3e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -39,7 +39,6 @@ #include "vcl/svids.hrc" #include "tools/urlobj.hxx" -#include "tools/multisel.hxx" #include "com/sun/star/ui/dialogs/XFilePicker.hpp" #include "com/sun/star/ui/dialogs/XFilterManager.hpp" @@ -72,17 +71,20 @@ public: typedef std::hash_map< rtl::OUString, ControlDependency, rtl::OUStringHash > ControlDependencyMap; boost::shared_ptr mpPrinter; - MultiSelection maSelection; Sequence< PropertyValue > maUIOptions; std::vector< PropertyValue > maUIProperties; std::vector< bool > maUIPropertyEnabled; PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; + rtl::OUString maSelectionString; vcl::PrintProgressDialog* mpProgress; - ImplPrinterListenerData() : mpProgress( NULL ) {} + ImplPrinterListenerData() : + maSelectionString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ), + mpProgress( NULL ) + {} ~ImplPrinterListenerData() { delete mpProgress; } }; @@ -189,12 +191,6 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene boost::shared_ptr pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); pListener->setPrinter( pPrinter ); - // setup page range selection - MultiSelection aSel; - int nPages = i_pListener->getPageCount(); - aSel.SetTotalRange( Range( 1, nPages ) ); - aSel.SelectAll(); - // check if the printer brings up its own dialog // in that case leave the work to that dialog if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) ) @@ -212,7 +208,6 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->getPrinter()->EnablePrintFile( TRUE ); pListener->getPrinter()->SetPrintFile( aFile ); } - aSel = aDlg.getPageSelection(); pListener->getPrinter()->SetCopyCount( static_cast(aDlg.getCopyCount()), aDlg.isCollate() ); } catch( std::bad_alloc& ) @@ -220,7 +215,6 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene } } - pListener->setPageSelection( aSel ); pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ), pListener ); @@ -319,12 +313,12 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrgetPageSelection() ); i_pListener->createProgressDialog(); - for( long nPage = aSel.FirstSelected(); nPage != long(SFX_ENDOFSELECTION); nPage = aSel.NextSelected() ) + int nPages = i_pListener->getPageCount(); + for( int nPage = 0; nPage < nPages; nPage++ ) { // remember MultiSelection is 1 based (due to user input) - i_pListener->printFilteredPage( static_cast(nPage-1) ); + i_pListener->printFilteredPage( nPage ); } EndJob(); } @@ -356,19 +350,14 @@ const boost::shared_ptr& PrinterListener::getPrinter() const return mpImplData->mpPrinter; } -const MultiSelection& PrinterListener::getPageSelection() const -{ - return mpImplData->maSelection; -} - void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; } -void PrinterListener::setPageSelection( const MultiSelection& i_rSel ) +void PrinterListener::setPrintSelection( const rtl::OUString& i_rSel ) { - mpImplData->maSelection = i_rSel; + mpImplData->maSelectionString = i_rSel; } static void modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) @@ -497,7 +486,7 @@ void PrinterListener::jobFinished() Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; - size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size(); + size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 1; for( int i = 0; i < i_rMergeList.getLength(); i++ ) aMergeSet.insert( i_rMergeList[i].Name ); @@ -510,6 +499,14 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro if( aMergeSet.find( mpImplData->maUIProperties[i].Name ) == aMergeSet.end() ) aResult[nCur++] = mpImplData->maUIProperties[i]; } + // append page selection + if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelection" ) ) ) == aMergeSet.end() ) + { + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelection" ) ); + aVal.Value <<= mpImplData->maSelectionString; + aResult[nCur++] = aVal; + } aResult.realloc( nCur ); return aResult; } @@ -666,7 +663,7 @@ void PrinterListener::createProgressDialog() { if( ! mpImplData->mpProgress ) { - mpImplData->mpProgress = new PrintProgressDialog( NULL, mpImplData->maSelection.GetSelectCount() ); + mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCount() ); mpImplData->mpProgress->Show(); } } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 739e9c036794..f64d07a0f03f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -244,20 +244,6 @@ bool PrintDialog::isCollate() return maJobPage.maCopyCountField.GetValue() > 1 ? maJobPage.maCollateBox.IsChecked() : FALSE; } -MultiSelection PrintDialog::getPageSelection() -{ - if( maJobPage.maPagesButton.IsChecked() ) - return MultiSelection( maJobPage.maPagesEdit.GetText() ); - else if( maJobPage.maAllButton.IsChecked() ) - { - MultiSelection aSel( Range( 1, maPListener->getPageCount() ) ); - aSel.SelectAll(); - return aSel; - } - DBG_ERROR( "NYI: Selection" ); - return MultiSelection(); -} - void PrintDialog::setupOptionalUI() { Window* pCurParent = 0; @@ -769,6 +755,20 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maPListener->getPrinter()->Setup( this ); } checkControlDependencies(); + if( ( pButton == &maJobPage.maAllButton || + pButton == &maJobPage.maPagesButton || + pButton == &maJobPage.maSelectionButton ) + && ((CheckBox*)pButton)->IsChecked() ) + { + if( pButton == &maJobPage.maAllButton ) + maPListener->setPrintSelection( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ); + else if( pButton == &maJobPage.maPagesButton ) + maPListener->setPrintSelection( maJobPage.maPagesEdit.GetText() ); + else + maPListener->setPrintSelection( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "selection" ) ) ); + + preparePreview(); + } return 0; } From f55d6646b5ad5051ca9a8c2dd97c2309bbed1782 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 24 Mar 2009 14:21:10 +0000 Subject: [PATCH 027/283] #i92516# paper orientation, free resource of progress dialog --- vcl/source/gdi/print.cxx | 2 ++ vcl/source/window/printdlg.cxx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index e8a1f5b32213..f3a89f6b6b23 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1031,6 +1031,7 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) { pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.m_nPaperWidth*100, rPaperInfo.m_nPaperHeight*100 ); + pSetupData->meOrientation = ORIENTATION_PORTRAIT; break; } } @@ -1053,6 +1054,7 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) { pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.m_nPaperWidth*100, rPaperInfo.m_nPaperHeight*100 ); + pSetupData->meOrientation = ORIENTATION_LANDSCAPE; break; } } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f64d07a0f03f..996b1d59d438 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -956,6 +956,8 @@ PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) : mnProgressHeight( 15 ), mbNativeProgress( false ) { + FreeResource(); + maStr = maText.GetText(); maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) ); From e9851ccef51bbecc4a7e3bc0ccc78e4a448de88b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 24 Mar 2009 17:51:00 +0000 Subject: [PATCH 028/283] #i91478# change to latest property changes --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 74 +++++++++++++++---- vcl/aqua/source/gdi/salprn.cxx | 3 +- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index b7aa9f660dbd..8c695e2ed0c4 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -118,7 +118,8 @@ class ListenerProperties { vcl::PrinterListener* mpListener; std::map< int, rtl::OUString > maTagToPropertyName; - std::map< int, rtl::OUString > maTagToValueName; + std::map< int, sal_Int32 > maTagToValueInt; + std::vector< NSObject* > maViews; int mnNextTag; public: ListenerProperties( vcl::PrinterListener* i_pListener ) @@ -128,6 +129,9 @@ class ListenerProperties void updatePrintJob() { // TODO: refresh page count etc from mpListener + + // page range may have changed depending on options + /*sal_Int32 nPages = */mpListener->getPageCount(); } int addNameTag( const rtl::OUString& i_rPropertyName ) @@ -137,19 +141,24 @@ class ListenerProperties return nNewTag; } - int addNameAndValueTag( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rValue ) + int addNameAndValueTag( const rtl::OUString& i_rPropertyName, sal_Int32 i_nValue ) { int nNewTag = mnNextTag++; maTagToPropertyName[ nNewTag ] = i_rPropertyName; - maTagToValueName[ nNewTag ] = i_rValue; + maTagToValueInt[ nNewTag ] = i_nValue; return nNewTag; } - void changePropertyWithNamedValue( int i_nTag ) + void addObservedControl( NSObject* i_pView ) + { + maViews.push_back( i_pView ); + } + + void changePropertyWithIntValue( int i_nTag ) { std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); - std::map< int, rtl::OUString >::const_iterator value_it = maTagToValueName.find( i_nTag ); - if( name_it != maTagToPropertyName.end() && value_it != maTagToValueName.end() ) + std::map< int, sal_Int32 >::const_iterator value_it = maTagToValueInt.find( i_nTag ); + if( name_it != maTagToPropertyName.end() && value_it != maTagToValueInt.end() ) { PropertyValue* pVal = mpListener->getValue( name_it->second ); if( pVal ) @@ -163,7 +172,7 @@ class ListenerProperties void changePropertyWithBoolValue( int i_nTag, sal_Bool i_bValue ) { std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); - if( name_it != maTagToPropertyName.end() ) + if( name_it != maTagToPropertyName.end() ) { PropertyValue* pVal = mpListener->getValue( name_it->second ); if( pVal ) @@ -173,6 +182,34 @@ class ListenerProperties } } } + + void updateEnableState() + { + for( std::vector< NSObject* >::iterator it = maViews.begin(); it != maViews.end(); ++it ) + { + NSObject* pObj = *it; + NSControl* pCtrl = nil; + NSCell* pCell = nil; + if( [pObj isKindOfClass: [NSControl class]] ) + pCtrl = (NSControl*)pObj; + else if( [pObj isKindOfClass: [NSCell class]] ) + pCell = (NSCell*)pObj; + + int nTag = pCtrl ? [pCtrl tag] : + pCell ? [pCell tag] : + -1; + + std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( nTag ); + if( name_it != maTagToPropertyName.end() ) + { + MacOSBOOL bEnabled = mpListener->isUIOptionEnabled( name_it->second ) ? YES : NO; + if( pCtrl ) + [pCtrl setEnabled: bEnabled]; + else if( pCell ) + [pCell setEnabled: bEnabled]; + } + } + } }; @interface ControlTarget : NSObject @@ -202,7 +239,7 @@ class ListenerProperties if( pSelected ) { int nTag = [pSelected tag]; - mpListener->changePropertyWithNamedValue( nTag ); + mpListener->changePropertyWithIntValue( nTag ); } } else if( [pSender isMemberOfClass: [NSButton class]] ) @@ -218,13 +255,14 @@ class ListenerProperties { NSButtonCell* pCell = (NSButtonCell*)pObj; int nTag = [pCell tag]; - mpListener->changePropertyWithNamedValue( nTag ); + mpListener->changePropertyWithIntValue( nTag ); } } else { DBG_ERROR( "unsupported class" ); } + mpListener->updateEnableState(); } -(void)dealloc { @@ -396,6 +434,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pBtn setTarget: pCtrlTarget]; [pBtn setAction: @selector(triggered:)]; int nTag = pListenerProperties->addNameTag( aPropertyName ); + pListenerProperties->addObservedControl( pBtn ); [pBtn setTag: nTag]; aCheckRect = [pBtn frame]; @@ -462,7 +501,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // connect target and action [pCell setTarget: pCtrlTarget]; [pCell setAction: @selector(triggered:)]; - int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, aChoices[ m ] ); + int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, m ); + pListenerProperties->addObservedControl( pCell ); [pCell setTag: nTag]; [pTitle release]; // set current selection @@ -517,25 +557,29 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSRect aBtnRect = { { nCurX + aTextRect.size.width, 0 }, { 0, 15 } }; NSPopUpButton* pBtn = [[NSPopUpButton alloc] initWithFrame: aBtnRect pullsDown: NO]; + // iterate options for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { NSString* pItemText = CreateNSString( aChoices[m] ); [pBtn addItemWithTitle: pItemText]; NSMenuItem* pItem = [pBtn itemWithTitle: pItemText]; - int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, aChoices[m] ); + int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, m ); [pItem setTag: nTag]; [pItemText release]; } PropertyValue* pVal = pListener->getValue( aPropertyName ); - rtl::OUString aSelectVal; + sal_Int32 aSelectVal = 0; if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aSelectVal; - NSString* pSelectText = CreateNSString( aSelectVal ); - [pBtn setTitle: pSelectText]; - [pSelectText release]; + [pBtn selectItemAtIndex: aSelectVal]; [pBtn setEnabled: (pListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL) ? YES : NO]; + + // add the button to observed controls for enabled state changes + // also add a tag just for this purpose + pListenerProperties->addObservedControl( pBtn ); + [pBtn setTag: pListenerProperties->addNameTag( aPropertyName )]; [pBtn sizeToFit]; [pCurParent addSubview: pBtn]; diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 959d421ae978..e11f3a6d86ba 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -496,8 +496,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, [pPath release]; } - // FIXME copies - // [pPrintDict setObject: [[NSNumber numberWithInt: (int)pQPrinter->GetCopyCount()] autorelease] forKey: NSPrintCopies]; + [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rListener.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; From e0d8f18a7d0e462706be41c2995c36f582adb883 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 26 Mar 2009 16:42:26 +0000 Subject: [PATCH 029/283] #i92516# print ranges, accessory view --- vcl/aqua/inc/aquaprintview.h | 2 +- vcl/aqua/inc/salprn.h | 8 +- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 144 +++++++---------- vcl/aqua/source/gdi/salprn.cxx | 147 +++++++++++++----- 4 files changed, 164 insertions(+), 137 deletions(-) diff --git a/vcl/aqua/inc/aquaprintview.h b/vcl/aqua/inc/aquaprintview.h index 294a6492869d..15b0fd3751ce 100755 --- a/vcl/aqua/inc/aquaprintview.h +++ b/vcl/aqua/inc/aquaprintview.h @@ -55,7 +55,7 @@ namespace vcl { class PrinterListener; } @interface AquaPrintAccessoryView : NSObject { } -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withRestartCondition: (bool*)pbRestart; @end diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index 8bfa8ac98cae..a2f4a6f80166 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -73,8 +73,8 @@ class AquaSalInfoPrinter : public SalInfoPrinter int mnStartPageOffsetX; int mnStartPageOffsetY; - ULONG mnCurPageRangeStart; - ULONG mnCurPageRangeCount; + sal_Int32 mnCurPageRangeStart; + sal_Int32 mnCurPageRangeCount; public: AquaSalInfoPrinter( const SalPrinterQueueInfo& pInfo ); @@ -117,8 +117,8 @@ class AquaSalInfoPrinter : public SalInfoPrinter NSPrintInfo* getPrintInfo() const { return mpPrintInfo; } void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; } - ULONG getCurPageRangeStart() const { return mnCurPageRangeStart; } - ULONG getCurPageRangeCount() const { return mnCurPageRangeCount; } + sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; } + sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; } private: AquaSalInfoPrinter( const AquaSalInfoPrinter& ); diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 8c695e2ed0c4..9f1b7ef64edf 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -42,78 +42,12 @@ using namespace com::sun::star; using namespace com::sun::star::beans; using namespace com::sun::star::uno; -#if 0 -/* below is some dark magic to inherit an NSViewController if running - on MacOS 10.5. However this is futile since as long as our base line is 10.4 - can use the deprecated method NSPrintOperation:setAccessoryView anyway. - The problem here is that as long as we're linked for 10.4, the print panel - will never show a preview and our accessory view at the same time. This is awful, - but since it was dictated by Apple that IT MUST BE SO it cannot be bad - - Anyway the code below (the load method) is really ugly, so perhaps it's better this way. +/* Note: the accesory view as implemented here is already deprecated in Leopard. Unfortunately + as long as our baseline is Tiger we cannot gain the advantages over multiple accessory views + as well havs haing accessory views AND a preview (as long as you are linked vs. 10.4 libraries + the preview insists on not being present. This is unfortunate. */ -#import - -APPKIT_EXTERN NSString *NSPrintPanelAccessorySummaryItemNameKey; -APPKIT_EXTERN NSString *NSPrintPanelAccessorySummaryItemDescriptionKey; - -#include "osl/module.h" - -@interface AquaPrintViewController : NSObject -{ - NSArray* pAry; -} -+(void)load; --(id)init; --(void)dealloc; --(NSArray *)localizedSummaryItems; --(NSSet*)keyPathsForValuesAffectingPreview; -@end - -@implementation AquaPrintViewController -+(void)load -{ - struct objc_class *pClass = (struct objc_class *)[self class]; - Class superclass = NSClassFromString(@"NSViewController"); - - if(superclass != NULL) - { - pClass->super_class = superclass; - pClass->instance_size += superclass->instance_size; - } -} - --(id)init -{ - if( (self = [super performSelector: @selector(initWithNibName:bundle:) withObject: nil withObject: nil]) ) - { - NSObject* pKeys[] = { NSPrintPanelAccessorySummaryItemNameKey, NSPrintPanelAccessorySummaryItemDescriptionKey }; - NSObject* pVals[] = { @"the Name", @"the summary value" }; - NSDictionary* pDict = [NSDictionary dictionaryWithObjects: pVals forKeys: pKeys count: 2]; - pAry = [NSArray arrayWithObject: pDict]; - } - return self; -} - --(void)dealloc -{ - [pAry release]; - [super dealloc]; -} - --(NSArray *)localizedSummaryItems -{ - return pAry; -} --(NSSet*)keyPathsForValuesAffectingPreview -{ - return [NSSet set]; -} -@end - -#endif - class ListenerProperties { vcl::PrinterListener* mpListener; @@ -121,17 +55,55 @@ class ListenerProperties std::map< int, sal_Int32 > maTagToValueInt; std::vector< NSObject* > maViews; int mnNextTag; + sal_Int32 mnLastPageCount; + bool* mpNeedRestart; + NSPrintOperation* mpOp; + public: - ListenerProperties( vcl::PrinterListener* i_pListener ) - : mpListener( i_pListener ), mnNextTag( 0 ) - {} + ListenerProperties( vcl::PrinterListener* i_pListener, NSPrintOperation* i_pOp, bool* i_pNeedRestart ) + : mpListener( i_pListener ), + mnNextTag( 0 ), + mnLastPageCount( i_pListener->getPageCount() ), + mpNeedRestart( i_pNeedRestart ), + mpOp( i_pOp ) + { + *mpNeedRestart = false; + } void updatePrintJob() { // TODO: refresh page count etc from mpListener // page range may have changed depending on options - /*sal_Int32 nPages = */mpListener->getPageCount(); + sal_Int32 nPages = mpListener->getPageCount(); + #if OSL_DEBUG_LEVEL > 1 + if( nPages != mnLastPageCount ) + fprintf( stderr, "trouble: number of pages changed from %ld to %ld !\n", mnLastPageCount, nPages ); + #endif + *mpNeedRestart = (nPages != mnLastPageCount); + mnLastPageCount = nPages; + if( *mpNeedRestart ) + { + // Warning: bad hack ahead + // Apple does not give as a chance of changing the page count, + // and they don't let us cancel the dialog either + // hack: send a cancel message to the window displaying our views. + // this is ugly. + for( std::vector< NSObject* >::iterator it = maViews.begin(); it != maViews.end(); ++it ) + { + if( [*it isKindOfClass: [NSView class]] ) + { + NSView* pView = (NSView*)*it; + NSWindow* pWindow = [pView window]; + if( pWindow ) + { + [pWindow cancelOperation: nil]; + break; + } + } + } + [[mpOp printInfo] setJobDisposition: NSPrintCancelJob]; + } } int addNameTag( const rtl::OUString& i_rPropertyName ) @@ -305,9 +277,13 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) } @implementation AquaPrintAccessoryView -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withRestartCondition: (bool*)pbRestart; { - ListenerProperties* pListenerProperties = new ListenerProperties( pListener ); + const Sequence< PropertyValue >& rOptions( pListener->getUIOptions() ); + if( rOptions.getLength() == 0 ) + return nil; + + ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pbRestart ); ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; NSView* pCurParent = 0; @@ -317,7 +293,6 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSSize aMaxTabSize = { 0, 0 }; NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aViewFrame]; - const Sequence< PropertyValue >& rOptions( pListener->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) { Sequence< beans::PropertyValue > aOptProp; @@ -619,20 +594,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pTabView setFrameSize: aTabCtrlSize]; // set the accessory view - #if 0 - NSPrintPanel* pPanel = [pOp printPanel]; - if( [pPanel respondsToSelector: @selector(addAccessoryController:)] ) - { - // 10.5 and upward case - AquaPrintViewController* pCtrl = [[AquaPrintViewController alloc] init]; - [pCtrl performSelector: @selector(setView:) withObject: pTabView]; - [pCtrl performSelector: @selector(setTitle:) withObject: @"Test OOOOO"]; - [pPanel performSelector: @selector(addAccessoryController:) withObject: pCtrl]; - [pPanel performSelector: @selector(setOptions:) withObject: (id)(0x20001)]; - } - else - #endif - [pOp setAccessoryView: pTabView]; + [pOp setAccessoryView: pTabView]; return pCtrlTarget; } diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index e11f3a6d86ba..e70f359bbe85 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -47,11 +47,13 @@ #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/awt/Size.hpp" #include using namespace rtl; using namespace vcl; +using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::beans; @@ -459,6 +461,24 @@ void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*, } } +static Size getPageSize( vcl::PrinterListener& i_rListener, sal_Int32 i_nPage ) +{ + Size aPageSize; + Sequence< PropertyValue > aPageParms( i_rListener.getPageParameters( i_nPage ) ); + for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty ) + { + if( aPageParms[ nProperty ].Name.equalsAscii( "PageSize" ) ) + { + awt::Size aSize; + aPageParms[ nProperty].Value >>= aSize; + aPageSize.Width() = aSize.Width; + aPageSize.Height() = aSize.Height; + break; + } + } + return aPageSize; +} + BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, const String& i_rAppName, ImplJobSetup* i_pSetupData, @@ -469,59 +489,104 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, return FALSE; BOOL bSuccess = FALSE; - - // FIXME: make paper ranges work again - mnCurPageRangeStart = 1; - mnCurPageRangeCount = i_rListener.getPageCount(); - AquaSalInstance* pInst = GetSalData()->mpFirstInstance; - - mnStartPageOffsetX = mnStartPageOffsetY = 0; + bool bNeedRestart = true; + sal_Int32 nAllPages = 1; // update job data if( i_pSetupData ) SetData( ~0, i_pSetupData ); - // create view - NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this]; - - NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; - - // set filename - if( i_pFileName ) + do { - [mpPrintInfo setJobDisposition: NSPrintSaveJob]; - NSString* pPath = CreateNSString( *i_pFileName ); - [pPrintDict setObject: pPath forKey: NSPrintSavePath]; - [pPath release]; - } + if( bNeedRestart ) + { + mnCurPageRangeStart = 1; + mnCurPageRangeCount = 1; + nAllPages = i_rListener.getPageCount(); + } - [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rListener.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; - [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; - [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; - [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; + bNeedRestart = false; + mnCurPageRangeCount = 1; + Size aCurSize( getPageSize( i_rListener, mnCurPageRangeStart ) ); + Size aNextSize( aCurSize ); + + // print pages up to a different size + while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) + { + aNextSize = getPageSize( i_rListener, mnCurPageRangeStart + mnCurPageRangeCount ); + if( aCurSize == aNextSize // same page size + || + (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation + ) + { + mnCurPageRangeCount++; + } + else + break; + } + + // now for the current run + mnStartPageOffsetX = mnStartPageOffsetY = 0; + // setup the paper size and orientation + if( aCurSize.Width() > aCurSize.Height() ) + { + mePageOrientation = ORIENTATION_LANDSCAPE; + long nTmp = aCurSize.Width(); + aCurSize.Width() = aCurSize.Height(); + aCurSize.Height() = nTmp; + } + else + mePageOrientation = ORIENTATION_PORTRAIT; + + NSSize aPaperSize = { TenMuToPt(aCurSize.Width()), TenMuToPt(aCurSize.Height()) }; + [mpPrintInfo setPaperSize: aPaperSize]; + + // create view + NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this]; + + NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; + + // set filename + if( i_pFileName ) + { + [mpPrintInfo setJobDisposition: NSPrintSaveJob]; + NSString* pPath = CreateNSString( *i_pFileName ); + [pPrintDict setObject: pPath forKey: NSPrintSavePath]; + [pPath release]; + } + + [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rListener.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; + [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; + [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; + [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; - // create print operation - NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; + // create print operation + NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo]; - if( pPrintOperation ) - { - NSObject* pReleaseAfterUse = nil; - bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); - [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; - [pPrintOperation setShowsProgressPanel: YES]; - if( bShowPanel ) - pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener]; + if( pPrintOperation ) + { + NSObject* pReleaseAfterUse = nil; + bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); + [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; + [pPrintOperation setShowsProgressPanel: YES]; + if( bShowPanel && mnCurPageRangeStart == 1 ) // only the first range of pages gets the accesory view + pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withRestartCondition: &bNeedRestart]; - bSuccess = TRUE; - mbJob = true; - pInst->startedPrintJob(); - [pPrintOperation runOperation]; - pInst->endedPrintJob(); - mbJob = false; - [pReleaseAfterUse release]; - } + bSuccess = TRUE; + mbJob = true; + pInst->startedPrintJob(); + [pPrintOperation runOperation]; + pInst->endedPrintJob(); + mbJob = false; + if( pReleaseAfterUse ) + [pReleaseAfterUse release]; + } + + mnCurPageRangeStart += mnCurPageRangeCount; + mnCurPageRangeCount = 1; + } while( bNeedRestart && mnCurPageRangeCount < nAllPages ); mnCurPageRangeStart = mnCurPageRangeCount = 0; From 1c3b1f0273aed225fa3fcc49e35f7c21a7f48d01 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 26 Mar 2009 16:48:52 +0000 Subject: [PATCH 030/283] #i92516# selection notification --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 996b1d59d438..2d3f35e90150 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -758,7 +758,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) if( ( pButton == &maJobPage.maAllButton || pButton == &maJobPage.maPagesButton || pButton == &maJobPage.maSelectionButton ) - && ((CheckBox*)pButton)->IsChecked() ) + && ((RadioButton*)pButton)->IsChecked() ) { if( pButton == &maJobPage.maAllButton ) maPListener->setPrintSelection( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ); From a8466c6d9bdc60423ad990199ebe0ec0ab82048f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 26 Mar 2009 18:00:43 +0000 Subject: [PATCH 031/283] #i92516# handle page count 0 --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/inc/vcl/svids.hrc | 1 + vcl/source/src/print.src | 4 ++++ vcl/source/window/printdlg.cxx | 25 ++++++++++++++++++++----- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 3802818a3bc2..8bd4ab56141c 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -124,6 +124,7 @@ namespace vcl boost::shared_ptr< PrinterListener > maPListener; rtl::OUString maPageStr; + rtl::OUString maNoPageStr; sal_Int32 mnCurPage; sal_Int32 mnCachedPages; Rectangle maPreviewSpace; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index ef4b021e1919..b2ceb89ec4cf 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -115,6 +115,7 @@ #define SV_PRINT_NOCOLLATE_IMG 13 #define SV_PRINT_COLLATE_HC_IMG 14 #define SV_PRINT_NOCOLLATE_HC_IMG 15 +#define SV_PRINT_NOPAGES 16 #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index e8543515d68c..26454e35ec3d 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -83,6 +83,10 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 0, 165 ); Size = MAP_APPFONT( 350, 8 ); }; + String SV_PRINT_NOPAGES + { + Text [en-US] = "No pages"; + }; TabPage SV_PRINT_TAB_PRINTER { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 2d3f35e90150..8f247b2a471e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -137,6 +137,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr= nPages ) mnCurPage = nPages-1; + if( mnCurPage < 0 ) + mnCurPage = 0; setPreviewText( mnCurPage ); - maPageScrollbar.SetRange( Range( 0, nPages-1 ) ); + maPageScrollbar.SetRange( Range( 0, nPages ) ); maPageScrollbar.SetThumbPos( mnCurPage ); + maPageScrollbar.SetVisibleSize( 1 ); boost::shared_ptr aPrt( maPListener->getPrinter() ); @@ -772,9 +782,14 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) return 0; } -IMPL_LINK( PrintDialog, ModifyHdl, Edit*, EMPTYARG ) +IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { checkControlDependencies(); + if( pEdit == &maJobPage.maPagesEdit && maJobPage.maPagesButton.IsChecked() ) + { + maPListener->setPrintSelection( maJobPage.maPagesEdit.GetText() ); + preparePreview(); + } return 0; } From 227c5f207931e2025e85fc751e4b13cc86bb5a98 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 26 Mar 2009 18:54:45 +0000 Subject: [PATCH 032/283] #i92516# sizing issues --- vcl/source/window/printdlg.cxx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 8f247b2a471e..2587d8ea6348 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -249,11 +249,11 @@ bool PrintDialog::isCollate() void PrintDialog::setupOptionalUI() { Window* pCurParent = 0; - long nCurY = 0, nXPos = 5; + long nCurY = 0, nXPos = 5, nMaxY = 0; USHORT nOptPageId = 9; MapMode aFontMapMode( MAP_APPFONT ); - Size aTabSize = maTabCtrl.GetSizePixel(); + Size aTabSize = maTabCtrl.GetTabPageSizePixel(); const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -319,6 +319,9 @@ void PrintDialog::setupOptionalUI() { if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) { + if( nCurY > nMaxY ) + nMaxY = nCurY; + // add new tab page TabPage* pNewGroup = new TabPage( &maTabCtrl ); maControls.push_front( pNewGroup ); @@ -448,7 +451,7 @@ void PrintDialog::setupOptionalUI() if( nEntryWidth > nMaxTextWidth ) nMaxTextWidth = nEntryWidth; } - nMaxTextWidth += 30; + nMaxTextWidth += 50; sal_Int32 nSelectVal = 0; PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) @@ -569,6 +572,18 @@ void PrintDialog::setupOptionalUI() DBG_ERROR( "Unsupported UI option" ); } } + + if( nCurY > nMaxY ) + nMaxY = nCurY; + + // resize dialog if necessary + Size aMaxSize( LogicToPixel( Size( nMaxY, nMaxY ), aFontMapMode ) ); + if( aMaxSize.Height() > aTabSize.Height() ) + { + Size aCurSize( GetSizePixel() ); + aCurSize.Height() += aMaxSize.Height() - aTabSize.Height(); + SetSizePixel( aCurSize ); + } } void PrintDialog::checkControlDependencies() From 839d1453b4318bf1b8819f67e78b6f801d1041b0 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 26 Mar 2009 19:13:43 +0000 Subject: [PATCH 033/283] #i92516# dependency indenting --- vcl/source/window/printdlg.cxx | 56 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 2587d8ea6348..01828874daa1 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -267,7 +267,7 @@ void PrintDialog::setupOptionalUI() rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; sal_Int64 nMinValue = 0, nMaxValue = 0; - bool bDependency = false; + long nDependencyIndent = 0; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -298,7 +298,28 @@ void PrintDialog::setupOptionalUI() } else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) { - bDependency = true; + rtl::OUString aDepName; + rEntry.Value >>= aDepName; + std::map< rtl::OUString, Window* >::iterator it( maPropertyToWindowMap.find( aDepName ) ); + if( it != maPropertyToWindowMap.end() ) + { + Window* pWin = it->second; + // still on the same page ? + if( pWin->GetParent() == pCurParent ) + { + // is it a labeled window ? + if( dynamic_cast< ListBox* >(pWin) || + dynamic_cast< NumericField* >(pWin) ) + { + Window* pLabelWin = pWin->GetLabeledBy(); + if( dynamic_cast(pLabelWin) ) // sanity check + pWin = pLabelWin; + } + long nDependencyXPos = PixelToLogic( pWin->GetPosPixel(), aFontMapMode ).X(); + if( (nDependencyXPos + 5) > nXPos ) + nDependencyIndent = nDependencyXPos + 5 - nXPos; + } + } } else if( rEntry.Name.equalsAscii( "MinValue" ) ) { @@ -351,16 +372,13 @@ void PrintDialog::setupOptionalUI() } else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { - if( bDependency ) - nXPos += 5; - // add a check box CheckBox* pNewBox = new CheckBox( pCurParent ); maControls.push_front( pNewBox ); pNewBox->SetText( aText ); // FIXME: measure text - pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) ); nCurY += 12; @@ -376,8 +394,6 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); maControlToPropertyMap[pNewBox] = aPropertyName; - if( bDependency ) - nXPos -= 5; } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -390,7 +406,7 @@ void PrintDialog::setupOptionalUI() pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); @@ -409,7 +425,7 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); - Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos, 12 ), aFontMapMode ) ); + Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos + nDependencyIndent, 12 ), aFontMapMode ) ); aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( 15, nCurY ), aFontMapMode ), aPixelSize ); @@ -426,16 +442,13 @@ void PrintDialog::setupOptionalUI() } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) { - if( bDependency ) - nXPos += 5; - // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); @@ -475,7 +488,7 @@ void PrintDialog::setupOptionalUI() else { nCurY += 12; - aListPos = pCurParent->LogicToPixel( Point( 15, nCurY ), aFontMapMode ); + aListPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode ); } pList->SetPosSizePixel( aListPos, aPixelSize ); @@ -494,22 +507,16 @@ void PrintDialog::setupOptionalUI() aPos.Y() += (pList->GetSizePixel().Height() - aSize.Height())/2; pHeading->SetPosSizePixel( aPos, aSize ); } - - if( bDependency ) - nXPos -= 5; } else if( aCtrlType.equalsAscii( "Range" ) && pCurParent ) { - if( bDependency ) - nXPos += 5; - // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); @@ -543,7 +550,7 @@ void PrintDialog::setupOptionalUI() else { nCurY += 12; - aFieldPos = pCurParent->LogicToPixel( Point( 15, nCurY ), aFontMapMode ); + aFieldPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode ); } pField->SetPosSizePixel( aFieldPos, aPixelSize ); @@ -562,9 +569,6 @@ void PrintDialog::setupOptionalUI() aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2; pHeading->SetPosSizePixel( aPos, aSize ); } - - if( bDependency ) - nXPos -= 5; } } else From ae603438b2a8de0c363270b162b52ca17a2d4988 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 27 Mar 2009 12:57:53 +0000 Subject: [PATCH 034/283] unify page metafiles --- vcl/inc/vcl/print.hxx | 3 + vcl/source/gdi/print3.cxx | 106 ++++++++++++++++++++++++++------- vcl/source/window/printdlg.cxx | 28 +-------- 3 files changed, 89 insertions(+), 48 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 66a17a14bc81..8ea864f3b6a5 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -485,6 +485,9 @@ public: virtual void jobFinished(); // optionally release resources bound to the job // implementation details, not usable outside vcl + int SAL_DLLPRIVATE getFilteredPageCount(); + Size SAL_DLLPRIVATE getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf ); + Size SAL_DLLPRIVATE getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ); void SAL_DLLPRIVATE printFilteredPage( int i_nPage ); void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 6400320e0d3e..e7761a8103df 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -79,10 +79,16 @@ public: ControlDependencyMap maControlDependencies; rtl::OUString maSelectionString; + int mnMultiPageRows; + int mnMultiPageColumns; + Size maMultiPageSize; + vcl::PrintProgressDialog* mpProgress; ImplPrinterListenerData() : maSelectionString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ), + mnMultiPageRows( 1 ), + mnMultiPageColumns( 1 ), mpProgress( NULL ) {} ~ImplPrinterListenerData() { delete mpProgress; } @@ -353,6 +359,8 @@ const boost::shared_ptr& PrinterListener::getPrinter() const void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; + Size aPaperSize( i_rPrinter->PixelToLogic( i_rPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + mpImplData->maMultiPageSize = aPaperSize; } void PrinterListener::setPrintSelection( const rtl::OUString& i_rSel ) @@ -360,13 +368,13 @@ void PrinterListener::setPrintSelection( const rtl::OUString& i_rSel ) mpImplData->maSelectionString = i_rSel; } -static void modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) +static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) { + Size aPageSize = pPrinter->GetPaperSize(); for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) { if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) { - Size aPageSize; awt::Size aSize; i_rProps[ nProperty].Value >>= aSize; aPageSize.Width() = aSize.Width; @@ -377,6 +385,80 @@ static void modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& pPrinter->SetPaperSizeUser( aPageSize ); } } + return aPageSize; +} + +Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) +{ + o_rMtf.Clear(); + + // get page parameters + Sequence< PropertyValue > aPageParm( getPageParameters( i_nUnfilteredPage ) ); + const MapMode aMapMode( MAP_100TH_MM ); + + mpImplData->mpPrinter->Push(); + mpImplData->mpPrinter->SetMapMode( aMapMode ); + + // modify job setup if necessary + Size aPageSize = modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); + + o_rMtf.SetPrefSize( aPageSize ); + o_rMtf.SetPrefMapMode( aMapMode ); + + mpImplData->mpPrinter->EnableOutput( FALSE ); + + o_rMtf.Record( mpImplData->mpPrinter.get() ); + + printPage( i_nUnfilteredPage ); + + o_rMtf.Stop(); + o_rMtf.WindStart(); + mpImplData->mpPrinter->Pop(); + + return aPageSize; +} + +Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ) +{ + // FIXME: work in progress + int nSubPages = mpImplData->mnMultiPageRows * mpImplData->mnMultiPageColumns; + if( nSubPages < 1 ) + nSubPages = 1; + + if( nSubPages == 1 ) + return getPageFile( i_nFilteredPage, o_rMtf ); + + Size aPaperSize( mpImplData->maMultiPageSize ); + long nAdvX = aPaperSize.Width() / mpImplData->mnMultiPageColumns; + long nAdvY = aPaperSize.Height() / mpImplData->mnMultiPageRows; + Size aSubPageSize( nAdvX, nAdvY ); + + GDIMetaFile aPageFile; + aPageFile.SetPrefSize( aPaperSize ); + aPageFile.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); + + int nDocPages = getPageCount(); + for( int nPage = i_nFilteredPage * nSubPages; + nPage < (i_nFilteredPage+1)*nSubPages && nPage < nDocPages; + nPage++ ) + { + GDIMetaFile aSubPageFile; + Size aPageSize = getPageFile( nPage, aSubPageFile ); + // scale the metafile down to a sub page size and move it + double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); + double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); + aSubPageFile.Scale( fScaleX, fScaleY ); + //aSubPageFile.Move( nAdvX * (nPage % mpImplData->mn + } + return aPaperSize; +} + +int PrinterListener::getFilteredPageCount() +{ + int nDiv = mpImplData->mnMultiPageRows * mpImplData->mnMultiPageColumns; + if( nDiv < 1 ) + nDiv = 1; + return (getPageCount() + (nDiv-1)) / nDiv; } void PrinterListener::printFilteredPage( int i_nPage ) @@ -391,26 +473,8 @@ void PrinterListener::printFilteredPage( int i_nPage ) Application::Reschedule( true ); } - // get page parameters - Sequence< PropertyValue > aPageParm( getPageParameters( i_nPage ) ); - const MapMode aMapMode( MAP_100TH_MM ); - - mpImplData->mpPrinter->Push(); - mpImplData->mpPrinter->SetMapMode( aMapMode ); - - // modify job setup if necessary - modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); - - mpImplData->mpPrinter->EnableOutput( FALSE ); - GDIMetaFile aPageFile; - aPageFile.Record( mpImplData->mpPrinter.get() ); - - printPage( i_nPage ); - - aPageFile.Stop(); - aPageFile.WindStart(); - mpImplData->mpPrinter->Pop(); + getPageFile( i_nPage, aPageFile ); ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 01828874daa1..4e807f374bca 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -688,34 +688,8 @@ void PrintDialog::preparePreview() const MapMode aMapMode( MAP_100TH_MM ); - aPrt->Push(); - aPrt->SetMapMode( aMapMode ); - - Size aPageSize( aPrt->GetPaperSize() ); - Sequence< PropertyValue > aPageParms( maPListener->getPageParameters( mnCurPage ) ); - for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty ) - { - if( aPageParms[ nProperty ].Name.equalsIgnoreAsciiCaseAscii( "PageSize" ) ) - { - awt::Size aSize; - aPageParms[ nProperty ].Value >>= aSize; - aPageSize.Width() = aSize.Width; - aPageSize.Height() = aSize.Height; - } - } - - aPrt->EnableOutput( FALSE ); - GDIMetaFile aMtf; - aMtf.SetPrefSize( aPageSize ); - aMtf.SetPrefMapMode( aMapMode ); - aMtf.Record( &(*aPrt) ); - - maPListener->printPage( mnCurPage ); - - aMtf.Stop(); - aMtf.WindStart(); - aPrt->Pop(); + Size aPageSize = maPListener->getPageFile( mnCurPage, aMtf ); Size aPreviewSize; Point aPreviewPos = maPreviewSpace.TopLeft(); From 71332919f5a9829758b1f150119c71c0fd5447ec Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 27 Mar 2009 23:46:53 +0000 Subject: [PATCH 035/283] n-up printing preparations --- vcl/source/gdi/print3.cxx | 97 ++++++++++++++++++++++++++-------- vcl/source/window/printdlg.cxx | 4 +- 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e7761a8103df..5356c74327ed 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -37,6 +37,7 @@ #include "vcl/salinst.hxx" #include "vcl/salprn.hxx" #include "vcl/svids.hrc" +#include "vcl/metaact.hxx" #include "tools/urlobj.hxx" @@ -288,7 +289,7 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrmaGDIData.mbPrinterPullModel ) { mbJobActive = TRUE; - // sallayer does all necesseary page printing + // sallayer does all necessary page printing if( mpPrinter->StartJob( pPrintFile, Application::GetDisplayName(), maJobSetup.ImplGetConstData(), @@ -320,7 +321,7 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrcreateProgressDialog(); - int nPages = i_pListener->getPageCount(); + int nPages = i_pListener->getFilteredPageCount(); for( int nPage = 0; nPage < nPages; nPage++ ) { // remember MultiSelection is 1 based (due to user input) @@ -390,6 +391,16 @@ static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) { + // update progress if necessary + if( mpImplData->mpProgress ) + { + // do nothing if printing is canceled + if( mpImplData->mpProgress->isCanceled() ) + return Size(); + mpImplData->mpProgress->tick(); + Application::Reschedule( true ); + } + o_rMtf.Clear(); // get page parameters @@ -418,9 +429,29 @@ Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) return aPageSize; } +static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rRect, GDIMetaFile& i_rSubPage ) +{ + // save gstate + o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION ) ); + + // draw a border + o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); + o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); + o_rMtf.AddAction( new MetaRectAction( i_rRect ) ); + + // clip to page rect + o_rMtf.AddAction( new MetaISectRectClipRegionAction( i_rRect ) ); + + // append the subpage + i_rSubPage.WindStart(); + i_rSubPage.Play( o_rMtf ); + + // restore gstate + o_rMtf.AddAction( new MetaPopAction() ); +} + Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ) { - // FIXME: work in progress int nSubPages = mpImplData->mnMultiPageRows * mpImplData->mnMultiPageColumns; if( nSubPages < 1 ) nSubPages = 1; @@ -429,27 +460,52 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r return getPageFile( i_nFilteredPage, o_rMtf ); Size aPaperSize( mpImplData->maMultiPageSize ); + + // determine offsets long nAdvX = aPaperSize.Width() / mpImplData->mnMultiPageColumns; long nAdvY = aPaperSize.Height() / mpImplData->mnMultiPageRows; - Size aSubPageSize( nAdvX, nAdvY ); - GDIMetaFile aPageFile; - aPageFile.SetPrefSize( aPaperSize ); - aPageFile.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); + // determine size of a "cell" subpage, leave a little space around pages + Size aSubPageSize( nAdvX - 300, nAdvY - 300 ); + + o_rMtf.Clear(); + o_rMtf.SetPrefSize( aPaperSize ); + o_rMtf.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); int nDocPages = getPageCount(); - for( int nPage = i_nFilteredPage * nSubPages; + for( int nPage = i_nFilteredPage * nSubPages, nSubP = 0; nPage < (i_nFilteredPage+1)*nSubPages && nPage < nDocPages; - nPage++ ) + nPage++, nSubP++ ) { - GDIMetaFile aSubPageFile; - Size aPageSize = getPageFile( nPage, aSubPageFile ); - // scale the metafile down to a sub page size and move it - double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); - double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); - aSubPageFile.Scale( fScaleX, fScaleY ); - //aSubPageFile.Move( nAdvX * (nPage % mpImplData->mn + GDIMetaFile aPageFile; + Size aPageSize = getPageFile( nPage, aPageFile ); + if( aPageSize.Width() && aPageSize.Height() ) + { + // scale the metafile down to a sub page size + double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); + double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); + double fScale = std::min( fScaleX, fScaleY ); + aPageFile.Scale( fScale, fScale ); + aPageFile.WindStart(); + + // move the subpage so it is centered in its "cell" + long nOffX = (nAdvX - long(double(aPageSize.Width()) * fScale)) / 2; + long nOffY = (nAdvY - long(double(aPageSize.Height()) * fScale)) / 2; + long nX = nOffX + nAdvX * (nSubP % mpImplData->mnMultiPageColumns); + long nY = nOffY + nAdvY * (nSubP / mpImplData->mnMultiPageColumns); + aPageFile.Move( nX, nY ); + aPageFile.WindStart(); + // calculate border rectangle + Rectangle aSubPageRect( Point( nX - 50, nY - 50 ), + Size( long(double(aPageSize.Width())*fScale) + 100, + long(double(aPageSize.Height())*fScale) + 100 ) ); + + // append subpage to page + appendSubPage( o_rMtf, aSubPageRect, aPageFile ); + } } + o_rMtf.WindStart(); + return aPaperSize; } @@ -463,19 +519,16 @@ int PrinterListener::getFilteredPageCount() void PrinterListener::printFilteredPage( int i_nPage ) { - // update progress if necessary + GDIMetaFile aPageFile; + getFilteredPageFile( i_nPage, aPageFile ); + if( mpImplData->mpProgress ) { // do nothing if printing is canceled if( mpImplData->mpProgress->isCanceled() ) return; - mpImplData->mpProgress->tick(); - Application::Reschedule( true ); } - GDIMetaFile aPageFile; - getPageFile( i_nPage, aPageFile ); - ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 4e807f374bca..eb1a0b2e0a2c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -670,7 +670,7 @@ void PrintDialog::setPreviewText( sal_Int32 nSetPage ) void PrintDialog::preparePreview() { // page range may have changed depending on options - sal_Int32 nPages = maPListener->getPageCount(); + sal_Int32 nPages = maPListener->getFilteredPageCount(); mnCachedPages = nPages; if( mnCurPage >= nPages ) @@ -689,7 +689,7 @@ void PrintDialog::preparePreview() const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; - Size aPageSize = maPListener->getPageFile( mnCurPage, aMtf ); + Size aPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); Size aPreviewSize; Point aPreviewPos = maPreviewSpace.TopLeft(); From d6a769554e5d7e263f4b388784d467776bc9b548 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 28 Mar 2009 08:51:45 +0000 Subject: [PATCH 036/283] remove warning --- vcl/source/window/splitwin.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index a7a21fb840ad..1e66849db73a 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -1879,7 +1879,7 @@ void SplitWindow::ImplDrawButtonRect( const Rectangle& rRect, long nSize ) DrawPixel( Point( i+1, nCenter-2+1 ), rStyleSettings.GetShadowColor() ); } i++; - if ( (i < nEx1) || (i > nEx2 ) && (i < nRight-3) ) + if ( (i < nEx1) || ((i > nEx2 ) && (i < nRight-3)) ) { DrawPixel( Point( i, nCenter+2 ), rStyleSettings.GetLightColor() ); DrawPixel( Point( i+1, nCenter+2+1 ), rStyleSettings.GetShadowColor() ); @@ -1909,7 +1909,7 @@ void SplitWindow::ImplDrawButtonRect( const Rectangle& rRect, long nSize ) DrawPixel( Point( nCenter-2+1, i+1 ), rStyleSettings.GetShadowColor() ); } i++; - if ( (i < nEx1) || (i > nEx2 ) && (i < nBottom-3) ) + if ( (i < nEx1) || ((i > nEx2 ) && (i < nBottom-3)) ) { DrawPixel( Point( nCenter+2, i ), rStyleSettings.GetLightColor() ); DrawPixel( Point( nCenter+2+1, i+1 ), rStyleSettings.GetShadowColor() ); From d314f09fd3477c9850493e4156bf96cfeb014aad Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 28 Mar 2009 08:52:14 +0000 Subject: [PATCH 037/283] N-Up printing --- vcl/inc/vcl/print.hxx | 1 + vcl/inc/vcl/prndlg.hxx | 11 +++++ vcl/inc/vcl/svids.hrc | 7 +++ vcl/source/gdi/print3.cxx | 14 +++++- vcl/source/src/print.src | 79 ++++++++++++++++++++++++++++------ vcl/source/window/printdlg.cxx | 45 +++++++++++++++++++ 6 files changed, 142 insertions(+), 15 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 8ea864f3b6a5..727c08545cf4 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -493,6 +493,7 @@ public: void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); void SAL_DLLPRIVATE createProgressDialog(); void SAL_DLLPRIVATE setPrintSelection( const rtl::OUString& ); + void SAL_DLLPRIVATE setMultipage( int nRows, int nColumns, const Size& rPaperSize ); }; } diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 8bd4ab56141c..c44bda8a2711 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -78,6 +78,13 @@ namespace vcl FixedText maLocText; FixedText maComment; FixedText maCommentText; + FixedLine maNupLine; + FixedText maNupRowsTxt; + NumericField maNupRowsEdt; + FixedText maNupColTxt; + NumericField maNupColEdt; + RadioButton maNupPortrait; + RadioButton maNupLandscape; PrinterTabPage( Window*, const ResId& ); virtual ~PrinterTabPage(); @@ -134,6 +141,10 @@ namespace vcl std::multimap< rtl::OUString, Window* > maPropertyToWindowMap; std::map< Window*, sal_Int32 > maControlToNumValMap; + Size maNupPortraitSize; + Size maNupLandscapeSize; + + void updateNup(); void preparePreview(); void setPreviewText( sal_Int32 ); void updatePrinterText(); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index b2ceb89ec4cf..1c5f5d598faf 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -94,6 +94,13 @@ #define SV_PRINT_PRT_COMMENT_TXT 9 #define SV_PRINT_PRT_TOFILE 10 #define SV_PRINT_PRT_SETUP 11 +#define SV_PRINT_PRT_NUP 12 +#define SV_PRINT_PRT_NUP_ROWS_TXT 13 +#define SV_PRINT_PRT_NUP_ROWS_EDT 14 +#define SV_PRINT_PRT_NUP_COLUMNS_TXT 15 +#define SV_PRINT_PRT_NUP_COLUMNS_EDT 16 +#define SV_PRINT_PRT_NUP_PORTRAIT 17 +#define SV_PRINT_PRT_NUP_LANDSCAPE 18 #define SV_DLG_PRINT_PROGRESS 2048 #define SV_PRINT_PROGRESS_CANCEL 1 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 5356c74327ed..bf7c02dc775e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -324,7 +324,6 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrgetFilteredPageCount(); for( int nPage = 0; nPage < nPages; nPage++ ) { - // remember MultiSelection is 1 based (due to user input) i_pListener->printFilteredPage( nPage ); } EndJob(); @@ -440,6 +439,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rRect, GDIMet o_rMtf.AddAction( new MetaRectAction( i_rRect ) ); // clip to page rect + // FIXME: clipping does not seem to work reliably with this o_rMtf.AddAction( new MetaISectRectClipRegionAction( i_rRect ) ); // append the subpage @@ -582,6 +582,11 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->EnableOutput( TRUE ); + // in N-Up printing set the correct page size + // FIXME: setting paper landscape/portrait does not work here reliably ? + if( mpImplData->mnMultiPageRows != 1 || mpImplData->mnMultiPageColumns != 1 ) + mpImplData->mpPrinter->SetPaperSizeUser( mpImplData->maMultiPageSize ); + // actually print the page mpImplData->mpPrinter->StartPage(); @@ -784,3 +789,10 @@ void PrinterListener::createProgressDialog() mpImplData->mpProgress->Show(); } } + +void PrinterListener::setMultipage( int i_nRows, int i_nColumns, const Size& rPaperSize ) +{ + mpImplData->mnMultiPageRows = i_nRows; + mpImplData->mnMultiPageColumns = i_nColumns; + mpImplData->maMultiPageSize = rPaperSize; +} \ No newline at end of file diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 26454e35ec3d..04d9c1e02b5e 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -45,6 +45,7 @@ ModalDialog SV_DLG_PRINT DefButton = TRUE; Pos = MAP_APPFONT( 240, 175 ); Size = MAP_APPFONT( 50, 15 ); + Text [en-US] = "~Print"; }; CancelButton SV_PRINT_CANCEL { @@ -76,7 +77,7 @@ ModalDialog SV_DLG_PRINT TabControl SV_PRINT_TABCTRL { Pos = MAP_APPFONT( 140, 5 ); - Size = MAP_APPFONT( 205, 155 ); + Size = MAP_APPFONT( 205, 160 ); }; FixedLine SV_PRINT_BUTTONLINE { @@ -149,6 +150,56 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 50, 66 ); Size = MAP_APPFONT( 200, 10 ); }; + FixedLine SV_PRINT_PRT_NUP + { + Pos = MAP_APPFONT( 5, 80 ); + Size = MAP_APPFONT( 150, 10 ); + Text [en-US] = "N-Up printing"; + }; + FixedText SV_PRINT_PRT_NUP_ROWS_TXT + { + Pos = MAP_APPFONT( 10, 95 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Rows"; + }; + NumericField SV_PRINT_PRT_NUP_ROWS_EDT + { + Pos = MAP_APPFONT( 55, 95 ); + Size = MAP_APPFONT( 40, 12 ); + Border = TRUE; + Spin = TRUE; + Minimum = 1; + Maximum = 32; + Value = 1; + }; + FixedText SV_PRINT_PRT_NUP_COLUMNS_TXT + { + Pos = MAP_APPFONT( 10, 110 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "C~olumns"; + }; + NumericField SV_PRINT_PRT_NUP_COLUMNS_EDT + { + Pos = MAP_APPFONT( 55, 110 ); + Size = MAP_APPFONT( 40, 12 ); + Border = TRUE; + Spin = TRUE; + Minimum = 1; + Maximum = 32; + Value = 1; + }; + RadioButton SV_PRINT_PRT_NUP_PORTRAIT + { + Pos = MAP_APPFONT( 10, 125 ); + Size = MAP_APPFONT( 90, 10 ); + Text [en-US] = "Po~rtrait"; + }; + RadioButton SV_PRINT_PRT_NUP_LANDSCAPE + { + Pos = MAP_APPFONT( 10, 135 ); + Size = MAP_APPFONT( 90, 10 ); + Text [en-US] = "~Landscape"; + }; }; TabPage SV_PRINT_TAB_JOB @@ -164,58 +215,58 @@ ModalDialog SV_DLG_PRINT }; CheckBox SV_PRINT_PRT_TOFILE { - Pos = MAP_APPFONT( 15, 20 ); + Pos = MAP_APPFONT( 10, 20 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print to file"; }; FixedLine SV_PRINT_RANGE { - Pos = MAP_APPFONT( 5, 30 ); + Pos = MAP_APPFONT( 5, 35 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Print range"; }; RadioButton SV_PRINT_ALL { - Pos = MAP_APPFONT( 10, 40 ); + Pos = MAP_APPFONT( 10, 45 ); Size = MAP_APPFONT( 145, 15 ); Text [en-US] = "All pages"; Check = TRUE; }; RadioButton SV_PRINT_PAGERANGE { - Pos = MAP_APPFONT( 10, 55 ); + Pos = MAP_APPFONT( 10, 60 ); Size = MAP_APPFONT( 60, 15 ); Text [en-US] = "Pages"; }; Edit SV_PRINT_PAGERANGE_EDIT { - Pos = MAP_APPFONT( 70, 55 ); - Size = MAP_APPFONT( 80, 15 ); + Pos = MAP_APPFONT( 70, 60 ); + Size = MAP_APPFONT( 80, 12 ); Border = TRUE; }; RadioButton SV_PRINT_SELECTION { - Pos = MAP_APPFONT( 10, 70 ); + Pos = MAP_APPFONT( 10, 75 ); Size = MAP_APPFONT( 145, 15 ); Text [en-US] = "Selection"; }; FixedLine SV_PRINT_COPIES { - Pos = MAP_APPFONT( 5, 90 ); + Pos = MAP_APPFONT( 5, 95 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Copies"; }; FixedText SV_PRINT_COPYCOUNT { - Pos = MAP_APPFONT( 10, 100 ); + Pos = MAP_APPFONT( 10, 105 ); Size = MAP_APPFONT( 80, 10 ); Text [en-US] = "Number of copies"; }; NumericField SV_PRINT_COPYCOUNT_FIELD { - Pos = MAP_APPFONT( 90, 100 ); - Size = MAP_APPFONT( 40, 10 ); + Pos = MAP_APPFONT( 90, 105 ); + Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; Minimum = 1; @@ -224,12 +275,12 @@ ModalDialog SV_DLG_PRINT }; FixedImage SV_PRINT_COLLATE_IMAGE { - Pos = MAP_APPFONT( 10, 120 ); + Pos = MAP_APPFONT( 10, 125 ); Size = MAP_PIXEL( 80, 30 ); }; CheckBox SV_PRINT_COLLATE { - Pos = MAP_APPFONT( 80, 120 ); + Pos = MAP_APPFONT( 80, 125 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index eb1a0b2e0a2c..bc6e22d2283a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -91,6 +91,13 @@ PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rRe , maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) ) , maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) ) , maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) ) + , maNupLine( this, VclResId( SV_PRINT_PRT_NUP ) ) + , maNupRowsTxt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_TXT ) ) + , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) + , maNupColTxt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_TXT ) ) + , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_EDT ) ) + , maNupPortrait( this, VclResId( SV_PRINT_PRT_NUP_PORTRAIT ) ) + , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) { FreeResource(); } @@ -198,16 +205,36 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPrinter()->PixelToLogic( + maPListener->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + if( maPListener->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE ) + { + maNupLandscapeSize = aNupSize; + maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() ); + maPrinterPage.maNupLandscape.Check(); + } + else + { + maNupPortraitSize = aNupSize; + maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() ); + maPrinterPage.maNupPortrait.Check(); + } + // setup click handler on the various buttons maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.maAllButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.maSelectionButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.maPagesButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maPrinterPage.maNupPortrait.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maPrinterPage.maNupLandscape.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); // setup modify hdl maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); maJobPage.maPagesEdit.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); + maPrinterPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); + maPrinterPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); // setup optional UI options set by application setupOptionalUI(); @@ -712,6 +739,18 @@ void PrintDialog::preparePreview() maPreviewWindow.setPreview( aMtf ); } +void PrintDialog::updateNup() +{ + int nRows = maPrinterPage.maNupRowsEdt.GetValue(); + int nCols = maPrinterPage.maNupColEdt.GetValue(); + + maPListener->setMultipage( nRows, nCols, + maPrinterPage.maNupPortrait.IsChecked() + ? maNupPortraitSize : maNupLandscapeSize ); + + preparePreview(); +} + IMPL_LINK( PrintDialog, ScrollHdl, ScrollBar*, pScrBar ) { if( pScrBar == &maPageScrollbar ) @@ -772,6 +811,8 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) preparePreview(); } + if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape ) + updateNup(); return 0; } @@ -783,6 +824,10 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) maPListener->setPrintSelection( maJobPage.maPagesEdit.GetText() ); preparePreview(); } + else if( pEdit == &maPrinterPage.maNupRowsEdt || pEdit == &maPrinterPage.maNupColEdt ) + { + updateNup(); + } return 0; } From 8ef0b97b08054eaf07b1f684f41ef91f47a76772 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 31 Mar 2009 21:04:59 +0000 Subject: [PATCH 038/283] add: clip metafiles on rectangles --- vcl/inc/vcl/gdimtf.hxx | 1 + vcl/source/gdi/gdimtf.cxx | 34 ++++++++++++++++++++++++++++++++++ vcl/source/gdi/print3.cxx | 32 ++++++++++++++++++++------------ 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx index 62439d4d4613..48b39d290872 100644 --- a/vcl/inc/vcl/gdimtf.hxx +++ b/vcl/inc/vcl/gdimtf.hxx @@ -164,6 +164,7 @@ public: void Scale( double fScaleX, double fScaleY ); void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); void Rotate( long nAngle10 ); + void Clip( const Rectangle& ); void Adjust( short nLuminancePercent = 0, short nContrastPercent = 0, short nChannelRPercent = 0, short nChannelGPercent = 0, diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index 3a29e6d56095..e0ea8976b75f 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -876,6 +876,40 @@ void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY ) // ------------------------------------------------------------------------ +void GDIMetaFile::Clip( const Rectangle& i_rClipRect ) +{ + Rectangle aCurRect( i_rClipRect ); + VirtualDevice aMapVDev; + + aMapVDev.EnableOutput( FALSE ); + aMapVDev.SetMapMode( GetPrefMapMode() ); + + for( MetaAction* pAct = (MetaAction*) First(); pAct; pAct = (MetaAction*) Next() ) + { + const long nType = pAct->GetType(); + + if( ( META_MAPMODE_ACTION == nType ) || + ( META_PUSH_ACTION == nType ) || + ( META_POP_ACTION == nType ) ) + { + pAct->Execute( &aMapVDev ); + aCurRect = aMapVDev.LogicToLogic( i_rClipRect, GetPrefMapMode(), aMapVDev.GetMapMode() ); + } + else if( nType == META_CLIPREGION_ACTION ) + { + MetaClipRegionAction* pOldAct = (MetaClipRegionAction*)pAct; + Region aNewReg( aCurRect ); + if( pOldAct->IsClipping() ) + aNewReg.Intersect( pOldAct->GetRegion() ); + MetaClipRegionAction* pNewAct = new MetaClipRegionAction( aNewReg, TRUE ); + Replace( pNewAct, GetCurPos() ); + pOldAct->Delete(); + } + } +} + +// ------------------------------------------------------------------------ + Point GDIMetaFile::ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt, const Size& rOffset, double fSin, double fCos ) { diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index bf7c02dc775e..c898e861d9f0 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -428,23 +428,31 @@ Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) return aPageSize; } -static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rRect, GDIMetaFile& i_rSubPage ) +static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GDIMetaFile& io_rSubPage ) { + // intersect all clipregion actions with our clip rect + io_rSubPage.WindStart(); + io_rSubPage.Clip( i_rClipRect ); + // save gstate o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION ) ); // draw a border + Rectangle aBorderRect( i_rClipRect ); + aBorderRect.Left() -= 100; + aBorderRect.Top() -= 100; + aBorderRect.Right() += 100; + aBorderRect.Bottom() += 100; o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); - o_rMtf.AddAction( new MetaRectAction( i_rRect ) ); + o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); // clip to page rect - // FIXME: clipping does not seem to work reliably with this - o_rMtf.AddAction( new MetaISectRectClipRegionAction( i_rRect ) ); + o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); // append the subpage - i_rSubPage.WindStart(); - i_rSubPage.Play( o_rMtf ); + io_rSubPage.WindStart(); + io_rSubPage.Play( o_rMtf ); // restore gstate o_rMtf.AddAction( new MetaPopAction() ); @@ -466,7 +474,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r long nAdvY = aPaperSize.Height() / mpImplData->mnMultiPageRows; // determine size of a "cell" subpage, leave a little space around pages - Size aSubPageSize( nAdvX - 300, nAdvY - 300 ); + Size aSubPageSize( nAdvX - 500, nAdvY - 500 ); o_rMtf.Clear(); o_rMtf.SetPrefSize( aPaperSize ); @@ -496,9 +504,9 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r aPageFile.Move( nX, nY ); aPageFile.WindStart(); // calculate border rectangle - Rectangle aSubPageRect( Point( nX - 50, nY - 50 ), - Size( long(double(aPageSize.Width())*fScale) + 100, - long(double(aPageSize.Height())*fScale) + 100 ) ); + Rectangle aSubPageRect( Point( nX, nY ), + Size( long(double(aPageSize.Width())*fScale), + long(double(aPageSize.Height())*fScale) ) ); // append subpage to page appendSubPage( o_rMtf, aSubPageRect, aPageFile ); @@ -529,6 +537,7 @@ void PrinterListener::printFilteredPage( int i_nPage ) return; } + bool bMultiPageOutput = mpImplData->mnMultiPageRows != 1 || mpImplData->mnMultiPageColumns != 1; ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); @@ -583,8 +592,7 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->EnableOutput( TRUE ); // in N-Up printing set the correct page size - // FIXME: setting paper landscape/portrait does not work here reliably ? - if( mpImplData->mnMultiPageRows != 1 || mpImplData->mnMultiPageColumns != 1 ) + if( bMultiPageOutput ) mpImplData->mpPrinter->SetPaperSizeUser( mpImplData->maMultiPageSize ); // actually print the page From d589b3562db69a644490300fe0949c5a3dafbc75 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 31 Mar 2009 21:16:00 +0000 Subject: [PATCH 039/283] remove warnings --- vcl/source/control/ilstbox.cxx | 2 +- vcl/source/gdi/sallayout.cxx | 4 ++-- vcl/source/window/decoview.cxx | 6 +++--- vcl/source/window/dialog.cxx | 2 +- vcl/source/window/winproc.cxx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index c717e491d7b2..a25ddbb68e8b 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -1124,7 +1124,7 @@ BOOL ImplListBoxWindow::SelectEntries( USHORT nSelect, LB_EVENT_TYPE eLET, BOOL mpEntryList->SetSelectionAnchor( nSelect ); } // MultiListBox nur mit CTRL/SHIFT oder nicht im SimpleMode - else if( ( !mbSimpleMode /* && !bShift */ ) || ( mbSimpleMode && ( bCtrl || bShift ) || mbStackMode ) ) + else if( ( !mbSimpleMode /* && !bShift */ ) || ( (mbSimpleMode && ( bCtrl || bShift )) || mbStackMode ) ) { // Space fuer Selektionswechsel if( !bShift && ( ( eLET == LET_KEYSPACE ) || ( eLET == LET_MBDOWN ) ) ) diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 0358b25ca153..89a47a9f4077 100755 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1292,10 +1292,10 @@ void GenericSalLayout::ApplyAsianKerning( const sal_Unicode* pStr, int nLength ) { // ignore code ranges that are not affected by asian punctuation compression const sal_Unicode cHere = pStr[n]; - if( (0x3000 != (cHere & 0xFF00)) && (0x2010 != (cHere & 0xFFF0)) || (0xFF00 != (cHere & 0xFF00)) ) + if( ((0x3000 != (cHere & 0xFF00)) && (0x2010 != (cHere & 0xFFF0))) || (0xFF00 != (cHere & 0xFF00)) ) continue; const sal_Unicode cNext = pStr[n+1]; - if( (0x3000 != (cNext & 0xFF00)) && (0x2010 != (cNext & 0xFFF0)) || (0xFF00 != (cNext & 0xFF00)) ) + if( ((0x3000 != (cNext & 0xFF00)) && (0x2010 != (cNext & 0xFFF0))) || (0xFF00 != (cNext & 0xFF00)) ) continue; // calculate compression values diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index 90934b382a88..4dd2bca2d6fa 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -944,8 +944,8 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect, Color aColor = bRound ? rStyleSettings.GetShadowColor() : pDev->GetSettings().GetStyleSettings().GetMonoColor(); // when the MonoColor wasn't set, check face color - if ( ( ( bRound && aColor.IsDark() ) || ( aColor == Color( COL_BLACK ) ) && - ( pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark() ) ) ) + if ( ( ( bRound && aColor.IsDark() ) || ( aColor == Color( COL_BLACK ) && + ( pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark() ) ) ) ) aColor = Color( COL_WHITE ); ImplDrawDPILineRect( pDev, rRect, &aColor, bRound ); } @@ -1183,7 +1183,7 @@ static void ImplDrawButton( OutputDevice* pDev, Rectangle& rRect, aFillRect.Right(), aFillRect.Top() ) ); aFillRect.Top()++; } - if ( ((nStyle & BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) && + if ( ((nStyle & (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) && !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED | BUTTON_DRAW_HIGHLIGHT)) ) { pDev->SetFillColor( rStyleSettings.GetDarkShadowColor() ); diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index c949a59cb222..1fc2b9be703a 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -347,7 +347,7 @@ void Dialog::ImplInit( Window* pParent, WinBits nStyle ) { mpWindowImpl->mbFrame = TRUE; mpWindowImpl->mbOverlapWin = TRUE; - SystemWindow::ImplInit( pParent, nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE) | WB_CLOSEABLE, NULL ); + SystemWindow::ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE)) | WB_CLOSEABLE, NULL ); // Now set all style bits mpWindowImpl->mnStyle = nStyle; } diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index a8be05bf4909..d41a861717e9 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1622,7 +1622,7 @@ void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight ) ImplDestroyHelpWindow( true ); } - if ( (nNewWidth > 0) && (nNewHeight > 0) || + if ( ((nNewWidth > 0) && (nNewHeight > 0)) || pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize ) { if ( (nNewWidth != pWindow->GetOutputWidthPixel()) || (nNewHeight != pWindow->GetOutputHeightPixel()) ) From 4313da356abe8254095a3c9a8f05eab695e2477c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 1 Apr 2009 09:13:22 +0000 Subject: [PATCH 040/283] add missing newline at EOF --- vcl/source/gdi/print3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index c898e861d9f0..f90ee6422045 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -803,4 +803,4 @@ void PrinterListener::setMultipage( int i_nRows, int i_nColumns, const Size& rPa mpImplData->mnMultiPageRows = i_nRows; mpImplData->mnMultiPageColumns = i_nColumns; mpImplData->maMultiPageSize = rPaperSize; -} \ No newline at end of file +} From 05edec8ff965d8e0c6001a7d22fce42a5d28f9a5 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 1 Apr 2009 11:58:28 +0000 Subject: [PATCH 041/283] #i92516# add: quick job --- vcl/source/gdi/print3.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index f90ee6422045..fd0008cd0dba 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -200,7 +200,9 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene // check if the printer brings up its own dialog // in that case leave the work to that dialog - if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) ) + const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); + bool bIsQuick = rQuick.Len() && rQuick.EqualsIgnoreCaseAscii( "true" ); + if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && ! bIsQuick ) { try { From 77c37222ad9d430b0d0f98e1432dec36d9650b00 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 1 Apr 2009 15:47:34 +0000 Subject: [PATCH 042/283] rearrange buttons --- vcl/source/src/print.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 04d9c1e02b5e..b8d21e45fb84 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -190,13 +190,13 @@ ModalDialog SV_DLG_PRINT }; RadioButton SV_PRINT_PRT_NUP_PORTRAIT { - Pos = MAP_APPFONT( 10, 125 ); + Pos = MAP_APPFONT( 110, 95 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "Po~rtrait"; }; RadioButton SV_PRINT_PRT_NUP_LANDSCAPE { - Pos = MAP_APPFONT( 10, 135 ); + Pos = MAP_APPFONT( 110, 105 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "~Landscape"; }; From 0f97c091b9fb04b076e1de890e9eee9e7ad27d37 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 1 Apr 2009 18:19:50 +0000 Subject: [PATCH 043/283] select correct paper size in n-up printing, minor fixes --- vcl/source/gdi/print3.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index fd0008cd0dba..1b2cef469da6 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -437,7 +437,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD io_rSubPage.Clip( i_rClipRect ); // save gstate - o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION ) ); + o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION | PUSH_MAPMODE ) ); // draw a border Rectangle aBorderRect( i_rClipRect ); @@ -481,6 +481,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r o_rMtf.Clear(); o_rMtf.SetPrefSize( aPaperSize ); o_rMtf.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); + o_rMtf.AddAction( new MetaMapModeAction( MapMode( MAP_100TH_MM ) ) ); int nDocPages = getPageCount(); for( int nPage = i_nFilteredPage * nSubPages, nSubP = 0; @@ -530,7 +531,7 @@ int PrinterListener::getFilteredPageCount() void PrinterListener::printFilteredPage( int i_nPage ) { GDIMetaFile aPageFile; - getFilteredPageFile( i_nPage, aPageFile ); + Size aPageSize = getFilteredPageFile( i_nPage, aPageFile ); if( mpImplData->mpProgress ) { @@ -594,14 +595,14 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->EnableOutput( TRUE ); // in N-Up printing set the correct page size + mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); if( bMultiPageOutput ) - mpImplData->mpPrinter->SetPaperSizeUser( mpImplData->maMultiPageSize ); + mpImplData->mpPrinter->SetPaperSizeUser( aPageSize = mpImplData->maMultiPageSize ); // actually print the page mpImplData->mpPrinter->StartPage(); mpImplData->mpPrinter->Push(); - mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); aCleanedFile.WindStart(); aCleanedFile.Play( mpImplData->mpPrinter.get() ); mpImplData->mpPrinter->Pop(); From bfb084f517f7c6f09e4d11684421b155b2c6b15d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 3 Apr 2009 11:33:25 +0000 Subject: [PATCH 044/283] #i92516# keep initialized printer for job if present --- vcl/source/gdi/print3.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1b2cef469da6..2ba9a143c4e1 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -195,8 +195,12 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene { // setup printer boost::shared_ptr pListener( i_pListener ); - boost::shared_ptr pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); - pListener->setPrinter( pPrinter ); + // if no specific printer is already set, create one + if( ! pListener->getPrinter() ) + { + boost::shared_ptr pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); + pListener->setPrinter( pPrinter ); + } // check if the printer brings up its own dialog // in that case leave the work to that dialog From ea16cf1deb6f2abb0d3595356364cf179e508883 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 15 Apr 2009 19:11:23 +0000 Subject: [PATCH 045/283] #i92516# vcl helper for new print ui options --- vcl/inc/vcl/print.hxx | 97 +++++++++++++++++- vcl/source/gdi/print3.cxx | 203 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+), 1 deletion(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 727c08545cf4..93b635756e95 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -44,6 +44,8 @@ #include "com/sun/star/beans/PropertyValue.hpp" #include +#include +#include struct SalPrinterInfoQueue; class SalInfoPrinter; @@ -454,7 +456,7 @@ public: com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const; - /* get the PorpertyValue of a Property + /* get the PropertyValue of a Property */ com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ) const; @@ -496,6 +498,99 @@ public: void SAL_DLLPRIVATE setMultipage( int nRows, int nColumns, const Size& rPaperSize ); }; +class VCL_DLLPUBLIC PrinterOptionsHelper +{ + protected: + std::hash_map< rtl::OUString, com::sun::star::uno::Any, rtl::OUStringHash > m_aPropertyMap; + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > m_aUIProperties; + + public: + PrinterOptionsHelper() {} // create without ui properties + PrinterOptionsHelper( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rUIProperties ) + : m_aUIProperties( i_rUIProperties ) + {} + ~PrinterOptionsHelper() + {} + + /* process a new set of properties + * merges changed properties and returns "true" if any occured + * if the optional output set is not NULL then the names of the changed properties are returned + **/ + bool processProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rNewProp, + std::set< rtl::OUString >* o_pChangeProp = NULL ); + /* append to a sequence of property values the ui property sequence passed at creation + * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property + * will be appended. + **/ + void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const; + + // returns an empty Any for not existing properties + com::sun::star::uno::Any getValue( const rtl::OUString& i_rPropertyName ) const; + + sal_Bool getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault = sal_False ) const; + // convenience for fixed strings + sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const + { return getBoolValue( rtl::OUString::createFromAscii( i_pPropName ), i_bDefault ); } + + sal_Int32 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int32 i_nDefault = 0 ) const; + // convenience for fixed strings + sal_Int32 getIntValue( const char* i_pPropName, sal_Int32 i_nDefault = 0 ) const + { return getIntValue( rtl::OUString::createFromAscii( i_pPropName ), i_nDefault ); } + + rtl::OUString getStringValue( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rDefault = rtl::OUString() ) const; + // convenience for fixed strings + rtl::OUString getStringValue( const char* i_pPropName, const rtl::OUString& i_rDefault = rtl::OUString() ) const + { return getStringValue( rtl::OUString::createFromAscii( i_pPropName ), i_rDefault ); } + + // helper functions for user to create a single control + + // general control + static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const com::sun::star::beans::PropertyValue* i_pVal = NULL, + const com::sun::star::uno::Sequence< rtl::OUString >* i_pChoices = NULL, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1, + sal_Int32 i_nMinValue = -1, sal_Int32 i_nMaxValue = -2 + ); + // create a group (e.g. a TabPage); following controls will be grouped in it until the next + // group begins + static com::sun::star::uno::Any getGroupControlOpt( const rtl::OUString& i_rTitle ); + + // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next + // subgroup or group begins + static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle ); + + // create a bool option (usually a checkbox) + static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Bool i_bValue, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); + + // create a set of choices (either a radio button group or a list box) + static com::sun::star::uno::Any getChoiceControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices, + sal_Int32 i_nValue, + const rtl::OUString& i_rType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); + + // create an integer range (e.g. a spin field) + // note: max value < min value means do not apply min/max values + static com::sun::star::uno::Any getRangeControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Int32 i_nValue, + sal_Int32 i_nMinValue = -1, + sal_Int32 i_nMaxValue = -2, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); +}; + } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 2ba9a143c4e1..63e27b5b3a5f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -811,3 +811,206 @@ void PrinterListener::setMultipage( int i_nRows, int i_nColumns, const Size& rPa mpImplData->mnMultiPageColumns = i_nColumns; mpImplData->maMultiPageSize = rPaperSize; } + +/* + * PrinterOptionsHelper +**/ +Any PrinterOptionsHelper::getValue( const rtl::OUString& i_rPropertyName ) const +{ + Any aRet; + std::hash_map< rtl::OUString, Any, rtl::OUStringHash >::const_iterator it = + m_aPropertyMap.find( i_rPropertyName ); + if( it != m_aPropertyMap.end() ) + aRet = it->second; + return aRet; +} + +sal_Bool PrinterOptionsHelper::getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault ) const +{ + sal_Bool bRet = sal_False; + Any aVal( getValue( i_rPropertyName ) ); + return (aVal >>= bRet) ? bRet : i_bDefault; +} + +sal_Int32 PrinterOptionsHelper::getIntValue( const rtl::OUString& i_rPropertyName, sal_Int32 i_nDefault ) const +{ + sal_Int32 nRet = 0; + Any aVal( getValue( i_rPropertyName ) ); + return (aVal >>= nRet) ? nRet : i_nDefault; +} + +rtl::OUString PrinterOptionsHelper::getStringValue( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rDefault ) const +{ + rtl::OUString aRet; + Any aVal( getValue( i_rPropertyName ) ); + return (aVal >>= aRet) ? aRet : i_rDefault; +} + +bool PrinterOptionsHelper::processProperties( const Sequence< PropertyValue >& i_rNewProp, + std::set< rtl::OUString >* o_pChangeProp ) +{ + bool bChanged = false; + + // clear the changed set + if( o_pChangeProp ) + o_pChangeProp->clear(); + + sal_Int32 nElements = i_rNewProp.getLength(); + const PropertyValue* pVals = i_rNewProp.getConstArray(); + for( sal_Int32 i = 0; i < nElements; i++ ) + { + bool bElementChanged = false; + std::hash_map< rtl::OUString, Any, rtl::OUStringHash >::iterator it = + m_aPropertyMap.find( pVals[ i ].Name ); + if( it != m_aPropertyMap.end() ) + { + if( it->second != pVals[ i ].Value ) + bElementChanged = true; + } + else + bElementChanged = true; + + if( bElementChanged ) + { + if( o_pChangeProp ) + o_pChangeProp->insert( pVals[ i ].Name ); + m_aPropertyMap[ pVals[i].Name ] = pVals[i].Value; + bChanged = true; + } + } + return bChanged; +} + +void PrinterOptionsHelper::appendPrintUIOptions( uno::Sequence< beans::PropertyValue >& io_rProps ) const +{ + if( m_aUIProperties.getLength() > 0 ) + { + sal_Int32 nIndex = io_rProps.getLength(); + io_rProps.realloc( nIndex+1 ); + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExtraPrintUIOptions" ) ); + aVal.Value = makeAny( m_aUIProperties ); + io_rProps[ nIndex ] = aVal; + } +} + +Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rType, + const PropertyValue* i_pVal, + const Sequence< rtl::OUString >* i_pChoices, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry, + sal_Int32 i_nMinValue, + sal_Int32 i_nMaxValue + ) +{ + sal_Int32 nElements = + 1 // ControlType + + (i_rTitle.getLength() ? 1 : 0) // Text + + (i_pVal ? 1 : 0) // Property + + (i_pChoices ? 1 : 0) // Choices + + (i_pDependsOnName ? (i_nDependsOnEntry != -1 ? 2 : 1) : 0) // dependencies + + (i_nMaxValue >= i_nMinValue ? 2 : 0) // min/max + ; + + Sequence< PropertyValue > aCtrl( nElements ); + sal_Int32 nUsed = 0; + if( i_rTitle.getLength() ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); + aCtrl[nUsed++].Value = makeAny( i_rTitle ); + } + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlType" ) ); + aCtrl[nUsed++].Value = makeAny( i_rType ); + if( i_pVal ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pVal ); + } + if( i_pChoices ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pChoices ); + } + if( i_pDependsOnName ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); + aCtrl[nUsed++].Value = makeAny( *i_pDependsOnName ); + if( i_nDependsOnEntry != -1 ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); + aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); + } + } + if( i_nMaxValue >= i_nMinValue ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinValue" ) ); + aCtrl[nUsed++].Value = makeAny( i_nMinValue ); + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxValue" ) ); + aCtrl[nUsed++].Value = makeAny( i_nMaxValue ); + } + + DBG_ASSERT( nUsed == nElements, "nUsed != nElements, probable heap corruption" ); + + return makeAny( aCtrl ); +} + +Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle ) +{ + return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); +} + +Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle ) +{ + return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); +} + +Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Bool i_bValue, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry + ) +{ + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_bValue ); + return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); +} + +Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + const Sequence< rtl::OUString >& i_rChoices, + sal_Int32 i_nValue, + const rtl::OUString& i_rType, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry + ) +{ + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_nValue ); + return getUIControlOpt( i_rTitle, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); +} + +Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rProperty, + sal_Int32 i_nValue, + sal_Int32 i_nMinValue, + sal_Int32 i_nMaxValue, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry + ) +{ + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_nValue ); + return getUIControlOpt( i_rTitle, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Range" ) ), + &aVal, + NULL, + i_pDependsOnName, + i_nDependsOnEntry, + i_nMinValue, + i_nMaxValue ); +} From a8b3bdded3b8a0fa7cfd12e52b9d60ce3658019e Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 16 Apr 2009 05:47:42 +0000 Subject: [PATCH 046/283] #i92516# adjust positions --- vcl/source/src/print.src | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index b8d21e45fb84..05fa6e1d9ccc 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -38,18 +38,18 @@ ModalDialog SV_DLG_PRINT Moveable = TRUE; SVLook = TRUE; - Size = MAP_APPFONT( 350, 195 ); + Size = MAP_APPFONT( 350, 205 ); OKButton SV_PRINT_OK { DefButton = TRUE; - Pos = MAP_APPFONT( 240, 175 ); + Pos = MAP_APPFONT( 240, 185 ); Size = MAP_APPFONT( 50, 15 ); Text [en-US] = "~Print"; }; CancelButton SV_PRINT_CANCEL { - Pos = MAP_APPFONT( 295, 175 ); + Pos = MAP_APPFONT( 295, 185 ); Size = MAP_APPFONT( 50, 15 ); }; @@ -77,11 +77,11 @@ ModalDialog SV_DLG_PRINT TabControl SV_PRINT_TABCTRL { Pos = MAP_APPFONT( 140, 5 ); - Size = MAP_APPFONT( 205, 160 ); + Size = MAP_APPFONT( 205, 165 ); }; FixedLine SV_PRINT_BUTTONLINE { - Pos = MAP_APPFONT( 0, 165 ); + Pos = MAP_APPFONT( 0, 175 ); Size = MAP_APPFONT( 350, 8 ); }; String SV_PRINT_NOPAGES From 198632aa538edc6804909fe7330fc122b769398b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 20 Apr 2009 16:57:13 +0000 Subject: [PATCH 047/283] CWS-TOOLING: rebase CWS printerpullpages to trunk@270723 (milestone: DEV300:m46) --- .../inc/basegfx/polygon/b3dpolygontools.hxx | 14 + basegfx/source/polygon/b3dpolygontools.cxx | 62 ++++ comphelper/source/misc/storagehelper.cxx | 2 +- i18nutil/inc/i18nutil/casefolding.hxx | 24 +- i18nutil/source/utility/casefolding.cxx | 12 +- padmin/prj/build.lst | 2 +- padmin/source/prtsetup.cxx | 17 - padmin/source/prtsetup.hxx | 2 - svtools/source/edit/editsyntaxhighlighter.cxx | 5 +- svtools/source/edit/svmedit.cxx | 2 +- toolkit/workben/layout/editor.cxx | 1 + toolkit/workben/layout/makefile.mk | 2 +- tools/bootstrp/rscdep.cxx | 10 +- vcl/aqua/inc/saldata.hxx | 3 +- vcl/aqua/source/app/saldata.cxx | 5 +- vcl/aqua/source/app/salinst.cxx | 7 +- vcl/aqua/source/gdi/salatslayout.cxx | 55 +-- vcl/aqua/source/gdi/salatsuifontutils.cxx | 177 ++++++---- vcl/aqua/source/gdi/salgdi.cxx | 20 +- vcl/aqua/source/window/salframeview.mm | 2 +- vcl/aqua/source/window/salmenu.cxx | 2 +- vcl/aqua/source/window/salobj.cxx | 7 +- vcl/inc/list.h | 3 +- vcl/inc/{sft.h => sft.hxx} | 29 +- vcl/inc/vcl/svdata.hxx | 1 + vcl/os2/source/gdi/salgdi3.cxx | 7 +- vcl/prj/build.lst | 2 +- vcl/source/app/svdata.cxx | 14 + vcl/source/fontsubset/crc32.c | 89 ----- vcl/source/fontsubset/crc32.h | 46 --- vcl/source/fontsubset/gsub.cxx | 12 +- vcl/source/fontsubset/gsub.h | 18 +- vcl/source/fontsubset/list.c | 9 +- vcl/source/fontsubset/makefile.mk | 4 - vcl/source/fontsubset/{sft.c => sft.cxx} | 334 ++++++++---------- vcl/source/fontsubset/{ttcr.c => ttcr.cxx} | 234 ++++++------ vcl/source/fontsubset/{ttcr.h => ttcr.hxx} | 47 +-- vcl/source/fontsubset/u2big5.inc | 5 +- vcl/source/fontsubset/u2johab.inc | 5 +- vcl/source/fontsubset/u2prc.inc | 5 +- vcl/source/fontsubset/u2shiftjis.inc | 5 +- vcl/source/fontsubset/u2wansung.inc | 5 +- vcl/source/fontsubset/{xlat.c => xlat.cxx} | 13 +- vcl/source/fontsubset/{xlat.h => xlat.hxx} | 24 +- vcl/source/gdi/font.cxx | 4 +- vcl/source/gdi/pdfwriter_impl.cxx | 43 ++- vcl/source/gdi/sallayout.cxx | 2 +- vcl/source/helper/smartid.cxx | 2 +- vcl/source/window/decoview.cxx | 13 +- vcl/source/window/menu.cxx | 200 +++++++---- vcl/source/window/winproc.cxx | 18 +- vcl/unx/gtk/a11y/atktext.cxx | 8 +- vcl/unx/gtk/app/gtkinst.cxx | 16 +- vcl/unx/gtk/window/gtkframe.cxx | 17 +- vcl/unx/inc/saldata.hxx | 2 - vcl/unx/source/app/saldata.cxx | 13 - vcl/unx/source/fontmanager/fontmanager.cxx | 5 +- vcl/unx/source/gdi/salgdi.cxx | 5 + vcl/unx/source/plugadapt/salplug.cxx | 16 +- vcl/unx/source/printergfx/glyphset.cxx | 5 +- vcl/util/makefile.mk | 2 - vcl/win/source/gdi/salgdi3.cxx | 5 +- vcl/win/source/gdi/winlayout.cxx | 20 +- 63 files changed, 840 insertions(+), 900 deletions(-) rename vcl/inc/{sft.h => sft.hxx} (98%) delete mode 100644 vcl/source/fontsubset/crc32.c delete mode 100644 vcl/source/fontsubset/crc32.h rename vcl/source/fontsubset/{sft.c => sft.cxx} (93%) rename vcl/source/fontsubset/{ttcr.c => ttcr.cxx} (89%) rename vcl/source/fontsubset/{ttcr.h => ttcr.hxx} (94%) rename vcl/source/fontsubset/{xlat.c => xlat.cxx} (97%) rename vcl/source/fontsubset/{xlat.h => xlat.hxx} (78%) diff --git a/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx index 7b451970c565..a29204eadc3f 100644 --- a/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b3dpolygontools.hxx @@ -174,6 +174,20 @@ namespace basegfx bool equal(const B3DPolygon& rCandidateA, const B3DPolygon& rCandidateB, const double& rfSmallValue); bool equal(const B3DPolygon& rCandidateA, const B3DPolygon& rCandidateB); + /** snap some polygon coordinates to discrete coordinates + + This method allows to snap some polygon points to discrete (integer) values + which equals e.g. a snap to discrete coordinates. It will snap points of + horizontal and vertical edges + + @param rCandidate + The source polygon + + @return + The modified version of the source polygon + */ + B3DPolygon snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon& rCandidate); + } // end of namespace tools } // end of namespace basegfx diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index 3ea163a85e89..ea303886dd88 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include ////////////////////////////////////////////////////////////////////////////// @@ -1101,6 +1102,67 @@ namespace basegfx return equal(rCandidateA, rCandidateB, fSmallValue); } + // snap points of horizontal or vertical edges to discrete values + B3DPolygon snapPointsOfHorizontalOrVerticalEdges(const B3DPolygon& rCandidate) + { + const sal_uInt32 nPointCount(rCandidate.count()); + + if(nPointCount > 1) + { + // Start by copying the source polygon to get a writeable copy. The closed state is + // copied by aRetval's initialisation, too, so no need to copy it in this method + B3DPolygon aRetval(rCandidate); + + // prepare geometry data. Get rounded from original + B3ITuple aPrevTuple(basegfx::fround(rCandidate.getB3DPoint(nPointCount - 1))); + B3DPoint aCurrPoint(rCandidate.getB3DPoint(0)); + B3ITuple aCurrTuple(basegfx::fround(aCurrPoint)); + + // loop over all points. This will also snap the implicit closing edge + // even when not closed, but that's no problem here + for(sal_uInt32 a(0); a < nPointCount; a++) + { + // get next point. Get rounded from original + const bool bLastRun(a + 1 == nPointCount); + const sal_uInt32 nNextIndex(bLastRun ? 0 : a + 1); + const B3DPoint aNextPoint(rCandidate.getB3DPoint(nNextIndex)); + const B3ITuple aNextTuple(basegfx::fround(aNextPoint)); + + // get the states + const bool bPrevVertical(aPrevTuple.getX() == aCurrTuple.getX()); + const bool bNextVertical(aNextTuple.getX() == aCurrTuple.getX()); + const bool bPrevHorizontal(aPrevTuple.getY() == aCurrTuple.getY()); + const bool bNextHorizontal(aNextTuple.getY() == aCurrTuple.getY()); + const bool bSnapX(bPrevVertical || bNextVertical); + const bool bSnapY(bPrevHorizontal || bNextHorizontal); + + if(bSnapX || bSnapY) + { + const B3DPoint aSnappedPoint( + bSnapX ? aCurrTuple.getX() : aCurrPoint.getX(), + bSnapY ? aCurrTuple.getY() : aCurrPoint.getY(), + aCurrPoint.getZ()); + + aRetval.setB3DPoint(a, aSnappedPoint); + } + + // prepare next point + if(!bLastRun) + { + aPrevTuple = aCurrTuple; + aCurrPoint = aNextPoint; + aCurrTuple = aNextTuple; + } + } + + return aRetval; + } + else + { + return rCandidate; + } + } + } // end of namespace tools } // end of namespace basegfx diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 7d63ed7a43f5..d2284409bdce 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -427,7 +427,7 @@ sal_Bool OStorageHelper::IsValidZipEntryFileName( return sal_False; break; default: - if ( pChar[i] < 32 || pChar[i] >= 0xD800 && pChar[i] <= 0xDFFF ) + if ( pChar[i] < 32 || (pChar[i] >= 0xD800 && pChar[i] <= 0xDFFF) ) return sal_False; } } diff --git a/i18nutil/inc/i18nutil/casefolding.hxx b/i18nutil/inc/i18nutil/casefolding.hxx index 2c993d43f75d..bc67f4fce47e 100644 --- a/i18nutil/inc/i18nutil/casefolding.hxx +++ b/i18nutil/inc/i18nutil/casefolding.hxx @@ -37,20 +37,20 @@ namespace com { namespace sun { namespace star { namespace i18n { -#define MappingTypeLowerToUpper 1 << 0 // Upper to Lower mapping -#define MappingTypeUpperToLower 1 << 1 // Lower to Upper mapping -#define MappingTypeToUpper 1 << 2 // to Upper mapping -#define MappingTypeToLower 1 << 3 // to Lower mapping -#define MappingTypeToTitle 1 << 4 // to Title mapping -#define MappingTypeSimpleFolding 1 << 5 // Simple Case Folding -#define MappingTypeFullFolding 1 << 6 // Full Case Folding -#define MappingTypeMask MappingTypeLowerToUpper|MappingTypeUpperToLower|\ +#define MappingTypeLowerToUpper (1 << 0) // Upper to Lower mapping +#define MappingTypeUpperToLower (1 << 1) // Lower to Upper mapping +#define MappingTypeToUpper (1 << 2) // to Upper mapping +#define MappingTypeToLower (1 << 3) // to Lower mapping +#define MappingTypeToTitle (1 << 4) // to Title mapping +#define MappingTypeSimpleFolding (1 << 5) // Simple Case Folding +#define MappingTypeFullFolding (1 << 6) // Full Case Folding +#define MappingTypeMask (MappingTypeLowerToUpper|MappingTypeUpperToLower|\ MappingTypeToUpper|MappingTypeToLower|MappingTypeToTitle|\ - MappingTypeSimpleFolding|MappingTypeFullFolding + MappingTypeSimpleFolding|MappingTypeFullFolding) -#define ValueTypeNotValue 1 << 7 // Value field is an address +#define ValueTypeNotValue (1 << 7) // Value field is an address -#define CasedLetter MappingTypeMask // for final sigmar +#define CasedLetter (MappingTypeMask) // for final sigmar struct Value { @@ -68,7 +68,7 @@ struct Mapping struct MappingElement { - MappingElement() {element.nmap = current = 0;}; + MappingElement() {element.nmap = current = 0;} Mapping element; sal_Int8 current; }; diff --git a/i18nutil/source/utility/casefolding.cxx b/i18nutil/source/utility/casefolding.cxx index 8a679b8afbe5..7a74609b0342 100644 --- a/i18nutil/source/utility/casefolding.cxx +++ b/i18nutil/source/utility/casefolding.cxx @@ -51,13 +51,13 @@ static Mapping mapping_0130[] = {{0, 1, {0x0069, 0, 0}},{0, 1, {0x0130, 0, 0}}}; #define langIs(lang) (aLocale.Language.compareToAscii(lang) == 0) // only check simple case, there is more complicated case need to be checked. -#define type_i(ch) (ch == 0x0069 || ch == 0x006a) +#define type_i(ch) ((ch) == 0x0069 || (ch) == 0x006a) -#define cased_letter(ch) (CaseMappingIndex[ch>>8] >= 0 && (CaseMappingValue[(CaseMappingIndex[ch>>8] << 8) + (ch&0xff)].type & CasedLetter)) +#define cased_letter(ch) (CaseMappingIndex[(ch)>>8] >= 0 && (CaseMappingValue[(CaseMappingIndex[(ch)>>8] << 8) + ((ch)&0xff)].type & CasedLetter)) // for Lithuanian, condition to make explicit dot above when lowercasing capital I's and J's // whenever there are more accents above. -#define accent_above(ch) (ch >= 0x0300 && ch <= 0x0314 || ch >= 0x033D && ch <= 0x0344 || ch == 0x0346 || ch >= 0x034A && ch <= 0x034C) +#define accent_above(ch) (((ch) >= 0x0300 && (ch) <= 0x0314) || ((ch) >= 0x033D && (ch) <= 0x0344) || (ch) == 0x0346 || ((ch) >= 0x034A && (ch) <= 0x034C)) Mapping& casefolding::getConditionalValue(const sal_Unicode* str, sal_Int32 pos, sal_Int32 len, Locale& aLocale, sal_uInt8 nMappingType) throw (RuntimeException) { @@ -68,8 +68,8 @@ Mapping& casefolding::getConditionalValue(const sal_Unicode* str, sal_Int32 pos, return !(pos < len && cased_letter(str[pos+1])) && (pos > 0 && cased_letter(str[pos-1])) ? mapping_03a3[0] : mapping_03a3[1]; case 0x0307: - return ((nMappingType == MappingTypeLowerToUpper && langIs("lt") || - nMappingType == MappingTypeUpperToLower && (langIs("tr") || langIs("az"))) && + return (((nMappingType == MappingTypeLowerToUpper && langIs("lt")) || + (nMappingType == MappingTypeUpperToLower && (langIs("tr") || langIs("az")))) && (pos > 0 && type_i(str[pos-1]))) ? // after_i mapping_0307[0] : mapping_0307[1]; case 0x0130: @@ -147,7 +147,7 @@ sal_Unicode casefolding::getNextChar(const sal_Unicode *str, sal_Int32& idx, sal } if (moduleLoaded & TransliterationModules_IGNORE_KANA) { - if (0x3040 <= c && c <= 0x3094 || 0x309d <= c && c <= 0x309f) + if ((0x3040 <= c && c <= 0x3094) || (0x309d <= c && c <= 0x309f)) c += 0x60; } diff --git a/padmin/prj/build.lst b/padmin/prj/build.lst index 9aaab83cf7de..765675d73137 100644 --- a/padmin/prj/build.lst +++ b/padmin/prj/build.lst @@ -1,3 +1,3 @@ -pd padmin : vcl svtools NULL +pd padmin : psprint vcl svtools NULL pd padmin usr1 - all pd_mkout NULL pd padmin\source nmake - all pd_source NULL diff --git a/padmin/source/prtsetup.cxx b/padmin/source/prtsetup.cxx index 1a6894789bb5..6cf4f8b257b1 100644 --- a/padmin/source/prtsetup.cxx +++ b/padmin/source/prtsetup.cxx @@ -148,23 +148,6 @@ RTSDialog::~RTSDialog() // -------------------------------------------------------------------------- -String RTSDialog::getPaperSize() -{ - String aRet; - if( m_aJobData.m_pParser ) - { - const PPDKey* pKey = m_aJobData.m_pParser->getKey( String::CreateFromAscii( "PageSize" ) ); - if( pKey ) - { - const PPDValue* pValue = m_aJobData.m_aContext.getValue( pKey ); - aRet = pValue->m_aOption; - } - } - return aRet; -} - -// -------------------------------------------------------------------------- - IMPL_LINK( RTSDialog, ActivatePage, TabControl*, pTabCtrl ) { if( pTabCtrl != &m_aTabControl ) diff --git a/padmin/source/prtsetup.hxx b/padmin/source/prtsetup.hxx index 56e68336dfd8..8487daa158da 100644 --- a/padmin/source/prtsetup.hxx +++ b/padmin/source/prtsetup.hxx @@ -86,8 +86,6 @@ class RTSDialog : public TabDialog // helper functions void insertAllPPDValues( ListBox&, const ::psp::PPDKey* ); - - String getPaperSize(); public: RTSDialog( const ::psp::PrinterInfo& rJobData, const String& rPrinter, bool bAllPages, Window* pParent = NULL ); ~RTSDialog(); diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index 334b19ccd98d..74d72e32155c 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -108,8 +108,11 @@ void MultiLineEditSyntaxHighlight::DoBracketHilight(USHORT aKey) { for (long aPara =nStartPara; aPara>=0;--aPara) { + if ( aStartPos == 0 ) + continue; + String aLine( GetTextEngine()->GetText( aPara ) ); - for (USHORT i = ((unsigned long)aPara==nStartPara) ? aStartPos-1 : (USHORT)(GetTextEngine()->GetTextLen()-1); i>0; --i) + for (USHORT i = ((unsigned long)aPara==nStartPara) ? aStartPos-1 : (USHORT)(aLine.Len()-1); i>0; --i) { if (aLine.GetChar(i)==aChar) { diff --git a/svtools/source/edit/svmedit.cxx b/svtools/source/edit/svmedit.cxx index 42026382385f..279af7c83cef 100644 --- a/svtools/source/edit/svmedit.cxx +++ b/svtools/source/edit/svmedit.cxx @@ -218,7 +218,7 @@ void ImpSvMEdit::ImpUpdateSrollBarVis( WinBits nWinStyle ) bNeedVScroll = true; } - const BOOL bNeedScrollBox = bNeedVScroll || bNeedHScroll; + const BOOL bNeedScrollBox = bNeedVScroll && bNeedHScroll; BOOL bScrollbarsChanged = false; if ( bHaveVScroll != bNeedVScroll ) diff --git a/toolkit/workben/layout/editor.cxx b/toolkit/workben/layout/editor.cxx index c8e44a9c9180..0ef31560b69f 100644 --- a/toolkit/workben/layout/editor.cxx +++ b/toolkit/workben/layout/editor.cxx @@ -34,6 +34,7 @@ #undef NDEBUG #include #include +#include #include #include diff --git a/toolkit/workben/layout/makefile.mk b/toolkit/workben/layout/makefile.mk index 8612992303d8..a7f1a8dfcb97 100644 --- a/toolkit/workben/layout/makefile.mk +++ b/toolkit/workben/layout/makefile.mk @@ -89,7 +89,7 @@ XML_FILES=\ wordcount.xml\ zoom.xml\ -TRALAY=tralay +TRALAY=$(AUGMENT_LIBRARY_PATH) tralay XML_LANGS=$(alllangiso) #ALL_XMLS=$(foreach,i,$(XML_LANGS) $(foreach,j,$(XML_FILES) $i/$j)) diff --git a/tools/bootstrp/rscdep.cxx b/tools/bootstrp/rscdep.cxx index 7c394dcdaee8..d4411058a6fb 100644 --- a/tools/bootstrp/rscdep.cxx +++ b/tools/bootstrp/rscdep.cxx @@ -96,7 +96,9 @@ main( int argc, char **argv ) String aSrsBaseName; BOOL bSource = FALSE; ByteString aRespArg; - String aDelim = String(DirEntry::GetAccessDelimiter()); +// who needs anything but '/' ? +// String aDelim = String(DirEntry::GetAccessDelimiter()); + String aDelim = '/'; RscHrcDep *pDep = new RscHrcDep; @@ -256,6 +258,7 @@ main( int argc, char **argv ) printf("further arguments : "); #endif aString = ByteString( pSrsFileName ); + aString.SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); aString += ByteString(" : " ); while ( optind < argc ) @@ -289,12 +292,7 @@ main( int argc, char **argv ) for ( ULONG j=0; jGetObject(j); -#ifdef UNX pStr->SearchAndReplaceAll('\\', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); -#endif -#ifdef WNT - pStr->SearchAndReplaceAll('/', ByteString( aDelim, RTL_TEXTENCODING_ASCII_US )); -#endif if ( j != (nCount-1) ) *pStr += ByteString( "\\" ); aOutStream.WriteLine( *pStr ); diff --git a/vcl/aqua/inc/saldata.hxx b/vcl/aqua/inc/saldata.hxx index 931369982f03..dc629b9a3b8c 100644 --- a/vcl/aqua/inc/saldata.hxx +++ b/vcl/aqua/inc/saldata.hxx @@ -107,9 +107,10 @@ struct SalData bool mbIsScrollbarDoubleMax; // TODO: support DoubleMin and DoubleBoth too SInt32 mnSystemVersion; // Store System Version MainController* mpMainController; // Apple Remote - bool mbIsTestTool; NSObject* mpDockIconClickHandler; + long mnDPIX; // #i100617# read DPI only once per office life + long mnDPIY; // #i100617# read DPI only once per office life SalData(); ~SalData(); diff --git a/vcl/aqua/source/app/saldata.cxx b/vcl/aqua/source/app/saldata.cxx index b110141fb224..a70854306122 100644 --- a/vcl/aqua/source/app/saldata.cxx +++ b/vcl/aqua/source/app/saldata.cxx @@ -61,8 +61,9 @@ SalData::SalData() mbIsScrollbarDoubleMax( false ), mnSystemVersion( VER_TIGER ), mpMainController( NULL ), - mbIsTestTool( false ), - mpDockIconClickHandler( nil ) + mpDockIconClickHandler( nil ), + mnDPIX( 0 ), + mnDPIY( 0 ) { if( s_aAutoReleaseKey == 0 ) s_aAutoReleaseKey = osl_createThreadKey( releasePool ); diff --git a/vcl/aqua/source/app/salinst.cxx b/vcl/aqua/source/app/salinst.cxx index 0523381b9223..b9d66d1e02d3 100644 --- a/vcl/aqua/source/app/salinst.cxx +++ b/vcl/aqua/source/app/salinst.cxx @@ -178,7 +178,6 @@ static void initNSApp() // get System Version and store the value in GetSalData()->mnSystemVersion [NSApp getSystemVersionMajor: (unsigned int *)major minor:(unsigned int *)minor bugFix:(unsigned int *)bugFix ]; -// ----------------------------------------------------------------------------------------------------------------- // Initialize Apple Remote GetSalData()->mpMainController = [[MainController alloc] init]; @@ -191,13 +190,9 @@ static void initNSApp() selector: @selector(applicationWillResignActive:) name: @"AppleRemoteWillResignActive" object: nil ]; -// ----------------------------------------------------------------------------------------------------------------- - if( AquaSalInstance::isOnCommandLine( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "-enableautomation" ) ) ) ) - { + if( ImplGetSVData()->mbIsTestTool ) [NSApp activateIgnoringOtherApps: YES]; - GetSalData()->mbIsTestTool = true; - } } BOOL ImplSVMainHook( BOOL * pbInit ) diff --git a/vcl/aqua/source/gdi/salatslayout.cxx b/vcl/aqua/source/gdi/salatslayout.cxx index 929c8dd19c64..f47920004f7a 100755 --- a/vcl/aqua/source/gdi/salatslayout.cxx +++ b/vcl/aqua/source/gdi/salatslayout.cxx @@ -711,6 +711,31 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons if( !maATSULayout ) return STRING_LEN; + // the semantics of the legacy use case (nCharExtra!=0) cannot be mapped to ATSUBreakLine() + if( nCharExtra != 0 ) + { + // prepare the measurement by layouting and measuring the un-expanded/un-condensed text + if( !InitGIA() ) + return STRING_LEN; + + // TODO: use a better way than by testing each the char position + ATSUTextMeasurement nATSUSumWidth = 0; + const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nMaxWidth / nFactor ); + const ATSUTextMeasurement nATSUExtraWidth = Vcl2Fixed( nCharExtra ) / nFactor; + for( int i = 0; i < mnCharCount; ++i ) + { + nATSUSumWidth += mpCharWidths[i]; + if( nATSUSumWidth >= nATSUMaxWidth ) + return (mnMinCharPos + i); + nATSUSumWidth += nATSUExtraWidth; + if( nATSUSumWidth >= nATSUMaxWidth ) + if( i+1 < mnCharCount ) + return (mnMinCharPos + i); + } + + return STRING_LEN; + } + // get a quick overview on what could fit const long nPixelWidth = (nMaxWidth - (nCharExtra * mnCharCount)) / nFactor; @@ -720,10 +745,10 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons // initial measurement of text break position UniCharArrayOffset nBreakPos = mnMinCharPos; const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nPixelWidth ); - OSStatus nStatus = ATSUBreakLine( maATSULayout, mnMinCharPos, + OSStatus eStatus = ATSUBreakLine( maATSULayout, mnMinCharPos, nATSUMaxWidth, false, &nBreakPos ); - if( (nStatus != noErr) && (nStatus != kATSULineBreakInWord) ) + if( (eStatus != noErr) && (eStatus != kATSULineBreakInWord) ) return STRING_LEN; // the result from ATSUBreakLine() doesn't match the semantics expected by its @@ -734,26 +759,6 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons if( nBreakPos >= static_cast(mnEndCharPos) ) return STRING_LEN; - // for the nCharExtra!=0 case the resulting nBreakPos needs be involved - if( nCharExtra != 0 ) - { - // age-old nCharExtra!=0 semantic is quite incompatible with ATSUBreakLine() - // TODO: use a better way than by testing each the char position - InitGIA(); - ATSUTextMeasurement nATSUSumWidth = 0; - const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nMaxWidth / nFactor ); - const ATSUTextMeasurement nATSUExtraWidth = Vcl2Fixed( nCharExtra ) / nFactor; - for( int i = 0; i < mnCharCount; ++i) - { - nATSUSumWidth += mpCharWidths[i]; - if( nATSUSumWidth >= nATSUMaxWidth ) - return (mnMinCharPos + i); - nATSUSumWidth += nATSUExtraWidth; - } - - return STRING_LEN; - } - // GetTextBreak()'s callers expect it to return the "stupid visual line break". // Returning anything else result.s in subtle problems in the application layers. static const bool bInWord = true; // TODO: add as argument to GetTextBreak() method @@ -762,15 +767,15 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons // emulate stupid visual line breaking by line breaking for the remaining width ATSUTextMeasurement nLeft, nRight, nDummy; - nStatus = ATSUGetUnjustifiedBounds( maATSULayout, mnMinCharPos, nBreakPos-mnMinCharPos, + eStatus = ATSUGetUnjustifiedBounds( maATSULayout, mnMinCharPos, nBreakPos-mnMinCharPos, &nLeft, &nRight, &nDummy, &nDummy ); - if( nStatus != noErr ) + if( eStatus != noErr ) return nBreakPos; const ATSUTextMeasurement nATSURemWidth = nATSUMaxWidth - (nRight - nLeft); if( nATSURemWidth <= 0 ) return nBreakPos; UniCharArrayOffset nBreakPosInWord = nBreakPos; - nStatus = ATSUBreakLine( maATSULayout, nBreakPos, nATSURemWidth, false, &nBreakPosInWord ); + eStatus = ATSUBreakLine( maATSULayout, nBreakPos, nATSURemWidth, false, &nBreakPosInWord ); return nBreakPosInWord; } diff --git a/vcl/aqua/source/gdi/salatsuifontutils.cxx b/vcl/aqua/source/gdi/salatsuifontutils.cxx index 6c8fe86bdaef..595b7d276a2a 100644 --- a/vcl/aqua/source/gdi/salatsuifontutils.cxx +++ b/vcl/aqua/source/gdi/salatsuifontutils.cxx @@ -46,17 +46,17 @@ // and SFNT fonts on Mac usually do not contain an OS/2 table. static void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttributes& rDFA ) { - // TODO: use a multi-string ignore-case matcher once it becomes available - String aPSName = rPSName; + ByteString aPSName( rPSName, RTL_TEXTENCODING_UTF8 ); aPSName.ToLowerAscii(); - if( (aPSName.SearchAscii("regular") != STRING_NOTFOUND) - || (aPSName.SearchAscii("normal") != STRING_NOTFOUND) - || (aPSName.SearchAscii("roman") != STRING_NOTFOUND) - || (aPSName.SearchAscii("medium") != STRING_NOTFOUND) - || (aPSName.SearchAscii("plain") != STRING_NOTFOUND) - || (aPSName.SearchAscii("standard") != STRING_NOTFOUND) - || (aPSName.SearchAscii("std") != STRING_NOTFOUND) ) + // TODO: use a multi-string ignore-case matcher once it becomes available + if( (aPSName.Search("regular") != STRING_NOTFOUND) + || (aPSName.Search("normal") != STRING_NOTFOUND) + || (aPSName.Search("roman") != STRING_NOTFOUND) + || (aPSName.Search("medium") != STRING_NOTFOUND) + || (aPSName.Search("plain") != STRING_NOTFOUND) + || (aPSName.Search("standard") != STRING_NOTFOUND) + || (aPSName.Search("std") != STRING_NOTFOUND) ) { rDFA.meWidthType = WIDTH_NORMAL; rDFA.meWeight = WEIGHT_NORMAL; @@ -64,110 +64,133 @@ static void UpdateAttributesFromPSName( const String& rPSName, ImplDevFontAttrib } // heuristics for font weight - if (aPSName.SearchAscii("extrablack") != STRING_NOTFOUND) + if (aPSName.Search("extrablack") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_BLACK; - else if (aPSName.SearchAscii("black") != STRING_NOTFOUND) + else if (aPSName.Search("black") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_BLACK; - //else if (aPSName.SearchAscii("book") != STRING_NOTFOUND) + //else if (aPSName.Search("book") != STRING_NOTFOUND) // rDFA.meWeight = WEIGHT_SEMIBOLD; - else if( (aPSName.SearchAscii("semibold") != STRING_NOTFOUND) - || (aPSName.SearchAscii("smbd") != STRING_NOTFOUND)) + else if( (aPSName.Search("semibold") != STRING_NOTFOUND) + || (aPSName.Search("smbd") != STRING_NOTFOUND)) rDFA.meWeight = WEIGHT_SEMIBOLD; - else if (aPSName.SearchAscii("ultrabold") != STRING_NOTFOUND) + else if (aPSName.Search("ultrabold") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_ULTRABOLD; - else if (aPSName.SearchAscii("extrabold") != STRING_NOTFOUND) + else if (aPSName.Search("extrabold") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_BLACK; - else if( (aPSName.SearchAscii("bold") != STRING_NOTFOUND) - || (aPSName.SearchAscii("-bd") != STRING_NOTFOUND)) + else if( (aPSName.Search("bold") != STRING_NOTFOUND) + || (aPSName.Search("-bd") != STRING_NOTFOUND)) rDFA.meWeight = WEIGHT_BOLD; - else if (aPSName.SearchAscii("extralight") != STRING_NOTFOUND) + else if (aPSName.Search("extralight") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_ULTRALIGHT; - else if (aPSName.SearchAscii("ultralight") != STRING_NOTFOUND) + else if (aPSName.Search("ultralight") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_ULTRALIGHT; - else if (aPSName.SearchAscii("light") != STRING_NOTFOUND) + else if (aPSName.Search("light") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_LIGHT; - else if (aPSName.SearchAscii("thin") != STRING_NOTFOUND) + else if (aPSName.Search("thin") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_THIN; - else if (aPSName.SearchAscii("-w3") != STRING_NOTFOUND) + else if (aPSName.Search("-w3") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_LIGHT; - else if (aPSName.SearchAscii("-w4") != STRING_NOTFOUND) + else if (aPSName.Search("-w4") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_SEMILIGHT; - else if (aPSName.SearchAscii("-w5") != STRING_NOTFOUND) + else if (aPSName.Search("-w5") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_NORMAL; - else if (aPSName.SearchAscii("-w6") != STRING_NOTFOUND) + else if (aPSName.Search("-w6") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_SEMIBOLD; - else if (aPSName.SearchAscii("-w7") != STRING_NOTFOUND) + else if (aPSName.Search("-w7") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_BOLD; - else if (aPSName.SearchAscii("-w8") != STRING_NOTFOUND) + else if (aPSName.Search("-w8") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_ULTRABOLD; - else if (aPSName.SearchAscii("-w9") != STRING_NOTFOUND) + else if (aPSName.Search("-w9") != STRING_NOTFOUND) rDFA.meWeight = WEIGHT_BLACK; // heuristics for font slant - if( (aPSName.SearchAscii("italic") != STRING_NOTFOUND) - || (aPSName.SearchAscii(" ital") != STRING_NOTFOUND) - || (aPSName.SearchAscii("cursive") != STRING_NOTFOUND) - || (aPSName.SearchAscii("-it") != STRING_NOTFOUND) - || (aPSName.SearchAscii("lightit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("mediumit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("boldit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("cnit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("bdcn") != STRING_NOTFOUND) - || (aPSName.SearchAscii("bdit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("condit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("bookit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("blackit") != STRING_NOTFOUND) - || (aPSName.SearchAscii("libertineio") != STRING_NOTFOUND) ) + if( (aPSName.Search("italic") != STRING_NOTFOUND) + || (aPSName.Search(" ital") != STRING_NOTFOUND) + || (aPSName.Search("cursive") != STRING_NOTFOUND) + || (aPSName.Search("-it") != STRING_NOTFOUND) + || (aPSName.Search("lightit") != STRING_NOTFOUND) + || (aPSName.Search("mediumit") != STRING_NOTFOUND) + || (aPSName.Search("boldit") != STRING_NOTFOUND) + || (aPSName.Search("cnit") != STRING_NOTFOUND) + || (aPSName.Search("bdcn") != STRING_NOTFOUND) + || (aPSName.Search("bdit") != STRING_NOTFOUND) + || (aPSName.Search("condit") != STRING_NOTFOUND) + || (aPSName.Search("bookit") != STRING_NOTFOUND) + || (aPSName.Search("blackit") != STRING_NOTFOUND) ) rDFA.meItalic = ITALIC_NORMAL; - if( (aPSName.SearchAscii("oblique") != STRING_NOTFOUND) - || (aPSName.SearchAscii("inclined") != STRING_NOTFOUND) - || (aPSName.SearchAscii("slanted") != STRING_NOTFOUND) ) + if( (aPSName.Search("oblique") != STRING_NOTFOUND) + || (aPSName.Search("inclined") != STRING_NOTFOUND) + || (aPSName.Search("slanted") != STRING_NOTFOUND) ) rDFA.meItalic = ITALIC_OBLIQUE; // heuristics for font width - if( (aPSName.SearchAscii("condensed") != STRING_NOTFOUND) - || (aPSName.SearchAscii("-cond") != STRING_NOTFOUND) - || (aPSName.SearchAscii("boldcond") != STRING_NOTFOUND) - || (aPSName.SearchAscii("boldcn") != STRING_NOTFOUND) - || (aPSName.SearchAscii("cnit") != STRING_NOTFOUND) ) + if( (aPSName.Search("condensed") != STRING_NOTFOUND) + || (aPSName.Search("-cond") != STRING_NOTFOUND) + || (aPSName.Search("boldcond") != STRING_NOTFOUND) + || (aPSName.Search("boldcn") != STRING_NOTFOUND) + || (aPSName.Search("cnit") != STRING_NOTFOUND) ) rDFA.meWidthType = WIDTH_CONDENSED; - else if (aPSName.SearchAscii("narrow") != STRING_NOTFOUND) + else if (aPSName.Search("narrow") != STRING_NOTFOUND) rDFA.meWidthType = WIDTH_SEMI_CONDENSED; - else if (aPSName.SearchAscii("expanded") != STRING_NOTFOUND) + else if (aPSName.Search("expanded") != STRING_NOTFOUND) rDFA.meWidthType = WIDTH_EXPANDED; - else if (aPSName.SearchAscii("wide") != STRING_NOTFOUND) + else if (aPSName.Search("wide") != STRING_NOTFOUND) rDFA.meWidthType = WIDTH_EXPANDED; // heuristics for font pitch - if( (aPSName.SearchAscii("mono") != STRING_NOTFOUND) - || (aPSName.SearchAscii("courier") != STRING_NOTFOUND) - || (aPSName.SearchAscii("monaco") != STRING_NOTFOUND) - || (aPSName.SearchAscii("typewriter") != STRING_NOTFOUND) ) + if( (aPSName.Search("mono") != STRING_NOTFOUND) + || (aPSName.Search("courier") != STRING_NOTFOUND) + || (aPSName.Search("monaco") != STRING_NOTFOUND) + || (aPSName.Search("typewriter") != STRING_NOTFOUND) ) rDFA.mePitch = PITCH_FIXED; // heuristics for font family type - if( (aPSName.SearchAscii("script") != STRING_NOTFOUND) - || (aPSName.SearchAscii("chancery") != STRING_NOTFOUND) - || (aPSName.SearchAscii("zapfino") != STRING_NOTFOUND)) + if( (aPSName.Search("script") != STRING_NOTFOUND) + || (aPSName.Search("chancery") != STRING_NOTFOUND) + || (aPSName.Search("zapfino") != STRING_NOTFOUND)) rDFA.meFamily = FAMILY_SCRIPT; - else if( (aPSName.SearchAscii("comic") != STRING_NOTFOUND) - || (aPSName.SearchAscii("outline") != STRING_NOTFOUND) - || (aPSName.SearchAscii("pinpoint") != STRING_NOTFOUND) ) + else if( (aPSName.Search("comic") != STRING_NOTFOUND) + || (aPSName.Search("outline") != STRING_NOTFOUND) + || (aPSName.Search("pinpoint") != STRING_NOTFOUND) ) rDFA.meFamily = FAMILY_DECORATIVE; - else if( (aPSName.SearchAscii("sans") != STRING_NOTFOUND) - || (aPSName.SearchAscii("arial") != STRING_NOTFOUND) ) + else if( (aPSName.Search("sans") != STRING_NOTFOUND) + || (aPSName.Search("arial") != STRING_NOTFOUND) ) rDFA.meFamily = FAMILY_SWISS; - else if( (aPSName.SearchAscii("roman") != STRING_NOTFOUND) - || (aPSName.SearchAscii("times") != STRING_NOTFOUND) ) + else if( (aPSName.Search("roman") != STRING_NOTFOUND) + || (aPSName.Search("times") != STRING_NOTFOUND) ) rDFA.meFamily = FAMILY_ROMAN; // heuristics for codepoint semantic - if( (aPSName.SearchAscii("symbol") != STRING_NOTFOUND) - || (aPSName.SearchAscii("dings") != STRING_NOTFOUND) - || (aPSName.SearchAscii("dingbats") != STRING_NOTFOUND) - || (aPSName.SearchAscii("ornaments") != STRING_NOTFOUND) - || (aPSName.SearchAscii("embellishments") != STRING_NOTFOUND) ) + if( (aPSName.Search("symbol") != STRING_NOTFOUND) + || (aPSName.Search("dings") != STRING_NOTFOUND) + || (aPSName.Search("dingbats") != STRING_NOTFOUND) + || (aPSName.Search("ornaments") != STRING_NOTFOUND) + || (aPSName.Search("embellishments") != STRING_NOTFOUND) ) rDFA.mbSymbolFlag = true; + + // #i100020# special heuristic for names with single-char styles + // NOTE: we are checking name that hasn't been lower-cased + if( rPSName.Len() > 3 ) + { + int i = rPSName.Len(); + sal_Unicode c = rPSName.GetChar( --i ); + if( c == 'C' ) { // "capitals" + rDFA.meFamily = FAMILY_DECORATIVE; + c = rPSName.GetChar( --i ); + } + if( c == 'O' ) { // CFF-based OpenType + c = rPSName.GetChar( --i ); + } + if( c == 'I' ) { // "italic" + rDFA.meItalic = ITALIC_NORMAL; + c = rPSName.GetChar( --i ); + } + if( c == 'B' ) // "bold" + rDFA.meWeight = WEIGHT_BOLD; + if( c == 'C' ) // "capitals" + rDFA.meFamily = FAMILY_DECORATIVE; + // TODO: check that all single-char styles have been resolved? + } } // ----------------------------------------------------------------------- @@ -231,9 +254,9 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF continue; // heuristic to find the most common font name - // prefering default language names or even better the names matching to the UI language + // prefering default language names or even better the names matching to the UI language int nNameValue = (eFontNameLanguage==eUILangCode) ? 0 : ((eFontNameLanguage==0) ? -10 : -20); - rtl_TextEncoding eEncoding = RTL_TEXTENCODING_UNICODE; + rtl_TextEncoding eEncoding = RTL_TEXTENCODING_UNICODE; const int nPlatformEncoding = ((int)eFontNamePlatform << 8) + (int)eFontNameScript; switch( nPlatformEncoding ) { @@ -259,6 +282,8 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF // ignore name entries with no useful encoding if( nNameValue <= 0 ) continue; + if( nNameLength >= aNameBuffer.size() ) + continue; // get the encoded name aNameBuffer.reserve( nNameLength+1 ); // extra byte helps for debugging @@ -306,7 +331,7 @@ static bool GetDevFontAttributes( ATSUFontID nFontID, ImplDevFontAttributes& rDF case kFontStyleName: // get a style name matching to the family name if( nBestStyleValue < nNameValue ) - { + { nBestStyleValue = nNameValue; rDFA.maStyleName = aUtf16Name; } diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index c39dc26f370f..661eb64b83ce 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -36,8 +36,7 @@ #include "salbmp.h" #include "salframe.h" #include "salcolorutils.hxx" -#include "list.h" -#include "sft.h" +#include "sft.hxx" #include "salatsuifontutils.hxx" #include "vcl/impfont.hxx" @@ -58,6 +57,8 @@ #include "basegfx/polygon/b2dpolygontools.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +using namespace vcl; + typedef unsigned char Boolean; // copied from MacTypes.h, should be properly included typedef std::vector ByteVector; @@ -400,19 +401,8 @@ void AquaSalGraphics::initResolution( NSWindow* pWin ) DBG_ERROR( "no screen found" ); } - // equalize x- and y-resolution if they are close enough to prevent unneeded font stretching - if( (mnRealDPIX != mnRealDPIY) - && (10*mnRealDPIX < 13*mnRealDPIY) && (13*mnRealDPIX > 10*mnRealDPIY) ) - { - mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2; - } - else // #i89650# workaround bogus device resolutions - { - if( mnRealDPIY < 72 ) - mnRealDPIY = 72; - if( mnRealDPIX < mnRealDPIY ) // e.g. for TripleHead2Go only mnRealDPIX is off - mnRealDPIX = mnRealDPIY; - } + // for OSX any anisotropy reported for the display resolution is best ignored (e.g. TripleHead2Go) + mnRealDPIX = mnRealDPIY = (mnRealDPIX + mnRealDPIY + 1) / 2; mfFakeDPIScale = 1.0; } diff --git a/vcl/aqua/source/window/salframeview.mm b/vcl/aqua/source/window/salframeview.mm index b491318bbb0d..e291dae911cf 100755 --- a/vcl/aqua/source/window/salframeview.mm +++ b/vcl/aqua/source/window/salframeview.mm @@ -922,7 +922,7 @@ private: // applications and vcl's edit fields ignore key events with ALT // however we're at a place where we know text should be inserted // so it seems we need to strip the Alt modifier here - if( (nLastModifiers & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) + if( (nLastModifiers & (NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)) == NSAlternateKeyMask ) { nLastModifiers = 0; diff --git a/vcl/aqua/source/window/salmenu.cxx b/vcl/aqua/source/window/salmenu.cxx index 9b4499cc1233..4fafbbdbb4cf 100644 --- a/vcl/aqua/source/window/salmenu.cxx +++ b/vcl/aqua/source/window/salmenu.cxx @@ -521,7 +521,7 @@ BOOL AquaSalMenu::VisibleMenuBar() static const char *pExperimental = getenv ("AQUA_NATIVE_MENUS"); - if ( GetSalData()->mbIsTestTool || (pExperimental && !strcasecmp(pExperimental, "FALSE")) ) + if ( ImplGetSVData()->mbIsTestTool || (pExperimental && !strcasecmp(pExperimental, "FALSE")) ) return FALSE; // End of experimental code enable/disable part diff --git a/vcl/aqua/source/window/salobj.cxx b/vcl/aqua/source/window/salobj.cxx index abbea052c3d6..79da1b155cad 100644 --- a/vcl/aqua/source/window/salobj.cxx +++ b/vcl/aqua/source/window/salobj.cxx @@ -37,11 +37,6 @@ #include "salobj.h" #include "salframe.h" -// get QTMovieView -#include "premac.h" -#include -#include "postmac.h" - // ======================================================================= AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : @@ -66,7 +61,7 @@ AquaSalObject::AquaSalObject( AquaSalFrame* pFrame ) : [mpFrame->getView() addSubview: mpClipView]; [mpClipView setHidden: YES]; } - maSysData.pView = [[QTMovieView alloc] initWithFrame: aInitFrame]; + maSysData.pView = [[NSView alloc] initWithFrame: aInitFrame]; if( maSysData.pView ) { if( mpClipView ) diff --git a/vcl/inc/list.h b/vcl/inc/list.h index b86521a1f666..b801b43d77eb 100644 --- a/vcl/inc/list.h +++ b/vcl/inc/list.h @@ -51,6 +51,7 @@ extern "C" */ typedef struct _list *list; + typedef void (*list_destructor)(void *); /*- constructors and a destructor */ list listNewEmpty(void); @@ -58,7 +59,7 @@ extern "C" list listNewCopy(list); #endif void listDispose(list); - void listSetElementDtor(list, void (*f)(void *)); /*- this function will be executed when the element is removed via listRemove() or listClear() */ + void listSetElementDtor(list, list_destructor); /*- this function will be executed when the element is removed via listRemove() or listClear() */ /*- queries */ void * listCurrent(list); diff --git a/vcl/inc/sft.h b/vcl/inc/sft.hxx similarity index 98% rename from vcl/inc/sft.h rename to vcl/inc/sft.hxx index efda0903afc5..5f22bc0a471f 100644 --- a/vcl/inc/sft.h +++ b/vcl/inc/sft.hxx @@ -46,7 +46,6 @@ * If NO_TYPE3 is defined CreateT3FromTTGlyphs() does not get compiled in. * If NO_TYPE42 is defined Type42-related code is excluded * If NO_TTCR is defined TrueType creation related code is excluded\ - * If NO_LIST is defined list.h and piblic functions that use it don't get compiled */ /* @@ -76,20 +75,10 @@ #include -#ifndef NO_LIST -#include "list.h" -#endif +#include -#ifdef __cplusplus -extern "C" { -#endif - -/*@{*/ -#ifndef __cplusplus -#define false 0 /**< standard false value */ -#define true 1 /**< standard true value */ -#endif -/*@}*/ +namespace vcl +{ /*@{*/ typedef sal_Int16 F2Dot14; /**< fixed: 2.14 */ @@ -349,7 +338,6 @@ extern "C" { */ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID); -#ifndef NO_LIST /** * For a specified glyph adds all component glyphs IDs to the list and * return their number. If the glyph is a single glyph it has one component @@ -365,8 +353,7 @@ extern "C" { * @ingroup sft * */ - int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist); -#endif + int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist); /** * Extracts all Name Records from the font and stores them in an allocated @@ -606,7 +593,7 @@ extern "C" { sal_uInt8 *cmap; int cmapType; sal_uInt32 (*mapper)(const sal_uInt8 *, sal_uInt32); /* character to glyphID translation function */ - void **tables; /* array of pointers to tables */ + sal_uInt8 **tables; /* array of pointers to raw subtables in SFNT file */ sal_uInt32 *tlens; /* array of table lengths */ int kerntype; /* Defined in the KernType enum */ sal_uInt32 nkern; /* number of kern subtables */ @@ -614,10 +601,6 @@ extern "C" { void *pGSubstitution; /* info provided by GSUB for UseGSUB() */ }; -#ifdef __cplusplus -} -#endif - /* indexes into _TrueTypeFont::tables[] and _TrueTypeFont::tlens[] */ #define O_maxp 0 /* 'maxp' */ #define O_glyf 1 /* 'glyf' */ @@ -638,4 +621,6 @@ extern "C" { #define O_gsub 16 /* 'GSUB' */ #define NUM_TAGS 17 +} // namespace vcl + #endif /* __SUBFONT_H */ diff --git a/vcl/inc/vcl/svdata.hxx b/vcl/inc/vcl/svdata.hxx index e3072a4bc250..bde902c3fbcd 100644 --- a/vcl/inc/vcl/svdata.hxx +++ b/vcl/inc/vcl/svdata.hxx @@ -338,6 +338,7 @@ struct ImplSVData UnoWrapperBase* mpUnoWrapper; Window* mpIntroWindow; // the splash screen DockingManager* mpDockingManager; + BOOL mbIsTestTool; vos::OThread::TThreadIdentifier mnMainThreadId; ::com::sun::star::uno::Reference< diff --git a/vcl/os2/source/gdi/salgdi3.cxx b/vcl/os2/source/gdi/salgdi3.cxx index 15034168269e..546f4bf2b7cd 100644 --- a/vcl/os2/source/gdi/salgdi3.cxx +++ b/vcl/os2/source/gdi/salgdi3.cxx @@ -74,15 +74,14 @@ #include #endif -#ifndef __SUBFONT_H -#include -#include -#endif +#include "sft.hxx" #ifdef GCP_KERN_HACK #include #endif +using namespace vcl; + // ----------- // - Inlines - // ----------- diff --git a/vcl/prj/build.lst b/vcl/prj/build.lst index ac93ae71bdd2..8a894cba2e55 100644 --- a/vcl/prj/build.lst +++ b/vcl/prj/build.lst @@ -1,4 +1,4 @@ -vc vcl : apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools transex3 icc NULL +vc vcl : apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools transex3 icc SO:print_header NULL vc vcl usr1 - all vc_mkout NULL vc vcl\inc nmake - all vc_inc NULL vc vcl\source\glyphs nmake - all vc_glyphs vc_inc NULL diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx index 56ba933e3931..db30fd4ef3ab 100644 --- a/vcl/source/app/svdata.cxx +++ b/vcl/source/app/svdata.cxx @@ -117,6 +117,20 @@ void ImplInitSVData() pImplSVData->maHelpData.mbAutoHelpId = sal_True; pImplSVData->maHelpData.mbAutoHelpId = sal_True; pImplSVData->maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT ); + + // find out whether we are running in the testtool + // in this case we need some special workarounds + sal_uInt32 nArgs = osl_getCommandArgCount(); + for( sal_uInt32 i = 0; i < nArgs; i++ ) + { + rtl::OUString aArg; + osl_getCommandArg( i, &aArg.pData ); + if( aArg.equalsAscii( "-enableautomation" ) ) + { + pImplSVData->mbIsTestTool = true; + break; + } + } } // ----------------------------------------------------------------------- diff --git a/vcl/source/fontsubset/crc32.c b/vcl/source/fontsubset/crc32.c deleted file mode 100644 index 386b873a011c..000000000000 --- a/vcl/source/fontsubset/crc32.c +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: crc32.c,v $ - * $Revision: 1.3 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* $Id: crc32.c,v 1.3 2008-04-11 10:13:50 rt Exp $ */ - -/** - * - * @file crc32.c - * @brief CRC-32 calculation function - * @author Alexander Gelfenbain - */ - -#include "sft.h" -#include "crc32.h" - -static uint32 crcTable[256] = { - 0x00000000UL, 0x77073096UL, 0xEE0E612CUL, 0x990951BAUL, 0x076DC419UL, 0x706AF48FUL, 0xE963A535UL, 0x9E6495A3UL, - 0x0EDB8832UL, 0x79DCB8A4UL, 0xE0D5E91EUL, 0x97D2D988UL, 0x09B64C2BUL, 0x7EB17CBDUL, 0xE7B82D07UL, 0x90BF1D91UL, - 0x1DB71064UL, 0x6AB020F2UL, 0xF3B97148UL, 0x84BE41DEUL, 0x1ADAD47DUL, 0x6DDDE4EBUL, 0xF4D4B551UL, 0x83D385C7UL, - 0x136C9856UL, 0x646BA8C0UL, 0xFD62F97AUL, 0x8A65C9ECUL, 0x14015C4FUL, 0x63066CD9UL, 0xFA0F3D63UL, 0x8D080DF5UL, - 0x3B6E20C8UL, 0x4C69105EUL, 0xD56041E4UL, 0xA2677172UL, 0x3C03E4D1UL, 0x4B04D447UL, 0xD20D85FDUL, 0xA50AB56BUL, - 0x35B5A8FAUL, 0x42B2986CUL, 0xDBBBC9D6UL, 0xACBCF940UL, 0x32D86CE3UL, 0x45DF5C75UL, 0xDCD60DCFUL, 0xABD13D59UL, - 0x26D930ACUL, 0x51DE003AUL, 0xC8D75180UL, 0xBFD06116UL, 0x21B4F4B5UL, 0x56B3C423UL, 0xCFBA9599UL, 0xB8BDA50FUL, - 0x2802B89EUL, 0x5F058808UL, 0xC60CD9B2UL, 0xB10BE924UL, 0x2F6F7C87UL, 0x58684C11UL, 0xC1611DABUL, 0xB6662D3DUL, - 0x76DC4190UL, 0x01DB7106UL, 0x98D220BCUL, 0xEFD5102AUL, 0x71B18589UL, 0x06B6B51FUL, 0x9FBFE4A5UL, 0xE8B8D433UL, - 0x7807C9A2UL, 0x0F00F934UL, 0x9609A88EUL, 0xE10E9818UL, 0x7F6A0DBBUL, 0x086D3D2DUL, 0x91646C97UL, 0xE6635C01UL, - 0x6B6B51F4UL, 0x1C6C6162UL, 0x856530D8UL, 0xF262004EUL, 0x6C0695EDUL, 0x1B01A57BUL, 0x8208F4C1UL, 0xF50FC457UL, - 0x65B0D9C6UL, 0x12B7E950UL, 0x8BBEB8EAUL, 0xFCB9887CUL, 0x62DD1DDFUL, 0x15DA2D49UL, 0x8CD37CF3UL, 0xFBD44C65UL, - 0x4DB26158UL, 0x3AB551CEUL, 0xA3BC0074UL, 0xD4BB30E2UL, 0x4ADFA541UL, 0x3DD895D7UL, 0xA4D1C46DUL, 0xD3D6F4FBUL, - 0x4369E96AUL, 0x346ED9FCUL, 0xAD678846UL, 0xDA60B8D0UL, 0x44042D73UL, 0x33031DE5UL, 0xAA0A4C5FUL, 0xDD0D7CC9UL, - 0x5005713CUL, 0x270241AAUL, 0xBE0B1010UL, 0xC90C2086UL, 0x5768B525UL, 0x206F85B3UL, 0xB966D409UL, 0xCE61E49FUL, - 0x5EDEF90EUL, 0x29D9C998UL, 0xB0D09822UL, 0xC7D7A8B4UL, 0x59B33D17UL, 0x2EB40D81UL, 0xB7BD5C3BUL, 0xC0BA6CADUL, - 0xEDB88320UL, 0x9ABFB3B6UL, 0x03B6E20CUL, 0x74B1D29AUL, 0xEAD54739UL, 0x9DD277AFUL, 0x04DB2615UL, 0x73DC1683UL, - 0xE3630B12UL, 0x94643B84UL, 0x0D6D6A3EUL, 0x7A6A5AA8UL, 0xE40ECF0BUL, 0x9309FF9DUL, 0x0A00AE27UL, 0x7D079EB1UL, - 0xF00F9344UL, 0x8708A3D2UL, 0x1E01F268UL, 0x6906C2FEUL, 0xF762575DUL, 0x806567CBUL, 0x196C3671UL, 0x6E6B06E7UL, - 0xFED41B76UL, 0x89D32BE0UL, 0x10DA7A5AUL, 0x67DD4ACCUL, 0xF9B9DF6FUL, 0x8EBEEFF9UL, 0x17B7BE43UL, 0x60B08ED5UL, - 0xD6D6A3E8UL, 0xA1D1937EUL, 0x38D8C2C4UL, 0x4FDFF252UL, 0xD1BB67F1UL, 0xA6BC5767UL, 0x3FB506DDUL, 0x48B2364BUL, - 0xD80D2BDAUL, 0xAF0A1B4CUL, 0x36034AF6UL, 0x41047A60UL, 0xDF60EFC3UL, 0xA867DF55UL, 0x316E8EEFUL, 0x4669BE79UL, - 0xCB61B38CUL, 0xBC66831AUL, 0x256FD2A0UL, 0x5268E236UL, 0xCC0C7795UL, 0xBB0B4703UL, 0x220216B9UL, 0x5505262FUL, - 0xC5BA3BBEUL, 0xB2BD0B28UL, 0x2BB45A92UL, 0x5CB36A04UL, 0xC2D7FFA7UL, 0xB5D0CF31UL, 0x2CD99E8BUL, 0x5BDEAE1DUL, - 0x9B64C2B0UL, 0xEC63F226UL, 0x756AA39CUL, 0x026D930AUL, 0x9C0906A9UL, 0xEB0E363FUL, 0x72076785UL, 0x05005713UL, - 0x95BF4A82UL, 0xE2B87A14UL, 0x7BB12BAEUL, 0x0CB61B38UL, 0x92D28E9BUL, 0xE5D5BE0DUL, 0x7CDCEFB7UL, 0x0BDBDF21UL, - 0x86D3D2D4UL, 0xF1D4E242UL, 0x68DDB3F8UL, 0x1FDA836EUL, 0x81BE16CDUL, 0xF6B9265BUL, 0x6FB077E1UL, 0x18B74777UL, - 0x88085AE6UL, 0xFF0F6A70UL, 0x66063BCAUL, 0x11010B5CUL, 0x8F659EFFUL, 0xF862AE69UL, 0x616BFFD3UL, 0x166CCF45UL, - 0xA00AE278UL, 0xD70DD2EEUL, 0x4E048354UL, 0x3903B3C2UL, 0xA7672661UL, 0xD06016F7UL, 0x4969474DUL, 0x3E6E77DBUL, - 0xAED16A4AUL, 0xD9D65ADCUL, 0x40DF0B66UL, 0x37D83BF0UL, 0xA9BCAE53UL, 0xDEBB9EC5UL, 0x47B2CF7FUL, 0x30B5FFE9UL, - 0xBDBDF21CUL, 0xCABAC28AUL, 0x53B39330UL, 0x24B4A3A6UL, 0xBAD03605UL, 0xCDD70693UL, 0x54DE5729UL, 0x23D967BFUL, - 0xB3667A2EUL, 0xC4614AB8UL, 0x5D681B02UL, 0x2A6F2B94UL, 0xB40BBE37UL, 0xC30C8EA1UL, 0x5A05DF1BUL, 0x2D02EF8DUL -}; - -uint32 crc32(const void *ptr, size_t len) -{ - uint32 crc = 0xFFFFFFFF; - const byte *bp = (const byte *) ptr; - size_t i; - - for (i=0; i> 8); - } - - return crc ^ 0xFFFFFFFF; -} diff --git a/vcl/source/fontsubset/crc32.h b/vcl/source/fontsubset/crc32.h deleted file mode 100644 index fa9ef71a1432..000000000000 --- a/vcl/source/fontsubset/crc32.h +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: crc32.h,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* $Id: crc32.h,v 1.4 2008-04-11 10:14:08 rt Exp $ */ - -/** - * - * @file crc32.h - * @brief CRC-32 calculation function - * @author Alexander Gelfenbain - */ - -#ifdef __cplusplus -extern "C"{ -#endif - sal_Int32 crc32(const void *ptr, sal_Int32 len); -#ifdef __cplusplus -} -#endif diff --git a/vcl/source/fontsubset/gsub.cxx b/vcl/source/fontsubset/gsub.cxx index e73ccccc12a4..9715e7fc8585 100644 --- a/vcl/source/fontsubset/gsub.cxx +++ b/vcl/source/fontsubset/gsub.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: gsub.cxx,v $ - * $Revision: 1.12.18.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,9 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include "sft.h" -#undef true -#undef false +#include "sft.hxx" #include "gsub.h" @@ -41,6 +36,9 @@ #include #include +namespace vcl +{ + typedef sal_uInt32 ULONG; typedef sal_uInt16 USHORT; typedef sal_uInt8 FT_Byte; @@ -355,3 +353,5 @@ int HasVerticalGSUB( struct _TrueTypeFont* pTTFile ) GlyphSubstitution* pGlyphSubstitution = (GlyphSubstitution*)pTTFile->pGSubstitution; return pGlyphSubstitution ? +1 : 0; } + +} diff --git a/vcl/source/fontsubset/gsub.h b/vcl/source/fontsubset/gsub.h index c64b2abb7e00..58b5b69c3e25 100644 --- a/vcl/source/fontsubset/gsub.h +++ b/vcl/source/fontsubset/gsub.h @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: gsub.h,v $ - * $Revision: 1.6.18.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,20 +28,17 @@ #ifndef _PSP_GSUB_H #define _PSP_GSUB_H -#ifdef __cplusplus -extern "C" { -#endif +namespace vcl +{ -int HasVerticalGSUB( struct _TrueTypeFont* pTTFile ); +int HasVerticalGSUB( struct vcl::_TrueTypeFont* pTTFile ); -int UseGSUB( struct _TrueTypeFont* pTTFile, int nGlyph, int wmode ); +int UseGSUB( struct vcl::_TrueTypeFont* pTTFile, int nGlyph, int wmode ); -int ReadGSUB( struct _TrueTypeFont* pTTFile, int nRequestedScript, int nRequestedLangsys ); +int ReadGSUB( struct vcl::_TrueTypeFont* pTTFile, int nRequestedScript, int nRequestedLangsys ); -void ReleaseGSUB( struct _TrueTypeFont* pTTFile ); +void ReleaseGSUB( struct vcl::_TrueTypeFont* pTTFile ); -#ifdef __cplusplus } -#endif #endif /* _PSP_GSUB_H */ diff --git a/vcl/source/fontsubset/list.c b/vcl/source/fontsubset/list.c index 83ebe8595a46..86864650db85 100644 --- a/vcl/source/fontsubset/list.c +++ b/vcl/source/fontsubset/list.c @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: list.c,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,8 +25,6 @@ * ************************************************************************/ -/* $Id: list.c,v 1.8 2008-06-25 14:19:44 kz Exp $ */ - /*[]---------------------------------------------------[]*/ /*| |*/ /*| list.c - bidirectional list class |*/ @@ -67,7 +62,7 @@ typedef struct _lnode { struct _list { lnode *head, *tail, *cptr; size_t aCount; - void (*eDtor)(void *); + list_destructor eDtor; }; /*- private methods */ @@ -177,7 +172,7 @@ void listDispose(list this) /*- dtor */ free(this); } -void listSetElementDtor(list this, void (*f)(void *)) +void listSetElementDtor(list this, list_destructor f) { assert(this != 0); this->eDtor = f; diff --git a/vcl/source/fontsubset/makefile.mk b/vcl/source/fontsubset/makefile.mk index b1d2552752a8..b7d719f3c912 100644 --- a/vcl/source/fontsubset/makefile.mk +++ b/vcl/source/fontsubset/makefile.mk @@ -6,10 +6,6 @@ # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.6 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/vcl/source/fontsubset/sft.c b/vcl/source/fontsubset/sft.cxx similarity index 93% rename from vcl/source/fontsubset/sft.c rename to vcl/source/fontsubset/sft.cxx index be54a872fd7f..10d4cf774b04 100644 --- a/vcl/source/fontsubset/sft.c +++ b/vcl/source/fontsubset/sft.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: sft.c,v $ - * $Revision: 1.47.4.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -49,32 +46,33 @@ #include #include #endif -#include "sft.h" +#include "sft.hxx" #include "gsub.h" #if ! (defined(NO_TTCR) && defined(NO_TYPE42)) -#include "ttcr.h" -#endif -#ifdef NO_LIST -#include "list.h" /* list.h does not get included in the sft.h */ +#include "ttcr.hxx" #endif #ifndef NO_MAPPERS /* include MapChar() and MapString() */ -#include "xlat.h" +#include "xlat.hxx" #endif #ifndef NO_TYPE3 /* include CreateT3FromTTGlyphs() */ #include #endif #include +#include #ifdef TEST7 #include #endif +namespace vcl +{ + /*- module identification */ -const char *modname = "SunTypeTools-TT"; -const char *modver = "1.0"; -const char *modextra = "gelf"; +static const char *modname = "SunTypeTools-TT"; +static const char *modver = "1.0"; +static const char *modextra = "gelf"; /*- private functions, constants and data types */ /*FOLD00*/ @@ -86,12 +84,20 @@ enum PathSegmentType { PS_CLOSEPATH = 4 }; -typedef struct { - int type; +struct PSPathElement +{ + PathSegmentType type; int x1, y1; int x2, y2; int x3, y3; -} PSPathElement; + + PSPathElement( PathSegmentType i_eType ) : type( i_eType ), + x1( 0 ), y1( 0 ), + x2( 0 ), y2( 0 ), + x3( 0 ), y3( 0 ) + { + } +}; /*- In horisontal writing mode right sidebearing is calculated using this formula *- rsb = aw - (lsb + xMax - xMin) -*/ @@ -412,7 +418,7 @@ _inline const char *UnicodeRangeName(sal_uInt16 bit) _inline sal_uInt8 *getTable(TrueTypeFont *ttf, sal_uInt32 ord) { - return ttf->tables[ord]; + return (sal_uInt8*)ttf->tables[ord]; } _inline sal_uInt32 getTableSize(TrueTypeFont *ttf, sal_uInt32 ord) @@ -426,7 +432,7 @@ static char HexChars[] = "0123456789ABCDEF"; static HexFmt *HexFmtNew(FILE *outf) { - HexFmt *res = smalloc(sizeof(HexFmt)); + HexFmt* res = (HexFmt*)smalloc(sizeof(HexFmt)); res->bufpos = res->total = 0; res->o = outf; return res; @@ -515,7 +521,7 @@ static void GetMetrics(TrueTypeFont *ttf, sal_uInt32 glyphID, TTGlyphMetrics *me } } -static int GetTTGlyphOutline(TrueTypeFont *, sal_uInt32 , ControlPoint **, TTGlyphMetrics *, list ); +static int GetTTGlyphOutline(TrueTypeFont *, sal_uInt32 , ControlPoint **, TTGlyphMetrics *, std::vector< sal_uInt32 >* ); /* returns the number of control points, allocates the pointArray */ static int GetSimpleTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics) /*FOLD02*/ @@ -525,7 +531,6 @@ static int GetSimpleTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoin sal_Int16 numberOfContours; sal_uInt16 t, instLen, lastPoint=0; int i, j, z; - ControlPoint* pa; *pointArray = 0; @@ -551,7 +556,7 @@ static int GetSimpleTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoin instLen = GetUInt16(ptr, 10 + numberOfContours*2, 1); p = ptr + 10 + 2 * numberOfContours + 2 + instLen; - pa = calloc(lastPoint+1, sizeof(ControlPoint)); + ControlPoint* pa = (ControlPoint*)calloc(lastPoint+1, sizeof(ControlPoint)); i = 0; while (i <= lastPoint) { @@ -608,13 +613,13 @@ static int GetSimpleTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoin return lastPoint + 1; } -static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, list glyphlist) /*FOLD02*/ +static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics, std::vector< sal_uInt32 >& glyphlist) /*FOLD02*/ { sal_uInt16 flags, index; sal_Int16 e, f, numberOfContours; sal_uInt8 *table = getTable(ttf, O_glyf); sal_uInt8 *ptr; - list myPoints; + std::vector myPoints; ControlPoint *nextComponent, *pa; int i, np; F16Dot16 a = 0x10000, b = 0, c = 0, d = 0x10000, m, n, abs1, abs2, abs3; @@ -630,9 +635,6 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo return 0; } - myPoints = listNewEmpty(); - listSetElementDtor(myPoints, free); - if (metrics) { metrics->xMin = GetInt16(ptr, 2, 1); metrics->yMin = GetInt16(ptr, 4, 1); @@ -649,27 +651,30 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo index = GetUInt16(ptr, 2, 1); ptr += 4; - if (listFind(glyphlist, (void *) (sal_IntPtr) index)) { + if( std::find( glyphlist.begin(), glyphlist.end(), index ) != glyphlist.end() ) + { #if OSL_DEBUG_LEVEL > 1 fprintf(stderr, "Endless loop found in a compound glyph.\n"); fprintf(stderr, "%d -> ", index); - listToFirst(glyphlist); fprintf(stderr," ["); - do { - fprintf(stderr,"%d ", (int) listCurrent(glyphlist)); - } while (listNext(glyphlist)); + for( std::vector< sal_uInt32 >::const_iterator it = glyphlist.begin(); + it != glyphlist.end(); ++it ) + { + fprintf( stderr,"%d ", (int) *it ); + } fprintf(stderr,"]\n"); /**/ #endif } - listAppend(glyphlist, (void *) (sal_IntPtr) index); + glyphlist.push_back( index ); #ifdef DEBUG2 fprintf(stderr,"glyphlist: += %d\n", index); #endif - if ((np = GetTTGlyphOutline(ttf, index, &nextComponent, 0, glyphlist)) == 0) { + if ((np = GetTTGlyphOutline(ttf, index, &nextComponent, 0, &glyphlist)) == 0) + { /* XXX that probably indicates a corrupted font */ #if OSL_DEBUG_LEVEL > 1 fprintf(stderr, "An empty compound!\n"); @@ -677,20 +682,20 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo #endif } - listToLast(glyphlist); #ifdef DEBUG2 - listToFirst(glyphlist); - fprintf(stderr,"%d [", listCount(glyphlist)); - if (!listIsEmpty(glyphlist)) { - do { - fprintf(stderr,"%d ", (int) listCurrent(glyphlist)); - } while (listNext(glyphlist)); + fprintf(stderr,"%d [", (int)glyphlist.size() ); + for( std::vector< sal_uInt32 >::const_iterator it = glyphlist.begin(); + it != glyphlist.end(); ++it ) + { + fprintf( stderr,"%d ", (int) *it ); } fprintf(stderr, "]\n"); - fprintf(stderr, "glyphlist: -= %d\n", (int) listCurrent(glyphlist)); + if( ! glyphlist.empty() ) + fprintf(stderr, "glyphlist: -= %d\n", (int) glyphlist.back()); #endif - listRemove(glyphlist); + if( ! glyphlist.empty() ) + glyphlist.pop_back(); if (flags & USE_MY_METRICS) { if (metrics) GetMetrics(ttf, index, metrics); @@ -774,18 +779,18 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo for (i=0; iflags = nextComponent[i].flags; + ControlPoint cp; + cp.flags = nextComponent[i].flags; t = fixedMulDiv(a, nextComponent[i].x << 16, m) + fixedMulDiv(c, nextComponent[i].y << 16, m) + (e << 16); - cp->x = (sal_Int16)(fixedMul(t, m) >> 16); + cp.x = (sal_Int16)(fixedMul(t, m) >> 16); t = fixedMulDiv(b, nextComponent[i].x << 16, n) + fixedMulDiv(d, nextComponent[i].y << 16, n) + (f << 16); - cp->y = (sal_Int16)(fixedMul(t, n) >> 16); + cp.y = (sal_Int16)(fixedMul(t, n) >> 16); #ifdef DEBUG2 - fprintf(stderr, "( %d %d ) -> ( %d %d )\n", nextComponent[i].x, nextComponent[i].y, cp->x, cp->y); + fprintf(stderr, "( %d %d ) -> ( %d %d )\n", nextComponent[i].x, nextComponent[i].y, cp.x, cp.y); #endif - listAppend(myPoints, cp); + myPoints.push_back( cp ); } free(nextComponent); @@ -794,16 +799,12 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo - np = listCount(myPoints); + np = myPoints.size(); - pa = calloc(np, sizeof(ControlPoint)); + pa = (ControlPoint*)calloc(np, sizeof(ControlPoint)); assert(pa != 0); - listToFirst(myPoints); - for (i=0; i* glyphlist) { sal_uInt8 *ptr, *table = getTable(ttf, O_glyf); sal_Int16 numberOfContours; @@ -840,21 +841,15 @@ static int GetTTGlyphOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint numberOfContours = GetInt16(ptr, 0, 1); - if (numberOfContours >= 0) { + if (numberOfContours >= 0) + { res=GetSimpleTTOutline(ttf, glyphID, pointArray, metrics); - } else { - int glyphlistFlag = 0; - if (!glyphlist) { - glyphlistFlag = 1; - glyphlist = listNewEmpty(); - listAppend(glyphlist, (void *) (sal_IntPtr) glyphID); - } - res = GetCompoundTTOutline(ttf, glyphID, pointArray, metrics, glyphlist); - if (glyphlistFlag) { - glyphlistFlag = 0; - listDispose(glyphlist); - glyphlist = 0; - } + } + else + { + std::vector< sal_uInt32 > aPrivList; + aPrivList.push_back( glyphID ); + res = GetCompoundTTOutline(ttf, glyphID, pointArray, metrics, glyphlist ? *glyphlist : aPrivList ); } #ifdef DEBUG3 @@ -877,22 +872,13 @@ static int GetTTGlyphOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint #ifndef NO_TYPE3 -static PSPathElement *newPSPathElement(int t) -{ - PSPathElement *p = malloc(sizeof(PSPathElement)); - assert(p != 0); - - p->type = t; - return p; -} - /*- returns the number of items in the path -*/ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **path) { - list pList = listNewEmpty(); - int i = 0, pCount = 0; - PSPathElement *p; + std::vector< PSPathElement > aPathList; + int nPathCount = 0; + PSPathElement p( PS_NOOP ); int x0 = 0, y0 = 0, x1 = 0, y1 = 0, x2, y2, curx, cury; int lastOff = 0; /*- last point was off-contour */ @@ -901,7 +887,6 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat int cp = 0; /*- current point */ int StartContour = 0, EndContour = 1; - listSetElementDtor(pList, free); *path = 0; /* if (srcCount > 0) for(;;) */ @@ -919,21 +904,21 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat break; } } - p = newPSPathElement(PS_MOVETO); + p = PSPathElement(PS_MOVETO); if (!(srcA[cp].flags & 1)) { if (!(srcA[EndContour].flags & 1)) { - p->x1 = x0 = (srcA[cp].x + srcA[EndContour].x + 1) / 2; - p->y1 = y0 = (srcA[cp].y + srcA[EndContour].y + 1) / 2; + p.x1 = x0 = (srcA[cp].x + srcA[EndContour].x + 1) / 2; + p.y1 = y0 = (srcA[cp].y + srcA[EndContour].y + 1) / 2; } else { - p->x1 = x0 = srcA[EndContour].x; - p->y1 = y0 = srcA[EndContour].y; + p.x1 = x0 = srcA[EndContour].x; + p.y1 = y0 = srcA[EndContour].y; } } else { - p->x1 = x0 = srcA[cp].x; - p->y1 = y0 = srcA[cp].y; + p.x1 = x0 = srcA[cp].x; + p.y1 = y0 = srcA[cp].y; cp++; } - listAppend(pList, p); + aPathList.push_back( p ); lastOff = 0; scflag = 0; } @@ -941,38 +926,45 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat curx = srcA[cp].x; cury = srcA[cp].y; - if (srcA[cp].flags & 1) { - if (lastOff) { - p = newPSPathElement(PS_CURVETO); - p->x1 = x0 + (2 * (x1 - x0) + 1) / 3; - p->y1 = y0 + (2 * (y1 - y0) + 1) / 3; - p->x2 = x1 + (curx - x1 + 1) / 3; - p->y2 = y1 + (cury - y1 + 1) / 3; - p->x3 = curx; - p->y3 = cury; - listAppend(pList, p); - } else { - if (!(x0 == curx && y0 == cury)) { /* eliminate empty lines */ - p = newPSPathElement(PS_LINETO); - p->x1 = curx; - p->y1 = cury; - listAppend(pList, p); + if (srcA[cp].flags & 1) + { + if (lastOff) + { + p = PSPathElement(PS_CURVETO); + p.x1 = x0 + (2 * (x1 - x0) + 1) / 3; + p.y1 = y0 + (2 * (y1 - y0) + 1) / 3; + p.x2 = x1 + (curx - x1 + 1) / 3; + p.y2 = y1 + (cury - y1 + 1) / 3; + p.x3 = curx; + p.y3 = cury; + aPathList.push_back( p ); + } + else + { + if (!(x0 == curx && y0 == cury)) + { /* eliminate empty lines */ + p = PSPathElement(PS_LINETO); + p.x1 = curx; + p.y1 = cury; + aPathList.push_back( p ); } } - x0 = curx; y0 = cury; lastOff = 0; - } else { - if (lastOff) { + } + else + { + if (lastOff) + { x2 = (x1 + curx + 1) / 2; y2 = (y1 + cury + 1) / 2; - p = newPSPathElement(PS_CURVETO); - p->x1 = x0 + (2 * (x1 - x0) + 1) / 3; - p->y1 = y0 + (2 * (y1 - y0) + 1) / 3; - p->x2 = x1 + (x2 - x1 + 1) / 3; - p->y2 = y1 + (y2 - y1 + 1) / 3; - p->x3 = x2; - p->y3 = y2; - listAppend(pList, p); + p = PSPathElement(PS_CURVETO); + p.x1 = x0 + (2 * (x1 - x0) + 1) / 3; + p.y1 = y0 + (2 * (y1 - y0) + 1) / 3; + p.x2 = x1 + (x2 - x1 + 1) / 3; + p.y2 = y1 + (y2 - y1 + 1) / 3; + p.x3 = x2; + p.y3 = y2; + aPathList.push_back( p ); x0 = x2; y0 = y2; x1 = curx; y1 = cury; } else { @@ -982,7 +974,7 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat } if (ecflag) { - listAppend(pList, newPSPathElement(PS_CLOSEPATH)); + aPathList.push_back( PSPathElement(PS_CLOSEPATH) ); scflag = 1; ecflag = 0; cp = EndContour + 1; @@ -999,19 +991,14 @@ static int BSplineToPSPath(ControlPoint *srcA, int srcCount, PSPathElement **pat } } - if ((pCount = listCount(pList)) > 0) { - p = calloc(pCount, sizeof(PSPathElement)); - assert(p != 0); - listToFirst(pList); - for (i=0; i 0) + { + *path = (PSPathElement*)calloc(nPathCount, sizeof(PSPathElement)); + assert(*path != 0); + memcpy( *path, &aPathList[0], nPathCount * sizeof(PSPathElement) ); } - listDispose(pList); - return pCount; + return nPathCount; } #endif @@ -1036,18 +1023,18 @@ static char *nameExtract(sal_uInt8 *name, int nTableSize, int n, int dbFlag, sal if( ucs2result ) *ucs2result = NULL; if (dbFlag) { - res = malloc(1 + len/2); + res = (char*)malloc(1 + len/2); assert(res != 0); for (i = 0; i < len/2; i++) res[i] = *(ptr + i * 2 + 1); res[len/2] = 0; if( ucs2result ) { - *ucs2result = malloc( len+2 ); + *ucs2result = (sal_uInt16*)malloc( len+2 ); for (i = 0; i < len/2; i++ ) (*ucs2result)[i] = GetUInt16( ptr, 2*i, 1 ); (*ucs2result)[len/2] = 0; } } else { - res = malloc(1 + len); + res = (char*)malloc(1 + len); assert(res != 0); memcpy(res, ptr, len); res[len] = 0; @@ -1493,7 +1480,7 @@ static void GetKern(TrueTypeFont *ttf) if (GetUInt16(table, 0, 1) == 0) { /* Traditional Microsoft style table with USHORT version and nTables fields */ ttf->nkern = GetUInt16(table, 2, 1); - ttf->kerntables = calloc(ttf->nkern, sizeof(sal_uInt8 *)); + ttf->kerntables = (sal_uInt8**)calloc(ttf->nkern, sizeof(sal_uInt8 *)); assert(ttf->kerntables != 0); memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *)); ttf->kerntype = KT_MICROSOFT; @@ -1513,7 +1500,7 @@ static void GetKern(TrueTypeFont *ttf) if (GetUInt32(table, 0, 1) == 0x00010000) { /* MacOS style kern tables: fixed32 version and sal_uInt32 nTables fields */ ttf->nkern = GetUInt32(table, 4, 1); - ttf->kerntables = calloc(ttf->nkern, sizeof(sal_uInt8 *)); + ttf->kerntables = (sal_uInt8**)calloc(ttf->nkern, sizeof(sal_uInt8*)); assert(ttf->kerntables != 0); memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *)); ttf->kerntype = KT_APPLE_NEW; @@ -1630,7 +1617,7 @@ int CountTTCFonts(const char* fname) static void allocTrueTypeFont( TrueTypeFont** ttf ) { - *ttf = calloc(1,sizeof(TrueTypeFont)); + *ttf = (TrueTypeFont*)calloc(1,sizeof(TrueTypeFont)); if( *ttf != NULL ) { (*ttf)->tag = 0; @@ -1714,7 +1701,7 @@ int OpenTTFontBuffer(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTyp (*ttf)->fname = NULL; (*ttf)->fsize = nLen; - (*ttf)->ptr = pBuffer; + (*ttf)->ptr = (sal_uInt8*)pBuffer; return doOpenTTFont( facenum, *ttf ); } @@ -1722,13 +1709,11 @@ int OpenTTFontBuffer(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTyp static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) { int i; - sal_uInt32 version; - sal_uInt8 *table, *offset; sal_uInt32 length, tag; sal_uInt32 tdoffset = 0; /* offset to TableDirectory in a TTC file. For TTF files is 0 */ int indexfmt, k; - version = GetInt32(t->ptr, 0, 1); + sal_uInt32 version = GetInt32(t->ptr, 0, 1); if ((version == 0x00010000) || (version == T_true)) { tdoffset = 0; @@ -1758,9 +1743,9 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) if( t->ntables >= 128 ) return SF_TTFORMAT; - t->tables = calloc(NUM_TAGS, sizeof(void *)); + t->tables = (sal_uInt8**)calloc(NUM_TAGS, sizeof(sal_uInt8*)); assert(t->tables != 0); - t->tlens = calloc(NUM_TAGS, sizeof(sal_uInt32)); + t->tlens = (sal_uInt32*)calloc(NUM_TAGS, sizeof(sal_uInt32)); assert(t->tlens != 0); memset(t->tables, 0, NUM_TAGS * sizeof(void *)); @@ -1791,22 +1776,23 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) default: nIndex = -1; break; } if( nIndex >= 0 ) { - offset = t->ptr + GetUInt32(t->ptr + tdoffset + 12, 16 * i + 8, 1); + sal_uInt32 nTableOffset = GetUInt32(t->ptr + tdoffset + 12, 16 * i + 8, 1); length = GetUInt32(t->ptr + tdoffset + 12, 16 * i + 12, 1); - t->tables[nIndex] = offset; + t->tables[nIndex] = t->ptr + nTableOffset; t->tlens[nIndex] = length; } } /* Fixup offsets when only a TTC extract was provided */ if( facenum == (sal_uInt32)~0 ) { - sal_uInt8 *pHead = t->tables[O_head], *p = NULL; + sal_uInt8* pHead = (sal_uInt8*)t->tables[O_head]; if( !pHead ) return SF_TTFORMAT; /* limit Head candidate to TTC extract's limits */ if( pHead > t->ptr + (t->fsize - 54) ) pHead = t->ptr + (t->fsize - 54); /* TODO: find better method than searching head table's magic */ + sal_uInt8* p = NULL; for( p = pHead + 12; p > t->ptr; --p ) { if( p[0]==0x5F && p[1]==0x0F && p[2]==0x3C && p[3]==0xF5 ) { int nDelta = (pHead + 12) - p, j; @@ -1861,7 +1847,7 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) return SF_TTFORMAT; } - table = getTable(t, O_maxp); + sal_uInt8* table = getTable(t, O_maxp); t->nglyphs = GetUInt16(table, 4, 1); table = getTable(t, O_head); @@ -1931,10 +1917,7 @@ int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **point return GetTTGlyphOutline(ttf, glyphID, pointArray, 0, 0); } -#ifdef NO_LIST -static -#endif -int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist) +int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist) { sal_uInt8 *ptr, *glyf = getTable(ttf, O_glyf); int n = 1; @@ -1942,7 +1925,7 @@ int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist) if (glyphID >= ttf->nglyphs) return 0; ptr = glyf + ttf->goffsets[glyphID]; - listAppend(glyphlist, (void *) (sal_IntPtr) glyphID); + glyphlist.push_back( glyphID ); if (GetInt16(ptr, 0, 1) == -1) { sal_uInt16 flags, index; @@ -2089,8 +2072,10 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO XUnits(UPEm, metrics.xMax), XUnits(UPEm, metrics.yMax)); - for (j = 0; j < n; j++) { - switch (path[j].type) { + for (j = 0; j < n; j++) + { + switch (path[j].type) + { case PS_MOVETO: fprintf(outf, "\t%d %d moveto\n", XUnits(UPEm, path[j].x1), XUnits(UPEm, path[j].y1)); break; @@ -2106,6 +2091,8 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO case PS_CLOSEPATH: fprintf(outf, "\tclosepath\n"); break; + case PS_NOOP: + break; } } if (n > 0) fprintf(outf, "\tfill\n"); /* if glyph is not a whitespace character */ @@ -2139,7 +2126,6 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, sal_uInt8 *p; int i; int res; - sal_uInt32 *gID; TrueTypeCreatorNewEmpty(T_true, &ttcr); @@ -2210,7 +2196,7 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, /** glyf **/ glyf = TrueTypeTableNew_glyf(); - gID = scalloc(nGlyphs, sizeof(sal_uInt32)); + sal_uInt32* gID = (sal_uInt32*)scalloc(nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < nGlyphs; i++) { gID[i] = glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); @@ -2277,7 +2263,7 @@ int CreateTTFromTTGlyphs(TrueTypeFont *ttf, #ifndef NO_TYPE42 static GlyphOffsets *GlyphOffsetsNew(sal_uInt8 *sfntP) { - GlyphOffsets *res = smalloc(sizeof(GlyphOffsets)); + GlyphOffsets* res = (GlyphOffsets*)smalloc(sizeof(GlyphOffsets)); sal_uInt8 *loca = NULL; sal_uInt16 i, numTables = GetUInt16(sfntP, 4, 1); sal_uInt32 locaLen = 0; @@ -2298,7 +2284,7 @@ static GlyphOffsets *GlyphOffsetsNew(sal_uInt8 *sfntP) res->nGlyphs = locaLen / ((indexToLocFormat == 1) ? 4 : 2); assert(res->nGlyphs != 0); - res->offs = scalloc(res->nGlyphs, sizeof(sal_uInt32)); + res->offs = (sal_uInt32*)scalloc(res->nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < res->nGlyphs; i++) { if (indexToLocFormat == 1) { @@ -2322,14 +2308,13 @@ static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP) { HexFmt *h = HexFmtNew(outf); sal_uInt16 i, numTables = GetUInt16(sfntP, 4, 1); - sal_uInt32 j, *offs, *len; GlyphOffsets *go = GlyphOffsetsNew(sfntP); sal_uInt8 pad[] = {0,0,0,0}; /* zeroes */ assert(numTables <= 9); /* Type42 has 9 required tables */ - offs = scalloc(numTables, sizeof(sal_uInt32)); - len = scalloc(numTables, sizeof(sal_uInt32)); + sal_uInt32* offs = (sal_uInt32*)scalloc(numTables, sizeof(sal_uInt32)); +// sal_uInt32* lens = (sal_uInt32*)scalloc(numTables, sizeof(sal_uInt32)); fputs("/sfnts [", outf); HexFmtOpenString(h); @@ -2345,7 +2330,7 @@ static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP) HexFmtBlockWrite(h, sfntP + off, len); } else { sal_uInt8 *glyf = sfntP + off; - sal_uInt32 o, l; + sal_uInt32 o, l, j; for (j = 0; j < go->nGlyphs - 1; j++) { o = go->offs[j]; l = go->offs[j + 1] - o; @@ -2359,7 +2344,7 @@ static void DumpSfnts(FILE *outf, sal_uInt8 *sfntP) GlyphOffsetsDispose(go); HexFmtDispose(h); free(offs); - free(len); +// free(lens); } int CreateT42FromTTGlyphs(TrueTypeFont *ttf, @@ -2382,8 +2367,6 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, sal_uInt32 sfntLen; int UPEm = ttf->unitsPerEm; - sal_uInt16 *gID; - if (nGlyphs >= 256) return SF_GLYPHNUM; assert(psname != 0); @@ -2425,7 +2408,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf, /** glyf **/ glyf = TrueTypeTableNew_glyf(); - gID = scalloc(nGlyphs, sizeof(sal_uInt32)); + sal_uInt16* gID = (sal_uInt16*)scalloc(nGlyphs, sizeof(sal_uInt32)); for (i = 0; i < nGlyphs; i++) { gID[i] = (sal_uInt16)glyfAdd(glyf, GetTTRawGlyphData(ttf, glyphArray[i]), ttf); @@ -2571,7 +2554,6 @@ int GetTTGlyphCount( TrueTypeFont* ttf ) TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, int mode) { sal_uInt8* pTable; - TTSimpleGlyphMetrics *res; int i; sal_uInt16 glyphID; sal_uInt32 n; @@ -2591,7 +2573,7 @@ TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *gly if (!nGlyphs || !glyphArray) return 0; /* invalid parameters */ if (!n || !pTable) return 0; /* the font does not contain the requested metrics */ - res = calloc(nGlyphs, sizeof(TTSimpleGlyphMetrics)); + TTSimpleGlyphMetrics* res = (TTSimpleGlyphMetrics*)calloc(nGlyphs, sizeof(TTSimpleGlyphMetrics)); assert(res != 0); for (i=0; i= nTableSize) res[i].adv = 0; /* better than a crash for buggy fonts */ else - res[i].adv = SAL_INT_CAST( - sal_uInt16, + res[i].adv = static_cast( XUnits( UPEm, GetUInt16( pTable, nAdvOffset, 1) ) ); if( nLsbOffset >= nTableSize) res[i].sb = 0; /* better than a crash for buggy fonts */ else - res[i].sb = SAL_INT_CAST( - sal_Int16, + res[i].sb = static_cast( XUnits( UPEm, GetInt16( pTable, nLsbOffset, 1) ) ); } @@ -2631,10 +2611,9 @@ TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *gly TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont * ttf, sal_uInt16 firstChar, int nChars, int mode) { TTSimpleGlyphMetrics *res = 0; - sal_uInt16 *str; int i, n; - str = malloc(nChars * 2); + sal_uInt16* str = (sal_uInt16*)malloc(nChars * 2); assert(str != 0); for (i=0; igoffsets[glyphID+1] - ttf->goffsets[glyphID]; - d = malloc(sizeof(GlyphData)); assert(d != 0); + GlyphData* d = (GlyphData*)malloc(sizeof(GlyphData)); assert(d != 0); if (length > 0) { sal_uInt8 *srcptr = glyf + ttf->goffsets[glyphID]; - d->ptr = malloc((length + 1) & ~1); assert(d->ptr != 0); + d->ptr = (sal_uInt8*)malloc((length + 1) & ~1); assert(d->ptr != 0); memcpy( d->ptr, srcptr, length ); d->compflag = (GetInt16( srcptr, 0, 1 ) < 0); } else { @@ -2811,7 +2789,7 @@ int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr) *nr = 0; if (n == 0) return 0; - rec = calloc(n, sizeof(NameRecord)); + rec = (NameRecord*)calloc(n, sizeof(NameRecord)); for (i = 0; i < n; i++) { int nStrOffset = GetUInt16(table + 6, 10 + 12 * i, 1); @@ -2864,7 +2842,7 @@ void DisposeNameRecords(NameRecord* nr, int n) free(nr); } - +} // namespace vcl #ifdef TEST1 diff --git a/vcl/source/fontsubset/ttcr.c b/vcl/source/fontsubset/ttcr.cxx similarity index 89% rename from vcl/source/fontsubset/ttcr.c rename to vcl/source/fontsubset/ttcr.cxx index e8c9d8cf74e0..7f9ae796142b 100644 --- a/vcl/source/fontsubset/ttcr.c +++ b/vcl/source/fontsubset/ttcr.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: ttcr.c,v $ - * $Revision: 1.11 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,8 +25,6 @@ * ************************************************************************/ -/* $Id: ttcr.c,v 1.11 2008-04-11 10:16:51 rt Exp $ */ - /* * TrueTypeCreator method implementation * @@ -48,7 +43,22 @@ #endif #include -#include "ttcr.h" +#include "ttcr.hxx" +#include "list.h" + + + +namespace vcl +{ + +/* + * Private Data Types + */ + + struct _TrueTypeCreator { + sal_uInt32 tag; /**< TrueType file tag */ + list tables; /**< List of table tags and pointers */ + }; /* These must be #defined so that they can be used in initializers */ #define T_maxp 0x6D617870 @@ -159,7 +169,6 @@ _inline void PutInt16(sal_Int16 val, sal_uInt8 *ptr, sal_uInt32 offset, int bige ptr[offset+1] = (sal_uInt8)((val >> 8) & 0xFF); ptr[offset] = (sal_uInt8)(val & 0xFF); } - } _inline void PutUInt16(sal_uInt16 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) @@ -173,10 +182,8 @@ _inline void PutUInt16(sal_uInt16 val, sal_uInt8 *ptr, sal_uInt32 offset, int bi ptr[offset+1] = (sal_uInt8)((val >> 8) & 0xFF); ptr[offset] = (sal_uInt8)(val & 0xFF); } - } - _inline void PutUInt32(sal_uInt32 val, sal_uInt8 *ptr, sal_uInt32 offset, int bigendian) { assert(ptr != 0); @@ -267,22 +274,16 @@ _inline void *scalloc(sal_uInt32 n, sal_uInt32 size) void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this) { - TrueTypeCreator *ptr = smalloc(sizeof(TrueTypeCreator)); + TrueTypeCreator* ptr = (TrueTypeCreator*)smalloc(sizeof(TrueTypeCreator)); ptr->tables = listNewEmpty(); - listSetElementDtor(ptr->tables, (void(*)(void*))TrueTypeTableDispose); + listSetElementDtor(ptr->tables, (list_destructor)TrueTypeTableDispose); ptr->tag = tag; *_this = ptr; } -void TrueTypeCreatorDispose(TrueTypeCreator *_this) -{ - listDispose(_this->tables); - free(_this); -} - int AddTable(TrueTypeCreator *_this, TrueTypeTable *table) { if (table != 0) { @@ -316,9 +317,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) sal_uInt16 numTables, searchRange=1, entrySelector=0, rangeShift; sal_uInt32 s, offset, checkSumAdjustment = 0; sal_uInt32 *p; - sal_uInt8 *ttf; int i=0, n; - TableEntry *te; sal_uInt8 *head = NULL; /* saved pointer to the head table data for checkSumAdjustment calculation */ if ((n = listCount(_this->tables)) == 0) return SF_TTFORMAT; @@ -331,7 +330,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) numTables = (sal_uInt16) n; - te = scalloc(n, sizeof(TableEntry)); + TableEntry* te = (TableEntry*)scalloc(n, sizeof(TableEntry)); listToFirst(_this->tables); for (i = 0; i < n; i++) { @@ -357,7 +356,7 @@ int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length) /* if ((te[i].length & 3) != 0) s += (4 - (te[i].length & 3)) & 3; */ } - ttf = smalloc(s); + sal_uInt8* ttf = (sal_uInt8*)smalloc(s); /* Offset Table */ PutUInt32(_this->tag, ttf, 0, 1); @@ -486,10 +485,9 @@ typedef struct { static sal_uInt8 *ttmalloc(sal_uInt32 nbytes) { sal_uInt32 n; - sal_uInt8 *res; n = (nbytes + 3) & (sal_uInt32) ~3; - res = malloc(n); + sal_uInt8* res = (sal_uInt8*)malloc(n); assert(res != 0); memset(res, 0, n); @@ -722,7 +720,7 @@ static int GetRawData_glyf(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le /* cmap packers */ static sal_uInt8 *PackCmapType0(CmapSubTable *s, sal_uInt32 *length) { - sal_uInt8 *ptr = smalloc(262); + sal_uInt8* ptr = (sal_uInt8*)smalloc(262); sal_uInt8 *p = ptr + 6; sal_uInt32 i, j; sal_uInt16 g; @@ -746,7 +744,7 @@ static sal_uInt8 *PackCmapType0(CmapSubTable *s, sal_uInt32 *length) static sal_uInt8 *PackCmapType6(CmapSubTable *s, sal_uInt32 *length) { - sal_uInt8 *ptr = smalloc(s->n*2 + 10); + sal_uInt8* ptr = (sal_uInt8*)smalloc(s->n*2 + 10); sal_uInt8 *p = ptr + 10; sal_uInt32 i, j; sal_uInt16 g; @@ -784,8 +782,6 @@ static sal_uInt8 *PackCmap(CmapSubTable *s, sal_uInt32 *length) static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { table_cmap *t; - sal_uInt8 **subtables; - sal_uInt32 *sizes; /* of subtables */ sal_uInt32 i; sal_uInt32 tlen = 0; sal_uInt32 l; @@ -798,8 +794,8 @@ static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le assert(t != 0); assert(t->n != 0); - subtables = scalloc(t->n, sizeof(sal_uInt8 *)); - sizes = scalloc(t->n, sizeof(sal_uInt32)); + sal_uInt8** subtables = (sal_uInt8**)scalloc(t->n, sizeof(sal_uInt8 *)); + sal_uInt32* sizes = (sal_uInt32*)scalloc(t->n, sizeof(sal_uInt32)); for (i = 0; i < t->n; i++) { subtables[i] = PackCmap(t->s+i, &l); @@ -837,10 +833,7 @@ static int GetRawData_cmap(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { list l; - NameRecord *nr; sal_Int16 i=0, n; /* number of Name Records */ - sal_uInt8 *name; - sal_uInt16 nameLen; int stringLen = 0; sal_uInt8 *p1, *p2; @@ -854,7 +847,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le if ((n = (sal_Int16)listCount(l)) == 0) return TTCR_NONAMES; - nr = scalloc(n, sizeof(NameRecord)); + NameRecord* nr = (NameRecord*)scalloc(n, sizeof(NameRecord)); listToFirst(l); @@ -871,8 +864,8 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le qsort(nr, n, sizeof(NameRecord), NameRecordCompareF); - nameLen = (sal_uInt16)(stringLen + 12 * n + 6); - name = ttmalloc(nameLen); + int nameLen = stringLen + 12 * n + 6; + sal_uInt8* name = (sal_uInt8*)ttmalloc(nameLen); PutUInt16(0, name, 0, 1); PutUInt16(n, name, 2, 1); @@ -898,7 +891,7 @@ static int GetRawData_name(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le _this->rawdata = name; *ptr = name; - *len = nameLen; + *len = (sal_uInt16)nameLen; *tag = T_name; /*{int j; for(j=0; jnbytes = nbytes; pdata->tag = tag; if (nbytes) { @@ -1006,13 +996,10 @@ TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision, sal_uInt16 lowestRecPPEM, sal_Int16 fontDirectionHint) { - TrueTypeTable *table; - sal_uInt8 *ptr; - assert(created != 0); - table = smalloc(sizeof(TrueTypeTable)); - ptr = ttmalloc(TABLESIZE_head); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); + sal_uInt8* ptr = (sal_uInt8*)ttmalloc(TABLESIZE_head); PutUInt32(0x00010000, ptr, 0, 1); /* version */ @@ -1040,11 +1027,8 @@ TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender, sal_Int16 caretSlopeRise, sal_Int16 caretSlopeRun) { - TrueTypeTable *table; - sal_uInt8 *ptr; - - table = smalloc(sizeof(TrueTypeTable)); - ptr = ttmalloc(TABLESIZE_hhea); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); + sal_uInt8* ptr = (sal_uInt8*)ttmalloc(TABLESIZE_hhea); PutUInt32(0x00010000, ptr, 0, 1); /* version */ PutUInt16(ascender, ptr, 4, 1); @@ -1068,7 +1052,7 @@ TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender, TrueTypeTable *TrueTypeTableNew_loca(void) { - TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); table->data = smalloc(sizeof(tdata_loca)); ((tdata_loca *)table->data)->nbytes = 0; @@ -1082,7 +1066,7 @@ TrueTypeTable *TrueTypeTableNew_loca(void) TrueTypeTable *TrueTypeTableNew_maxp(sal_uInt8 *maxp, int size) { - TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); table->data = ttmalloc(TABLESIZE_maxp); if (maxp && size == TABLESIZE_maxp) { @@ -1097,12 +1081,12 @@ TrueTypeTable *TrueTypeTableNew_maxp(sal_uInt8 *maxp, int size) TrueTypeTable *TrueTypeTableNew_glyf(void) { - TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); list l = listNewEmpty(); assert(l != 0); - listSetElementDtor(l, FreeGlyphData); + listSetElementDtor(l, (list_destructor)FreeGlyphData); table->data = l; table->rawdata = 0; @@ -1113,8 +1097,8 @@ TrueTypeTable *TrueTypeTableNew_glyf(void) TrueTypeTable *TrueTypeTableNew_cmap(void) { - TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); - table_cmap *cmap = smalloc(sizeof(table_cmap)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); + table_cmap* cmap = (table_cmap*)smalloc(sizeof(table_cmap)); cmap->n = 0; cmap->m = CMAP_SUBTABLE_INIT; @@ -1140,12 +1124,12 @@ static void DisposeNameRecord(void *ptr) static NameRecord* NameRecordNewCopy(NameRecord *nr) { - NameRecord *p = smalloc(sizeof(NameRecord)); + NameRecord* p = (NameRecord*)smalloc(sizeof(NameRecord)); memcpy(p, nr, sizeof(NameRecord)); if (p->slen) { - p->sptr = smalloc(p->slen); + p->sptr = (sal_uInt8*)smalloc(p->slen); memcpy(p->sptr, nr->sptr, p->slen); } @@ -1154,12 +1138,12 @@ static NameRecord* NameRecordNewCopy(NameRecord *nr) TrueTypeTable *TrueTypeTableNew_name(int n, NameRecord *nr) { - TrueTypeTable *table = smalloc(sizeof(TrueTypeTable)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); list l = listNewEmpty(); assert(l != 0); - listSetElementDtor(l, DisposeNameRecord); + listSetElementDtor(l, (list_destructor)DisposeNameRecord); if (n != 0) { int i; @@ -1181,12 +1165,9 @@ TrueTypeTable *TrueTypeTableNew_post(sal_uInt32 format, sal_Int16 underlineThickness, sal_uInt32 isFixedPitch) { - TrueTypeTable *table; - tdata_post *post; - assert(format == 0x00030000); /* Only format 3.0 is supported at this time */ - table = smalloc(sizeof(TrueTypeTable)); - post = smalloc(sizeof(tdata_post)); + TrueTypeTable* table = (TrueTypeTable*)smalloc(sizeof(TrueTypeTable)); + tdata_post* post = (tdata_post*)smalloc(sizeof(tdata_post)); post->format = format; post->italicAngle = italicAngle; @@ -1202,26 +1183,6 @@ TrueTypeTable *TrueTypeTableNew_post(sal_uInt32 format, return table; } - - -void TrueTypeTableDispose(TrueTypeTable *_this) -{ - /* XXX do a binary search */ - unsigned int i; - - assert(_this != 0); - - if (_this->rawdata) free(_this->rawdata); - - for(i=0; i < sizeof(vtable1)/sizeof(*vtable1); i++) { - if (_this->tag == vtable1[i].tag) { - vtable1[i].f(_this); - return; - } - } - assert(!"Unknown TrueType table.\n"); -} - int GetRawData(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag) { /* XXX do a binary search */ @@ -1271,8 +1232,7 @@ void cmapAdd(TrueTypeTable *table, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g) if (!found) { if (t->n == t->m) { - CmapSubTable *tmp; - tmp = scalloc(t->m + CMAP_SUBTABLE_INCR, sizeof(CmapSubTable)); + CmapSubTable* tmp = (CmapSubTable*)scalloc(t->m + CMAP_SUBTABLE_INCR, sizeof(CmapSubTable)); memset(tmp, 0, t->m + CMAP_SUBTABLE_INCR * sizeof(CmapSubTable)); memcpy(tmp, s, sizeof(CmapSubTable) * t->m); t->m += CMAP_SUBTABLE_INCR; @@ -1294,13 +1254,13 @@ void cmapAdd(TrueTypeTable *table, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g) s[i].id = id; s[i].n = 0; s[i].m = CMAP_PAIR_INIT; - s[i].xc = scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); - s[i].xg = scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); + s[i].xc = (sal_uInt32*)scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); + s[i].xg = (sal_uInt32*)scalloc(CMAP_PAIR_INIT, sizeof(sal_uInt32)); } if (s[i].n == s[i].m) { - sal_uInt32 *tmp1 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); - sal_uInt32 *tmp2 = scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); + sal_uInt32* tmp1 = (sal_uInt32*)scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); + sal_uInt32* tmp2 = (sal_uInt32*)scalloc(s[i].m + CMAP_PAIR_INCR, sizeof(sal_uInt32)); assert(tmp1 != 0); assert(tmp2 != 0); memcpy(tmp1, s[i].xc, sizeof(sal_uInt32) * s[i].m); @@ -1322,7 +1282,6 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt list l; sal_uInt32 currentID; int ret, n, ncomponents; - list glyphlist; GlyphData *gd; assert(table != 0); @@ -1330,7 +1289,7 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt if (!glyphdata) return (sal_uInt32)~0; - glyphlist = listNewEmpty(); + std::vector< sal_uInt32 > glyphlist; ncomponents = GetTTGlyphComponents(fnt, glyphdata->glyphID, glyphlist); @@ -1344,11 +1303,15 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt glyphdata->newID = n++; listAppend(l, glyphdata); - if (ncomponents > 1) { - listPositionAt(glyphlist, 1); /* glyphData->glyphID is always the first glyph on the list */ - do { + if (ncomponents > 1 && glyphlist.size() > 1 ) + { + std::vector< sal_uInt32 >::const_iterator it = glyphlist.begin(); + ++it; + /* glyphData->glyphID is always the first glyph on the list */ + do + { int found = 0; - currentID = (sal_uIntPtr) listCurrent(glyphlist); + currentID = *it; /* XXX expensive! should be rewritten with sorted arrays! */ listToFirst(l); do { @@ -1363,10 +1326,9 @@ sal_uInt32 glyfAdd(TrueTypeTable *table, GlyphData *glyphdata, TrueTypeFont *fnt gd->newID = n++; listAppend(l, gd); } - } while (listNext(glyphlist)); + } while( ++it != glyphlist.end() ); } - listDispose(glyphlist); return ret; } @@ -1398,7 +1360,7 @@ static TrueTypeTable *FindTable(TrueTypeCreator *tt, sal_uInt32 tag) do { if (((TrueTypeTable *) listCurrent(tt->tables))->tag == tag) { - return listCurrent(tt->tables); + return (TrueTypeTable*)listCurrent(tt->tables); } } while (listNext(tt->tables)); @@ -1428,11 +1390,10 @@ static void ProcessTables(TrueTypeCreator *tt) sal_Int16 xMin = 0, yMin = 0, xMax = 0, yMax = 0; sal_uInt32 i = 0; sal_Int16 indexToLocFormat; - sal_uInt8 *glyfPtr, *locaPtr, *hmtxPtr, *hheaPtr; + sal_uInt8 *hmtxPtr, *hheaPtr; sal_uInt32 hmtxSize; sal_uInt8 *p1, *p2; sal_uInt16 maxPoints = 0, maxContours = 0, maxCompositePoints = 0, maxCompositeContours = 0; - TTSimpleGlyphMetrics *met; int nlsb = 0; sal_uInt32 *gid; /* array of old glyphIDs */ @@ -1440,7 +1401,7 @@ static void ProcessTables(TrueTypeCreator *tt) glyphlist = (list) glyf->data; nGlyphs = listCount(glyphlist); assert(nGlyphs != 0); - gid = scalloc(nGlyphs, sizeof(sal_uInt32)); + gid = (sal_uInt32*)scalloc(nGlyphs, sizeof(sal_uInt32)); RemoveTable(tt, T_loca); RemoveTable(tt, T_hmtx); @@ -1488,9 +1449,9 @@ static void ProcessTables(TrueTypeCreator *tt) indexToLocFormat = (glyfLen / 2 > 0xFFFF) ? 1 : 0; locaLen = indexToLocFormat ? (nGlyphs + 1) << 2 : (nGlyphs + 1) << 1; - glyfPtr = ttmalloc(glyfLen); - locaPtr = ttmalloc(locaLen); - met = scalloc(nGlyphs, sizeof(TTSimpleGlyphMetrics)); + sal_uInt8* glyfPtr = ttmalloc(glyfLen); + sal_uInt8* locaPtr = ttmalloc(locaLen); + TTSimpleGlyphMetrics* met = (TTSimpleGlyphMetrics*)scalloc(nGlyphs, sizeof(TTSimpleGlyphMetrics)); i = 0; listToFirst(glyphlist); @@ -1569,19 +1530,21 @@ static void ProcessTables(TrueTypeCreator *tt) AddTable(tt, loca); head = FindTable(tt, T_head); - PutInt16(xMin, head->data, 36, 1); - PutInt16(yMin, head->data, 38, 1); - PutInt16(xMax, head->data, 40, 1); - PutInt16(yMax, head->data, 42, 1); - PutInt16(indexToLocFormat, head->data, 50, 1); + sal_uInt8* const pHeadData = (sal_uInt8*)head->data; + PutInt16(xMin, pHeadData, 36, 1); + PutInt16(yMin, pHeadData, 38, 1); + PutInt16(xMax, pHeadData, 40, 1); + PutInt16(yMax, pHeadData, 42, 1); + PutInt16(indexToLocFormat, pHeadData, 50, 1); maxp = FindTable(tt, T_maxp); - PutUInt16((sal_uInt16)nGlyphs, maxp->data, 4, 1); - PutUInt16(maxPoints, maxp->data, 6, 1); - PutUInt16(maxContours, maxp->data, 8, 1); - PutUInt16(maxCompositePoints, maxp->data, 10, 1); - PutUInt16(maxCompositeContours, maxp->data, 12, 1); + sal_uInt8* const pMaxpData = (sal_uInt8*)maxp->data; + PutUInt16((sal_uInt16)nGlyphs, pMaxpData, 4, 1); + PutUInt16(maxPoints, pMaxpData, 6, 1); + PutUInt16(maxContours, pMaxpData, 8, 1); + PutUInt16(maxCompositePoints, pMaxpData, 10, 1); + PutUInt16(maxCompositeContours, pMaxpData, 12, 1); #if 0 /* XXX do not overwrite the existing data. Fix: re-calculate these numbers here */ @@ -1628,6 +1591,43 @@ static void ProcessTables(TrueTypeCreator *tt) free(met); } +} // namespace vcl + +extern "C" +{ + /** + * TrueTypeCreator destructor. It calls destructors for all TrueTypeTables added to it. + */ + void TrueTypeCreatorDispose(vcl::TrueTypeCreator *_this) + { + listDispose(_this->tables); + free(_this); + } + + + /** + * Destructor for the TrueTypeTable object. + */ + void TrueTypeTableDispose(vcl::TrueTypeTable *_this) + { + /* XXX do a binary search */ + unsigned int i; + + assert(_this != 0); + + if (_this->rawdata) free(_this->rawdata); + + for(i=0; i < sizeof(vcl::vtable1)/sizeof(*vcl::vtable1); i++) { + if (_this->tag == vcl::vtable1[i].tag) { + vcl::vtable1[i].f(_this); + return; + } + } + assert(!"Unknown TrueType table.\n"); + } +} + + #ifdef TEST_TTCR int main(void) { diff --git a/vcl/source/fontsubset/ttcr.h b/vcl/source/fontsubset/ttcr.hxx similarity index 94% rename from vcl/source/fontsubset/ttcr.h rename to vcl/source/fontsubset/ttcr.hxx index 95aa1a6c9e99..5b47f09d552a 100644 --- a/vcl/source/fontsubset/ttcr.h +++ b/vcl/source/fontsubset/ttcr.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: ttcr.h,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,8 +25,6 @@ * ************************************************************************/ -/* $Id: ttcr.h,v 1.4 2008-04-11 10:17:09 rt Exp $ */ - /** * * @file ttcr.h @@ -40,14 +35,10 @@ #ifndef __TTCR_H #define __TTCR_H -#include "sft.h" -#include "list.h" +#include "sft.hxx" -#ifdef __cplusplus -extern "C" +namespace vcl { -#endif - typedef struct _TrueTypeCreator TrueTypeCreator; /* TrueType data types */ @@ -57,11 +48,11 @@ extern "C" } longHorMetrics; /* A generic base class for all TrueType tables */ - typedef struct { + struct TrueTypeTable { sal_uInt32 tag; /* table tag */ sal_uInt8 *rawdata; /* raw data allocated by GetRawData_*() */ void *data; /* table specific data */ - } TrueTypeTable; + }; /** Error codes for most functions */ enum TTCRErrCodes { @@ -86,11 +77,6 @@ extern "C" */ void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this); -/** - * TrueTypeCreator destructor. It calls destructors for all TrueTypeTables added to it. - */ - void TrueTypeCreatorDispose(TrueTypeCreator *_this); - /** * Adds a TrueType table to the TrueType creator. * SF_TABLEFORMAT value. @@ -130,10 +116,6 @@ extern "C" * * ============================================================================ */ -/** - * Destructor for the TrueTypeTable object. - */ - void TrueTypeTableDispose(TrueTypeTable *); /** * This function converts the data of a TrueType table to a raw array of bytes. @@ -260,21 +242,20 @@ extern "C" */ void nameAdd(TrueTypeTable *, NameRecord *nr); +} // namespace -/* - * Private Data Types +extern "C" +{ +/** + * Destructor for the TrueTypeTable object. */ + void TrueTypeTableDispose(vcl::TrueTypeTable *); - struct _TrueTypeCreator { - sal_uInt32 tag; /**< TrueType file tag */ - list tables; /**< List of table tags and pointers */ - }; - - - -#ifdef __cplusplus +/** + * TrueTypeCreator destructor. It calls destructors for all TrueTypeTables added to it. + */ + void TrueTypeCreatorDispose(vcl::TrueTypeCreator *_this); } -#endif #endif /* __TTCR_H */ diff --git a/vcl/source/fontsubset/u2big5.inc b/vcl/source/fontsubset/u2big5.inc index 2883e9d99094..951b65cffc25 100644 --- a/vcl/source/fontsubset/u2big5.inc +++ b/vcl/source/fontsubset/u2big5.inc @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: u2big5.inc,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,6 +25,8 @@ * ************************************************************************/ +// TODO: use generic RTL_TEXTENCODING_BIG5 to get rid of this file + sal_uInt16pair xlat_1_3[13798] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, diff --git a/vcl/source/fontsubset/u2johab.inc b/vcl/source/fontsubset/u2johab.inc index ae07cc571fb8..f7a75afaf503 100644 --- a/vcl/source/fontsubset/u2johab.inc +++ b/vcl/source/fontsubset/u2johab.inc @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: u2johab.inc,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,6 +25,8 @@ * ************************************************************************/ +// use generic RTL_TEXTENCODING_JOHAB to get rid of this file + sal_uInt16pair xlat_1_6[17141] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, diff --git a/vcl/source/fontsubset/u2prc.inc b/vcl/source/fontsubset/u2prc.inc index 2479d23ebe6f..445461b59653 100644 --- a/vcl/source/fontsubset/u2prc.inc +++ b/vcl/source/fontsubset/u2prc.inc @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: u2prc.inc,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,6 +25,8 @@ * ************************************************************************/ +// use generic RTL_TEXTENCODING_ to get rid of this file + sal_uInt16pair xlat_1_4[24035] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, diff --git a/vcl/source/fontsubset/u2shiftjis.inc b/vcl/source/fontsubset/u2shiftjis.inc index fb130feaebe2..ebc6f1676784 100644 --- a/vcl/source/fontsubset/u2shiftjis.inc +++ b/vcl/source/fontsubset/u2shiftjis.inc @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: u2shiftjis.inc,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,6 +25,8 @@ * ************************************************************************/ +// TODO: use generic RTL_TEXTENCODING_SHIFTJIS to get rid of this file + sal_uInt16pair xlat_1_2[7484] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, diff --git a/vcl/source/fontsubset/u2wansung.inc b/vcl/source/fontsubset/u2wansung.inc index 0cb8867f1c2a..b321c9e58bfa 100644 --- a/vcl/source/fontsubset/u2wansung.inc +++ b/vcl/source/fontsubset/u2wansung.inc @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: u2wansung.inc,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,6 +25,8 @@ * ************************************************************************/ +// TODO: use generic RTL_TEXTENCODING_WANSUNG to get rid of this file + sal_uInt16pair xlat_1_5[8319] = { {0x0020, 0x0020},{0x0021, 0x0021},{0x0022, 0x0022},{0x0023, 0x0023},{0x0024, 0x0024},{0x0025, 0x0025},{0x0026, 0x0026},{0x0027, 0x0027}, {0x0028, 0x0028},{0x0029, 0x0029},{0x002A, 0x002A},{0x002B, 0x002B},{0x002C, 0x002C},{0x002D, 0x002D},{0x002E, 0x002E},{0x002F, 0x002F}, diff --git a/vcl/source/fontsubset/xlat.c b/vcl/source/fontsubset/xlat.cxx similarity index 97% rename from vcl/source/fontsubset/xlat.c rename to vcl/source/fontsubset/xlat.cxx index 840850a020da..27b2f517f4a1 100644 --- a/vcl/source/fontsubset/xlat.c +++ b/vcl/source/fontsubset/xlat.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: xlat.c,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,7 +25,7 @@ * ************************************************************************/ -/* $Id: xlat.c,v 1.4 2008-04-11 10:19:41 rt Exp $ +/* * * Data translation from Unicode to MS encodings * If the host system provides this functionality @@ -39,8 +36,12 @@ * */ -#include "xlat.h" +#include "xlat.hxx" +namespace vcl +{ + +// TODO: use generic encoding converters and get rid of the include files below #include "u2big5.inc" #include "u2johab.inc" #include "u2prc.inc" @@ -183,5 +184,5 @@ void TranslateString16(sal_uInt16 *src, sal_uInt16 *dst, sal_uInt32 n) } } - +} // namespace vcl diff --git a/vcl/source/fontsubset/xlat.h b/vcl/source/fontsubset/xlat.hxx similarity index 78% rename from vcl/source/fontsubset/xlat.h rename to vcl/source/fontsubset/xlat.hxx index 86eca1691574..c3bd076f6fbd 100644 --- a/vcl/source/fontsubset/xlat.h +++ b/vcl/source/fontsubset/xlat.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: xlat.h,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -28,25 +25,17 @@ * ************************************************************************/ -/* $Id: xlat.h,v 1.4 2008-04-11 10:19:58 rt Exp $ */ - -/*[]---------------------------------------------------[]*/ -/*| |*/ -/*| xlat.h |*/ -/*| |*/ /*| Author: Alexander Gelfenbain |*/ -/*[]---------------------------------------------------[]*/ #ifndef __XLAT_H #define __XLAT_H -#ifdef __cplusplus -extern "C" { -#endif +#include "sft.hxx" - -#include "sft.h" +namespace vcl +{ +// TODO: sal_UCS4 sal_uInt16 TranslateChar12(sal_uInt16); sal_uInt16 TranslateChar13(sal_uInt16); @@ -59,10 +48,7 @@ extern "C" { void TranslateString14(sal_uInt16 *, sal_uInt16 *, sal_uInt32); void TranslateString15(sal_uInt16 *, sal_uInt16 *, sal_uInt32); void TranslateString16(sal_uInt16 *, sal_uInt16 *, sal_uInt32); - -#ifdef __cplusplus } -#endif - #endif /* __XLAT_H */ + diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx index 820b053a4211..3bbdba5dad5f 100644 --- a/vcl/source/gdi/font.cxx +++ b/vcl/source/gdi/font.cxx @@ -31,7 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include "sft.h" +#include "sft.hxx" #include "tools/stream.hxx" #include "tools/vcompat.hxx" @@ -43,6 +43,8 @@ #include +using namespace vcl; + // ======================================================================= DBG_NAME( Font ) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 0754f5c5b3dc..05067ee2d024 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6680,6 +6680,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( appendHex( rGlyphs[nPos].m_nMappedGlyphId, aUnkernedLine ); // check for adjustment double fTheoreticalGlyphWidth = rGlyphs[nPos].m_aPos.X() - rGlyphs[nPos-1].m_aPos.X(); + fTheoreticalGlyphWidth = fabs( fTheoreticalGlyphWidth ); // #i100522# workaround until #i87686# gets fixed fTheoreticalGlyphWidth = 1000.0 * fTheoreticalGlyphWidth / fXScale / double(nPixelFontHeight); sal_Int32 nAdjustment = rGlyphs[nPos-1].m_nNativeWidth - sal_Int32(fTheoreticalGlyphWidth+0.5); if( nAdjustment != 0 ) @@ -6902,10 +6903,16 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const String& rText, bool bT if( aAlignOffset.X() || aAlignOffset.Y() ) aAlignOffset = aRotScale.transform( aAlignOffset ); - if( bVertical ) - drawVerticalGlyphs( aGlyphs, aLine, aAlignOffset, aRotScale, fAngle, fXScale, fSkew, nFontHeight ); - else - drawHorizontalGlyphs( aGlyphs, aLine, aAlignOffset, fAngle, fXScale, fSkew, nFontHeight, nPixelFontHeight ); + /* #159153# do not emit an empty glyph vector; this can happen if e.g. the original + string contained only on of the UTF16 BOMs + */ + if( ! aGlyphs.empty() ) + { + if( bVertical ) + drawVerticalGlyphs( aGlyphs, aLine, aAlignOffset, aRotScale, fAngle, fXScale, fSkew, nFontHeight ); + else + drawHorizontalGlyphs( aGlyphs, aLine, aAlignOffset, fAngle, fXScale, fSkew, nFontHeight, nPixelFontHeight ); + } // end textobject aLine.append( "ET\n" ); @@ -9297,14 +9304,24 @@ void PDFWriterImpl::drawJPGBitmap( SvStream& rDCTData, bool bIsTrueColor, const delete pStream; aLine.append( "q " ); - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetWidth(), aLine, false ); + sal_Int32 nCheckWidth = 0; + m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetWidth(), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetHeight(), aLine, true ); + sal_Int32 nCheckHeight = 0; + m_aPages.back().appendMappedLength( (sal_Int32)rTargetArea.GetHeight(), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rTargetArea.BottomLeft(), aLine ); aLine.append( " cm\n/Im" ); aLine.append( it->m_nObject ); aLine.append( " Do Q\n" ); + if( nCheckWidth == 0 || nCheckHeight == 0 ) + { + // #i97512# avoid invalid current matrix + aLine.setLength( 0 ); + aLine.append( "\n%jpeg image /Im" ); + aLine.append( it->m_nObject ); + aLine.append( " scaled to zero size, omitted\n" ); + } writeBuffer( aLine.getStr(), aLine.getLength() ); OStringBuffer aObjName( 16 ); @@ -9325,14 +9342,24 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, appendNonStrokingColor( rFillColor, aLine ); aLine.append( ' ' ); } - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Width(), aLine, false ); + sal_Int32 nCheckWidth = 0; + m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Width(), aLine, false, &nCheckWidth ); aLine.append( " 0 0 " ); - m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Height(), aLine, true ); + sal_Int32 nCheckHeight = 0; + m_aPages.back().appendMappedLength( (sal_Int32)rDestSize.Height(), aLine, true, &nCheckHeight ); aLine.append( ' ' ); m_aPages.back().appendPoint( rDestPoint + Point( 0, rDestSize.Height()-1 ), aLine ); aLine.append( " cm\n/Im" ); aLine.append( rBitmap.m_nObject ); aLine.append( " Do Q\n" ); + if( nCheckWidth == 0 || nCheckHeight == 0 ) + { + // #i97512# avoid invalid current matrix + aLine.setLength( 0 ); + aLine.append( "\n%bitmap image /Im" ); + aLine.append( rBitmap.m_nObject ); + aLine.append( " scaled to zero size, omitted\n" ); + } writeBuffer( aLine.getStr(), aLine.getLength() ); } diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 89a47a9f4077..a96d4dc64b89 100755 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1773,7 +1773,7 @@ void MultiSalLayout::AdjustLayout( ImplLayoutArgs& rArgs ) int nStartNew[ MAX_FALLBACK ]; int nCharPos[ MAX_FALLBACK ]; sal_Int32 nGlyphAdv[ MAX_FALLBACK ]; - int nValid[ MAX_FALLBACK ]; + int nValid[ MAX_FALLBACK ] = {0}; sal_GlyphId nDummy; Point aPos; diff --git a/vcl/source/helper/smartid.cxx b/vcl/source/helper/smartid.cxx index 7ac7abe0d18b..73ad6f89a21c 100755 --- a/vcl/source/helper/smartid.cxx +++ b/vcl/source/helper/smartid.cxx @@ -262,6 +262,6 @@ BOOL SmartId::operator < ( const SmartId& rRight ) const if ( HasString() ) return rRight.HasString() && rRight.HasNumeric(); else - return rRight.HasString() || !HasNumeric() && rRight.HasNumeric(); + return rRight.HasString() || (!HasNumeric() && rRight.HasNumeric()); } } diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index 4dd2bca2d6fa..8c6bb2b76463 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -944,9 +944,16 @@ static void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect, Color aColor = bRound ? rStyleSettings.GetShadowColor() : pDev->GetSettings().GetStyleSettings().GetMonoColor(); // when the MonoColor wasn't set, check face color - if ( ( ( bRound && aColor.IsDark() ) || ( aColor == Color( COL_BLACK ) && - ( pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark() ) ) ) ) + if ( + (bRound && aColor.IsDark()) || + ( + (aColor == Color(COL_BLACK)) && + (pDev->GetSettings().GetStyleSettings().GetFaceColor().IsDark()) + ) + ) + { aColor = Color( COL_WHITE ); + } ImplDrawDPILineRect( pDev, rRect, &aColor, bRound ); } else @@ -1183,7 +1190,7 @@ static void ImplDrawButton( OutputDevice* pDev, Rectangle& rRect, aFillRect.Right(), aFillRect.Top() ) ); aFillRect.Top()++; } - if ( ((nStyle & (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) && + if ( (( (nStyle & BUTTON_DRAW_NOBOTTOMSHADOWBORDER) | BUTTON_DRAW_FLAT) == (BUTTON_DRAW_NOBOTTOMSHADOWBORDER | BUTTON_DRAW_FLAT)) && !(nStyle & (BUTTON_DRAW_PRESSED | BUTTON_DRAW_CHECKED | BUTTON_DRAW_HIGHLIGHT)) ) { pDev->SetFillColor( rStyleSettings.GetDarkShadowColor() ); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 1318f4fa8415..adbc2a8de06e 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2323,6 +2323,8 @@ Size Menu::ImplCalcSize( Window* pWin ) if ( !bIsMenuBar && ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) ) { Size aImgSz = pData->aImage.GetSizePixel(); + aImgSz.Height() += 4; // add a border for native marks + aImgSz.Width() += 4; // add a border for native marks if ( aImgSz.Width() > aMaxImgSz.Width() ) aMaxImgSz.Width() = aImgSz.Width(); if ( aImgSz.Height() > aMaxImgSz.Height() ) @@ -2336,7 +2338,11 @@ Size Menu::ImplCalcSize( Window* pWin ) { nCheckWidth = nMaxCheckWidth; if (nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) - nWidth += nCheckWidth + nExtra * 2; + { + // checks / images take the same place + if( ! ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) ) + nWidth += nCheckWidth + nExtra * 2; + } } // Text: @@ -2397,16 +2403,14 @@ Size Menu::ImplCalcSize( Window* pWin ) nCheckPos = (USHORT)nExtra; if (nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) { - // non-NWF case has an implicit little extra space around - // the symbol; NWF case has not, so image pos needs to - // be distinct in this case + long nImgOrChkWidth = 0; + nImagePos = nCheckPos; if( nMax > 0 ) // NWF case - nImagePos = (USHORT)(nCheckPos + nMax + nExtra ); + nImgOrChkWidth = nMax + nExtra; else // non NWF case - nImagePos = (USHORT)(nCheckPos + nFontHeight/2 + gfxExtra ); - nTextPos = (USHORT)(nImagePos+aMaxImgSz.Width()); - if ( aMaxImgSz.Width() ) - nTextPos = nTextPos + gfxExtra; + nImgOrChkWidth = nFontHeight/2 + gfxExtra; + nImgOrChkWidth = Max( nImgOrChkWidth, aMaxImgSz.Width() + gfxExtra ); + nTextPos = (USHORT)(nImagePos + nImgOrChkWidth); } else { @@ -2464,6 +2468,45 @@ Size Menu::ImplCalcSize( Window* pWin ) return aSz; } +static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) +{ + BOOL bNativeOk = FALSE; + if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) + { + ImplControlValue aControlValue; + Region aCtrlRegion( i_rRect ); + ControlState nState = CTRL_STATE_PRESSED | CTRL_STATE_ENABLED; + + aControlValue.setTristateVal( BUTTONVALUE_ON ); + + bNativeOk = i_pWindow->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, + aCtrlRegion, nState, aControlValue, + rtl::OUString() ); + } + + if( ! bNativeOk ) + { + const StyleSettings& rSettings = i_pWindow->GetSettings().GetStyleSettings(); + if( i_bHighlight ) + { + i_pWindow->Push( PUSH_ALL ); + Color aCol = rSettings.GetMenuHighlightTextColor(); + i_pWindow->SetFillColor( rSettings.GetMenuHighlightTextColor() ); + if( aCol.IsDark() ) + aCol.IncreaseLuminance( 128 ); + else + aCol.DecreaseLuminance( 128 ); + i_pWindow->SetLineColor( aCol ); + Polygon aPoly( i_rRect ); + PolyPolygon aPolyPoly( aPoly ); + i_pWindow->DrawTransparent( aPolyPoly, 20 ); + i_pWindow->Pop(); + } + else + i_pWindow->DrawSelectionBackground( i_rRect, 1, FALSE, TRUE, FALSE ); + } +} + void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData* pThisItemOnly, BOOL bHighlighted, bool bLayout ) const { // Fuer Symbole: nFontHeight x nFontHeight @@ -2537,15 +2580,89 @@ void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData* pWin->SetLineColor(); } + Rectangle aOuterCheckRect( Point( aPos.X()+nCheckPos, aPos.Y() ), Size( pData->aSz.Height(), pData->aSz.Height() ) ); + aOuterCheckRect.Left() += 1; + aOuterCheckRect.Right() -= 1; + aOuterCheckRect.Top() += 1; + aOuterCheckRect.Bottom() -= 1; + + // CheckMark + if ( !bLayout && !bIsMenuBar && pData->HasCheck() ) + { + // draw selection transparent marker if checked + // onto that either a checkmark or the item image + // will be painted + // however do not do this if native checks will be painted since + // the selection color too often does not fit the theme's check and/or radio + + if( ! ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) ) + { + if ( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, + (pData->nBits & MIB_RADIOCHECK) + ? PART_MENU_ITEM_CHECK_MARK + : PART_MENU_ITEM_RADIO_MARK ) ) + { + ControlPart nPart = ((pData->nBits & MIB_RADIOCHECK) + ? PART_MENU_ITEM_RADIO_MARK + : PART_MENU_ITEM_CHECK_MARK); + + ControlState nState = 0; + + if ( pData->bChecked ) + nState |= CTRL_STATE_PRESSED; + + if ( pData->bEnabled ) + nState |= CTRL_STATE_ENABLED; + + if ( bHighlighted ) + nState |= CTRL_STATE_SELECTED; + + long nCtrlHeight = (pData->nBits & MIB_RADIOCHECK) ? nCheckHeight : nRadioHeight; + aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight)/2; + aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight)/2; + + Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) ); + pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart, + Region( aCheckRect ), + nState, + ImplControlValue(), + OUString() ); + } + else if ( pData->bChecked ) // by default do nothing for unchecked items + { + ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); + + SymbolType eSymbol; + Size aSymbolSize; + if ( pData->nBits & MIB_RADIOCHECK ) + { + eSymbol = SYMBOL_RADIOCHECKMARK; + aSymbolSize = Size( nFontHeight/2, nFontHeight/2 ); + } + else + { + eSymbol = SYMBOL_CHECKMARK; + aSymbolSize = Size( (nFontHeight*25)/40, nFontHeight/2 ); + } + aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2; + aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2; + Rectangle aRect( aTmpPos, aSymbolSize ); + aDecoView.DrawSymbol( aRect, eSymbol, pWin->GetTextColor(), nSymbolStyle ); + } + } + } + // Image: if ( !bLayout && !bIsMenuBar && ( ( pData->eType == MENUITEM_IMAGE ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) ) { // Don't render an image for a check thing if ((nMenuFlags & MENU_FLAG_SHOWCHECKIMAGES) || !pData->HasCheck() ) { - aTmpPos.Y() = aPos.Y(); - aTmpPos.X() = aPos.X() + nImagePos; - aTmpPos.Y() += (pData->aSz.Height()-pData->aImage.GetSizePixel().Height())/2; + if( pData->bChecked ) + ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); + aTmpPos = aOuterCheckRect.TopLeft(); + aTmpPos.X() += (aOuterCheckRect.GetWidth()-pData->aImage.GetSizePixel().Width())/2; + aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pData->aImage.GetSizePixel().Height())/2; pWin->DrawImage( aTmpPos, pData->aImage, nImageStyle ); } } @@ -2598,65 +2715,6 @@ void Menu::ImplPaint( Window* pWin, USHORT nBorder, long nStartY, MenuItemData* pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.Len(), nTextStyle ); } - // CheckMark - if ( !bLayout && !bIsMenuBar && pData->HasCheck() ) - { - if ( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, - (pData->nBits & MIB_RADIOCHECK) - ? PART_MENU_ITEM_CHECK_MARK - : PART_MENU_ITEM_RADIO_MARK ) ) - { - ControlPart nPart = ((pData->nBits & MIB_RADIOCHECK) - ? PART_MENU_ITEM_RADIO_MARK - : PART_MENU_ITEM_CHECK_MARK); - - ControlState nState = 0; - - if ( pData->bChecked ) - nState |= CTRL_STATE_PRESSED; - - if ( pData->bEnabled ) - nState |= CTRL_STATE_ENABLED; - - if ( bHighlighted ) - nState |= CTRL_STATE_SELECTED; - - aTmpPos.X() = aPos.X() + nCheckPos; - aTmpPos.Y() = aPos.Y() + nCheckPos; - - long nCtrlHeight = (pData->nBits & MIB_RADIOCHECK) ? nCheckHeight : nRadioHeight; - Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) ); - pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart, - Region( aCheckRect ), - nState, - ImplControlValue(), - OUString() ); - } - else if ( pData->bChecked ) // by default do nothing for unchecked items - { - Rectangle aRect; - SymbolType eSymbol; - aTmpPos.Y() = aPos.Y(); - aTmpPos.Y() += nExtra/2; - aTmpPos.Y() += pData->aSz.Height() / 2; - if ( pData->nBits & MIB_RADIOCHECK ) - { - aTmpPos.X() = aPos.X() + nCheckPos; - eSymbol = SYMBOL_RADIOCHECKMARK; - aTmpPos.Y() -= nFontHeight/4; - aRect = Rectangle( aTmpPos, Size( nFontHeight/2, nFontHeight/2 ) ); - } - else - { - aTmpPos.X() = aPos.X() + nCheckPos; - eSymbol = SYMBOL_CHECKMARK; - aTmpPos.Y() -= nFontHeight/4; - aRect = Rectangle( aTmpPos, Size( (nFontHeight*25)/40, nFontHeight/2 ) ); - } - aDecoView.DrawSymbol( aRect, eSymbol, pWin->GetTextColor(), nSymbolStyle ); - } - } - // SubMenu? if ( !bLayout && !bIsMenuBar && pData->pSubMenu ) { diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index d41a861717e9..8c69c2a45daf 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1622,8 +1622,10 @@ void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight ) ImplDestroyHelpWindow( true ); } - if ( ((nNewWidth > 0) && (nNewHeight > 0)) || - pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize ) + if ( + (nNewWidth > 0 && nNewHeight > 0) || + pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize + ) { if ( (nNewWidth != pWindow->GetOutputWidthPixel()) || (nNewHeight != pWindow->GetOutputHeightPixel()) ) { @@ -1849,11 +1851,15 @@ static void ImplHandleGetFocus( Window* pWindow ) // nicht alles flackert, wenn diese den Focus bekommen if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId ) { + bool bCallDirect = ImplGetSVData()->mbIsTestTool; pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus; - Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) ); + if( ! bCallDirect ) + Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) ); Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin; if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor ) pFocusWin->ImplGetWindowImpl()->mpCursor->ImplShow(); + if( bCallDirect ) + pWindow->ImplAsyncFocusHdl( NULL ); } } @@ -1887,15 +1893,19 @@ static void ImplHandleLoseFocus( Window* pWindow ) // Focus-Events zeitverzoegert ausfuehren, damit bei SystemChildFenstern // nicht alles flackert, wenn diese den Focus bekommen + bool bCallDirect = ImplGetSVData()->mbIsTestTool; if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId ) { pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus; - Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) ); + if( ! bCallDirect ) + Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) ); } Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin; if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor ) pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide(); + if( bCallDirect ) + pWindow->ImplAsyncFocusHdl( NULL ); } // ----------------------------------------------------------------------- diff --git a/vcl/unx/gtk/a11y/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx index 60975174096a..1c839ed58839 100644 --- a/vcl/unx/gtk/a11y/atktext.cxx +++ b/vcl/unx/gtk/a11y/atktext.cxx @@ -322,9 +322,11 @@ text_wrapper_get_text_at_offset (AtkText *text, * which is the same index as the first character of the next line. In atk the magic offset * '-2' is used to cover this special case. */ - if( -2 == offset && - (ATK_TEXT_BOUNDARY_LINE_START == boundary_type) || - (ATK_TEXT_BOUNDARY_LINE_END == boundary_type) ) + if ( + -2 == offset && + (ATK_TEXT_BOUNDARY_LINE_START == boundary_type || + ATK_TEXT_BOUNDARY_LINE_END == boundary_type) + ) { accessibility::XAccessibleMultiLineText* pMultiLineText = getMultiLineText( text ); if( pMultiLineText ) diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index b06a601d177e..2692177c765a 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -174,21 +174,7 @@ extern "C" pSalData->Init(); pSalData->initNWF(); - const char* pGtkModules = getenv( "GTK_MODULES" ); - if( pGtkModules ) - { - rtl::OString aModules( pGtkModules ); - sal_Int32 nIndex = 0; - while( nIndex >= 0 ) - { - rtl::OString aToken = aModules.getToken( 0, ':', nIndex ); - if( aToken.equals( "gail" ) || aToken.equals( "atk-bridge" ) ) - { - InitAtkBridge(); - break; - } - } - } + InitAtkBridge(); return pInstance; } diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx index a47b9bf31b01..8aef97904769 100644 --- a/vcl/unx/gtk/window/gtkframe.cxx +++ b/vcl/unx/gtk/window/gtkframe.cxx @@ -783,6 +783,11 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) ( ! (nStyle & SAL_FRAME_STYLE_FLOAT) || (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ); + /* #i100116# metacity has a peculiar behavior regarding WM_HINT accept focus and _NET_WM_USER_TIME + at some point that may be fixed in metacity and we will have to revisit this + */ + bool bMetaCityToolWindowHack = getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("Metacity") && + (nStyle & SAL_FRAME_STYLE_TOOLWINDOW ); if( bDecoHandling ) { bool bNoDecor = ! (nStyle & (SAL_FRAME_STYLE_MOVEABLE | SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_CLOSEABLE ) ); @@ -798,7 +803,8 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) { eType = GDK_WINDOW_TYPE_HINT_UTILITY; gtk_window_set_skip_taskbar_hint( GTK_WINDOW(m_pWindow), true ); - lcl_set_accept_focus( GTK_WINDOW(m_pWindow), FALSE, true ); + if( bMetaCityToolWindowHack ) + lcl_set_accept_focus( GTK_WINDOW(m_pWindow), FALSE, true ); } else if( (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) { @@ -843,7 +849,7 @@ void GtkSalFrame::Init( SalFrame* pParent, ULONG nStyle ) if( bDecoHandling ) { gtk_window_set_resizable( GTK_WINDOW(m_pWindow), (nStyle & SAL_FRAME_STYLE_SIZEABLE) ? TRUE : FALSE ); - if( ( (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) || ( (nStyle & SAL_FRAME_STYLE_TOOLWINDOW ) ) ) + if( ( (nStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) || bMetaCityToolWindowHack ) lcl_set_accept_focus( GTK_WINDOW(m_pWindow), FALSE, false ); } @@ -1329,7 +1335,10 @@ void GtkSalFrame::Show( BOOL bVisible, BOOL bNoActivate ) if( nUserTime == 0 && ( getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("Metacity") || - getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("compiz") + ( + getDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii("compiz") && + (m_nStyle & (SAL_FRAME_STYLE_OWNERDRAWDECORATION)) + ) ) ) { @@ -2791,7 +2800,7 @@ gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame ) GTK_YIELD_GRAB(); - if( GetX11SalData()->isTestTool() ) + if( ImplGetSVData()->mbIsTestTool ) { /* #i76541# testtool needs the focus to be in a new document * however e.g. metacity does not necessarily put the focus into diff --git a/vcl/unx/inc/saldata.hxx b/vcl/unx/inc/saldata.hxx index a4326990c464..2d09bd35649e 100644 --- a/vcl/unx/inc/saldata.hxx +++ b/vcl/unx/inc/saldata.hxx @@ -65,7 +65,6 @@ protected: SalXLib *pXLib_; SalDisplay *m_pSalDisplay; pthread_t hMainThread_; - bool m_bIsTesttool; public: X11SalData(); @@ -90,7 +89,6 @@ public: void StartTimer( ULONG nMS ); inline void StopTimer(); void Timeout() const; - bool isTestTool() const { return m_bIsTesttool; } static int XErrorHdl( Display*, XErrorEvent* ); static int XIOErrorHdl( Display* ); diff --git a/vcl/unx/source/app/saldata.cxx b/vcl/unx/source/app/saldata.cxx index 0f9e21052c50..b1f5a113828f 100644 --- a/vcl/unx/source/app/saldata.cxx +++ b/vcl/unx/source/app/saldata.cxx @@ -277,21 +277,8 @@ X11SalData::X11SalData() m_pSalDisplay = NULL; m_pInstance = NULL; m_pPlugin = NULL; - m_bIsTesttool = false; hMainThread_ = pthread_self(); - - sal_uInt32 nArgs = osl_getCommandArgCount(); - for( sal_uInt32 i = 0; i < nArgs; i++ ) - { - rtl::OUString aArg; - osl_getCommandArg( i, &aArg.pData ); - if( aArg.equalsAscii( "-enableautomation" ) ) - { - m_bIsTesttool = true; - break; - } - } } X11SalData::~X11SalData() diff --git a/vcl/unx/source/fontmanager/fontmanager.cxx b/vcl/unx/source/fontmanager/fontmanager.cxx index 73e117550a14..a116749daf47 100644 --- a/vcl/unx/source/fontmanager/fontmanager.cxx +++ b/vcl/unx/source/fontmanager/fontmanager.cxx @@ -63,9 +63,7 @@ #include "parseAFM.hxx" -#define NO_LIST -#include "sft.h" -#undef NO_LIST +#include "sft.hxx" #if OSL_DEBUG_LEVEL > 1 #include @@ -90,6 +88,7 @@ #define PRINTER_METRICDIR "fontmetric" +using namespace vcl; using namespace utl; using namespace psp; using namespace osl; diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 1d61dbe214a2..6d7812828a10 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1385,6 +1385,7 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly rRenderPeer.FillRectangle( PictOpSrc, rEntry.m_aPicture, &aRenderColor, 0, 0, 1, 1 ); // notify xrender of target drawable + // TODO: cache the matching xrender picture in the X11SalGraphics Picture aDst = rRenderPeer.CreatePicture( hDrawable_, pVisualFormat, 0, NULL ); // set clipping @@ -1396,6 +1397,10 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly rRenderPeer.CompositeTrapezoids( PictOpOver, rEntry.m_aPicture, aDst, pMaskFormat, 0, 0, &aTrapVector[0], aTrapVector.size() ); + // release xrender-counterpart of target drawable + // TODO: use scoped xrender picture + rRenderPeer.FreePicture( aDst ); + return TRUE; } diff --git a/vcl/unx/source/plugadapt/salplug.cxx b/vcl/unx/source/plugadapt/salplug.cxx index d76977944c11..668493c6ccb3 100644 --- a/vcl/unx/source/plugadapt/salplug.cxx +++ b/vcl/unx/source/plugadapt/salplug.cxx @@ -101,21 +101,7 @@ static SalInstance* tryInstance( const OUString& rModuleBase ) */ if( rModuleBase.equalsAscii("gtk") ) { - const char* gtk_modules = getenv( "GTK_MODULES" ); - if( gtk_modules ) - { - rtl::OString aModules( gtk_modules ); - sal_Int32 nIndex = 0; - while( nIndex >= 0 ) - { - rtl::OString aToken = aModules.getToken( 0, ':', nIndex ); - if( aToken.equals( "atk-bridge" ) ) - { - pCloseModule = NULL; - break; - } - } - } + pCloseModule = NULL; } GetSalData()->m_pPlugin = aMod; diff --git a/vcl/unx/source/printergfx/glyphset.cxx b/vcl/unx/source/printergfx/glyphset.cxx index 0d26a66cac2f..2a35e975cbab 100644 --- a/vcl/unx/source/printergfx/glyphset.cxx +++ b/vcl/unx/source/printergfx/glyphset.cxx @@ -34,9 +34,7 @@ #include "glyphset.hxx" #include "psputil.hxx" -#define NO_LIST -#include "sft.h" -#undef NO_LIST +#include "sft.hxx" #include "vcl/printergfx.hxx" #include "vcl/fontmanager.hxx" @@ -51,6 +49,7 @@ #include #include +using namespace vcl; using namespace psp; using namespace rtl; diff --git a/vcl/util/makefile.mk b/vcl/util/makefile.mk index 96cf50504ef0..6f5fd8a99522 100644 --- a/vcl/util/makefile.mk +++ b/vcl/util/makefile.mk @@ -190,8 +190,6 @@ SHL1STDLIBS+= \ $(BASEBMPLIB) \ -lAppleRemote$(DLLPOSTFIX) -SHL1STDLIBS+= \ - -framework QTKit LIB1FILES+= \ $(SLB)$/sala11y.lib .ENDIF diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 70701e2ee19a..16c055209088 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -64,8 +64,7 @@ #include "basegfx/polygon/b2dpolypolygon.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" -#include -#include +#include "sft.hxx" #ifdef GCP_KERN_HACK #include @@ -76,6 +75,8 @@ #include +using namespace vcl; + static const int MAXFONTHEIGHT = 2048; // ----------- diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 34900aaa951a..0689b8710655 100755 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -36,7 +36,7 @@ #include "salgdi.h" #include "saldata.hxx" // for GetMirroredChar -#include "sft.h" +#include "sft.hxx" #include "vcl/sallayout.hxx" #include "vcl/svapp.hxx" @@ -2441,9 +2441,9 @@ void UniscribeLayout::ApplyDXArray( const ImplLayoutArgs& rArgs ) if( rVisualItem.IsRTL() ) { for( i = rVisualItem.mnMinGlyphPos; i < rVisualItem.mnEndGlyphPos; ++i ) - if ( (1U << mpVisualAttrs[i].uJustification) & 0xFF89 ) // any Arabic justification ? - { // the last SCRIPT_JUSTIFY_xxx - // yes // == 15 (usp 1.6) + if ( (1U << mpVisualAttrs[i].uJustification) & 0xFF82 ) // any Arabic justification + { // excluding SCRIPT_JUSTIFY_NONE + // yes rVisualItem.mbHasKashidas = true; // so prepare for kashida handling InitKashidaHandling(); @@ -2509,10 +2509,14 @@ void UniscribeLayout::ApplyDXArray( const ImplLayoutArgs& rArgs ) for( i = nMinGlyphPos; i < nEndGlyphPos; ++i ) { const int nXOffsetAdjust = mpJustifications[i] - mpGlyphAdvances[i]; - if( i == nMinGlyphPos ) + // #i99862# skip diacritics, we mustn't add extra justification to diacritics + int nIdxAdd = i - 1; + while( (nIdxAdd >= nMinGlyphPos) && !mpGlyphAdvances[nIdxAdd] ) + --nIdxAdd; + if( nIdxAdd < nMinGlyphPos ) rVisualItem.mnXOffset += nXOffsetAdjust; else - mpJustifications[i-1] += nXOffsetAdjust; + mpJustifications[nIdxAdd] += nXOffsetAdjust; mpJustifications[i] -= nXOffsetAdjust; } } @@ -2540,8 +2544,8 @@ void UniscribeLayout::KashidaItemFix( int nMinGlyphPos, int nEndGlyphPos ) { // check for vowels if( (i > nMinGlyphPos && !mpGlyphAdvances[ i-1 ]) - && (1U << mpVisualAttrs[i].uJustification) & 0xFF89 ) - { + && (1U << mpVisualAttrs[i].uJustification) & 0xFF83 ) // all Arabic justifiction types + { // including SCRIPT_JUSTIFY_NONE // vowel, we do it like ScriptJustify does // the vowel gets the extra width long nSpaceAdded = mpJustifications[ i ] - mpGlyphAdvances[ i ]; From 09c7b55d7df42519027d0125ad7e0a01c8fa9d4b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 22 Apr 2009 08:23:48 +0000 Subject: [PATCH 048/283] fix a warning --- vcl/source/window/printdlg.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index bc6e22d2283a..398bac4d7e43 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -741,8 +741,8 @@ void PrintDialog::preparePreview() void PrintDialog::updateNup() { - int nRows = maPrinterPage.maNupRowsEdt.GetValue(); - int nCols = maPrinterPage.maNupColEdt.GetValue(); + int nRows = int(maPrinterPage.maNupRowsEdt.GetValue()); + int nCols = int(maPrinterPage.maNupColEdt.GetValue()); maPListener->setMultipage( nRows, nCols, maPrinterPage.maNupPortrait.IsChecked() From f0a717315d35423a70308ce84638caba6ca8822c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 23 Apr 2009 15:53:27 +0000 Subject: [PATCH 049/283] #101241# IntValue can be from NumericField which is a sal_Int64 --- vcl/inc/vcl/print.hxx | 4 ++-- vcl/source/gdi/print3.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 93b635756e95..1cff0331a704 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -532,9 +532,9 @@ class VCL_DLLPUBLIC PrinterOptionsHelper sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const { return getBoolValue( rtl::OUString::createFromAscii( i_pPropName ), i_bDefault ); } - sal_Int32 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int32 i_nDefault = 0 ) const; + sal_Int64 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const; // convenience for fixed strings - sal_Int32 getIntValue( const char* i_pPropName, sal_Int32 i_nDefault = 0 ) const + sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault = 0 ) const { return getIntValue( rtl::OUString::createFromAscii( i_pPropName ), i_nDefault ); } rtl::OUString getStringValue( const rtl::OUString& i_rPropertyName, const rtl::OUString& i_rDefault = rtl::OUString() ) const; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 63e27b5b3a5f..0623230ae085 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -832,9 +832,9 @@ sal_Bool PrinterOptionsHelper::getBoolValue( const rtl::OUString& i_rPropertyNam return (aVal >>= bRet) ? bRet : i_bDefault; } -sal_Int32 PrinterOptionsHelper::getIntValue( const rtl::OUString& i_rPropertyName, sal_Int32 i_nDefault ) const +sal_Int64 PrinterOptionsHelper::getIntValue( const rtl::OUString& i_rPropertyName, sal_Int64 i_nDefault ) const { - sal_Int32 nRet = 0; + sal_Int64 nRet = 0; Any aVal( getValue( i_rPropertyName ) ); return (aVal >>= nRet) ? nRet : i_nDefault; } From 060f36af7d35aaa8a7c9c28d9a8a1a6bf6a684e0 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 09:43:48 +0000 Subject: [PATCH 050/283] #i92516# avoid unnecessary calls to render the current page --- vcl/inc/vcl/prndlg.hxx | 6 ++++- vcl/source/window/printdlg.cxx | 48 +++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index c44bda8a2711..24ea0ea6a3e3 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -56,6 +56,8 @@ namespace vcl class PrintPreviewWindow : public Window { GDIMetaFile maMtf; + double mfScaleX; + double mfScaleY; public: PrintPreviewWindow( Window* pParent, const ResId& ); virtual ~PrintPreviewWindow(); @@ -63,6 +65,7 @@ namespace vcl virtual void Paint( const Rectangle& rRect ); void setPreview( const GDIMetaFile& ); + void setScale( double fScaleX, double fScaleY ); }; class PrinterTabPage : public TabPage @@ -135,6 +138,7 @@ namespace vcl sal_Int32 mnCurPage; sal_Int32 mnCachedPages; Rectangle maPreviewSpace; + Size maCurPageSize; std::list< Window* > maControls; std::map< Window*, rtl::OUString > maControlToPropertyMap; @@ -145,7 +149,7 @@ namespace vcl Size maNupLandscapeSize; void updateNup(); - void preparePreview(); + void preparePreview( bool i_bPrintChanged = true ); void setPreviewText( sal_Int32 ); void updatePrinterText(); void checkControlDependencies(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 398bac4d7e43..39e9f97f7290 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -51,7 +51,9 @@ using namespace com::sun::star::uno; using namespace com::sun::star::beans; PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) - : Window( i_pParent, i_rId ) + : Window( i_pParent, i_rId ), + mfScaleX( 1 ), + mfScaleY( 1 ) { } @@ -63,13 +65,17 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect ) { Window::Paint( i_rRect ); + GDIMetaFile aMtf( maMtf ); + SetFillColor( Color( COL_WHITE ) ); SetLineColor(); DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() )); Push(); SetMapMode( MAP_100TH_MM ); - maMtf.WindStart(); - maMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ); + aMtf.WindStart(); + aMtf.Scale( mfScaleX, mfScaleY ); + aMtf.WindStart(); + aMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ); Pop(); } @@ -79,6 +85,13 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi Invalidate(); } +void PrintDialog::PrintPreviewWindow::setScale( double fScaleX, double fScaleY ) +{ + mfScaleX = fScaleX; + mfScaleY = fScaleY; + Invalidate(); +} + PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) @@ -694,7 +707,7 @@ void PrintDialog::setPreviewText( sal_Int32 nSetPage ) maPageText.SetText( maNoPageStr ); } -void PrintDialog::preparePreview() +void PrintDialog::preparePreview( bool i_bNewPage ) { // page range may have changed depending on options sal_Int32 nPages = maPListener->getFilteredPageCount(); @@ -714,29 +727,34 @@ void PrintDialog::preparePreview() boost::shared_ptr aPrt( maPListener->getPrinter() ); - const MapMode aMapMode( MAP_100TH_MM ); - GDIMetaFile aMtf; - Size aPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); + if( i_bNewPage ) + { + const MapMode aMapMode( MAP_100TH_MM ); + GDIMetaFile aMtf; + maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); + + maPreviewWindow.setPreview( aMtf ); + } Size aPreviewSize; Point aPreviewPos = maPreviewSpace.TopLeft(); const long nW = maPreviewSpace.GetSize().Width(); const long nH = maPreviewSpace.GetSize().Height(); - if( aPageSize.Width() > aPageSize.Height() ) + if( maCurPageSize.Width() > maCurPageSize.Height() ) { - aPreviewSize = Size( nW, nW * aPageSize.Height() / aPageSize.Width() ); + aPreviewSize = Size( nW, nW * maCurPageSize.Height() / maCurPageSize.Width() ); aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2; } else { - aPreviewSize = Size( nH * aPageSize.Width() / aPageSize.Height(), nH ); + aPreviewSize = Size( nH * maCurPageSize.Width() / maCurPageSize.Height(), nH ); aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2; } + maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize ); const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) ); - aMtf.Scale( double(aLogicSize.Width())/double(aPageSize.Width()), - double(aLogicSize.Height())/double(aPageSize.Height()) ); - maPreviewWindow.setPreview( aMtf ); + maPreviewWindow.setScale( double(aLogicSize.Width())/double(maCurPageSize.Width()), + double(aLogicSize.Height())/double(maCurPageSize.Height()) ); } void PrintDialog::updateNup() @@ -989,8 +1007,8 @@ void PrintDialog::Resize() aBtnRect.Bottom() = aBtnRect.Top() + maPageText.GetSizePixel().Height() - 1; maPageText.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - // and do the preview - preparePreview(); + // and do the preview; however the metafile does not need to be gotten anew + preparePreview( false ); } // ----------------------------------------------------------------------------- From fb285c9745d6e3b6e0a00830e703adcfe0e6c230 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 13:15:04 +0000 Subject: [PATCH 051/283] #i101242# release options helper on last page --- vcl/aqua/source/gdi/salprn.cxx | 10 ++++++++++ vcl/inc/vcl/print.hxx | 1 + vcl/source/gdi/print3.cxx | 27 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index e70f359bbe85..f7e08cf4804c 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -493,6 +493,9 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, bool bNeedRestart = true; sal_Int32 nAllPages = 1; + // reset IsLastPage + i_rListener.setLastPage( sal_False ); + // update job data if( i_pSetupData ) SetData( ~0, i_pSetupData ); @@ -588,6 +591,13 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, mnCurPageRangeCount = 1; } while( bNeedRestart && mnCurPageRangeCount < nAllPages ); + // inform applictation that it can release its data + // this is awkward, but the XRenderable interface has no method for this, + // so we need to call XRenderadble::render one last time with IsLastPage = TRUE + i_rListener.setLastPage( sal_True ); + GDIMetaFile aPageFile; + Size aPageSize = i_rListener.getFilteredPageFile( 0, aPageFile ); + mnCurPageRangeStart = mnCurPageRangeCount = 0; return bSuccess; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 1cff0331a704..a757684a7eff 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -496,6 +496,7 @@ public: void SAL_DLLPRIVATE createProgressDialog(); void SAL_DLLPRIVATE setPrintSelection( const rtl::OUString& ); void SAL_DLLPRIVATE setMultipage( int nRows, int nColumns, const Size& rPaperSize ); + void SAL_DLLPRIVATE setLastPage( sal_Bool i_bLastPage ); }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 0623230ae085..74aae6936609 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -79,6 +79,7 @@ public: Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; rtl::OUString maSelectionString; + sal_Bool mbLastPage; int mnMultiPageRows; int mnMultiPageColumns; @@ -88,6 +89,7 @@ public: ImplPrinterListenerData() : maSelectionString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ), + mbLastPage( sal_False ), mnMultiPageRows( 1 ), mnMultiPageColumns( 1 ), mpProgress( NULL ) @@ -202,6 +204,9 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->setPrinter( pPrinter ); } + // reset last page property + i_pListener->setLastPage( sal_False ); + // check if the printer brings up its own dialog // in that case leave the work to that dialog const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); @@ -212,7 +217,12 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene { PrintDialog aDlg( NULL, i_pListener ); if( ! aDlg.Execute() ) + { + GDIMetaFile aPageFile; + i_pListener->setLastPage( sal_True ); + Size aPageSize = i_pListener->getFilteredPageFile( 0, aPageFile ); return; + } if( aDlg.isPrintToFile() ) { rtl::OUString aFile = queryFile( pListener->getPrinter().get() ); @@ -330,6 +340,8 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrgetFilteredPageCount(); for( int nPage = 0; nPage < nPages; nPage++ ) { + if( nPage == nPages-1 ) + i_pListener->setLastPage( sal_True ); i_pListener->printFilteredPage( nPage ); } EndJob(); @@ -620,10 +632,15 @@ void PrinterListener::jobFinished() { } +void PrinterListener::setLastPage( sal_Bool i_bLastPage ) +{ + mpImplData->mbLastPage = i_bLastPage; +} + Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; - size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 1; + size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 2; for( int i = 0; i < i_rMergeList.getLength(); i++ ) aMergeSet.insert( i_rMergeList[i].Name ); @@ -644,6 +661,14 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro aVal.Value <<= mpImplData->maSelectionString; aResult[nCur++] = aVal; } + // append IsLastPage + if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) ) == aMergeSet.end() ) + { + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ); + aVal.Value <<= mpImplData->mbLastPage; + aResult[nCur++] = aVal; + } aResult.realloc( nCur ); return aResult; } From a34d3936c81cdd3997ef5783c6c49f1239ba1f5b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 13:21:25 +0000 Subject: [PATCH 052/283] #i101241# IsPrinter property --- vcl/source/gdi/print3.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 74aae6936609..cee64726581d 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -640,7 +640,7 @@ void PrinterListener::setLastPage( sal_Bool i_bLastPage ) Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; - size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 2; + size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 3; for( int i = 0; i < i_rMergeList.getLength(); i++ ) aMergeSet.insert( i_rMergeList[i].Name ); @@ -669,6 +669,14 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro aVal.Value <<= mpImplData->mbLastPage; aResult[nCur++] = aVal; } + // append IsPrinter + if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrinter" ) ) ) == aMergeSet.end() ) + { + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrinter" ) ); + aVal.Value <<= sal_True; + aResult[nCur++] = aVal; + } aResult.realloc( nCur ); return aResult; } From 2332ec48eb9166e8bcd0b205da730b2e955d8ec8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Apr 2009 15:39:41 +0000 Subject: [PATCH 053/283] #i92516# help ids for fixed controls --- vcl/source/window/printdlg.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 39e9f97f7290..e76ce4298474 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -50,6 +50,8 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::beans; +#define SMHID( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( ".HelpId:vcl:PrintDialog:" a ":" b ) ) ) ) + PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ), mfScaleX( 1 ), @@ -113,6 +115,23 @@ PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rRe , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) { FreeResource(); + maPrinters.SMHID( "PrinterPage", "PrinterList" ); + maSetupButton.SMHID( "PrinterPage", "Setup" ); + maType.SMHID( "PrinterPage", "Type" ); + maTypeText.SMHID( "PrinterPage", "TypeText" ); + maStatus.SMHID( "PrinterPage", "Status" ); + maStatusText.SMHID( "PrinterPage", "StatusText" ); + maLocation.SMHID( "PrinterPage", "Locaction" ); + maLocText.SMHID( "PrinterPage", "LocactionText" ); + maComment.SMHID( "PrinterPage", "Comment" ); + maCommentText.SMHID( "PrinterPage", "CommentText" ); + maNupLine.SMHID( "PrinterPage", "NUPline" ); + maNupRowsTxt.SMHID( "PrinterPage", "NUPRowsText" ); + maNupRowsEdt.SMHID( "PrinterPage", "NUPRows" ); + maNupColTxt.SMHID( "PrinterPage", "NUPColumnsText" ); + maNupColEdt.SMHID( "PrinterPage", "NUPColumns" ); + maNupPortrait.SMHID( "PrinterPage", "NUPPortrait" ); + maNupLandscape.SMHID( "PrinterPage", "NUPLandscape" ); } PrintDialog::PrinterTabPage::~PrinterTabPage() @@ -139,6 +158,18 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) { FreeResource(); + maPrinters.SMHID( "JobPage", "PrinterList" ); + maToFileBox.SMHID( "JobPage", "ToFile" ); + maPrintRange.SMHID( "JobPage", "PrintRange" ); + maAllButton.SMHID( "JobPage", "AllButton" ); + maPagesButton.SMHID( "JobPage", "PagesButton" ); + maSelectionButton.SMHID( "JobPage", "SelectionButton" ); + maPagesEdit.SMHID( "JobPage", "Pages" ); + maCopies.SMHID( "JobPage", "CopiesLine" ); + maCopyCount.SMHID( "JobPage", "CopiesText" ); + maCopyCountField.SMHID( "JobPage", "Copies" ); + maCollateBox.SMHID( "JobPage", "Collate" ); + maCollateImage.SMHID( "JobPage", "CollateImage" ); } PrintDialog::JobTabPage::~JobTabPage() From 28d7db7c3c0d52c923da67814f9bb40db9cc9304 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 27 Apr 2009 09:47:17 +0000 Subject: [PATCH 054/283] #i92516# add help ids --- vcl/source/window/printdlg.cxx | 124 ++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 31 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index e76ce4298474..b704e46ed392 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -50,7 +50,9 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::beans; -#define SMHID( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( ".HelpId:vcl:PrintDialog:" a ":" b ) ) ) ) +#define HELPID_PREFIX ".HelpId:vcl:PrintDialog" +#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ) ) ) +#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) ) PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ), @@ -115,23 +117,23 @@ PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rRe , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) { FreeResource(); - maPrinters.SMHID( "PrinterPage", "PrinterList" ); - maSetupButton.SMHID( "PrinterPage", "Setup" ); - maType.SMHID( "PrinterPage", "Type" ); - maTypeText.SMHID( "PrinterPage", "TypeText" ); - maStatus.SMHID( "PrinterPage", "Status" ); - maStatusText.SMHID( "PrinterPage", "StatusText" ); - maLocation.SMHID( "PrinterPage", "Locaction" ); - maLocText.SMHID( "PrinterPage", "LocactionText" ); - maComment.SMHID( "PrinterPage", "Comment" ); - maCommentText.SMHID( "PrinterPage", "CommentText" ); - maNupLine.SMHID( "PrinterPage", "NUPline" ); - maNupRowsTxt.SMHID( "PrinterPage", "NUPRowsText" ); - maNupRowsEdt.SMHID( "PrinterPage", "NUPRows" ); - maNupColTxt.SMHID( "PrinterPage", "NUPColumnsText" ); - maNupColEdt.SMHID( "PrinterPage", "NUPColumns" ); - maNupPortrait.SMHID( "PrinterPage", "NUPPortrait" ); - maNupLandscape.SMHID( "PrinterPage", "NUPLandscape" ); + maPrinters.SMHID2( "PrinterPage", "PrinterList" ); + maSetupButton.SMHID2( "PrinterPage", "Setup" ); + maType.SMHID2( "PrinterPage", "Type" ); + maTypeText.SMHID2( "PrinterPage", "TypeText" ); + maStatus.SMHID2( "PrinterPage", "Status" ); + maStatusText.SMHID2( "PrinterPage", "StatusText" ); + maLocation.SMHID2( "PrinterPage", "Locaction" ); + maLocText.SMHID2( "PrinterPage", "LocactionText" ); + maComment.SMHID2( "PrinterPage", "Comment" ); + maCommentText.SMHID2( "PrinterPage", "CommentText" ); + maNupLine.SMHID2( "PrinterPage", "NUPline" ); + maNupRowsTxt.SMHID2( "PrinterPage", "NUPRowsText" ); + maNupRowsEdt.SMHID2( "PrinterPage", "NUPRows" ); + maNupColTxt.SMHID2( "PrinterPage", "NUPColumnsText" ); + maNupColEdt.SMHID2( "PrinterPage", "NUPColumns" ); + maNupPortrait.SMHID2( "PrinterPage", "NUPPortrait" ); + maNupLandscape.SMHID2( "PrinterPage", "NUPLandscape" ); } PrintDialog::PrinterTabPage::~PrinterTabPage() @@ -158,18 +160,18 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) { FreeResource(); - maPrinters.SMHID( "JobPage", "PrinterList" ); - maToFileBox.SMHID( "JobPage", "ToFile" ); - maPrintRange.SMHID( "JobPage", "PrintRange" ); - maAllButton.SMHID( "JobPage", "AllButton" ); - maPagesButton.SMHID( "JobPage", "PagesButton" ); - maSelectionButton.SMHID( "JobPage", "SelectionButton" ); - maPagesEdit.SMHID( "JobPage", "Pages" ); - maCopies.SMHID( "JobPage", "CopiesLine" ); - maCopyCount.SMHID( "JobPage", "CopiesText" ); - maCopyCountField.SMHID( "JobPage", "Copies" ); - maCollateBox.SMHID( "JobPage", "Collate" ); - maCollateImage.SMHID( "JobPage", "CollateImage" ); + maPrinters.SMHID2( "JobPage", "PrinterList" ); + maToFileBox.SMHID2( "JobPage", "ToFile" ); + maPrintRange.SMHID2( "JobPage", "PrintRange" ); + maAllButton.SMHID2( "JobPage", "AllButton" ); + maPagesButton.SMHID2( "JobPage", "PagesButton" ); + maSelectionButton.SMHID2( "JobPage", "SelectionButton" ); + maPagesEdit.SMHID2( "JobPage", "Pages" ); + maCopies.SMHID2( "JobPage", "CopiesLine" ); + maCopyCount.SMHID2( "JobPage", "CopiesText" ); + maCopyCountField.SMHID2( "JobPage", "Copies" ); + maCollateBox.SMHID2( "JobPage", "Collate" ); + maCollateImage.SMHID2( "JobPage", "CollateImage" ); } PrintDialog::JobTabPage::~JobTabPage() @@ -291,6 +293,14 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr 1 ? maJobPage.maCollateBox.IsChecked() : FALSE; } +static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId = -1, const rtl::OUString& i_rPropName = rtl::OUString() ) +{ + rtl::OUStringBuffer aBuf( 256 ); + aBuf.appendAscii( HELPID_PREFIX ); + if( i_rPropName.getLength() ) + { + aBuf.append( sal_Unicode( ':' ) ); + aBuf.append( i_rPropName ); + } + if( i_pType ) + { + aBuf.append( sal_Unicode( ':' ) ); + aBuf.appendAscii( i_pType ); + } + if( i_nId >= 0 ) + { + aBuf.append( sal_Unicode( ':' ) ); + aBuf.append( i_nId ); + } + i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear() ) ); +} + void PrintDialog::setupOptionalUI() { Window* pCurParent = 0; long nCurY = 0, nXPos = 5, nMaxY = 0; - USHORT nOptPageId = 9; + USHORT nOptPageId = 9, nCurSubGroup = 0; MapMode aFontMapMode( MAP_APPFONT ); Size aTabSize = maTabCtrl.GetTabPageSizePixel(); @@ -423,6 +455,12 @@ void PrintDialog::setupOptionalUI() pNewGroup->SetText( aText ); maTabCtrl.InsertPage( ++nOptPageId, aText ); maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); + + // set help id + setSmartId( pNewGroup, "TabPage", nOptPageId ); + + // reset subgroup counter + nCurSubGroup = 0; } if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) @@ -440,6 +478,9 @@ void PrintDialog::setupOptionalUI() pNewSub->Show(); nCurY += 12; nXPos += 5; + + // set help id + setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); } else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { @@ -465,6 +506,9 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); maControlToPropertyMap[pNewBox] = aPropertyName; + // set help id + setSmartId( pNewBox, "CheckBox", -1, aPropertyName ); + } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -483,6 +527,9 @@ void PrintDialog::setupOptionalUI() nXPos += 10; nCurY += 12; + + // set help id + setSmartId( pHeading, "FixedText", -1, aPropertyName ); } // iterate options @@ -507,6 +554,9 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pBtn] = aPropertyName; maControlToNumValMap[pBtn] = m; + // set help id + setSmartId( pBtn, "RadioButton", m, aPropertyName ); + nCurY += 12; } nXPos = nOldXPos; @@ -523,6 +573,9 @@ void PrintDialog::setupOptionalUI() aPixelSize ); pHeading->Show(); + // set help id + setSmartId( pHeading, "FixedText", -1, aPropertyName ); + ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); maControls.push_front( pList ); @@ -567,6 +620,9 @@ void PrintDialog::setupOptionalUI() pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); pList->Show(); + // set help id + setSmartId( pList, "ListBox", -1, aPropertyName ); + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); maControlToPropertyMap[pList] = aPropertyName; nCurY += 16; @@ -591,6 +647,9 @@ void PrintDialog::setupOptionalUI() aPixelSize ); pHeading->Show(); + // set help id + setSmartId( pHeading, "FixedText", -1, aPropertyName ); + NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); maControls.push_front( pField ); @@ -629,6 +688,9 @@ void PrintDialog::setupOptionalUI() pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); + // set help id + setSmartId( pField, "NumericField", -1, aPropertyName ); + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); maControlToPropertyMap[pField] = aPropertyName; nCurY += 16; From 1845fc4790d475720db8476444cce65d56065805 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 27 Apr 2009 16:11:03 +0000 Subject: [PATCH 055/283] #i92516# HelpTexts for new print UI --- vcl/inc/vcl/print.hxx | 8 ++++-- vcl/source/gdi/print3.cxx | 47 +++++++++++++++++++++++++++++----- vcl/source/window/printdlg.cxx | 35 ++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index a757684a7eff..48878199cb98 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -547,6 +547,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // general control static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, + const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpText, const rtl::OUString& i_rType, const com::sun::star::beans::PropertyValue* i_pVal = NULL, const com::sun::star::uno::Sequence< rtl::OUString >* i_pChoices = NULL, @@ -556,14 +557,15 @@ class VCL_DLLPUBLIC PrinterOptionsHelper ); // create a group (e.g. a TabPage); following controls will be grouped in it until the next // group begins - static com::sun::star::uno::Any getGroupControlOpt( const rtl::OUString& i_rTitle ); + static com::sun::star::uno::Any getGroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ); // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next // subgroup or group begins - static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle ); + static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ); // create a bool option (usually a checkbox) static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Bool i_bValue, const rtl::OUString* i_pDependsOnName = NULL, @@ -572,6 +574,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // create a set of choices (either a radio button group or a list box) static com::sun::star::uno::Any getChoiceControlOpt( const rtl::OUString& i_rTitle, + const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpText, const rtl::OUString& i_rProperty, const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, @@ -583,6 +586,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // create an integer range (e.g. a spin field) // note: max value < min value means do not apply min/max values static com::sun::star::uno::Any getRangeControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Int32 i_nValue, sal_Int32 i_nMinValue = -1, diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index cee64726581d..14735ff42413 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -928,6 +928,7 @@ void PrinterOptionsHelper::appendPrintUIOptions( uno::Sequence< beans::PropertyV } Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + const Sequence< rtl::OUString >& i_rHelpTexts, const rtl::OUString& i_rType, const PropertyValue* i_pVal, const Sequence< rtl::OUString >* i_pChoices, @@ -940,6 +941,7 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, sal_Int32 nElements = 1 // ControlType + (i_rTitle.getLength() ? 1 : 0) // Text + + (i_rHelpTexts.getLength() ? 1 : 0) // HelpText + (i_pVal ? 1 : 0) // Property + (i_pChoices ? 1 : 0) // Choices + (i_pDependsOnName ? (i_nDependsOnEntry != -1 ? 2 : 1) : 0) // dependencies @@ -953,6 +955,11 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) ); aCtrl[nUsed++].Value = makeAny( i_rTitle ); } + if( i_rHelpTexts.getLength() ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ); + aCtrl[nUsed++].Value = makeAny( i_rHelpTexts ); + } aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlType" ) ); aCtrl[nUsed++].Value = makeAny( i_rType ); if( i_pVal ) @@ -988,30 +995,50 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, return makeAny( aCtrl ); } -Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle ) +Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ) { - return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); + Sequence< rtl::OUString > aHelpText; + if( i_rHelpText.getLength() > 0 ) + { + aHelpText.realloc( 1 ); + *aHelpText.getArray() = i_rHelpText; + } + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); } -Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle ) +Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ) { - return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + Sequence< rtl::OUString > aHelpText; + if( i_rHelpText.getLength() > 0 ) + { + aHelpText.realloc( 1 ); + *aHelpText.getArray() = i_rHelpText; + } + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); } Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Bool i_bValue, const rtl::OUString* i_pDependsOnName, sal_Int32 i_nDependsOnEntry ) { + Sequence< rtl::OUString > aHelpText; + if( i_rHelpText.getLength() > 0 ) + { + aHelpText.realloc( 1 ); + *aHelpText.getArray() = i_rHelpText; + } PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); } Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, + const Sequence< rtl::OUString >& i_rHelpText, const rtl::OUString& i_rProperty, const Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, @@ -1023,10 +1050,11 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); + return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); } Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Int32 i_nValue, sal_Int32 i_nMinValue, @@ -1035,10 +1063,17 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nDependsOnEntry ) { + Sequence< rtl::OUString > aHelpText; + if( i_rHelpText.getLength() > 0 ) + { + aHelpText.realloc( 1 ); + *aHelpText.getArray() = i_rHelpText; + } PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_nValue ); return getUIControlOpt( i_rTitle, + aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Range" ) ), &aVal, NULL, diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b704e46ed392..b8a2a1a21910 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -349,6 +349,12 @@ static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear() ) ); } +static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex ) +{ + if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() ) + i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); +} + void PrintDialog::setupOptionalUI() { Window* pCurParent = 0; @@ -369,8 +375,10 @@ void PrintDialog::setupOptionalUI() rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + Sequence< rtl::OUString > aHelpTexts; sal_Int64 nMinValue = 0, nMaxValue = 0; long nDependencyIndent = 0; + sal_Int32 nCurHelpText = 0; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -432,6 +440,18 @@ void PrintDialog::setupOptionalUI() { rEntry.Value >>= nMaxValue; } + else if( rEntry.Name.equalsAscii( "HelpText" ) ) + { + if( ! (rEntry.Value >>= aHelpTexts) ) + { + rtl::OUString aHelpText; + if( (rEntry.Value >>= aHelpText) ) + { + aHelpTexts.realloc( 1 ); + *aHelpTexts.getArray() = aHelpText; + } + } + } } if( aCtrlType.equalsAscii( "Group" ) || @@ -458,6 +478,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pNewGroup, "TabPage", nOptPageId ); + // set help text + setHelpText( pNewGroup, aHelpTexts, 0 ); // reset subgroup counter nCurSubGroup = 0; @@ -481,6 +503,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); + // set help text + setHelpText( pNewSub, aHelpTexts, 0 ); } else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { @@ -508,7 +532,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pNewBox, "CheckBox", -1, aPropertyName ); - + // set help text + setHelpText( pNewBox, aHelpTexts, 0 ); } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -530,6 +555,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); + // set help text + setHelpText( pHeading, aHelpTexts, nCurHelpText++ ); } // iterate options @@ -556,6 +583,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pBtn, "RadioButton", m, aPropertyName ); + // set help text + setHelpText( pBtn, aHelpTexts, nCurHelpText++ ); nCurY += 12; } @@ -622,6 +651,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pList, "ListBox", -1, aPropertyName ); + // set help text + setHelpText( pList, aHelpTexts, 0 ); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); maControlToPropertyMap[pList] = aPropertyName; @@ -690,6 +721,8 @@ void PrintDialog::setupOptionalUI() // set help id setSmartId( pField, "NumericField", -1, aPropertyName ); + // set help text + setHelpText( pField, aHelpTexts, 0 ); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); maControlToPropertyMap[pField] = aPropertyName; From e9de7039fd558700fb4ae953ad5b2939b099c6b5 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Apr 2009 09:49:55 +0000 Subject: [PATCH 056/283] #i92516# pass selection or whole document to XRenderable interface --- vcl/inc/vcl/print.hxx | 6 ++++++ vcl/source/gdi/print3.cxx | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 48878199cb98..ab08a9ef7e56 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -456,6 +456,12 @@ public: com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const; + /* get the current selection string; either a UI editable string or "all" + a special value "selection" is supported signifying the current selected contents + of the printed document is to be printed. + */ + const rtl::OUString& getSelectionString() const; + /* get the PropertyValue of a Property */ com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 14735ff42413..d3a2c784fd9e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -681,6 +681,11 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro return aResult; } +const rtl::OUString& PrinterListener::getSelectionString() const +{ + return mpImplData->maSelectionString; +} + const Sequence< beans::PropertyValue >& PrinterListener::getUIOptions() const { return mpImplData->maUIOptions; From 51dd8091fce1270fa10b18f5b92a816dd824bd1e Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 5 May 2009 17:16:25 +0000 Subject: [PATCH 057/283] #i92516# catch a corner case (0 pages) --- vcl/source/gdi/print3.cxx | 3 ++- vcl/source/window/printdlg.cxx | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index d3a2c784fd9e..7d18c754ee5b 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -220,7 +220,8 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene { GDIMetaFile aPageFile; i_pListener->setLastPage( sal_True ); - Size aPageSize = i_pListener->getFilteredPageFile( 0, aPageFile ); + if( i_pListener->getPageCount() > 0 ) + i_pListener->getFilteredPageFile( 0, aPageFile ); return; } if( aDlg.isPrintToFile() ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b8a2a1a21910..d386b7ad43b2 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -857,10 +857,14 @@ void PrintDialog::preparePreview( bool i_bNewPage ) { const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; - maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); + if( nPages > 0 ) + maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); maPreviewWindow.setPreview( aMtf ); } + // catch corner case of strange page size + if( maCurPageSize.Width() == 0 || maCurPageSize.Height() == 0 ) + maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); Size aPreviewSize; Point aPreviewPos = maPreviewSpace.TopLeft(); @@ -1155,6 +1159,9 @@ PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) : { FreeResource(); + if( mnMax < 1 ) + mnMax = 1; + maStr = maText.GetText(); maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) ); @@ -1201,6 +1208,9 @@ void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) if( i_nMax != -1 ) mnMax = i_nMax; + if( mnMax < 1 ) + mnMax = 1; + rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur ) ); aNewText = searchAndReplace( aNewText, "%n", 2, mnMax ); maText.SetText( aNewText ); @@ -1217,6 +1227,9 @@ void PrintProgressDialog::tick() void PrintProgressDialog::Paint( const Rectangle& ) { + if( maProgressRect.IsEmpty() ) + implCalcProgressRect(); + Push( PUSH_LINECOLOR | PUSH_FILLCOLOR ); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); Color aPrgsColor = rStyleSettings.GetHighlightColor(); From 210e3f82d81d50d44acc59bac05a680968d4976f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 14 May 2009 08:05:27 +0000 Subject: [PATCH 058/283] #i92516# add: hasProperty --- vcl/inc/vcl/print.hxx | 5 +++++ vcl/source/gdi/print3.cxx | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index ab08a9ef7e56..c7575812f01d 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -531,6 +531,11 @@ class VCL_DLLPUBLIC PrinterOptionsHelper **/ void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const; + // check if a property exists + bool hasProperty( const rtl::OUString& i_rPropertyName ) const; + bool hasProperty( const char* i_pPropertyName ) const + { return hasProperty( rtl::OUString::createFromAscii( i_pPropertyName ) ); } + // returns an empty Any for not existing properties com::sun::star::uno::Any getValue( const rtl::OUString& i_rPropertyName ) const; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 7d18c754ee5b..6c6d55a4a796 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -864,6 +864,14 @@ Any PrinterOptionsHelper::getValue( const rtl::OUString& i_rPropertyName ) const return aRet; } +bool PrinterOptionsHelper::hasProperty( const rtl::OUString& i_rPropertyName ) const +{ + Any aRet; + std::hash_map< rtl::OUString, Any, rtl::OUStringHash >::const_iterator it = + m_aPropertyMap.find( i_rPropertyName ); + return it != m_aPropertyMap.end(); +} + sal_Bool PrinterOptionsHelper::getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault ) const { sal_Bool bRet = sal_False; From de84f6b62c4edbfb2b998e9b12402a8c4dd105ab Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 14 May 2009 08:18:58 +0000 Subject: [PATCH 059/283] #i92516# filter accelerators from texts (not used on MacOS) --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 9f1b7ef64edf..ed16df90af80 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -184,6 +184,14 @@ class ListenerProperties } }; +static void filterAccelerator( rtl::OUString& io_rText ) +{ + rtl::OUStringBuffer aBuf( io_rText.getLength() ); + for( sal_Int32 nIndex = 0; nIndex != -1; ) + aBuf.append( io_rText.getToken( 0, '~', nIndex ) ); + io_rText = aBuf.makeStringAndClear(); +} + @interface ControlTarget : NSObject { ListenerProperties* mpListener; @@ -311,6 +319,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) if( rEntry.Name.equalsAscii( "Text" ) ) { rEntry.Value >>= aText; + filterAccelerator( aText ); } else if( rEntry.Name.equalsAscii( "ControlType" ) ) { From 10b35f02b14b8377c63d76bf634f1c794995c5f6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 14 May 2009 13:32:29 +0000 Subject: [PATCH 060/283] #i92516# fix 0 pages case --- vcl/aqua/source/gdi/aquaprintview.mm | 3 +- vcl/aqua/source/gdi/salprn.cxx | 52 +++++++++++++++++----------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintview.mm b/vcl/aqua/source/gdi/aquaprintview.mm index 79efb9c80941..a050d229f033 100755 --- a/vcl/aqua/source/gdi/aquaprintview.mm +++ b/vcl/aqua/source/gdi/aquaprintview.mm @@ -76,6 +76,7 @@ int nPage = (int)(aPaperSize.width * rect.origin.y + rect.origin.x); // page count is 1 based - mpListener->printFilteredPage( nPage-1 ); + if( nPage - 1 < (mpInfoPrinter->getCurPageRangeStart() + mpInfoPrinter->getCurPageRangeCount() ) ) + mpListener->printFilteredPage( nPage-1 ); } @end diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index f7e08cf4804c..5dcac0a38027 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -491,7 +491,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, BOOL bSuccess = FALSE; AquaSalInstance* pInst = GetSalData()->mpFirstInstance; bool bNeedRestart = true; - sal_Int32 nAllPages = 1; + sal_Int32 nAllPages = 0; // reset IsLastPage i_rListener.setLastPage( sal_False ); @@ -504,30 +504,37 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, { if( bNeedRestart ) { - mnCurPageRangeStart = 1; - mnCurPageRangeCount = 1; + mnCurPageRangeStart = 0; + mnCurPageRangeCount = 0; nAllPages = i_rListener.getPageCount(); } bNeedRestart = false; - mnCurPageRangeCount = 1; - Size aCurSize( getPageSize( i_rListener, mnCurPageRangeStart ) ); - Size aNextSize( aCurSize ); - // print pages up to a different size - while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) + Size aCurSize( 21000, 29700 ); + if( nAllPages > 0 ) { - aNextSize = getPageSize( i_rListener, mnCurPageRangeStart + mnCurPageRangeCount ); - if( aCurSize == aNextSize // same page size - || - (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation - ) + mnCurPageRangeCount = 1; + aCurSize = getPageSize( i_rListener, mnCurPageRangeStart ); + Size aNextSize( aCurSize ); + + // print pages up to a different size + while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) { - mnCurPageRangeCount++; + aNextSize = getPageSize( i_rListener, mnCurPageRangeStart + mnCurPageRangeCount ); + if( aCurSize == aNextSize // same page size + || + (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation + ) + { + mnCurPageRangeCount++; + } + else + break; } - else - break; } + else + mnCurPageRangeCount = 0; // now for the current run mnStartPageOffsetX = mnStartPageOffsetY = 0; @@ -574,7 +581,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: YES]; - if( bShowPanel && mnCurPageRangeStart == 1 ) // only the first range of pages gets the accesory view + if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withRestartCondition: &bNeedRestart]; bSuccess = TRUE; @@ -589,14 +596,17 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, mnCurPageRangeStart += mnCurPageRangeCount; mnCurPageRangeCount = 1; - } while( bNeedRestart && mnCurPageRangeCount < nAllPages ); + } while( bNeedRestart && mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); // inform applictation that it can release its data // this is awkward, but the XRenderable interface has no method for this, // so we need to call XRenderadble::render one last time with IsLastPage = TRUE - i_rListener.setLastPage( sal_True ); - GDIMetaFile aPageFile; - Size aPageSize = i_rListener.getFilteredPageFile( 0, aPageFile ); + if( nAllPages > 0 ) + { + i_rListener.setLastPage( sal_True ); + GDIMetaFile aPageFile; + i_rListener.getFilteredPageFile( 0, aPageFile ); + } mnCurPageRangeStart = mnCurPageRangeCount = 0; From 5d5929a51dc6a0d53ac3838cc071b19cf3c7e193 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 14 May 2009 15:38:18 +0000 Subject: [PATCH 061/283] #i92516# do not access dead CGContextRef --- vcl/aqua/source/gdi/salprn.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 5dcac0a38027..e30ef8c3c942 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -605,6 +605,8 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, { i_rListener.setLastPage( sal_True ); GDIMetaFile aPageFile; + if( mrContext ) + SetupPrinterGraphics( mrContext ); i_rListener.getFilteredPageFile( 0, aPageFile ); } From 7b03cd38245b6b76cf1a8f8c8c0c21104b483acf Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 14 May 2009 16:18:28 +0000 Subject: [PATCH 062/283] #i92516# implement GetLandscapeAngle, InitPaperFormats --- vcl/aqua/source/gdi/salprn.cxx | 43 ++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index e30ef8c3c942..e4f16c332955 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -742,6 +742,42 @@ ULONG AquaSalPrinter::GetErrorCode() return mpInfoPrinter->GetErrorCode(); } +void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) +{ + m_aPaperFormats.clear(); + m_bPapersInit = true; + + if( mpPrinter ) + { + if( [mpPrinter statusForTable: @"PPD"] == NSPrinterTableOK ) + { + NSArray* pPaperNames = [mpPrinter stringListForKey: @"PageSize" inTable: @"PPD"]; + if( pPaperNames ) + { + unsigned int nPapers = [pPaperNames count]; + for( unsigned int i = 0; i < nPapers; i++ ) + { + NSString* pPaper = [pPaperNames objectAtIndex: i]; + NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper]; + if( aPaperSize.width > 0 && aPaperSize.height > 0 ) + { + vcl::PaperInfo aInfo; + aInfo.m_aPaperName = GetOUString( pPaper ); + aInfo.m_nPaperWidth = (PtTo10Mu( aPaperSize.width ) + 50 ) / 100; + aInfo.m_nPaperHeight = (PtTo10Mu( aPaperSize.height ) + 50 ) / 100; + m_aPaperFormats.push_back( aInfo ); + } + } + } + } + } +} + +int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) +{ + return 900; +} + //////////////////////////// ////// IMPLEMENT US ///// //////////////////////////// @@ -751,11 +787,4 @@ DuplexMode AquaSalInfoPrinter::GetDuplexMode( const ImplJobSetup* i_pSetupData ) return DUPLEX_UNKNOWN; } -void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) -{ -} -int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) -{ - return 0; -} From 6ca5ebc179d809750a43bf13e0acec3ff6e3f551 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 15 May 2009 15:16:28 +0000 Subject: [PATCH 063/283] #i92516# improved paper handling --- vcl/aqua/inc/salprn.h | 6 ++- vcl/aqua/source/gdi/salprn.cxx | 93 +++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index a2f4a6f80166..0ab4c02ab264 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -120,6 +120,10 @@ class AquaSalInfoPrinter : public SalInfoPrinter sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; } sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; } + // match width/height against known paper formats, possibly switching orientation + const vcl::PaperInfo* matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const; + void setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation ); + private: AquaSalInfoPrinter( const AquaSalInfoPrinter& ); AquaSalInfoPrinter& operator=(const AquaSalInfoPrinter&); @@ -162,7 +166,7 @@ const double fPtTo100thMM = 35.27777778; inline int PtTo10Mu( double nPoints ) { return (int)(((nPoints)*fPtTo100thMM)+0.5); } -inline double TenMuToPt( double nUnits ) { return (((nUnits)/fPtTo100thMM)+0.5); } +inline double TenMuToPt( double nUnits ) { return floor(((nUnits)/fPtTo100thMM)+0.5); } diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index e4f16c332955..b109f2c19dcd 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -69,7 +69,9 @@ AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) : mpPrintInfo( nil ), mePageOrientation( ORIENTATION_PORTRAIT ), mnStartPageOffsetX( 0 ), - mnStartPageOffsetY( 0 ) + mnStartPageOffsetY( 0 ), + mnCurPageRangeStart( 0 ), + mnCurPageRangeCount( 0 ) { NSString* pStr = CreateNSString( i_rQueue.maPrinterName ); mpPrinter = [NSPrinter printerWithName: pStr]; @@ -89,6 +91,7 @@ AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) : const int nWidth = 100, nHeight = 100; maContextMemory.reset( reinterpret_cast( rtl_allocateMemory( nWidth * 4 * nHeight ) ), boost::bind( rtl_freeMemory, _1 ) ); + if( maContextMemory ) { mrContext = CGBitmapContextCreate( maContextMemory.get(), nWidth, nHeight, 8, nWidth * 4, GetSalData()->mxRGBSpace, kCGImageAlphaNoneSkipFirst ); @@ -126,12 +129,9 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const long nDPIX = 720, nDPIY = 720; NSSize aPaperSize = [mpPrintInfo paperSize]; - NSRect aImageRect = [mpPrintInfo imageablePageBounds]; if( mePageOrientation == ORIENTATION_PORTRAIT ) { double dX = 0, dY = aPaperSize.height; - // dX += aImageRect.origin.x; - // dY -= aPaperSize.height - aImageRect.size.height - aImageRect.origin.y; CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY ); CGContextScaleCTM( i_rContext, 0.1, -0.1 ); } @@ -139,9 +139,6 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const { CGContextRotateCTM( i_rContext, M_PI/2 ); double dX = aPaperSize.height, dY = -aPaperSize.width; - // dY += aPaperSize.height - aImageRect.size.height - aImageRect.origin.y; - // dX -= aImageRect.origin.x; - CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX ); CGContextScaleCTM( i_rContext, -0.1, 0.1 ); } @@ -291,6 +288,28 @@ BOOL AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData ) // ----------------------------------------------------------------------- +void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation ) +{ + + Orientation ePaperOrientation = ORIENTATION_PORTRAIT; + const vcl::PaperInfo* pPaper = matchPaper( (i_nWidth+50)/100, (i_nHeight+50)/100, ePaperOrientation ); + + if( pPaper ) + { + NSString* pPaperName = [CreateNSString( pPaper->m_aPaperName ) autorelease]; + [mpPrintInfo setPaperName: pPaperName]; + } + else if( i_nWidth > 0 && i_nHeight > 0 ) + { + NSSize aPaperSize = { TenMuToPt(i_nWidth), TenMuToPt(i_nHeight) }; + [mpPrintInfo setPaperSize: aPaperSize]; + } + // this seems counterintuitive + mePageOrientation = i_eSetOrientation; +} + +// ----------------------------------------------------------------------- + BOOL AquaSalInfoPrinter::SetData( ULONG i_nFlags, ImplJobSetup* io_pSetupData ) { if( ! io_pSetupData || io_pSetupData->mnSystem != JOBSETUP_SYSTEM_MAC ) @@ -299,27 +318,28 @@ BOOL AquaSalInfoPrinter::SetData( ULONG i_nFlags, ImplJobSetup* io_pSetupData ) if( mpPrintInfo ) { + if( (i_nFlags & SAL_JOBSET_ORIENTATION) != 0 ) + mePageOrientation = io_pSetupData->meOrientation; + if( (i_nFlags & SAL_JOBSET_PAPERSIZE) != 0) { // set paper format - double width = 0, height = 0; + long width = 0, height = 0; if( io_pSetupData->mePaperFormat == PAPER_USER ) { - width = TenMuToPt( io_pSetupData->mnPaperWidth ); - height = TenMuToPt( io_pSetupData->mnPaperHeight ); + width = io_pSetupData->mnPaperWidth; + height = io_pSetupData->mnPaperHeight; } else - getPaperSize( width, height, io_pSetupData->mePaperFormat ); - - if( width > 0 && height > 0 ) { - NSSize aPaperSize = { width, height }; - [mpPrintInfo setPaperSize: aPaperSize]; + double w = 595, h = 842; + getPaperSize( w, h, io_pSetupData->mePaperFormat ); + width = static_cast(PtTo10Mu( w )); + height = static_cast(PtTo10Mu( h )); } - } - if( (i_nFlags & SAL_JOBSET_ORIENTATION) != 0 ) - mePageOrientation = io_pSetupData->meOrientation; + setPaperSize( width, height, mePageOrientation ); + } } return mpPrintInfo != nil; @@ -539,18 +559,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, // now for the current run mnStartPageOffsetX = mnStartPageOffsetY = 0; // setup the paper size and orientation - if( aCurSize.Width() > aCurSize.Height() ) - { - mePageOrientation = ORIENTATION_LANDSCAPE; - long nTmp = aCurSize.Width(); - aCurSize.Width() = aCurSize.Height(); - aCurSize.Height() = nTmp; - } - else - mePageOrientation = ORIENTATION_PORTRAIT; - - NSSize aPaperSize = { TenMuToPt(aCurSize.Width()), TenMuToPt(aCurSize.Height()) }; - [mpPrintInfo setPaperSize: aPaperSize]; + setPaperSize( aCurSize.Width(), aCurSize.Height(), ORIENTATION_PORTRAIT ); // create view NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this]; @@ -773,6 +782,30 @@ void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) } } +const vcl::PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const +{ + if( ! m_bPapersInit ) + const_cast(this)->InitPaperFormats( NULL ); + + const vcl::PaperInfo* pMatch = NULL; + o_rOrientation = ORIENTATION_PORTRAIT; + for( int n = 0; n < 2 ; n++ ) + { + for( size_t i = 0; i < m_aPaperFormats.size(); i++ ) + { + if( abs( m_aPaperFormats[i].m_nPaperWidth - i_nWidth ) < 2 && + abs( m_aPaperFormats[i].m_nPaperHeight - i_nHeight ) < 2 ) + { + pMatch = &m_aPaperFormats[i]; + return pMatch; + } + } + o_rOrientation = ORIENTATION_LANDSCAPE; + std::swap( i_nWidth, i_nHeight ); + } + return pMatch; +} + int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) { return 900; From cf5d2108b8709bb9973026f191ba9276ee3b5e15 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 21 May 2009 11:52:39 +0000 Subject: [PATCH 064/283] helper class for layouting child controls --- vcl/inc/vcl/arrange.hxx | 179 ++++++++++++++++++ vcl/source/window/arrange.cxx | 342 ++++++++++++++++++++++++++++++++++ vcl/source/window/makefile.mk | 1 + 3 files changed, 522 insertions(+) create mode 100644 vcl/inc/vcl/arrange.hxx create mode 100644 vcl/source/window/arrange.cxx diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx new file mode 100644 index 000000000000..03a388a519bd --- /dev/null +++ b/vcl/inc/vcl/arrange.hxx @@ -0,0 +1,179 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: accel.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_ARRANGE_HXX +#define _VCL_ARRANGE_HXX + +#include "vcl/window.hxx" + +#include + +namespace vcl +{ + /* some helper classes for simple window layouting + guidelines: + - a WindowArranger is not a Window + - a WindowArranger hierarchy manages exactly one level of child windows inside a common parent + this is to keep the vcl Window hierarchy flat, as some code like accelerators depend on such behavior + - a WindowArranger never becomes owner of a Window, windows need to be destroyed separately + - a WindowArranger however always is owner of its child WindowArrangers, that is the + WindowArranger hierarchy will keep track of its objects and delete them + - a managed element of a WindowArranger can either be a Window (a leaf in the hierarchy) + or a child WindowArranger (a node in the hierarchy), but never both + */ + + class WindowArranger + { + protected: + struct Element + { + Window* m_pElement; + WindowArranger* m_pChild; + + Element() + : m_pElement( NULL ) + , m_pChild( NULL ) + {} + + Element( Window* i_pWin, WindowArranger* i_pChild ) + : m_pElement( i_pWin ) + , m_pChild( i_pChild ) + {} + + void deleteChild() { delete m_pChild; m_pChild = NULL; } + }; + + Window* m_pParentWindow; + WindowArranger* m_pParentArranger; + Rectangle m_aManagedArea; + long m_nOuterBorder; + + public: + WindowArranger( WindowArranger* i_pParent = NULL ) + : m_pParentWindow( i_pParent ? i_pParent->m_pParentWindow : NULL ) + , m_pParentArranger( i_pParent ) + , m_nOuterBorder( 0 ) + {} + virtual ~WindowArranger(); + + // ask what would be the optimal size + virtual Size getOptimalSize( WindowSizeType ) const = 0; + // call Resize to trigger layouting inside the managed area + // without function while parent window is unset + virtual void resize() = 0; + // avoid this if possible, using the constructor instead + // there can be only one parent window and all managed windows MUST + // be direct children of that window + // violating that condition will result in undefined behavior + virtual void setParentWindow( Window* ) = 0; + virtual void setParent( WindowArranger* ); + + virtual size_t countElements() const = 0; + virtual WindowArranger* getChild( size_t i_nIndex ) const = 0; + virtual Window* getWindow( size_t i_nIndex ) const = 0; + + void setManagedArea( const Rectangle& i_rArea ) + { + m_aManagedArea = i_rArea; + resize(); + } + + void setOuterBorder( long i_nBorder ) + { + m_nOuterBorder = i_nBorder; + resize(); + } + }; + + class RowOrColumn : public WindowArranger + { + long m_nBorderWidth; + bool m_bColumn; + + std::vector< WindowArranger::Element > m_aElements; + + void distributeRowWidth( std::vector< Size >& io_rSizes, long i_nUsedWidth, long i_nExtraWidth ); + public: + RowOrColumn( WindowArranger* i_pParent = NULL, bool bColumn = true, long i_nBorderWidth = 5 ) + : WindowArranger( i_pParent ) + , m_nBorderWidth( i_nBorderWidth ) + , m_bColumn( bColumn ) + {} + + virtual ~RowOrColumn(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual void setParentWindow( Window* ); + virtual size_t countElements() const { return m_aElements.size(); } + virtual WindowArranger* getChild( size_t i_nIndex ) const; + virtual Window* getWindow( size_t i_nIndex ) const; + + // add a managed window at the given index + // an index smaller than zero means add the window at the end + void addWindow( Window*, sal_Int32 nIndex = -1 ); + void remove( Window* ); + + void addChild( WindowArranger*, sal_Int32 nIndex = -1 ); + void remove( WindowArranger* ); + }; + + class Indenter : public WindowArranger + { + long m_nIndent; + WindowArranger::Element m_aElement; + + public: + Indenter( WindowArranger* i_pParent = NULL, long i_nIndent = 15 ) + : WindowArranger( i_pParent ) + , m_nIndent( i_nIndent ) + {} + + virtual ~Indenter(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual void setParentWindow( Window* ); + virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } + virtual WindowArranger* getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild : NULL; } + virtual Window* getWindow( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pElement : NULL; } + + void setIndent( long i_nIndent ) + { + m_nIndent = i_nIndent; + resize(); + } + + void setWindow( Window* ); + void setChild( WindowArranger* ); + }; +} + +#endif \ No newline at end of file diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx new file mode 100644 index 000000000000..134e18f9935a --- /dev/null +++ b/vcl/source/window/arrange.cxx @@ -0,0 +1,342 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: accel.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vcl/arrange.hxx" + +#include "osl/diagnose.h" + +using namespace vcl; + +// ---------------------------------------- +// vcl::WindowArranger +//----------------------------------------- + +WindowArranger::~WindowArranger() +{} + +void WindowArranger::setParent( WindowArranger* i_pParent ) +{ + OSL_VERIFY( i_pParent->m_pParentWindow == m_pParentWindow || m_pParentWindow == NULL ); + + m_pParentArranger = i_pParent; + m_pParentWindow = i_pParent->m_pParentWindow; + setParentWindow( m_pParentWindow ); +} + +// ---------------------------------------- +// vcl::RowOrColumn +//----------------------------------------- + +RowOrColumn::~RowOrColumn() +{ + for( std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + it->deleteChild(); + } +} + +WindowArranger* RowOrColumn::getChild( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : NULL; +} + +Window* RowOrColumn::getWindow( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pElement : NULL; +} + +Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const +{ + Size aRet( 0, 0 ); + if( ! m_aElements.empty() ) + { + if( m_bColumn ) + aRet.Height() -= m_nBorderWidth; + else + aRet.Width() -= m_nBorderWidth; + } + + for( std::vector< WindowArranger::Element >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + // get the size of type of the managed element + Size aElementSize( it->m_pElement + ? it->m_pElement->GetOptimalSize( i_eType ) + : it->m_pChild + ? it->m_pChild->getOptimalSize( i_eType ) + : Size() ); + if( m_bColumn ) + { + // add the distance between elements + aRet.Height() += m_nBorderWidth; + // check if the width needs adjustment + if( aRet.Width() < aElementSize.Width() ) + aRet.Width() = aElementSize.Width(); + aRet.Height() += aElementSize.Height(); + } + else + { + // add the distance between elements + aRet.Width() += m_nBorderWidth; + // check if the height needs adjustment + if( aRet.Height() < aElementSize.Height() ) + aRet.Height() = aElementSize.Height(); + aRet.Width() += aElementSize.Width(); + } + } + + // add the outer border + aRet.Width() += 2*m_nOuterBorder; + aRet.Height() += 2*m_nOuterBorder; + + return aRet; +} + +void RowOrColumn::distributeRowWidth( std::vector& io_rSizes, long /*i_nUsedWidth*/, long i_nExtraWidth ) +{ + // distribute extra space evenly among elements + size_t nElements = io_rSizes.size(); + long nDelta = i_nExtraWidth / nElements; + for( size_t i = 0; i < nElements; i++ ) + { + io_rSizes[i].Width() += nDelta; + i_nExtraWidth -= nDelta; + } + // add the last pixels to the last row element + if( i_nExtraWidth > 0 && nElements > 0 ) + io_rSizes.back().Width() += i_nExtraWidth; +} + +void RowOrColumn::resize() +{ + // check if we can get optimal size, else fallback to minimal size + Size aOptSize( getOptimalSize( WINDOWSIZE_PREFERRED ) ); + WindowSizeType eType = WINDOWSIZE_PREFERRED; + if( m_bColumn ) + { + if( aOptSize.Height() > m_aManagedArea.GetHeight() ) + eType = WINDOWSIZE_MINIMUM; + } + else + { + if( aOptSize.Width() > m_aManagedArea.GetWidth() ) + eType = WINDOWSIZE_MINIMUM; + } + + size_t nElements = m_aElements.size(); + // get all element sizes for sizing + std::vector aElementSizes( nElements ); + long nUsedWidth = m_nOuterBorder - (nElements ? m_nBorderWidth : 0); + for( size_t i = 0; i < nElements; i++ ) + { + aElementSizes[i] = m_aElements[i].m_pElement + ? m_aElements[i].m_pElement->GetOptimalSize( eType ) + : m_aElements[i].m_pChild + ? m_aElements[i].m_pChild->getOptimalSize( eType ) + : Size(); + if( m_bColumn ) + { + aElementSizes[i].Width() = m_aManagedArea.GetWidth() - 2* m_nOuterBorder; + nUsedWidth += aElementSizes[i].Height() + m_nBorderWidth; + } + else + { + aElementSizes[i].Height() = m_aManagedArea.GetHeight() - 2* m_nOuterBorder; + nUsedWidth += aElementSizes[i].Width() + m_nBorderWidth; + } + } + + long nExtraWidth = m_aManagedArea.GetWidth() - nUsedWidth; + if( nExtraWidth > 0 ) + if( ! m_bColumn ) + distributeRowWidth( aElementSizes, nUsedWidth, nExtraWidth ); + + // get starting position + Point aElementPos( m_aManagedArea.TopLeft() ); + // outer border + aElementPos.X() += m_nOuterBorder; + aElementPos.Y() += m_nOuterBorder; + + // position managed windows + for( size_t i = 0; i < nElements; i++ ) + { + // get the size of type of the managed element + + if( m_aElements[i].m_pElement ) // this actually is a window + { + m_aElements[i].m_pElement->SetPosSizePixel( aElementPos, aElementSizes[i] ); + } + else if( m_aElements[i].m_pChild ) + { + m_aElements[i].m_pChild->setManagedArea( Rectangle( aElementPos, aElementSizes[i] ) ); + } + if( m_bColumn ) + aElementPos.Y() += m_nBorderWidth + aElementSizes[i].Height(); + else + aElementPos.X() += m_nBorderWidth + aElementSizes[i].Width(); + } +} + +void RowOrColumn::setParentWindow( Window* i_pNewParent ) +{ + m_pParentWindow = i_pNewParent; + for( std::vector< WindowArranger::Element >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + #if OSL_DEBUG_LEVEL > 0 + if( it->m_pElement ) + { + OSL_VERIFY( it->m_pElement->GetParent() == i_pNewParent ); + } + #endif + if( it->m_pChild ) + it->m_pChild->setParentWindow( i_pNewParent ); + } +} + +void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nIndex ) +{ + if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) + m_aElements.push_back( WindowArranger::Element( i_pWindow, NULL ) ); + else + { + std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); + while( i_nIndex-- ) + ++it; + m_aElements.insert( it, WindowArranger::Element( i_pWindow, NULL ) ); + } +} + +void RowOrColumn::addChild( WindowArranger* i_pChild, sal_Int32 i_nIndex ) +{ + if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) + m_aElements.push_back( WindowArranger::Element( NULL, i_pChild ) ); + else + { + std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); + while( i_nIndex-- ) + ++it; + m_aElements.insert( it, WindowArranger::Element( NULL, i_pChild ) ); + } +} + +void RowOrColumn::remove( Window* i_pWindow ) +{ + if( i_pWindow ) + { + for( std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + if( it->m_pElement == i_pWindow ) + { + m_aElements.erase( it ); + return; + } + } + } +} + +void RowOrColumn::remove( WindowArranger* i_pChild ) +{ + if( i_pChild ) + { + for( std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + if( it->m_pChild == i_pChild ) + { + m_aElements.erase( it ); + return; + } + } + } +} + +// ---------------------------------------- +// vcl::Indenter +//----------------------------------------- + +Indenter::~Indenter() +{ + m_aElement.deleteChild(); +} + +Size Indenter::getOptimalSize( WindowSizeType i_eType ) const +{ + Size aSize( m_aElement.m_pElement + ? m_aElement.m_pElement->GetOptimalSize( i_eType ) + : m_aElement.m_pChild + ? m_aElement.m_pChild->getOptimalSize( i_eType ) + : Size() ); + aSize.Width() += 2*m_nOuterBorder + m_nIndent; + aSize.Height() += 2*m_nOuterBorder; + return aSize; +} + +void Indenter::resize() +{ + Point aPt( m_aManagedArea.TopLeft() ); + aPt.X() += m_nOuterBorder + m_nIndent; + aPt.Y() += m_nOuterBorder; + Size aSz( m_aManagedArea.GetSize() ); + aSz.Width() -= 2*m_nOuterBorder - m_nIndent; + aSz.Height() -= 2*m_nOuterBorder; + if( m_aElement.m_pElement ) + m_aElement.m_pElement->SetPosSizePixel( aPt, aSz ); + else if( m_aElement.m_pChild ) + m_aElement.m_pChild->setManagedArea( Rectangle( aPt, aSz ) ); +} + +void Indenter::setWindow( Window* i_pWindow ) +{ + OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0) || i_pWindow == 0 ); + OSL_VERIFY( i_pWindow == 0 || i_pWindow->GetParent() == m_pParentWindow ); + m_aElement.m_pElement = i_pWindow; +} + +void Indenter::setChild( WindowArranger* i_pChild ) +{ + OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0) || i_pChild == 0 ); + m_aElement.m_pChild = i_pChild; +} + +void Indenter::setParentWindow( Window* i_pNewParent ) +{ + m_pParentWindow = i_pNewParent; + #if OSL_DEBUG_LEVEL > 0 + if( m_aElement.m_pElement ) + { + OSL_VERIFY( m_aElement.m_pElement->GetParent() == i_pNewParent ); + } + #endif + if( m_aElement.m_pChild ) + m_aElement.m_pChild->setParentWindow( i_pNewParent ); +} diff --git a/vcl/source/window/makefile.mk b/vcl/source/window/makefile.mk index cadea48f6f7a..4d1c3d60816b 100644 --- a/vcl/source/window/makefile.mk +++ b/vcl/source/window/makefile.mk @@ -45,6 +45,7 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- SLOFILES= \ + $(SLO)$/arrange.obj \ $(SLO)$/abstdlg.obj \ $(SLO)$/accel.obj \ $(SLO)$/accmgr.obj \ From e2dcfdf1706b4c636c74b90fd2442b18537af1e8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 22 May 2009 07:04:13 +0000 Subject: [PATCH 065/283] #i101309# need the page range controls app specific --- vcl/inc/vcl/print.hxx | 26 ++-- vcl/inc/vcl/prndlg.hxx | 11 +- vcl/source/gdi/print3.cxx | 109 ++++++++++------- vcl/source/src/print.src | 42 +------ vcl/source/window/printdlg.cxx | 212 ++++++++++++++++++++++----------- 5 files changed, 229 insertions(+), 171 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index c7575812f01d..98e08312e5ca 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -456,12 +456,6 @@ public: com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getJobProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& i_rMergeList ) const; - /* get the current selection string; either a UI editable string or "all" - a special value "selection" is supported signifying the current selected contents - of the printed document is to be printed. - */ - const rtl::OUString& getSelectionString() const; - /* get the PropertyValue of a Property */ com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); @@ -500,7 +494,6 @@ public: void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); void SAL_DLLPRIVATE createProgressDialog(); - void SAL_DLLPRIVATE setPrintSelection( const rtl::OUString& ); void SAL_DLLPRIVATE setMultipage( int nRows, int nColumns, const Size& rPaperSize ); void SAL_DLLPRIVATE setLastPage( sal_Bool i_bLastPage ); }; @@ -560,11 +553,11 @@ class VCL_DLLPUBLIC PrinterOptionsHelper static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpText, const rtl::OUString& i_rType, - const com::sun::star::beans::PropertyValue* i_pVal = NULL, - const com::sun::star::uno::Sequence< rtl::OUString >* i_pChoices = NULL, + const com::sun::star::beans::PropertyValue* i_pValue = NULL, const rtl::OUString* i_pDependsOnName = NULL, sal_Int32 i_nDependsOnEntry = -1, - sal_Int32 i_nMinValue = -1, sal_Int32 i_nMaxValue = -2 + const com::sun::star::beans::PropertyValue* i_pAddProps = NULL, + sal_Int32 i_nAddProps = 0 ); // create a group (e.g. a TabPage); following controls will be grouped in it until the next // group begins @@ -572,7 +565,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next // subgroup or group begins - static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ); + // setting bJobPage = true will make the subgroup appear on the first page of the print dialog + static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, bool i_bJobPage = false, bool i_bInternalOnly = false ); // create a bool option (usually a checkbox) static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, @@ -605,6 +599,16 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const rtl::OUString* i_pDependsOnName = NULL, sal_Int32 i_nDependsOnEntry = -1 ); + + // create a string field + // note: max value < min value means do not apply min/max values + static com::sun::star::uno::Any getEditControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, + const rtl::OUString& i_rProperty, + const rtl::OUString& i_rValue, + const rtl::OUString* i_pDependsOnName = NULL, + sal_Int32 i_nDependsOnEntry = -1 + ); }; } diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 24ea0ea6a3e3..408ec46b2aff 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -98,11 +98,6 @@ namespace vcl public: ListBox maPrinters; CheckBox maToFileBox; - FixedLine maPrintRange; - RadioButton maAllButton; - RadioButton maPagesButton; - RadioButton maSelectionButton; - Edit maPagesEdit; FixedLine maCopies; FixedText maCopyCount; @@ -123,7 +118,7 @@ namespace vcl CancelButton maCancelButton; PrintPreviewWindow maPreviewWindow; FixedText maPageText; - ScrollBar maPageScrollbar; + ScrollBar maPageSlider; TabControl maTabCtrl; PrinterTabPage maPrinterPage; @@ -159,8 +154,8 @@ namespace vcl virtual void Resize(); - DECL_LINK( ScrollHdl, ScrollBar* ); - DECL_LINK( ScrollEndHdl, ScrollBar* ); + DECL_LINK( SlideHdl, ScrollBar* ); + DECL_LINK( EndSlideHdl, ScrollBar* ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); DECL_LINK( ModifyHdl, Edit* ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 6c6d55a4a796..d16db4ef9aec 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -78,7 +78,6 @@ public: PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; - rtl::OUString maSelectionString; sal_Bool mbLastPage; int mnMultiPageRows; @@ -88,7 +87,6 @@ public: vcl::PrintProgressDialog* mpProgress; ImplPrinterListenerData() : - maSelectionString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ), mbLastPage( sal_False ), mnMultiPageRows( 1 ), mnMultiPageColumns( 1 ), @@ -382,11 +380,6 @@ void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) mpImplData->maMultiPageSize = aPaperSize; } -void PrinterListener::setPrintSelection( const rtl::OUString& i_rSel ) -{ - mpImplData->maSelectionString = i_rSel; -} - static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) { Size aPageSize = pPrinter->GetPaperSize(); @@ -654,14 +647,6 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro if( aMergeSet.find( mpImplData->maUIProperties[i].Name ) == aMergeSet.end() ) aResult[nCur++] = mpImplData->maUIProperties[i]; } - // append page selection - if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelection" ) ) ) == aMergeSet.end() ) - { - PropertyValue aVal; - aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelection" ) ); - aVal.Value <<= mpImplData->maSelectionString; - aResult[nCur++] = aVal; - } // append IsLastPage if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) ) == aMergeSet.end() ) { @@ -682,11 +667,6 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro return aResult; } -const rtl::OUString& PrinterListener::getSelectionString() const -{ - return mpImplData->maSelectionString; -} - const Sequence< beans::PropertyValue >& PrinterListener::getUIOptions() const { return mpImplData->maUIOptions; @@ -945,11 +925,10 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, const Sequence< rtl::OUString >& i_rHelpTexts, const rtl::OUString& i_rType, const PropertyValue* i_pVal, - const Sequence< rtl::OUString >* i_pChoices, const rtl::OUString* i_pDependsOnName, sal_Int32 i_nDependsOnEntry, - sal_Int32 i_nMinValue, - sal_Int32 i_nMaxValue + const PropertyValue* i_pAddProps, + sal_Int32 i_nAddProps ) { sal_Int32 nElements = @@ -957,9 +936,8 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + (i_rTitle.getLength() ? 1 : 0) // Text + (i_rHelpTexts.getLength() ? 1 : 0) // HelpText + (i_pVal ? 1 : 0) // Property - + (i_pChoices ? 1 : 0) // Choices + (i_pDependsOnName ? (i_nDependsOnEntry != -1 ? 2 : 1) : 0) // dependencies - + (i_nMaxValue >= i_nMinValue ? 2 : 0) // min/max + + i_nAddProps ; Sequence< PropertyValue > aCtrl( nElements ); @@ -981,11 +959,6 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); aCtrl[nUsed++].Value = makeAny( *i_pVal ); } - if( i_pChoices ) - { - aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pChoices ); - } if( i_pDependsOnName ) { aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); @@ -996,13 +969,8 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); } } - if( i_nMaxValue >= i_nMinValue ) - { - aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinValue" ) ); - aCtrl[nUsed++].Value = makeAny( i_nMinValue ); - aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxValue" ) ); - aCtrl[nUsed++].Value = makeAny( i_nMaxValue ); - } + for( sal_Int32 i = 0; i < i_nAddProps; i++ ) + aCtrl[ nUsed++ ] = i_pAddProps[i]; DBG_ASSERT( nUsed == nElements, "nUsed != nElements, probable heap corruption" ); @@ -1020,15 +988,29 @@ Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle, con return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); } -Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText ) +Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, + bool i_bJobPage, bool i_bInternalOnly ) { + PropertyValue aAddProps[2]; + sal_Int32 nUsed = 0; + if( i_bJobPage ) + { + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PutOnJobPage" ) ); + aAddProps[nUsed++].Value <<= sal_True; + } + if( i_bInternalOnly ) + { + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InternalUIOnly" ) ); + aAddProps[nUsed++].Value <<= sal_True; + } Sequence< rtl::OUString > aHelpText; if( i_rHelpText.getLength() > 0 ) { aHelpText.realloc( 1 ); *aHelpText.getArray() = i_rHelpText; } - return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ) ); + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ), + NULL, NULL, -1, aAddProps, nUsed ); } Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, @@ -1048,7 +1030,7 @@ Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, NULL, i_pDependsOnName, i_nDependsOnEntry ); + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, i_pDependsOnName, i_nDependsOnEntry ); } Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, @@ -1061,10 +1043,15 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nDependsOnEntry ) { + PropertyValue aAddProps[2]; + sal_Int32 nUsed = 0; + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); + aAddProps[nUsed++].Value = makeAny( i_rChoices ); + PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, &i_rChoices, i_pDependsOnName, i_nDependsOnEntry ); + return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, i_pDependsOnName, i_nDependsOnEntry, aAddProps, nUsed ); } Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, @@ -1077,6 +1064,16 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nDependsOnEntry ) { + PropertyValue aAddProps[2]; + sal_Int32 nUsed = 0; + if( i_nMaxValue >= i_nMinValue ) + { + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinValue" ) ); + aAddProps[nUsed++].Value = makeAny( i_nMinValue ); + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxValue" ) ); + aAddProps[nUsed++].Value = makeAny( i_nMaxValue ); + } + Sequence< rtl::OUString > aHelpText; if( i_rHelpText.getLength() > 0 ) { @@ -1090,9 +1087,33 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Range" ) ), &aVal, - NULL, i_pDependsOnName, i_nDependsOnEntry, - i_nMinValue, - i_nMaxValue ); + aAddProps, nUsed ); +} + +Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, + const rtl::OUString& i_rProperty, + const rtl::OUString& i_rValue, + const rtl::OUString* i_pDependsOnName, + sal_Int32 i_nDependsOnEntry + ) +{ + Sequence< rtl::OUString > aHelpText; + if( i_rHelpText.getLength() > 0 ) + { + aHelpText.realloc( 1 ); + *aHelpText.getArray() = i_rHelpText; + } + PropertyValue aVal; + aVal.Name = i_rProperty; + aVal.Value = makeAny( i_rValue ); + return getUIControlOpt( i_rTitle, + aHelpText, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Edit" ) ), + &aVal, + i_pDependsOnName, + i_nDependsOnEntry, + 0, 0 ); } diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 05fa6e1d9ccc..d6842560d1f8 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -219,53 +219,21 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print to file"; }; - FixedLine SV_PRINT_RANGE - { - Pos = MAP_APPFONT( 5, 35 ); - Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "Print range"; - }; - RadioButton SV_PRINT_ALL - { - Pos = MAP_APPFONT( 10, 45 ); - Size = MAP_APPFONT( 145, 15 ); - Text [en-US] = "All pages"; - Check = TRUE; - }; - RadioButton SV_PRINT_PAGERANGE - { - Pos = MAP_APPFONT( 10, 60 ); - Size = MAP_APPFONT( 60, 15 ); - Text [en-US] = "Pages"; - }; - Edit SV_PRINT_PAGERANGE_EDIT - { - Pos = MAP_APPFONT( 70, 60 ); - Size = MAP_APPFONT( 80, 12 ); - Border = TRUE; - }; - RadioButton SV_PRINT_SELECTION - { - Pos = MAP_APPFONT( 10, 75 ); - Size = MAP_APPFONT( 145, 15 ); - Text [en-US] = "Selection"; - }; - FixedLine SV_PRINT_COPIES { - Pos = MAP_APPFONT( 5, 95 ); + Pos = MAP_APPFONT( 5, 35 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Copies"; }; FixedText SV_PRINT_COPYCOUNT { - Pos = MAP_APPFONT( 10, 105 ); + Pos = MAP_APPFONT( 10, 45 ); Size = MAP_APPFONT( 80, 10 ); Text [en-US] = "Number of copies"; }; NumericField SV_PRINT_COPYCOUNT_FIELD { - Pos = MAP_APPFONT( 90, 105 ); + Pos = MAP_APPFONT( 90, 45 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -275,12 +243,12 @@ ModalDialog SV_DLG_PRINT }; FixedImage SV_PRINT_COLLATE_IMAGE { - Pos = MAP_APPFONT( 10, 125 ); + Pos = MAP_APPFONT( 10, 65 ); Size = MAP_PIXEL( 80, 30 ); }; CheckBox SV_PRINT_COLLATE { - Pos = MAP_APPFONT( 80, 125 ); + Pos = MAP_APPFONT( 80, 65 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index d386b7ad43b2..9092d3abac83 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -144,11 +144,6 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) - , maPrintRange( this, VclResId( SV_PRINT_RANGE ) ) - , maAllButton( this, VclResId( SV_PRINT_ALL ) ) - , maPagesButton( this, VclResId( SV_PRINT_PAGERANGE ) ) - , maSelectionButton( this, VclResId( SV_PRINT_SELECTION ) ) - , maPagesEdit( this, VclResId( SV_PRINT_PAGERANGE_EDIT ) ) , maCopies( this, VclResId( SV_PRINT_COPIES ) ) , maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) ) , maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) ) @@ -162,11 +157,6 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) FreeResource(); maPrinters.SMHID2( "JobPage", "PrinterList" ); maToFileBox.SMHID2( "JobPage", "ToFile" ); - maPrintRange.SMHID2( "JobPage", "PrintRange" ); - maAllButton.SMHID2( "JobPage", "AllButton" ); - maPagesButton.SMHID2( "JobPage", "PagesButton" ); - maSelectionButton.SMHID2( "JobPage", "SelectionButton" ); - maPagesEdit.SMHID2( "JobPage", "Pages" ); maCopies.SMHID2( "JobPage", "CopiesLine" ); maCopyCount.SMHID2( "JobPage", "CopiesText" ); maCopyCountField.SMHID2( "JobPage", "Copies" ); @@ -184,7 +174,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& rQueues( Printer::GetPrinterQueues() ); @@ -241,16 +231,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr 1 ) - { - aBuf.append( sal_Unicode('-') ); - aBuf.append( mnCachedPages ); - } - maJobPage.maPagesEdit.SetText( aBuf.makeStringAndClear() ); - // setup sizes for N-Up Size aNupSize( maPListener->getPrinter()->PixelToLogic( maPListener->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); @@ -269,16 +249,12 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_r i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); } +// FIXME: this is evil hackery and witchcraft +// the automatic controls should be replaced by some kind of row/column widget void PrintDialog::setupOptionalUI() { - Window* pCurParent = 0; - long nCurY = 0, nXPos = 5, nMaxY = 0; - USHORT nOptPageId = 9, nCurSubGroup = 0; + Window* pCurParent = 0, *pDynamicPageParent = 0; + long nCurY = 0, nXPos = 5, nMaxY = 0, nJobPageCurY = 0, nDynamicPageCurY = 0; + USHORT nOptPageId = 9, nCurSubGroup = 0, nJobGroups = 0; MapMode aFontMapMode( MAP_APPFONT ); + bool bOnJobPage = false; + + nJobPageCurY = maJobPage.PixelToLogic( maJobPage.maCollateImage.GetPosPixel(), aFontMapMode ).Y(); + nJobPageCurY += maJobPage.PixelToLogic( maJobPage.maCollateImage.GetSizePixel(), aFontMapMode ).Height(); + nJobPageCurY += 5; Size aTabSize = maTabCtrl.GetTabPageSizePixel(); const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); @@ -379,6 +362,7 @@ void PrintDialog::setupOptionalUI() sal_Int64 nMinValue = 0, nMaxValue = 0; long nDependencyIndent = 0; sal_Int32 nCurHelpText = 0; + sal_Bool bOnJobPageValue = sal_False; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -407,6 +391,10 @@ void PrintDialog::setupOptionalUI() rEntry.Value >>= bValue; bEnabled = bValue; } + else if( rEntry.Name.equalsAscii( "PutOnJobPage" ) ) + { + rEntry.Value >>= bOnJobPageValue; + } else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) { rtl::OUString aDepName; @@ -459,6 +447,7 @@ void PrintDialog::setupOptionalUI() aCtrlType.equalsAscii( "Radio" ) || aCtrlType.equalsAscii( "List" ) || aCtrlType.equalsAscii( "Range" ) || + aCtrlType.equalsAscii( "Edit" ) || aCtrlType.equalsAscii( "Bool" ) ) { if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) @@ -488,12 +477,36 @@ void PrintDialog::setupOptionalUI() if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) { nXPos = 5; + // change to job page or back if necessary + if( (bOnJobPage && ! bOnJobPageValue) || + (! bOnJobPage && bOnJobPageValue) ) + { + if( nCurY > nMaxY ) // keep track of maximum Y + nMaxY = nCurY; + bOnJobPage = bOnJobPageValue; + if( bOnJobPage ) + { + nDynamicPageCurY = nCurY; // save nCurY + pDynamicPageParent = pCurParent; // save current parent + pCurParent = &maJobPage; // set job page as current parent + } + else + { + nCurY = nDynamicPageCurY; // set dynamic CurY + pCurParent = pDynamicPageParent; // set current tab page as parent + } + } + if( bOnJobPage ) + { + nXPos += 100 * nJobGroups++; + nCurY = nJobPageCurY; + } FixedLine* pNewSub = new FixedLine( pCurParent ); maControls.push_front( pNewSub ); pNewSub->SetText( aText ); nCurY += 4; Size aPixelSize( aTabSize ); - aPixelSize.Width() /= 2; + aPixelSize.Width() /= 3; aPixelSize.Height() = pCurParent->GetTextHeight() + 4; pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), aPixelSize ); @@ -545,7 +558,10 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pHeading ); pHeading->SetText( aText ); Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + if( bOnJobPage ) + aPixelSize.Width() = maJobPage.LogicToPixel( Size( 90, 10 ), aFontMapMode ).Width(); + else + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), aPixelSize ); pHeading->Show(); @@ -571,8 +587,11 @@ void PrintDialog::setupOptionalUI() pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos + nDependencyIndent, 12 ), aFontMapMode ) ); - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); - pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( 15, nCurY ), aFontMapMode ), + if( bOnJobPage ) + aPixelSize.Width() = maJobPage.LogicToPixel( Size( 80, 10 ), aFontMapMode ).Width(); + else + aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); + pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), aPixelSize ); pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); @@ -588,6 +607,7 @@ void PrintDialog::setupOptionalUI() nCurY += 12; } + nCurY += 2; nXPos = nOldXPos; } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) @@ -728,6 +748,76 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pField] = aPropertyName; nCurY += 16; + if( bDoAlign ) + { + Point aPos = pHeading->GetPosPixel(); + Size aSize = pHeading->GetSizePixel(); + aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2; + pHeading->SetPosSizePixel( aPos, aSize ); + } + } + else if( aCtrlType.equalsAscii( "Edit" ) && pCurParent ) + { + FixedText* pHeading = NULL; + Size aPixelSize; + if( aText.getLength() ) + { + // add a FixedText: + pHeading = new FixedText( pCurParent ); + maControls.push_front( pHeading ); + pHeading->SetText( aText ); + aPixelSize = pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ); + aPixelSize.Width() += pHeading->GetTextWidth( aText ); + pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), + aPixelSize ); + pHeading->Show(); + + // set help id + setSmartId( pHeading, "FixedText", -1, aPropertyName ); + } + + Edit* pField = new Edit( pCurParent, WB_BORDER ); + maControls.push_front( pField ); + + rtl::OUString aCurVal; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= aCurVal; + pField->SetText( aCurVal ); + + aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) ); + + Point aFieldPos; + bool bDoAlign = false; + if( pHeading && aPixelSize.Width() < aTabSize.Width() - 10 ) + { + aFieldPos = pHeading->GetPosPixel(); + aFieldPos.X() += pHeading->GetSizePixel().Width() + 5; + + // align heading and list box + bDoAlign = true; + } + else + { + if( pHeading ) + nCurY += 12; + aFieldPos = pCurParent->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ); + } + + pField->SetPosSizePixel( aFieldPos, aPixelSize ); + pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); + pField->Show(); + + // set help id + setSmartId( pField, "Edit", -1, aPropertyName ); + // set help text + setHelpText( pField, aHelpTexts, 0 ); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maControlToPropertyMap[pField] = aPropertyName; + nCurY += 16; + if( bDoAlign ) { Point aPos = pHeading->GetPosPixel(); @@ -763,7 +853,6 @@ void PrintDialog::checkControlDependencies() else maJobPage.maCollateBox.Enable( FALSE ); - maJobPage.maPagesEdit.Enable( maJobPage.maPagesButton.IsChecked() ); Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg ); if( GetSettings().GetStyleSettings().GetFieldColor().IsDark() ) aImg = maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg; @@ -846,9 +935,9 @@ void PrintDialog::preparePreview( bool i_bNewPage ) setPreviewText( mnCurPage ); - maPageScrollbar.SetRange( Range( 0, nPages ) ); - maPageScrollbar.SetThumbPos( mnCurPage ); - maPageScrollbar.SetVisibleSize( 1 ); + maPageSlider.SetRange( Range( 0, nPages-1 ) ); + maPageSlider.SetThumbPos( mnCurPage ); + maPageSlider.SetVisibleSize( 1 ); boost::shared_ptr aPrt( maPListener->getPrinter() ); @@ -899,21 +988,21 @@ void PrintDialog::updateNup() preparePreview(); } -IMPL_LINK( PrintDialog, ScrollHdl, ScrollBar*, pScrBar ) +IMPL_LINK( PrintDialog, SlideHdl, ScrollBar*, pSlider ) { - if( pScrBar == &maPageScrollbar ) + if( pSlider == &maPageSlider ) { - sal_Int32 nNewPage = static_cast( maPageScrollbar.GetThumbPos() ); + sal_Int32 nNewPage = static_cast( maPageSlider.GetThumbPos() ); setPreviewText( nNewPage ); } return 0; } -IMPL_LINK( PrintDialog, ScrollEndHdl, ScrollBar*, pScrBar ) +IMPL_LINK( PrintDialog, EndSlideHdl, ScrollBar*, pSlider ) { - if( pScrBar == &maPageScrollbar ) + if( pSlider == &maPageSlider ) { - sal_Int32 nNewPage = static_cast( maPageScrollbar.GetThumbPos() ); + sal_Int32 nNewPage = static_cast( maPageSlider.GetThumbPos() ); if( nNewPage != mnCurPage ) { mnCurPage = nNewPage; @@ -945,20 +1034,6 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maPListener->getPrinter()->Setup( this ); } checkControlDependencies(); - if( ( pButton == &maJobPage.maAllButton || - pButton == &maJobPage.maPagesButton || - pButton == &maJobPage.maSelectionButton ) - && ((RadioButton*)pButton)->IsChecked() ) - { - if( pButton == &maJobPage.maAllButton ) - maPListener->setPrintSelection( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "all" ) ) ); - else if( pButton == &maJobPage.maPagesButton ) - maPListener->setPrintSelection( maJobPage.maPagesEdit.GetText() ); - else - maPListener->setPrintSelection( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "selection" ) ) ); - - preparePreview(); - } if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape ) updateNup(); return 0; @@ -967,12 +1042,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { checkControlDependencies(); - if( pEdit == &maJobPage.maPagesEdit && maJobPage.maPagesButton.IsChecked() ) - { - maPListener->setPrintSelection( maJobPage.maPagesEdit.GetText() ); - preparePreview(); - } - else if( pEdit == &maPrinterPage.maNupRowsEdt || pEdit == &maPrinterPage.maNupColEdt ) + if( pEdit == &maPrinterPage.maNupRowsEdt || pEdit == &maPrinterPage.maNupColEdt ) { updateNup(); } @@ -1123,15 +1193,15 @@ void PrintDialog::Resize() long nMaxY = maButtonLine.GetPosPixel().Y() - 2 * aPixDiff.Height() - maPageText.GetSizePixel().Height() - - maPageScrollbar.GetSizePixel().Height(); + - maPageSlider.GetSizePixel().Height(); long nPreviewLength = std::min( nMaxX, nMaxY ); maPreviewSpace = Rectangle( Point( aPixDiff.Width(), aPixDiff.Height() ), Size( nPreviewLength, nPreviewLength ) ); - // position text and scrollbar below preview + // position text and slider below preview aBtnRect = Rectangle( Point( aPixDiff.Width(), 2*aPixDiff.Height() + nPreviewLength ), - Size( nPreviewLength, maPageScrollbar.GetSizePixel().Height() ) ); - maPageScrollbar.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); + Size( nPreviewLength, maPageSlider.GetSizePixel().Height() ) ); + maPageSlider.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); aBtnRect.Top() = aBtnRect.Bottom() + aPixDiff.Height()/2; aBtnRect.Bottom() = aBtnRect.Top() + maPageText.GetSizePixel().Height() - 1; From 60e54d904b1c3bd46ee9bdbe0b72756ae6cc231a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 22 May 2009 10:06:06 +0000 Subject: [PATCH 066/283] use autoarranging --- vcl/source/window/arrange.cxx | 23 +-- vcl/source/window/printdlg.cxx | 292 +++++++++++++-------------------- 2 files changed, 130 insertions(+), 185 deletions(-) diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 134e18f9935a..d52b5e813f74 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -122,17 +122,20 @@ Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const void RowOrColumn::distributeRowWidth( std::vector& io_rSizes, long /*i_nUsedWidth*/, long i_nExtraWidth ) { - // distribute extra space evenly among elements - size_t nElements = io_rSizes.size(); - long nDelta = i_nExtraWidth / nElements; - for( size_t i = 0; i < nElements; i++ ) + if( ! io_rSizes.empty() ) { - io_rSizes[i].Width() += nDelta; - i_nExtraWidth -= nDelta; + // distribute extra space evenly among elements + size_t nElements = io_rSizes.size(); + long nDelta = i_nExtraWidth / nElements; + for( size_t i = 0; i < nElements; i++ ) + { + io_rSizes[i].Width() += nDelta; + i_nExtraWidth -= nDelta; + } + // add the last pixels to the last row element + if( i_nExtraWidth > 0 && nElements > 0 ) + io_rSizes.back().Width() += i_nExtraWidth; } - // add the last pixels to the last row element - if( i_nExtraWidth > 0 && nElements > 0 ) - io_rSizes.back().Width() += i_nExtraWidth; } void RowOrColumn::resize() @@ -154,7 +157,7 @@ void RowOrColumn::resize() size_t nElements = m_aElements.size(); // get all element sizes for sizing std::vector aElementSizes( nElements ); - long nUsedWidth = m_nOuterBorder - (nElements ? m_nBorderWidth : 0); + long nUsedWidth = 2*m_nOuterBorder - (nElements ? m_nBorderWidth : 0); for( size_t i = 0; i < nElements; i++ ) { aElementSizes[i] = m_aElements[i].m_pElement diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9092d3abac83..9a5b20c0496f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -40,6 +40,7 @@ #include "vcl/jobset.h" #include "vcl/status.hxx" #include "vcl/decoview.hxx" +#include "vcl/arrange.hxx" #include "rtl/ustrbuf.hxx" @@ -331,21 +332,21 @@ static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_r i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); } -// FIXME: this is evil hackery and witchcraft -// the automatic controls should be replaced by some kind of row/column widget void PrintDialog::setupOptionalUI() { + const long nBorderWidth = maJobPage.maCopies.GetPosPixel().X(); + + vcl::RowOrColumn aPrintRangeRow( NULL, false, nBorderWidth ); + std::vector aDynamicColumns; + vcl::RowOrColumn* pCurColumn = 0; + + aPrintRangeRow.setParentWindow( &maJobPage ); + aPrintRangeRow.setOuterBorder( nBorderWidth ); + Window* pCurParent = 0, *pDynamicPageParent = 0; - long nCurY = 0, nXPos = 5, nMaxY = 0, nJobPageCurY = 0, nDynamicPageCurY = 0; - USHORT nOptPageId = 9, nCurSubGroup = 0, nJobGroups = 0; - MapMode aFontMapMode( MAP_APPFONT ); + USHORT nOptPageId = 9, nCurSubGroup = 0; bool bOnJobPage = false; - nJobPageCurY = maJobPage.PixelToLogic( maJobPage.maCollateImage.GetPosPixel(), aFontMapMode ).Y(); - nJobPageCurY += maJobPage.PixelToLogic( maJobPage.maCollateImage.GetSizePixel(), aFontMapMode ).Height(); - nJobPageCurY += 5; - - Size aTabSize = maTabCtrl.GetTabPageSizePixel(); const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -360,7 +361,6 @@ void PrintDialog::setupOptionalUI() Sequence< rtl::OUString > aChoices; Sequence< rtl::OUString > aHelpTexts; sal_Int64 nMinValue = 0, nMaxValue = 0; - long nDependencyIndent = 0; sal_Int32 nCurHelpText = 0; sal_Bool bOnJobPageValue = sal_False; @@ -407,16 +407,14 @@ void PrintDialog::setupOptionalUI() if( pWin->GetParent() == pCurParent ) { // is it a labeled window ? - if( dynamic_cast< ListBox* >(pWin) || - dynamic_cast< NumericField* >(pWin) ) + if( dynamic_cast< ListBox* >(pWin) || + dynamic_cast< Edit* >(pWin) + ) { Window* pLabelWin = pWin->GetLabeledBy(); if( dynamic_cast(pLabelWin) ) // sanity check pWin = pLabelWin; } - long nDependencyXPos = PixelToLogic( pWin->GetPosPixel(), aFontMapMode ).X(); - if( (nDependencyXPos + 5) > nXPos ) - nDependencyIndent = nDependencyXPos + 5 - nXPos; } } } @@ -452,15 +450,10 @@ void PrintDialog::setupOptionalUI() { if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) { - if( nCurY > nMaxY ) - nMaxY = nCurY; - // add new tab page TabPage* pNewGroup = new TabPage( &maTabCtrl ); maControls.push_front( pNewGroup ); pCurParent = pNewGroup; - nCurY = 5; - nXPos = 5; pNewGroup->SetText( aText ); maTabCtrl.InsertPage( ++nOptPageId, aText ); maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); @@ -472,52 +465,54 @@ void PrintDialog::setupOptionalUI() // reset subgroup counter nCurSubGroup = 0; + + aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, nBorderWidth ) ); + pCurColumn = aDynamicColumns.back(); + pCurColumn->setParentWindow( pNewGroup ); + pCurColumn->setOuterBorder( nBorderWidth ); } if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) { - nXPos = 5; // change to job page or back if necessary if( (bOnJobPage && ! bOnJobPageValue) || (! bOnJobPage && bOnJobPageValue) ) { - if( nCurY > nMaxY ) // keep track of maximum Y - nMaxY = nCurY; bOnJobPage = bOnJobPageValue; if( bOnJobPage ) { - nDynamicPageCurY = nCurY; // save nCurY pDynamicPageParent = pCurParent; // save current parent pCurParent = &maJobPage; // set job page as current parent } else { - nCurY = nDynamicPageCurY; // set dynamic CurY pCurParent = pDynamicPageParent; // set current tab page as parent } } + if( bOnJobPage ) { - nXPos += 100 * nJobGroups++; - nCurY = nJobPageCurY; + // create a new column in the PrintRange row + vcl::RowOrColumn* pNewColumn = new vcl::RowOrColumn( &aPrintRangeRow, true, nBorderWidth ); + aPrintRangeRow.addChild( pNewColumn ); + pCurColumn = pNewColumn; } + else + pCurColumn = aDynamicColumns.back(); + + // create group FixedLine FixedLine* pNewSub = new FixedLine( pCurParent ); maControls.push_front( pNewSub ); pNewSub->SetText( aText ); - nCurY += 4; - Size aPixelSize( aTabSize ); - aPixelSize.Width() /= 3; - aPixelSize.Height() = pCurParent->GetTextHeight() + 4; - pNewSub->SetPosSizePixel( pNewSub->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), - aPixelSize ); pNewSub->Show(); - nCurY += 12; - nXPos += 5; // set help id setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); // set help text setHelpText( pNewSub, aHelpTexts, 0 ); + + // add group to current column + pCurColumn->addWindow( pNewSub ); } else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { @@ -525,13 +520,8 @@ void PrintDialog::setupOptionalUI() CheckBox* pNewBox = new CheckBox( pCurParent ); maControls.push_front( pNewBox ); pNewBox->SetText( aText ); - - // FIXME: measure text - pNewBox->SetPosSizePixel( pNewBox->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), - pNewBox->LogicToPixel( Size( 100, 10 ), aFontMapMode ) ); - nCurY += 12; - pNewBox->Show(); + sal_Bool bVal = sal_False; PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal ) @@ -547,34 +537,34 @@ void PrintDialog::setupOptionalUI() setSmartId( pNewBox, "CheckBox", -1, aPropertyName ); // set help text setHelpText( pNewBox, aHelpTexts, 0 ); + + // add checkbox to current column + pCurColumn->addWindow( pNewBox ); } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { - long nOldXPos = nXPos; + vcl::RowOrColumn* pRadioColumn = pCurColumn; if( aText.getLength() ) { // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); - Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); - if( bOnJobPage ) - aPixelSize.Width() = maJobPage.LogicToPixel( Size( 90, 10 ), aFontMapMode ).Width(); - else - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), - aPixelSize ); pHeading->Show(); - nXPos += 10; - nCurY += 12; - // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); // set help text setHelpText( pHeading, aHelpTexts, nCurHelpText++ ); + // add fixed text to current column + pCurColumn->addWindow( pHeading ); + // add an indent to the current column + vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, 15 ); + pCurColumn->addChild( pIndent ); + // and create a column inside the indent + pRadioColumn = new vcl::RowOrColumn( pIndent ); + pIndent->setChild( pRadioColumn ); } - // iterate options sal_Int32 nSelectVal = 0; PropertyValue* pVal = maPListener->getValue( aPropertyName ); @@ -586,13 +576,6 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); - Size aPixelSize( pBtn->LogicToPixel( Size( 10 + nXPos + nDependencyIndent, 12 ), aFontMapMode ) ); - if( bOnJobPage ) - aPixelSize.Width() = maJobPage.LogicToPixel( Size( 80, 10 ), aFontMapMode ).Width(); - else - aPixelSize.Width() = aTabSize.Width() - aPixelSize.Width(); - pBtn->SetPosSizePixel( pBtn->LogicToPixel( Point( nXPos, nCurY ), aFontMapMode ), - aPixelSize ); pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); pBtn->Show(); @@ -604,67 +587,41 @@ void PrintDialog::setupOptionalUI() setSmartId( pBtn, "RadioButton", m, aPropertyName ); // set help text setHelpText( pBtn, aHelpTexts, nCurHelpText++ ); - - nCurY += 12; + // add the radio button to the column + pRadioColumn->addWindow( pBtn ); } - nCurY += 2; - nXPos = nOldXPos; } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) { + // create a row in the current column + vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pPair ); + // add a FixedText: - FixedText* pHeading = new FixedText( pCurParent ); + FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER ); maControls.push_front( pHeading ); pHeading->SetText( aText ); - Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); - aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), - aPixelSize ); pHeading->Show(); // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); + // add to pair + pPair->addWindow( pHeading ); + ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); maControls.push_front( pList ); // iterate options - long nMaxTextWidth = 0; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { pList->InsertEntry( aChoices[m] ); - long nEntryWidth = pList->GetTextWidth( aChoices[m] ); - if( nEntryWidth > nMaxTextWidth ) - nMaxTextWidth = nEntryWidth; } - nMaxTextWidth += 50; sal_Int32 nSelectVal = 0; PropertyValue* pVal = maPListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; pList->SelectEntryPos( static_cast(nSelectVal) ); - - aPixelSize = Size( pList->LogicToPixel( Size( 25, 12 ), aFontMapMode ) ); - aPixelSize.Width() = nMaxTextWidth; - aPixelSize.Height() *= aChoices.getLength() > 15 ? 15 : aChoices.getLength(); - - Point aListPos; - bool bDoAlign = false; - if( nMaxTextWidth + aPixelSize.Width() < aTabSize.Width() - 10 ) - { - aListPos = pHeading->GetPosPixel(); - aListPos.X() += pHeading->GetSizePixel().Width() + 5; - - // align heading and list box - bDoAlign = true; - } - else - { - nCurY += 12; - aListPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode ); - } - - pList->SetPosSizePixel( aListPos, aPixelSize ); pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); pList->Show(); @@ -676,31 +633,28 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); maControlToPropertyMap[pList] = aPropertyName; - nCurY += 16; - if( bDoAlign ) - { - Point aPos = pHeading->GetPosPixel(); - Size aSize = pHeading->GetSizePixel(); - aPos.Y() += (pList->GetSizePixel().Height() - aSize.Height())/2; - pHeading->SetPosSizePixel( aPos, aSize ); - } + // finish the pair + pPair->addWindow( pList ); } else if( aCtrlType.equalsAscii( "Range" ) && pCurParent ) { + // create a row in the current column + vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pPair ); + // add a FixedText: FixedText* pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); - Size aPixelSize( pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ) ); - aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), - aPixelSize ); pHeading->Show(); // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); + // add to pair + pPair->addWindow( pHeading ); + NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); maControls.push_front( pField ); @@ -716,25 +670,6 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= nCurVal; pField->SetValue( nCurVal ); - aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) ); - - Point aFieldPos; - bool bDoAlign = false; - if( aPixelSize.Width() < aTabSize.Width() - 10 ) - { - aFieldPos = pHeading->GetPosPixel(); - aFieldPos.X() += pHeading->GetSizePixel().Width() + 5; - - // align heading and list box - bDoAlign = true; - } - else - { - nCurY += 12; - aFieldPos = pCurParent->LogicToPixel( Point( 15 + nDependencyIndent, nCurY ), aFontMapMode ); - } - - pField->SetPosSizePixel( aFieldPos, aPixelSize ); pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -746,34 +681,30 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); maControlToPropertyMap[pField] = aPropertyName; - nCurY += 16; - if( bDoAlign ) - { - Point aPos = pHeading->GetPosPixel(); - Size aSize = pHeading->GetSizePixel(); - aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2; - pHeading->SetPosSizePixel( aPos, aSize ); - } + // add to pair + pPair->addWindow( pField ); } else if( aCtrlType.equalsAscii( "Edit" ) && pCurParent ) { + vcl::RowOrColumn* pEditColumn = pCurColumn; FixedText* pHeading = NULL; - Size aPixelSize; if( aText.getLength() ) { + // create a row in the current column + vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pPair ); + pEditColumn = pPair; + // add a FixedText: pHeading = new FixedText( pCurParent ); maControls.push_front( pHeading ); pHeading->SetText( aText ); - aPixelSize = pHeading->LogicToPixel( Size( 10, 10 ), aFontMapMode ); - aPixelSize.Width() += pHeading->GetTextWidth( aText ); - pHeading->SetPosSizePixel( pHeading->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ), - aPixelSize ); pHeading->Show(); // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); + pPair->addWindow( pHeading ); } Edit* pField = new Edit( pCurParent, WB_BORDER ); @@ -784,27 +715,6 @@ void PrintDialog::setupOptionalUI() if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aCurVal; pField->SetText( aCurVal ); - - aPixelSize = Size( pField->LogicToPixel( Size( 80, 12 ), aFontMapMode ) ); - - Point aFieldPos; - bool bDoAlign = false; - if( pHeading && aPixelSize.Width() < aTabSize.Width() - 10 ) - { - aFieldPos = pHeading->GetPosPixel(); - aFieldPos.X() += pHeading->GetSizePixel().Width() + 5; - - // align heading and list box - bDoAlign = true; - } - else - { - if( pHeading ) - nCurY += 12; - aFieldPos = pCurParent->LogicToPixel( Point( nXPos + nDependencyIndent, nCurY ), aFontMapMode ); - } - - pField->SetPosSizePixel( aFieldPos, aPixelSize ); pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -816,15 +726,8 @@ void PrintDialog::setupOptionalUI() maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); maControlToPropertyMap[pField] = aPropertyName; - nCurY += 16; - if( bDoAlign ) - { - Point aPos = pHeading->GetPosPixel(); - Size aSize = pHeading->GetSizePixel(); - aPos.Y() += (pField->GetSizePixel().Height() - aSize.Height())/2; - pHeading->SetPosSizePixel( aPos, aSize ); - } + pEditColumn->addWindow( pField ); } } else @@ -833,17 +736,56 @@ void PrintDialog::setupOptionalUI() } } - if( nCurY > nMaxY ) - nMaxY = nCurY; + // calculate job page + long nJobPageCurY = maJobPage.maCollateImage.GetPosPixel().Y(); + nJobPageCurY += maJobPage.maCollateImage.GetSizePixel().Height(); + + Size aMaxSize = aPrintRangeRow.getOptimalSize( WINDOWSIZE_PREFERRED ); + aMaxSize.Height() += nJobPageCurY; + + Size aMaxPageSize; + for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); + it != aDynamicColumns.end(); ++it ) + { + Size aPageSize( (*it)->getOptimalSize( WINDOWSIZE_PREFERRED ) ); + if( aPageSize.Width() > aMaxPageSize.Width() ) + aMaxPageSize.Width() = aPageSize.Width(); + if( aPageSize.Height() > aMaxPageSize.Height() ) + aMaxPageSize.Height() = aPageSize.Height(); + } + if( aMaxPageSize.Width() > aMaxSize.Width() ) + aMaxSize.Width() = aMaxPageSize.Width(); + if( aMaxPageSize.Height() > aMaxSize.Height() ) + aMaxSize.Height() = aMaxPageSize.Height(); // resize dialog if necessary - Size aMaxSize( LogicToPixel( Size( nMaxY, nMaxY ), aFontMapMode ) ); - if( aMaxSize.Height() > aTabSize.Height() ) + Size aTabSize = maTabCtrl.GetTabPageSizePixel(); + if( aMaxSize.Height() > aTabSize.Height() || aMaxSize.Width() > aTabSize.Width() ) { Size aCurSize( GetSizePixel() ); - aCurSize.Height() += aMaxSize.Height() - aTabSize.Height(); + if( aMaxSize.Height() > aTabSize.Height() ) + aCurSize.Height() += aMaxSize.Height() - aTabSize.Height(); + if( aMaxSize.Width() > aTabSize.Width() ) + { + aCurSize.Width() += aMaxSize.Width() - aTabSize.Width(); + // and the tab ctrl needs more space, too + aTabSize.Width() = aMaxSize.Width(); + maTabCtrl.SetSizePixel( aTabSize ); + } SetSizePixel( aCurSize ); } + + // and finally arrange controls + aTabSize = maTabCtrl.GetTabPageSizePixel(); + aPrintRangeRow.setManagedArea( Rectangle( Point( 0, nJobPageCurY ), + Size( aTabSize.Width(), aTabSize.Height() - nJobPageCurY ) ) ); + for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); + it != aDynamicColumns.end(); ++it ) + { + (*it)->setManagedArea( Rectangle( Point(), aMaxPageSize ) ); + delete *it; + *it = NULL; + } } void PrintDialog::checkControlDependencies() From 0b93cf4d4dd806181f6ec6afa4097c43bf1f2420 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 22 May 2009 10:19:01 +0000 Subject: [PATCH 067/283] simplify code --- vcl/source/window/printdlg.cxx | 214 +++++++++++++++------------------ 1 file changed, 95 insertions(+), 119 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9a5b20c0496f..2d53abd9ec86 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -591,143 +591,119 @@ void PrintDialog::setupOptionalUI() pRadioColumn->addWindow( pBtn ); } } - else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) + else if( ( aCtrlType.equalsAscii( "List" ) || + aCtrlType.equalsAscii( "Range" ) || + aCtrlType.equalsAscii( "Edit" ) + ) && pCurParent ) { - // create a row in the current column - vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); - pCurColumn->addChild( pPair ); - - // add a FixedText: - FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER ); - maControls.push_front( pHeading ); - pHeading->SetText( aText ); - pHeading->Show(); - - // set help id - setSmartId( pHeading, "FixedText", -1, aPropertyName ); - - // add to pair - pPair->addWindow( pHeading ); - - ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); - maControls.push_front( pList ); - - // iterate options - for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) - { - pList->InsertEntry( aChoices[m] ); - } - sal_Int32 nSelectVal = 0; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); - if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= nSelectVal; - pList->SelectEntryPos( static_cast(nSelectVal) ); - pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); - pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); - pList->Show(); - - // set help id - setSmartId( pList, "ListBox", -1, aPropertyName ); - // set help text - setHelpText( pList, aHelpTexts, 0 ); - - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); - maControlToPropertyMap[pList] = aPropertyName; - - // finish the pair - pPair->addWindow( pList ); - } - else if( aCtrlType.equalsAscii( "Range" ) && pCurParent ) - { - // create a row in the current column - vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); - pCurColumn->addChild( pPair ); - - // add a FixedText: - FixedText* pHeading = new FixedText( pCurParent ); - maControls.push_front( pHeading ); - pHeading->SetText( aText ); - pHeading->Show(); - - // set help id - setSmartId( pHeading, "FixedText", -1, aPropertyName ); - - // add to pair - pPair->addWindow( pHeading ); - - NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); - maControls.push_front( pField ); - - // set min/max and current value - if( nMinValue != nMaxValue ) - { - pField->SetMin( nMinValue ); - pField->SetMax( nMaxValue ); - } - sal_Int64 nCurVal = 0; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); - if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= nCurVal; - pField->SetValue( nCurVal ); - - pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); - pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); - pField->Show(); - - // set help id - setSmartId( pField, "NumericField", -1, aPropertyName ); - // set help text - setHelpText( pField, aHelpTexts, 0 ); - - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); - maControlToPropertyMap[pField] = aPropertyName; - - // add to pair - pPair->addWindow( pField ); - } - else if( aCtrlType.equalsAscii( "Edit" ) && pCurParent ) - { - vcl::RowOrColumn* pEditColumn = pCurColumn; - FixedText* pHeading = NULL; + vcl::RowOrColumn* pFieldColumn = pCurColumn; if( aText.getLength() ) { // create a row in the current column - vcl::RowOrColumn* pPair = new vcl::RowOrColumn( pCurColumn, false ); - pCurColumn->addChild( pPair ); - pEditColumn = pPair; + pFieldColumn = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pFieldColumn ); // add a FixedText: - pHeading = new FixedText( pCurParent ); + FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER ); maControls.push_front( pHeading ); pHeading->SetText( aText ); pHeading->Show(); // set help id setSmartId( pHeading, "FixedText", -1, aPropertyName ); - pPair->addWindow( pHeading ); + + // add to row + pFieldColumn->addWindow( pHeading ); } - Edit* pField = new Edit( pCurParent, WB_BORDER ); - maControls.push_front( pField ); + if( aCtrlType.equalsAscii( "List" ) ) + { + ListBox* pList = new ListBox( pCurParent, WB_DROPDOWN | WB_BORDER ); + maControls.push_front( pList ); - rtl::OUString aCurVal; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); - if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= aCurVal; - pField->SetText( aCurVal ); - pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); - pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); - pField->Show(); + // iterate options + for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) + { + pList->InsertEntry( aChoices[m] ); + } + sal_Int32 nSelectVal = 0; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= nSelectVal; + pList->SelectEntryPos( static_cast(nSelectVal) ); + pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); + pList->SetDropDownLineCount( aChoices.getLength() ); + pList->Show(); - // set help id - setSmartId( pField, "Edit", -1, aPropertyName ); - // set help text - setHelpText( pField, aHelpTexts, 0 ); + // set help id + setSmartId( pList, "ListBox", -1, aPropertyName ); + // set help text + setHelpText( pList, aHelpTexts, 0 ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); - maControlToPropertyMap[pField] = aPropertyName; + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); + maControlToPropertyMap[pList] = aPropertyName; - pEditColumn->addWindow( pField ); + // finish the pair + pFieldColumn->addWindow( pList ); + } + else if( aCtrlType.equalsAscii( "Range" ) ) + { + NumericField* pField = new NumericField( pCurParent, WB_BORDER | WB_SPIN ); + maControls.push_front( pField ); + + // set min/max and current value + if( nMinValue != nMaxValue ) + { + pField->SetMin( nMinValue ); + pField->SetMax( nMaxValue ); + } + sal_Int64 nCurVal = 0; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= nCurVal; + pField->SetValue( nCurVal ); + + pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); + pField->Show(); + + // set help id + setSmartId( pField, "NumericField", -1, aPropertyName ); + // set help text + setHelpText( pField, aHelpTexts, 0 ); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maControlToPropertyMap[pField] = aPropertyName; + + // add to row + pFieldColumn->addWindow( pField ); + } + else if( aCtrlType.equalsAscii( "Edit" ) ) + { + Edit* pField = new Edit( pCurParent, WB_BORDER ); + maControls.push_front( pField ); + + rtl::OUString aCurVal; + PropertyValue* pVal = maPListener->getValue( aPropertyName ); + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= aCurVal; + pField->SetText( aCurVal ); + pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); + pField->Show(); + + // set help id + setSmartId( pField, "Edit", -1, aPropertyName ); + // set help text + setHelpText( pField, aHelpTexts, 0 ); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maControlToPropertyMap[pField] = aPropertyName; + + // add to row + pFieldColumn->addWindow( pField ); + } } } else From ea23b7444553505a98f0cf9258631e45884303ec Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 25 May 2009 09:08:28 +0000 Subject: [PATCH 068/283] use shared ptr, newline --- vcl/inc/vcl/arrange.hxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 03a388a519bd..29ec72a27bd9 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -34,6 +34,7 @@ #include "vcl/window.hxx" #include +#include namespace vcl { @@ -54,12 +55,12 @@ namespace vcl protected: struct Element { - Window* m_pElement; - WindowArranger* m_pChild; + Window* m_pElement; + boost::shared_ptr m_pChild; Element() : m_pElement( NULL ) - , m_pChild( NULL ) + , m_pChild() {} Element( Window* i_pWin, WindowArranger* i_pChild ) @@ -67,7 +68,7 @@ namespace vcl , m_pChild( i_pChild ) {} - void deleteChild() { delete m_pChild; m_pChild = NULL; } + void deleteChild() { m_pChild.reset(); } }; Window* m_pParentWindow; @@ -162,7 +163,7 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } - virtual WindowArranger* getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild : NULL; } + virtual WindowArranger* getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild.get() : 0; } virtual Window* getWindow( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pElement : NULL; } void setIndent( long i_nIndent ) @@ -176,4 +177,5 @@ namespace vcl }; } -#endif \ No newline at end of file +#endif + From 708bbabd2b9c99488ec128278b0a79d358c811cc Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 25 May 2009 15:12:27 +0000 Subject: [PATCH 069/283] fix some warnings --- vcl/source/window/arrange.cxx | 8 ++++---- vcl/source/window/printdlg.cxx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index d52b5e813f74..6aae74919dad 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -65,7 +65,7 @@ RowOrColumn::~RowOrColumn() WindowArranger* RowOrColumn::getChild( size_t i_nIndex ) const { - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : NULL; + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild.get() : NULL; } Window* RowOrColumn::getWindow( size_t i_nIndex ) const @@ -274,7 +274,7 @@ void RowOrColumn::remove( WindowArranger* i_pChild ) for( std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); it != m_aElements.end(); ++it ) { - if( it->m_pChild == i_pChild ) + if( it->m_pChild.get() == i_pChild ) { m_aElements.erase( it ); return; @@ -327,8 +327,8 @@ void Indenter::setWindow( Window* i_pWindow ) void Indenter::setChild( WindowArranger* i_pChild ) { - OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0) || i_pChild == 0 ); - m_aElement.m_pChild = i_pChild; + OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0 ) || i_pChild == 0 ); + m_aElement.m_pChild.reset( i_pChild ); } void Indenter::setParentWindow( Window* i_pNewParent ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 2d53abd9ec86..ac335940f75e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -633,7 +633,7 @@ void PrintDialog::setupOptionalUI() pList->SelectEntryPos( static_cast(nSelectVal) ); pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); - pList->SetDropDownLineCount( aChoices.getLength() ); + pList->SetDropDownLineCount( static_cast(aChoices.getLength()) ); pList->Show(); // set help id From 1b47f9b4216522537b01b687491cfd50145cd623 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 26 May 2009 14:01:29 +0000 Subject: [PATCH 070/283] add completely useless PCH directive to satisfy stupid windows compiler --- vcl/source/window/arrange.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 6aae74919dad..2d92a3a287fd 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -28,6 +28,8 @@ * ************************************************************************/ +#include "precompiled_vcl.hxx" + #include "vcl/arrange.hxx" #include "osl/diagnose.h" From e7e3874e373e3ae1bf4da96c0fcd0ea9a394a92b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 27 May 2009 12:26:30 +0000 Subject: [PATCH 071/283] make WindowArranger API safer --- vcl/inc/vcl/arrange.hxx | 23 +++++++++++++++-------- vcl/source/window/arrange.cxx | 18 +++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 29ec72a27bd9..e2d1e9e677e9 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -63,7 +63,7 @@ namespace vcl , m_pChild() {} - Element( Window* i_pWin, WindowArranger* i_pChild ) + Element( Window* i_pWin, boost::shared_ptr const & i_pChild = boost::shared_ptr() ) : m_pElement( i_pWin ) , m_pChild( i_pChild ) {} @@ -97,7 +97,7 @@ namespace vcl virtual void setParent( WindowArranger* ); virtual size_t countElements() const = 0; - virtual WindowArranger* getChild( size_t i_nIndex ) const = 0; + virtual boost::shared_ptr getChild( size_t i_nIndex ) const = 0; virtual Window* getWindow( size_t i_nIndex ) const = 0; void setManagedArea( const Rectangle& i_rArea ) @@ -122,7 +122,8 @@ namespace vcl void distributeRowWidth( std::vector< Size >& io_rSizes, long i_nUsedWidth, long i_nExtraWidth ); public: - RowOrColumn( WindowArranger* i_pParent = NULL, bool bColumn = true, long i_nBorderWidth = 5 ) + RowOrColumn( WindowArranger* i_pParent = NULL, + bool bColumn = true, long i_nBorderWidth = 5 ) : WindowArranger( i_pParent ) , m_nBorderWidth( i_nBorderWidth ) , m_bColumn( bColumn ) @@ -134,7 +135,7 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return m_aElements.size(); } - virtual WindowArranger* getChild( size_t i_nIndex ) const; + virtual boost::shared_ptr getChild( size_t i_nIndex ) const; virtual Window* getWindow( size_t i_nIndex ) const; // add a managed window at the given index @@ -142,8 +143,11 @@ namespace vcl void addWindow( Window*, sal_Int32 nIndex = -1 ); void remove( Window* ); - void addChild( WindowArranger*, sal_Int32 nIndex = -1 ); - void remove( WindowArranger* ); + void addChild( boost::shared_ptr const &, sal_Int32 nIndex = -1 ); + // convenience: use for addChild( new WindowArranger( ... ) ) constructs + void addChild( WindowArranger* i_pNewChild, sal_Int32 nIndex = -1 ) + { addChild( boost::shared_ptr( i_pNewChild ), nIndex ); } + void remove( boost::shared_ptr const & ); }; class Indenter : public WindowArranger @@ -163,7 +167,7 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } - virtual WindowArranger* getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild.get() : 0; } + virtual boost::shared_ptr getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild : boost::shared_ptr(); } virtual Window* getWindow( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pElement : NULL; } void setIndent( long i_nIndent ) @@ -173,7 +177,10 @@ namespace vcl } void setWindow( Window* ); - void setChild( WindowArranger* ); + void setChild( boost::shared_ptr const & ); + // convenience: use for setChild( new WindowArranger( ... ) ) constructs + void setChild( WindowArranger* i_pChild ) + { setChild( boost::shared_ptr( i_pChild ) ); } }; } diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 2d92a3a287fd..bedfb6c9b533 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -65,9 +65,9 @@ RowOrColumn::~RowOrColumn() } } -WindowArranger* RowOrColumn::getChild( size_t i_nIndex ) const +boost::shared_ptr RowOrColumn::getChild( size_t i_nIndex ) const { - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild.get() : NULL; + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : boost::shared_ptr(); } Window* RowOrColumn::getWindow( size_t i_nIndex ) const @@ -230,17 +230,17 @@ void RowOrColumn::setParentWindow( Window* i_pNewParent ) void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nIndex ) { if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) - m_aElements.push_back( WindowArranger::Element( i_pWindow, NULL ) ); + m_aElements.push_back( WindowArranger::Element( i_pWindow ) ); else { std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); while( i_nIndex-- ) ++it; - m_aElements.insert( it, WindowArranger::Element( i_pWindow, NULL ) ); + m_aElements.insert( it, WindowArranger::Element( i_pWindow ) ); } } -void RowOrColumn::addChild( WindowArranger* i_pChild, sal_Int32 i_nIndex ) +void RowOrColumn::addChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nIndex ) { if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) m_aElements.push_back( WindowArranger::Element( NULL, i_pChild ) ); @@ -269,14 +269,14 @@ void RowOrColumn::remove( Window* i_pWindow ) } } -void RowOrColumn::remove( WindowArranger* i_pChild ) +void RowOrColumn::remove( boost::shared_ptr const & i_pChild ) { if( i_pChild ) { for( std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); it != m_aElements.end(); ++it ) { - if( it->m_pChild.get() == i_pChild ) + if( it->m_pChild == i_pChild ) { m_aElements.erase( it ); return; @@ -327,10 +327,10 @@ void Indenter::setWindow( Window* i_pWindow ) m_aElement.m_pElement = i_pWindow; } -void Indenter::setChild( WindowArranger* i_pChild ) +void Indenter::setChild( boost::shared_ptr const & i_pChild ) { OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0 ) || i_pChild == 0 ); - m_aElement.m_pChild.reset( i_pChild ); + m_aElement.m_pChild = i_pChild; } void Indenter::setParentWindow( Window* i_pNewParent ) From 2d74f4c2357195cc0c7b3bd0ffe9fb93e83c18e0 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 27 May 2009 12:44:22 +0000 Subject: [PATCH 072/283] fix last page in preview missing --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index ac335940f75e..804711c62b50 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -853,7 +853,7 @@ void PrintDialog::preparePreview( bool i_bNewPage ) setPreviewText( mnCurPage ); - maPageSlider.SetRange( Range( 0, nPages-1 ) ); + maPageSlider.SetRange( Range( 0, nPages ) ); maPageSlider.SetThumbPos( mnCurPage ); maPageSlider.SetVisibleSize( 1 ); From 2f7007962edc48f987f14e7631bf3ddb96af7f7f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 27 May 2009 17:40:24 +0000 Subject: [PATCH 073/283] print range changes, dependency UI --- vcl/inc/vcl/arrange.hxx | 30 +++-- vcl/inc/vcl/print.hxx | 13 +- vcl/source/control/edit.cxx | 5 + vcl/source/gdi/print3.cxx | 27 ++-- vcl/source/window/arrange.cxx | 77 +++++++++--- vcl/source/window/printdlg.cxx | 218 ++++++++++++++++++--------------- 6 files changed, 233 insertions(+), 137 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index e2d1e9e677e9..fdaf957dce76 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -57,18 +57,26 @@ namespace vcl { Window* m_pElement; boost::shared_ptr m_pChild; + sal_Int32 m_nExpandPriority; Element() : m_pElement( NULL ) , m_pChild() + , m_nExpandPriority( 0 ) {} - Element( Window* i_pWin, boost::shared_ptr const & i_pChild = boost::shared_ptr() ) + Element( Window* i_pWin, + boost::shared_ptr const & i_pChild = boost::shared_ptr(), + sal_Int32 i_nExpandPriority = 0 + ) : m_pElement( i_pWin ) , m_pChild( i_pChild ) + , m_nExpandPriority( i_nExpandPriority ) {} void deleteChild() { m_pChild.reset(); } + + sal_Int32 getExpandPriority() const; }; Window* m_pParentWindow; @@ -99,6 +107,7 @@ namespace vcl virtual size_t countElements() const = 0; virtual boost::shared_ptr getChild( size_t i_nIndex ) const = 0; virtual Window* getWindow( size_t i_nIndex ) const = 0; + virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const = 0; void setManagedArea( const Rectangle& i_rArea ) { @@ -137,16 +146,17 @@ namespace vcl virtual size_t countElements() const { return m_aElements.size(); } virtual boost::shared_ptr getChild( size_t i_nIndex ) const; virtual Window* getWindow( size_t i_nIndex ) const; + virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const; // add a managed window at the given index // an index smaller than zero means add the window at the end - void addWindow( Window*, sal_Int32 nIndex = -1 ); + void addWindow( Window*, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ); void remove( Window* ); - void addChild( boost::shared_ptr const &, sal_Int32 nIndex = -1 ); + void addChild( boost::shared_ptr const &, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ); // convenience: use for addChild( new WindowArranger( ... ) ) constructs - void addChild( WindowArranger* i_pNewChild, sal_Int32 nIndex = -1 ) - { addChild( boost::shared_ptr( i_pNewChild ), nIndex ); } + void addChild( WindowArranger* i_pNewChild, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ) + { addChild( boost::shared_ptr( i_pNewChild ), i_nExpandPrio, i_nIndex ); } void remove( boost::shared_ptr const & ); }; @@ -169,6 +179,8 @@ namespace vcl virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } virtual boost::shared_ptr getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild : boost::shared_ptr(); } virtual Window* getWindow( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pElement : NULL; } + virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const + { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } void setIndent( long i_nIndent ) { @@ -176,11 +188,11 @@ namespace vcl resize(); } - void setWindow( Window* ); - void setChild( boost::shared_ptr const & ); + void setWindow( Window*, sal_Int32 i_nExpandPrio = 0 ); + void setChild( boost::shared_ptr const &, sal_Int32 i_nExpandPrio = 0 ); // convenience: use for setChild( new WindowArranger( ... ) ) constructs - void setChild( WindowArranger* i_pChild ) - { setChild( boost::shared_ptr( i_pChild ) ); } + void setChild( WindowArranger* i_pChild, sal_Int32 i_nExpandPrio = 0 ) + { setChild( boost::shared_ptr( i_pChild ), i_nExpandPrio ); } }; } diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 98e08312e5ca..774a74572d59 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -556,6 +556,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const com::sun::star::beans::PropertyValue* i_pValue = NULL, const rtl::OUString* i_pDependsOnName = NULL, sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False, const com::sun::star::beans::PropertyValue* i_pAddProps = NULL, sal_Int32 i_nAddProps = 0 ); @@ -574,7 +575,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const rtl::OUString& i_rProperty, sal_Bool i_bValue, const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False ); // create a set of choices (either a radio button group or a list box) @@ -585,7 +587,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper sal_Int32 i_nValue, const rtl::OUString& i_rType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False ); // create an integer range (e.g. a spin field) @@ -597,7 +600,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper sal_Int32 i_nMinValue = -1, sal_Int32 i_nMaxValue = -2, const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False ); // create a string field @@ -607,7 +611,8 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const rtl::OUString& i_rProperty, const rtl::OUString& i_rValue, const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1 + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False ); }; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 3834e4de8677..cbead10a4618 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2831,6 +2831,11 @@ void Edit::SetSubEdit( Edit* pEdit ) Size Edit::CalcMinimumSize() const { Size aSize ( GetTextWidth( GetText() ), GetTextHeight() ); + // do not create edit fields in which one cannot enter anything + // a default minimum width should exist for at least 3 characters + Size aMinSize ( CalcSize( 3 ) ); + if( aSize.Width() < aMinSize.Width() ) + aSize.Width() = aMinSize.Width(); return CalcWindowSize( aSize ); } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index d16db4ef9aec..ed1080a70e7b 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -927,6 +927,7 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, const PropertyValue* i_pVal, const rtl::OUString* i_pDependsOnName, sal_Int32 i_nDependsOnEntry, + sal_Bool i_bAttachToDependency, const PropertyValue* i_pAddProps, sal_Int32 i_nAddProps ) @@ -937,6 +938,7 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + (i_rHelpTexts.getLength() ? 1 : 0) // HelpText + (i_pVal ? 1 : 0) // Property + (i_pDependsOnName ? (i_nDependsOnEntry != -1 ? 2 : 1) : 0) // dependencies + + (i_pDependsOnName && i_bAttachToDependency ? 1 : 0) // attach to dependency + i_nAddProps ; @@ -968,6 +970,11 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); } + if( i_bAttachToDependency ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AttachToDependency" ) ); + aCtrl[nUsed++].Value = makeAny( i_bAttachToDependency ); + } } for( sal_Int32 i = 0; i < i_nAddProps; i++ ) aCtrl[ nUsed++ ] = i_pAddProps[i]; @@ -1010,7 +1017,7 @@ Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, *aHelpText.getArray() = i_rHelpText; } return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ), - NULL, NULL, -1, aAddProps, nUsed ); + NULL, NULL, -1, sal_False, aAddProps, nUsed ); } Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, @@ -1018,7 +1025,8 @@ Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rProperty, sal_Bool i_bValue, const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry + sal_Int32 i_nDependsOnEntry, + sal_Bool i_bAttachToDependency ) { Sequence< rtl::OUString > aHelpText; @@ -1030,7 +1038,7 @@ Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, i_pDependsOnName, i_nDependsOnEntry ); + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, i_pDependsOnName, i_nDependsOnEntry, i_bAttachToDependency ); } Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, @@ -1040,7 +1048,8 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nValue, const rtl::OUString& i_rType, const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry + sal_Int32 i_nDependsOnEntry, + sal_Bool i_bAttachToDependency ) { PropertyValue aAddProps[2]; @@ -1051,7 +1060,7 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, i_pDependsOnName, i_nDependsOnEntry, aAddProps, nUsed ); + return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, i_pDependsOnName, i_nDependsOnEntry, i_bAttachToDependency, aAddProps, nUsed ); } Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, @@ -1061,7 +1070,8 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nMinValue, sal_Int32 i_nMaxValue, const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry + sal_Int32 i_nDependsOnEntry, + sal_Bool i_bAttachToDependency ) { PropertyValue aAddProps[2]; @@ -1089,6 +1099,7 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, &aVal, i_pDependsOnName, i_nDependsOnEntry, + i_bAttachToDependency, aAddProps, nUsed ); } @@ -1097,7 +1108,8 @@ Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rProperty, const rtl::OUString& i_rValue, const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry + sal_Int32 i_nDependsOnEntry, + sal_Bool i_bAttachToDependency ) { Sequence< rtl::OUString > aHelpText; @@ -1115,5 +1127,6 @@ Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, &aVal, i_pDependsOnName, i_nDependsOnEntry, + i_bAttachToDependency, 0, 0 ); } diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index bedfb6c9b533..ba1a89eb79da 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -31,6 +31,7 @@ #include "precompiled_vcl.hxx" #include "vcl/arrange.hxx" +#include "vcl/edit.hxx" #include "osl/diagnose.h" @@ -52,6 +53,22 @@ void WindowArranger::setParent( WindowArranger* i_pParent ) setParentWindow( m_pParentWindow ); } +sal_Int32 WindowArranger::Element::getExpandPriority() const +{ + sal_Int32 nPrio = m_nExpandPriority; + if( m_pChild ) + { + size_t nElements = m_pChild->countElements(); + for( size_t i = 0; i < nElements; i++ ) + { + sal_Int32 nCPrio = m_pChild->getExpandPriority( i ); + if( nCPrio > nPrio ) + nPrio = nCPrio; + } + } + return nPrio; +} + // ---------------------------------------- // vcl::RowOrColumn //----------------------------------------- @@ -75,6 +92,11 @@ Window* RowOrColumn::getWindow( size_t i_nIndex ) const return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pElement : NULL; } +sal_Int32 RowOrColumn::getExpandPriority( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].getExpandPriority() : 0; +} + Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const { Size aRet( 0, 0 ); @@ -124,19 +146,38 @@ Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const void RowOrColumn::distributeRowWidth( std::vector& io_rSizes, long /*i_nUsedWidth*/, long i_nExtraWidth ) { - if( ! io_rSizes.empty() ) + if( ! io_rSizes.empty() && io_rSizes.size() == m_aElements.size() ) { - // distribute extra space evenly among elements - size_t nElements = io_rSizes.size(); - long nDelta = i_nExtraWidth / nElements; + // find all elements with the highest expand priority + size_t nElements = m_aElements.size(); + std::vector< size_t > aIndices; + sal_Int32 nHighPrio = 0; for( size_t i = 0; i < nElements; i++ ) { - io_rSizes[i].Width() += nDelta; - i_nExtraWidth -= nDelta; + sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); + if( nCurPrio > nHighPrio ) + { + aIndices.clear(); + nHighPrio = nCurPrio; + } + if( nCurPrio == nHighPrio ) + aIndices.push_back( i ); + } + + // distribute extra space evenly among elements + nElements = aIndices.size(); + if( nElements > 0 ) // sanity check + { + long nDelta = i_nExtraWidth / nElements; + for( size_t i = 0; i < nElements; i++ ) + { + io_rSizes[ aIndices[i] ].Width() += nDelta; + i_nExtraWidth -= nDelta; + } + // add the last pixels to the last row element + if( i_nExtraWidth > 0 && nElements > 0 ) + io_rSizes[aIndices.back()].Width() += i_nExtraWidth; } - // add the last pixels to the last row element - if( i_nExtraWidth > 0 && nElements > 0 ) - io_rSizes.back().Width() += i_nExtraWidth; } } @@ -227,29 +268,29 @@ void RowOrColumn::setParentWindow( Window* i_pNewParent ) } } -void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nIndex ) +void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio, sal_Int32 i_nIndex ) { if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) - m_aElements.push_back( WindowArranger::Element( i_pWindow ) ); + m_aElements.push_back( WindowArranger::Element( i_pWindow, boost::shared_ptr(), i_nExpandPrio ) ); else { std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); while( i_nIndex-- ) ++it; - m_aElements.insert( it, WindowArranger::Element( i_pWindow ) ); + m_aElements.insert( it, WindowArranger::Element( i_pWindow, boost::shared_ptr(), i_nExpandPrio ) ); } } -void RowOrColumn::addChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nIndex ) +void RowOrColumn::addChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nExpandPrio, sal_Int32 i_nIndex ) { if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) - m_aElements.push_back( WindowArranger::Element( NULL, i_pChild ) ); + m_aElements.push_back( WindowArranger::Element( NULL, i_pChild, i_nExpandPrio ) ); else { std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); while( i_nIndex-- ) ++it; - m_aElements.insert( it, WindowArranger::Element( NULL, i_pChild ) ); + m_aElements.insert( it, WindowArranger::Element( NULL, i_pChild, i_nExpandPrio ) ); } } @@ -320,17 +361,19 @@ void Indenter::resize() m_aElement.m_pChild->setManagedArea( Rectangle( aPt, aSz ) ); } -void Indenter::setWindow( Window* i_pWindow ) +void Indenter::setWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio ) { OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0) || i_pWindow == 0 ); OSL_VERIFY( i_pWindow == 0 || i_pWindow->GetParent() == m_pParentWindow ); m_aElement.m_pElement = i_pWindow; + m_aElement.m_nExpandPriority = i_nExpandPrio; } -void Indenter::setChild( boost::shared_ptr const & i_pChild ) +void Indenter::setChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nExpandPrio ) { OSL_VERIFY( (m_aElement.m_pElement == 0 && m_aElement.m_pChild == 0 ) || i_pChild == 0 ); m_aElement.m_pChild = i_pChild; + m_aElement.m_nExpandPriority = i_nExpandPrio; } void Indenter::setParentWindow( Window* i_pNewParent ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 804711c62b50..08083364f801 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -347,6 +347,8 @@ void PrintDialog::setupOptionalUI() USHORT nOptPageId = 9, nCurSubGroup = 0; bool bOnJobPage = false; + std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap; + const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -363,6 +365,9 @@ void PrintDialog::setupOptionalUI() sal_Int64 nMinValue = 0, nMaxValue = 0; sal_Int32 nCurHelpText = 0; sal_Bool bOnJobPageValue = sal_False; + rtl::OUString aDependsOnName; + sal_Int32 nDependsOnValue = 0; + sal_Bool bUseDependencyRow = sal_False; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -397,26 +402,15 @@ void PrintDialog::setupOptionalUI() } else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) { - rtl::OUString aDepName; - rEntry.Value >>= aDepName; - std::map< rtl::OUString, Window* >::iterator it( maPropertyToWindowMap.find( aDepName ) ); - if( it != maPropertyToWindowMap.end() ) - { - Window* pWin = it->second; - // still on the same page ? - if( pWin->GetParent() == pCurParent ) - { - // is it a labeled window ? - if( dynamic_cast< ListBox* >(pWin) || - dynamic_cast< Edit* >(pWin) - ) - { - Window* pLabelWin = pWin->GetLabeledBy(); - if( dynamic_cast(pLabelWin) ) // sanity check - pWin = pLabelWin; - } - } - } + rEntry.Value >>= aDependsOnName; + } + else if( rEntry.Name.equalsAscii( "DependsOnEntry" ) ) + { + rEntry.Value >>= nDependsOnValue; + } + else if( rEntry.Name.equalsAscii( "AttachToDependency" ) ) + { + rEntry.Value >>= bUseDependencyRow; } else if( rEntry.Name.equalsAscii( "MinValue" ) ) { @@ -440,81 +434,95 @@ void PrintDialog::setupOptionalUI() } } - if( aCtrlType.equalsAscii( "Group" ) || - aCtrlType.equalsAscii( "Subgroup" ) || - aCtrlType.equalsAscii( "Radio" ) || - aCtrlType.equalsAscii( "List" ) || - aCtrlType.equalsAscii( "Range" ) || - aCtrlType.equalsAscii( "Edit" ) || - aCtrlType.equalsAscii( "Bool" ) ) + if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) { - if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) + // add new tab page + TabPage* pNewGroup = new TabPage( &maTabCtrl ); + maControls.push_front( pNewGroup ); + pCurParent = pNewGroup; + pNewGroup->SetText( aText ); + maTabCtrl.InsertPage( ++nOptPageId, aText ); + maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); + + // set help id + setSmartId( pNewGroup, "TabPage", nOptPageId ); + // set help text + setHelpText( pNewGroup, aHelpTexts, 0 ); + + // reset subgroup counter + nCurSubGroup = 0; + + aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, nBorderWidth ) ); + pCurColumn = aDynamicColumns.back(); + pCurColumn->setParentWindow( pNewGroup ); + pCurColumn->setOuterBorder( nBorderWidth ); + } + else if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) + { + // change to job page or back if necessary + if( (bOnJobPage && ! bOnJobPageValue) || + (! bOnJobPage && bOnJobPageValue) ) { - // add new tab page - TabPage* pNewGroup = new TabPage( &maTabCtrl ); - maControls.push_front( pNewGroup ); - pCurParent = pNewGroup; - pNewGroup->SetText( aText ); - maTabCtrl.InsertPage( ++nOptPageId, aText ); - maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); - - // set help id - setSmartId( pNewGroup, "TabPage", nOptPageId ); - // set help text - setHelpText( pNewGroup, aHelpTexts, 0 ); - - // reset subgroup counter - nCurSubGroup = 0; - - aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, nBorderWidth ) ); - pCurColumn = aDynamicColumns.back(); - pCurColumn->setParentWindow( pNewGroup ); - pCurColumn->setOuterBorder( nBorderWidth ); - } - - if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) - { - // change to job page or back if necessary - if( (bOnJobPage && ! bOnJobPageValue) || - (! bOnJobPage && bOnJobPageValue) ) - { - bOnJobPage = bOnJobPageValue; - if( bOnJobPage ) - { - pDynamicPageParent = pCurParent; // save current parent - pCurParent = &maJobPage; // set job page as current parent - } - else - { - pCurParent = pDynamicPageParent; // set current tab page as parent - } - } - + bOnJobPage = bOnJobPageValue; if( bOnJobPage ) { - // create a new column in the PrintRange row - vcl::RowOrColumn* pNewColumn = new vcl::RowOrColumn( &aPrintRangeRow, true, nBorderWidth ); - aPrintRangeRow.addChild( pNewColumn ); - pCurColumn = pNewColumn; + pDynamicPageParent = pCurParent; // save current parent + pCurParent = &maJobPage; // set job page as current parent } else - pCurColumn = aDynamicColumns.back(); - - // create group FixedLine - FixedLine* pNewSub = new FixedLine( pCurParent ); - maControls.push_front( pNewSub ); - pNewSub->SetText( aText ); - pNewSub->Show(); - - // set help id - setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); - // set help text - setHelpText( pNewSub, aHelpTexts, 0 ); - - // add group to current column - pCurColumn->addWindow( pNewSub ); + { + pCurParent = pDynamicPageParent; // set current tab page as parent + } } - else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) + + if( bOnJobPage ) + { + // create a new column in the PrintRange row + vcl::RowOrColumn* pNewColumn = new vcl::RowOrColumn( &aPrintRangeRow, true, nBorderWidth ); + aPrintRangeRow.addChild( pNewColumn ); + pCurColumn = pNewColumn; + } + else + pCurColumn = aDynamicColumns.back(); + + // create group FixedLine + FixedLine* pNewSub = new FixedLine( pCurParent ); + maControls.push_front( pNewSub ); + pNewSub->SetText( aText ); + pNewSub->Show(); + + // set help id + setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); + // set help text + setHelpText( pNewSub, aHelpTexts, 0 ); + + // add group to current column + pCurColumn->addWindow( pNewSub ); + } + else + { + vcl::RowOrColumn* pSaveCurColumn = pCurColumn; + + if( bUseDependencyRow && aDependsOnName.getLength() ) + { + // find the correct dependency row (if any) + std::pair< std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator, + std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator > aDepRange; + aDepRange = aPropertyToDependencyRowMap.equal_range( aDependsOnName ); + if( aDepRange.first != aDepRange.second ) + { + while( nDependsOnValue && aDepRange.first != aDepRange.second ) + { + nDependsOnValue--; + ++aDepRange.first; + } + if( aDepRange.first != aPropertyToDependencyRowMap.end() ) + { + pCurColumn = aDepRange.first->second; + } + } + } + if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { // add a check box CheckBox* pNewBox = new CheckBox( pCurParent ); @@ -538,8 +546,12 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pNewBox, aHelpTexts, 0 ); + vcl::RowOrColumn* pDependencyRow = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pDependencyRow ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow ) ); + // add checkbox to current column - pCurColumn->addWindow( pNewBox ); + pDependencyRow->addWindow( pNewBox ); } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -572,6 +584,10 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= nSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { + vcl::RowOrColumn* pDependencyRow = new vcl::RowOrColumn( pCurColumn, false ); + pRadioColumn->addChild( pDependencyRow ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow ) ); + RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); @@ -588,7 +604,7 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pBtn, aHelpTexts, nCurHelpText++ ); // add the radio button to the column - pRadioColumn->addWindow( pBtn ); + pDependencyRow->addWindow( pBtn ); } } else if( ( aCtrlType.equalsAscii( "List" ) || @@ -596,13 +612,13 @@ void PrintDialog::setupOptionalUI() aCtrlType.equalsAscii( "Edit" ) ) && pCurParent ) { - vcl::RowOrColumn* pFieldColumn = pCurColumn; + // create a row in the current column + vcl::RowOrColumn* pFieldColumn = new vcl::RowOrColumn( pCurColumn, false ); + pCurColumn->addChild( pFieldColumn ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pFieldColumn ) ); + if( aText.getLength() ) { - // create a row in the current column - pFieldColumn = new vcl::RowOrColumn( pCurColumn, false ); - pCurColumn->addChild( pFieldColumn ); - // add a FixedText: FixedText* pHeading = new FixedText( pCurParent, WB_VCENTER ); maControls.push_front( pHeading ); @@ -702,13 +718,15 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pField] = aPropertyName; // add to row - pFieldColumn->addWindow( pField ); + pFieldColumn->addWindow( pField, 2 ); } } - } - else - { - DBG_ERROR( "Unsupported UI option" ); + else + { + DBG_ERROR( "Unsupported UI option" ); + } + + pCurColumn = pSaveCurColumn; } } From 9b32197487cc7993e021e4bd733685173cdae271 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 27 May 2009 18:53:40 +0000 Subject: [PATCH 074/283] print range changes for basic ide --- vcl/source/window/printdlg.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 08083364f801..f4164b3a66a6 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -434,7 +434,8 @@ void PrintDialog::setupOptionalUI() } } - if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) + if( aCtrlType.equalsAscii( "Group" ) || + ( ! pCurParent && ! (bOnJobPage || bOnJobPageValue) ) ) { // add new tab page TabPage* pNewGroup = new TabPage( &maTabCtrl ); @@ -457,7 +458,7 @@ void PrintDialog::setupOptionalUI() pCurColumn->setParentWindow( pNewGroup ); pCurColumn->setOuterBorder( nBorderWidth ); } - else if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) + else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || bOnJobPageValue) ) { // change to job page or back if necessary if( (bOnJobPage && ! bOnJobPageValue) || From 599de0cf57cc354fbe9ac9b2ec7c3cebabcc90be Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 28 May 2009 16:46:25 +0000 Subject: [PATCH 075/283] #i96402# SetDuplexMode --- vcl/aqua/inc/salprn.h | 2 - vcl/aqua/source/gdi/salprn.cxx | 11 +--- vcl/inc/vcl/jobset.h | 13 ++--- vcl/inc/vcl/print.hxx | 1 + vcl/inc/vcl/prntypes.hxx | 3 +- vcl/inc/vcl/salprn.hxx | 1 - vcl/inc/vcl/salptype.hxx | 6 ++- vcl/os2/inc/salprn.h | 1 - vcl/os2/source/gdi/salprn.cxx | 7 +-- vcl/source/gdi/jobset.cxx | 26 +++++++++- vcl/source/gdi/print.cxx | 39 +++++++++++++- vcl/unx/headless/svpprn.cxx | 87 ++++++++++++++++++++++---------- vcl/unx/headless/svpprn.hxx | 1 - vcl/unx/inc/salprn.h | 1 - vcl/unx/source/gdi/salprnpsp.cxx | 87 ++++++++++++++++++++++---------- vcl/win/inc/salprn.h | 1 - vcl/win/source/gdi/salprn.cxx | 68 +++++++++++++------------ 17 files changed, 234 insertions(+), 121 deletions(-) diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index 0ab4c02ab264..3a486d901ddc 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -96,8 +96,6 @@ class AquaSalInfoPrinter : public SalInfoPrinter virtual String GetPaperBinName( const ImplJobSetup* i_pSetupData, ULONG i_nPaperBin ); virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData ); virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData ); - virtual DuplexMode GetDuplexMode( const ImplJobSetup* i_pSetupData ); - // the artificial separation between InfoPrinter and Printer // is not really useful for us diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index b109f2c19dcd..de7e5200b8af 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -435,6 +435,8 @@ ULONG AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup* i_pSetupData, USH return 0; case PRINTER_CAPABILITIES_SETORIENTATION: return 1; + case PRINTER_CAPABILITIES_SETDUPLEX: + return 0; case PRINTER_CAPABILITIES_SETPAPERBIN: return 0; case PRINTER_CAPABILITIES_SETPAPERSIZE: @@ -811,13 +813,4 @@ int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) return 900; } -//////////////////////////// -////// IMPLEMENT US ///// -//////////////////////////// - -DuplexMode AquaSalInfoPrinter::GetDuplexMode( const ImplJobSetup* i_pSetupData ) -{ - return DUPLEX_UNKNOWN; -} - diff --git a/vcl/inc/vcl/jobset.h b/vcl/inc/vcl/jobset.h index 5d08319a7e6c..fd15d0c076da 100644 --- a/vcl/inc/vcl/jobset.h +++ b/vcl/inc/vcl/jobset.h @@ -60,12 +60,13 @@ struct ImplJobSetup String maPrinterName; // Printer-Name String maDriver; // Driver-Name Orientation meOrientation; // Orientation - USHORT mnPaperBin; // Papierschacht - Paper mePaperFormat; // Papierformat - long mnPaperWidth; // Papierbreite in 100tel mm - long mnPaperHeight; // Papierhoehe in 100tel mm - ULONG mnDriverDataLen; // Laenge der systemabhaengigen Daten - BYTE* mpDriverData; // Systemabhaengige Daten die als Byte-Block rausgeschrieben werden + DuplexMode meDuplexMode; // Duplex + USHORT mnPaperBin; // paper bin / in tray + Paper mePaperFormat; // paper format + long mnPaperWidth; // paper width (100th mm) + long mnPaperHeight; // paper height (100th mm) + ULONG mnDriverDataLen; // length of system specific data + BYTE* mpDriverData; // system specific data (will be streamed a byte block) ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > maValueMap; ImplJobSetup(); diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 774a74572d59..83e4e984a1d3 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -335,6 +335,7 @@ public: BOOL SetOrientation( Orientation eOrient ); Orientation GetOrientation() const; DuplexMode GetDuplexMode() const; + BOOL SetDuplexMode( DuplexMode ); // returns the angle that a landscape page will be turned counterclockwise // wrt to portrait. The return value may be only valid for // the current paper diff --git a/vcl/inc/vcl/prntypes.hxx b/vcl/inc/vcl/prntypes.hxx index 84ef320de20e..8a05f95f8fc1 100644 --- a/vcl/inc/vcl/prntypes.hxx +++ b/vcl/inc/vcl/prntypes.hxx @@ -38,7 +38,7 @@ // - Duplex Mode - // --------------- -enum DuplexMode { DUPLEX_UNKNOWN, DUPLEX_OFF, DUPLEX_ON }; +enum DuplexMode { DUPLEX_UNKNOWN, DUPLEX_OFF, DUPLEX_LONGEDGE, DUPLEX_SHORTEDGE }; // --------------- // - Orientation - @@ -119,5 +119,6 @@ struct PaperInfo #define PRINTER_CAPABILITIES_FAX ((USHORT)8) #define PRINTER_CAPABILITIES_PDF ((USHORT)9) #define PRINTER_CAPABILITIES_EXTERNALDIALOG ((USHORT)10) +#define PRINTER_CAPABILITIES_SETDUPLEX ((USHORT)11) #endif // _SV_PRNTYPES_HXX diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx index d76040f8cb8b..923b3a750e36 100644 --- a/vcl/inc/vcl/salprn.hxx +++ b/vcl/inc/vcl/salprn.hxx @@ -101,7 +101,6 @@ public: virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) = 0; // returns angle that a landscape page will be turned counterclockwise wrt to portrait virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ) = 0; - virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ) = 0; }; // -------------- diff --git a/vcl/inc/vcl/salptype.hxx b/vcl/inc/vcl/salptype.hxx index 7f1c82079f38..bc9883757432 100644 --- a/vcl/inc/vcl/salptype.hxx +++ b/vcl/inc/vcl/salptype.hxx @@ -40,7 +40,11 @@ #define SAL_JOBSET_ORIENTATION ((ULONG)0x00000001) #define SAL_JOBSET_PAPERBIN ((ULONG)0x00000002) #define SAL_JOBSET_PAPERSIZE ((ULONG)0x00000004) -#define SAL_JOBSET_ALL (SAL_JOBSET_ORIENTATION | SAL_JOBSET_PAPERBIN | SAL_JOBSET_PAPERSIZE) +#define SAL_JOBSET_DUPLEXMODE ((ULONG)0x00000008) +#define SAL_JOBSET_ALL (SAL_JOBSET_ORIENTATION |\ + SAL_JOBSET_PAPERBIN |\ + SAL_JOBSET_PAPERSIZE |\ + SAL_JOBSET_DUPLEXMODE) // ------------------- // - SalPrinterError - diff --git a/vcl/os2/inc/salprn.h b/vcl/os2/inc/salprn.h index 25ecfe87ed89..bddb29f61442 100644 --- a/vcl/os2/inc/salprn.h +++ b/vcl/os2/inc/salprn.h @@ -83,7 +83,6 @@ public: virtual String GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ); virtual void InitPaperFormats( const ImplJobSetup* pSetupData ); virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ); - virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ); }; // ------------------ diff --git a/vcl/os2/source/gdi/salprn.cxx b/vcl/os2/source/gdi/salprn.cxx index 0c254e2f6e62..b8207ed317f2 100644 --- a/vcl/os2/source/gdi/salprn.cxx +++ b/vcl/os2/source/gdi/salprn.cxx @@ -1831,9 +1831,4 @@ int Os2SalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* pSetupData ) printf("Os2SalInfoPrinter::GetLandscapeAngle\n"); return 0; } -DuplexMode Os2SalInfoPrinter::GetDuplexMode( const ImplJobSetup* pSetupData ) -{ - DuplexMode nRet = DUPLEX_UNKNOWN; - printf("Os2SalInfoPrinter::GetDuplexMode\n"); - return nRet; -} + diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 686d33593466..4823a5492ded 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -73,6 +73,7 @@ ImplJobSetup::ImplJobSetup() mnRefCount = 1; mnSystem = 0; meOrientation = ORIENTATION_PORTRAIT; + meDuplexMode = DUPLEX_UNKNOWN; mnPaperBin = 0; mePaperFormat = PAPER_USER; mnPaperWidth = 0; @@ -90,6 +91,7 @@ ImplJobSetup::ImplJobSetup( const ImplJobSetup& rJobSetup ) : mnRefCount = 1; mnSystem = rJobSetup.mnSystem; meOrientation = rJobSetup.meOrientation; + meDuplexMode = rJobSetup.meDuplexMode; mnPaperBin = rJobSetup.mnPaperBin; mePaperFormat = rJobSetup.mePaperFormat; mnPaperWidth = rJobSetup.mnPaperWidth; @@ -277,6 +279,7 @@ BOOL JobSetup::operator==( const JobSetup& rJobSetup ) const (pData1->maPrinterName == pData2->maPrinterName) && (pData1->maDriver == pData2->maDriver) && (pData1->meOrientation == pData2->meOrientation) && + (pData1->meDuplexMode == pData2->meDuplexMode) && (pData1->mnPaperBin == pData2->mnPaperBin) && (pData1->mePaperFormat == pData2->mePaperFormat) && (pData1->mnPaperWidth == pData2->mnPaperWidth) && @@ -337,6 +340,7 @@ SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup ) pJobData->mnSystem = SVBT16ToShort( pOldJobData->nSystem ); pJobData->mnDriverDataLen = SVBT32ToUInt32( pOldJobData->nDriverDataLen ); pJobData->meOrientation = (Orientation)SVBT16ToShort( pOldJobData->nOrientation ); + pJobData->meDuplexMode = DUPLEX_UNKNOWN; pJobData->mnPaperBin = SVBT16ToShort( pOldJobData->nPaperBin ); pJobData->mePaperFormat = (Paper)SVBT16ToShort( pOldJobData->nPaperFormat ); pJobData->mnPaperWidth = (long)SVBT32ToUInt32( pOldJobData->nPaperWidth ); @@ -355,7 +359,19 @@ SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup ) String aKey, aValue; rIStream.ReadByteString( aKey, RTL_TEXTENCODING_UTF8 ); rIStream.ReadByteString( aValue, RTL_TEXTENCODING_UTF8 ); - pJobData->maValueMap[ aKey ] = aValue; + if( aKey.EqualsAscii( "COMPAT_DUPLEX_MODE" ) ) + { + if( aValue.EqualsAscii( "DUPLEX_UNKNOWN" ) ) + pJobData->meDuplexMode = DUPLEX_UNKNOWN; + else if( aValue.EqualsAscii( "DUPLEX_OFF" ) ) + pJobData->meDuplexMode = DUPLEX_OFF; + else if( aValue.EqualsAscii( "DUPLEX_SHORTEDGE" ) ) + pJobData->meDuplexMode = DUPLEX_SHORTEDGE; + else if( aValue.EqualsAscii( "DUPLEX_LONGEDGE" ) ) + pJobData->meDuplexMode = DUPLEX_LONGEDGE; + } + else + pJobData->maValueMap[ aKey ] = aValue; } DBG_ASSERT( rIStream.Tell() == nFirstPos+nLen, "corrupted job setup" ); // ensure correct stream position @@ -421,6 +437,14 @@ SvStream& operator<<( SvStream& rOStream, const JobSetup& rJobSetup ) rOStream.WriteByteString( it->first, RTL_TEXTENCODING_UTF8 ); rOStream.WriteByteString( it->second, RTL_TEXTENCODING_UTF8 ); } + rOStream.WriteByteString( "COMPAT_DUPLEX_MODE" ) ; + switch( pJobData->meDuplexMode ) + { + case DUPLEX_UNKNOWN: rOStream.WriteByteString( "DUPLEX_UNKNOWN" );break; + case DUPLEX_OFF: rOStream.WriteByteString( "DUPLEX_OFF" );break; + case DUPLEX_SHORTEDGE: rOStream.WriteByteString( "DUPLEX_SHORTEDGE" );break; + case DUPLEX_LONGEDGE: rOStream.WriteByteString( "DUPLEX_LONGEDGE" );break; + } nLen = sal::static_int_cast(rOStream.Tell() - nPos); rOStream.Seek( nPos ); rOStream << nLen; diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index f3a89f6b6b23..a74038c4eaaa 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1200,7 +1200,44 @@ BOOL Printer::SetPaperFromInfo( const vcl::PaperInfo& rInfo ) DuplexMode Printer::GetDuplexMode() const { - return mpInfoPrinter ? mpInfoPrinter->GetDuplexMode( maJobSetup.ImplGetConstData() ) : DUPLEX_UNKNOWN; + return maJobSetup.ImplGetConstData()->meDuplexMode; +} + +// ----------------------------------------------------------------------- + +BOOL Printer::SetDuplexMode( DuplexMode eDuplex ) +{ + if ( mbInPrintPage ) + return FALSE; + + if ( maJobSetup.ImplGetConstData()->meDuplexMode != eDuplex ) + { + JobSetup aJobSetup = maJobSetup; + ImplJobSetup* pSetupData = aJobSetup.ImplGetData(); + pSetupData->meDuplexMode = eDuplex; + + if ( IsDisplayPrinter() ) + { + mbNewJobSetup = TRUE; + maJobSetup = aJobSetup; + return TRUE; + } + + ImplReleaseGraphics(); + if ( mpInfoPrinter->SetData( SAL_JOBSET_DUPLEXMODE, pSetupData ) ) + { + ImplUpdateJobSetupPaper( aJobSetup ); + mbNewJobSetup = TRUE; + maJobSetup = aJobSetup; + ImplUpdatePageData(); + ImplUpdateFontList(); + return TRUE; + } + else + return FALSE; + } + + return TRUE; } // ----------------------------------------------------------------------- diff --git a/vcl/unx/headless/svpprn.cxx b/vcl/unx/headless/svpprn.cxx index e9d726464921..880f218cccb4 100644 --- a/vcl/unx/headless/svpprn.cxx +++ b/vcl/unx/headless/svpprn.cxx @@ -154,6 +154,32 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) pJobSetup->mnPaperBin = 0xffff; } + // copy duplex + pKey = NULL; + pValue = NULL; + + pJobSetup->meDuplexMode = DUPLEX_UNKNOWN; + if( rData.m_pParser ) + pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); + if( pKey ) + pValue = rData.m_aContext.getValue( pKey ); + if( pKey && pValue ) + { + if( pValue->m_aOption.EqualsIgnoreCaseAscii( "None" ) || + pValue->m_aOption.EqualsIgnoreCaseAscii( "Simplex", 0, 7 ) + ) + { + pJobSetup->meDuplexMode = DUPLEX_OFF; + } + else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexNoTumble" ) ) + { + pJobSetup->meDuplexMode = DUPLEX_LONGEDGE; + } + else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexTumble" ) ) + { + pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE; + } + } // copy the whole context if( pJobSetup->mpDriverData ) @@ -491,34 +517,6 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) // ----------------------------------------------------------------------- -DuplexMode PspSalInfoPrinter::GetDuplexMode( const ImplJobSetup* pJobSetup ) -{ - DuplexMode aRet = DUPLEX_UNKNOWN; - PrinterInfo aInfo( PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName ) ); - if ( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo ); - if( aInfo.m_pParser ) - { - const PPDKey * pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); - if( pKey ) - { - const PPDValue* pVal = aInfo.m_aContext.getValue( pKey ); - if( pVal && ( - pVal->m_aOption.EqualsIgnoreCaseAscii( "None" ) || - pVal->m_aOption.EqualsIgnoreCaseAscii( "Simplex", 0, 7 ) - ) ) - { - aRet = DUPLEX_OFF; - } - else - aRet = DUPLEX_ON; - } - } - return aRet; -} - -// ----------------------------------------------------------------------- - int PspSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* ) { return 900; @@ -660,6 +658,37 @@ BOOL PspSalInfoPrinter::SetData( if( nSetDataFlags & SAL_JOBSET_ORIENTATION ) aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait; + // merge duplex if necessary + if( nSetDataFlags & SAL_JOBSET_DUPLEXMODE ) + { + pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); + if( pKey ) + { + pValue = NULL; + switch( pJobSetup->meDuplexMode ) + { + case DUPLEX_OFF: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) ); + if( pValue == NULL ) + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "SimplexNoTumble" ) ) ); + break; + case DUPLEX_SHORTEDGE: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexTumble" ) ) ); + break; + case DUPLEX_LONGEDGE: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexNoTumble" ) ) ); + break; + case DUPLEX_UNKNOWN: + default: + pValue = 0; + break; + } + if( ! pValue ) + pValue = pKey->getDefaultValue(); + aData.m_aContext.setValue( pKey, pValue ); + } + } + m_aJobData = aData; copyJobDataToJobSetup( pJobSetup, aData ); return TRUE; @@ -764,6 +793,8 @@ ULONG PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT return 0; case PRINTER_CAPABILITIES_SETORIENTATION: return 1; + case PRINTER_CAPABILITIES_SETDUPLEX: + return 1; case PRINTER_CAPABILITIES_SETPAPERBIN: return 1; case PRINTER_CAPABILITIES_SETPAPERSIZE: diff --git a/vcl/unx/headless/svpprn.hxx b/vcl/unx/headless/svpprn.hxx index c2d85c054fce..dd1c0cb1d88e 100644 --- a/vcl/unx/headless/svpprn.hxx +++ b/vcl/unx/headless/svpprn.hxx @@ -63,7 +63,6 @@ public: virtual String GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ); virtual void InitPaperFormats( const ImplJobSetup* pSetupData ); virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ); - virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ); }; class PspSalPrinter : public SalPrinter diff --git a/vcl/unx/inc/salprn.h b/vcl/unx/inc/salprn.h index 452fa5a89387..7d46d24ce94c 100644 --- a/vcl/unx/inc/salprn.h +++ b/vcl/unx/inc/salprn.h @@ -63,7 +63,6 @@ public: virtual String GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ); virtual void InitPaperFormats( const ImplJobSetup* pSetupData ); virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ); - virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ); }; class PspSalPrinter : public SalPrinter diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx index b3fdfaef56ce..f3da8cb3855f 100644 --- a/vcl/unx/source/gdi/salprnpsp.cxx +++ b/vcl/unx/source/gdi/salprnpsp.cxx @@ -207,6 +207,32 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) pJobSetup->mnPaperBin = 0; } + // copy duplex + pKey = NULL; + pValue = NULL; + + pJobSetup->meDuplexMode = DUPLEX_UNKNOWN; + if( rData.m_pParser ) + pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); + if( pKey ) + pValue = rData.m_aContext.getValue( pKey ); + if( pKey && pValue ) + { + if( pValue->m_aOption.EqualsIgnoreCaseAscii( "None" ) || + pValue->m_aOption.EqualsIgnoreCaseAscii( "Simplex", 0, 7 ) + ) + { + pJobSetup->meDuplexMode = DUPLEX_OFF; + } + else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexNoTumble" ) ) + { + pJobSetup->meDuplexMode = DUPLEX_LONGEDGE; + } + else if( pValue->m_aOption.EqualsIgnoreCaseAscii( "DuplexTumble" ) ) + { + pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE; + } + } // copy the whole context if( pJobSetup->mpDriverData ) @@ -560,34 +586,6 @@ void PspSalInfoPrinter::InitPaperFormats( const ImplJobSetup* ) // ----------------------------------------------------------------------- -DuplexMode PspSalInfoPrinter::GetDuplexMode( const ImplJobSetup* pJobSetup ) -{ - DuplexMode aRet = DUPLEX_UNKNOWN; - PrinterInfo aInfo( PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName ) ); - if ( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo ); - if( aInfo.m_pParser ) - { - const PPDKey * pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); - if( pKey ) - { - const PPDValue* pVal = aInfo.m_aContext.getValue( pKey ); - if( pVal && ( - pVal->m_aOption.EqualsIgnoreCaseAscii( "None" ) || - pVal->m_aOption.EqualsIgnoreCaseAscii( "Simplex", 0, 7 ) - ) ) - { - aRet = DUPLEX_OFF; - } - else - aRet = DUPLEX_ON; - } - } - return aRet; -} - -// ----------------------------------------------------------------------- - int PspSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* ) { return 900; @@ -762,6 +760,37 @@ BOOL PspSalInfoPrinter::SetData( if( nSetDataFlags & SAL_JOBSET_ORIENTATION ) aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait; + // merge duplex if necessary + if( nSetDataFlags & SAL_JOBSET_DUPLEXMODE ) + { + pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) ); + if( pKey ) + { + pValue = NULL; + switch( pJobSetup->meDuplexMode ) + { + case DUPLEX_OFF: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) ); + if( pValue == NULL ) + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "SimplexNoTumble" ) ) ); + break; + case DUPLEX_SHORTEDGE: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexTumble" ) ) ); + break; + case DUPLEX_LONGEDGE: + pValue = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "DuplexNoTumble" ) ) ); + break; + case DUPLEX_UNKNOWN: + default: + pValue = 0; + break; + } + if( ! pValue ) + pValue = pKey->getDefaultValue(); + aData.m_aContext.setValue( pKey, pValue ); + } + } + m_aJobData = aData; copyJobDataToJobSetup( pJobSetup, aData ); return TRUE; @@ -866,6 +895,8 @@ ULONG PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT return 0; case PRINTER_CAPABILITIES_SETORIENTATION: return 1; + case PRINTER_CAPABILITIES_SETDUPLEX: + return 1; case PRINTER_CAPABILITIES_SETPAPERBIN: return 1; case PRINTER_CAPABILITIES_SETPAPERSIZE: diff --git a/vcl/win/inc/salprn.h b/vcl/win/inc/salprn.h index 58d721fd043a..09473cf518e0 100644 --- a/vcl/win/inc/salprn.h +++ b/vcl/win/inc/salprn.h @@ -88,7 +88,6 @@ public: virtual String GetPaperBinName( const ImplJobSetup* pSetupData, ULONG nPaperBin ); virtual void InitPaperFormats( const ImplJobSetup* pSetupData ); virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ); - virtual DuplexMode GetDuplexMode( const ImplJobSetup* pSetupData ); }; // ----------------- diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx index cc359da97cd9..f18c888b067c 100644 --- a/vcl/win/source/gdi/salprn.cxx +++ b/vcl/win/source/gdi/salprn.cxx @@ -923,6 +923,21 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS break; } } + + if( nFlags & SAL_JOBSET_DUPLEXMODE ) + { + DuplexMode eDuplex = DUPLEX_UNKNOWN; + if( (CHOOSE_DEVMODE(dmFields) & DM_DUPLEX) ) + { + if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_SIMPLEX ) + eDuplex = DUPLEX_OFF; + else if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_VERTICAL ) + eDuplex = DUPLEX_LONGEDGE; + else if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_HORIZONTAL ) + eDuplex = DUPLEX_SHORTEDGE; + } + pSetupData->meDuplexMode = eDuplex; + } } // ----------------------------------------------------------------------- @@ -1075,6 +1090,26 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS } } } + if( (nFlags & SAL_JOBSET_DUPLEXMODE) ) + { + switch( pSetupData->meDuplexMode ) + { + case DUPLEX_OFF: + CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX; + CHOOSE_DEVMODE(dmDuplex) = DMDUP_SIMPLEX; + break; + case DUPLEX_SHORTEDGE: + CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX; + CHOOSE_DEVMODE(dmDuplex) = DMDUP_HORIZONTAL; + break; + case DUPLEX_LONGEDGE: + CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX; + CHOOSE_DEVMODE(dmDuplex) = DMDUP_VERTICAL; + break; + case DUPLEX_UNKNOWN: + break; + } + } } // ----------------------------------------------------------------------- @@ -1316,39 +1351,6 @@ void WinSalInfoPrinter::InitPaperFormats( const ImplJobSetup* pSetupData ) // ----------------------------------------------------------------------- -DuplexMode WinSalInfoPrinter::GetDuplexMode( const ImplJobSetup* pSetupData ) -{ - DuplexMode nRet = DUPLEX_UNKNOWN; - if ( pSetupData &&pSetupData->mpDriverData ) - { - if( aSalShlData.mbWPrinter ) - { - DEVMODEW* pDevMode = SAL_DEVMODE_W( pSetupData ); - if ( pDevMode && (pDevMode->dmFields & DM_DUPLEX )) - { - if ( pDevMode->dmDuplex == DMDUP_SIMPLEX ) - nRet = DUPLEX_OFF; - else - nRet = DUPLEX_ON; - } - } - else - { - DEVMODEA* pDevMode = SAL_DEVMODE_A( pSetupData ); - if ( pDevMode && (pDevMode->dmFields & DM_DUPLEX )) - { - if ( pDevMode->dmDuplex == DMDUP_SIMPLEX ) - nRet = DUPLEX_OFF; - else - nRet = DUPLEX_ON; - } - } - } - return nRet; -} - -// ----------------------------------------------------------------------- - int WinSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* pSetupData ) { int nRet = ImplDeviceCaps( this, DC_ORIENTATION, NULL, pSetupData ); From efea6413054936f812fb0bceeca97ed8e199aa6d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 29 May 2009 14:45:00 +0000 Subject: [PATCH 076/283] filter out group for internal dialog --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index ed16df90af80..5499a5e7cc96 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -300,6 +300,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSRect aViewFrame = { { 0, 0 }, {400, 400 } }; NSSize aMaxTabSize = { 0, 0 }; NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aViewFrame]; + sal_Bool bIgnoreSubgroup = sal_False; for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -312,6 +313,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + sal_Bool bIgnore = sal_False; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -341,6 +343,10 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rEntry.Value >>= bValue; bEnabled = bValue; } + else if( rEntry.Name.equalsAscii( "InternalUIOnly" ) ) + { + rEntry.Value >>= bIgnore; + } } if( aCtrlType.equalsAscii( "Group" ) || @@ -374,6 +380,10 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) { + bIgnoreSubgroup = bIgnore; + if( bIgnore ) + continue; + NSString* pText = CreateNSString( aText ); NSRect aTextRect = { { 0, 0 }, { 300, 15 } }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; @@ -398,6 +408,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // cleanup [pText release]; } + else if( bIgnoreSubgroup || bIgnore ) + continue; else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { NSString* pText = CreateNSString( aText ); @@ -480,6 +492,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { NSCell* pCell = [pCells objectAtIndex: m]; + filterAccelerator( aChoices[m] ); NSString* pTitle = CreateNSString( aChoices[m] ); [pCell setTitle: pTitle]; // connect target and action From 91975f770557199dd1760ba024bff68e271749fd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 29 May 2009 14:58:05 +0000 Subject: [PATCH 077/283] correct restarting --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 1 - vcl/aqua/source/gdi/salprn.cxx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 5499a5e7cc96..7c6fa970b316 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -517,7 +517,6 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // update nCurY nCurY = aRadioRect.origin.y - 5; - [pProto release]; } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index de7e5200b8af..3d86e0b6f0ad 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -607,7 +607,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, mnCurPageRangeStart += mnCurPageRangeCount; mnCurPageRangeCount = 1; - } while( bNeedRestart && mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); + } while( bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); // inform applictation that it can release its data // this is awkward, but the XRenderable interface has no method for this, From 8db120c45b673dbfee37f8731437800425517485 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 2 Jun 2009 11:37:36 +0000 Subject: [PATCH 078/283] #i92516# persistency for print dialog --- vcl/inc/vcl/configsettings.hxx | 3 +- vcl/inc/vcl/prndlg.hxx | 8 ++ vcl/source/window/printdlg.cxx | 155 +++++++++++++++++++++++++++++++-- 3 files changed, 156 insertions(+), 10 deletions(-) diff --git a/vcl/inc/vcl/configsettings.hxx b/vcl/inc/vcl/configsettings.hxx index aee684a84ca4..211ea3f0892b 100644 --- a/vcl/inc/vcl/configsettings.hxx +++ b/vcl/inc/vcl/configsettings.hxx @@ -54,7 +54,6 @@ namespace vcl std::hash_map< rtl::OUString, SmallOUStrMap, rtl::OUStringHash > m_aSettings; virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames ); - virtual void Commit(); void getValues(); SettingsConfigItem(); @@ -65,6 +64,8 @@ namespace vcl const rtl::OUString& getValue( const rtl::OUString& rGroup, const rtl::OUString& rKey ) const; void setValue( const rtl::OUString& rGroup, const rtl::OUString& rKey, const rtl::OUString& rValue ); + + virtual void Commit(); }; //........................................................................ diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 408ec46b2aff..4e7302f112c0 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -91,6 +91,9 @@ namespace vcl PrinterTabPage( Window*, const ResId& ); virtual ~PrinterTabPage(); + + void readFromSettings(); + void storeToSettings(); }; class JobTabPage : public TabPage @@ -112,6 +115,9 @@ namespace vcl JobTabPage( Window*, const ResId& ); virtual ~JobTabPage(); + + void readFromSettings(); + void storeToSettings(); }; OKButton maOKButton; @@ -150,6 +156,8 @@ namespace vcl void checkControlDependencies(); void checkOptionalControlDependencies(); void setupOptionalUI(); + void readFromSettings(); + void storeToSettings(); com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; virtual void Resize(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f4164b3a66a6..fea99791c113 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -41,6 +41,7 @@ #include "vcl/status.hxx" #include "vcl/decoview.hxx" #include "vcl/arrange.hxx" +#include "vcl/configsettings.hxx" #include "rtl/ustrbuf.hxx" @@ -141,6 +142,43 @@ PrintDialog::PrinterTabPage::~PrinterTabPage() { } +void PrintDialog::PrinterTabPage::readFromSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + rtl::OUString aValue; + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ) ); + sal_Int32 nVal = aValue.toInt32(); + maNupRowsEdt.SetValue( sal_Int64( nVal > 1 ? nVal : 1) ); + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ) ); + nVal = aValue.toInt32(); + maNupColEdt.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ) ); + if( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ) + maNupPortrait.Check(); + else + maNupLandscape.Check(); +} + +void PrintDialog::PrinterTabPage::storeToSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ), + maNupRowsEdt.GetText() ); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ), + maNupColEdt.GetText() ); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ), + rtl::OUString::createFromAscii( maNupPortrait.IsChecked() ? "true" : "false" ) ); +} + PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) @@ -169,6 +207,39 @@ PrintDialog::JobTabPage::~JobTabPage() { } +void PrintDialog::JobTabPage::readFromSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + rtl::OUString aValue; + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); + maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Copies" ) ) ); + sal_Int32 nVal = aValue.toInt32(); + maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); + maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); +} + +void PrintDialog::JobTabPage::storeToSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), + rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Copies" ) ), + maCopyCountField.GetText() ); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), + rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) ); +} + PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rListener ) : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) , maOKButton( this, VclResId( SV_PRINT_OK ) ) @@ -220,10 +291,23 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); + // fall back to last printer + SettingsConfigItem* pItem = SettingsConfigItem::get(); + String aValue( pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ) ) ); + if( maPrinterPage.maPrinters.GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND ) + { + maPrinterPage.maPrinters.SelectEntry( aValue ); + maJobPage.maPrinters.SelectEntry( aValue ); + maPListener->setPrinter( boost::shared_ptr( new Printer( aValue ) ) ); + } + else + { + // fall back to default printer + maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); + maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); + maPListener->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); + } } // update the text fields for the printer updatePrinterText(); @@ -249,6 +333,10 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr 1 + maCancelButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + #endif maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maPrinterPage.maNupPortrait.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); @@ -268,6 +356,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ) ); + USHORT nCount = maTabCtrl.GetPageCount(); + for( USHORT i = 0; i < nCount; i++ ) + { + USHORT nPageId = maTabCtrl.GetPageId( i ); + if( aValue.equals( maTabCtrl.GetPageText( nPageId ) ) ) + { + maTabCtrl.SelectTabPage( nPageId ); + break; + } + } +} + +void PrintDialog::storeToSettings() +{ + maJobPage.storeToSettings(); + maPrinterPage.storeToSettings(); + + // store last selected printer + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ), + maJobPage.maPrinters.GetSelectEntry() ); + + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPage" ) ), + maTabCtrl.GetPageText( maTabCtrl.GetCurPageId() ) ); + pItem->Commit(); +} + bool PrintDialog::isPrintToFile() { return maJobPage.maToFileBox.IsChecked(); @@ -966,13 +1095,21 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { - if( pButton == &maPrinterPage.maSetupButton ) + if( pButton == &maOKButton || pButton == &maCancelButton ) { - maPListener->getPrinter()->Setup( this ); + storeToSettings(); + EndDialog( pButton == &maOKButton ); + } + else + { + if( pButton == &maPrinterPage.maSetupButton ) + { + maPListener->getPrinter()->Setup( this ); + } + checkControlDependencies(); + if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape ) + updateNup(); } - checkControlDependencies(); - if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape ) - updateNup(); return 0; } From c8e7522755016b630edeac9b7ba4e41a7e74d997 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 2 Jun 2009 13:23:25 +0000 Subject: [PATCH 079/283] #i92516# restart on correct page --- vcl/aqua/inc/aquaprintview.h | 11 ++++- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 42 ++++++++++++------- vcl/aqua/source/gdi/salprn.cxx | 12 +++--- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/vcl/aqua/inc/aquaprintview.h b/vcl/aqua/inc/aquaprintview.h index 15b0fd3751ce..a3984333f84e 100755 --- a/vcl/aqua/inc/aquaprintview.h +++ b/vcl/aqua/inc/aquaprintview.h @@ -40,6 +40,15 @@ class AquaSalInfoPrinter; namespace vcl { class PrinterListener; } +struct PrintAccessoryViewState +{ + bool bNeedRestart; + sal_Int32 nLastPage; + + PrintAccessoryViewState() + : bNeedRestart( false ), nLastPage( 0 ) {} +}; + @interface AquaPrintView : NSView { vcl::PrinterListener* mpListener; @@ -55,7 +64,7 @@ namespace vcl { class PrinterListener; } @interface AquaPrintAccessoryView : NSObject { } -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withRestartCondition: (bool*)pbRestart; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withState: (PrintAccessoryViewState*)pState; @end diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 7c6fa970b316..f5196b369658 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -56,18 +56,23 @@ class ListenerProperties std::vector< NSObject* > maViews; int mnNextTag; sal_Int32 mnLastPageCount; - bool* mpNeedRestart; + PrintAccessoryViewState* mpState; NSPrintOperation* mpOp; + NSTabView* mpTabView; public: - ListenerProperties( vcl::PrinterListener* i_pListener, NSPrintOperation* i_pOp, bool* i_pNeedRestart ) + ListenerProperties( vcl::PrinterListener* i_pListener, + NSPrintOperation* i_pOp, + NSTabView* i_pTabView, + PrintAccessoryViewState* i_pState ) : mpListener( i_pListener ), mnNextTag( 0 ), mnLastPageCount( i_pListener->getPageCount() ), - mpNeedRestart( i_pNeedRestart ), - mpOp( i_pOp ) + mpState( i_pState ), + mpOp( i_pOp ), + mpTabView( i_pTabView ) { - *mpNeedRestart = false; + mpState->bNeedRestart = false; } void updatePrintJob() @@ -80,9 +85,14 @@ class ListenerProperties if( nPages != mnLastPageCount ) fprintf( stderr, "trouble: number of pages changed from %ld to %ld !\n", mnLastPageCount, nPages ); #endif - *mpNeedRestart = (nPages != mnLastPageCount); + mpState->bNeedRestart = (nPages != mnLastPageCount); + NSTabViewItem* pItem = [mpTabView selectedTabViewItem]; + if( pItem ) + mpState->nLastPage = [mpTabView indexOfTabViewItem: pItem]; + else + mpState->nLastPage = 0; mnLastPageCount = nPages; - if( *mpNeedRestart ) + if( mpState->bNeedRestart ) { // Warning: bad hack ahead // Apple does not give as a chance of changing the page count, @@ -285,15 +295,12 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) } @implementation AquaPrintAccessoryView -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withRestartCondition: (bool*)pbRestart; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withState: (PrintAccessoryViewState*)pState; { const Sequence< PropertyValue >& rOptions( pListener->getUIOptions() ); if( rOptions.getLength() == 0 ) return nil; - ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pbRestart ); - ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; - NSView* pCurParent = 0; long nCurY = 0; long nCurX = 0; @@ -302,6 +309,9 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aViewFrame]; sal_Bool bIgnoreSubgroup = sal_False; + ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pTabView, pState ); + ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; + for( int i = 0; i < rOptions.getLength(); i++ ) { Sequence< beans::PropertyValue > aOptProp; @@ -483,10 +493,10 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) numberOfRows: aChoices.getLength() numberOfColumns: 1]; // get currently selected value - rtl::OUString aSelectVal; + sal_Int32 nSelectVal; PropertyValue* pVal = pListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) - pVal->Value >>= aSelectVal; + pVal->Value >>= nSelectVal; // set individual titles NSArray* pCells = [pMatrix cells]; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) @@ -503,7 +513,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pCell setTag: nTag]; [pTitle release]; // set current selection - if( aSelectVal == aChoices[m] ) + if( nSelectVal == m ) [pMatrix selectCellAtRow: m column: 0]; } [pMatrix sizeToFit]; @@ -616,6 +626,10 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // set the accessory view [pOp setAccessoryView: pTabView]; + + // set the current selecte tab item + if( pState->nLastPage >= 0 && pState->nLastPage < [pTabView numberOfTabViewItems] ) + [pTabView selectTabViewItemAtIndex: pState->nLastPage]; return pCtrlTarget; } diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 3d86e0b6f0ad..944812e1a8ea 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -512,9 +512,11 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, BOOL bSuccess = FALSE; AquaSalInstance* pInst = GetSalData()->mpFirstInstance; - bool bNeedRestart = true; + PrintAccessoryViewState aAccViewState; sal_Int32 nAllPages = 0; + aAccViewState.bNeedRestart = true; + // reset IsLastPage i_rListener.setLastPage( sal_False ); @@ -524,14 +526,14 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, do { - if( bNeedRestart ) + if( aAccViewState.bNeedRestart ) { mnCurPageRangeStart = 0; mnCurPageRangeCount = 0; nAllPages = i_rListener.getPageCount(); } - bNeedRestart = false; + aAccViewState.bNeedRestart = false; Size aCurSize( 21000, 29700 ); if( nAllPages > 0 ) @@ -593,7 +595,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: YES]; if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view - pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withRestartCondition: &bNeedRestart]; + pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withState: &aAccViewState]; bSuccess = TRUE; mbJob = true; @@ -607,7 +609,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, mnCurPageRangeStart += mnCurPageRangeCount; mnCurPageRangeCount = 1; - } while( bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); + } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); // inform applictation that it can release its data // this is awkward, but the XRenderable interface has no method for this, From 30eb643a7daf38348350968b8cbdecbcc0ec0f24 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 2 Jun 2009 16:56:35 +0000 Subject: [PATCH 080/283] #i92516# add missing controls, fix some minor issues --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 256 +++++++++++++++++- 1 file changed, 246 insertions(+), 10 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index f5196b369658..33774ea67d53 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -53,6 +53,7 @@ class ListenerProperties vcl::PrinterListener* mpListener; std::map< int, rtl::OUString > maTagToPropertyName; std::map< int, sal_Int32 > maTagToValueInt; + std::map< NSView*, NSView* > maViewPairMap; std::vector< NSObject* > maViews; int mnNextTag; sal_Int32 mnLastPageCount; @@ -136,6 +137,21 @@ class ListenerProperties maViews.push_back( i_pView ); } + void addViewPair( NSView* i_pLeft, NSView* i_pRight ) + { + maViewPairMap[ i_pLeft ] = i_pRight; + maViewPairMap[ i_pRight ] = i_pLeft; + } + + NSView* getPair( NSView* i_pLeft ) const + { + NSView* pRight = nil; + std::map< NSView*, NSView* >::const_iterator it = maViewPairMap.find( i_pLeft ); + if( it != maViewPairMap.end() ) + pRight = it->second; + return pRight; + } + void changePropertyWithIntValue( int i_nTag ) { std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); @@ -150,6 +166,20 @@ class ListenerProperties } } } + + void changePropertyWithIntValue( int i_nTag, sal_Int64 i_nValue ) + { + std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); + if( name_it != maTagToPropertyName.end() ) + { + PropertyValue* pVal = mpListener->getValue( name_it->second ); + if( pVal ) + { + pVal->Value <<= i_nValue; + updatePrintJob(); + } + } + } void changePropertyWithBoolValue( int i_nTag, sal_Bool i_bValue ) { @@ -165,6 +195,20 @@ class ListenerProperties } } + void changePropertyWithStringValue( int i_nTag, const rtl::OUString& i_rValue ) + { + std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); + if( name_it != maTagToPropertyName.end() ) + { + PropertyValue* pVal = mpListener->getValue( name_it->second ); + if( pVal ) + { + pVal->Value <<= i_rValue; + updatePrintJob(); + } + } + } + void updateEnableState() { for( std::vector< NSObject* >::iterator it = maViews.begin(); it != maViews.end(); ++it ) @@ -186,9 +230,15 @@ class ListenerProperties { MacOSBOOL bEnabled = mpListener->isUIOptionEnabled( name_it->second ) ? YES : NO; if( pCtrl ) + { [pCtrl setEnabled: bEnabled]; + NSView* pOther = getPair( pCtrl ); + if( pOther && [pOther isKindOfClass: [NSControl class]] ) + [(NSControl*)pOther setEnabled: bEnabled]; + } else if( pCell ) [pCell setEnabled: bEnabled]; + } } } @@ -208,6 +258,7 @@ static void filterAccelerator( rtl::OUString& io_rText ) } -(id)initWithListenerMap: (ListenerProperties*)pListener; -(void)triggered:(id)pSender; +-(void)triggeredNumeric:(id)pSender; -(void)dealloc; @end @@ -248,6 +299,45 @@ static void filterAccelerator( rtl::OUString& io_rText ) mpListener->changePropertyWithIntValue( nTag ); } } + else if( [pSender isMemberOfClass: [NSTextField class]] ) + { + NSTextField* pField = (NSTextField*)pSender; + int nTag = [pField tag]; + rtl::OUString aValue = GetOUString( [pSender stringValue] ); + mpListener->changePropertyWithStringValue( nTag, aValue ); + } + else + { + DBG_ERROR( "unsupported class" ); + } + mpListener->updateEnableState(); +} +-(void)triggeredNumeric:(id)pSender; +{ + if( [pSender isMemberOfClass: [NSTextField class]] ) + { + NSTextField* pField = (NSTextField*)pSender; + int nTag = [pField tag]; + sal_Int64 nValue = [pField intValue]; + + NSView* pOther = mpListener->getPair( pField ); + if( pOther ) + [(NSControl*)pOther setIntValue: nValue]; + + mpListener->changePropertyWithIntValue( nTag, nValue ); + } + else if( [pSender isMemberOfClass: [NSStepper class]] ) + { + NSStepper* pStep = (NSStepper*)pSender; + int nTag = [pStep tag]; + sal_Int64 nValue = [pStep intValue]; + + NSView* pOther = mpListener->getPair( pStep ); + if( pOther ) + [(NSControl*)pOther setIntValue: nValue]; + + mpListener->changePropertyWithIntValue( nTag, nValue ); + } else { DBG_ERROR( "unsupported class" ); @@ -323,6 +413,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rtl::OUString aText; rtl::OUString aPropertyName; Sequence< rtl::OUString > aChoices; + sal_Int64 nMinValue = 0, nMaxValue = 0; + long nAttachOffset = 0; sal_Bool bIgnore = sal_False; for( int n = 0; n < aOptProp.getLength(); n++ ) @@ -353,6 +445,18 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rEntry.Value >>= bValue; bEnabled = bValue; } + else if( rEntry.Name.equalsAscii( "MinValue" ) ) + { + rEntry.Value >>= nMinValue; + } + else if( rEntry.Name.equalsAscii( "MaxValue" ) ) + { + rEntry.Value >>= nMaxValue; + } + else if( rEntry.Name.equalsAscii( "AttachToDependency" ) ) + { + nAttachOffset = 20; + } else if( rEntry.Name.equalsAscii( "InternalUIOnly" ) ) { rEntry.Value >>= bIgnore; @@ -363,6 +467,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aCtrlType.equalsAscii( "Subgroup" ) || aCtrlType.equalsAscii( "Radio" ) || aCtrlType.equalsAscii( "List" ) || + aCtrlType.equalsAscii( "Edit" ) || + aCtrlType.equalsAscii( "Range" ) || aCtrlType.equalsAscii( "Bool" ) ) { // since our build target is MacOSX 10.4 we can have only one accessory view @@ -412,9 +518,6 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // update nCurY nCurY = aTextRect.origin.y - 5; - // set indent - nCurX = 20; - // cleanup [pText release]; } @@ -423,7 +526,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { NSString* pText = CreateNSString( aText ); - NSRect aCheckRect = { { nCurX, 0 }, { 0, 15 } }; + NSRect aCheckRect = { { nCurX + nAttachOffset, 0 }, { 0, 15 } }; NSButton* pBtn = [[NSButton alloc] initWithFrame: aCheckRect]; [pBtn setButtonType: NSSwitchButton]; [pBtn setTitle: pText]; @@ -432,7 +535,6 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) if( pVal ) pVal->Value >>= bVal; [pBtn setState: bVal ? NSOnState : NSOffState]; - [pBtn setEnabled: (pListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL) ? YES : NO]; [pBtn sizeToFit]; [pCurParent addSubview: pBtn]; @@ -457,11 +559,12 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { + sal_Int32 nOff = 0; if( aText.getLength() ) { // add a label NSString* pText = CreateNSString( aText ); - NSRect aTextRect = { { nCurX, 0 }, { 300, 15 } }; + NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, { 300, 15 } }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; @@ -477,6 +580,9 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // update nCurY nCurY = aTextRect.origin.y - 5; + // indent the radio group relative to the text + // nOff = 20; + // cleanup [pText release]; } @@ -484,7 +590,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // setup radio matrix NSButtonCell* pProto = [[NSButtonCell alloc] init]; - NSRect aRadioRect = { { nCurX + 20, 0 }, { 280 - nCurX, 5*aChoices.getLength() } }; + NSRect aRadioRect = { { nCurX + nOff, 0 }, { 280 - nCurX, 5*aChoices.getLength() } }; [pProto setTitle: @"RadioButtonGroup"]; [pProto setButtonType: NSRadioButton]; NSMatrix* pMatrix = [[NSMatrix alloc] initWithFrame: aRadioRect @@ -548,7 +654,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // will have to suffice for the time being. aTextSize.width *= 1.5; aTextSize.height += 3; - NSRect aTextRect = { { nCurX, 0 }, aTextSize }; + NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; @@ -561,7 +667,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aTextRect = [pTextView frame]; - NSRect aBtnRect = { { nCurX + aTextRect.size.width, 0 }, { 0, 15 } }; + NSRect aBtnRect = { { nCurX + nAttachOffset + aTextRect.size.width, 0 }, { 0, 15 } }; NSPopUpButton* pBtn = [[NSPopUpButton alloc] initWithFrame: aBtnRect pullsDown: NO]; // iterate options @@ -580,7 +686,6 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aSelectVal; [pBtn selectItemAtIndex: aSelectVal]; - [pBtn setEnabled: (pListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL) ? YES : NO]; // add the button to observed controls for enabled state changes // also add a tag just for this purpose @@ -609,12 +714,143 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // cleanup [pText release]; } + else if( (aCtrlType.equalsAscii( "Edit" ) || aCtrlType.equalsAscii( "Range" )) && pCurParent ) + { + sal_Int32 nOff = 0; + if( aText.getLength() ) + { + // add a label + NSString* pText = CreateNSString( aText ); + NSFont* pFont = [NSFont labelFontOfSize: 0]; + NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont + forKey: NSFontAttributeName]; + + NSSize aTextSize = [pText sizeWithAttributes: pDict]; + // FIXME: the only thing reliable about sizeWithAttributes is + // that the size it outputs is way too small for our NSTextView + // that would not matter so much if NSTextView's fitToSize actually + // did something out of the box, alas it doesn't. This probably needs more + // fiddling with NSTextView's and NSTextContainer's parameters, however + // since this already almost cost me my sanity a Murphy factor of 1.5 + // will have to suffice for the time being. + aTextSize.width *= 1.5; + aTextSize.height += 3; + NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; + NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setEditable: NO]; + [pTextView setSelectable: NO]; + [pTextView setDrawsBackground: NO]; + [pTextView setString: pText]; + [pTextView sizeToFit]; // FIXME: this does nothing + [pCurParent addSubview: pTextView]; + + // move to nCurY + aTextRect.origin.y = nCurY - aTextRect.size.height; + [pTextView setFrame: aTextRect]; + + // update nCurY + nCurY = aTextRect.origin.y - 5; + + // and set the offset for the real edit field + nOff = aTextSize.width + 5; + + // cleanup + [pText release]; + } + + NSRect aFieldRect = { { nCurX + nOff + nAttachOffset, 0 }, { 100, 25 } }; + NSTextField* pFieldView = [[NSTextField alloc] initWithFrame: aFieldRect]; + [pFieldView setEditable: YES]; + [pFieldView setSelectable: YES]; + [pFieldView setDrawsBackground: YES]; + [pFieldView sizeToFit]; // FIXME: this does nothing + [pCurParent addSubview: pFieldView]; + + // add the field to observed controls for enabled state changes + // also add a tag just for this purpose + pListenerProperties->addObservedControl( pFieldView ); + int nTag = pListenerProperties->addNameTag( aPropertyName ); + [pFieldView setTag: nTag]; + // pListenerProperties->addNamedView( pFieldView, aPropertyName ); + + // move to nCurY + aFieldRect.origin.y = nCurY - aFieldRect.size.height; + [pFieldView setFrame: aFieldRect]; + + // current value + PropertyValue* pVal = pListener->getValue( aPropertyName ); + if( aCtrlType.equalsAscii( "Range" ) ) + { + // add a stepper control + NSRect aStepFrame = { { aFieldRect.origin.x + aFieldRect.size.width + 5, + aFieldRect.origin.y }, + { 15, aFieldRect.size.height } }; + NSStepper* pStep = [[NSStepper alloc] initWithFrame: aStepFrame]; + [pStep setIncrement: 1]; + [pStep setValueWraps: NO]; + [pStep setTag: nTag]; + [pCurParent addSubview: pStep]; + pListenerProperties->addObservedControl( pStep ); + [pStep setTarget: pCtrlTarget]; + [pStep setAction: @selector(triggered:)]; + + // constrain the text field to decimal numbers + NSNumberFormatter* pFormatter = [[NSNumberFormatter alloc] init]; + [pFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; + [pFormatter setAllowsFloats: NO]; + if( nMinValue != nMaxValue ) + { + [pFormatter setMinimum: [[NSNumber numberWithInt: nMinValue] autorelease]]; + [pStep setMinValue: nMinValue]; + [pFormatter setMaximum: [[NSNumber numberWithInt: nMaxValue] autorelease]]; + [pStep setMaxValue: nMaxValue]; + } + [pFieldView setFormatter: pFormatter]; + + sal_Int64 nSelectVal = 0; + if( pVal && pVal->Value.hasValue() ) + pVal->Value >>= nSelectVal; + + [pFieldView setIntValue: nSelectVal]; + [pStep setIntValue: nSelectVal]; + + pListenerProperties->addViewPair( pFieldView, pStep ); + // connect target and action + [pFieldView setTarget: pCtrlTarget]; + [pFieldView setAction: @selector(triggeredNumeric:)]; + [pStep setTarget: pCtrlTarget]; + [pStep setAction: @selector(triggeredNumeric:)]; + } + else + { + // connect target and action + [pFieldView setTarget: pCtrlTarget]; + [pFieldView setAction: @selector(triggered:)]; + + if( pVal && pVal->Value.hasValue() ) + { + rtl::OUString aValue; + pVal->Value >>= aValue; + if( aValue.getLength() ) + { + NSString* pText = CreateNSString( aValue ); + [pFieldView setStringValue: pText]; + [pText release]; + } + } + } + + // update nCurY + nCurY = aFieldRect.origin.y - 5; + + } } else { DBG_ERROR( "Unsupported UI option" ); } } + pListenerProperties->updateEnableState(); adjustViewAndChildren( pCurParent, aMaxTabSize ); // find the minimum needed tab size From 457e3281821544b84b8328590b5ca407750031dc Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 3 Jun 2009 14:41:23 +0000 Subject: [PATCH 081/283] #i92516# enable WB_DROPDOWN on TabControl --- rsc/source/parser/rscicpx.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx index e69094064754..bced7f36c3b6 100644 --- a/rsc/source/parser/rscicpx.cxx +++ b/rsc/source/parser/rscicpx.cxx @@ -2279,6 +2279,7 @@ RscTop * RscTypCont::InitClassTabControl( RscTop * pSuper, RSC_TABCONTROL_ITEMLIST ); INS_WINBIT( pClassTabControl, SingleLine ); + INS_WINBIT( pClassTabControl, DropDown ); } return pClassTabControl; From 07c9e528cb418b3c722342d5548e49650d7852ef Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 3 Jun 2009 14:43:17 +0000 Subject: [PATCH 082/283] #i92516# enable WB_DROPDOWN on TabControl --- vcl/inc/vcl/lstbox.h | 5 ++ vcl/inc/vcl/tabctrl.hxx | 8 ++- vcl/source/control/ilstbox.cxx | 2 + vcl/source/control/lstbox.cxx | 18 ++++- vcl/source/control/tabctrl.cxx | 117 ++++++++++++++++++++++++++++----- 5 files changed, 128 insertions(+), 22 deletions(-) diff --git a/vcl/inc/vcl/lstbox.h b/vcl/inc/vcl/lstbox.h index 6097422b556b..9b95b9526d58 100644 --- a/vcl/inc/vcl/lstbox.h +++ b/vcl/inc/vcl/lstbox.h @@ -60,4 +60,9 @@ */ #define LISTBOX_ENTRY_FLAG_MULTILINE 0x0000002 +/** this flags lets the item be drawn disabled (e.g. in grey text) + usage only guaranteed with LISTBOX_ENTRY_FLAG_DISABLE_SELECTION +*/ +#define LISTBOX_ENTRY_FLAG_DRAW_DISABLED 0x0000004 + #endif // _SV_LSTBOX_H diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index b12d33d579a3..cfe40a25a7f2 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -31,15 +31,16 @@ #ifndef _SV_TABCTRL_HXX #define _SV_TABCTRL_HXX -#include -#include -#include +#include "vcl/sv.h" +#include "vcl/dllapi.h" +#include "vcl/ctrl.hxx" struct ImplTabItem; struct ImplTabCtrlData; class ImplTabItemList; class TabPage; class PushButton; +class ListBox; // -------------------- // - TabControl-Types - @@ -92,6 +93,7 @@ private: SAL_DLLPRIVATE void ImplPaint( const Rectangle& rRect, bool bLayout = false ); SAL_DLLPRIVATE void ImplFreeLayoutData(); DECL_DLLPRIVATE_LINK( ImplScrollBtnHdl, PushButton* pBtn ); + DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox* ); protected: using Window::ImplInit; diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index a25ddbb68e8b..b3fed3ee7a05 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -1873,6 +1873,8 @@ void ImplListBoxWindow::DrawEntry( USHORT nPos, BOOL bDrawImage, BOOL bDrawText, USHORT nDrawStyle = ImplGetTextStyle(); if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) ) nDrawStyle |= MULTILINE_ENTRY_DRAW_FLAGS; + if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_DRAW_DISABLED) ) + nDrawStyle |= TEXT_DRAW_DISABLE; DrawText( aTextRect, aStr, nDrawStyle, pVector, pDisplayText ); } diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 0accd17489c9..efb44a369df9 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1267,7 +1267,23 @@ Size ListBox::CalcMinimumSize() const { aSz.Height() = mpImplLB->CalcSize( 1 ).Height(); aSz.Width() = mpImplLB->GetMaxEntryWidth(); - aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize(); + + // try native borders; scrollbar size may not be a good indicator + // see how large the edit area inside is to estimate what is needed for the dropdown + ImplControlValue aControlValue; + Point aPoint; + Region aContent, aBound; + Size aTestSize( 100, 20 ); + Region aArea( Rectangle( aPoint, aTestSize ) ); + if( const_cast(this)->GetNativeControlRegion( + CTRL_LISTBOX, PART_SUB_EDIT, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) ) + { + // use the themes drop down size + Rectangle aContentRect = aContent.GetBoundRect(); + aSz.Width() += aTestSize.Width() - aContentRect.GetWidth(); + } + else + aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize(); } aSz = CalcWindowSize( aSz ); diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 561d550b1168..9ff3e4f5a728 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -87,6 +88,7 @@ struct ImplTabCtrlData std::vector< Rectangle > maTabRectangles; Point maItemsOffset; // offset of the tabitems std::vector< ImplTabItem > maItemList; + ListBox* mpListBox; }; // ----------------------------------------------------------------------- @@ -159,10 +161,19 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) mpTabCtrlData = new ImplTabCtrlData; mpTabCtrlData->mpLeftBtn = NULL; mpTabCtrlData->mpRightBtn = NULL; + mpTabCtrlData->mpListBox = NULL; ImplInitSettings( TRUE, TRUE, TRUE ); + if( (nStyle & WB_DROPDOWN) ) + { + mpTabCtrlData->mpListBox = new ListBox( this, WB_DROPDOWN ); + mpTabCtrlData->mpListBox->SetPosSizePixel( Point( 0, 0 ), Size( 200, 20 ) ); + mpTabCtrlData->mpListBox->SetSelectHdl( LINK( this, TabControl, ImplListBoxSelectHdl ) ); + mpTabCtrlData->mpListBox->Show(); + } + // if the tabcontrol is drawn (ie filled) by a native widget, make sure all contols will have transparent background // otherwise they will paint with a wrong background if( IsNativeControlSupported(CTRL_TAB_PANE, PART_ENTIRE_CONTROL) ) @@ -292,6 +303,8 @@ TabControl::~TabControl() // TabCtrl-Daten loeschen if ( mpTabCtrlData ) { + if( mpTabCtrlData->mpListBox ) + delete mpTabCtrlData->mpListBox; if ( mpTabCtrlData->mpLeftBtn ) delete mpTabCtrlData->mpLeftBtn; if ( mpTabCtrlData->mpRightBtn ) @@ -797,7 +810,7 @@ void TabControl::ImplSetFirstPagePos( USHORT ) void TabControl::ImplShowFocus() { - if ( !GetPageCount() ) + if ( !GetPageCount() || mpTabCtrlData->mpListBox ) return; // make sure the focussed item rect is computed using a bold font @@ -1068,16 +1081,27 @@ IMPL_LINK( TabControl, ImplScrollBtnHdl, PushButton*, EMPTYARG ) // ----------------------------------------------------------------------- +IMPL_LINK( TabControl, ImplListBoxSelectHdl, ListBox*, EMPTYARG ) +{ + SelectTabPage( GetPageId( mpTabCtrlData->mpListBox->GetSelectEntryPos() ) ); + return 0; +} + +// ----------------------------------------------------------------------- + void TabControl::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() ) + if( mpTabCtrlData->mpListBox == NULL ) { - USHORT nPageId = GetPageId( rMEvt.GetPosPixel() ); - ImplTabItem* pItem = ImplGetItem( nPageId ); - if( pItem && pItem->mbEnabled ) - SelectTabPage( nPageId ); - else - Sound::Beep( SOUND_ERROR, this ); + if( rMEvt.IsLeft() ) + { + USHORT nPageId = GetPageId( rMEvt.GetPosPixel() ); + ImplTabItem* pItem = ImplGetItem( nPageId ); + if( pItem && pItem->mbEnabled ) + SelectTabPage( nPageId ); + else + Sound::Beep( SOUND_ERROR, this ); + } } } @@ -1085,7 +1109,9 @@ void TabControl::MouseButtonDown( const MouseEvent& rMEvt ) void TabControl::KeyInput( const KeyEvent& rKEvt ) { - if ( GetPageCount() > 1 ) + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->KeyInput( rKEvt ); + else if ( GetPageCount() > 1 ) { KeyCode aKeyCode = rKEvt.GetKeyCode(); USHORT nKeyCode = aKeyCode.GetCode(); @@ -1230,7 +1256,7 @@ void TabControl::ImplPaint( const Rectangle& rRect, bool bLayout ) } } - if ( !mpTabCtrlData->maItemList.empty() ) + if ( !mpTabCtrlData->maItemList.empty() && mpTabCtrlData->mpListBox == NULL ) { // Some native toolkits (GTK+) draw tabs right-to-left, with an // overlap between adjacent tabs @@ -1300,6 +1326,18 @@ void TabControl::Resize() if ( !IsReallyShown() ) return; + if( mpTabCtrlData->mpListBox ) + { + // get the listbox' preferred size + Size aTabCtrlSize( GetSizePixel() ); + long nPrefWidth = mpTabCtrlData->mpListBox->GetOptimalSize( WINDOWSIZE_PREFERRED ).Width(); + if( nPrefWidth > aTabCtrlSize.Width() ) + nPrefWidth = aTabCtrlSize.Width(); + Size aNewSize( nPrefWidth, LogicToPixel( Size( 12, 12 ), MapMode( MAP_APPFONT ) ).Height() ); + Point aNewPos( (aTabCtrlSize.Width() - nPrefWidth) / 2, 0 ); + mpTabCtrlData->mpListBox->SetPosSizePixel( aNewPos, aNewSize ); + } + mbFormat = TRUE; // Aktuelle TabPage resizen/positionieren @@ -1349,8 +1387,16 @@ void TabControl::Resize() void TabControl::GetFocus() { - ImplShowFocus(); - SetInputContext( InputContext( GetFont() ) ); + if( ! mpTabCtrlData->mpListBox ) + { + ImplShowFocus(); + SetInputContext( InputContext( GetFont() ) ); + } + else + { + if( mpTabCtrlData->mpListBox->IsReallyVisible() ) + mpTabCtrlData->mpListBox->GrabFocus(); + } Control::GetFocus(); } @@ -1358,7 +1404,8 @@ void TabControl::GetFocus() void TabControl::LoseFocus() { - HideFocus(); + if( ! mpTabCtrlData->mpListBox ) + HideFocus(); Control::LoseFocus(); } @@ -1452,7 +1499,7 @@ void TabControl::RequestHelp( const HelpEvent& rHEvt ) void TabControl::Command( const CommandEvent& rCEvt ) { - if ( (rCEvt.GetCommand() == COMMAND_CONTEXTMENU) && (GetPageCount() > 1) ) + if( (mpTabCtrlData->mpListBox == NULL) && (rCEvt.GetCommand() == COMMAND_CONTEXTMENU) && (GetPageCount() > 1) ) { Point aMenuPos; BOOL bMenu; @@ -1496,7 +1543,11 @@ void TabControl::StateChanged( StateChangedType nType ) Control::StateChanged( nType ); if ( nType == STATE_CHANGE_INITSHOW ) + { ImplPosCurTabPage(); + if( mpTabCtrlData->mpListBox ) + Resize(); + } else if ( nType == STATE_CHANGE_UPDATEMODE ) { if ( IsUpdateMode() ) @@ -1714,23 +1765,33 @@ void TabControl::InsertPage( USHORT nPageId, const XubString& rText, DBG_ASSERT( GetPagePos( nPageId ) == TAB_PAGE_NOTFOUND, "TabControl::InsertPage(): PageId already exists" ); - // set current page id - if ( !mnCurPageId ) - mnCurPageId = nPageId; - // insert new page item ImplTabItem* pItem = NULL; if( nPos == TAB_APPEND || size_t(nPos) >= mpTabCtrlData->maItemList.size() ) { mpTabCtrlData->maItemList.push_back( ImplTabItem() ); pItem = &mpTabCtrlData->maItemList.back(); + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->InsertEntry( rText ); } else { std::vector< ImplTabItem >::iterator new_it = mpTabCtrlData->maItemList.insert( mpTabCtrlData->maItemList.begin() + nPos, ImplTabItem() ); pItem = &(*new_it); + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->InsertEntry( rText, nPos); } + if( mpTabCtrlData->mpListBox ) + { + if( ! mnCurPageId ) + mpTabCtrlData->mpListBox->SelectEntryPos( 0 ); + mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() ); + } + + // set current page id + if ( !mnCurPageId ) + mnCurPageId = nPageId; // init new page item pItem->mnId = nPageId; @@ -1745,6 +1806,8 @@ void TabControl::InsertPage( USHORT nPageId, const XubString& rText, Invalidate(); ImplFreeLayoutData(); + if( mpTabCtrlData->mpListBox ) // reposition/resize listbox + Resize(); ImplCallEventListeners( VCLEVENT_TABPAGE_INSERTED, (void*) (ULONG)nPageId ); } @@ -1762,6 +1825,11 @@ void TabControl::RemovePage( USHORT nPageId ) std::vector< ImplTabItem >::iterator it = mpTabCtrlData->maItemList.begin() + nPos; bool bIsCurrentPage = (it->mnId == mnCurPageId); mpTabCtrlData->maItemList.erase( it ); + if( mpTabCtrlData->mpListBox ) + { + mpTabCtrlData->mpListBox->RemoveEntry( nPos ); + mpTabCtrlData->mpListBox->SetDropDownLineCount( mpTabCtrlData->mpListBox->GetEntryCount() ); + } // If current page is removed, than first page gets the current page if ( bIsCurrentPage ) @@ -1799,6 +1867,8 @@ void TabControl::Clear() // clear item list mpTabCtrlData->maItemList.clear(); mnCurPageId = 0; + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->Clear(); ImplFreeLayoutData(); @@ -1819,6 +1889,9 @@ void TabControl::EnablePage( USHORT i_nPageId, bool i_bEnable ) { pItem->mbEnabled = i_bEnable; mbFormat = TRUE; + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->SetEntryFlags( GetPagePos( i_nPageId ), + i_bEnable ? 0 : (LISTBOX_ENTRY_FLAG_DISABLE_SELECTION | LISTBOX_ENTRY_FLAG_DRAW_DISABLED) ); if( pItem->mnId == mnCurPageId ) { // SetCurPageId will change to an enabled page @@ -1943,6 +2016,8 @@ void TabControl::SelectTabPage( USHORT nPageId ) nPageId = mnActPageId; mnActPageId = 0; SetCurPageId( nPageId ); + if( mpTabCtrlData->mpListBox ) + mpTabCtrlData->mpListBox->SelectEntryPos( GetPagePos( nPageId ) ); ImplCallEventListeners( VCLEVENT_TABPAGE_ACTIVATE, (void*) (ULONG) nPageId ); } } @@ -2007,6 +2082,12 @@ void TabControl::SetPageText( USHORT nPageId, const XubString& rText ) { pItem->maText = rText; mbFormat = TRUE; + if( mpTabCtrlData->mpListBox ) + { + USHORT nPos = GetPagePos( nPageId ); + mpTabCtrlData->mpListBox->RemoveEntry( nPos ); + mpTabCtrlData->mpListBox->InsertEntry( rText, nPos ); + } if ( IsUpdateMode() ) Invalidate(); ImplFreeLayoutData(); From 586a494193a5d0147332abb7c17e1e70e74dee20 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 3 Jun 2009 18:51:46 +0000 Subject: [PATCH 083/283] #i92516# latest changes according to UX --- vcl/inc/vcl/prndlg.hxx | 49 +++--- vcl/inc/vcl/svids.hrc | 79 +++++---- vcl/source/src/print.src | 130 ++++++--------- vcl/source/window/printdlg.cxx | 292 +++++++++++++++++---------------- 4 files changed, 273 insertions(+), 277 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 4e7302f112c0..dc8d2ba6586f 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -39,7 +39,6 @@ #include "vcl/dialog.hxx" #include "vcl/fixed.hxx" #include "vcl/button.hxx" -#include "vcl/scrbar.hxx" #include "vcl/gdimtf.hxx" #include "vcl/lstbox.hxx" #include "vcl/field.hxx" @@ -53,6 +52,16 @@ namespace vcl { class PrintDialog : public ModalDialog { + class PrinterListBox : public ListBox + { + public: + PrinterListBox( Window* i_pParent, const ResId& i_rId ) + : ListBox( i_pParent, i_rId ) + {} + virtual ~PrinterListBox() {} + virtual void RequestHelp( const HelpEvent& i_rHEvt ); + }; + class PrintPreviewWindow : public Window { GDIMetaFile maMtf; @@ -68,19 +77,9 @@ namespace vcl void setScale( double fScaleX, double fScaleY ); }; - class PrinterTabPage : public TabPage + class NUpTabPage : public TabPage { public: - ListBox maPrinters; - PushButton maSetupButton; - FixedText maType; - FixedText maTypeText; - FixedText maStatus; - FixedText maStatusText; - FixedText maLocation; - FixedText maLocText; - FixedText maComment; - FixedText maCommentText; FixedLine maNupLine; FixedText maNupRowsTxt; NumericField maNupRowsEdt; @@ -89,8 +88,8 @@ namespace vcl RadioButton maNupPortrait; RadioButton maNupLandscape; - PrinterTabPage( Window*, const ResId& ); - virtual ~PrinterTabPage(); + NUpTabPage( Window*, const ResId& ); + virtual ~NUpTabPage(); void readFromSettings(); void storeToSettings(); @@ -99,7 +98,8 @@ namespace vcl class JobTabPage : public TabPage { public: - ListBox maPrinters; + PrinterListBox maPrinters; + PushButton maSetupButton; CheckBox maToFileBox; FixedLine maCopies; @@ -123,11 +123,13 @@ namespace vcl OKButton maOKButton; CancelButton maCancelButton; PrintPreviewWindow maPreviewWindow; - FixedText maPageText; - ScrollBar maPageSlider; + NumericField maPageEdit; + FixedText maNumPagesText; + PushButton maForwardBtn; + PushButton maBackwardBtn; TabControl maTabCtrl; - PrinterTabPage maPrinterPage; + NUpTabPage maNUpPage; JobTabPage maJobPage; FixedLine maButtonLine; @@ -149,6 +151,11 @@ namespace vcl Size maNupPortraitSize; Size maNupLandscapeSize; + rtl::OUString maCommentText; + rtl::OUString maStatusText; + rtl::OUString maLocationText; + rtl::OUString maTypeText; + void updateNup(); void preparePreview( bool i_bPrintChanged = true ); void setPreviewText( sal_Int32 ); @@ -162,8 +169,6 @@ namespace vcl virtual void Resize(); - DECL_LINK( SlideHdl, ScrollBar* ); - DECL_LINK( EndSlideHdl, ScrollBar* ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); DECL_LINK( ModifyHdl, Edit* ); @@ -190,8 +195,8 @@ namespace vcl CancelButton maButton; bool mbCanceled; - int mnCur; - int mnMax; + sal_Int32 mnCur; + sal_Int32 mnMax; long mnProgressHeight; Rectangle maProgressRect; bool mbNativeProgress; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 1c5f5d598faf..c42435344d34 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -77,52 +77,51 @@ #define SV_DLG_PRINT 2048 #define SV_PRINT_OK 1 #define SV_PRINT_CANCEL 2 -#define SV_PRINT_PAGE_TXT 3 -#define SV_PRINT_PAGE_PREVIEW 4 -#define SV_PRINT_PAGE_SCROLL 5 -#define SV_PRINT_TABCTRL 6 +#define SV_PRINT_PAGE_PREVIEW 3 +#define SV_PRINT_PAGE_TXT 4 +#define SV_PRINT_PAGE_FORWARD 5 +#define SV_PRINT_PAGE_BACKWARD 6 +#define SV_PRINT_PAGE_EDIT 7 +#define SV_PRINT_TABCTRL 8 +#define SV_PRINT_PRT_TYPE 9 +#define SV_PRINT_PRT_STATUS 10 +#define SV_PRINT_PRT_LOCATION 11 +#define SV_PRINT_PRT_COMMENT 12 -#define SV_PRINT_TAB_PRINTER 1 +#define SV_PRINT_TAB_NUP 1 +#define SV_PRINT_PRT_NUP 1 +#define SV_PRINT_PRT_NUP_ROWS_TXT 2 +#define SV_PRINT_PRT_NUP_ROWS_EDT 3 +#define SV_PRINT_PRT_NUP_COLUMNS_TXT 4 +#define SV_PRINT_PRT_NUP_COLUMNS_EDT 5 +#define SV_PRINT_PRT_NUP_PORTRAIT 6 +#define SV_PRINT_PRT_NUP_LANDSCAPE 7 + +#define SV_PRINT_TAB_JOB 2 #define SV_PRINT_PRINTERS 1 -#define SV_PRINT_PRT_TYPE 2 -#define SV_PRINT_PRT_TYPE_TXT 3 -#define SV_PRINT_PRT_STATUS 4 -#define SV_PRINT_PRT_STATUS_TXT 5 -#define SV_PRINT_PRT_LOCATION 6 -#define SV_PRINT_PRT_LOCATION_TXT 7 -#define SV_PRINT_PRT_COMMENT 8 -#define SV_PRINT_PRT_COMMENT_TXT 9 -#define SV_PRINT_PRT_TOFILE 10 -#define SV_PRINT_PRT_SETUP 11 -#define SV_PRINT_PRT_NUP 12 -#define SV_PRINT_PRT_NUP_ROWS_TXT 13 -#define SV_PRINT_PRT_NUP_ROWS_EDT 14 -#define SV_PRINT_PRT_NUP_COLUMNS_TXT 15 -#define SV_PRINT_PRT_NUP_COLUMNS_EDT 16 -#define SV_PRINT_PRT_NUP_PORTRAIT 17 -#define SV_PRINT_PRT_NUP_LANDSCAPE 18 +#define SV_PRINT_PRT_TOFILE 2 +#define SV_PRINT_PRT_SETUP 3 +#define SV_PRINT_RANGE 4 +#define SV_PRINT_ALL 5 +#define SV_PRINT_PAGERANGE 6 +#define SV_PRINT_SELECTION 7 +#define SV_PRINT_PAGERANGE_EDIT 8 +#define SV_PRINT_COPIES 9 +#define SV_PRINT_COPYCOUNT 10 +#define SV_PRINT_COPYCOUNT_FIELD 11 +#define SV_PRINT_COLLATE 12 +#define SV_PRINT_COLLATE_IMAGE 13 +#define SV_PRINT_BUTTONLINE 14 +#define SV_PRINT_COLLATE_IMG 15 +#define SV_PRINT_NOCOLLATE_IMG 16 +#define SV_PRINT_COLLATE_HC_IMG 17 +#define SV_PRINT_NOCOLLATE_HC_IMG 18 +#define SV_PRINT_NOPAGES 19 -#define SV_DLG_PRINT_PROGRESS 2048 +#define SV_DLG_PRINT_PROGRESS 2049 #define SV_PRINT_PROGRESS_CANCEL 1 #define SV_PRINT_PROGRESS_TEXT 2 -#define SV_PRINT_TAB_JOB 2 -#define SV_PRINT_RANGE 1 -#define SV_PRINT_ALL 2 -#define SV_PRINT_PAGERANGE 3 -#define SV_PRINT_SELECTION 4 -#define SV_PRINT_PAGERANGE_EDIT 5 -#define SV_PRINT_COPIES 6 -#define SV_PRINT_COPYCOUNT 7 -#define SV_PRINT_COPYCOUNT_FIELD 8 -#define SV_PRINT_COLLATE 9 -#define SV_PRINT_COLLATE_IMAGE 10 -#define SV_PRINT_BUTTONLINE 11 -#define SV_PRINT_COLLATE_IMG 12 -#define SV_PRINT_NOCOLLATE_IMG 13 -#define SV_PRINT_COLLATE_HC_IMG 14 -#define SV_PRINT_NOCOLLATE_HC_IMG 15 -#define SV_PRINT_NOPAGES 16 #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index d6842560d1f8..c949dbea95dd 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -59,25 +59,36 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 130, 130 ); Border = TRUE; }; - ScrollBar SV_PRINT_PAGE_SCROLL + NumericField SV_PRINT_PAGE_EDIT { Pos = MAP_APPFONT( 5, 140 ); - Size = MAP_APPFONT( 130, 10 ); + Size = MAP_APPFONT( 30, 12 ); SVLook = TRUE; - HScroll = TRUE; - TabStop = TRUE; + Spin = TRUE; + Border = TRUE; }; FixedText SV_PRINT_PAGE_TXT { - Pos = MAP_APPFONT( 5,150 ); - Size = MAP_APPFONT( 130, 10 ); - Text [ en-US ] = "Page %p of %n"; - Center = TRUE; + Pos = MAP_APPFONT( 40,142 ); + Size = MAP_APPFONT( 30, 12 ); + Text [ en-US ] = "/ %n"; + VCenter = TRUE; + }; + PushButton SV_PRINT_PAGE_FORWARD + { + Pos = MAP_APPFONT( 95, 140 ); + Size = MAP_APPFONT( 15, 12 ); + }; + PushButton SV_PRINT_PAGE_BACKWARD + { + Pos = MAP_APPFONT( 80, 140 ); + Size = MAP_APPFONT( 15, 12 ); }; TabControl SV_PRINT_TABCTRL { Pos = MAP_APPFONT( 140, 5 ); Size = MAP_APPFONT( 205, 165 ); +// DropDown = TRUE; }; FixedLine SV_PRINT_BUTTONLINE { @@ -89,82 +100,43 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "No pages"; }; - TabPage SV_PRINT_TAB_PRINTER + String SV_PRINT_PRT_TYPE { - Text [en-US] = "Printer"; + Text [en-US] = "Type: %s"; + }; + String SV_PRINT_PRT_STATUS + { + Text [en-US] = "Status: %s"; + }; + String SV_PRINT_PRT_LOCATION + { + Text [en-US] = "Location: %s"; + }; + String SV_PRINT_PRT_COMMENT + { + Text [en-US] = "Comment: %s"; + }; + + TabPage SV_PRINT_TAB_NUP + { + Text [en-US] = "N-Up"; Hide = TRUE; - ListBox SV_PRINT_PRINTERS - { - Pos = MAP_APPFONT( 5, 5 ); - Size = MAP_APPFONT( 100, 200 ); - DropDown = TRUE; - }; - PushButton SV_PRINT_PRT_SETUP - { - Pos = MAP_APPFONT( 115, 5 ); - Size = MAP_APPFONT( 50, 15 ); - Text [en-US] = "Properties..."; - }; - FixedText SV_PRINT_PRT_TYPE - { - Pos = MAP_APPFONT( 5, 30 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Type"; - }; - FixedText SV_PRINT_PRT_TYPE_TXT - { - Pos = MAP_APPFONT( 50, 30 ); - Size = MAP_APPFONT( 200, 10 ); - }; - FixedText SV_PRINT_PRT_STATUS - { - Pos = MAP_APPFONT( 5, 42 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Status"; - }; - FixedText SV_PRINT_PRT_STATUS_TXT - { - Pos = MAP_APPFONT( 50, 42 ); - Size = MAP_APPFONT( 200, 10 ); - }; - FixedText SV_PRINT_PRT_LOCATION - { - Pos = MAP_APPFONT( 5, 54 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Location"; - }; - FixedText SV_PRINT_PRT_LOCATION_TXT - { - Pos = MAP_APPFONT( 50, 54 ); - Size = MAP_APPFONT( 200, 10 ); - }; - FixedText SV_PRINT_PRT_COMMENT - { - Pos = MAP_APPFONT( 5, 66 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Comment"; - }; - FixedText SV_PRINT_PRT_COMMENT_TXT - { - Pos = MAP_APPFONT( 50, 66 ); - Size = MAP_APPFONT( 200, 10 ); - }; FixedLine SV_PRINT_PRT_NUP { - Pos = MAP_APPFONT( 5, 80 ); + Pos = MAP_APPFONT( 5, 10 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "N-Up printing"; }; FixedText SV_PRINT_PRT_NUP_ROWS_TXT { - Pos = MAP_APPFONT( 10, 95 ); + Pos = MAP_APPFONT( 10, 25 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "~Rows"; }; NumericField SV_PRINT_PRT_NUP_ROWS_EDT { - Pos = MAP_APPFONT( 55, 95 ); + Pos = MAP_APPFONT( 55, 25 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -174,13 +146,13 @@ ModalDialog SV_DLG_PRINT }; FixedText SV_PRINT_PRT_NUP_COLUMNS_TXT { - Pos = MAP_APPFONT( 10, 110 ); + Pos = MAP_APPFONT( 10, 50 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "C~olumns"; }; NumericField SV_PRINT_PRT_NUP_COLUMNS_EDT { - Pos = MAP_APPFONT( 55, 110 ); + Pos = MAP_APPFONT( 55, 50 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -190,13 +162,13 @@ ModalDialog SV_DLG_PRINT }; RadioButton SV_PRINT_PRT_NUP_PORTRAIT { - Pos = MAP_APPFONT( 110, 95 ); + Pos = MAP_APPFONT( 110, 25 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "Po~rtrait"; }; RadioButton SV_PRINT_PRT_NUP_LANDSCAPE { - Pos = MAP_APPFONT( 110, 105 ); + Pos = MAP_APPFONT( 110, 35 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "~Landscape"; }; @@ -213,6 +185,12 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 100, 200 ); DropDown = TRUE; }; + PushButton SV_PRINT_PRT_SETUP + { + Pos = MAP_APPFONT( 115, 5 ); + Size = MAP_APPFONT( 50, 15 ); + Text [en-US] = "Properties..."; + }; CheckBox SV_PRINT_PRT_TOFILE { Pos = MAP_APPFONT( 10, 20 ); @@ -233,7 +211,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_COPYCOUNT_FIELD { - Pos = MAP_APPFONT( 90, 45 ); + Pos = MAP_APPFONT( 10, 55 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -243,12 +221,12 @@ ModalDialog SV_DLG_PRINT }; FixedImage SV_PRINT_COLLATE_IMAGE { - Pos = MAP_APPFONT( 10, 65 ); + Pos = MAP_APPFONT( 90, 60 ); Size = MAP_PIXEL( 80, 30 ); }; CheckBox SV_PRINT_COLLATE { - Pos = MAP_APPFONT( 80, 65 ); + Pos = MAP_APPFONT( 90, 45 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index fea99791c113..4ec838ad289c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -42,6 +42,7 @@ #include "vcl/decoview.hxx" #include "vcl/arrange.hxx" #include "vcl/configsettings.hxx" +#include "vcl/help.hxx" #include "rtl/ustrbuf.hxx" @@ -56,6 +57,14 @@ using namespace com::sun::star::beans; #define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ) ) ) #define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) ) +void PrintDialog::PrinterListBox::RequestHelp( const HelpEvent& i_rHEvt ) +{ + if( i_rHEvt.GetMode() & HELPMODE_QUICK ) + Help::ShowBalloon( this, i_rHEvt.GetMousePosPixel(), GetHelpText() ); + else + ListBox::RequestHelp( i_rHEvt ); +} + PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ), mfScaleX( 1 ), @@ -98,18 +107,8 @@ void PrintDialog::PrintPreviewWindow::setScale( double fScaleX, double fScaleY ) Invalidate(); } -PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rResId ) +PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) - , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) - , maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) ) - , maType( this, VclResId( SV_PRINT_PRT_TYPE ) ) - , maTypeText( this, VclResId( SV_PRINT_PRT_TYPE_TXT ) ) - , maStatus( this, VclResId( SV_PRINT_PRT_STATUS ) ) - , maStatusText(this, VclResId( SV_PRINT_PRT_STATUS_TXT ) ) - , maLocation( this, VclResId( SV_PRINT_PRT_LOCATION ) ) - , maLocText( this, VclResId( SV_PRINT_PRT_LOCATION_TXT ) ) - , maComment( this, VclResId( SV_PRINT_PRT_COMMENT ) ) - , maCommentText( this, VclResId( SV_PRINT_PRT_COMMENT_TXT ) ) , maNupLine( this, VclResId( SV_PRINT_PRT_NUP ) ) , maNupRowsTxt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_TXT ) ) , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) @@ -119,45 +118,35 @@ PrintDialog::PrinterTabPage::PrinterTabPage( Window* i_pParent, const ResId& rRe , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) { FreeResource(); - maPrinters.SMHID2( "PrinterPage", "PrinterList" ); - maSetupButton.SMHID2( "PrinterPage", "Setup" ); - maType.SMHID2( "PrinterPage", "Type" ); - maTypeText.SMHID2( "PrinterPage", "TypeText" ); - maStatus.SMHID2( "PrinterPage", "Status" ); - maStatusText.SMHID2( "PrinterPage", "StatusText" ); - maLocation.SMHID2( "PrinterPage", "Locaction" ); - maLocText.SMHID2( "PrinterPage", "LocactionText" ); - maComment.SMHID2( "PrinterPage", "Comment" ); - maCommentText.SMHID2( "PrinterPage", "CommentText" ); - maNupLine.SMHID2( "PrinterPage", "NUPline" ); - maNupRowsTxt.SMHID2( "PrinterPage", "NUPRowsText" ); - maNupRowsEdt.SMHID2( "PrinterPage", "NUPRows" ); - maNupColTxt.SMHID2( "PrinterPage", "NUPColumnsText" ); - maNupColEdt.SMHID2( "PrinterPage", "NUPColumns" ); - maNupPortrait.SMHID2( "PrinterPage", "NUPPortrait" ); - maNupLandscape.SMHID2( "PrinterPage", "NUPLandscape" ); + maNupLine.SMHID2( "NUpPage", "NUPline" ); + maNupRowsTxt.SMHID2( "NUpPage", "NUPRowsText" ); + maNupRowsEdt.SMHID2( "NUpPage", "NUPRows" ); + maNupColTxt.SMHID2( "NUpPage", "NUPColumnsText" ); + maNupColEdt.SMHID2( "NUpPage", "NUPColumns" ); + maNupPortrait.SMHID2( "NUpPage", "NUPPortrait" ); + maNupLandscape.SMHID2( "NUpPage", "NUPLandscape" ); } -PrintDialog::PrinterTabPage::~PrinterTabPage() +PrintDialog::NUpTabPage::~NUpTabPage() { } -void PrintDialog::PrinterTabPage::readFromSettings() +void PrintDialog::NUpTabPage::readFromSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ) ); sal_Int32 nVal = aValue.toInt32(); maNupRowsEdt.SetValue( sal_Int64( nVal > 1 ? nVal : 1) ); - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ) ); nVal = aValue.toInt32(); maNupColEdt.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ) ); if( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ) maNupPortrait.Check(); @@ -165,16 +154,16 @@ void PrintDialog::PrinterTabPage::readFromSettings() maNupLandscape.Check(); } -void PrintDialog::PrinterTabPage::storeToSettings() +void PrintDialog::NUpTabPage::storeToSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ), maNupRowsEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ), maNupColEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_PrinterPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ), rtl::OUString::createFromAscii( maNupPortrait.IsChecked() ? "true" : "false" ) ); } @@ -182,6 +171,7 @@ void PrintDialog::PrinterTabPage::storeToSettings() PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) + , maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) ) , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) , maCopies( this, VclResId( SV_PRINT_COPIES ) ) , maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) ) @@ -195,6 +185,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) { FreeResource(); maPrinters.SMHID2( "JobPage", "PrinterList" ); + maSetupButton.SMHID2( "JobPage", "Setup" ); maToFileBox.SMHID2( "JobPage", "ToFile" ); maCopies.SMHID2( "JobPage", "CopiesLine" ); maCopyCount.SMHID2( "JobPage", "CopiesText" ); @@ -245,48 +236,53 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& rQueues( Printer::GetPrinterQueues() ); for( std::vector< rtl::OUString >::const_iterator it = rQueues.begin(); it != rQueues.end(); ++it ) { - maPrinterPage.maPrinters.InsertEntry( *it ); maJobPage.maPrinters.InsertEntry( *it ); } // select current printer - if( maPrinterPage.maPrinters.GetEntryPos( maPListener->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) + if( maJobPage.maPrinters.GetEntryPos( maPListener->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) { - maPrinterPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); maJobPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); } else @@ -295,16 +291,14 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LastPrinter" ) ) ) ); - if( maPrinterPage.maPrinters.GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND ) + if( maJobPage.maPrinters.GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND ) { - maPrinterPage.maPrinters.SelectEntry( aValue ); maJobPage.maPrinters.SelectEntry( aValue ); maPListener->setPrinter( boost::shared_ptr( new Printer( aValue ) ) ); } else { // fall back to default printer - maPrinterPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); maPListener->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); } @@ -313,7 +307,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr 1 maCancelButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); #endif + maForwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maBackwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.maCollateBox.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); - maPrinterPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); - maPrinterPage.maNupPortrait.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); - maPrinterPage.maNupLandscape.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maJobPage.maSetupButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maNUpPage.maNupPortrait.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); + maNUpPage.maNupLandscape.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); // setup modify hdl + maPageEdit.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); maJobPage.maCopyCountField.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); - maPrinterPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); - maPrinterPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); + maNUpPage.maNupRowsEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); + maNUpPage.maNupColEdt.SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) ); // setup optional UI options set by application setupOptionalUI(); @@ -366,8 +362,10 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPrinter()->HasSupport( SUPPORT_SETUPDIALOG ) ); + bool bHaveSetup = maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); + maJobPage.maSetupButton.Enable( bHaveSetup ); + if( bHaveSetup ) + { + if( ! maJobPage.maSetupButton.IsVisible() ) + { + Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() ); + Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() ); + Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() ); + aPrinterSize.Width() = aSetupPos.X() - aPrinterPos.X() - LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ).Width(); + maJobPage.maPrinters.SetSizePixel( aPrinterSize ); + maJobPage.maSetupButton.Show(); + } + } + else + { + if( maJobPage.maSetupButton.IsVisible() ) + { + Point aPrinterPos( maJobPage.maPrinters.GetPosPixel() ); + Point aSetupPos( maJobPage.maSetupButton.GetPosPixel() ); + Size aPrinterSize( maJobPage.maPrinters.GetSizePixel() ); + Size aSetupSize( maJobPage.maSetupButton.GetSizePixel() ); + aPrinterSize.Width() = aSetupPos.X() + aSetupSize.Width() - aPrinterPos.X(); + maJobPage.maPrinters.SetSizePixel( aPrinterSize ); + maJobPage.maSetupButton.Hide(); + } + } } void PrintDialog::checkOptionalControlDependencies() @@ -948,27 +968,14 @@ void PrintDialog::checkOptionalControlDependencies() } } -void PrintDialog::updatePrinterText() -{ - const QueueInfo* pInfo = Printer::GetQueueInfo( maPrinterPage.maPrinters.GetSelectEntry(), true ); - if( pInfo ) - { - maPrinterPage.maTypeText.SetText( pInfo->GetDriver() ); - // FIXME: status message - // maJobPage.maStatusText.SetText(); - maPrinterPage.maLocText.SetText( pInfo->GetLocation() ); - maPrinterPage.maCommentText.SetText( pInfo->GetComment() ); - } -} - -static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, sal_Int32 i_nReplacement ) +static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* i_pRepl, sal_Int32 i_nReplLen, const rtl::OUString& i_rRepl ) { sal_Int32 nPos = i_rOrig.indexOfAsciiL( i_pRepl, i_nReplLen ); if( nPos != -1 ) { rtl::OUStringBuffer aBuf( i_rOrig.getLength() ); aBuf.append( i_rOrig.getStr(), nPos ); - aBuf.append( i_nReplacement ); + aBuf.append( i_rRepl ); if( nPos + i_nReplLen < i_rOrig.getLength() ) aBuf.append( i_rOrig.getStr() + nPos + i_nReplLen ); return aBuf.makeStringAndClear(); @@ -976,16 +983,31 @@ static rtl::OUString searchAndReplace( const rtl::OUString& i_rOrig, const char* return i_rOrig; } +void PrintDialog::updatePrinterText() +{ + const QueueInfo* pInfo = Printer::GetQueueInfo( maJobPage.maPrinters.GetSelectEntry(), true ); + if( pInfo ) + { + rtl::OUStringBuffer aBuf( 256 ); + aBuf.append( searchAndReplace( maTypeText, "%s", 2, pInfo->GetDriver() ) ); + aBuf.append( sal_Unicode( '\n' ) ); + aBuf.append( searchAndReplace( maLocationText, "%s", 2, pInfo->GetLocation() ) ); + aBuf.append( sal_Unicode( '\n' ) ); + aBuf.append( searchAndReplace( maCommentText, "%s", 2, pInfo->GetComment() ) ); + aBuf.append( sal_Unicode( '\n' ) ); + maJobPage.maPrinters.SetHelpText( aBuf.makeStringAndClear() ); + } +} + void PrintDialog::setPreviewText( sal_Int32 nSetPage ) { if( mnCachedPages != 0 ) { - rtl::OUString aNewText( searchAndReplace( maPageStr, "%p", 2, nSetPage+1 ) ); - aNewText = searchAndReplace( aNewText, "%n", 2, mnCachedPages ); - maPageText.SetText( aNewText ); + rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) ); + maNumPagesText.SetText( aNewText ); } else - maPageText.SetText( maNoPageStr ); + maNumPagesText.SetText( maNoPageStr ); } void PrintDialog::preparePreview( bool i_bNewPage ) @@ -1001,9 +1023,8 @@ void PrintDialog::preparePreview( bool i_bNewPage ) setPreviewText( mnCurPage ); - maPageSlider.SetRange( Range( 0, nPages ) ); - maPageSlider.SetThumbPos( mnCurPage ); - maPageSlider.SetVisibleSize( 1 ); + maPageEdit.SetMin( 1 ); + maPageEdit.SetMax( nPages ); boost::shared_ptr aPrt( maPListener->getPrinter() ); @@ -1044,47 +1065,22 @@ void PrintDialog::preparePreview( bool i_bNewPage ) void PrintDialog::updateNup() { - int nRows = int(maPrinterPage.maNupRowsEdt.GetValue()); - int nCols = int(maPrinterPage.maNupColEdt.GetValue()); + int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); + int nCols = int(maNUpPage.maNupColEdt.GetValue()); maPListener->setMultipage( nRows, nCols, - maPrinterPage.maNupPortrait.IsChecked() + maNUpPage.maNupPortrait.IsChecked() ? maNupPortraitSize : maNupLandscapeSize ); preparePreview(); } -IMPL_LINK( PrintDialog, SlideHdl, ScrollBar*, pSlider ) -{ - if( pSlider == &maPageSlider ) - { - sal_Int32 nNewPage = static_cast( maPageSlider.GetThumbPos() ); - setPreviewText( nNewPage ); - } - return 0; -} - -IMPL_LINK( PrintDialog, EndSlideHdl, ScrollBar*, pSlider ) -{ - if( pSlider == &maPageSlider ) - { - sal_Int32 nNewPage = static_cast( maPageSlider.GetThumbPos() ); - if( nNewPage != mnCurPage ) - { - mnCurPage = nNewPage; - preparePreview(); - } - } - return 0; -} - IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) { - if( pBox == &maPrinterPage.maPrinters || pBox == &maJobPage.maPrinters ) + if( pBox == &maJobPage.maPrinters ) { String aNewPrinter( pBox->GetSelectEntry() ); maJobPage.maPrinters.SelectEntry( aNewPrinter ); - maPrinterPage.maPrinters.SelectEntry( aNewPrinter ); // set new printer maPListener->setPrinter( boost::shared_ptr( new Printer( aNewPrinter ) ) ); // update text fields @@ -1100,14 +1096,22 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) storeToSettings(); EndDialog( pButton == &maOKButton ); } + else if( pButton == &maForwardBtn ) + { + maPageEdit.Up(); + } + else if( pButton == &maBackwardBtn ) + { + maPageEdit.Down(); + } else { - if( pButton == &maPrinterPage.maSetupButton ) + if( pButton == &maJobPage.maSetupButton ) { maPListener->getPrinter()->Setup( this ); } checkControlDependencies(); - if( pButton == &maPrinterPage.maNupPortrait || pButton == &maPrinterPage.maNupLandscape ) + if( pButton == &maNUpPage.maNupPortrait || pButton == &maNUpPage.maNupLandscape ) updateNup(); } return 0; @@ -1116,10 +1120,15 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { checkControlDependencies(); - if( pEdit == &maPrinterPage.maNupRowsEdt || pEdit == &maPrinterPage.maNupColEdt ) + if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt ) { updateNup(); } + else if( pEdit == &maPageEdit ) + { + mnCurPage = sal_Int32( maPageEdit.GetValue() - 1 ); + preparePreview(); + } return 0; } @@ -1266,23 +1275,28 @@ void PrintDialog::Resize() long nMaxX = maTabCtrl.GetPosPixel().X() - 2*aPixDiff.Width(); long nMaxY = maButtonLine.GetPosPixel().Y() - 2 * aPixDiff.Height() - - maPageText.GetSizePixel().Height() - - maPageSlider.GetSizePixel().Height(); + - maForwardBtn.GetSizePixel().Height(); long nPreviewLength = std::min( nMaxX, nMaxY ); maPreviewSpace = Rectangle( Point( aPixDiff.Width(), aPixDiff.Height() ), Size( nPreviewLength, nPreviewLength ) ); - // position text and slider below preview - aBtnRect = Rectangle( Point( aPixDiff.Width(), 2*aPixDiff.Height() + nPreviewLength ), - Size( nPreviewLength, maPageSlider.GetSizePixel().Height() ) ); - maPageSlider.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - - aBtnRect.Top() = aBtnRect.Bottom() + aPixDiff.Height()/2; - aBtnRect.Bottom() = aBtnRect.Top() + maPageText.GetSizePixel().Height() - 1; - maPageText.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); + + // position text and slider below preview, aligned + Point aCtrlPos( maPreviewWindow.GetPosPixel().X(), 2*aPixDiff.Height() + nPreviewLength ); + maPageEdit.SetPosPixel( aCtrlPos ); + + aCtrlPos.X() += maPageEdit.GetSizePixel().Width() + aPixDiff.Width(); + maNumPagesText.SetPosPixel( aCtrlPos ); + + aCtrlPos.X() = maPreviewWindow.GetPosPixel().X() + maPreviewWindow.GetSizePixel().Width(); + aCtrlPos.X() -= maForwardBtn.GetSizePixel().Width(); + maForwardBtn.SetPosPixel( aCtrlPos ); + + aCtrlPos.X() -= aPixDiff.Width() + maBackwardBtn.GetSizePixel().Width(); + maBackwardBtn.SetPosPixel( aCtrlPos ); + } // ----------------------------------------------------------------------------- @@ -1355,8 +1369,8 @@ void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax ) if( mnMax < 1 ) mnMax = 1; - rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, mnCur ) ); - aNewText = searchAndReplace( aNewText, "%n", 2, mnMax ); + rtl::OUString aNewText( searchAndReplace( maStr, "%p", 2, rtl::OUString::valueOf( mnCur ) ) ); + aNewText = searchAndReplace( aNewText, "%n", 2, rtl::OUString::valueOf( mnMax ) ); maText.SetText( aNewText ); // update progress From fc1d80c5911955f1937822dd9561e7d81cb8a2ea Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 3 Jun 2009 19:22:35 +0000 Subject: [PATCH 084/283] fix a warning --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 4ec838ad289c..629e39f37336 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -999,7 +999,7 @@ void PrintDialog::updatePrinterText() } } -void PrintDialog::setPreviewText( sal_Int32 nSetPage ) +void PrintDialog::setPreviewText( sal_Int32 ) { if( mnCachedPages != 0 ) { From b6cb39ab39a25200954d20780aabe70ac1347479 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 3 Jun 2009 19:23:14 +0000 Subject: [PATCH 085/283] fix a warning --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 33774ea67d53..b016920ae18e 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -599,7 +599,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) numberOfRows: aChoices.getLength() numberOfColumns: 1]; // get currently selected value - sal_Int32 nSelectVal; + sal_Int32 nSelectVal = 0; PropertyValue* pVal = pListener->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; From 33ce99fd93f419a1659a541b37ad7b1de84a3e00 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 4 Jun 2009 10:37:39 +0000 Subject: [PATCH 086/283] get correct page count --- vcl/aqua/source/gdi/salprn.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 944812e1a8ea..f58c63b19079 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -530,7 +530,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, { mnCurPageRangeStart = 0; mnCurPageRangeCount = 0; - nAllPages = i_rListener.getPageCount(); + nAllPages = i_rListener.getFilteredPageCount(); } aAccViewState.bNeedRestart = false; From a7432bba85ee4904c0768d0a32052c86a835fc6d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 5 Jun 2009 15:01:27 +0000 Subject: [PATCH 087/283] improve control arrangement, small UI changes --- vcl/inc/vcl/arrange.hxx | 22 ++++++++++++++++++++++ vcl/inc/vcl/prndlg.hxx | 3 +++ vcl/source/src/print.src | 10 +++++----- vcl/source/window/printdlg.cxx | 26 ++++++++++++++------------ 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index fdaf957dce76..cd13400fc27e 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -194,6 +194,28 @@ namespace vcl void setChild( WindowArranger* i_pChild, sal_Int32 i_nExpandPrio = 0 ) { setChild( boost::shared_ptr( i_pChild ), i_nExpandPrio ); } }; + + class Spacer : public WindowArranger + { + WindowArranger::Element m_aElement; + public: + Spacer( WindowArranger* i_pParent = NULL, sal_Int32 i_nPrio = 20 ) + : WindowArranger( i_pParent ) + , m_aElement( NULL, boost::shared_ptr(), i_nPrio ) + {} + + virtual ~Spacer() {} + + virtual Size getOptimalSize( WindowSizeType ) const + { return Size( 0, 0 ); } + virtual void resize() {} + virtual void setParentWindow( Window* ) {} + virtual size_t countElements() const { return 1; } + virtual boost::shared_ptr getChild( size_t i_nIndex ) const { return boost::shared_ptr(); } + virtual Window* getWindow( size_t i_nIndex ) const { return NULL; } + virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const + { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } + }; } #endif diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index dc8d2ba6586f..04a62fc84954 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -44,6 +44,7 @@ #include "vcl/field.hxx" #include "vcl/tabctrl.hxx" #include "vcl/tabpage.hxx" +#include "vcl/arrange.hxx" #include #include @@ -156,6 +157,8 @@ namespace vcl rtl::OUString maLocationText; rtl::OUString maTypeText; + vcl::RowOrColumn maPreviewCtrlRow; + void updateNup(); void preparePreview( bool i_bPrintChanged = true ); void setPreviewText( sal_Int32 ); diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index c949dbea95dd..58d8010f0a2c 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -57,14 +57,14 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 130, 130 ); - Border = TRUE; + Border = FALSE; }; NumericField SV_PRINT_PAGE_EDIT { Pos = MAP_APPFONT( 5, 140 ); Size = MAP_APPFONT( 30, 12 ); SVLook = TRUE; - Spin = TRUE; + Spin = FALSE; Border = TRUE; }; FixedText SV_PRINT_PAGE_TXT @@ -211,7 +211,7 @@ ModalDialog SV_DLG_PRINT }; NumericField SV_PRINT_COPYCOUNT_FIELD { - Pos = MAP_APPFONT( 10, 55 ); + Pos = MAP_APPFONT( 10, 56 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -221,12 +221,12 @@ ModalDialog SV_DLG_PRINT }; FixedImage SV_PRINT_COLLATE_IMAGE { - Pos = MAP_APPFONT( 90, 60 ); + Pos = MAP_APPFONT( 95, 60 ); Size = MAP_PIXEL( 80, 30 ); }; CheckBox SV_PRINT_COLLATE { - Pos = MAP_APPFONT( 90, 45 ); + Pos = MAP_APPFONT( 95, 45 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 629e39f37336..ec700683cc64 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -252,9 +252,20 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Mon, 8 Jun 2009 12:43:56 +0000 Subject: [PATCH 088/283] #i92516# move preview and corresponding controls into an own border --- vcl/inc/vcl/arrange.hxx | 1 + vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/window/printdlg.cxx | 48 +++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index cd13400fc27e..1f085521c818 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -114,6 +114,7 @@ namespace vcl m_aManagedArea = i_rArea; resize(); } + const Rectangle& getManagedArea() const { return m_aManagedArea; } void setOuterBorder( long i_nBorder ) { diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 04a62fc84954..64bfa65a8d23 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -158,6 +158,7 @@ namespace vcl rtl::OUString maTypeText; vcl::RowOrColumn maPreviewCtrlRow; + Rectangle maPreviewBackground; void updateNup(); void preparePreview( bool i_bPrintChanged = true ); @@ -171,6 +172,7 @@ namespace vcl com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; virtual void Resize(); + virtual void Paint( const Rectangle& ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index ec700683cc64..e94b0803df4a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -43,6 +43,7 @@ #include "vcl/arrange.hxx" #include "vcl/configsettings.hxx" #include "vcl/help.hxx" +#include "vcl/decoview.hxx" #include "rtl/ustrbuf.hxx" @@ -1252,6 +1253,34 @@ IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) return 0; } +void PrintDialog::Paint( const Rectangle& i_rRect ) +{ + ModalDialog::Paint( i_rRect ); + + #if 0 + // sadly Tab panes are not a reliable choice for a grouping background + // since they depend on the tab items above in some themes + if( IsNativeControlSupported( CTRL_TAB_PANE, PART_ENTIRE_CONTROL) ) + { + Rectangle aPrevBg( maPreviewBackground ); + #ifdef QUARTZ + // FIXME: this interacts with vcl/aqua/source/gdi/salnativewidgets.cxx where + // some magic offsets are added to the area + aPrevBg.Top() += 10; + #endif + const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); + + ControlState nState = CTRL_STATE_ENABLED; + Region aCtrlRegion( aPrevBg ); + DrawNativeControl( CTRL_TAB_PANE, PART_ENTIRE_CONTROL, aCtrlRegion, nState, + aControlValue, rtl::OUString() ); + } + #else + DecorationView aVw( this ); + aVw.DrawFrame( maPreviewBackground, FRAME_DRAW_IN ); + #endif +} + void PrintDialog::Resize() { Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); @@ -1285,20 +1314,25 @@ void PrintDialog::Resize() // set size for preview long nMaxX = maTabCtrl.GetPosPixel().X() - 2*aPixDiff.Width(); long nMaxY = maButtonLine.GetPosPixel().Y() - - 2 * aPixDiff.Height() + - 4 * aPixDiff.Height() - maForwardBtn.GetSizePixel().Height(); long nPreviewLength = std::min( nMaxX, nMaxY ); - maPreviewSpace = Rectangle( Point( aPixDiff.Width(), aPixDiff.Height() ), + maPreviewSpace = Rectangle( Point( aPixDiff.Width(), 2 * aPixDiff.Height() ), Size( nPreviewLength, nPreviewLength ) ); + // position text and slider below preview, aligned + Size aPrefSize( maPreviewCtrlRow.getOptimalSize( WINDOWSIZE_PREFERRED ) ); + aPrefSize.Width() = nPreviewLength - 2* aPixDiff.Width(); + Point aCtrlPos( 2*aPixDiff.Width(), 3*aPixDiff.Height() + nPreviewLength ); + maPreviewCtrlRow.setManagedArea( Rectangle( aCtrlPos, aPrefSize ) ); + maPreviewBackground.Left() = aPixDiff.Width(); + maPreviewBackground.Top() = aPixDiff.Height(); + maPreviewBackground.Right() = aPixDiff.Width() + nPreviewLength; + maPreviewBackground.Bottom() = maPreviewCtrlRow.getManagedArea().Bottom() + aPixDiff.Height(); + // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); - // position text and slider below preview, aligned - Size aPrefSize( maPreviewCtrlRow.getOptimalSize( WINDOWSIZE_PREFERRED ) ); - aPrefSize.Width() = maPreviewWindow.GetSizePixel().Width(); - Point aCtrlPos( maPreviewWindow.GetPosPixel().X(), 2*aPixDiff.Height() + nPreviewLength ); - maPreviewCtrlRow.setManagedArea( Rectangle( aCtrlPos, aPrefSize ) ); } // ----------------------------------------------------------------------------- From a597b3e1f953fb9185e51cd24952026401dc9c11 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 9 Jun 2009 15:06:16 +0000 Subject: [PATCH 089/283] #i92516# adapt to new printer API --- padmin/source/padialog.cxx | 149 ++++++++++++++++++++++--------------- padmin/source/padialog.hxx | 2 - 2 files changed, 91 insertions(+), 60 deletions(-) diff --git a/padmin/source/padialog.cxx b/padmin/source/padialog.cxx index 5b49409a1c8a..7c8ed6d39fe3 100644 --- a/padmin/source/padialog.cxx +++ b/padmin/source/padialog.cxx @@ -60,11 +60,16 @@ #include "unotools/localedatawrapper.hxx" #include "unotools/configitem.hxx" #include "unotools/configmgr.hxx" + +#include "com/sun/star/awt/Size.hpp" + using namespace psp; using namespace rtl; using namespace padmin; using namespace osl; +using namespace com::sun::star; using namespace com::sun::star::uno; +using namespace com::sun::star::beans; PADialog* PADialog::Create( Window* pParent, BOOL bAdmin ) { @@ -96,7 +101,6 @@ PADialog::PADialog( Window* pParent, BOOL /*bAdmin*/ ) : m_aCancelButton( this, PaResId( RID_PA_BTN_CANCEL ) ), m_aDefPrt( PaResId( RID_PA_STR_DEFPRT ) ), m_aRenameStr( PaResId( RID_PA_STR_RENAME ) ), - m_pPrinter( 0 ), m_rPIManager( PrinterInfoManager::get() ) { FreeResource(); @@ -248,18 +252,6 @@ IMPL_LINK( PADialog, SelectHdl, ListBox*, pListBox ) return 0; } -IMPL_LINK( PADialog, EndPrintHdl, void*, EMPTYARG ) -{ - String aInfoString( PaResId( RID_PA_TXT_TESTPAGE_PRINTED ) ); - InfoBox aInfoBox( this, aInfoString ); - aInfoBox.SetText( String( PaResId( RID_BXT_TESTPAGE ) ) ); - aInfoBox.Execute(); - - delete m_pPrinter; - m_pPrinter = NULL; - return 0; -} - void PADialog::UpdateDefPrt() { m_rPIManager.setDefaultPrinter( getSelectedDevice() ); @@ -369,66 +361,77 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) return aColor; } -#define DELTA 5.0 -void PADialog::PrintTestPage() +class SpaPrinterListener : public vcl::PrinterListener { - if( m_pPrinter ) // already printing; user pressed button twice - return; +public: + SpaPrinterListener( const boost::shared_ptr& i_pPrinter ) + : vcl::PrinterListener( i_pPrinter ) + {} + virtual ~SpaPrinterListener() + {} - String sPrinter( getSelectedDevice() ); + virtual int getPageCount() const { return 1; } + virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; + virtual void printPage( int i_nPage ) const; + virtual void jobFinished(); +}; - m_pPrinter = new Printer( sPrinter ); +Sequence< PropertyValue > SpaPrinterListener::getPageParameters( int ) const +{ + Sequence< PropertyValue > aRet( 1 ); - PrinterInfo aInfo( m_rPIManager.getPrinterInfo( sPrinter ) ); + Size aPageSize( getPrinter()->GetPaperSizePixel() ); + aPageSize = getPrinter()->PixelToLogic( aPageSize, MapMode( MAP_100TH_MM ) ); + + awt::Size aSize; + aSize.Width = aPageSize.Width(); + aSize.Height = aPageSize.Height(); + aRet[0].Value = makeAny(aSize); + + return aRet; +} + +void SpaPrinterListener::printPage( int ) const +{ + const double DELTA = 5.0; + + boost::shared_ptr pPrinter( getPrinter() ); + + PrinterInfo aInfo( psp::PrinterInfoManager::get().getPrinterInfo( pPrinter->GetName() ) ); const PPDParser* pPrintParser = aInfo.m_pParser; MapMode aMapMode( MAP_100TH_MM ); Bitmap aButterfly( PaResId( RID_BUTTERFLY ) ); - m_pPrinter->SetMapMode( aMapMode ); - m_pPrinter->SetEndPrintHdl( LINK( this, PADialog, EndPrintHdl ) ); + pPrinter->SetMapMode( aMapMode ); Any aRet = utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ); OUString aJobName; aRet >>= aJobName; aJobName = aJobName + OUString( RTL_CONSTASCII_USTRINGPARAM( " Testpage" ) ); - if( m_pPrinter->GetName() != sPrinter || ! m_pPrinter->StartJob( aJobName ) ) - { - String aString( PaResId( RID_ERR_NOPRINTER ) ); - aString.SearchAndReplaceAscii( "%s", sPrinter ); - ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aString ); - aErrorBox.SetText( String( PaResId( RID_BXT_ENVIRONMENT ) ) ); - aErrorBox.Execute(); - delete m_pPrinter; - m_pPrinter = 0; - return; - } - m_pPrinter->StartPage(); - - Size aPaperSize=m_pPrinter->GetOutputSize(); + Size aPaperSize=pPrinter->GetOutputSize(); Point aCenter( aPaperSize.Width()/2-300, aPaperSize.Height() - aPaperSize.Width()/2 ); Point aP1( aPaperSize.Width()/48, 0), aP2( aPaperSize.Width()/40, 0 ), aPoint; - m_pPrinter->DrawRect( Rectangle( Point( 0,0 ), aPaperSize ) ); - m_pPrinter->DrawRect( Rectangle( Point( 100,100 ), + pPrinter->DrawRect( Rectangle( Point( 0,0 ), aPaperSize ) ); + pPrinter->DrawRect( Rectangle( Point( 100,100 ), Size( aPaperSize.Width()-200, aPaperSize.Height()-200 ) ) ); - m_pPrinter->DrawRect( Rectangle( Point( 200,200 ), + pPrinter->DrawRect( Rectangle( Point( 200,200 ), Size( aPaperSize.Width()-400, aPaperSize.Height()-400 ) ) ); - m_pPrinter->DrawRect( Rectangle( Point( 300,300 ), + pPrinter->DrawRect( Rectangle( Point( 300,300 ), Size( aPaperSize.Width()-600, aPaperSize.Height()-600 ) ) ); - Font aFont( m_pPrinter->GetFont() ); - aFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Courier" ) ) ); + Font aFont( String( RTL_CONSTASCII_USTRINGPARAM( "Courier" ) ), Size( 0, 400 ) ); aFont.SetWeight( WEIGHT_NORMAL ); aFont.SetItalic( ITALIC_NONE ); - m_pPrinter->SetFont( aFont ); + pPrinter->SetFont( aFont ); OUStringBuffer aPrintText(1024); long nWidth = 0, nMaxWidth = 0; @@ -455,12 +458,12 @@ void PADialog::PrintTestPage() aToken = String::CreateFromAscii( aResIds[i].pDirect ); else aToken = String( PaResId( aResIds[i].nResId ) ); - nMaxWidth = ( nWidth = m_pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; + nMaxWidth = ( nWidth = pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; aPrintText.append( aToken ); aPrintText.append( (sal_Unicode)'\n' ); }; - m_pPrinter->DrawText( Rectangle( Point( 1000, 2000 ), + pPrinter->DrawText( Rectangle( Point( 1000, 1000 ), Size( aPaperSize.Width() - 2000, aPaperSize.Height() - 4000 ) ), aPrintText.makeStringAndClear(), @@ -470,7 +473,7 @@ void PADialog::PrintTestPage() const LocaleDataWrapper& rLocaleWrapper( aSettings.GetLocaleDataWrapper() ); aPrintText.appendAscii( ": " ); - aPrintText.append( sPrinter ); + aPrintText.append( pPrinter->GetName() ); aPrintText.appendAscii( "\n: " ); if( pPrintParser ) aPrintText.append( pPrintParser->getPrinterName() ); @@ -487,17 +490,17 @@ void PADialog::PrintTestPage() aPrintText.appendAscii( "\n: " ); aPrintText.append( rLocaleWrapper.getTime( Time() ) ); - m_pPrinter->DrawText( Rectangle( Point( 1100 + nMaxWidth, 2000 ), + pPrinter->DrawText( Rectangle( Point( 1100 + nMaxWidth, 1000 ), Size( aPaperSize.Width() - 2100 - nMaxWidth, aPaperSize.Height() - 4000 ) ), aPrintText.makeStringAndClear(), TEXT_DRAW_MULTILINE ); - m_pPrinter->DrawBitmap( Point( aPaperSize.Width() - 4000, 1000 ), + pPrinter->DrawBitmap( Point( aPaperSize.Width() - 4000, 1000 ), Size( 3000,3000 ), aButterfly ); - m_pPrinter->SetFillColor(); - m_pPrinter->DrawRect( Rectangle( Point( aPaperSize.Width() - 4000, 1000 ), + pPrinter->SetFillColor(); + pPrinter->DrawRect( Rectangle( Point( aPaperSize.Width() - 4000, 1000 ), Size( 3000,3000 ) ) ); Color aWhite( 0xff, 0xff, 0xff ); @@ -511,22 +514,22 @@ void PADialog::PrintTestPage() Gradient aGradient( GRADIENT_LINEAR, aBlack, aWhite ); aGradient.SetAngle( 900 ); - m_pPrinter->DrawGradient( Rectangle( Point( 1000, 5500 ), + pPrinter->DrawGradient( Rectangle( Point( 1000, 5500 ), Size( aPaperSize.Width() - 2000, 500 ) ), aGradient ); aGradient.SetStartColor( aDarkRed ); aGradient.SetEndColor( aLightBlue ); - m_pPrinter->DrawGradient( Rectangle( Point( 1000, 6300 ), + pPrinter->DrawGradient( Rectangle( Point( 1000, 6300 ), Size( aPaperSize.Width() - 2000, 500 ) ), aGradient ); aGradient.SetStartColor( aDarkBlue ); aGradient.SetEndColor( aLightGreen ); - m_pPrinter->DrawGradient( Rectangle( Point( 1000, 7100 ), + pPrinter->DrawGradient( Rectangle( Point( 1000, 7100 ), Size( aPaperSize.Width() - 2000, 500 ) ), aGradient ); aGradient.SetStartColor( aDarkGreen ); aGradient.SetEndColor( aLightRed ); - m_pPrinter->DrawGradient( Rectangle( Point( 1000, 7900 ), + pPrinter->DrawGradient( Rectangle( Point( 1000, 7900 ), Size( aPaperSize.Width() - 2000, 500 ) ), aGradient ); @@ -543,7 +546,7 @@ void PADialog::PrintTestPage() { aLineInfo.SetWidth( n/3 ); aLineColor = approachColor( aLineColor, aApproachColor ); - m_pPrinter->SetLineColor( aLineColor ); + pPrinter->SetLineColor( aLineColor ); // switch aproach color if( aApproachColor.IsRGBEqual( aLineColor ) ) @@ -556,7 +559,7 @@ void PADialog::PrintTestPage() aApproachColor = Color( 0, 200, 0 ); } - m_pPrinter->DrawLine( project( aP1 ) + aCenter, + pPrinter->DrawLine( project( aP1 ) + aCenter, project( aP2 ) + aCenter, aLineInfo ); aPoint.X() = (int)((((double)aP1.X())*cosd - ((double)aP1.Y())*sind)*factor); @@ -569,8 +572,38 @@ void PADialog::PrintTestPage() #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL fprintf( stderr, "%d lines\n",n ); #endif - m_pPrinter->EndPage(); - m_pPrinter->EndJob(); +} + +void SpaPrinterListener::jobFinished() +{ + String aInfoString( PaResId( RID_PA_TXT_TESTPAGE_PRINTED ) ); + InfoBox aInfoBox( NULL, aInfoString ); + aInfoBox.SetText( String( PaResId( RID_BXT_TESTPAGE ) ) ); + aInfoBox.Execute(); +} + +void PADialog::PrintTestPage() +{ + String sPrinter( getSelectedDevice() ); + + boost::shared_ptr pPrinter( new Printer( sPrinter ) ); + + if( pPrinter->GetName() != sPrinter ) + { + String aString( PaResId( RID_ERR_NOPRINTER ) ); + aString.SearchAndReplaceAscii( "%s", sPrinter ); + + ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aString ); + aErrorBox.SetText( String( PaResId( RID_BXT_ENVIRONMENT ) ) ); + aErrorBox.Execute(); + return; + } + + boost::shared_ptr pListener( new SpaPrinterListener( pPrinter ) ); + JobSetup aJobSetup( pPrinter->GetJobSetup() ); + aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), + String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); + Printer::PrintJob( pListener, aJobSetup ); } void PADialog::AddDevice() diff --git a/padmin/source/padialog.hxx b/padmin/source/padialog.hxx index ac6ee8f4279f..0350f66a2905 100644 --- a/padmin/source/padialog.hxx +++ b/padmin/source/padialog.hxx @@ -83,7 +83,6 @@ namespace padmin { String m_aDefPrt; String m_aRenameStr; - Printer* m_pPrinter; ::psp::PrinterInfoManager& m_rPIManager; ::std::list< ::rtl::OUString > m_aPrinters; @@ -94,7 +93,6 @@ namespace padmin { DECL_LINK( ClickBtnHdl, PushButton* ); DECL_LINK( DoubleClickHdl, ListBox* ); DECL_LINK( SelectHdl, ListBox* ); - DECL_LINK( EndPrintHdl, void* ); DECL_LINK( DelPressedHdl, ListBox* ); PADialog( Window*, BOOL ); From 793ffd2b60a7b8c864e38928f8e169cf304e7bb3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 9 Jun 2009 15:06:57 +0000 Subject: [PATCH 090/283] #i92516# allow for already available printer --- vcl/inc/vcl/print.hxx | 2 ++ vcl/source/gdi/print3.cxx | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 83e4e984a1d3..ecf3b8aa1a46 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -443,6 +443,8 @@ class ImplPrinterListenerData; class VCL_DLLPUBLIC PrinterListener { ImplPrinterListenerData* mpImplData; +protected: + PrinterListener( const boost::shared_ptr& ); public: PrinterListener(); virtual ~PrinterListener(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index ed1080a70e7b..e50b345c4a7f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -100,6 +100,12 @@ PrinterListener::PrinterListener() { } +PrinterListener::PrinterListener( const boost::shared_ptr& i_pPrinter ) + : mpImplData( new ImplPrinterListenerData ) +{ + mpImplData->mpPrinter = i_pPrinter; +} + static rtl::OUString queryFile( Printer* pPrinter ) { rtl::OUString aResult; From 808c249f8c1ed5c8b583ac9d33e928d1f2dff81d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 9 Jun 2009 18:58:38 +0000 Subject: [PATCH 091/283] #i92516# additional N-Up functionality --- vcl/inc/vcl/print.hxx | 27 +++++++- vcl/inc/vcl/prndlg.hxx | 17 +++++ vcl/inc/vcl/svids.hrc | 14 ++++ vcl/source/gdi/print3.cxx | 82 +++++++++++++---------- vcl/source/src/print.src | 117 +++++++++++++++++++++++++++++++-- vcl/source/window/printdlg.cxx | 85 ++++++++++++++++++++++-- 6 files changed, 296 insertions(+), 46 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index ecf3b8aa1a46..6d63d7a6ab23 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -446,6 +446,30 @@ class VCL_DLLPUBLIC PrinterListener protected: PrinterListener( const boost::shared_ptr& ); public: + struct MultiPageSetup + { + // all metrics in 100th mm + int nRows; + int nColumns; + Size aPaperSize; + long nLeftMargin; + long nTopMargin; + long nRightMargin; + long nBottomMargin; + long nHorizontalSpacing; + long nVerticalSpacing; + bool bDrawBorder; + + MultiPageSetup() + : nRows( 1 ), nColumns( 1 ), aPaperSize( 21000, 29700 ) + , nLeftMargin( 0 ), nTopMargin( 0 ) + , nRightMargin( 0 ), nBottomMargin( 0 ) + , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) + , bDrawBorder( true ) + { + } + }; + PrinterListener(); virtual ~PrinterListener(); @@ -497,7 +521,8 @@ public: void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); void SAL_DLLPRIVATE createProgressDialog(); - void SAL_DLLPRIVATE setMultipage( int nRows, int nColumns, const Size& rPaperSize ); + void SAL_DLLPRIVATE setMultipage( const MultiPageSetup& ); + const MultiPageSetup& getMultipage() const; void SAL_DLLPRIVATE setLastPage( sal_Bool i_bLastPage ); }; diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 64bfa65a8d23..384dcd2451e3 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -86,14 +86,31 @@ namespace vcl NumericField maNupRowsEdt; FixedText maNupColTxt; NumericField maNupColEdt; + CheckBox maBorderCB; RadioButton maNupPortrait; RadioButton maNupLandscape; + FixedLine maMargins; + FixedText maLeftMarginTxt; + MetricField maLeftMarginEdt; + FixedText maRightMarginTxt; + MetricField maRightMarginEdt; + FixedText maTopMarginTxt; + MetricField maTopMarginEdt; + FixedText maBottomMarginTxt; + MetricField maBottomMarginEdt; + + FixedText maHSpaceTxt; + MetricField maHSpaceEdt; + FixedText maVSpaceTxt; + MetricField maVSpaceEdt; + NUpTabPage( Window*, const ResId& ); virtual ~NUpTabPage(); void readFromSettings(); void storeToSettings(); + void initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& ); }; class JobTabPage : public TabPage diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index c42435344d34..4c512d056153 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -96,6 +96,20 @@ #define SV_PRINT_PRT_NUP_COLUMNS_EDT 5 #define SV_PRINT_PRT_NUP_PORTRAIT 6 #define SV_PRINT_PRT_NUP_LANDSCAPE 7 +#define SV_PRINT_PRT_NUP_MARGINS_FL 8 +#define SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT 9 +#define SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT 10 +#define SV_PRINT_PRT_NUP_MARGINS_TOP_TXT 11 +#define SV_PRINT_PRT_NUP_MARGINS_TOP_EDT 12 +#define SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT 13 +#define SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT 14 +#define SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT 15 +#define SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT 16 +#define SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT 17 +#define SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT 18 +#define SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT 19 +#define SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT 20 +#define SV_PRINT_PRT_NUP_BORDER_CB 21 #define SV_PRINT_TAB_JOB 2 #define SV_PRINT_PRINTERS 1 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e50b345c4a7f..e873b1cc068d 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -80,16 +80,12 @@ public: ControlDependencyMap maControlDependencies; sal_Bool mbLastPage; - int mnMultiPageRows; - int mnMultiPageColumns; - Size maMultiPageSize; + vcl::PrinterListener::MultiPageSetup maMultiPage; vcl::PrintProgressDialog* mpProgress; ImplPrinterListenerData() : mbLastPage( sal_False ), - mnMultiPageRows( 1 ), - mnMultiPageColumns( 1 ), mpProgress( NULL ) {} ~ImplPrinterListenerData() { delete mpProgress; } @@ -383,7 +379,6 @@ void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; Size aPaperSize( i_rPrinter->PixelToLogic( i_rPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); - mpImplData->maMultiPageSize = aPaperSize; } static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) @@ -446,7 +441,7 @@ Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) return aPageSize; } -static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GDIMetaFile& io_rSubPage ) +static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GDIMetaFile& io_rSubPage, bool i_bDrawBorder ) { // intersect all clipregion actions with our clip rect io_rSubPage.WindStart(); @@ -456,14 +451,17 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION | PUSH_MAPMODE ) ); // draw a border - Rectangle aBorderRect( i_rClipRect ); - aBorderRect.Left() -= 100; - aBorderRect.Top() -= 100; - aBorderRect.Right() += 100; - aBorderRect.Bottom() += 100; - o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); - o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); - o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); + if( i_bDrawBorder ) + { + Rectangle aBorderRect( i_rClipRect ); + aBorderRect.Left() -= 100; + aBorderRect.Top() -= 100; + aBorderRect.Right() += 100; + aBorderRect.Bottom() += 100; + o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); + o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); + o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); + } // clip to page rect o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); @@ -478,21 +476,36 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ) { - int nSubPages = mpImplData->mnMultiPageRows * mpImplData->mnMultiPageColumns; + const MultiPageSetup& rMPS( mpImplData->maMultiPage ); + int nSubPages = rMPS.nRows * rMPS.nColumns; if( nSubPages < 1 ) nSubPages = 1; - if( nSubPages == 1 ) + // there is no filtering to be done (and especially the page size of the + // original page is to be set), when N-Up is "neutral" that is there is + // only one subpage and the margins are 0 + if( nSubPages == 1 && + rMPS.nLeftMargin == 0 && rMPS.nRightMargin == 0 && + rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 ) + { return getPageFile( i_nFilteredPage, o_rMtf ); + } - Size aPaperSize( mpImplData->maMultiPageSize ); + Size aPaperSize( mpImplData->maMultiPage.aPaperSize ); + // multi page area: paper size minus margins + one time spacing right and down + // the added spacing is so each subpage can be calculated including its spacing + Size aMPArea( aPaperSize ); + aMPArea.Width() -= rMPS.nLeftMargin + rMPS.nRightMargin; + aMPArea.Width() += rMPS.nHorizontalSpacing; + aMPArea.Height() -= rMPS.nTopMargin + rMPS.nBottomMargin; + aMPArea.Height() += rMPS.nVerticalSpacing; // determine offsets - long nAdvX = aPaperSize.Width() / mpImplData->mnMultiPageColumns; - long nAdvY = aPaperSize.Height() / mpImplData->mnMultiPageRows; + long nAdvX = aMPArea.Width() / rMPS.nColumns; + long nAdvY = aMPArea.Height() / rMPS.nRows; // determine size of a "cell" subpage, leave a little space around pages - Size aSubPageSize( nAdvX - 500, nAdvY - 500 ); + Size aSubPageSize( nAdvX - rMPS.nHorizontalSpacing, nAdvY - rMPS.nVerticalSpacing ); o_rMtf.Clear(); o_rMtf.SetPrefSize( aPaperSize ); @@ -516,10 +529,10 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r aPageFile.WindStart(); // move the subpage so it is centered in its "cell" - long nOffX = (nAdvX - long(double(aPageSize.Width()) * fScale)) / 2; - long nOffY = (nAdvY - long(double(aPageSize.Height()) * fScale)) / 2; - long nX = nOffX + nAdvX * (nSubP % mpImplData->mnMultiPageColumns); - long nY = nOffY + nAdvY * (nSubP / mpImplData->mnMultiPageColumns); + long nOffX = (aSubPageSize.Width() - long(double(aPageSize.Width()) * fScale)) / 2; + long nOffY = (aSubPageSize.Height() - long(double(aPageSize.Height()) * fScale)) / 2; + long nX = rMPS.nLeftMargin + nOffX + nAdvX * (nSubP % rMPS.nColumns); + long nY = rMPS.nTopMargin + nOffY + nAdvY * (nSubP / rMPS.nColumns); aPageFile.Move( nX, nY ); aPageFile.WindStart(); // calculate border rectangle @@ -528,7 +541,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r long(double(aPageSize.Height())*fScale) ) ); // append subpage to page - appendSubPage( o_rMtf, aSubPageRect, aPageFile ); + appendSubPage( o_rMtf, aSubPageRect, aPageFile, rMPS.bDrawBorder ); } } o_rMtf.WindStart(); @@ -538,7 +551,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r int PrinterListener::getFilteredPageCount() { - int nDiv = mpImplData->mnMultiPageRows * mpImplData->mnMultiPageColumns; + int nDiv = mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns; if( nDiv < 1 ) nDiv = 1; return (getPageCount() + (nDiv-1)) / nDiv; @@ -556,7 +569,7 @@ void PrinterListener::printFilteredPage( int i_nPage ) return; } - bool bMultiPageOutput = mpImplData->mnMultiPageRows != 1 || mpImplData->mnMultiPageColumns != 1; + bool bMultiPageOutput = mpImplData->maMultiPage.nRows != 1 || mpImplData->maMultiPage.nColumns != 1; ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); @@ -613,7 +626,7 @@ void PrinterListener::printFilteredPage( int i_nPage ) // in N-Up printing set the correct page size mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); if( bMultiPageOutput ) - mpImplData->mpPrinter->SetPaperSizeUser( aPageSize = mpImplData->maMultiPageSize ); + mpImplData->mpPrinter->SetPaperSizeUser( aPageSize = mpImplData->maMultiPage.aPaperSize ); // actually print the page mpImplData->mpPrinter->StartPage(); @@ -830,11 +843,14 @@ void PrinterListener::createProgressDialog() } } -void PrinterListener::setMultipage( int i_nRows, int i_nColumns, const Size& rPaperSize ) +void PrinterListener::setMultipage( const MultiPageSetup& i_rMPS ) { - mpImplData->mnMultiPageRows = i_nRows; - mpImplData->mnMultiPageColumns = i_nColumns; - mpImplData->maMultiPageSize = rPaperSize; + mpImplData->maMultiPage = i_rMPS; +} + +const PrinterListener::MultiPageSetup& PrinterListener::getMultipage() const +{ + return mpImplData->maMultiPage; } /* diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 58d8010f0a2c..148af441b8ec 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -124,19 +124,19 @@ ModalDialog SV_DLG_PRINT FixedLine SV_PRINT_PRT_NUP { - Pos = MAP_APPFONT( 5, 10 ); + Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "N-Up printing"; }; FixedText SV_PRINT_PRT_NUP_ROWS_TXT { - Pos = MAP_APPFONT( 10, 25 ); + Pos = MAP_APPFONT( 10, 20 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "~Rows"; }; NumericField SV_PRINT_PRT_NUP_ROWS_EDT { - Pos = MAP_APPFONT( 55, 25 ); + Pos = MAP_APPFONT( 55, 20 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -146,13 +146,13 @@ ModalDialog SV_DLG_PRINT }; FixedText SV_PRINT_PRT_NUP_COLUMNS_TXT { - Pos = MAP_APPFONT( 10, 50 ); + Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "C~olumns"; }; NumericField SV_PRINT_PRT_NUP_COLUMNS_EDT { - Pos = MAP_APPFONT( 55, 50 ); + Pos = MAP_APPFONT( 55, 35 ); Size = MAP_APPFONT( 40, 12 ); Border = TRUE; Spin = TRUE; @@ -160,18 +160,121 @@ ModalDialog SV_DLG_PRINT Maximum = 32; Value = 1; }; + CheckBox SV_PRINT_PRT_NUP_BORDER_CB + { + Pos = MAP_APPFONT( 10, 50 ); + Size = MAP_APPFONT( 150, 12 ); + Text [en-US] = "~Draw a Border around each page"; + }; RadioButton SV_PRINT_PRT_NUP_PORTRAIT { - Pos = MAP_APPFONT( 110, 25 ); + Pos = MAP_APPFONT( 110, 20 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "Po~rtrait"; }; RadioButton SV_PRINT_PRT_NUP_LANDSCAPE { - Pos = MAP_APPFONT( 110, 35 ); + Pos = MAP_APPFONT( 110, 30 ); Size = MAP_APPFONT( 90, 10 ); Text [en-US] = "~Landscape"; }; + FixedLine SV_PRINT_PRT_NUP_MARGINS_FL + { + Pos = MAP_APPFONT( 5, 65 ); + Size = MAP_APPFONT( 150, 10 ); + Text [en-US] = "Margins"; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT + { + Pos = MAP_APPFONT( 10, 80 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Left"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT + { + Pos = MAP_APPFONT( 55, 80 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT + { + Pos = MAP_APPFONT( 110, 80 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Right"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT + { + Pos = MAP_APPFONT( 155, 80 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_TOP_TXT + { + Pos = MAP_APPFONT( 10, 95 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Top"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_TOP_EDT + { + Pos = MAP_APPFONT( 55, 95 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT + { + Pos = MAP_APPFONT( 110, 95 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Bottom"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT + { + Pos = MAP_APPFONT( 155, 95 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + + FixedText SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT + { + Pos = MAP_APPFONT( 10, 115 ); + Size = MAP_APPFONT( 80, 10 ); + Text [en-US] = "~Horizontal spacing"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT + { + Pos = MAP_APPFONT( 95, 115 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT + { + Pos = MAP_APPFONT( 10, 130 ); + Size = MAP_APPFONT( 80, 10 ); + Text [en-US] = "~Vertical spacing"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT + { + Pos = MAP_APPFONT( 95, 130 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; }; TabPage SV_PRINT_TAB_JOB diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index e94b0803df4a..14bd0eb1c26d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -115,8 +115,22 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) , maNupColTxt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_TXT ) ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_EDT ) ) + , maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) ) , maNupPortrait( this, VclResId( SV_PRINT_PRT_NUP_PORTRAIT ) ) , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) + , maMargins( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_FL ) ) + , maLeftMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT ) ) + , maLeftMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT) ) + , maRightMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT ) ) + , maRightMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT ) ) + , maTopMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_TOP_TXT ) ) + , maTopMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_TOP_EDT ) ) + , maBottomMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT ) ) + , maBottomMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT ) ) + , maHSpaceTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT ) ) + , maHSpaceEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT ) ) + , maVSpaceTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT ) ) + , maVSpaceEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT ) ) { FreeResource(); maNupLine.SMHID2( "NUpPage", "NUPline" ); @@ -126,14 +140,42 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maNupColEdt.SMHID2( "NUpPage", "NUPColumns" ); maNupPortrait.SMHID2( "NUpPage", "NUPPortrait" ); maNupLandscape.SMHID2( "NUpPage", "NUPLandscape" ); + maBorderCB.SMHID2( "NUpPage", "NUPBorder" ); + maMargins.SMHID2( "NUpPage", "NUPMargins" ); + maLeftMarginTxt.SMHID2( "NUpPage", "NUPLeftText" ); + maLeftMarginEdt.SMHID2( "NUpPage", "NUPLeft" ); + maTopMarginTxt.SMHID2( "NUpPage", "NUPTopText" ); + maTopMarginEdt.SMHID2( "NUpPage", "NUPTop" ); + maRightMarginTxt.SMHID2( "NUpPage", "NUPRightText" ); + maRightMarginEdt.SMHID2( "NUpPage", "NUPRight" ); + maBottomMarginTxt.SMHID2( "NUpPage", "NUPBottomText" ); + maBottomMarginEdt.SMHID2( "NUpPage", "NUPBottom" ); + maHSpaceTxt.SMHID2( "NUpPage", "NUPHSpaceText" ); + maHSpaceEdt.SMHID2( "NUpPage", "NUPHSpace" ); + maVSpaceTxt.SMHID2( "NUpPage", "NUPVSpaceText" ); + maVSpaceEdt.SMHID2( "NUpPage", "NUPVSpace" ); } PrintDialog::NUpTabPage::~NUpTabPage() { } +void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& i_rMPS ) +{ + maLeftMarginEdt.SetValue( i_rMPS.nLeftMargin, FUNIT_100TH_MM ); + maTopMarginEdt.SetValue( i_rMPS.nTopMargin, FUNIT_100TH_MM ); + maRightMarginEdt.SetValue( i_rMPS.nRightMargin, FUNIT_100TH_MM ); + maBottomMarginEdt.SetValue( i_rMPS.nBottomMargin, FUNIT_100TH_MM ); + maHSpaceEdt.SetValue( i_rMPS.nHorizontalSpacing, FUNIT_100TH_MM ); + maVSpaceEdt.SetValue( i_rMPS.nVerticalSpacing, FUNIT_100TH_MM ); + maBorderCB.Check( i_rMPS.bDrawBorder ); + maNupRowsEdt.SetValue( i_rMPS.nRows ); + maNupColEdt.SetValue( i_rMPS.nColumns ); +} + void PrintDialog::NUpTabPage::readFromSettings() { + #if 0 SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; @@ -153,10 +195,12 @@ void PrintDialog::NUpTabPage::readFromSettings() maNupPortrait.Check(); else maNupLandscape.Check(); + #endif } void PrintDialog::NUpTabPage::storeToSettings() { + #if 0 SettingsConfigItem* pItem = SettingsConfigItem::get(); pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ), @@ -167,6 +211,7 @@ void PrintDialog::NUpTabPage::storeToSettings() pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ), rtl::OUString::createFromAscii( maNupPortrait.IsChecked() ? "true" : "false" ) ); + #endif } PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) @@ -208,10 +253,14 @@ void PrintDialog::JobTabPage::readFromSettings() rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); + #if 0 + // do not actually make copy count persistent + // the assumption is that this would lead to a lot of unwanted copies aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Copies" ) ) ); sal_Int32 nVal = aValue.toInt32(); maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); + #endif aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); @@ -336,6 +385,8 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetMultipage() ); + // setup click handler on the various buttons maOKButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); @@ -348,12 +399,19 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetMultipage( nRows, nCols, - maNUpPage.maNupPortrait.IsChecked() - ? maNupPortraitSize : maNupLandscapeSize ); + PrinterListener::MultiPageSetup aMPS; + aMPS.nRows = nRows; + aMPS.nColumns = nCols; + aMPS.aPaperSize = maNUpPage.maNupPortrait.IsChecked() + ? maNupPortraitSize : maNupLandscapeSize; + aMPS.nLeftMargin = long(maNUpPage.maLeftMarginEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nTopMargin = long(maNUpPage.maTopMarginEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nRightMargin = long(maNUpPage.maRightMarginEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nBottomMargin = long(maNUpPage.maBottomMarginEdt.GetValue( FUNIT_100TH_MM )); + + aMPS.nHorizontalSpacing = long(maNUpPage.maHSpaceEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nVerticalSpacing = long(maNUpPage.maVSpaceEdt.GetValue( FUNIT_100TH_MM )); + + aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); + + maPListener->setMultipage( aMPS ); preparePreview(); } @@ -1123,7 +1194,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maPListener->getPrinter()->Setup( this ); } checkControlDependencies(); - if( pButton == &maNUpPage.maNupPortrait || pButton == &maNUpPage.maNupLandscape ) + if( pButton == &maNUpPage.maNupPortrait || pButton == &maNUpPage.maNupLandscape || pButton == &maNUpPage.maBorderCB ) updateNup(); } return 0; @@ -1132,7 +1203,11 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { checkControlDependencies(); - if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt ) + if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt || + pEdit == &maNUpPage.maLeftMarginEdt || pEdit == &maNUpPage.maTopMarginEdt || + pEdit == &maNUpPage.maRightMarginEdt || pEdit == &maNUpPage.maBottomMarginEdt || + pEdit == &maNUpPage.maHSpaceEdt || pEdit == &maNUpPage.maVSpaceEdt + ) { updateNup(); } From 706d4c761e10840fc03458896a0360c514b6cae1 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 10 Jun 2009 12:10:29 +0000 Subject: [PATCH 092/283] locale dependent metric field unit --- vcl/source/window/printdlg.cxx | 52 ++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 14bd0eb1c26d..a79537aacf27 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -45,6 +45,8 @@ #include "vcl/help.hxx" #include "vcl/decoview.hxx" +#include "unotools/localedatawrapper.hxx" + #include "rtl/ustrbuf.hxx" #include "com/sun/star/awt/Size.hpp" @@ -133,6 +135,32 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maVSpaceEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT ) ) { FreeResource(); + + // setup field units for metric fields + const LocaleDataWrapper& rLocWrap( maLeftMarginEdt.GetLocaleDataWrapper() ); + FieldUnit eUnit = FUNIT_MM; + USHORT nDigits = 0; + if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) + { + eUnit = FUNIT_INCH; + nDigits = 2; + } + // set units + maLeftMarginEdt.SetUnit( eUnit ); + maTopMarginEdt.SetUnit( eUnit ); + maRightMarginEdt.SetUnit( eUnit ); + maBottomMarginEdt.SetUnit( eUnit ); + maHSpaceEdt.SetUnit( eUnit ); + maVSpaceEdt.SetUnit( eUnit ); + + // set precision + maLeftMarginEdt.SetDecimalDigits( nDigits ); + maTopMarginEdt.SetDecimalDigits( nDigits ); + maRightMarginEdt.SetDecimalDigits( nDigits ); + maBottomMarginEdt.SetDecimalDigits( nDigits ); + maHSpaceEdt.SetDecimalDigits( nDigits ); + maVSpaceEdt.SetDecimalDigits( nDigits ); + maNupLine.SMHID2( "NUpPage", "NUPline" ); maNupRowsTxt.SMHID2( "NUpPage", "NUPRowsText" ); maNupRowsEdt.SMHID2( "NUpPage", "NUPRows" ); @@ -162,12 +190,12 @@ PrintDialog::NUpTabPage::~NUpTabPage() void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& i_rMPS ) { - maLeftMarginEdt.SetValue( i_rMPS.nLeftMargin, FUNIT_100TH_MM ); - maTopMarginEdt.SetValue( i_rMPS.nTopMargin, FUNIT_100TH_MM ); - maRightMarginEdt.SetValue( i_rMPS.nRightMargin, FUNIT_100TH_MM ); - maBottomMarginEdt.SetValue( i_rMPS.nBottomMargin, FUNIT_100TH_MM ); - maHSpaceEdt.SetValue( i_rMPS.nHorizontalSpacing, FUNIT_100TH_MM ); - maVSpaceEdt.SetValue( i_rMPS.nVerticalSpacing, FUNIT_100TH_MM ); + maLeftMarginEdt.SetValue( maLeftMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); + maTopMarginEdt.SetValue( maTopMarginEdt.Normalize( i_rMPS.nTopMargin ), FUNIT_100TH_MM ); + maRightMarginEdt.SetValue( maRightMarginEdt.Normalize( i_rMPS.nRightMargin ), FUNIT_100TH_MM ); + maBottomMarginEdt.SetValue( maBottomMarginEdt.Normalize( i_rMPS.nBottomMargin ), FUNIT_100TH_MM ); + maHSpaceEdt.SetValue( maHSpaceEdt.Normalize( i_rMPS.nHorizontalSpacing ), FUNIT_100TH_MM ); + maVSpaceEdt.SetValue( maVSpaceEdt.Normalize( i_rMPS.nVerticalSpacing ), FUNIT_100TH_MM ); maBorderCB.Check( i_rMPS.bDrawBorder ); maNupRowsEdt.SetValue( i_rMPS.nRows ); maNupColEdt.SetValue( i_rMPS.nColumns ); @@ -1143,13 +1171,13 @@ void PrintDialog::updateNup() aMPS.nColumns = nCols; aMPS.aPaperSize = maNUpPage.maNupPortrait.IsChecked() ? maNupPortraitSize : maNupLandscapeSize; - aMPS.nLeftMargin = long(maNUpPage.maLeftMarginEdt.GetValue( FUNIT_100TH_MM )); - aMPS.nTopMargin = long(maNUpPage.maTopMarginEdt.GetValue( FUNIT_100TH_MM )); - aMPS.nRightMargin = long(maNUpPage.maRightMarginEdt.GetValue( FUNIT_100TH_MM )); - aMPS.nBottomMargin = long(maNUpPage.maBottomMarginEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nLeftMargin = long(maNUpPage.maLeftMarginEdt.Denormalize(maNUpPage.maLeftMarginEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nTopMargin = long(maNUpPage.maTopMarginEdt.Denormalize(maNUpPage.maTopMarginEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nRightMargin = long(maNUpPage.maRightMarginEdt.Denormalize(maNUpPage.maRightMarginEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nBottomMargin = long(maNUpPage.maBottomMarginEdt.Denormalize(maNUpPage.maBottomMarginEdt.GetValue( FUNIT_100TH_MM ))); - aMPS.nHorizontalSpacing = long(maNUpPage.maHSpaceEdt.GetValue( FUNIT_100TH_MM )); - aMPS.nVerticalSpacing = long(maNUpPage.maVSpaceEdt.GetValue( FUNIT_100TH_MM )); + aMPS.nHorizontalSpacing = long(maNUpPage.maHSpaceEdt.Denormalize(maNUpPage.maHSpaceEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nVerticalSpacing = long(maNUpPage.maVSpaceEdt.Denormalize(maNUpPage.maVSpaceEdt.GetValue( FUNIT_100TH_MM ))); aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); From 2651918016923f6f9cd617aa84c1b7d40c1ed914 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 10 Jun 2009 12:18:55 +0000 Subject: [PATCH 093/283] avoid overpainting of border --- vcl/source/window/printdlg.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a79537aacf27..121278bf21df 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1428,9 +1428,9 @@ void PrintDialog::Resize() aPrefSize.Width() = nPreviewLength - 2* aPixDiff.Width(); Point aCtrlPos( 2*aPixDiff.Width(), 3*aPixDiff.Height() + nPreviewLength ); maPreviewCtrlRow.setManagedArea( Rectangle( aCtrlPos, aPrefSize ) ); - maPreviewBackground.Left() = aPixDiff.Width(); - maPreviewBackground.Top() = aPixDiff.Height(); - maPreviewBackground.Right() = aPixDiff.Width() + nPreviewLength; + maPreviewBackground.Left() = aPixDiff.Width() - 2; + maPreviewBackground.Top() = aPixDiff.Height() - 2; + maPreviewBackground.Right() = aPixDiff.Width() + nPreviewLength + 2; maPreviewBackground.Bottom() = maPreviewCtrlRow.getManagedArea().Bottom() + aPixDiff.Height(); // and do the preview; however the metafile does not need to be gotten anew From 00f2ce881250398b2eb892deac038aa85fbf1636 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 10 Jun 2009 13:22:04 +0000 Subject: [PATCH 094/283] add: page repeat for N-Up --- vcl/inc/vcl/print.hxx | 3 +- vcl/inc/vcl/prndlg.hxx | 2 + vcl/inc/vcl/svids.hrc | 2 + vcl/source/gdi/print3.cxx | 55 ++++++++--------- vcl/source/src/print.src | 104 +++++++++++++++++++-------------- vcl/source/window/printdlg.cxx | 14 ++++- 6 files changed, 106 insertions(+), 74 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 6d63d7a6ab23..8b5d711d129f 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -451,6 +451,7 @@ public: // all metrics in 100th mm int nRows; int nColumns; + int nRepeat; Size aPaperSize; long nLeftMargin; long nTopMargin; @@ -461,7 +462,7 @@ public: bool bDrawBorder; MultiPageSetup() - : nRows( 1 ), nColumns( 1 ), aPaperSize( 21000, 29700 ) + : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) , nLeftMargin( 0 ), nTopMargin( 0 ) , nRightMargin( 0 ), nBottomMargin( 0 ) , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 384dcd2451e3..4d1ead6018e2 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -86,6 +86,8 @@ namespace vcl NumericField maNupRowsEdt; FixedText maNupColTxt; NumericField maNupColEdt; + FixedText maNupRepTxt; + NumericField maNupRepEdt; CheckBox maBorderCB; RadioButton maNupPortrait; RadioButton maNupLandscape; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 4c512d056153..0edbd5661335 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -110,6 +110,8 @@ #define SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT 19 #define SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT 20 #define SV_PRINT_PRT_NUP_BORDER_CB 21 +#define SV_PRINT_PRT_NUP_PAGEREPEAT_TXT 22 +#define SV_PRINT_PRT_NUP_PAGEREPEAT_EDT 23 #define SV_PRINT_TAB_JOB 2 #define SV_PRINT_PRINTERS 1 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e873b1cc068d..00fda02135a3 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -513,35 +513,38 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r o_rMtf.AddAction( new MetaMapModeAction( MapMode( MAP_100TH_MM ) ) ); int nDocPages = getPageCount(); - for( int nPage = i_nFilteredPage * nSubPages, nSubP = 0; - nPage < (i_nFilteredPage+1)*nSubPages && nPage < nDocPages; - nPage++, nSubP++ ) + for( int nSubPage = 0; nSubPage < nSubPages; nSubPage++ ) { - GDIMetaFile aPageFile; - Size aPageSize = getPageFile( nPage, aPageFile ); - if( aPageSize.Width() && aPageSize.Height() ) + // map current sub page to real page + int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; + if( nPage < nDocPages ) { - // scale the metafile down to a sub page size - double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); - double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); - double fScale = std::min( fScaleX, fScaleY ); - aPageFile.Scale( fScale, fScale ); - aPageFile.WindStart(); + GDIMetaFile aPageFile; + Size aPageSize = getPageFile( nPage, aPageFile ); + if( aPageSize.Width() && aPageSize.Height() ) + { + // scale the metafile down to a sub page size + double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); + double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); + double fScale = std::min( fScaleX, fScaleY ); + aPageFile.Scale( fScale, fScale ); + aPageFile.WindStart(); - // move the subpage so it is centered in its "cell" - long nOffX = (aSubPageSize.Width() - long(double(aPageSize.Width()) * fScale)) / 2; - long nOffY = (aSubPageSize.Height() - long(double(aPageSize.Height()) * fScale)) / 2; - long nX = rMPS.nLeftMargin + nOffX + nAdvX * (nSubP % rMPS.nColumns); - long nY = rMPS.nTopMargin + nOffY + nAdvY * (nSubP / rMPS.nColumns); - aPageFile.Move( nX, nY ); - aPageFile.WindStart(); - // calculate border rectangle - Rectangle aSubPageRect( Point( nX, nY ), - Size( long(double(aPageSize.Width())*fScale), - long(double(aPageSize.Height())*fScale) ) ); + // move the subpage so it is centered in its "cell" + long nOffX = (aSubPageSize.Width() - long(double(aPageSize.Width()) * fScale)) / 2; + long nOffY = (aSubPageSize.Height() - long(double(aPageSize.Height()) * fScale)) / 2; + long nX = rMPS.nLeftMargin + nOffX + nAdvX * (nSubPage % rMPS.nColumns); + long nY = rMPS.nTopMargin + nOffY + nAdvY * (nSubPage / rMPS.nColumns); + aPageFile.Move( nX, nY ); + aPageFile.WindStart(); + // calculate border rectangle + Rectangle aSubPageRect( Point( nX, nY ), + Size( long(double(aPageSize.Width())*fScale), + long(double(aPageSize.Height())*fScale) ) ); - // append subpage to page - appendSubPage( o_rMtf, aSubPageRect, aPageFile, rMPS.bDrawBorder ); + // append subpage to page + appendSubPage( o_rMtf, aSubPageRect, aPageFile, rMPS.bDrawBorder ); + } } } o_rMtf.WindStart(); @@ -554,7 +557,7 @@ int PrinterListener::getFilteredPageCount() int nDiv = mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns; if( nDiv < 1 ) nDiv = 1; - return (getPageCount() + (nDiv-1)) / nDiv; + return (getPageCount() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; } void PrinterListener::printFilteredPage( int i_nPage ) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 148af441b8ec..d629ba7c04d2 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -38,18 +38,18 @@ ModalDialog SV_DLG_PRINT Moveable = TRUE; SVLook = TRUE; - Size = MAP_APPFONT( 350, 205 ); + Size = MAP_APPFONT( 350, 215 ); OKButton SV_PRINT_OK { DefButton = TRUE; - Pos = MAP_APPFONT( 240, 185 ); + Pos = MAP_APPFONT( 240, 195 ); Size = MAP_APPFONT( 50, 15 ); Text [en-US] = "~Print"; }; CancelButton SV_PRINT_CANCEL { - Pos = MAP_APPFONT( 295, 185 ); + Pos = MAP_APPFONT( 295, 195 ); Size = MAP_APPFONT( 50, 15 ); }; @@ -87,12 +87,12 @@ ModalDialog SV_DLG_PRINT TabControl SV_PRINT_TABCTRL { Pos = MAP_APPFONT( 140, 5 ); - Size = MAP_APPFONT( 205, 165 ); + Size = MAP_APPFONT( 205, 175 ); // DropDown = TRUE; }; FixedLine SV_PRINT_BUTTONLINE { - Pos = MAP_APPFONT( 0, 175 ); + Pos = MAP_APPFONT( 0, 185 ); Size = MAP_APPFONT( 350, 8 ); }; String SV_PRINT_NOPAGES @@ -160,9 +160,25 @@ ModalDialog SV_DLG_PRINT Maximum = 32; Value = 1; }; - CheckBox SV_PRINT_PRT_NUP_BORDER_CB + FixedText SV_PRINT_PRT_NUP_PAGEREPEAT_TXT { Pos = MAP_APPFONT( 10, 50 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Repeat"; + }; + NumericField SV_PRINT_PRT_NUP_PAGEREPEAT_EDT + { + Pos = MAP_APPFONT( 55, 50 ); + Size = MAP_APPFONT( 40, 12 ); + Border = TRUE; + Spin = TRUE; + Minimum = 1; + Maximum = 32; + Value = 1; + }; + CheckBox SV_PRINT_PRT_NUP_BORDER_CB + { + Pos = MAP_APPFONT( 10, 65 ); Size = MAP_APPFONT( 150, 12 ); Text [en-US] = "~Draw a Border around each page"; }; @@ -180,47 +196,17 @@ ModalDialog SV_DLG_PRINT }; FixedLine SV_PRINT_PRT_NUP_MARGINS_FL { - Pos = MAP_APPFONT( 5, 65 ); + Pos = MAP_APPFONT( 5, 80 ); Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Margins"; }; FixedText SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT { - Pos = MAP_APPFONT( 10, 80 ); + Pos = MAP_APPFONT( 10, 95 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "~Left"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT - { - Pos = MAP_APPFONT( 55, 80 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; - Border = TRUE; - Value = 0; - Unit = FUNIT_MM; - }; - FixedText SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT - { - Pos = MAP_APPFONT( 110, 80 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Right"; - }; - MetricField SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT - { - Pos = MAP_APPFONT( 155, 80 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; - Border = TRUE; - Value = 0; - Unit = FUNIT_MM; - }; - FixedText SV_PRINT_PRT_NUP_MARGINS_TOP_TXT - { - Pos = MAP_APPFONT( 10, 95 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Top"; - }; - MetricField SV_PRINT_PRT_NUP_MARGINS_TOP_EDT { Pos = MAP_APPFONT( 55, 95 ); Size = MAP_APPFONT( 40, 12 ); @@ -229,15 +215,45 @@ ModalDialog SV_DLG_PRINT Value = 0; Unit = FUNIT_MM; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT + FixedText SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT { Pos = MAP_APPFONT( 110, 95 ); Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Right"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT + { + Pos = MAP_APPFONT( 155, 95 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_TOP_TXT + { + Pos = MAP_APPFONT( 10, 110 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "~Top"; + }; + MetricField SV_PRINT_PRT_NUP_MARGINS_TOP_EDT + { + Pos = MAP_APPFONT( 55, 110 ); + Size = MAP_APPFONT( 40, 12 ); + Spin = TRUE; + Border = TRUE; + Value = 0; + Unit = FUNIT_MM; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT + { + Pos = MAP_APPFONT( 110, 110 ); + Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "~Bottom"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT { - Pos = MAP_APPFONT( 155, 95 ); + Pos = MAP_APPFONT( 155, 110 ); Size = MAP_APPFONT( 40, 12 ); Spin = TRUE; Border = TRUE; @@ -247,13 +263,13 @@ ModalDialog SV_DLG_PRINT FixedText SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT { - Pos = MAP_APPFONT( 10, 115 ); + Pos = MAP_APPFONT( 10, 130 ); Size = MAP_APPFONT( 80, 10 ); Text [en-US] = "~Horizontal spacing"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT { - Pos = MAP_APPFONT( 95, 115 ); + Pos = MAP_APPFONT( 95, 130 ); Size = MAP_APPFONT( 40, 12 ); Spin = TRUE; Border = TRUE; @@ -262,13 +278,13 @@ ModalDialog SV_DLG_PRINT }; FixedText SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT { - Pos = MAP_APPFONT( 10, 130 ); + Pos = MAP_APPFONT( 10, 145 ); Size = MAP_APPFONT( 80, 10 ); Text [en-US] = "~Vertical spacing"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT { - Pos = MAP_APPFONT( 95, 130 ); + Pos = MAP_APPFONT( 95, 145 ); Size = MAP_APPFONT( 40, 12 ); Spin = TRUE; Border = TRUE; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 121278bf21df..6d9772f8b5f2 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -117,6 +117,8 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) , maNupColTxt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_TXT ) ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_EDT ) ) + , maNupRepTxt( this, VclResId( SV_PRINT_PRT_NUP_PAGEREPEAT_TXT ) ) + , maNupRepEdt( this, VclResId( SV_PRINT_PRT_NUP_PAGEREPEAT_EDT ) ) , maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) ) , maNupPortrait( this, VclResId( SV_PRINT_PRT_NUP_PORTRAIT ) ) , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) @@ -166,6 +168,8 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maNupRowsEdt.SMHID2( "NUpPage", "NUPRows" ); maNupColTxt.SMHID2( "NUpPage", "NUPColumnsText" ); maNupColEdt.SMHID2( "NUpPage", "NUPColumns" ); + maNupRepTxt.SMHID2( "NUpPage", "NUPRepeatText" ); + maNupRepEdt.SMHID2( "NUpPage", "NUPRepeat" ); maNupPortrait.SMHID2( "NUpPage", "NUPPortrait" ); maNupLandscape.SMHID2( "NUpPage", "NUPLandscape" ); maBorderCB.SMHID2( "NUpPage", "NUPBorder" ); @@ -199,6 +203,7 @@ void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterListener maBorderCB.Check( i_rMPS.bDrawBorder ); maNupRowsEdt.SetValue( i_rMPS.nRows ); maNupColEdt.SetValue( i_rMPS.nColumns ); + maNupRepEdt.SetValue( i_rMPS.nRepeat ); } void PrintDialog::NUpTabPage::readFromSettings() @@ -434,6 +439,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Wed, 10 Jun 2009 17:21:10 +0000 Subject: [PATCH 095/283] page cache for faster preview --- vcl/inc/vcl/print.hxx | 4 +- vcl/inc/vcl/prndlg.hxx | 2 +- vcl/source/gdi/print3.cxx | 98 ++++++++++++++++++++++++++++++++-- vcl/source/window/printdlg.cxx | 10 ++-- 4 files changed, 102 insertions(+), 12 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 8b5d711d129f..5e9f0834c574 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -516,8 +516,8 @@ public: // implementation details, not usable outside vcl int SAL_DLLPRIVATE getFilteredPageCount(); - Size SAL_DLLPRIVATE getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf ); - Size SAL_DLLPRIVATE getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ); + Size SAL_DLLPRIVATE getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); + Size SAL_DLLPRIVATE getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); void SAL_DLLPRIVATE printFilteredPage( int i_nPage ); void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 4d1ead6018e2..c2e8beaa16e9 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -180,7 +180,7 @@ namespace vcl Rectangle maPreviewBackground; void updateNup(); - void preparePreview( bool i_bPrintChanged = true ); + void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); void setPreviewText( sal_Int32 ); void updatePrinterText(); void checkControlDependencies(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 00fda02135a3..1ef2e18b996a 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -57,6 +57,79 @@ using namespace com::sun::star::uno; using namespace com::sun::star::beans; using namespace vcl; +class ImplPageCache +{ + std::vector< GDIMetaFile > maPages; + std::vector< sal_Int32 > maPageNumbers; + std::vector< sal_Int32 > maCacheRanking; + + static const sal_Int32 nCacheSize = 6; + + void updateRanking( sal_Int32 nLastHit ) + { + if( maCacheRanking[0] != nLastHit ) + { + bool bMove = false; + for( sal_Int32 i = nCacheSize-1; i > 0; i-- ) + { + if( maCacheRanking[i] == nLastHit ) + bMove = true; + maCacheRanking[i] = maCacheRanking[i-1]; + } + maCacheRanking[0] = nLastHit; + } + } + +public: + ImplPageCache() + : maPages( nCacheSize ) + , maPageNumbers( nCacheSize, -1 ) + , maCacheRanking( nCacheSize ) + { + for( sal_Int32 i = 0; i < nCacheSize; i++ ) + maCacheRanking[i] = nCacheSize - i - 1; + } + + // caution: does not ensure uniqueness + void insert( sal_Int32 i_nPageNo, const GDIMetaFile& i_rPage ) + { + sal_Int32 nReplacePage = maCacheRanking.back(); + maPages[ nReplacePage ] = i_rPage; + maPageNumbers[ nReplacePage ] = i_nPageNo; + // cache insertion means in our case, the page was just queried + // so update the ranking + updateRanking( nReplacePage ); + } + + // caution: bad algorithm; should there ever be reason to increase the cache size beyond 6 + // this needs to be urgently rewritten. However do NOT increase the cache size lightly, + // whole pages can be rather memory intensive + const GDIMetaFile* get( sal_Int32 i_nPageNo ) + { + const GDIMetaFile* pRet = NULL; + for( sal_Int32 i = 0; i < nCacheSize; ++i ) + { + if( maPageNumbers[i] == i_nPageNo ) + { + updateRanking( i ); + pRet = &maPages[i]; + break; + } + } + return pRet; + } + + void invalidate() + { + for( sal_Int32 i = 0; i < nCacheSize; ++i ) + { + maPageNumbers[i] = -1; + maPages[i].Clear(); + maCacheRanking[i] = nCacheSize - i - 1; + } + } +}; + class vcl::ImplPrinterListenerData { public: @@ -84,6 +157,8 @@ public: vcl::PrintProgressDialog* mpProgress; + ImplPageCache maPageCache; + ImplPrinterListenerData() : mbLastPage( sal_False ), mpProgress( NULL ) @@ -401,7 +476,7 @@ static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& return aPageSize; } -Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) +Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { // update progress if necessary if( mpImplData->mpProgress ) @@ -413,6 +488,18 @@ Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) Application::Reschedule( true ); } + if( i_bMayUseCache ) + { + const GDIMetaFile* pCached = mpImplData->maPageCache.get( i_nUnfilteredPage ); + if( pCached ) + { + o_rMtf = *pCached; + return pCached->GetPrefSize(); + } + } + else + mpImplData->maPageCache.invalidate(); + o_rMtf.Clear(); // get page parameters @@ -438,6 +525,9 @@ Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf ) o_rMtf.WindStart(); mpImplData->mpPrinter->Pop(); + if( i_bMayUseCache ) + mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf ); + return aPageSize; } @@ -474,7 +564,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD o_rMtf.AddAction( new MetaPopAction() ); } -Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf ) +Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { const MultiPageSetup& rMPS( mpImplData->maMultiPage ); int nSubPages = rMPS.nRows * rMPS.nColumns; @@ -488,7 +578,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r rMPS.nLeftMargin == 0 && rMPS.nRightMargin == 0 && rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 ) { - return getPageFile( i_nFilteredPage, o_rMtf ); + return getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); } Size aPaperSize( mpImplData->maMultiPage.aPaperSize ); @@ -520,7 +610,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r if( nPage < nDocPages ) { GDIMetaFile aPageFile; - Size aPageSize = getPageFile( nPage, aPageFile ); + Size aPageSize = getPageFile( nPage, aPageFile, i_bMayUseCache ); if( aPageSize.Width() && aPageSize.Height() ) { // scale the metafile down to a sub page size diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 6d9772f8b5f2..7bc771e7493e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -365,7 +365,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& rQueues( Printer::GetPrinterQueues() ); @@ -1114,7 +1114,7 @@ void PrintDialog::setPreviewText( sal_Int32 ) maNumPagesText.SetText( maNoPageStr ); } -void PrintDialog::preparePreview( bool i_bNewPage ) +void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) { // page range may have changed depending on options sal_Int32 nPages = maPListener->getFilteredPageCount(); @@ -1138,7 +1138,7 @@ void PrintDialog::preparePreview( bool i_bNewPage ) const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; if( nPages > 0 ) - maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf ); + maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); maPreviewWindow.setPreview( aMtf ); } @@ -1191,7 +1191,7 @@ void PrintDialog::updateNup() maPListener->setMultipage( aMPS ); - preparePreview(); + preparePreview( true, true ); } IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) @@ -1250,7 +1250,7 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) else if( pEdit == &maPageEdit ) { mnCurPage = sal_Int32( maPageEdit.GetValue() - 1 ); - preparePreview(); + preparePreview( true, true ); } return 0; } From 4eef171d081c2ebf0005798f1ae038fb2d899441 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 11 Jun 2009 08:54:51 +0000 Subject: [PATCH 096/283] make old Start/EndJob Start/EndPage dll private --- vcl/inc/vcl/arrange.hxx | 4 ++-- vcl/inc/vcl/print.hxx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 1f085521c818..2005418fe740 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -212,8 +212,8 @@ namespace vcl virtual void resize() {} virtual void setParentWindow( Window* ) {} virtual size_t countElements() const { return 1; } - virtual boost::shared_ptr getChild( size_t i_nIndex ) const { return boost::shared_ptr(); } - virtual Window* getWindow( size_t i_nIndex ) const { return NULL; } + virtual boost::shared_ptr getChild( size_t ) const { return boost::shared_ptr(); } + virtual Window* getWindow( size_t ) const { return NULL; } virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } }; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 5e9f0834c574..104e51cb4f24 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -279,6 +279,10 @@ private: public: SAL_DLLPRIVATE void ImplEndPrint(); SAL_DLLPRIVATE void ImplUpdateQuickStatus(); + SAL_DLLPRIVATE BOOL StartJob( const XubString& rJobName ); + SAL_DLLPRIVATE BOOL EndJob(); + SAL_DLLPRIVATE BOOL StartPage(); + SAL_DLLPRIVATE BOOL EndPage(); private: SAL_DLLPRIVATE Printer( const Printer& rPrinter ); SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter ); @@ -374,14 +378,10 @@ public: const XubString& GetPrintFile() const { return maPrintFile; } void EnablePrintFile( BOOL bEnable ) { mbPrintFile = bEnable; } BOOL IsPrintFileEnabled() const { return mbPrintFile; } - BOOL StartJob( const XubString& rJobName ); - BOOL EndJob(); BOOL AbortJob(); const XubString& GetCurJobName() const { return maJobName; } USHORT GetCurPage() const { return mnCurPage; } BOOL IsJobActive() const { return mbJobActive; } - BOOL StartPage(); - BOOL EndPage(); void SetPageQueueSize( USHORT nPages ) { mnPageQueueSize = nPages; } USHORT GetPageQueueSize() const { return mnPageQueueSize; } From 68e6ca91d58be4b05cc2cd8d95acaf70665d3b22 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 11 Jun 2009 14:54:05 +0000 Subject: [PATCH 097/283] make compile, need to build an adaptor to new print API --- toolkit/source/awt/vclxprinter.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index 69d8dd827497..f57fd8803adf 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -332,7 +332,10 @@ sal_Bool VCLXPrinter::start( const ::rtl::OUString& rJobName, sal_Int16 /*nCopie sal_Bool bDone = sal_True; if ( GetPrinter() ) - bDone = GetPrinter()->StartJob( rJobName ); + { + // FIXME: adapt to new interface + // bDone = GetPrinter()->StartJob( rJobName ); + } return bDone; } @@ -342,7 +345,10 @@ void VCLXPrinter::end( ) throw(::com::sun::star::awt::PrinterException, ::com:: ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); if ( GetPrinter() ) - GetPrinter()->EndJob(); + { + // FIXME: adapt to new interface + // GetPrinter()->EndJob(); + } } void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException) @@ -358,7 +364,10 @@ void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException) ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); if ( GetPrinter() ) - GetPrinter()->StartPage(); + { + // FIXME: adapt to new interface + // GetPrinter()->StartPage(); + } return GetDevice(); } @@ -367,7 +376,10 @@ void VCLXPrinter::endPage( ) throw(::com::sun::star::awt::PrinterException, ::c ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); if ( GetPrinter() ) - GetPrinter()->EndPage(); + { + // FIXME: adapt to new interface + // GetPrinter()->EndPage(); + } } From 2280881e946919001cb89ee16ad5b37c210c7cbd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 11 Jun 2009 15:01:42 +0000 Subject: [PATCH 098/283] fix warning --- toolkit/source/awt/vclxprinter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index f57fd8803adf..a0d4de43fe0f 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -326,7 +326,7 @@ IMPL_XTYPEPROVIDER_START( VCLXPrinter ) VCLXPrinterPropertySet::getTypes() IMPL_XTYPEPROVIDER_END -sal_Bool VCLXPrinter::start( const ::rtl::OUString& rJobName, sal_Int16 /*nCopies*/, sal_Bool /*bCollate*/ ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) +sal_Bool VCLXPrinter::start( const ::rtl::OUString& /*rJobName*/, sal_Int16 /*nCopies*/, sal_Bool /*bCollate*/ ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); From 81249233487670c90d1c40c62c9d4241b178d17f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 12 Jun 2009 15:22:27 +0000 Subject: [PATCH 099/283] #i92516# remove old StartPage/EndPage API --- vcl/aqua/source/gdi/salprn.cxx | 1 - vcl/inc/vcl/impprn.hxx | 3 +- vcl/inc/vcl/print.h | 12 -- vcl/inc/vcl/print.hxx | 48 +---- vcl/source/gdi/makefile.mk | 2 - vcl/source/gdi/print.cxx | 360 +++++++-------------------------- vcl/source/gdi/print2.cxx | 2 - vcl/source/gdi/print3.cxx | 11 +- 8 files changed, 85 insertions(+), 354 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index f58c63b19079..8e22a83e1403 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -38,7 +38,6 @@ #include "saldata.hxx" #include "vcl/jobset.h" #include "vcl/salptype.hxx" -#include "vcl/impprn.hxx" #include "vcl/print.hxx" #include "vcl/unohelp.hxx" diff --git a/vcl/inc/vcl/impprn.hxx b/vcl/inc/vcl/impprn.hxx index c86090e8b49f..0cd6e9688201 100644 --- a/vcl/inc/vcl/impprn.hxx +++ b/vcl/inc/vcl/impprn.hxx @@ -28,7 +28,7 @@ * ************************************************************************/ -#ifndef _SV_IMPPRN_HXX +#if 0 #define _SV_IMPPRN_HXX #include @@ -107,7 +107,6 @@ public: /** used by pull implementation to emit the next page */ - using Printer::PrintPage; void PrintPage( unsigned int nPage ); /** used by pull implementation to get the number of physical pages diff --git a/vcl/inc/vcl/print.h b/vcl/inc/vcl/print.h index bc74b6441f28..12c7439aa5b3 100644 --- a/vcl/inc/vcl/print.h +++ b/vcl/inc/vcl/print.h @@ -44,18 +44,6 @@ class JobSetup; namespace vcl { class PrinterListener; } -// ------------------------ -// - private printer data - -// ------------------------ -struct ImplPrivatePrinterData -{ - bool mbNextJobIsQuick; - - ImplPrivatePrinterData() : - mbNextJobIsQuick( false ) - {} -}; - // -------------------- // - ImplPrnQueueData - // -------------------- diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 104e51cb4f24..18529c07b432 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -53,8 +53,6 @@ struct SalPrinterQueueInfo; class SalPrinter; class VirtualDevice; class Window; -class ImplQPrinter; -struct ImplPrivatePrinterData; namespace vcl { class PrinterListener; @@ -224,16 +222,12 @@ class VCL_DLLPUBLIC Printer : public OutputDevice friend class ImplQPrinter; private: - ImplPrivatePrinterData* mpPrinterData; SalInfoPrinter* mpInfoPrinter; SalPrinter* mpPrinter; - Printer* mpJobPrinter; SalGraphics* mpJobGraphics; Printer* mpPrev; Printer* mpNext; VirtualDevice* mpDisplayDev; - ImplQPrinter* mpQPrinter; - GDIMetaFile* mpQMtf; PrinterOptions* mpPrinterOptions; XubString maPrinterName; XubString maDriver; @@ -258,9 +252,6 @@ private: BOOL mbUserSetupCompleted; BOOL mbUserSetupResult; Link maErrorHdl; - Link maStartPrintHdl; - Link maEndPrintHdl; - Link maPrintPageHdl; SAL_DLLPRIVATE void ImplInitData(); SAL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo ); @@ -276,24 +267,19 @@ private: static SAL_DLLPRIVATE ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError ); -public: +private: SAL_DLLPRIVATE void ImplEndPrint(); - SAL_DLLPRIVATE void ImplUpdateQuickStatus(); SAL_DLLPRIVATE BOOL StartJob( const XubString& rJobName ); SAL_DLLPRIVATE BOOL EndJob(); - SAL_DLLPRIVATE BOOL StartPage(); - SAL_DLLPRIVATE BOOL EndPage(); -private: SAL_DLLPRIVATE Printer( const Printer& rPrinter ); SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter ); - -#ifdef _SPOOLPRINTER_EXT +public: + SAL_DLLPRIVATE void ImplStartPage(); + SAL_DLLPRIVATE void ImplEndPage(); public: void DrawGradientEx( OutputDevice* pOut, const Rectangle& rRect, const Gradient& rGradient ); void DrawGradientEx( OutputDevice* pOut, const PolyPolygon& rPolyPoly, const Gradient& rGradient ); -#endif // _SPOOLPRINTER_EXT - protected: void SetSelfAsQueuePrinter( BOOL bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; } @@ -312,9 +298,6 @@ public: static XubString GetDefaultPrinterName(); virtual void Error(); - virtual void StartPrint(); - virtual void EndPrint(); - virtual void PrintPage(); const XubString& GetName() const { return maPrinterName; } const XubString& GetDriverName() const { return maDriver; } @@ -371,7 +354,6 @@ public: USHORT GetCopyCount() const { return mnCopyCount; } BOOL IsCollateCopy() const { return mbCollateCopy; } - USHORT GetCurPrintPage() const { return mnCurPrintPage; } BOOL IsPrinting() const { return mbPrinting; } void SetPrintFile( const XubString& rFileName ) { maPrintFile = rFileName; } @@ -383,36 +365,14 @@ public: USHORT GetCurPage() const { return mnCurPage; } BOOL IsJobActive() const { return mbJobActive; } - void SetPageQueueSize( USHORT nPages ) { mnPageQueueSize = nPages; } - USHORT GetPageQueueSize() const { return mnPageQueueSize; } - ULONG GetError() const { return ERRCODE_TOERROR(mnError); } ULONG GetErrorCode() const { return mnError; } void SetErrorHdl( const Link& rLink ) { maErrorHdl = rLink; } const Link& GetErrorHdl() const { return maErrorHdl; } - void SetStartPrintHdl( const Link& rLink ) { maStartPrintHdl = rLink; } - const Link& GetStartPrintHdl() const { return maStartPrintHdl; } - void SetEndPrintHdl( const Link& rLink ) { maEndPrintHdl = rLink; } - const Link& GetEndPrintHdl() const { return maEndPrintHdl; } - void SetPrintPageHdl( const Link& rLink ) { maPrintPageHdl = rLink; } - const Link& GetPrintPageHdl() const { return maPrintPageHdl; } void Compat_OldPrinterMetrics( bool bSet ); - /** Notify that the next StartJob belongs to a UI less "direct print" job - * - * deprecated: the canonical way to notify a UI less job is to set the - * JobSetup value "IsQuickJob" to "true". If set at all, the "IsQuickJob" value - * on JobSetup will be preferred. However if no "IsQuickJob" value is set, - * setting SetNextJobIsQuick will cause the following StartJob to set this value - * to "true" in the current JobSetup. - * - * the paramter can be set to "false" again in case a job was not started and the - * printer is to be reused. - */ - void SetNextJobIsQuick( bool bQuick = true ); - /** checks the printer list and updates it necessary * * sends a DataChanged event of type DATACHANGED_PRINTER diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 57d5804a8afa..05dc998d6651 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -76,7 +76,6 @@ SLOFILES= $(SLO)$/salmisc.obj \ $(SLO)$/impgraph.obj \ $(SLO)$/impimagetree.obj \ $(SLO)$/imagerepository.obj \ - $(SLO)$/impprn.obj \ $(SLO)$/impvect.obj \ $(SLO)$/implncvt.obj \ $(SLO)$/jobset.obj \ @@ -138,7 +137,6 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/pngread.obj \ $(SLO)$/pngwrite.obj \ $(SLO)$/virdev.obj \ - $(SLO)$/impprn.obj \ $(SLO)$/graphictools.obj diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index a74038c4eaaa..a3e33f236166 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -31,8 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#define _SPOOLPRINTER_EXT -#define _RMPRINTER_EXT #define ENABLE_BYTESTRING_STREAM_OPERATORS #include @@ -58,7 +56,6 @@ #include #include #include -#include #include #include @@ -369,7 +366,6 @@ XubString Printer::GetDefaultPrinterName() void Printer::ImplInitData() { - mpPrinterData = new ImplPrivatePrinterData(); mbDevOutput = FALSE; meOutDevType = OUTDEV_PRINTER; mbDefPrinter = FALSE; @@ -387,8 +383,6 @@ void Printer::ImplInitData() mpInfoPrinter = NULL; mpPrinter = NULL; mpDisplayDev = NULL; - mpQPrinter = NULL; - mpQMtf = NULL; mbIsQueuePrinter = FALSE; mpPrinterOptions = new PrinterOptions; @@ -435,7 +429,6 @@ void Printer::ImplInit( SalPrinterQueueInfo* pInfo ) mpInfoPrinter = pSVData->mpDefInst->CreateInfoPrinter( pInfo, pJobSetup ); mpPrinter = NULL; - mpJobPrinter = NULL; mpJobGraphics = NULL; ImplUpdateJobSetupPaper( maJobSetup ); @@ -467,7 +460,6 @@ void Printer::ImplInitDisplay( const Window* pWindow ) mpInfoPrinter = NULL; mpPrinter = NULL; - mpJobPrinter = NULL; mpJobGraphics = NULL; if ( pWindow ) @@ -623,11 +615,6 @@ Printer::~Printer() { DBG_ASSERT( !IsPrinting(), "Printer::~Printer() - Job is printing" ); DBG_ASSERT( !IsJobActive(), "Printer::~Printer() - Job is active" ); - DBG_ASSERT( !mpQPrinter, "Printer::~Printer() - QueuePrinter not destroyed" ); - DBG_ASSERT( !mpQMtf, "Printer::~Printer() - QueueMetafile not destroyed" ); - - delete mpPrinterData; - mpPrinterData = NULL; delete mpPrinterOptions; @@ -673,22 +660,12 @@ Printer::~Printer() pSVData->maGDIData.mpLastPrinter = mpPrev; } -// ----------------------------------------------------------------------- -void Printer::SetNextJobIsQuick( bool bQuick ) -{ - mpPrinterData->mbNextJobIsQuick = bQuick; - if( mpQPrinter ) - mpQPrinter->SetNextJobIsQuick( bQuick ); -} - // ----------------------------------------------------------------------- void Printer::Compat_OldPrinterMetrics( bool bSet ) { // propagate flag if( mpInfoPrinter ) mpInfoPrinter->m_bCompatMetrics = bSet; - if( mpQPrinter ) - mpQPrinter->Compat_OldPrinterMetrics( bSet ); // get new font data ImplUpdateFontData( TRUE ); @@ -1326,27 +1303,6 @@ void Printer::Error() // ----------------------------------------------------------------------- -void Printer::StartPrint() -{ - maStartPrintHdl.Call( this ); -} - -// ----------------------------------------------------------------------- - -void Printer::EndPrint() -{ - maEndPrintHdl.Call( this ); -} - -// ----------------------------------------------------------------------- - -void Printer::PrintPage() -{ - maPrintPageHdl.Call( this ); -} - -// ----------------------------------------------------------------------- - ULONG Printer::ImplSalPrinterErrorCodeToVCL( ULONG nError ) { @@ -1374,12 +1330,6 @@ void Printer::ImplEndPrint() mbPrinting = FALSE; mnCurPrintPage = 0; maJobName.Erase(); - if( mpQPrinter ) // not necessarily filled e.g. after AbortJob - { - mpQPrinter->Destroy(); - mpQPrinter = NULL; - } - EndPrint(); } // ----------------------------------------------------------------------- @@ -1394,31 +1344,6 @@ IMPL_LINK( Printer, ImplDestroyPrinterAsync, void*, pSalPrinter ) // ----------------------------------------------------------------------- -void Printer::ImplUpdateQuickStatus() -{ - // remove possibly added "IsQuickJob" - if( mpPrinterData->mbNextJobIsQuick ) - { - rtl::OUString aKey( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ); - // const data means not really const, but change all references - // to refcounted job setup - ImplJobSetup* pImpSetup = maJobSetup.ImplGetConstData(); - pImpSetup->maValueMap.erase( aKey ); - mpPrinterData->mbNextJobIsQuick = false; - } -} - -class QuickGuard -{ - Printer* mpPrinter; - public: - QuickGuard( Printer* pPrn ) : mpPrinter( pPrn ) {} - ~QuickGuard() - { - mpPrinter->ImplUpdateQuickStatus(); - } -}; - BOOL Printer::StartJob( const XubString& rJobName ) { mnError = PRINTER_OK; @@ -1429,139 +1354,72 @@ BOOL Printer::StartJob( const XubString& rJobName ) if ( IsJobActive() || IsPrinting() ) return FALSE; - if( mpPrinterData->mbNextJobIsQuick ) - { - String aKey( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ); - if( maJobSetup.GetValue( aKey ).Len() == 0 ) - maJobSetup.SetValue( aKey, String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - } - - QuickGuard aQGuard( this ); - ULONG nCopies = mnCopyCount; BOOL bCollateCopy = mbCollateCopy; BOOL bUserCopy = FALSE; - if ( IsQueuePrinter() ) + if ( nCopies > 1 ) { - if ( ((ImplQPrinter*)this)->IsUserCopy() ) + ULONG nDevCopy; + + if ( bCollateCopy ) + nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COLLATECOPIES ); + else + nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COPIES ); + + // Muessen Kopien selber gemacht werden? + if ( nCopies > nDevCopy ) { + bUserCopy = TRUE; nCopies = 1; bCollateCopy = FALSE; } } else - { - if ( nCopies > 1 ) - { - ULONG nDevCopy; + bCollateCopy = FALSE; - if ( bCollateCopy ) - nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COLLATECOPIES ); - else - nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COPIES ); + ImplSVData* pSVData = ImplGetSVData(); + mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); - // Muessen Kopien selber gemacht werden? - if ( nCopies > nDevCopy ) - { - bUserCopy = TRUE; - nCopies = 1; - bCollateCopy = FALSE; - } - } - else - bCollateCopy = FALSE; + if ( !mpPrinter ) + return FALSE; - // we need queue printing - if( !mnPageQueueSize ) - mnPageQueueSize = 1; - } - - if ( !mnPageQueueSize ) - { - ImplSVData* pSVData = ImplGetSVData(); - mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); - - if ( !mpPrinter ) - return FALSE; - - XubString* pPrintFile; - if ( mbPrintFile ) - pPrintFile = &maPrintFile; - else - pPrintFile = NULL; - - // #125075# StartJob can Reschedule on Windows, sfx - // depends on IsPrinting() in case of closing a document - BOOL bSaveNewJobSetup = mbNewJobSetup; - mbNewJobSetup = FALSE; - String aSaveJobName = maJobName; - maJobName = rJobName; - mnCurPage = 1; - mnCurPrintPage = 1; - mbPrinting = TRUE; - - if( ! ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - // in the pull model the job can only be started when - // we have collected all pages to be printed - if ( !mpPrinter->StartJob( pPrintFile, rJobName, Application::GetDisplayName(), - nCopies, bCollateCopy, - maJobSetup.ImplGetConstData() ) ) - { - mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); - if ( !mnError ) - mnError = PRINTER_GENERALERROR; - pSVData->mpDefInst->DestroyPrinter( mpPrinter ); - mbNewJobSetup = bSaveNewJobSetup; - maJobName = aSaveJobName; - mnCurPage = 0; - mnCurPrintPage = 0; - mbPrinting = FALSE; - mpPrinter = NULL; - return FALSE; - } - } - - mbJobActive = TRUE; - StartPrint(); - } + XubString* pPrintFile; + if ( mbPrintFile ) + pPrintFile = &maPrintFile; else + pPrintFile = NULL; + + // #125075# StartJob can Reschedule on Windows, sfx + // depends on IsPrinting() in case of closing a document + BOOL bSaveNewJobSetup = mbNewJobSetup; + mbNewJobSetup = FALSE; + String aSaveJobName = maJobName; + maJobName = rJobName; + mnCurPage = 1; + mnCurPrintPage = 1; + mbPrinting = TRUE; + + if( ! ImplGetSVData()->maGDIData.mbPrinterPullModel ) { - mpQPrinter = new ImplQPrinter( this ); - if( mpInfoPrinter ) - mpQPrinter->Compat_OldPrinterMetrics( mpInfoPrinter->m_bCompatMetrics ); - mpQPrinter->SetDigitLanguage( GetDigitLanguage() ); - mpQPrinter->SetUserCopy( bUserCopy ); - mpQPrinter->SetPrinterOptions( *mpPrinterOptions ); - - // #125075# StartJob can Reschedule on Windows, sfx - // depends on IsPrinting() in case of closing a document - BOOL bSaveNewJobSetup = mbNewJobSetup; - mbNewJobSetup = FALSE; - String aSaveJobName = maJobName; - maJobName = rJobName; - mnCurPage = 1; - mbPrinting = TRUE; - - if ( mpQPrinter->StartJob( rJobName ) ) + if ( !mpPrinter->StartJob( pPrintFile, rJobName, Application::GetDisplayName(), + nCopies, bCollateCopy, + maJobSetup.ImplGetConstData() ) ) { - mbJobActive = TRUE; - StartPrint(); - mpQPrinter->StartQueuePrint(); - } - else - { - mbNewJobSetup = bSaveNewJobSetup; - maJobName = aSaveJobName; - mnCurPage = 0; - mbPrinting = FALSE; - mnError = mpQPrinter->GetErrorCode(); - mpQPrinter->Destroy(); - mpQPrinter = NULL; + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); + if ( !mnError ) + mnError = PRINTER_GENERALERROR; + pSVData->mpDefInst->DestroyPrinter( mpPrinter ); + mbNewJobSetup = bSaveNewJobSetup; + maJobName = aSaveJobName; + mnCurPage = 0; + mnCurPrintPage = 0; + mbPrinting = FALSE; + mpPrinter = NULL; return FALSE; } } + mbJobActive = TRUE; return TRUE; } @@ -1578,7 +1436,7 @@ BOOL Printer::EndJob() mbJobActive = FALSE; - if ( mpPrinter || mpQPrinter ) + if ( mpPrinter ) { ImplReleaseGraphics(); @@ -1586,23 +1444,17 @@ BOOL Printer::EndJob() bRet = TRUE; - if ( mpPrinter ) - { - mbPrinting = FALSE; - mnCurPrintPage = 0; - maJobName.Erase(); + mbPrinting = FALSE; + mnCurPrintPage = 0; + maJobName.Erase(); - mbDevOutput = FALSE; - bRet = mpPrinter->EndJob(); - // Hier den Drucker nicht asyncron zerstoeren, da es - // W95 nicht verkraftet, wenn gleichzeitig gedruckt wird - // und ein Druckerobjekt zerstoert wird - ImplGetSVData()->mpDefInst->DestroyPrinter( mpPrinter ); - mpPrinter = NULL; - EndPrint(); - } - else - mpQPrinter->EndQueuePrint(); + mbDevOutput = FALSE; + bRet = mpPrinter->EndJob(); + // Hier den Drucker nicht asyncron zerstoeren, da es + // W95 nicht verkraftet, wenn gleichzeitig gedruckt wird + // und ein Druckerobjekt zerstoert wird + ImplGetSVData()->mpDefInst->DestroyPrinter( mpPrinter ); + mpPrinter = NULL; } return bRet; @@ -1621,35 +1473,18 @@ BOOL Printer::AbortJob() mbInPrintPage = FALSE; mpJobGraphics = NULL; - if ( mpPrinter || mpQPrinter ) + if ( mpPrinter ) { mbPrinting = FALSE; mnCurPage = 0; mnCurPrintPage = 0; maJobName.Erase(); - if ( mpPrinter ) - { - ImplReleaseGraphics(); - mbDevOutput = FALSE; - mpPrinter->AbortJob(); - Application::PostUserEvent( LINK( this, Printer, ImplDestroyPrinterAsync ), mpPrinter ); - mpPrinter = NULL; - EndPrint(); - } - else - { - mpQPrinter->AbortQueuePrint(); - mpQPrinter->Destroy(); - mpQPrinter = NULL; - if ( mpQMtf ) - { - mpQMtf->Clear(); - delete mpQMtf; - mpQMtf = NULL; - } - EndPrint(); - } + ImplReleaseGraphics(); + mbDevOutput = FALSE; + mpPrinter->AbortJob(); + Application::PostUserEvent( LINK( this, Printer, ImplDestroyPrinterAsync ), mpPrinter ); + mpPrinter = NULL; return TRUE; } @@ -1659,88 +1494,49 @@ BOOL Printer::AbortJob() // ----------------------------------------------------------------------- -BOOL Printer::StartPage() +void Printer::ImplStartPage() { if ( !IsJobActive() ) - return FALSE; + return; - if ( mpPrinter || mpQPrinter ) + if ( mpPrinter ) { - if ( mpPrinter ) + SalGraphics* pGraphics = mpPrinter->StartPage( maJobSetup.ImplGetConstData(), mbNewJobSetup ); + if ( pGraphics ) { - SalGraphics* pGraphics = mpPrinter->StartPage( maJobSetup.ImplGetConstData(), mbNewJobSetup ); - if ( pGraphics ) - { - ImplReleaseGraphics(); - mpJobGraphics = pGraphics; - } - mbDevOutput = TRUE; - } - else - { - ImplGetGraphics(); - mpJobGraphics = mpGraphics; + ImplReleaseGraphics(); + mpJobGraphics = pGraphics; } + mbDevOutput = TRUE; // PrintJob not aborted ??? if ( IsJobActive() ) { mbInPrintPage = TRUE; mnCurPage++; - if ( mpQPrinter ) - { - mpQPrinter->SetPrinterOptions( *mpPrinterOptions ); - mpQMtf = new GDIMetaFile; - mpQMtf->Record( this ); - mpQMtf->SaveStatus(); - } - else - { - mnCurPrintPage++; - PrintPage(); - } + mnCurPrintPage++; } - - return TRUE; } - - return FALSE; } // ----------------------------------------------------------------------- -BOOL Printer::EndPage() +void Printer::ImplEndPage() { if ( !IsJobActive() ) - return FALSE; + return; mbInPrintPage = FALSE; - if ( mpPrinter || mpQPrinter ) + if ( mpPrinter ) { - if ( mpPrinter ) - { - mpPrinter->EndPage(); - ImplReleaseGraphics(); - mbDevOutput = FALSE; - } - else if ( mpQPrinter ) - { - // Eigentuemeruebergang an QPrinter - mpQMtf->Stop(); - mpQMtf->WindStart(); - GDIMetaFile* pPage = mpQMtf; - mpQMtf = NULL; - mpQPrinter->AddQueuePage( pPage, mnCurPage, mbNewJobSetup ); - } + mpPrinter->EndPage(); + ImplReleaseGraphics(); + mbDevOutput = FALSE; mpJobGraphics = NULL; mbNewJobSetup = FALSE; - - return TRUE; } - - return FALSE; } // ----------------------------------------------------------------------- diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 685f68fe7af3..21c6b59f53a4 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -31,8 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#define _SPOOLPRINTER_EXT - #include #include #include diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1ef2e18b996a..b7344d073386 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -330,13 +330,6 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrmbNextJobIsQuick ) - { - String aKey( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ); - if( maJobSetup.GetValue( aKey ).Len() == 0 ) - maJobSetup.SetValue( aKey, String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - } - ULONG nCopies = mnCopyCount; BOOL bCollateCopy = mbCollateCopy; BOOL bUserCopy = FALSE; @@ -722,14 +715,14 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetPaperSizeUser( aPageSize = mpImplData->maMultiPage.aPaperSize ); // actually print the page - mpImplData->mpPrinter->StartPage(); + mpImplData->mpPrinter->ImplStartPage(); mpImplData->mpPrinter->Push(); aCleanedFile.WindStart(); aCleanedFile.Play( mpImplData->mpPrinter.get() ); mpImplData->mpPrinter->Pop(); - mpImplData->mpPrinter->EndPage(); + mpImplData->mpPrinter->ImplEndPage(); mpImplData->mpPrinter->SetDrawMode( nRestoreDrawMode ); } From bf2e454176da56effb2161ce5fa2d7267b07fc19 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 12 Jun 2009 16:34:50 +0000 Subject: [PATCH 100/283] #i92516# helper class to fix old style printing routines --- vcl/inc/vcl/oldprintadaptor.hxx | 52 ++++++++++++++ vcl/prj/d.lst | 1 + vcl/source/gdi/makefile.mk | 2 + vcl/source/gdi/oldprintadaptor.cxx | 107 +++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+) create mode 100644 vcl/inc/vcl/oldprintadaptor.hxx create mode 100644 vcl/source/gdi/oldprintadaptor.cxx diff --git a/vcl/inc/vcl/oldprintadaptor.hxx b/vcl/inc/vcl/oldprintadaptor.hxx new file mode 100644 index 000000000000..9a0cb9a1d083 --- /dev/null +++ b/vcl/inc/vcl/oldprintadaptor.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_OLDPRINTADAPTOR +#define _VCL_OLDPRINTADAPTOR + +#include "vcl/print.hxx" + +namespace vcl +{ + struct ImplOldStyleAdaptorData; + class VCL_DLLPUBLIC OldStylePrintAdaptor : public PrinterListener + { + ImplOldStyleAdaptorData* mpData; + public: + OldStylePrintAdaptor( const boost::shared_ptr< Printer >& ); + virtual ~OldStylePrintAdaptor(); + + void StartPage(); + void EndPage(); + + virtual int getPageCount() const; + virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const; + virtual void printPage( int i_nPage ) const; + }; +} + +#endif diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst index 6718a9c267de..a8b308aea462 100644 --- a/vcl/prj/d.lst +++ b/vcl/prj/d.lst @@ -82,6 +82,7 @@ mkdir: %_DEST%\inc%_EXT%\vcl\plug\vcl ..\inc\vcl\morebtn.hxx %_DEST%\inc%_EXT%\vcl\morebtn.hxx ..\inc\vcl\msgbox.hxx %_DEST%\inc%_EXT%\vcl\msgbox.hxx ..\inc\vcl\octree.hxx %_DEST%\inc%_EXT%\vcl\octree.hxx +..\inc\vcl\oldprintadaptor.hxx %_DEST%\inc%_EXT%\vcl\oldprintadaptor.hxx ..\inc\vcl\outdev.hxx %_DEST%\inc%_EXT%\vcl\outdev.hxx ..\inc\vcl\pointr.hxx %_DEST%\inc%_EXT%\vcl\pointr.hxx ..\inc\vcl\print.hxx %_DEST%\inc%_EXT%\vcl\print.hxx diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 05dc998d6651..ed22a4ac6764 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -84,6 +84,7 @@ SLOFILES= $(SLO)$/salmisc.obj \ $(SLO)$/metaact.obj \ $(SLO)$/metric.obj \ $(SLO)$/octree.obj \ + $(SLO)$/oldprintadaptor.obj \ $(SLO)$/outmap.obj \ $(SLO)$/outdev.obj \ $(SLO)$/outdev2.obj \ @@ -126,6 +127,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/impimage.obj \ $(SLO)$/impgraph.obj \ $(SLO)$/metric.obj \ + $(SLO)$/oldprintadaptor.obj \ $(SLO)$/pdfwriter_impl.obj \ $(SLO)$/pdffontcache.obj\ $(SLO)$/fontcfg.obj \ diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx new file mode 100644 index 000000000000..3ff6ce27c4d4 --- /dev/null +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vcl/oldprintadaptor.hxx" +#include "vcl/gdimtf.hxx" + +#include "com/sun/star/awt/Size.hpp" + +#include + +namespace vcl +{ + struct AdaptorPage + { + GDIMetaFile maPage; + com::sun::star::awt::Size maPageSize; + }; + + struct ImplOldStyleAdaptorData + { + std::vector< AdaptorPage > maPages; + }; +}; + +using namespace vcl; +using namespace cppu; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; + +OldStylePrintAdaptor::OldStylePrintAdaptor( const boost::shared_ptr< Printer >& i_pPrinter ) + : PrinterListener( i_pPrinter ) + , mpData( new ImplOldStyleAdaptorData() ) +{ +} + +OldStylePrintAdaptor::~OldStylePrintAdaptor() +{ +} + +void OldStylePrintAdaptor::StartPage() +{ + Size aPaperSize( getPrinter()->PixelToLogic( getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + mpData->maPages.push_back( AdaptorPage() ); + mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth(); + mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight(); + getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage ); +} + +void OldStylePrintAdaptor::EndPage() +{ + getPrinter()->SetConnectMetaFile( NULL ); + mpData->maPages.back().maPage.WindStart(); +} + +int OldStylePrintAdaptor::getPageCount() const +{ + return int(mpData->maPages.size()); +} + +Sequence< PropertyValue > OldStylePrintAdaptor::getPageParameters( int i_nPage ) const +{ + Sequence< PropertyValue > aRet( 1 ); + aRet[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageSize") ); + if( i_nPage < int(mpData->maPages.size() ) ) + aRet[0].Value = makeAny( mpData->maPages[i_nPage].maPageSize ); + else + { + awt::Size aEmpty( 0, 0 ); + aRet[0].Value = makeAny( aEmpty ); + } + return aRet; +} + +void OldStylePrintAdaptor::printPage( int i_nPage ) const +{ + if( i_nPage < int(mpData->maPages.size()) ) + { + mpData->maPages[ i_nPage ].maPage.WindStart(); + mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() ); + } +} + From 0c7e5dafaf360b1fac76c26c0a95cb0322c3c341 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 12 Jun 2009 16:44:24 +0000 Subject: [PATCH 101/283] fix a warning --- vcl/source/gdi/oldprintadaptor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx index 3ff6ce27c4d4..a83a5cbc0a09 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -44,7 +44,7 @@ namespace vcl { std::vector< AdaptorPage > maPages; }; -}; +} using namespace vcl; using namespace cppu; From 47d8f3b65172271f386a64d1a983b46dd1de0e9f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 13 Jun 2009 10:45:00 +0000 Subject: [PATCH 102/283] add missing precompiled header --- vcl/source/gdi/oldprintadaptor.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx index a83a5cbc0a09..a2286172a88d 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -25,6 +25,8 @@ * ************************************************************************/ +#include "precompiled_vcl.hxx" + #include "vcl/oldprintadaptor.hxx" #include "vcl/gdimtf.hxx" From c65c7c60ac0c12558f4fe96206b40f29ab41afb4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 17 Jun 2009 14:07:26 +0000 Subject: [PATCH 103/283] #i92516# adapt old deprecated interface to new API --- toolkit/inc/toolkit/awt/vclxprinter.hxx | 15 +++++-------- toolkit/source/awt/vclxprinter.cxx | 30 +++++++++++-------------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/toolkit/inc/toolkit/awt/vclxprinter.hxx b/toolkit/inc/toolkit/awt/vclxprinter.hxx index e94864b51280..4db43a3c5d77 100644 --- a/toolkit/inc/toolkit/awt/vclxprinter.hxx +++ b/toolkit/inc/toolkit/awt/vclxprinter.hxx @@ -43,9 +43,7 @@ #include #include -class Printer; -class String; - +#include "vcl/oldprintadaptor.hxx" // Fuer den Drucker relevante Properties: /* @@ -65,20 +63,17 @@ class VCLXPrinterPropertySet : public ::com::sun::star::awt::XPrinterPropertySe public MutexAndBroadcastHelper, public ::cppu::OPropertySetHelper { -private: - Printer* mpPrinter; +protected: + boost::shared_ptr mpPrinter; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > mxPrnDevice; sal_Int16 mnOrientation; sal_Bool mbHorizontal; - -protected: - public: VCLXPrinterPropertySet( const String& rPrinterName ); virtual ~VCLXPrinterPropertySet(); - Printer* GetPrinter() const { return mpPrinter; } + Printer* GetPrinter() const { return mpPrinter.get(); } ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > GetDevice(); // ::com::sun::star::uno::XInterface @@ -120,6 +115,8 @@ class VCLXPrinter: public ::com::sun::star::awt::XPrinter, public VCLXPrinterPropertySet, public ::cppu::OWeakObject { + boost::shared_ptr mpListener; + JobSetup maInitJobSetup; public: VCLXPrinter( const String& rPrinterName ); ~VCLXPrinter(); diff --git a/toolkit/source/awt/vclxprinter.cxx b/toolkit/source/awt/vclxprinter.cxx index a0d4de43fe0f..a8059463a297 100644 --- a/toolkit/source/awt/vclxprinter.cxx +++ b/toolkit/source/awt/vclxprinter.cxx @@ -102,10 +102,10 @@ IMPL_XTYPEPROVIDER_END VCLXPrinterPropertySet::VCLXPrinterPropertySet( const String& rPrinterName ) : OPropertySetHelper( BrdcstHelper ) + , mpPrinter( new Printer( rPrinterName ) ) { osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); - mpPrinter = new Printer( rPrinterName ); mnOrientation = 0; mbHorizontal = sal_False; } @@ -113,8 +113,7 @@ VCLXPrinterPropertySet::VCLXPrinterPropertySet( const String& rPrinterName ) VCLXPrinterPropertySet::~VCLXPrinterPropertySet() { osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); - - delete mpPrinter; + mpPrinter.reset(); } ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinterPropertySet::GetDevice() @@ -331,10 +330,10 @@ sal_Bool VCLXPrinter::start( const ::rtl::OUString& /*rJobName*/, sal_Int16 /*nC ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); sal_Bool bDone = sal_True; - if ( GetPrinter() ) + if ( mpListener.get() ) { - // FIXME: adapt to new interface - // bDone = GetPrinter()->StartJob( rJobName ); + maInitJobSetup = mpPrinter->GetJobSetup(); + mpListener.reset( new vcl::OldStylePrintAdaptor( mpPrinter ) ); } return bDone; @@ -344,10 +343,10 @@ void VCLXPrinter::end( ) throw(::com::sun::star::awt::PrinterException, ::com:: { ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); - if ( GetPrinter() ) + if ( mpListener.get() ) { - // FIXME: adapt to new interface - // GetPrinter()->EndJob(); + Printer::PrintJob( mpListener, maInitJobSetup ); + mpListener.reset(); } } @@ -355,18 +354,16 @@ void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException) { ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); - if ( GetPrinter() ) - GetPrinter()->AbortJob(); + mpListener.reset(); } ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinter::startPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) { ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); - if ( GetPrinter() ) + if ( mpListener.get() ) { - // FIXME: adapt to new interface - // GetPrinter()->StartPage(); + mpListener->StartPage(); } return GetDevice(); } @@ -375,10 +372,9 @@ void VCLXPrinter::endPage( ) throw(::com::sun::star::awt::PrinterException, ::c { ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); - if ( GetPrinter() ) + if ( mpListener.get() ) { - // FIXME: adapt to new interface - // GetPrinter()->EndPage(); + mpListener->EndPage(); } } From cc0801b55d5504dc7a71f4c8322b2286390ff18e Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 17 Jun 2009 15:16:29 +0000 Subject: [PATCH 104/283] #i92516# copy state to metafile --- vcl/source/gdi/oldprintadaptor.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx index a2286172a88d..e0250d2832ba 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -71,6 +71,14 @@ void OldStylePrintAdaptor::StartPage() mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth(); mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight(); getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage ); + + // copy state into metafile + boost::shared_ptr pPrinter( getPrinter() ); + pPrinter->SetMapMode( pPrinter->GetMapMode() ); + pPrinter->SetFont( pPrinter->GetFont() ); + pPrinter->SetDrawMode( pPrinter->GetDrawMode() ); + pPrinter->SetLineColor( pPrinter->GetLineColor() ); + pPrinter->SetFillColor( pPrinter->GetFillColor() ); } void OldStylePrintAdaptor::EndPage() From a6e3e2a5a75bc7f41cc5fcf5b5661c7996af327c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 18 Jun 2009 18:26:15 +0000 Subject: [PATCH 105/283] #i92516# autoarrange of N-Up page --- vcl/inc/vcl/arrange.hxx | 67 +++++++++++ vcl/inc/vcl/prndlg.hxx | 2 + vcl/source/window/arrange.cxx | 214 +++++++++++++++++++++++++++++++++ vcl/source/window/printdlg.cxx | 59 +++++++++ 4 files changed, 342 insertions(+) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 2005418fe740..f350b9ae110d 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -34,6 +34,7 @@ #include "vcl/window.hxx" #include +#include #include namespace vcl @@ -217,6 +218,72 @@ namespace vcl virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } }; + + class MatrixArranger : public WindowArranger + { + long m_nBorderX; + long m_nBorderY; + + struct MatrixElement : public WindowArranger::Element + { + sal_uInt32 m_nX; + sal_uInt32 m_nY; + + MatrixElement() + : WindowArranger::Element() + , m_nX( 0 ) + , m_nY( 0 ) + {} + + MatrixElement( Window* i_pWin, + sal_uInt32 i_nX, sal_uInt32 i_nY, + boost::shared_ptr const & i_pChild = boost::shared_ptr(), + sal_Int32 i_nExpandPriority = 0 + ) + : WindowArranger::Element( i_pWin, i_pChild, i_nExpandPriority ) + , m_nX( i_nX ) + , m_nY( i_nY ) + { + } + }; + + std::vector< MatrixElement > m_aElements; + std::map< sal_uInt64, size_t > m_aMatrixMap; // maps (x | (y << 32)) to index in m_aElements + + sal_uInt64 getMap( sal_uInt32 i_nX, sal_uInt32 i_nY ) + { return static_cast< sal_uInt64 >(i_nX) | (static_cast< sal_uInt64>(i_nY) << 32 ); } + + Size getOptimalSize( WindowSizeType, std::vector& o_rColumnWidths, std::vector& o_rRowHeights ) const; + public: + MatrixArranger( WindowArranger* i_pParent = NULL, + long i_nBorderX = 5, + long i_nBorderY = 5 ) + : WindowArranger( i_pParent ) + , m_nBorderX( i_nBorderX ) + , m_nBorderY( i_nBorderY ) + {} + + virtual ~MatrixArranger(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual void setParentWindow( Window* ); + virtual size_t countElements() const { return m_aElements.size(); } + virtual boost::shared_ptr getChild( size_t i_nIndex ) const; + virtual Window* getWindow( size_t i_nIndex ) const; + virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const; + + // add a managed window at the given matrix position + void addWindow( Window*, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); + void remove( Window* ); + + void addChild( boost::shared_ptr const &, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); + // convenience: use for addChild( new WindowArranger( ... ) ) constructs + void addChild( WindowArranger* i_pNewChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ) + { addChild( boost::shared_ptr( i_pNewChild ), i_nX, i_nY, i_nExpandPrio ); } + void remove( boost::shared_ptr const & ); + }; + } #endif diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index c2e8beaa16e9..67f38e45540f 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -113,6 +113,8 @@ namespace vcl void readFromSettings(); void storeToSettings(); void initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& ); + + virtual void Resize(); }; class JobTabPage : public TabPage diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index ba1a89eb79da..917b04fcc855 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -388,3 +388,217 @@ void Indenter::setParentWindow( Window* i_pNewParent ) if( m_aElement.m_pChild ) m_aElement.m_pChild->setParentWindow( i_pNewParent ); } + +// ---------------------------------------- +// vcl::MatrixArranger +//----------------------------------------- +MatrixArranger::~MatrixArranger() +{ +} + +Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector& o_rColumnWidths, std::vector& o_rRowHeights ) const +{ + Size aMatrixSize( 2*m_nOuterBorder, 2*m_nOuterBorder ); + + // first find out the current number of rows and columns + sal_uInt32 nRows = 0, nColumns = 0; + for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + if( it->m_nX >= nColumns ) + nColumns = it->m_nX+1; + if( it->m_nY >= nRows ) + nRows = it->m_nY+1; + } + + // now allocate row and column depth vectors + o_rColumnWidths = std::vector< long >( nColumns, 0 ); + o_rRowHeights = std::vector< long >( nRows, 0 ); + + // get sizes an allocate them into rows/columns + for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + Size aSize; + if( it->m_pElement ) + aSize = it->m_pElement->GetOptimalSize( i_eType ); + else if( it->m_pChild ) + aSize = it->m_pChild->getOptimalSize( i_eType ); + if( aSize.Width() > o_rColumnWidths[ it->m_nX ] ) + o_rColumnWidths[ it->m_nX ] = aSize.Width(); + if( aSize.Height() > o_rRowHeights[ it->m_nY ] ) + o_rRowHeights[ it->m_nY ] = aSize.Height(); + } + + // add up sizes + for( sal_uInt32 i = 0; i < nColumns; i++ ) + aMatrixSize.Width() += o_rColumnWidths[i] + m_nBorderX; + if( nColumns > 0 ) + aMatrixSize.Width() -= m_nBorderX; + + for( sal_uInt32 i = 0; i < nRows; i++ ) + aMatrixSize.Height() += o_rRowHeights[i] + m_nBorderY; + if( nRows > 0 ) + aMatrixSize.Height() -= m_nBorderY; + + return aMatrixSize; +} + +Size MatrixArranger::getOptimalSize( WindowSizeType i_eType ) const +{ + std::vector aColumnWidths, aRowHeights; + return getOptimalSize( i_eType, aColumnWidths, aRowHeights ); +} + +void MatrixArranger::resize() +{ + // assure that we have at least one row and column + if( m_aElements.empty() ) + return; + + // check if we can get optimal size, else fallback to minimal size + std::vector aColumnWidths, aRowHeights; + Size aOptSize( getOptimalSize( WINDOWSIZE_PREFERRED, aColumnWidths, aRowHeights ) ); + if( aOptSize.Height() > m_aManagedArea.GetHeight() || + aOptSize.Width() > m_aManagedArea.GetWidth() ) + { + std::vector aMinColumnWidths, aMinRowHeights; + getOptimalSize( WINDOWSIZE_MINIMUM, aMinColumnWidths, aMinRowHeights ); + if( aOptSize.Height() > m_aManagedArea.GetHeight() ) + aRowHeights = aMinRowHeights; + if( aOptSize.Width() > m_aManagedArea.GetWidth() ) + aColumnWidths = aMinColumnWidths; + } + + // FIXME: distribute extra space available + + // prepare offsets + std::vector aColumnX( aColumnWidths.size() ); + aColumnX[0] = m_aManagedArea.Left() + m_nOuterBorder; + for( size_t i = 1; i < aColumnX.size(); i++ ) + aColumnX[i] = aColumnX[i-1] + aColumnWidths[i-1] + m_nBorderX; + + std::vector aRowY( aRowHeights.size() ); + aRowY[0] = m_aManagedArea.Top() + m_nOuterBorder; + for( size_t i = 1; i < aRowY.size(); i++ ) + aRowY[i] = aRowY[i-1] + aRowHeights[i-1] + m_nBorderY; + + // now iterate over the elements and assign their positions + for( std::vector< MatrixElement >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + Point aCellPos( aColumnX[it->m_nX], aRowY[it->m_nY] ); + Size aCellSize( aColumnWidths[it->m_nX], aRowHeights[it->m_nY] ); + if( it->m_pElement ) + it->m_pElement->SetPosSizePixel( aCellPos, aCellSize ); + else if( it->m_pChild ) + it->m_pChild->setManagedArea( Rectangle( aCellPos, aCellSize ) ); + } +} + +void MatrixArranger::setParentWindow( Window* i_pNewParent ) +{ + m_pParentWindow = i_pNewParent; + for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + #if OSL_DEBUG_LEVEL > 0 + if( it->m_pElement ) + { + OSL_VERIFY( it->m_pElement->GetParent() == i_pNewParent ); + } + #endif + if( it->m_pChild ) + it->m_pChild->setParentWindow( i_pNewParent ); + } +} + +boost::shared_ptr MatrixArranger::getChild( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : boost::shared_ptr(); +} + +Window* MatrixArranger::getWindow( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pElement : NULL; +} + +sal_Int32 MatrixArranger::getExpandPriority( size_t i_nIndex ) const +{ + return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].getExpandPriority() : 0; +} + +void MatrixArranger::addWindow( Window* i_pWindow, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) +{ + sal_uInt64 nMapValue = getMap( i_nX, i_nY ); + std::map< sal_uInt64, size_t >::const_iterator it = m_aMatrixMap.find( nMapValue ); + if( it == m_aMatrixMap.end() ) + { + m_aMatrixMap[ nMapValue ] = m_aElements.size(); + m_aElements.push_back( MatrixElement( i_pWindow, i_nX, i_nY, boost::shared_ptr(), i_nExpandPrio ) ); + } + else + { + MatrixElement& rEle( m_aElements[ it->second ] ); + rEle.m_pElement = i_pWindow; + rEle.m_pChild.reset(); + rEle.m_nExpandPriority = i_nExpandPrio; + rEle.m_nX = i_nX; + rEle.m_nY = i_nY; + } +} + +void MatrixArranger::remove( Window* i_pWindow ) +{ + if( i_pWindow ) + { + for( std::vector< MatrixElement >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + if( it->m_pElement == i_pWindow ) + { + m_aMatrixMap.erase( getMap( it->m_nX, it->m_nY ) ); + m_aElements.erase( it ); + return; + } + } + } +} + +void MatrixArranger::addChild( boost::shared_ptr const &i_pChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) +{ + sal_uInt64 nMapValue = getMap( i_nX, i_nY ); + std::map< sal_uInt64, size_t >::const_iterator it = m_aMatrixMap.find( nMapValue ); + if( it == m_aMatrixMap.end() ) + { + m_aMatrixMap[ nMapValue ] = m_aElements.size(); + m_aElements.push_back( MatrixElement( NULL, i_nX, i_nY, i_pChild, i_nExpandPrio ) ); + } + else + { + MatrixElement& rEle( m_aElements[ it->second ] ); + rEle.m_pElement = 0; + rEle.m_pChild = i_pChild; + rEle.m_nExpandPriority = i_nExpandPrio; + rEle.m_nX = i_nX; + rEle.m_nY = i_nY; + } +} + +void MatrixArranger::remove( boost::shared_ptr const &i_pChild ) +{ + if( i_pChild ) + { + for( std::vector< MatrixElement >::iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) + { + if( it->m_pChild == i_pChild ) + { + m_aMatrixMap.erase( getMap( it->m_nX, it->m_nY ) ); + m_aElements.erase( it ); + return; + } + } + } +} + diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 7bc771e7493e..fd6a2422defc 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -192,6 +192,65 @@ PrintDialog::NUpTabPage::~NUpTabPage() { } +void PrintDialog::NUpTabPage::Resize() +{ + Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + + boost::shared_ptr aPage( new vcl::RowOrColumn() ); + aPage->setParentWindow( this ); + aPage->setOuterBorder( aBorder.Width() ); + aPage->addWindow( &maNupLine ); + + boost::shared_ptr aNupIndent( new vcl::Indenter( aPage.get(), aBorder.Width() ) ); + aPage->addChild( aNupIndent ); + boost::shared_ptr aNupColumn( new vcl::RowOrColumn( aNupIndent.get() ) ); + aNupIndent->setChild( aNupColumn ); + + boost::shared_ptr aNupRow( new vcl::RowOrColumn( aNupColumn.get(), false ) ); + aNupColumn->addChild( aNupRow ); + boost::shared_ptr aNupMat( new vcl::MatrixArranger( aNupRow.get(), aBorder.Width(), aBorder.Height() ) ); + aNupRow->addChild( aNupMat ); + aNupMat->addWindow( &maNupRowsTxt, 0, 0 ); + aNupMat->addWindow( &maNupRowsEdt, 1, 0 ); + aNupMat->addWindow( &maNupColTxt, 0, 1 ); + aNupMat->addWindow( &maNupColEdt, 1, 1 ); + aNupMat->addWindow( &maNupRepTxt, 0, 2 ); + aNupMat->addWindow( &maNupRepEdt, 1, 2 ); + boost::shared_ptr aOriCol( new vcl::RowOrColumn( aNupRow.get() ) ); + aNupRow->addChild( aOriCol ); + aOriCol->addWindow( &maNupPortrait ); + aOriCol->addWindow( &maNupLandscape ); + + aNupColumn->addWindow( &maBorderCB ); + + aPage->addWindow( &maMargins ); + + boost::shared_ptr aMargIndent( new vcl::Indenter( aPage.get(), aBorder.Width() ) ); + aPage->addChild( aMargIndent ); + boost::shared_ptr aMargColumn( new vcl::RowOrColumn( aMargIndent.get(), true, 2*aBorder.Height() ) ); + aMargIndent->setChild( aMargColumn ); + + boost::shared_ptr aMargMat( new vcl::MatrixArranger( aMargIndent.get(), aBorder.Width(), aBorder.Height() ) ); + aMargColumn->addChild( aMargMat ); + aMargMat->addWindow( &maLeftMarginTxt, 0, 0 ); + aMargMat->addWindow( &maLeftMarginEdt, 1, 0 ); + aMargMat->addWindow( &maRightMarginTxt, 3, 0 ); + aMargMat->addWindow( &maRightMarginEdt, 4, 0 ); + aMargMat->addWindow( &maTopMarginTxt, 0, 1 ); + aMargMat->addWindow( &maTopMarginEdt, 1, 1 ); + aMargMat->addWindow( &maBottomMarginTxt, 3, 1 ); + aMargMat->addWindow( &maBottomMarginEdt, 4, 1 ); + + boost::shared_ptr aSpacingMat( new vcl::MatrixArranger( aPage.get(), aBorder.Width(), aBorder.Height() ) ); + aMargColumn->addChild( aSpacingMat ); + aSpacingMat->addWindow( &maHSpaceTxt, 0, 0 ); + aSpacingMat->addWindow( &maHSpaceEdt, 1, 0 ); + aSpacingMat->addWindow( &maVSpaceTxt, 0, 1 ); + aSpacingMat->addWindow( &maVSpaceEdt, 1, 1 ); + + aPage->setManagedArea( Rectangle( Point(), GetOutputSizePixel() ) ); +} + void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& i_rMPS ) { maLeftMarginEdt.SetValue( maLeftMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); From e38ba906f787d79e8042f3a97bf44372cad4c0aa Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 24 Jun 2009 15:18:33 +0000 Subject: [PATCH 106/283] add: PrinterListener::setValue --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 6 +++ vcl/inc/vcl/print.hxx | 11 +++-- vcl/source/gdi/print3.cxx | 42 +++++++++++++++---- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index b016920ae18e..f746f0462778 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -95,6 +95,7 @@ class ListenerProperties mnLastPageCount = nPages; if( mpState->bNeedRestart ) { + #if 0 // Warning: bad hack ahead // Apple does not give as a chance of changing the page count, // and they don't let us cancel the dialog either @@ -113,6 +114,11 @@ class ListenerProperties } } } + #else + NSWindow* pWindow = [NSApp modalWindow]; + if( pWindow ) + [pWindow cancelOperation: nil]; + #endif [[mpOp printInfo] setJobDisposition: NSPrintCancelJob]; } } diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 18529c07b432..ca3c6030f4e4 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -446,10 +446,15 @@ public: /* get the PropertyValue of a Property */ - com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ); - const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& rPropertyName ) const; + com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ); + const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ) const; - /* return the currently active UI options. These are the same passed to setUIOptions. + /* set a property value - can also be used to add another UI property + */ + void setValue( const rtl::OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue ); + void setValue( const com::sun::star::beans::PropertyValue& i_rValue ); + + /* return the currently active UI options. These are the same that were passed to setUIOptions. */ const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& getUIOptions() const; /* set possible UI options. should only be done once before passing the PrinterListener diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index b7344d073386..24618e6162e3 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -791,14 +791,35 @@ const com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; } +void PrinterListener::setValue( const rtl::OUString& i_rName, const Any& i_rValue ) +{ + beans::PropertyValue aVal; + aVal.Name = i_rName; + aVal.Value = i_rValue; + + setValue( aVal ); +} + +void PrinterListener::setValue( const beans::PropertyValue& i_rValue ) +{ + std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = + mpImplData->maPropertyToIndex.find( i_rValue.Name ); + if( it != mpImplData->maPropertyToIndex.end() ) + mpImplData->maUIProperties[ it->second ] = i_rValue; + else + { + // insert correct index into property map + mpImplData->maPropertyToIndex[ i_rValue.Name ] = mpImplData->maUIProperties.size(); + mpImplData->maUIProperties.push_back( i_rValue ); + mpImplData->maUIPropertyEnabled.push_back( true ); + } +} + void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rOptions ) { DBG_ASSERT( mpImplData->maUIOptions.getLength() == 0, "setUIOptions called twice !" ); mpImplData->maUIOptions = i_rOptions; - mpImplData->maUIProperties.clear(); - mpImplData->maPropertyToIndex.clear(); - mpImplData->maUIPropertyEnabled.clear(); for( int i = 0; i < i_rOptions.getLength(); i++ ) { @@ -806,6 +827,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO i_rOptions[i].Value >>= aOptProp; bool bIsEnabled = true; bool bHaveProperty = false; + rtl::OUString aPropName; vcl::ImplPrinterListenerData::ControlDependency aDep; for( int n = 0; n < aOptProp.getLength(); n++ ) { @@ -816,8 +838,8 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO rEntry.Value >>= aVal; DBG_ASSERT( mpImplData->maPropertyToIndex.find( aVal.Name ) == mpImplData->maPropertyToIndex.end(), "duplicate property entry" ); - mpImplData->maPropertyToIndex[ aVal.Name ] = mpImplData->maUIProperties.size(); - mpImplData->maUIProperties.push_back( aVal ); + setValue( aVal ); + aPropName = aVal.Name; bHaveProperty = true; } else if( rEntry.Name.equalsAscii( "Enabled" ) ) @@ -837,9 +859,15 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO } if( bHaveProperty ) { - mpImplData->maUIPropertyEnabled.push_back( bIsEnabled ); + vcl::ImplPrinterListenerData::PropertyToIndexMap::const_iterator it = + mpImplData->maPropertyToIndex.find( aPropName ); + // sanity check + if( it != mpImplData->maPropertyToIndex.end() ) + { + mpImplData->maUIPropertyEnabled[ it->second ] = bIsEnabled; + } if( aDep.maDependsOnName.getLength() > 0 ) - mpImplData->maControlDependencies[ mpImplData->maUIProperties.back().Name ] = aDep; + mpImplData->maControlDependencies[ aPropName ] = aDep; } } } From a22cd6b9c89f9d1bac898596942af3e889ee94d6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 24 Jun 2009 15:59:36 +0000 Subject: [PATCH 107/283] save to file should be PDF --- vcl/aqua/source/gdi/salprn.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 8e22a83e1403..347e57aa8380 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -444,6 +444,8 @@ ULONG AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup* i_pSetupData, USH return 1; case PRINTER_CAPABILITIES_EXTERNALDIALOG: return getUseNativeDialog() ? 1 : 0; + case PRINTER_CAPABILITIES_PDF: + return 1; default: break; }; return 0; From d3afbfc954cd9e3f99e3bd77fa87d70055447e03 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 24 Jun 2009 17:37:07 +0000 Subject: [PATCH 108/283] prepare for more properties from the outside (e.g. API printing) --- vcl/inc/vcl/print.hxx | 21 +++++++++++---------- vcl/source/gdi/print3.cxx | 19 ++++++++++++++++++- vcl/source/window/printdlg.cxx | 9 +++++++-- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index ca3c6030f4e4..941feb97b8e3 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -480,16 +480,17 @@ public: virtual void jobFinished(); // optionally release resources bound to the job // implementation details, not usable outside vcl - int SAL_DLLPRIVATE getFilteredPageCount(); - Size SAL_DLLPRIVATE getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); - Size SAL_DLLPRIVATE getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); - void SAL_DLLPRIVATE printFilteredPage( int i_nPage ); - void SAL_DLLPRIVATE setPrinter( const boost::shared_ptr& ); - void SAL_DLLPRIVATE setOptionChangeHdl( const Link& ); - void SAL_DLLPRIVATE createProgressDialog(); - void SAL_DLLPRIVATE setMultipage( const MultiPageSetup& ); - const MultiPageSetup& getMultipage() const; - void SAL_DLLPRIVATE setLastPage( sal_Bool i_bLastPage ); + SAL_DLLPRIVATE int getFilteredPageCount(); + SAL_DLLPRIVATE Size getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); + SAL_DLLPRIVATE Size getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); + SAL_DLLPRIVATE void printFilteredPage( int i_nPage ); + SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr& ); + SAL_DLLPRIVATE void setOptionChangeHdl( const Link& ); + SAL_DLLPRIVATE void createProgressDialog(); + SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); + SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; + SAL_DLLPRIVATE void setLastPage( sal_Bool i_bLastPage ); + SAL_DLLPRIVATE void pushPropertiesToPrinter(); }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 24618e6162e3..6ab34439b5e4 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -307,13 +307,14 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->getPrinter()->EnablePrintFile( TRUE ); pListener->getPrinter()->SetPrintFile( aFile ); } - pListener->getPrinter()->SetCopyCount( static_cast(aDlg.getCopyCount()), aDlg.isCollate() ); } catch( std::bad_alloc& ) { } } + pListener->pushPropertiesToPrinter(); + pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ), pListener ); @@ -447,6 +448,8 @@ void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; Size aPaperSize( i_rPrinter->PixelToLogic( i_rPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), + makeAny( rtl::OUString( i_rPrinter->GetName() ) ) ); } static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) @@ -967,6 +970,20 @@ const PrinterListener::MultiPageSetup& PrinterListener::getMultipage() const return mpImplData->maMultiPage; } +void PrinterListener::pushPropertiesToPrinter() +{ + sal_Int32 nCopyCount = 1; + // set copycount and collate + const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); + if( pVal ) + pVal->Value >>= nCopyCount; + sal_Bool bCollate = sal_False; + pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); + if( pVal ) + pVal->Value >>= bCollate; + mpImplData->mpPrinter->SetCopyCount( static_cast(nCopyCount), bCollate ); +} + /* * PrinterOptionsHelper **/ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index fd6a2422defc..138c75427d6d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -349,7 +349,7 @@ void PrintDialog::JobTabPage::readFromSettings() // do not actually make copy count persistent // the assumption is that this would lead to a lot of unwanted copies aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Copies" ) ) ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); sal_Int32 nVal = aValue.toInt32(); maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); #endif @@ -366,7 +366,7 @@ void PrintDialog::JobTabPage::storeToSettings() rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Copies" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), maCopyCountField.GetText() ); pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), @@ -1311,6 +1311,11 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) mnCurPage = sal_Int32( maPageEdit.GetValue() - 1 ); preparePreview( true, true ); } + else if( pEdit == &maJobPage.maCopyCountField ) + { + maPListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), + makeAny( sal_Int32(maJobPage.maCopyCountField.GetValue()) ) ); + } return 0; } From de8ad26685ea2b9ed62433563670de0e7ebfa942 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 26 Jun 2009 10:50:42 +0000 Subject: [PATCH 109/283] #i92516# add: jobStarted, PrintableState --- vcl/aqua/source/gdi/salprn.cxx | 9 +++++++ vcl/inc/vcl/print.hxx | 7 +++++- vcl/source/gdi/print3.cxx | 43 ++++++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 347e57aa8380..ce213c1c042b 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -512,6 +512,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, return FALSE; BOOL bSuccess = FALSE; + bool bWasAborted = false; AquaSalInstance* pInst = GetSalData()->mpFirstInstance; PrintAccessoryViewState aAccViewState; sal_Int32 nAllPages = 0; @@ -525,6 +526,9 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( i_pSetupData ) SetData( ~0, i_pSetupData ); + // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) + // how do I know when that might be ? + i_rListener.jobStarted(); do { if( aAccViewState.bNeedRestart ) @@ -603,6 +607,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, pInst->startedPrintJob(); [pPrintOperation runOperation]; pInst->endedPrintJob(); + bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame; mbJob = false; if( pReleaseAfterUse ) [pReleaseAfterUse release]; @@ -624,6 +629,10 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, i_rListener.getFilteredPageFile( 0, aPageFile ); } + i_rListener.setJobState( bWasAborted + ? view::PrintableState_JOB_ABORTED + : view::PrintableState_JOB_SPOOLED ); + mnCurPageRangeStart = mnCurPageRangeCount = 0; return bSuccess; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 941feb97b8e3..c9fa42238c2f 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -42,6 +42,7 @@ #include "tools/multisel.hxx" #include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/view/PrintableState.hpp" #include #include @@ -477,7 +478,10 @@ public: // must be overloaded by the app, return page size in 1/100th mm virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParameters( int i_nPage ) const = 0; virtual void printPage( int i_nPage ) const = 0; // must be overloaded by the app - virtual void jobFinished(); // optionally release resources bound to the job + virtual void jobStarted(); // will be called after a possible dialog has been shown and the real printjob starts + virtual void jobFinished( com::sun::star::view::PrintableState ); + + com::sun::star::view::PrintableState getJobState() const; // implementation details, not usable outside vcl SAL_DLLPRIVATE int getFilteredPageCount(); @@ -491,6 +495,7 @@ public: SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; SAL_DLLPRIVATE void setLastPage( sal_Bool i_bLastPage ); SAL_DLLPRIVATE void pushPropertiesToPrinter(); + SAL_DLLPRIVATE void setJobState( com::sun::star::view::PrintableState ); }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 6ab34439b5e4..12ef70ee958b 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -152,6 +152,7 @@ public: Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; sal_Bool mbLastPage; + view::PrintableState meJobState; vcl::PrinterListener::MultiPageSetup maMultiPage; @@ -161,6 +162,7 @@ public: ImplPrinterListenerData() : mbLastPage( sal_False ), + meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ) {} ~ImplPrinterListenerData() { delete mpProgress; } @@ -316,9 +318,9 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->pushPropertiesToPrinter(); pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ), - pListener ); + pListener ); - pListener->jobFinished(); + pListener->jobFinished( pListener->getJobState() ); } bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptr& i_pListener ) @@ -376,6 +378,9 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrStartJob( pPrintFile, Application::GetDisplayName(), maJobSetup.ImplGetConstData(), @@ -399,6 +404,11 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrsetJobState( view::PrintableState_JOB_STARTED ); + i_pListener->jobStarted(); + if( mpPrinter->StartJob( pPrintFile, i_rJobName, Application::GetDisplayName(), @@ -415,9 +425,14 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrprintFilteredPage( nPage ); } EndJob(); + + if( i_pListener->getJobState() == view::PrintableState_JOB_STARTED ) + i_pListener->setJobState( view::PrintableState_JOB_SPOOLED ); } else { + i_pListener->setJobState( view::PrintableState_JOB_FAILED ); + mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); if ( !mnError ) mnError = PRINTER_GENERALERROR; @@ -439,6 +454,16 @@ PrinterListener::~PrinterListener() delete mpImplData; } +view::PrintableState PrinterListener::getJobState() const +{ + return mpImplData->meJobState; +} + +void PrinterListener::setJobState( view::PrintableState i_eState ) +{ + mpImplData->meJobState = i_eState; +} + const boost::shared_ptr& PrinterListener::getPrinter() const { return mpImplData->mpPrinter; @@ -648,6 +673,9 @@ int PrinterListener::getFilteredPageCount() void PrinterListener::printFilteredPage( int i_nPage ) { + if( mpImplData->meJobState != view::PrintableState_JOB_STARTED ) + return; + GDIMetaFile aPageFile; Size aPageSize = getFilteredPageFile( i_nPage, aPageFile ); @@ -655,7 +683,10 @@ void PrinterListener::printFilteredPage( int i_nPage ) { // do nothing if printing is canceled if( mpImplData->mpProgress->isCanceled() ) - return; + { + setJobState( view::PrintableState_JOB_ABORTED ); + return; + } } bool bMultiPageOutput = mpImplData->maMultiPage.nRows != 1 || mpImplData->maMultiPage.nColumns != 1; @@ -730,7 +761,11 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetDrawMode( nRestoreDrawMode ); } -void PrinterListener::jobFinished() +void PrinterListener::jobStarted() +{ +} + +void PrinterListener::jobFinished( view::PrintableState ) { } From 135137e4930fd36174007520755fc62a30d520aa Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 26 Jun 2009 11:35:24 +0000 Subject: [PATCH 110/283] #i92516# add: LocalFileName --- vcl/source/gdi/print3.cxx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 12ef70ee958b..7c97946cb3f3 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -306,8 +306,8 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene rtl::OUString aFile = queryFile( pListener->getPrinter().get() ); if( ! aFile.getLength() ) return; - pListener->getPrinter()->EnablePrintFile( TRUE ); - pListener->getPrinter()->SetPrintFile( aFile ); + pListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), + makeAny( aFile ) ); } } catch( std::bad_alloc& ) @@ -364,11 +364,25 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrgetValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ) ); + if( pFileValue ) + { + rtl::OUString aFile; + pFileValue->Value >>= aFile; + if( aFile.getLength() ) + { + mbPrintFile = TRUE; + maPrintFile = aFile; + } + } + + XubString* pPrintFile = NULL; if ( mbPrintFile ) pPrintFile = &maPrintFile; - else - pPrintFile = NULL; maJobName = i_rJobName; mnCurPage = 1; From 497f21a8d0142c70d1c188a77055c509fd7cb690 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 26 Jun 2009 12:32:01 +0000 Subject: [PATCH 111/283] #i92516# add: MonitorVisible --- vcl/aqua/source/gdi/salprn.cxx | 8 +++++++- vcl/source/gdi/print3.cxx | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index ce213c1c042b..1131fb54ccd5 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -526,6 +526,12 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( i_pSetupData ) SetData( ~0, i_pSetupData ); + // do we want a progress panel ? + sal_Bool bShowProgressPanel = sal_True; + beans::PropertyValue* pMonitor = i_rListener.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); + if( pMonitor ) + pMonitor->Value >>= bShowProgressPanel; + // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) // how do I know when that might be ? i_rListener.jobStarted(); @@ -598,7 +604,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, NSObject* pReleaseAfterUse = nil; bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; - [pPrintOperation setShowsProgressPanel: YES]; + [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withState: &aAccViewState]; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 7c97946cb3f3..7e5c68c700bb 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1004,8 +1004,16 @@ void PrinterListener::createProgressDialog() { if( ! mpImplData->mpProgress ) { - mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCount() ); - mpImplData->mpProgress->Show(); + sal_Bool bShow = sal_True; + beans::PropertyValue* pMonitor = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); + if( pMonitor ) + pMonitor->Value >>= bShow; + + if( bShow ) + { + mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCount() ); + mpImplData->mpProgress->Show(); + } } } From 61e5696463d074e6bba86a12300f9623a32f71e7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 26 Jun 2009 13:31:24 +0000 Subject: [PATCH 112/283] #i92516# add: Pages, Wait --- vcl/source/gdi/print3.cxx | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 7e5c68c700bb..1d6a614f847d 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -264,8 +264,18 @@ void Printer::PrintJob( const boost::shared_ptr& i_pListener, const JobSetup& i_rInitSetup ) { - PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup ); - Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) ); + sal_Bool bSynchronous = sal_False; + beans::PropertyValue* pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + if( pVal ) + pVal->Value >>= bSynchronous; + + if( bSynchronous ) + ImplPrintJob( i_pListener, i_rInitSetup ); + else + { + PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup ); + Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) ); + } } void Printer::ImplPrintJob( const boost::shared_ptr& i_pListener, @@ -284,6 +294,27 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene // reset last page property i_pListener->setLastPage( sal_False ); + beans::PropertyValue* pPagesVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) ) ); + if( pPagesVal ) + { + rtl::OUString aPagesVal; + pPagesVal->Value >>= aPagesVal; + if( aPagesVal.getLength() ) + { + // "Pages" attribute from API is now equivalent to "PageRange" + // AND "PrintContent" = 1 except calc where it is "PrintRange" = 1 + // Argh ! That sure needs cleaning up + beans::PropertyValue* pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + if( ! pVal ) + pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); + if( pVal ) + { + pVal->Value = makeAny( sal_Int32( 1 ) ); + i_pListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), pPagesVal->Value ); + } + } + } + // check if the printer brings up its own dialog // in that case leave the work to that dialog const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); From eabda9293f16222f50be0495de945d1df909010a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 26 Jun 2009 14:03:31 +0000 Subject: [PATCH 113/283] #i92516# add: JobName --- vcl/aqua/inc/salprn.h | 2 ++ vcl/aqua/source/gdi/salprn.cxx | 17 ++++++++++++----- vcl/inc/vcl/print.hxx | 2 +- vcl/inc/vcl/salprn.hxx | 7 ++++--- vcl/source/app/salvtables.cxx | 2 +- vcl/source/gdi/print3.cxx | 13 +++++++++---- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index 3a486d901ddc..a22503c22e78 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -103,6 +103,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter // and concentrate the real work in one class // implement pull model print system BOOL StartJob( const String* i_pFileName, + const String& rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, vcl::PrinterListener& i_rListener, @@ -145,6 +146,7 @@ class AquaSalPrinter : public SalPrinter ImplJobSetup* i_pSetupData ); // implement pull model print system virtual BOOL StartJob( const String* i_pFileName, + const String& rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, vcl::PrinterListener& i_rListener ); diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 1131fb54ccd5..e06e8c48fd8b 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -503,6 +503,7 @@ static Size getPageSize( vcl::PrinterListener& i_rListener, sal_Int32 i_nPage ) } BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, + const String& i_rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, vcl::PrinterListener& i_rListener, @@ -605,6 +606,11 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; + + // set job title (since MacOSX 10.5) + if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] ) + [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]]; + if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withState: &aAccViewState]; @@ -707,6 +713,7 @@ AquaSalPrinter::~AquaSalPrinter() // ----------------------------------------------------------------------- BOOL AquaSalPrinter::StartJob( const String* i_pFileName, + const String& i_rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, vcl::PrinterListener& i_rListener ) @@ -721,16 +728,16 @@ BOOL AquaSalPrinter::StartJob( const String* i_pFileName, bIsQuickJob = true; } - return mpInfoPrinter->StartJob( i_pFileName, i_rAppName, i_pSetupData, i_rListener, bIsQuickJob ); + return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rListener, bIsQuickJob ); } // ----------------------------------------------------------------------- BOOL AquaSalPrinter::StartJob( const XubString* i_pFileName, - const XubString& i_rJobName, - const XubString& i_rAppName, - ULONG i_nCopies, BOOL i_bCollate, - ImplJobSetup* i_pSetupData ) + const XubString& i_rJobName, + const XubString& i_rAppName, + ULONG i_nCopies, BOOL i_bCollate, + ImplJobSetup* i_pSetupData ) { DBG_ERROR( "should never be called" ); return FALSE; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index c9fa42238c2f..4cbd24dc02bd 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -264,7 +264,7 @@ private: SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& ); DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); - SAL_DLLPRIVATE bool StartJob( const XubString& rJobName, boost::shared_ptr& ); + SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr& ); static SAL_DLLPRIVATE ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError ); diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx index 923b3a750e36..a53adfe3518e 100644 --- a/vcl/inc/vcl/salprn.hxx +++ b/vcl/inc/vcl/salprn.hxx @@ -113,15 +113,16 @@ public: // public for Sal Implementation SalPrinter() {} virtual ~SalPrinter(); - virtual BOOL StartJob( const XubString* pFileName, - const XubString& rJobName, - const XubString& rAppName, + virtual BOOL StartJob( const String* pFileName, + const String& rJobName, + const String& rAppName, ULONG nCopies, BOOL bCollate, ImplJobSetup* pSetupData ) = 0; // implement for pull model print systems only, // default implementations (see salvtables.cxx) just returns FALSE virtual BOOL StartJob( const String* pFileName, + const String& rJobName, const String& rAppName, ImplJobSetup* pSetupData, vcl::PrinterListener& rListener ); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index fe1ef6e7b992..7f872d0a9b63 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -90,7 +90,7 @@ SalPrinter::~SalPrinter() { } -BOOL SalPrinter::StartJob( const String*, const String&, +BOOL SalPrinter::StartJob( const String*, const String&, const String&, ImplJobSetup*, vcl::PrinterListener& ) { return FALSE; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1d6a614f847d..d0ff5814aa51 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -348,13 +348,17 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene pListener->pushPropertiesToPrinter(); - pListener->getPrinter()->StartJob( String( RTL_CONSTASCII_USTRINGPARAM( "FIXME: no job name" ) ), - pListener ); + rtl::OUString aJobName; + beans::PropertyValue* pJobNameVal = pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ) ); + if( pJobNameVal ) + pJobNameVal->Value >>= aJobName; + + pListener->getPrinter()->StartJob( String( aJobName ), pListener ); pListener->jobFinished( pListener->getJobState() ); } -bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptr& i_pListener ) +bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr& i_pListener ) { mnError = PRINTER_OK; @@ -377,7 +381,7 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptr nDevCopy ) { bUserCopy = TRUE; @@ -427,6 +431,7 @@ bool Printer::StartJob( const XubString& i_rJobName, boost::shared_ptrStartJob( pPrintFile, + i_rJobName, Application::GetDisplayName(), maJobSetup.ImplGetConstData(), *i_pListener ) ) From a06a9f6d94bc1338fc68f01abfb6516fbf184918 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 29 Jun 2009 17:52:53 +0000 Subject: [PATCH 114/283] #i92516# replace missing preview in native mac dialog by our own --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 248 ++++++++++++++++-- vcl/inc/vcl/svids.hrc | 1 + vcl/source/src/print.src | 10 + 3 files changed, 233 insertions(+), 26 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index f746f0462778..30811a1e0219 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -34,6 +34,13 @@ #include "aquaprintview.h" #include "salinst.h" #include "vcl/print.hxx" +#include "vcl/image.hxx" +#include "vcl/virdev.hxx" +#include "vcl/svdata.hxx" + +#include "vcl/svids.hrc" + +#include "tools/resary.hxx" #include @@ -44,10 +51,24 @@ using namespace com::sun::star::uno; /* Note: the accesory view as implemented here is already deprecated in Leopard. Unfortunately as long as our baseline is Tiger we cannot gain the advantages over multiple accessory views - as well havs haing accessory views AND a preview (as long as you are linked vs. 10.4 libraries + as well havs having accessory views AND a preview (as long as you are linked vs. 10.4 libraries the preview insists on not being present. This is unfortunate. */ +class ListenerProperties; + +@interface ControlTarget : NSObject +{ + ListenerProperties* mpListener; +} +-(id)initWithListenerMap: (ListenerProperties*)pListener; +-(void)triggered:(id)pSender; +-(void)triggeredNumeric:(id)pSender; +-(void)triggeredPreview:(id)pSender; +-(void)dealloc; +@end + + class ListenerProperties { vcl::PrinterListener* mpListener; @@ -59,11 +80,18 @@ class ListenerProperties sal_Int32 mnLastPageCount; PrintAccessoryViewState* mpState; NSPrintOperation* mpOp; + NSView* mpAccessoryView; NSTabView* mpTabView; + NSBox* mpPreviewBox; + NSImageView* mpPreview; + NSTextField* mpPageEdit; + NSStepper* mpStepper; + NSTextView* mpPagesLabel; public: ListenerProperties( vcl::PrinterListener* i_pListener, NSPrintOperation* i_pOp, + NSView* i_pAccessoryView, NSTabView* i_pTabView, PrintAccessoryViewState* i_pState ) : mpListener( i_pListener ), @@ -71,7 +99,13 @@ class ListenerProperties mnLastPageCount( i_pListener->getPageCount() ), mpState( i_pState ), mpOp( i_pOp ), - mpTabView( i_pTabView ) + mpAccessoryView( i_pAccessoryView ), + mpTabView( i_pTabView ), + mpPreviewBox( nil ), + mpPreview( nil ), + mpPageEdit( nil ), + mpStepper( nil ), + mpPagesLabel( nil ) { mpState->bNeedRestart = false; } @@ -121,6 +155,11 @@ class ListenerProperties #endif [[mpOp printInfo] setJobDisposition: NSPrintCancelJob]; } + else + { + sal_Int32 nPage = [mpStepper intValue]; + updatePreviewImage( nPage-1 ); + } } int addNameTag( const rtl::OUString& i_rPropertyName ) @@ -248,6 +287,153 @@ class ListenerProperties } } } + + void updatePreviewImage( sal_Int32 i_nPage ) + { + sal_Int32 nPages = mpListener->getFilteredPageCount(); + NSRect aViewFrame = [mpPreview frame]; + Size aPixelSize( static_cast(aViewFrame.size.width), + static_cast(aViewFrame.size.height) ); + if( i_nPage >= 0 && nPages > i_nPage ) + { + GDIMetaFile aMtf; + Size aPageSize( mpListener->getFilteredPageFile( i_nPage, aMtf, false ) ); + VirtualDevice aDev; + Size aLogicSize( aDev.PixelToLogic( aPixelSize, MapMode( MAP_100TH_MM ) ) ); + double fScaleX = double(aLogicSize.Width())/double(aPageSize.Width()); + double fScaleY = double(aLogicSize.Height())/double(aPageSize.Height()); + double fScale = (fScaleX < fScaleY) ? fScaleX : fScaleY; + aMtf.WindStart(); + aMtf.Scale( fScale, fScale ); + aMtf.WindStart(); + aLogicSize.Width() = long(double(aPageSize.Width()) * fScale); + aLogicSize.Height() = long(double(aPageSize.Height()) * fScale); + aPixelSize = aDev.LogicToPixel( aLogicSize, MapMode( MAP_100TH_MM ) ); + aDev.SetOutputSizePixel( aPixelSize ); + aMtf.WindStart(); + aDev.SetMapMode( MapMode( MAP_100TH_MM ) ); + aMtf.Play( &aDev, Point( 0, 0 ), aLogicSize ); + aDev.EnableMapMode( FALSE ); + Image aImage( aDev.GetBitmap( Point( 0, 0 ), aPixelSize ) ); + NSImage* pImage = CreateNSImage( aImage ); + [mpPreview setImage: [pImage autorelease]]; + } + else + [mpPreview setImage: nil]; + } + + void setupPreview( ControlTarget* i_pCtrlTarget ) + { + // get some needed resources + ResStringArray aStrings( VclResId( SV_PRINT_NATIVE_STRINGS ) ); + + DBG_ASSERT( aStrings.Count() >= 3, "resources not found !" ); + if( aStrings.Count() < 3 ) + return; + + // get the preview control + NSRect aPreviewFrame = [mpAccessoryView frame]; + aPreviewFrame.origin.x = 0; + aPreviewFrame.origin.y = 5; + aPreviewFrame.size.width = 190; + aPreviewFrame.size.height -= 7; + + // create a box to put the preview controls in + mpPreviewBox = [[NSBox alloc] initWithFrame: aPreviewFrame]; + [mpPreviewBox setTitle: [CreateNSString( aStrings.GetString( 0 ) ) autorelease]]; + [mpAccessoryView addSubview: [mpPreviewBox autorelease]]; + + // now create the image view of the preview + NSSize aMargins = [mpPreviewBox contentViewMargins]; + aPreviewFrame.origin.x = 0; + aPreviewFrame.origin.y = 34; + aPreviewFrame.size.height -= 61; + mpPreview = [[NSImageView alloc] initWithFrame: aPreviewFrame]; + [mpPreview setImageScaling: NSScaleNone]; + [mpPreview setImageAlignment: NSImageAlignCenter]; + [mpPreview setImageFrameStyle: NSImageFrameNone]; + [mpPreviewBox addSubview: [mpPreview autorelease]]; + + // add a label + sal_Int32 nPages = mpListener->getFilteredPageCount(); + rtl::OUStringBuffer aBuf( 16 ); + aBuf.appendAscii( "/ " ); + aBuf.append( rtl::OUString::valueOf( nPages ) ); + + NSString* pText = CreateNSString( aBuf.makeStringAndClear() ); + NSRect aTextRect = { { 100, 5 }, { 100, 22 } }; + mpPagesLabel = [[NSTextView alloc] initWithFrame: aTextRect]; + [mpPagesLabel setFont: [NSFont controlContentFontOfSize: 0]]; + [mpPagesLabel setEditable: NO]; + [mpPagesLabel setSelectable: NO]; + [mpPagesLabel setDrawsBackground: NO]; + [mpPagesLabel setString: [pText autorelease]]; + [mpPagesLabel setToolTip: [CreateNSString( aStrings.GetString( 2 ) ) autorelease]]; + [mpPreviewBox addSubview: [mpPagesLabel autorelease]]; + + NSRect aFieldRect = { { 45, 5 }, { 35, 25 } }; + mpPageEdit = [[NSTextField alloc] initWithFrame: aFieldRect]; + [mpPageEdit setEditable: YES]; + [mpPageEdit setSelectable: YES]; + [mpPageEdit setDrawsBackground: YES]; + [mpPageEdit setToolTip: [CreateNSString( aStrings.GetString( 1 ) ) autorelease]]; + [mpPreviewBox addSubview: [mpPageEdit autorelease]]; + + // add a stepper control + NSRect aStepFrame = { { 85, 5 }, { 15, 25 } }; + mpStepper = [[NSStepper alloc] initWithFrame: aStepFrame]; + [mpStepper setIncrement: 1]; + [mpStepper setValueWraps: NO]; + [mpPreviewBox addSubview: [mpStepper autorelease]]; + + // constrain the text field to decimal numbers + NSNumberFormatter* pFormatter = [[NSNumberFormatter alloc] init]; + [pFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4]; + [pFormatter setMinimum: [[NSNumber numberWithInt: 1] autorelease]]; + [pFormatter setMaximum: [[NSNumber numberWithInt: nPages] autorelease]]; + [pFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; + [pFormatter setAllowsFloats: NO]; + [pFormatter setMaximumFractionDigits: 0]; + [mpPageEdit setFormatter: pFormatter]; + [mpStepper setMinValue: 1]; + [mpStepper setMaxValue: nPages]; + + [mpPageEdit setIntValue: 1]; + [mpStepper setIntValue: 1]; + + // connect target and action + [mpStepper setTarget: i_pCtrlTarget]; + [mpStepper setAction: @selector(triggeredPreview:)]; + [mpPageEdit setTarget: i_pCtrlTarget]; + [mpPageEdit setAction: @selector(triggeredPreview:)]; + + // set first preview image + updatePreviewImage( 0 ); + } + + void changePreview( NSObject* i_pSender ) + { + if( [i_pSender isMemberOfClass: [NSTextField class]] ) + { + NSTextField* pField = (NSTextField*)i_pSender; + if( pField == mpPageEdit ) // sanity check + { + sal_Int32 nPage = [pField intValue]; + [mpStepper setIntValue: nPage]; + updatePreviewImage( nPage-1 ); + } + } + else if( [i_pSender isMemberOfClass: [NSStepper class]] ) + { + NSStepper* pStepper = (NSStepper*)i_pSender; + if( pStepper == mpStepper ) // sanity check + { + sal_Int32 nPage = [pStepper intValue]; + [mpPageEdit setIntValue: nPage]; + updatePreviewImage( nPage-1 ); + } + } + } }; static void filterAccelerator( rtl::OUString& io_rText ) @@ -258,16 +444,6 @@ static void filterAccelerator( rtl::OUString& io_rText ) io_rText = aBuf.makeStringAndClear(); } -@interface ControlTarget : NSObject -{ - ListenerProperties* mpListener; -} --(id)initWithListenerMap: (ListenerProperties*)pListener; --(void)triggered:(id)pSender; --(void)triggeredNumeric:(id)pSender; --(void)dealloc; -@end - @implementation ControlTarget -(id)initWithListenerMap: (ListenerProperties*)pListener { @@ -350,6 +526,10 @@ static void filterAccelerator( rtl::OUString& io_rText ) } mpListener->updateEnableState(); } +-(void)triggeredPreview:(id)pSender +{ + mpListener->changePreview( pSender ); +} -(void)dealloc { delete mpListener; @@ -390,6 +570,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rMaxSize.height = aUnion.size.height; } + @implementation AquaPrintAccessoryView +(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withState: (PrintAccessoryViewState*)pState; { @@ -400,12 +581,16 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSView* pCurParent = 0; long nCurY = 0; long nCurX = 0; - NSRect aViewFrame = { { 0, 0 }, {400, 400 } }; + NSRect aViewFrame = { { 0, 0 }, {600, 400 } }; + NSRect aTabViewFrame = { { 200, 0 }, {400, 400 } }; NSSize aMaxTabSize = { 0, 0 }; - NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aViewFrame]; + NSView* pAccessoryView = [[NSView alloc] initWithFrame: aViewFrame]; + NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aTabViewFrame]; + [pAccessoryView addSubview: [pTabView autorelease]]; + sal_Bool bIgnoreSubgroup = sal_False; - ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pTabView, pState ); + ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pAccessoryView, pTabView, pState ); ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; for( int i = 0; i < rOptions.getLength(); i++ ) @@ -492,7 +677,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSTabViewItem* pItem = [[NSTabViewItem alloc] initWithIdentifier: pLabel ]; [pItem setLabel: pLabel]; [pTabView addTabViewItem: pItem]; - pCurParent = [[NSView alloc] initWithFrame: aViewFrame]; + pCurParent = [[NSView alloc] initWithFrame: aTabViewFrame]; [pItem setView: pCurParent]; [pLabel release]; @@ -509,12 +694,13 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSString* pText = CreateNSString( aText ); NSRect aTextRect = { { 0, 0 }, { 300, 15 } }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; [pTextView setDrawsBackground: NO]; [pTextView setString: pText]; [pTextView sizeToFit]; // FIXME: this does nothing - [pCurParent addSubview: pTextView]; + [pCurParent addSubview: [pTextView autorelease]]; aTextRect = [pTextView frame]; // move to nCurY @@ -542,7 +728,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) pVal->Value >>= bVal; [pBtn setState: bVal ? NSOnState : NSOffState]; [pBtn sizeToFit]; - [pCurParent addSubview: pBtn]; + [pCurParent addSubview: [pBtn autorelease]]; // connect target [pBtn setTarget: pCtrlTarget]; @@ -572,12 +758,13 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSString* pText = CreateNSString( aText ); NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, { 300, 15 } }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; [pTextView setDrawsBackground: NO]; [pTextView setString: pText]; [pTextView sizeToFit]; // FIXME: this does nothing - [pCurParent addSubview: pTextView]; + [pCurParent addSubview: [pTextView autorelease]]; // move to nCurY aTextRect.origin.y = nCurY - aTextRect.size.height; @@ -634,7 +821,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // move it down, so it comes to the correct position aRadioRect.origin.y = nCurY - aRadioRect.size.height; [pMatrix setFrame: aRadioRect]; - [pCurParent addSubview: pMatrix]; + [pCurParent addSubview: [pMatrix autorelease]]; // update nCurY nCurY = aRadioRect.origin.y - 5; @@ -662,6 +849,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aTextSize.height += 3; NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; [pTextView setDrawsBackground: NO]; @@ -669,7 +857,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pTextView setVerticallyResizable: NO]; [pTextView setHorizontallyResizable: YES]; [pTextView sizeToFit]; // FIXME: this actually does nothing - [pCurParent addSubview: pTextView]; + [pCurParent addSubview: [pTextView autorelease]]; aTextRect = [pTextView frame]; @@ -699,7 +887,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pBtn setTag: pListenerProperties->addNameTag( aPropertyName )]; [pBtn sizeToFit]; - [pCurParent addSubview: pBtn]; + [pCurParent addSubview: [pBtn autorelease]]; // connect target and action [pBtn setTarget: pCtrlTarget]; @@ -743,12 +931,13 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aTextSize.height += 3; NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; + [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; [pTextView setEditable: NO]; [pTextView setSelectable: NO]; [pTextView setDrawsBackground: NO]; [pTextView setString: pText]; [pTextView sizeToFit]; // FIXME: this does nothing - [pCurParent addSubview: pTextView]; + [pCurParent addSubview: [pTextView autorelease]]; // move to nCurY aTextRect.origin.y = nCurY - aTextRect.size.height; @@ -770,7 +959,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pFieldView setSelectable: YES]; [pFieldView setDrawsBackground: YES]; [pFieldView sizeToFit]; // FIXME: this does nothing - [pCurParent addSubview: pFieldView]; + [pCurParent addSubview: [pFieldView autorelease]]; // add the field to observed controls for enabled state changes // also add a tag just for this purpose @@ -795,15 +984,17 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pStep setIncrement: 1]; [pStep setValueWraps: NO]; [pStep setTag: nTag]; - [pCurParent addSubview: pStep]; + [pCurParent addSubview: [pStep autorelease]]; pListenerProperties->addObservedControl( pStep ); [pStep setTarget: pCtrlTarget]; [pStep setAction: @selector(triggered:)]; // constrain the text field to decimal numbers NSNumberFormatter* pFormatter = [[NSNumberFormatter alloc] init]; + [pFormatter setFormatterBehavior: NSNumberFormatterBehavior10_4]; [pFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; [pFormatter setAllowsFloats: NO]; + [pFormatter setMaximumFractionDigits: 0]; if( nMinValue != nMaxValue ) { [pFormatter setMinimum: [[NSNumber numberWithInt: nMinValue] autorelease]]; @@ -865,9 +1056,14 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) if( aTabCtrlSize.width < aMaxTabSize.width + 10 ) aTabCtrlSize.width = aMaxTabSize.width + 10; [pTabView setFrameSize: aTabCtrlSize]; + aViewFrame.size.width = aTabCtrlSize.width + aTabViewFrame.origin.x; + aViewFrame.size.height = aTabCtrlSize.height + aTabViewFrame.origin.y; + [pAccessoryView setFrameSize: aViewFrame.size]; + + pListenerProperties->setupPreview( pCtrlTarget ); // set the accessory view - [pOp setAccessoryView: pTabView]; + [pOp setAccessoryView: [pAccessoryView autorelease]]; // set the current selecte tab item if( pState->nLastPage >= 0 && pState->nLastPage < [pTabView numberOfTabViewItems] ) diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 0edbd5661335..a774717e8078 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -138,6 +138,7 @@ #define SV_PRINT_PROGRESS_CANCEL 1 #define SV_PRINT_PROGRESS_TEXT 2 +#define SV_PRINT_NATIVE_STRINGS 2050 #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index d629ba7c04d2..a653798332a2 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -395,3 +395,13 @@ ModelessDialog SV_DLG_PRINT_PROGRESS Center = TRUE; }; }; + +StringArray SV_PRINT_NATIVE_STRINGS +{ + ItemList [en-US] = + { + < "Preview"; >; + < "Page Number"; >; + < "Number of pages"; >; + }; +}; From 6587abd0796af81128602a7e43927fb3eaead419 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 6 Jul 2009 10:54:21 +0000 Subject: [PATCH 115/283] rename PrinterListener, add: getValues, abortJob --- vcl/aqua/inc/aquaprintview.h | 7 +- vcl/aqua/inc/salprn.h | 4 +- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 116 ++++++------ vcl/aqua/source/gdi/aquaprintview.mm | 6 +- vcl/aqua/source/gdi/salprn.cxx | 34 ++-- vcl/inc/vcl/oldprintadaptor.hxx | 2 +- vcl/inc/vcl/print.hxx | 24 ++- vcl/inc/vcl/prndlg.hxx | 6 +- vcl/inc/vcl/salprn.hxx | 4 +- vcl/source/app/salvtables.cxx | 2 +- vcl/source/gdi/oldprintadaptor.cxx | 2 +- vcl/source/gdi/print3.cxx | 175 ++++++++++-------- vcl/source/window/printdlg.cxx | 68 +++---- 13 files changed, 236 insertions(+), 214 deletions(-) diff --git a/vcl/aqua/inc/aquaprintview.h b/vcl/aqua/inc/aquaprintview.h index a3984333f84e..55a85678cd50 100755 --- a/vcl/aqua/inc/aquaprintview.h +++ b/vcl/aqua/inc/aquaprintview.h @@ -38,7 +38,6 @@ #include "vcl/print.hxx" class AquaSalInfoPrinter; -namespace vcl { class PrinterListener; } struct PrintAccessoryViewState { @@ -51,10 +50,10 @@ struct PrintAccessoryViewState @interface AquaPrintView : NSView { - vcl::PrinterListener* mpListener; + vcl::PrinterController* mpController; AquaSalInfoPrinter* mpInfoPrinter; } --(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter; +-(id)initWithController: (vcl::PrinterController*)pController withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter; -(MacOSBOOL)knowsPageRange: (NSRangePointer)range; -(NSRect)rectForPage: (int)page; -(NSPoint)locationOfPrintRect: (NSRect)aRect; @@ -64,7 +63,7 @@ struct PrintAccessoryViewState @interface AquaPrintAccessoryView : NSObject { } -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withState: (PrintAccessoryViewState*)pState; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withController: (vcl::PrinterController*)pController withState: (PrintAccessoryViewState*)pState; @end diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index a22503c22e78..e265f800906d 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -106,7 +106,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter const String& rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterListener& i_rListener, + vcl::PrinterController& i_rController, bool bIsQuickJob ); BOOL EndJob(); BOOL AbortJob(); @@ -149,7 +149,7 @@ class AquaSalPrinter : public SalPrinter const String& rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterListener& i_rListener ); + vcl::PrinterController& i_rListener ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 30811a1e0219..645de97d7ac3 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -55,13 +55,13 @@ using namespace com::sun::star::uno; the preview insists on not being present. This is unfortunate. */ -class ListenerProperties; +class ControllerProperties; @interface ControlTarget : NSObject { - ListenerProperties* mpListener; + ControllerProperties* mpController; } --(id)initWithListenerMap: (ListenerProperties*)pListener; +-(id)initWithControllerMap: (ControllerProperties*)pController; -(void)triggered:(id)pSender; -(void)triggeredNumeric:(id)pSender; -(void)triggeredPreview:(id)pSender; @@ -69,9 +69,9 @@ class ListenerProperties; @end -class ListenerProperties +class ControllerProperties { - vcl::PrinterListener* mpListener; + vcl::PrinterController* mpController; std::map< int, rtl::OUString > maTagToPropertyName; std::map< int, sal_Int32 > maTagToValueInt; std::map< NSView*, NSView* > maViewPairMap; @@ -89,14 +89,14 @@ class ListenerProperties NSTextView* mpPagesLabel; public: - ListenerProperties( vcl::PrinterListener* i_pListener, - NSPrintOperation* i_pOp, - NSView* i_pAccessoryView, - NSTabView* i_pTabView, - PrintAccessoryViewState* i_pState ) - : mpListener( i_pListener ), + ControllerProperties( vcl::PrinterController* i_pController, + NSPrintOperation* i_pOp, + NSView* i_pAccessoryView, + NSTabView* i_pTabView, + PrintAccessoryViewState* i_pState ) + : mpController( i_pController ), mnNextTag( 0 ), - mnLastPageCount( i_pListener->getPageCount() ), + mnLastPageCount( i_pController->getPageCount() ), mpState( i_pState ), mpOp( i_pOp ), mpAccessoryView( i_pAccessoryView ), @@ -112,10 +112,10 @@ class ListenerProperties void updatePrintJob() { - // TODO: refresh page count etc from mpListener + // TODO: refresh page count etc from mpController // page range may have changed depending on options - sal_Int32 nPages = mpListener->getPageCount(); + sal_Int32 nPages = mpController->getPageCount(); #if OSL_DEBUG_LEVEL > 1 if( nPages != mnLastPageCount ) fprintf( stderr, "trouble: number of pages changed from %ld to %ld !\n", mnLastPageCount, nPages ); @@ -203,7 +203,7 @@ class ListenerProperties std::map< int, sal_Int32 >::const_iterator value_it = maTagToValueInt.find( i_nTag ); if( name_it != maTagToPropertyName.end() && value_it != maTagToValueInt.end() ) { - PropertyValue* pVal = mpListener->getValue( name_it->second ); + PropertyValue* pVal = mpController->getValue( name_it->second ); if( pVal ) { pVal->Value <<= value_it->second; @@ -217,7 +217,7 @@ class ListenerProperties std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); if( name_it != maTagToPropertyName.end() ) { - PropertyValue* pVal = mpListener->getValue( name_it->second ); + PropertyValue* pVal = mpController->getValue( name_it->second ); if( pVal ) { pVal->Value <<= i_nValue; @@ -231,7 +231,7 @@ class ListenerProperties std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); if( name_it != maTagToPropertyName.end() ) { - PropertyValue* pVal = mpListener->getValue( name_it->second ); + PropertyValue* pVal = mpController->getValue( name_it->second ); if( pVal ) { pVal->Value <<= i_bValue; @@ -245,7 +245,7 @@ class ListenerProperties std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( i_nTag ); if( name_it != maTagToPropertyName.end() ) { - PropertyValue* pVal = mpListener->getValue( name_it->second ); + PropertyValue* pVal = mpController->getValue( name_it->second ); if( pVal ) { pVal->Value <<= i_rValue; @@ -273,7 +273,7 @@ class ListenerProperties std::map< int, rtl::OUString >::const_iterator name_it = maTagToPropertyName.find( nTag ); if( name_it != maTagToPropertyName.end() ) { - MacOSBOOL bEnabled = mpListener->isUIOptionEnabled( name_it->second ) ? YES : NO; + MacOSBOOL bEnabled = mpController->isUIOptionEnabled( name_it->second ) ? YES : NO; if( pCtrl ) { [pCtrl setEnabled: bEnabled]; @@ -290,14 +290,14 @@ class ListenerProperties void updatePreviewImage( sal_Int32 i_nPage ) { - sal_Int32 nPages = mpListener->getFilteredPageCount(); + sal_Int32 nPages = mpController->getFilteredPageCount(); NSRect aViewFrame = [mpPreview frame]; Size aPixelSize( static_cast(aViewFrame.size.width), static_cast(aViewFrame.size.height) ); if( i_nPage >= 0 && nPages > i_nPage ) { GDIMetaFile aMtf; - Size aPageSize( mpListener->getFilteredPageFile( i_nPage, aMtf, false ) ); + Size aPageSize( mpController->getFilteredPageFile( i_nPage, aMtf, false ) ); VirtualDevice aDev; Size aLogicSize( aDev.PixelToLogic( aPixelSize, MapMode( MAP_100TH_MM ) ) ); double fScaleX = double(aLogicSize.Width())/double(aPageSize.Width()); @@ -355,7 +355,7 @@ class ListenerProperties [mpPreviewBox addSubview: [mpPreview autorelease]]; // add a label - sal_Int32 nPages = mpListener->getFilteredPageCount(); + sal_Int32 nPages = mpController->getFilteredPageCount(); rtl::OUStringBuffer aBuf( 16 ); aBuf.appendAscii( "/ " ); aBuf.append( rtl::OUString::valueOf( nPages ) ); @@ -445,11 +445,11 @@ static void filterAccelerator( rtl::OUString& io_rText ) } @implementation ControlTarget --(id)initWithListenerMap: (ListenerProperties*)pListener +-(id)initWithControllerMap: (ControllerProperties*)pController { if( (self = [super init]) ) { - mpListener = pListener; + mpController = pController; } return self; } @@ -462,14 +462,14 @@ static void filterAccelerator( rtl::OUString& io_rText ) if( pSelected ) { int nTag = [pSelected tag]; - mpListener->changePropertyWithIntValue( nTag ); + mpController->changePropertyWithIntValue( nTag ); } } else if( [pSender isMemberOfClass: [NSButton class]] ) { NSButton* pBtn = (NSButton*)pSender; int nTag = [pBtn tag]; - mpListener->changePropertyWithBoolValue( nTag, [pBtn state] == NSOnState ); + mpController->changePropertyWithBoolValue( nTag, [pBtn state] == NSOnState ); } else if( [pSender isMemberOfClass: [NSMatrix class]] ) { @@ -478,7 +478,7 @@ static void filterAccelerator( rtl::OUString& io_rText ) { NSButtonCell* pCell = (NSButtonCell*)pObj; int nTag = [pCell tag]; - mpListener->changePropertyWithIntValue( nTag ); + mpController->changePropertyWithIntValue( nTag ); } } else if( [pSender isMemberOfClass: [NSTextField class]] ) @@ -486,13 +486,13 @@ static void filterAccelerator( rtl::OUString& io_rText ) NSTextField* pField = (NSTextField*)pSender; int nTag = [pField tag]; rtl::OUString aValue = GetOUString( [pSender stringValue] ); - mpListener->changePropertyWithStringValue( nTag, aValue ); + mpController->changePropertyWithStringValue( nTag, aValue ); } else { DBG_ERROR( "unsupported class" ); } - mpListener->updateEnableState(); + mpController->updateEnableState(); } -(void)triggeredNumeric:(id)pSender; { @@ -502,11 +502,11 @@ static void filterAccelerator( rtl::OUString& io_rText ) int nTag = [pField tag]; sal_Int64 nValue = [pField intValue]; - NSView* pOther = mpListener->getPair( pField ); + NSView* pOther = mpController->getPair( pField ); if( pOther ) [(NSControl*)pOther setIntValue: nValue]; - mpListener->changePropertyWithIntValue( nTag, nValue ); + mpController->changePropertyWithIntValue( nTag, nValue ); } else if( [pSender isMemberOfClass: [NSStepper class]] ) { @@ -514,25 +514,25 @@ static void filterAccelerator( rtl::OUString& io_rText ) int nTag = [pStep tag]; sal_Int64 nValue = [pStep intValue]; - NSView* pOther = mpListener->getPair( pStep ); + NSView* pOther = mpController->getPair( pStep ); if( pOther ) [(NSControl*)pOther setIntValue: nValue]; - mpListener->changePropertyWithIntValue( nTag, nValue ); + mpController->changePropertyWithIntValue( nTag, nValue ); } else { DBG_ERROR( "unsupported class" ); } - mpListener->updateEnableState(); + mpController->updateEnableState(); } -(void)triggeredPreview:(id)pSender { - mpListener->changePreview( pSender ); + mpController->changePreview( pSender ); } -(void)dealloc { - delete mpListener; + delete mpController; [super dealloc]; } @end @@ -572,9 +572,9 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) @implementation AquaPrintAccessoryView -+(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withListener: (vcl::PrinterListener*)pListener withState: (PrintAccessoryViewState*)pState; ++(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withController: (vcl::PrinterController*)pController withState: (PrintAccessoryViewState*)pState; { - const Sequence< PropertyValue >& rOptions( pListener->getUIOptions() ); + const Sequence< PropertyValue >& rOptions( pController->getUIOptions() ); if( rOptions.getLength() == 0 ) return nil; @@ -590,8 +590,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) sal_Bool bIgnoreSubgroup = sal_False; - ListenerProperties* pListenerProperties = new ListenerProperties( pListener, pOp, pAccessoryView, pTabView, pState ); - ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithListenerMap: pListenerProperties]; + ControllerProperties* pControllerProperties = new ControllerProperties( pController, pOp, pAccessoryView, pTabView, pState ); + ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithControllerMap: pControllerProperties]; for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -723,7 +723,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pBtn setButtonType: NSSwitchButton]; [pBtn setTitle: pText]; sal_Bool bVal = sal_False; - PropertyValue* pVal = pListener->getValue( aPropertyName ); + PropertyValue* pVal = pController->getValue( aPropertyName ); if( pVal ) pVal->Value >>= bVal; [pBtn setState: bVal ? NSOnState : NSOffState]; @@ -733,8 +733,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // connect target [pBtn setTarget: pCtrlTarget]; [pBtn setAction: @selector(triggered:)]; - int nTag = pListenerProperties->addNameTag( aPropertyName ); - pListenerProperties->addObservedControl( pBtn ); + int nTag = pControllerProperties->addNameTag( aPropertyName ); + pControllerProperties->addObservedControl( pBtn ); [pBtn setTag: nTag]; aCheckRect = [pBtn frame]; @@ -793,7 +793,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) numberOfColumns: 1]; // get currently selected value sal_Int32 nSelectVal = 0; - PropertyValue* pVal = pListener->getValue( aPropertyName ); + PropertyValue* pVal = pController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; // set individual titles @@ -807,8 +807,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // connect target and action [pCell setTarget: pCtrlTarget]; [pCell setAction: @selector(triggered:)]; - int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, m ); - pListenerProperties->addObservedControl( pCell ); + int nTag = pControllerProperties->addNameAndValueTag( aPropertyName, m ); + pControllerProperties->addObservedControl( pCell ); [pCell setTag: nTag]; [pTitle release]; // set current selection @@ -870,12 +870,12 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSString* pItemText = CreateNSString( aChoices[m] ); [pBtn addItemWithTitle: pItemText]; NSMenuItem* pItem = [pBtn itemWithTitle: pItemText]; - int nTag = pListenerProperties->addNameAndValueTag( aPropertyName, m ); + int nTag = pControllerProperties->addNameAndValueTag( aPropertyName, m ); [pItem setTag: nTag]; [pItemText release]; } - PropertyValue* pVal = pListener->getValue( aPropertyName ); + PropertyValue* pVal = pController->getValue( aPropertyName ); sal_Int32 aSelectVal = 0; if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aSelectVal; @@ -883,8 +883,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // add the button to observed controls for enabled state changes // also add a tag just for this purpose - pListenerProperties->addObservedControl( pBtn ); - [pBtn setTag: pListenerProperties->addNameTag( aPropertyName )]; + pControllerProperties->addObservedControl( pBtn ); + [pBtn setTag: pControllerProperties->addNameTag( aPropertyName )]; [pBtn sizeToFit]; [pCurParent addSubview: [pBtn autorelease]]; @@ -963,17 +963,17 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // add the field to observed controls for enabled state changes // also add a tag just for this purpose - pListenerProperties->addObservedControl( pFieldView ); - int nTag = pListenerProperties->addNameTag( aPropertyName ); + pControllerProperties->addObservedControl( pFieldView ); + int nTag = pControllerProperties->addNameTag( aPropertyName ); [pFieldView setTag: nTag]; - // pListenerProperties->addNamedView( pFieldView, aPropertyName ); + // pControllerProperties->addNamedView( pFieldView, aPropertyName ); // move to nCurY aFieldRect.origin.y = nCurY - aFieldRect.size.height; [pFieldView setFrame: aFieldRect]; // current value - PropertyValue* pVal = pListener->getValue( aPropertyName ); + PropertyValue* pVal = pController->getValue( aPropertyName ); if( aCtrlType.equalsAscii( "Range" ) ) { // add a stepper control @@ -985,7 +985,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pStep setValueWraps: NO]; [pStep setTag: nTag]; [pCurParent addSubview: [pStep autorelease]]; - pListenerProperties->addObservedControl( pStep ); + pControllerProperties->addObservedControl( pStep ); [pStep setTarget: pCtrlTarget]; [pStep setAction: @selector(triggered:)]; @@ -1011,7 +1011,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pFieldView setIntValue: nSelectVal]; [pStep setIntValue: nSelectVal]; - pListenerProperties->addViewPair( pFieldView, pStep ); + pControllerProperties->addViewPair( pFieldView, pStep ); // connect target and action [pFieldView setTarget: pCtrlTarget]; [pFieldView setAction: @selector(triggeredNumeric:)]; @@ -1047,7 +1047,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) DBG_ERROR( "Unsupported UI option" ); } } - pListenerProperties->updateEnableState(); + pControllerProperties->updateEnableState(); adjustViewAndChildren( pCurParent, aMaxTabSize ); // find the minimum needed tab size @@ -1060,7 +1060,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aViewFrame.size.height = aTabCtrlSize.height + aTabViewFrame.origin.y; [pAccessoryView setFrameSize: aViewFrame.size]; - pListenerProperties->setupPreview( pCtrlTarget ); + pControllerProperties->setupPreview( pCtrlTarget ); // set the accessory view [pOp setAccessoryView: [pAccessoryView autorelease]]; diff --git a/vcl/aqua/source/gdi/aquaprintview.mm b/vcl/aqua/source/gdi/aquaprintview.mm index a050d229f033..6519b4981770 100755 --- a/vcl/aqua/source/gdi/aquaprintview.mm +++ b/vcl/aqua/source/gdi/aquaprintview.mm @@ -36,12 +36,12 @@ #include "vcl/print.hxx" @implementation AquaPrintView --(id)initWithListener: (vcl::PrinterListener*)pListener withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter +-(id)initWithController: (vcl::PrinterController*)pController withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter { NSRect aRect = { { 0, 0 }, [pInfoPrinter->getPrintInfo() paperSize] }; if( (self = [super initWithFrame: aRect]) != nil ) { - mpListener = pListener; + mpController = pController; mpInfoPrinter = pInfoPrinter; } return self; @@ -77,6 +77,6 @@ // page count is 1 based if( nPage - 1 < (mpInfoPrinter->getCurPageRangeStart() + mpInfoPrinter->getCurPageRangeCount() ) ) - mpListener->printFilteredPage( nPage-1 ); + mpController->printFilteredPage( nPage-1 ); } @end diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index e06e8c48fd8b..89a9d08cef13 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -484,10 +484,10 @@ void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*, } } -static Size getPageSize( vcl::PrinterListener& i_rListener, sal_Int32 i_nPage ) +static Size getPageSize( vcl::PrinterController& i_rController, sal_Int32 i_nPage ) { Size aPageSize; - Sequence< PropertyValue > aPageParms( i_rListener.getPageParameters( i_nPage ) ); + Sequence< PropertyValue > aPageParms( i_rController.getPageParameters( i_nPage ) ); for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty ) { if( aPageParms[ nProperty ].Name.equalsAscii( "PageSize" ) ) @@ -506,7 +506,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, const String& i_rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterListener& i_rListener, + vcl::PrinterController& i_rController, bool bIsQuickJob ) { if( mbJob ) @@ -521,7 +521,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, aAccViewState.bNeedRestart = true; // reset IsLastPage - i_rListener.setLastPage( sal_False ); + i_rController.setLastPage( sal_False ); // update job data if( i_pSetupData ) @@ -529,20 +529,20 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, // do we want a progress panel ? sal_Bool bShowProgressPanel = sal_True; - beans::PropertyValue* pMonitor = i_rListener.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); + beans::PropertyValue* pMonitor = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); if( pMonitor ) pMonitor->Value >>= bShowProgressPanel; // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) // how do I know when that might be ? - i_rListener.jobStarted(); + i_rController.jobStarted(); do { if( aAccViewState.bNeedRestart ) { mnCurPageRangeStart = 0; mnCurPageRangeCount = 0; - nAllPages = i_rListener.getFilteredPageCount(); + nAllPages = i_rController.getFilteredPageCount(); } aAccViewState.bNeedRestart = false; @@ -551,13 +551,13 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( nAllPages > 0 ) { mnCurPageRangeCount = 1; - aCurSize = getPageSize( i_rListener, mnCurPageRangeStart ); + aCurSize = getPageSize( i_rController, mnCurPageRangeStart ); Size aNextSize( aCurSize ); // print pages up to a different size while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages ) { - aNextSize = getPageSize( i_rListener, mnCurPageRangeStart + mnCurPageRangeCount ); + aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount ); if( aCurSize == aNextSize // same page size || (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation @@ -578,7 +578,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, setPaperSize( aCurSize.Width(), aCurSize.Height(), ORIENTATION_PORTRAIT ); // create view - NSView* pPrintView = [[AquaPrintView alloc] initWithListener: &i_rListener withInfoPrinter: this]; + NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this]; NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary]; @@ -591,7 +591,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, [pPath release]; } - [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rListener.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; + [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rController.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; @@ -612,7 +612,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]]; if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view - pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withListener: &i_rListener withState: &aAccViewState]; + pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState]; bSuccess = TRUE; mbJob = true; @@ -634,14 +634,14 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, // so we need to call XRenderadble::render one last time with IsLastPage = TRUE if( nAllPages > 0 ) { - i_rListener.setLastPage( sal_True ); + i_rController.setLastPage( sal_True ); GDIMetaFile aPageFile; if( mrContext ) SetupPrinterGraphics( mrContext ); - i_rListener.getFilteredPageFile( 0, aPageFile ); + i_rController.getFilteredPageFile( 0, aPageFile ); } - i_rListener.setJobState( bWasAborted + i_rController.setJobState( bWasAborted ? view::PrintableState_JOB_ABORTED : view::PrintableState_JOB_SPOOLED ); @@ -716,7 +716,7 @@ BOOL AquaSalPrinter::StartJob( const String* i_pFileName, const String& i_rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterListener& i_rListener ) + vcl::PrinterController& i_rController ) { bool bIsQuickJob = false; std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator quick_it = @@ -728,7 +728,7 @@ BOOL AquaSalPrinter::StartJob( const String* i_pFileName, bIsQuickJob = true; } - return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rListener, bIsQuickJob ); + return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController, bIsQuickJob ); } // ----------------------------------------------------------------------- diff --git a/vcl/inc/vcl/oldprintadaptor.hxx b/vcl/inc/vcl/oldprintadaptor.hxx index 9a0cb9a1d083..d8b26433af94 100644 --- a/vcl/inc/vcl/oldprintadaptor.hxx +++ b/vcl/inc/vcl/oldprintadaptor.hxx @@ -33,7 +33,7 @@ namespace vcl { struct ImplOldStyleAdaptorData; - class VCL_DLLPUBLIC OldStylePrintAdaptor : public PrinterListener + class VCL_DLLPUBLIC OldStylePrintAdaptor : public PrinterController { ImplOldStyleAdaptorData* mpData; public: diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 4cbd24dc02bd..339dee01d86d 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -56,7 +56,7 @@ class VirtualDevice; class Window; namespace vcl { - class PrinterListener; + class PrinterController; class PrintDialog; } @@ -264,7 +264,7 @@ private: SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& ); DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); - SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr& ); + SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr& ); static SAL_DLLPRIVATE ULONG ImplSalPrinterErrorCodeToVCL( ULONG nError ); @@ -386,26 +386,26 @@ public: starts a print job asynchronously (that is will return */ - static void PrintJob( const boost::shared_ptr& i_pListener, + static void PrintJob( const boost::shared_ptr& i_pController, const JobSetup& i_rInitSetup ); // implementation detail of PrintJob being asynchronous // not exported, not usable outside vcl - static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr& i_pListener, + static void SAL_DLLPRIVATE ImplPrintJob( const boost::shared_ptr& i_pController, const JobSetup& i_rInitSetup ); }; namespace vcl { -class ImplPrinterListenerData; +class ImplPrinterControllerData; -class VCL_DLLPUBLIC PrinterListener +class VCL_DLLPUBLIC PrinterController { - ImplPrinterListenerData* mpImplData; + ImplPrinterControllerData* mpImplData; protected: - PrinterListener( const boost::shared_ptr& ); + PrinterController( const boost::shared_ptr& ); public: struct MultiPageSetup { @@ -432,8 +432,8 @@ public: } }; - PrinterListener(); - virtual ~PrinterListener(); + PrinterController(); + virtual ~PrinterController(); const boost::shared_ptr& getPrinter() const; /* for implementations: get current job properties as changed by e.g. print dialog @@ -449,6 +449,8 @@ public: */ com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ); const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ) const; + // get a sequence of properties + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getValues( const com::sun::star::uno::Sequence< rtl::OUString >& ) const; /* set a property value - can also be used to add another UI property */ @@ -483,6 +485,8 @@ public: com::sun::star::view::PrintableState getJobState() const; + void abortJob(); + // implementation details, not usable outside vcl SAL_DLLPRIVATE int getFilteredPageCount(); SAL_DLLPRIVATE Size getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 67f38e45540f..e76d823b447a 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -112,7 +112,7 @@ namespace vcl void readFromSettings(); void storeToSettings(); - void initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& ); + void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); virtual void Resize(); }; @@ -156,7 +156,7 @@ namespace vcl FixedLine maButtonLine; - boost::shared_ptr< PrinterListener > maPListener; + boost::shared_ptr< PrinterController > maPController; rtl::OUString maPageStr; rtl::OUString maNoPageStr; @@ -206,7 +206,7 @@ namespace vcl DECL_LINK( UIOption_ModifyHdl, Edit* ); public: - PrintDialog( Window*, const boost::shared_ptr< PrinterListener >& ); + PrintDialog( Window*, const boost::shared_ptr< PrinterController >& ); virtual ~PrintDialog(); bool isPrintToFile(); diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx index a53adfe3518e..e7fc44f0ab7d 100644 --- a/vcl/inc/vcl/salprn.hxx +++ b/vcl/inc/vcl/salprn.hxx @@ -41,7 +41,7 @@ class SalGraphics; class SalFrame; struct ImplJobSetup; -namespace vcl { class PrinterListener; } +namespace vcl { class PrinterController; } // ----------------------- // - SalPrinterQueueInfo - @@ -125,7 +125,7 @@ public: // public for Sal Implementation const String& rJobName, const String& rAppName, ImplJobSetup* pSetupData, - vcl::PrinterListener& rListener ); + vcl::PrinterController& rController ); virtual BOOL EndJob() = 0; virtual BOOL AbortJob() = 0; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 7f872d0a9b63..d8ead71c0a4b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -91,7 +91,7 @@ SalPrinter::~SalPrinter() } BOOL SalPrinter::StartJob( const String*, const String&, const String&, - ImplJobSetup*, vcl::PrinterListener& ) + ImplJobSetup*, vcl::PrinterController& ) { return FALSE; } diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx index e0250d2832ba..cffd11daaad6 100644 --- a/vcl/source/gdi/oldprintadaptor.cxx +++ b/vcl/source/gdi/oldprintadaptor.cxx @@ -55,7 +55,7 @@ using namespace com::sun::star::uno; using namespace com::sun::star::beans; OldStylePrintAdaptor::OldStylePrintAdaptor( const boost::shared_ptr< Printer >& i_pPrinter ) - : PrinterListener( i_pPrinter ) + : PrinterController( i_pPrinter ) , mpData( new ImplOldStyleAdaptorData() ) { } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index d0ff5814aa51..583ef206df7e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -130,7 +130,7 @@ public: } }; -class vcl::ImplPrinterListenerData +class vcl::ImplPrinterControllerData { public: struct ControlDependency @@ -154,27 +154,27 @@ public: sal_Bool mbLastPage; view::PrintableState meJobState; - vcl::PrinterListener::MultiPageSetup maMultiPage; + vcl::PrinterController::MultiPageSetup maMultiPage; vcl::PrintProgressDialog* mpProgress; ImplPageCache maPageCache; - ImplPrinterListenerData() : + ImplPrinterControllerData() : mbLastPage( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ) {} - ~ImplPrinterListenerData() { delete mpProgress; } + ~ImplPrinterControllerData() { delete mpProgress; } }; -PrinterListener::PrinterListener() - : mpImplData( new ImplPrinterListenerData ) +PrinterController::PrinterController() + : mpImplData( new ImplPrinterControllerData ) { } -PrinterListener::PrinterListener( const boost::shared_ptr& i_pPrinter ) - : mpImplData( new ImplPrinterListenerData ) +PrinterController::PrinterController( const boost::shared_ptr& i_pPrinter ) + : mpImplData( new ImplPrinterControllerData ) { mpImplData->mpPrinter = i_pPrinter; } @@ -238,13 +238,13 @@ static rtl::OUString queryFile( Printer* pPrinter ) struct PrintJobAsync { - boost::shared_ptr mpListener; + boost::shared_ptr mpController; JobSetup maInitSetup; - PrintJobAsync( const boost::shared_ptr& i_pListener, + PrintJobAsync( const boost::shared_ptr& i_pController, const JobSetup& i_rInitSetup ) - : mpListener( i_pListener ), maInitSetup( i_rInitSetup ) + : mpController( i_pController ), maInitSetup( i_rInitSetup ) {} DECL_LINK( ExecJob, void* ); @@ -252,7 +252,7 @@ struct PrintJobAsync IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG ) { - Printer::ImplPrintJob( mpListener, maInitSetup ); + Printer::ImplPrintJob( mpController, maInitSetup ); // clean up, do not access members after this delete this; @@ -260,41 +260,41 @@ IMPL_LINK( PrintJobAsync, ExecJob, void*, EMPTYARG ) return 0; } -void Printer::PrintJob( const boost::shared_ptr& i_pListener, +void Printer::PrintJob( const boost::shared_ptr& i_pController, const JobSetup& i_rInitSetup ) { sal_Bool bSynchronous = sal_False; - beans::PropertyValue* pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + beans::PropertyValue* pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); if( pVal ) pVal->Value >>= bSynchronous; if( bSynchronous ) - ImplPrintJob( i_pListener, i_rInitSetup ); + ImplPrintJob( i_pController, i_rInitSetup ); else { - PrintJobAsync* pAsync = new PrintJobAsync( i_pListener, i_rInitSetup ); + PrintJobAsync* pAsync = new PrintJobAsync( i_pController, i_rInitSetup ); Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) ); } } -void Printer::ImplPrintJob( const boost::shared_ptr& i_pListener, +void Printer::ImplPrintJob( const boost::shared_ptr& i_pController, const JobSetup& i_rInitSetup ) { // setup printer - boost::shared_ptr pListener( i_pListener ); + boost::shared_ptr pController( i_pController ); // if no specific printer is already set, create one - if( ! pListener->getPrinter() ) + if( ! pController->getPrinter() ) { boost::shared_ptr pPrinter( new Printer( i_rInitSetup.GetPrinterName() ) ); - pListener->setPrinter( pPrinter ); + pController->setPrinter( pPrinter ); } // reset last page property - i_pListener->setLastPage( sal_False ); + i_pController->setLastPage( sal_False ); - beans::PropertyValue* pPagesVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) ) ); + beans::PropertyValue* pPagesVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) ) ); if( pPagesVal ) { rtl::OUString aPagesVal; @@ -304,13 +304,13 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene // "Pages" attribute from API is now equivalent to "PageRange" // AND "PrintContent" = 1 except calc where it is "PrintRange" = 1 // Argh ! That sure needs cleaning up - beans::PropertyValue* pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + beans::PropertyValue* pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); if( ! pVal ) - pVal = i_pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); + pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); if( pVal ) { pVal->Value = makeAny( sal_Int32( 1 ) ); - i_pListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), pPagesVal->Value ); + i_pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), pPagesVal->Value ); } } } @@ -319,25 +319,25 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene // in that case leave the work to that dialog const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); bool bIsQuick = rQuick.Len() && rQuick.EqualsIgnoreCaseAscii( "true" ); - if( ! pListener->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && ! bIsQuick ) + if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && ! bIsQuick ) { try { - PrintDialog aDlg( NULL, i_pListener ); + PrintDialog aDlg( NULL, i_pController ); if( ! aDlg.Execute() ) { GDIMetaFile aPageFile; - i_pListener->setLastPage( sal_True ); - if( i_pListener->getPageCount() > 0 ) - i_pListener->getFilteredPageFile( 0, aPageFile ); + i_pController->setLastPage( sal_True ); + if( i_pController->getPageCount() > 0 ) + i_pController->getFilteredPageFile( 0, aPageFile ); return; } if( aDlg.isPrintToFile() ) { - rtl::OUString aFile = queryFile( pListener->getPrinter().get() ); + rtl::OUString aFile = queryFile( pController->getPrinter().get() ); if( ! aFile.getLength() ) return; - pListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), + pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), makeAny( aFile ) ); } } @@ -346,19 +346,19 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pListene } } - pListener->pushPropertiesToPrinter(); + pController->pushPropertiesToPrinter(); rtl::OUString aJobName; - beans::PropertyValue* pJobNameVal = pListener->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ) ); + beans::PropertyValue* pJobNameVal = pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ) ); if( pJobNameVal ) pJobNameVal->Value >>= aJobName; - pListener->getPrinter()->StartJob( String( aJobName ), pListener ); + pController->getPrinter()->StartJob( String( aJobName ), pController ); - pListener->jobFinished( pListener->getJobState() ); + pController->jobFinished( pController->getJobState() ); } -bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr& i_pListener ) +bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr& i_pController ) { mnError = PRINTER_OK; @@ -403,7 +403,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrgetValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ) ); + beans::PropertyValue* pFileValue = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ) ); if( pFileValue ) { rtl::OUString aFile; @@ -429,12 +429,12 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrStartJob( pPrintFile, i_rJobName, Application::GetDisplayName(), maJobSetup.ImplGetConstData(), - *i_pListener ) ) + *i_pController ) ) { EndJob(); } @@ -456,8 +456,8 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrsetJobState( view::PrintableState_JOB_STARTED ); - i_pListener->jobStarted(); + i_pController->setJobState( view::PrintableState_JOB_STARTED ); + i_pController->jobStarted(); if( mpPrinter->StartJob( pPrintFile, i_rJobName, @@ -466,22 +466,22 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrcreateProgressDialog(); - int nPages = i_pListener->getFilteredPageCount(); + i_pController->createProgressDialog(); + int nPages = i_pController->getFilteredPageCount(); for( int nPage = 0; nPage < nPages; nPage++ ) { if( nPage == nPages-1 ) - i_pListener->setLastPage( sal_True ); - i_pListener->printFilteredPage( nPage ); + i_pController->setLastPage( sal_True ); + i_pController->printFilteredPage( nPage ); } EndJob(); - if( i_pListener->getJobState() == view::PrintableState_JOB_STARTED ) - i_pListener->setJobState( view::PrintableState_JOB_SPOOLED ); + if( i_pController->getJobState() == view::PrintableState_JOB_STARTED ) + i_pController->setJobState( view::PrintableState_JOB_SPOOLED ); } else { - i_pListener->setJobState( view::PrintableState_JOB_FAILED ); + i_pController->setJobState( view::PrintableState_JOB_FAILED ); mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); if ( !mnError ) @@ -499,27 +499,27 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrmeJobState; } -void PrinterListener::setJobState( view::PrintableState i_eState ) +void PrinterController::setJobState( view::PrintableState i_eState ) { mpImplData->meJobState = i_eState; } -const boost::shared_ptr& PrinterListener::getPrinter() const +const boost::shared_ptr& PrinterController::getPrinter() const { return mpImplData->mpPrinter; } -void PrinterListener::setPrinter( const boost::shared_ptr& i_rPrinter ) +void PrinterController::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; Size aPaperSize( i_rPrinter->PixelToLogic( i_rPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); @@ -547,7 +547,7 @@ static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& return aPageSize; } -Size PrinterListener::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) +Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { // update progress if necessary if( mpImplData->mpProgress ) @@ -635,7 +635,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD o_rMtf.AddAction( new MetaPopAction() ); } -Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) +Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { const MultiPageSetup& rMPS( mpImplData->maMultiPage ); int nSubPages = rMPS.nRows * rMPS.nColumns; @@ -713,7 +713,7 @@ Size PrinterListener::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_r return aPaperSize; } -int PrinterListener::getFilteredPageCount() +int PrinterController::getFilteredPageCount() { int nDiv = mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns; if( nDiv < 1 ) @@ -721,7 +721,7 @@ int PrinterListener::getFilteredPageCount() return (getPageCount() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; } -void PrinterListener::printFilteredPage( int i_nPage ) +void PrinterController::printFilteredPage( int i_nPage ) { if( mpImplData->meJobState != view::PrintableState_JOB_STARTED ) return; @@ -811,20 +811,25 @@ void PrinterListener::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetDrawMode( nRestoreDrawMode ); } -void PrinterListener::jobStarted() +void PrinterController::jobStarted() { } -void PrinterListener::jobFinished( view::PrintableState ) +void PrinterController::jobFinished( view::PrintableState ) { } -void PrinterListener::setLastPage( sal_Bool i_bLastPage ) +void PrinterController::abortJob() +{ + setJobState( view::PrintableState_JOB_ABORTED ); +} + +void PrinterController::setLastPage( sal_Bool i_bLastPage ) { mpImplData->mbLastPage = i_bLastPage; } -Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const +Sequence< PropertyValue > PrinterController::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; size_t nResultLen = size_t(i_rMergeList.getLength()) + mpImplData->maUIProperties.size() + 3; @@ -860,26 +865,40 @@ Sequence< PropertyValue > PrinterListener::getJobProperties( const Sequence< Pro return aResult; } -const Sequence< beans::PropertyValue >& PrinterListener::getUIOptions() const +const Sequence< beans::PropertyValue >& PrinterController::getUIOptions() const { return mpImplData->maUIOptions; } -com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl::OUString& i_rProperty ) +beans::PropertyValue* PrinterController::getValue( const rtl::OUString& i_rProperty ) { std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rProperty ); return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; } -const com::sun::star::beans::PropertyValue* PrinterListener::getValue( const rtl::OUString& i_rProperty ) const +const beans::PropertyValue* PrinterController::getValue( const rtl::OUString& i_rProperty ) const { std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rProperty ); return it != mpImplData->maPropertyToIndex.end() ? &mpImplData->maUIProperties[it->second] : NULL; } -void PrinterListener::setValue( const rtl::OUString& i_rName, const Any& i_rValue ) +Sequence< beans::PropertyValue > PrinterController::getValues( const Sequence< rtl::OUString >& i_rNames ) const +{ + Sequence< beans::PropertyValue > aRet( i_rNames.getLength() ); + sal_Int32 nFound = 0; + for( sal_Int32 i = 0; i < i_rNames.getLength(); i++ ) + { + const beans::PropertyValue* pVal = getValue( i_rNames[i] ); + if( pVal ) + aRet[ nFound++ ] = *pVal; + } + aRet.realloc( nFound ); + return aRet; +} + +void PrinterController::setValue( const rtl::OUString& i_rName, const Any& i_rValue ) { beans::PropertyValue aVal; aVal.Name = i_rName; @@ -888,7 +907,7 @@ void PrinterListener::setValue( const rtl::OUString& i_rName, const Any& i_rValu setValue( aVal ); } -void PrinterListener::setValue( const beans::PropertyValue& i_rValue ) +void PrinterController::setValue( const beans::PropertyValue& i_rValue ) { std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rValue.Name ); @@ -903,7 +922,7 @@ void PrinterListener::setValue( const beans::PropertyValue& i_rValue ) } } -void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rOptions ) +void PrinterController::setUIOptions( const Sequence< beans::PropertyValue >& i_rOptions ) { DBG_ASSERT( mpImplData->maUIOptions.getLength() == 0, "setUIOptions called twice !" ); @@ -916,7 +935,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO bool bIsEnabled = true; bool bHaveProperty = false; rtl::OUString aPropName; - vcl::ImplPrinterListenerData::ControlDependency aDep; + vcl::ImplPrinterControllerData::ControlDependency aDep; for( int n = 0; n < aOptProp.getLength(); n++ ) { const beans::PropertyValue& rEntry( aOptProp[ n ] ); @@ -947,7 +966,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO } if( bHaveProperty ) { - vcl::ImplPrinterListenerData::PropertyToIndexMap::const_iterator it = + vcl::ImplPrinterControllerData::PropertyToIndexMap::const_iterator it = mpImplData->maPropertyToIndex.find( aPropName ); // sanity check if( it != mpImplData->maPropertyToIndex.end() ) @@ -960,7 +979,7 @@ void PrinterListener::setUIOptions( const Sequence< beans::PropertyValue >& i_rO } } -void PrinterListener::enableUIOption( const rtl::OUString& i_rProperty, bool i_bEnable ) +void PrinterController::enableUIOption( const rtl::OUString& i_rProperty, bool i_bEnable ) { std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator it = mpImplData->maPropertyToIndex.find( i_rProperty ); @@ -977,7 +996,7 @@ void PrinterListener::enableUIOption( const rtl::OUString& i_rProperty, bool i_b } } -bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) const +bool PrinterController::isUIOptionEnabled( const rtl::OUString& i_rProperty ) const { bool bEnabled = false; std::hash_map< rtl::OUString, size_t, rtl::OUStringHash >::const_iterator prop_it = @@ -989,7 +1008,7 @@ bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) cons if( bEnabled ) { // check control dependencies - vcl::ImplPrinterListenerData::ControlDependencyMap::const_iterator it = + vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it = mpImplData->maControlDependencies.find( i_rProperty ); if( it != mpImplData->maControlDependencies.end() ) { @@ -1031,12 +1050,12 @@ bool PrinterListener::isUIOptionEnabled( const rtl::OUString& i_rProperty ) cons return bEnabled; } -void PrinterListener::setOptionChangeHdl( const Link& i_rHdl ) +void PrinterController::setOptionChangeHdl( const Link& i_rHdl ) { mpImplData->maOptionChangeHdl = i_rHdl; } -void PrinterListener::createProgressDialog() +void PrinterController::createProgressDialog() { if( ! mpImplData->mpProgress ) { @@ -1053,17 +1072,17 @@ void PrinterListener::createProgressDialog() } } -void PrinterListener::setMultipage( const MultiPageSetup& i_rMPS ) +void PrinterController::setMultipage( const MultiPageSetup& i_rMPS ) { mpImplData->maMultiPage = i_rMPS; } -const PrinterListener::MultiPageSetup& PrinterListener::getMultipage() const +const PrinterController::MultiPageSetup& PrinterController::getMultipage() const { return mpImplData->maMultiPage; } -void PrinterListener::pushPropertiesToPrinter() +void PrinterController::pushPropertiesToPrinter() { sal_Int32 nCopyCount = 1; // set copycount and collate diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 138c75427d6d..5f8d08ec28a7 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -251,7 +251,7 @@ void PrintDialog::NUpTabPage::Resize() aPage->setManagedArea( Rectangle( Point(), GetOutputSizePixel() ) ); } -void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterListener::MultiPageSetup& i_rMPS ) +void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS ) { maLeftMarginEdt.SetValue( maLeftMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); maTopMarginEdt.SetValue( maTopMarginEdt.Normalize( i_rMPS.nTopMargin ), FUNIT_100TH_MM ); @@ -373,7 +373,7 @@ void PrintDialog::JobTabPage::storeToSettings() rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) ); } -PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rListener ) +PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rController ) : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) , maOKButton( this, VclResId( SV_PRINT_OK ) ) , maCancelButton( this, VclResId( SV_PRINT_CANCEL ) ) @@ -386,7 +386,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) + if( maJobPage.maPrinters.GetEntryPos( maPController->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND ) { - maJobPage.maPrinters.SelectEntry( maPListener->getPrinter()->GetName() ); + maJobPage.maPrinters.SelectEntry( maPController->getPrinter()->GetName() ); } else { @@ -447,13 +447,13 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetPrinter( boost::shared_ptr( new Printer( aValue ) ) ); + maPController->setPrinter( boost::shared_ptr( new Printer( aValue ) ) ); } else { // fall back to default printer maJobPage.maPrinters.SelectEntry( Printer::GetDefaultPrinterName() ); - maPListener->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); + maPController->setPrinter( boost::shared_ptr( new Printer( Printer::GetDefaultPrinterName() ) ) ); } } // update the text fields for the printer @@ -463,9 +463,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPrinter()->PixelToLogic( - maPListener->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); - if( maPListener->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE ) + Size aNupSize( maPController->getPrinter()->PixelToLogic( + maPController->getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + if( maPController->getPrinter()->GetOrientation() == ORIENTATION_LANDSCAPE ) { maNupLandscapeSize = aNupSize; maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() ); @@ -477,7 +477,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetMultipage() ); + maNUpPage.initFromMultiPageSetup( maPController->getMultipage() ); // setup click handler on the various buttons @@ -510,7 +510,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); + maPController->setOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); // set min size pixel to current size SetMinOutputSizePixel( GetOutputSizePixel() ); @@ -639,7 +639,7 @@ void PrintDialog::setupOptionalUI() std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap; - const Sequence< PropertyValue >& rOptions( maPListener->getUIOptions() ); + const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() ); for( int i = 0; i < rOptions.getLength(); i++ ) { Sequence< beans::PropertyValue > aOptProp; @@ -822,11 +822,11 @@ void PrintDialog::setupOptionalUI() pNewBox->Show(); sal_Bool bVal = sal_False; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); + PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal ) pVal->Value >>= bVal; pNewBox->Check( bVal ); - pNewBox->Enable( maPListener->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); + pNewBox->Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) ); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); @@ -870,7 +870,7 @@ void PrintDialog::setupOptionalUI() } // iterate options sal_Int32 nSelectVal = 0; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); + PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) @@ -883,7 +883,7 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); - pBtn->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pBtn->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); pBtn->Show(); maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) ); @@ -934,11 +934,11 @@ void PrintDialog::setupOptionalUI() pList->InsertEntry( aChoices[m] ); } sal_Int32 nSelectVal = 0; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); + PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; pList->SelectEntryPos( static_cast(nSelectVal) ); - pList->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pList->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); pList->SetDropDownLineCount( static_cast(aChoices.getLength()) ); pList->Show(); @@ -966,12 +966,12 @@ void PrintDialog::setupOptionalUI() pField->SetMax( nMaxValue ); } sal_Int64 nCurVal = 0; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); + PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nCurVal; pField->SetValue( nCurVal ); - pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -992,11 +992,11 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pField ); rtl::OUString aCurVal; - PropertyValue* pVal = maPListener->getValue( aPropertyName ); + PropertyValue* pVal = maPController->getValue( aPropertyName ); if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aCurVal; pField->SetText( aCurVal ); - pField->Enable( maPListener->isUIOptionEnabled( aPropertyName ) ); + pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -1089,7 +1089,7 @@ void PrintDialog::checkControlDependencies() maJobPage.maCollateImage.SetImage( aImg ); // enable setup button only for printers that can be setup - bool bHaveSetup = maPListener->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); + bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); maJobPage.maSetupButton.Enable( bHaveSetup ); if( bHaveSetup ) { @@ -1123,7 +1123,7 @@ void PrintDialog::checkOptionalControlDependencies() for( std::map< Window*, rtl::OUString >::iterator it = maControlToPropertyMap.begin(); it != maControlToPropertyMap.end(); ++it ) { - bool bShouldbeEnabled = maPListener->isUIOptionEnabled( it->second ); + bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second ); bool bIsEnabled = it->first->IsEnabled(); // Enable does not do a change check first, so can be less cheap than expected if( bShouldbeEnabled != bIsEnabled ) @@ -1176,7 +1176,7 @@ void PrintDialog::setPreviewText( sal_Int32 ) void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) { // page range may have changed depending on options - sal_Int32 nPages = maPListener->getFilteredPageCount(); + sal_Int32 nPages = maPController->getFilteredPageCount(); mnCachedPages = nPages; if( mnCurPage >= nPages ) @@ -1189,7 +1189,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) maPageEdit.SetMin( 1 ); maPageEdit.SetMax( nPages ); - boost::shared_ptr aPrt( maPListener->getPrinter() ); + boost::shared_ptr aPrt( maPController->getPrinter() ); if( i_bNewPage ) @@ -1197,7 +1197,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; if( nPages > 0 ) - maCurPageSize = maPListener->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); + maCurPageSize = maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); maPreviewWindow.setPreview( aMtf ); } @@ -1232,7 +1232,7 @@ void PrintDialog::updateNup() int nCols = int(maNUpPage.maNupColEdt.GetValue()); int nRepeat = int(maNUpPage.maNupRepEdt.GetValue()); - PrinterListener::MultiPageSetup aMPS; + PrinterController::MultiPageSetup aMPS; aMPS.nRows = nRows; aMPS.nColumns = nCols; aMPS.nRepeat = nRepeat; @@ -1248,7 +1248,7 @@ void PrintDialog::updateNup() aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); - maPListener->setMultipage( aMPS ); + maPController->setMultipage( aMPS ); preparePreview( true, true ); } @@ -1260,7 +1260,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) String aNewPrinter( pBox->GetSelectEntry() ); maJobPage.maPrinters.SelectEntry( aNewPrinter ); // set new printer - maPListener->setPrinter( boost::shared_ptr( new Printer( aNewPrinter ) ) ); + maPController->setPrinter( boost::shared_ptr( new Printer( aNewPrinter ) ) ); // update text fields updatePrinterText(); } @@ -1286,7 +1286,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { if( pButton == &maJobPage.maSetupButton ) { - maPListener->getPrinter()->Setup( this ); + maPController->getPrinter()->Setup( this ); } checkControlDependencies(); if( pButton == &maNUpPage.maNupPortrait || pButton == &maNUpPage.maNupLandscape || pButton == &maNUpPage.maBorderCB ) @@ -1313,7 +1313,7 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) } else if( pEdit == &maJobPage.maCopyCountField ) { - maPListener->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), + maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), makeAny( sal_Int32(maJobPage.maCopyCountField.GetValue()) ) ); } return 0; @@ -1331,7 +1331,7 @@ PropertyValue* PrintDialog::getValueForWindow( Window* i_pWindow ) const std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow ); if( it != maControlToPropertyMap.end() ) { - pVal = maPListener->getValue( it->second ); + pVal = maPController->getValue( it->second ); DBG_ASSERT( pVal, "property value not found" ); } else From de669ed51a29363beeb6b73e777004718b988861 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 6 Jul 2009 12:02:13 +0000 Subject: [PATCH 116/283] #i92516# rename PrinterListener --- padmin/source/padialog.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/padmin/source/padialog.cxx b/padmin/source/padialog.cxx index 7c8ed6d39fe3..0417c784590a 100644 --- a/padmin/source/padialog.cxx +++ b/padmin/source/padialog.cxx @@ -361,13 +361,13 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) return aColor; } -class SpaPrinterListener : public vcl::PrinterListener +class SpaPrinterController : public vcl::PrinterController { public: - SpaPrinterListener( const boost::shared_ptr& i_pPrinter ) - : vcl::PrinterListener( i_pPrinter ) + SpaPrinterController( const boost::shared_ptr& i_pPrinter ) + : vcl::PrinterController( i_pPrinter ) {} - virtual ~SpaPrinterListener() + virtual ~SpaPrinterController() {} virtual int getPageCount() const { return 1; } @@ -376,7 +376,7 @@ public: virtual void jobFinished(); }; -Sequence< PropertyValue > SpaPrinterListener::getPageParameters( int ) const +Sequence< PropertyValue > SpaPrinterController::getPageParameters( int ) const { Sequence< PropertyValue > aRet( 1 ); @@ -391,7 +391,7 @@ Sequence< PropertyValue > SpaPrinterListener::getPageParameters( int ) const return aRet; } -void SpaPrinterListener::printPage( int ) const +void SpaPrinterController::printPage( int ) const { const double DELTA = 5.0; @@ -574,7 +574,7 @@ void SpaPrinterListener::printPage( int ) const #endif } -void SpaPrinterListener::jobFinished() +void SpaPrinterController::jobFinished() { String aInfoString( PaResId( RID_PA_TXT_TESTPAGE_PRINTED ) ); InfoBox aInfoBox( NULL, aInfoString ); @@ -599,11 +599,11 @@ void PADialog::PrintTestPage() return; } - boost::shared_ptr pListener( new SpaPrinterListener( pPrinter ) ); + boost::shared_ptr pController( new SpaPrinterController( pPrinter ) ); JobSetup aJobSetup( pPrinter->GetJobSetup() ); aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - Printer::PrintJob( pListener, aJobSetup ); + Printer::PrintJob( pController, aJobSetup ); } void PADialog::AddDevice() From c8aed19d39abefd12d03b3c3fcc9a948344c4e94 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 7 Jul 2009 08:24:51 +0000 Subject: [PATCH 117/283] PrinterController API change --- padmin/source/padialog.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/padmin/source/padialog.cxx b/padmin/source/padialog.cxx index 0417c784590a..d1d36fade717 100644 --- a/padmin/source/padialog.cxx +++ b/padmin/source/padialog.cxx @@ -373,7 +373,7 @@ public: virtual int getPageCount() const { return 1; } virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; virtual void printPage( int i_nPage ) const; - virtual void jobFinished(); + virtual void jobFinished( com::sun::star::view::PrintableState ); }; Sequence< PropertyValue > SpaPrinterController::getPageParameters( int ) const @@ -574,7 +574,7 @@ void SpaPrinterController::printPage( int ) const #endif } -void SpaPrinterController::jobFinished() +void SpaPrinterController::jobFinished( com::sun::star::view::PrintableState ) { String aInfoString( PaResId( RID_PA_TXT_TESTPAGE_PRINTED ) ); InfoBox aInfoBox( NULL, aInfoString ); From e83bd2a5f6cab65ececd3a22722a41bbbeaf43b7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 8 Jul 2009 16:27:08 +0000 Subject: [PATCH 118/283] #i95216# get a new enumerator that parsers a page range --- tools/inc/tools/multisel.hxx | 75 +++++++++++++ tools/source/memtools/multisel.cxx | 172 +++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index 46fd8947e21b..9e018d6b8479 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -35,6 +35,8 @@ #include #include +#include + //------------------------------------------------------------------ #ifdef _SV_MULTISEL_CXX @@ -112,4 +114,77 @@ public: const Range& GetRange( ULONG nRange ) const { return *(const Range*)aSels.GetObject(nRange); } }; +class TOOLS_DLLPUBLIC StringRangeEnumerator +{ + std::vector< sal_Int32 > maSequence; + sal_Int32 mnMin; + sal_Int32 mnMax; + sal_Int32 mnOffset; +public: + + typedef std::vector< sal_Int32 >::const_iterator Iterator; + + StringRangeEnumerator() {} + StringRangeEnumerator( const rtl::OUString& i_rInput, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1 ) : + mnMin( i_nMinNumber ), + mnMax( i_nMaxNumber ), + mnOffset( i_nLogicalOffset ) + { + getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset ); + } + + size_t size() const { return maSequence.size(); } + Iterator begin() const { return maSequence.begin(); } + Iterator end() const { return maSequence.end(); } + + sal_Int32 getMin() const { return mnMin; } + void setMin( sal_Int32 i_nMinValue ) { mnMin = i_nMinValue; } + sal_Int32 getMax() const { return mnMax; } + void setMax( sal_Int32 i_nMaxValue ) { mnMax = i_nMaxValue; } + sal_Int32 getLogicalOffset() const { return mnOffset; } + void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } + + void setRange( const rtl::OUString& i_rNewRange ) + { + maSequence.clear(); + getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset ); + } + + + /** + i_rPageRange: the string to be changed into a sequence of numbers + valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well + o_rPageVector: the output sequence of numbers + i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence + example: a user enters page numbers from 1 to n (since that is logical) + of course usable page numbers in code would start from 0 and end at n-1 + so the logical offset would be -1 + i_nMinNumber: the minimum allowed number, a negative number means no minimum check + i_nMaxNumber: the maximum allowed number, a negative number means no maximum check + + @returns: true if the input string was valid, o_rPageVector will contain the resulting sequence + false if the input string was invalid, o_rPageVector will be unchanged + + behavior: + - only non-negative sequence numbers are allowed + - only non-negative values in the input string are allowed + - the string "-3" will be either + * an error if no minimum is given + * or result in the sequence i_nMinNumber to 3 + - the string "3-" will be either + * an error if no maximum is given + * or result in the seqeuence 3 to i_nMaxNumber + - an empty string as input is valid and will result in an empty result vector + */ + static bool getRangesFromString( const rtl::OUString& i_rPageRange, + std::vector< sal_Int32 >& o_rPageVector, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1 + ); +}; + #endif // _SV_MULTISEL_HXX diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 6b32badc283e..a28b54c2347e 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -47,6 +47,8 @@ #define DBG(x) #endif +using namespace rtl; + //================================================================== #ifdef MI_DEBUG @@ -865,3 +867,173 @@ void MultiSelection::SetTotalRange( const Range& rTotRange ) bCurValid = FALSE; nCurIndex = 0; } + +// ----------------------------------------------------------------------- +// +// StringRangeEnumerator +// +// ----------------------------------------------------------------------- + +static bool lcl_getSingleValue( + const OUString &rText, + sal_Int32 &rVal, + sal_Int32 nLogicalOffset, + sal_Int32 nMinNumber, + sal_Int32 nMaxNumber + ) +{ + bool bRes = false; + const sal_Int32 nLen = rText.getLength(); + if (nLen > 0) + { + // verify that text consists of decimal number 0..9 only + bool bValidText = true; + const sal_Unicode *pText = rText.getStr(); + for (sal_Int32 i = 0; i < nLen && bValidText; ++i) + { + const sal_Unicode cChar = pText[i]; + if (cChar < '0' || cChar > '9') + bValidText = false; + } + + // get integer value if text is valid + if (bValidText) + { + sal_Int32 nTmpVal = rText.toInt32(); + nTmpVal += nLogicalOffset; + if( nTmpVal >= 0 && + (nMinNumber < 0 || nTmpVal >= nMinNumber) && + (nMaxNumber < 0 || nTmpVal <= nMaxNumber) + ) + { + bRes = true; + rVal = nTmpVal; + } + } + } + return bRes; +} + +static bool lcl_getSubRangeBounds( + const OUString &rSubRange, + sal_Int32 &rFirst, + sal_Int32 &rLast, + sal_Int32 nLogicalOffset, + sal_Int32 nMinNumber, + sal_Int32 nMaxNumber + ) +{ + bool bRes = false; + + // check for page range... + sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); + if (nPos > 0) + { + // page range found... + nPos = 0; + const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); + const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); + sal_Int32 nTmpFirst = -1; + sal_Int32 nTmpLast = -1; + if( aFirstPage.getLength() == 0 && nMinNumber >= 0 ) + nTmpFirst = nMinNumber; + else + lcl_getSingleValue( aFirstPage, nTmpFirst, nLogicalOffset, nMinNumber, nMaxNumber ); + if( aLastPage.getLength() == 0 && nMaxNumber >= 0 ) + nTmpLast = nMaxNumber; + else + lcl_getSingleValue( aLastPage, nTmpLast, nLogicalOffset, nMinNumber, nMaxNumber ); + if( nTmpFirst != -1 && nTmpLast != -1 ) + { + rFirst = nTmpFirst; + rLast = nTmpLast; + bRes = true; + } + } + else + { + // single page value... + sal_Int32 nVal = -1; + if (lcl_getSingleValue( rSubRange, nVal, nLogicalOffset, nMinNumber, nMaxNumber )) + { + rFirst = rLast = nVal; + bRes = true; + } + } + + return bRes; +} + +bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, + std::vector< sal_Int32 >& o_rPageVector, + sal_Int32 i_nMinNumber, + sal_Int32 i_nMaxNumber, + sal_Int32 i_nLogicalOffset + ) +{ + bool bRes = false; + + // - strip leading and trailing whitespaces + // - unify token delimeters to ';' + // - remove duplicate delimiters + OUString aRange( i_rPageRange.trim() ); + aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); + aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); + sal_Int32 nPos = -1; + rtl::OUString aDoubleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); + rtl::OUString aSingleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); + while ((nPos = aRange.indexOf( aDoubleSemi )) >= 0) + aRange = aRange.replaceAt( nPos, 2, aSingleSemi ); + + if (aRange.getLength() > 0) + { + std::vector< sal_Int32 > aTmpVector; + + // iterate over all sub ranges and add the respective pages to the + // vector while preserving the page order + bool bFailed = false; + nPos = 0; + do + { + const OUString aSubRange = aRange.getToken( 0, ';', nPos ); + sal_Int32 nFirst = -1, nLast = -1; + if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast, i_nLogicalOffset, i_nMinNumber, i_nMaxNumber ) + && nFirst >= 0 && nLast >= 0) + { + // add pages of sub range to vector + if (nFirst == nLast) + aTmpVector.push_back( nFirst ); + else if (nFirst < nLast) + { + for (sal_Int32 i = nFirst; i <= nLast; ++i) + aTmpVector.push_back( i ); + } + else if (nFirst > nLast) + { + for (sal_Int32 i = nFirst; i >= nLast; --i) + aTmpVector.push_back( i ); + } + else + OSL_ENSURE( 0, "unexpected case" ); + } + else + bFailed = true; + } + while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); + + if (!bFailed) + { + o_rPageVector = aTmpVector; + bRes = true; + } + } + else + { + // empty string ... + o_rPageVector.clear(); + bRes = true; + } + + return bRes; +} + From 3f6401a45f6c8b112752900e959384080e5a4522 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 9 Jul 2009 14:01:10 +0000 Subject: [PATCH 119/283] add: set of possible values --- tools/inc/tools/multisel.hxx | 14 +++++++++----- tools/source/memtools/multisel.cxx | 23 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index 9e018d6b8479..e30aff744897 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -36,6 +36,7 @@ #include #include +#include //------------------------------------------------------------------ @@ -128,12 +129,14 @@ public: StringRangeEnumerator( const rtl::OUString& i_rInput, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1 ) : + sal_Int32 i_nLogicalOffset = -1, + std::set< sal_Int32 >* i_pPossibleValues = NULL + ) : mnMin( i_nMinNumber ), mnMax( i_nMaxNumber ), mnOffset( i_nLogicalOffset ) { - getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset ); + getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); } size_t size() const { return maSequence.size(); } @@ -147,10 +150,10 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - void setRange( const rtl::OUString& i_rNewRange ) + void setRange( const rtl::OUString& i_rNewRange, std::set< sal_Int32 >* i_pPossibleValues = NULL ) { maSequence.clear(); - getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset ); + getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); } @@ -183,7 +186,8 @@ public: std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1 + sal_Int32 i_nLogicalOffset = -1, + std::set< sal_Int32 >* i_pPossibleValues = NULL ); }; diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index a28b54c2347e..642a2398ae91 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -964,11 +964,17 @@ static bool lcl_getSubRangeBounds( return bRes; } +inline bool checkValue( std::set< sal_Int32 >* i_pPossibleValues, sal_Int32 nVal ) +{ + return i_pPossibleValues ? (i_pPossibleValues->find( nVal ) != i_pPossibleValues->end()) : true; +} + bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, - sal_Int32 i_nLogicalOffset + sal_Int32 i_nLogicalOffset, + std::set< sal_Int32 >* i_pPossibleValues ) { bool bRes = false; @@ -1002,16 +1008,25 @@ bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, { // add pages of sub range to vector if (nFirst == nLast) - aTmpVector.push_back( nFirst ); + { + if( checkValue( i_pPossibleValues, nFirst ) ) + aTmpVector.push_back( nFirst ); + } else if (nFirst < nLast) { for (sal_Int32 i = nFirst; i <= nLast; ++i) - aTmpVector.push_back( i ); + { + if( checkValue( i_pPossibleValues, i ) ) + aTmpVector.push_back( i ); + } } else if (nFirst > nLast) { for (sal_Int32 i = nFirst; i >= nLast; --i) - aTmpVector.push_back( i ); + { + if( checkValue( i_pPossibleValues, i ) ) + aTmpVector.push_back( i ); + } } else OSL_ENSURE( 0, "unexpected case" ); From a2459a0cb43b28458b1fef79db93067bb7f3bfc4 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 10 Jul 2009 13:52:54 +0000 Subject: [PATCH 120/283] #i92516# new parser for ranges --- tools/inc/tools/multisel.hxx | 70 ++++-- tools/source/memtools/multisel.cxx | 373 ++++++++++++++++++----------- 2 files changed, 277 insertions(+), 166 deletions(-) diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index e30aff744897..e9b8b0f00177 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -117,31 +117,58 @@ public: class TOOLS_DLLPUBLIC StringRangeEnumerator { - std::vector< sal_Int32 > maSequence; - sal_Int32 mnMin; - sal_Int32 mnMax; - sal_Int32 mnOffset; + struct Range + { + sal_Int32 nFirst; + sal_Int32 nLast; + + Range() : nFirst( -1 ), nLast( -1 ) {} + Range( sal_Int32 i_nFirst, sal_Int32 i_nLast ) : nFirst( i_nFirst ), nLast( i_nLast ) {} + }; + std::vector< StringRangeEnumerator::Range > maSequence; + sal_Int32 mnCount; + sal_Int32 mnMin; + sal_Int32 mnMax; + sal_Int32 mnOffset; + + bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence ); + bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; public: + class TOOLS_DLLPUBLIC Iterator + { + const StringRangeEnumerator* pEnumerator; + const std::set< sal_Int32 >* pPossibleValues; + sal_Int32 nRangeIndex; + sal_Int32 nCurrent; - typedef std::vector< sal_Int32 >::const_iterator Iterator; + friend class StringRangeEnumerator; + Iterator( const StringRangeEnumerator* i_pEnum, + const std::set< sal_Int32 >* i_pPossibleValues, + sal_Int32 i_nRange, + sal_Int32 i_nCurrent ) + : pEnumerator( i_pEnum ), pPossibleValues( i_pPossibleValues ) + , nRangeIndex( i_nRange ), nCurrent( i_nCurrent ) {} + public: + Iterator() : pEnumerator( NULL ), pPossibleValues( NULL ), nRangeIndex( -1 ), nCurrent( -1 ) {} + Iterator& operator++(); + sal_Int32 operator*() const; + bool operator==(const Iterator&) const; + bool operator!=(const Iterator& i_rComp) const + { return ! (*this == i_rComp); } + }; - StringRangeEnumerator() {} + friend class StringRangeEnumerator::Iterator; + + StringRangeEnumerator() : mnCount( 0 ), mnMin( -1 ), mnMax( -1 ), mnOffset( -1 ) {} StringRangeEnumerator( const rtl::OUString& i_rInput, sal_Int32 i_nMinNumber = -1, sal_Int32 i_nMaxNumber = -1, - sal_Int32 i_nLogicalOffset = -1, - std::set< sal_Int32 >* i_pPossibleValues = NULL - ) : - mnMin( i_nMinNumber ), - mnMax( i_nMaxNumber ), - mnOffset( i_nLogicalOffset ) - { - getRangesFromString( i_rInput, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); - } + sal_Int32 i_nLogicalOffset = -1 + ); - size_t size() const { return maSequence.size(); } - Iterator begin() const { return maSequence.begin(); } - Iterator end() const { return maSequence.end(); } + size_t size() const { return size_t(mnCount); } + Iterator begin( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; + Iterator end( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; sal_Int32 getMin() const { return mnMin; } void setMin( sal_Int32 i_nMinValue ) { mnMin = i_nMinValue; } @@ -150,11 +177,8 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - void setRange( const rtl::OUString& i_rNewRange, std::set< sal_Int32 >* i_pPossibleValues = NULL ) - { - maSequence.clear(); - getRangesFromString( i_rNewRange, maSequence, mnMin, mnMax, mnOffset, i_pPossibleValues ); - } + bool setRange( const rtl::OUString& i_rNewRange ); + bool hasValue( sal_Int32 nValue, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; /** diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 642a2398ae91..db83f3b47866 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -41,6 +41,8 @@ #include #include +#include "rtl/ustrbuf.hxx" + #ifdef MI_DEBUG #define DBG(x) x #else @@ -873,100 +875,240 @@ void MultiSelection::SetTotalRange( const Range& rTotRange ) // StringRangeEnumerator // // ----------------------------------------------------------------------- - -static bool lcl_getSingleValue( - const OUString &rText, - sal_Int32 &rVal, - sal_Int32 nLogicalOffset, - sal_Int32 nMinNumber, - sal_Int32 nMaxNumber - ) +StringRangeEnumerator::StringRangeEnumerator( const rtl::OUString& i_rInput, + sal_Int32 i_nMinNumber, + sal_Int32 i_nMaxNumber, + sal_Int32 i_nLogicalOffset + ) + : mnCount( 0 ) + , mnMin( i_nMinNumber ) + , mnMax( i_nMaxNumber ) + , mnOffset( i_nLogicalOffset ) { - bool bRes = false; - const sal_Int32 nLen = rText.getLength(); - if (nLen > 0) - { - // verify that text consists of decimal number 0..9 only - bool bValidText = true; - const sal_Unicode *pText = rText.getStr(); - for (sal_Int32 i = 0; i < nLen && bValidText; ++i) - { - const sal_Unicode cChar = pText[i]; - if (cChar < '0' || cChar > '9') - bValidText = false; - } - - // get integer value if text is valid - if (bValidText) - { - sal_Int32 nTmpVal = rText.toInt32(); - nTmpVal += nLogicalOffset; - if( nTmpVal >= 0 && - (nMinNumber < 0 || nTmpVal >= nMinNumber) && - (nMaxNumber < 0 || nTmpVal <= nMaxNumber) - ) - { - bRes = true; - rVal = nTmpVal; - } - } - } - return bRes; + setRange( i_rInput ); } -static bool lcl_getSubRangeBounds( - const OUString &rSubRange, - sal_Int32 &rFirst, - sal_Int32 &rLast, - sal_Int32 nLogicalOffset, - sal_Int32 nMinNumber, - sal_Int32 nMaxNumber - ) +bool StringRangeEnumerator::checkValue( sal_Int32 i_nValue, const std::set< sal_Int32 >* i_pPossibleValues ) const { - bool bRes = false; + if( mnMin >= 0 && i_nValue < mnMin ) + return false; + if( mnMax >= 0 && i_nValue > mnMax ) + return false; + if( i_nValue < 0 ) + return false; + if( i_pPossibleValues && i_pPossibleValues->find( i_nValue ) == i_pPossibleValues->end() ) + return false; + return true; +} - // check for page range... - sal_Int32 nPos = rSubRange.indexOf( (sal_Unicode)'-' ); - if (nPos > 0) +bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence ) +{ + bool bSuccess = true; + if( bSequence ) { - // page range found... - nPos = 0; - const OUString aFirstPage( rSubRange.getToken( 0, '-', nPos ) ); - const OUString aLastPage( rSubRange.getToken( 0, '-', nPos ) ); - sal_Int32 nTmpFirst = -1; - sal_Int32 nTmpLast = -1; - if( aFirstPage.getLength() == 0 && nMinNumber >= 0 ) - nTmpFirst = nMinNumber; - else - lcl_getSingleValue( aFirstPage, nTmpFirst, nLogicalOffset, nMinNumber, nMaxNumber ); - if( aLastPage.getLength() == 0 && nMaxNumber >= 0 ) - nTmpLast = nMaxNumber; - else - lcl_getSingleValue( aLastPage, nTmpLast, nLogicalOffset, nMinNumber, nMaxNumber ); - if( nTmpFirst != -1 && nTmpLast != -1 ) + if( i_nFirst == -1 ) + i_nFirst = mnMin; + if( i_nLast == -1 ) + i_nLast = mnMax; + if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { - rFirst = nTmpFirst; - rLast = nTmpLast; - bRes = true; + maSequence.push_back( Range( i_nFirst, i_nLast ) ); + mnCount += std::abs( i_nLast - i_nFirst - 1 ); } + else + bSuccess = false; } else { - // single page value... - sal_Int32 nVal = -1; - if (lcl_getSingleValue( rSubRange, nVal, nLogicalOffset, nMinNumber, nMaxNumber )) + if( i_nFirst >= 0 ) { - rFirst = rLast = nVal; - bRes = true; + if( checkValue( i_nFirst ) ) + { + maSequence.push_back( Range( i_nFirst, i_nFirst ) ); + mnCount++; + } + else + bSuccess = false; + } + if( i_nLast >= 0 ) + { + if( checkValue( i_nLast ) ) + { + maSequence.push_back( Range( i_nLast, i_nLast ) ); + mnCount++; + } + else + bSuccess = false; } } - return bRes; + return bSuccess; } -inline bool checkValue( std::set< sal_Int32 >* i_pPossibleValues, sal_Int32 nVal ) +bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { - return i_pPossibleValues ? (i_pPossibleValues->find( nVal ) != i_pPossibleValues->end()) : true; + mnCount = 0; + maSequence.clear(); + + const sal_Unicode* pInput = i_rNewRange.getStr(); + rtl::OUStringBuffer aNumberBuf( 16 ); + sal_Int32 nLastNumber = -1, nNumber = -1; + bool bSequence = false; + bool bSuccess = true; + while( *pInput ) + { + while( *pInput >= sal_Unicode('0') && *pInput <= sal_Unicode('9') ) + aNumberBuf.append( *pInput++ ); + if( aNumberBuf.getLength() ) + { + if( nNumber != -1 ) + { + if( bSequence ) + { + if( ! insertRange( nLastNumber, nNumber, true ) ) + { + bSuccess = false; + break; + } + nLastNumber = -1; + } + else + { + if( ! insertRange( nNumber, nNumber, false ) ) + { + bSuccess = false; + break; + } + } + } + nNumber = aNumberBuf.makeStringAndClear().toInt32(); + nNumber += mnOffset; + } + bool bInsertRange = false; + if( *pInput == sal_Unicode('-') ) + { + nLastNumber = nNumber; + nNumber = -1; + bSequence = true; + } + else if( *pInput == ' ' ) + { + } + else if( *pInput == sal_Unicode(',') || *pInput == sal_Unicode(';') ) + bInsertRange = true; + else + { + bSuccess = false; + break; // parse error + } + + if( bInsertRange ) + { + if( ! insertRange( nLastNumber, nNumber, bSequence ) ) + { + bSuccess = false; + break; + } + nNumber = nLastNumber = -1; + bSequence = false; + } + if( *pInput ) + pInput++; + } + // insert last entries + insertRange( nLastNumber, nNumber, bSequence ); + + return bSuccess; +} + +bool StringRangeEnumerator::hasValue( sal_Int32 i_nValue, const std::set< sal_Int32 >* i_pPossibleValues ) const +{ + if( i_pPossibleValues && i_pPossibleValues->find( i_nValue ) == i_pPossibleValues->end() ) + return false; + size_t n = maSequence.size(); + for( size_t i= 0; i < n; ++i ) + { + const StringRangeEnumerator::Range rRange( maSequence[i] ); + if( rRange.nFirst < rRange.nLast ) + { + if( i_nValue >= rRange.nFirst && i_nValue <= rRange.nLast ) + return true; + } + else + { + if( i_nValue >= rRange.nLast && i_nValue <= rRange.nFirst ) + return true; + } + } + return false; +} + +StringRangeEnumerator::Iterator& StringRangeEnumerator::Iterator::operator++() +{ + if( nRangeIndex >= 0 && nCurrent >= 0 && pEnumerator ) + { + const StringRangeEnumerator::Range& rRange( pEnumerator->maSequence[nRangeIndex] ); + bool bRangeChange = false; + if( rRange.nLast < rRange.nFirst ) + { + // backward range + if( nCurrent > rRange.nLast ) + nCurrent--; + else + bRangeChange = true; + } + else + { + // forward range + if( nCurrent < rRange.nLast ) + nCurrent++; + else + bRangeChange = true; + } + if( bRangeChange ) + { + nRangeIndex++; + if( size_t(nRangeIndex) == pEnumerator->maSequence.size() ) + { + // reached the end + nRangeIndex = nCurrent = -1; + } + else + nCurrent = pEnumerator->maSequence[nRangeIndex].nFirst; + } + if( nRangeIndex != -1 && nCurrent != -1 ) + { + if( ! pEnumerator->checkValue( nCurrent, pPossibleValues ) ) + return ++(*this); + } + } + return *this; +} + +sal_Int32 StringRangeEnumerator::Iterator::operator*() const +{ + return nCurrent; +} + +bool StringRangeEnumerator::Iterator::operator==( const Iterator& i_rCompare ) const +{ + return i_rCompare.pEnumerator == pEnumerator && i_rCompare.nRangeIndex == nRangeIndex && i_rCompare.nCurrent == nCurrent; +} + +StringRangeEnumerator::Iterator StringRangeEnumerator::begin( const std::set< sal_Int32 >* i_pPossibleValues ) const +{ + StringRangeEnumerator::Iterator it( this, + i_pPossibleValues, + maSequence.empty() ? -1 : 0, + maSequence.empty() ? -1 : maSequence[0].nFirst ); + if( ! checkValue(*it, i_pPossibleValues ) ) + ++it; + return it; +} + +StringRangeEnumerator::Iterator StringRangeEnumerator::end( const std::set< sal_Int32 >* i_pPossibleValues ) const +{ + return StringRangeEnumerator::Iterator( this, i_pPossibleValues, -1, -1 ); } bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, @@ -977,76 +1119,21 @@ bool StringRangeEnumerator::getRangesFromString( const OUString& i_rPageRange, std::set< sal_Int32 >* i_pPossibleValues ) { - bool bRes = false; + StringRangeEnumerator aEnum; + aEnum.setMin( i_nMinNumber ); + aEnum.setMax( i_nMaxNumber ); + aEnum.setLogicalOffset( i_nLogicalOffset ); - // - strip leading and trailing whitespaces - // - unify token delimeters to ';' - // - remove duplicate delimiters - OUString aRange( i_rPageRange.trim() ); - aRange = aRange.replace( (sal_Unicode)' ', (sal_Unicode)';' ); - aRange = aRange.replace( (sal_Unicode)',', (sal_Unicode)';' ); - sal_Int32 nPos = -1; - rtl::OUString aDoubleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); - rtl::OUString aSingleSemi( RTL_CONSTASCII_USTRINGPARAM(";;") ); - while ((nPos = aRange.indexOf( aDoubleSemi )) >= 0) - aRange = aRange.replaceAt( nPos, 2, aSingleSemi ); - - if (aRange.getLength() > 0) + bool bRes = aEnum.setRange( i_rPageRange ); + if( bRes ) { - std::vector< sal_Int32 > aTmpVector; - - // iterate over all sub ranges and add the respective pages to the - // vector while preserving the page order - bool bFailed = false; - nPos = 0; - do - { - const OUString aSubRange = aRange.getToken( 0, ';', nPos ); - sal_Int32 nFirst = -1, nLast = -1; - if (lcl_getSubRangeBounds( aSubRange, nFirst, nLast, i_nLogicalOffset, i_nMinNumber, i_nMaxNumber ) - && nFirst >= 0 && nLast >= 0) - { - // add pages of sub range to vector - if (nFirst == nLast) - { - if( checkValue( i_pPossibleValues, nFirst ) ) - aTmpVector.push_back( nFirst ); - } - else if (nFirst < nLast) - { - for (sal_Int32 i = nFirst; i <= nLast; ++i) - { - if( checkValue( i_pPossibleValues, i ) ) - aTmpVector.push_back( i ); - } - } - else if (nFirst > nLast) - { - for (sal_Int32 i = nFirst; i >= nLast; --i) - { - if( checkValue( i_pPossibleValues, i ) ) - aTmpVector.push_back( i ); - } - } - else - OSL_ENSURE( 0, "unexpected case" ); - } - else - bFailed = true; - } - while (!bFailed && 0 <= nPos && nPos < aRange.getLength()); - - if (!bFailed) - { - o_rPageVector = aTmpVector; - bRes = true; - } - } - else - { - // empty string ... o_rPageVector.clear(); - bRes = true; + o_rPageVector.reserve( aEnum.size() ); + for( StringRangeEnumerator::Iterator it = aEnum.begin( i_pPossibleValues ); + it != aEnum.end( i_pPossibleValues ); ++it ) + { + o_rPageVector.push_back( *it ); + } } return bRes; From d6ad6af9da5d94ecad27aceedf9cb719858e5cfd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 10 Jul 2009 14:33:03 +0000 Subject: [PATCH 121/283] #i92516# fix count --- tools/source/memtools/multisel.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index db83f3b47866..b6f483312fa5 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -913,7 +913,9 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { maSequence.push_back( Range( i_nFirst, i_nLast ) ); - mnCount += std::abs( i_nLast - i_nFirst - 1 ); + sal_Int32 nNumber = i_nLast - i_nFirst; + nNumber = nNumber < 0 ? -nNumber : nNumber; + mnCount += nNumber + 1; } else bSuccess = false; From 92cb6e5eac5e9108ddfe37f70189a96f61c27c39 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 13 Jul 2009 14:32:36 +0000 Subject: [PATCH 122/283] fix number at end, change behaviour for empty string --- tools/inc/tools/multisel.hxx | 3 ++- tools/source/memtools/multisel.cxx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index e9b8b0f00177..bd2f7023bf8d 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -204,7 +204,8 @@ public: - the string "3-" will be either * an error if no maximum is given * or result in the seqeuence 3 to i_nMaxNumber - - an empty string as input is valid and will result in an empty result vector + - an empty string as input is valid and will result in the range [min,max] if given + or an empty vector, if not */ static bool getRangesFromString( const rtl::OUString& i_rPageRange, std::vector< sal_Int32 >& o_rPageVector, diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index b6f483312fa5..4f5ccbbabeae 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -952,6 +952,16 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) mnCount = 0; maSequence.clear(); + // we love special cases + if( i_rNewRange.getLength() == 0 ) + { + if( mnMin >= 0 && mnMax >= 0 ) + { + insertRange( mnMin, mnMax, mnMin != mnMax ); + } + return true; + } + const sal_Unicode* pInput = i_rNewRange.getStr(); rtl::OUStringBuffer aNumberBuf( 16 ); sal_Int32 nLastNumber = -1, nNumber = -1; @@ -998,8 +1008,9 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) } else if( *pInput == sal_Unicode(',') || *pInput == sal_Unicode(';') ) bInsertRange = true; - else + else if( *pInput ) { + bSuccess = false; break; // parse error } From cd572c7f63e41e68dc74a2ec6166f686911c0fa8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 14 Jul 2009 13:26:46 +0000 Subject: [PATCH 123/283] #i92516# make dialog maximizable, fix a paint issue --- vcl/source/src/print.src | 1 + vcl/source/window/printdlg.cxx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index a653798332a2..8a589c4b18ed 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -36,6 +36,7 @@ ModalDialog SV_DLG_PRINT Closeable = TRUE; Sizeable = TRUE; Moveable = TRUE; + Maxable = TRUE; SVLook = TRUE; Size = MAP_APPFONT( 350, 215 ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 5f8d08ec28a7..20b3b737f509 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1508,6 +1508,8 @@ void PrintDialog::Resize() // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); + // do an invalidate for the benefit of the grouping elements + Invalidate(); } // ----------------------------------------------------------------------------- From 2564edcb1c9779e345c5a418d8db251d8ba20f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Sch=C3=B6nheit?= Date: Tue, 14 Jul 2009 16:00:02 +0000 Subject: [PATCH 124/283] merging selected changes from tags/DEV300_m52 --- toolkit/inc/toolkit/helper/vclunohelper.hxx | 4 ++++ toolkit/source/helper/vclunohelper.cxx | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/toolkit/inc/toolkit/helper/vclunohelper.hxx b/toolkit/inc/toolkit/helper/vclunohelper.hxx index 68583f99b447..1c5d89a3cc64 100644 --- a/toolkit/inc/toolkit/helper/vclunohelper.hxx +++ b/toolkit/inc/toolkit/helper/vclunohelper.hxx @@ -135,11 +135,15 @@ public: static MapUnit /* MapModeUnit */ ConvertToMapModeUnit(sal_Int16 /* com.sun.star.util.MeasureUnit.* */ _nMeasureUnit) throw (::com::sun::star::lang::IllegalArgumentException); static sal_Int16 /* com.sun.star.util.MeasureUnit.* */ ConvertToMeasurementUnit(MapUnit /* MapModeUnit */ _nMapModeUnit) throw (::com::sun::star::lang::IllegalArgumentException); + static ::Size /* VCLSize */ ConvertToVCLSize(::com::sun::star::awt::Size const& _aSize); static ::com::sun::star::awt::Size ConvertToAWTSize(::Size /* VCLSize */ const& _aSize); + static ::Point /* VCLPoint */ ConvertToVCLPoint(::com::sun::star::awt::Point const& _aPoint); static ::com::sun::star::awt::Point ConvertToAWTPoint(::Point /* VCLPoint */ const& _aPoint); + static ::Rectangle ConvertToVCLRect( ::com::sun::star::awt::Rectangle const & _rRect ); + static ::com::sun::star::awt::Rectangle ConvertToAWTRect( ::Rectangle const & _rRect ); }; diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index d76b56a6a37d..029e520baca6 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -736,4 +736,12 @@ com::sun::star::awt::Point VCLUnoHelper::ConvertToAWTPoint(::Point /* VCLPoint * return aAWTPoint; } +::Rectangle VCLUnoHelper::ConvertToVCLRect( ::com::sun::star::awt::Rectangle const & _rRect ) +{ + return ::Rectangle( _rRect.X, _rRect.Y, _rRect.X + _rRect.Width - 1, _rRect.Y + _rRect.Height - 1 ); +} +::com::sun::star::awt::Rectangle VCLUnoHelper::ConvertToAWTRect( ::Rectangle const & _rRect ) +{ + return ::com::sun::star::awt::Rectangle( _rRect.Left(), _rRect.Top(), _rRect.GetWidth(), _rRect.GetHeight() ); +} From c2a9d1f422dee43b2dac04bed45fc9a201c62893 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 16 Jul 2009 08:50:32 +0000 Subject: [PATCH 125/283] #i92516# support wheel for preview forward/backward --- vcl/inc/vcl/prndlg.hxx | 5 ++++ vcl/source/window/printdlg.cxx | 51 ++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index e76d823b447a..b689ee66e058 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -73,6 +73,7 @@ namespace vcl virtual ~PrintPreviewWindow(); virtual void Paint( const Rectangle& rRect ); + virtual void Command( const CommandEvent& ); void setPreview( const GDIMetaFile& ); void setScale( double fScaleX, double fScaleY ); @@ -194,6 +195,7 @@ namespace vcl virtual void Resize(); virtual void Paint( const Rectangle& ); + virtual void Command( const CommandEvent& ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); @@ -212,6 +214,9 @@ namespace vcl bool isPrintToFile(); int getCopyCount(); bool isCollate(); + + void previewForward(); + void previewBackward(); }; class PrintProgressDialog : public ModelessDialog diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 20b3b737f509..20dfa502f61e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -97,6 +97,26 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect ) Pop(); } +void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) +{ + if( rEvt.GetCommand() == COMMAND_WHEEL ) + { + const CommandWheelData* pWheelData = rEvt.GetWheelData(); + PrintDialog* pDlg = dynamic_cast(GetParent()); + if( pDlg ) + { + if( pWheelData->GetDelta() > 0 ) + pDlg->previewForward(); + else if( pWheelData->GetDelta() < 0 ) + pDlg->previewBackward(); + /* + else + huh ? + */ + } + } +} + void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview ) { maMtf = i_rNewPreview; @@ -1276,11 +1296,11 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) } else if( pButton == &maForwardBtn ) { - maPageEdit.Up(); + previewForward(); } else if( pButton == &maBackwardBtn ) { - maPageEdit.Down(); + previewBackward(); } else { @@ -1456,6 +1476,22 @@ void PrintDialog::Paint( const Rectangle& i_rRect ) #endif } +void PrintDialog::Command( const CommandEvent& rEvt ) +{ + if( rEvt.GetCommand() == COMMAND_WHEEL ) + { + const CommandWheelData* pWheelData = rEvt.GetWheelData(); + if( pWheelData->GetDelta() > 0 ) + previewForward(); + else if( pWheelData->GetDelta() < 0 ) + previewBackward(); + /* + else + huh ? + */ + } +} + void PrintDialog::Resize() { Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); @@ -1512,6 +1548,16 @@ void PrintDialog::Resize() Invalidate(); } +void PrintDialog::previewForward() +{ + maPageEdit.Up(); +} + +void PrintDialog::previewBackward() +{ + maPageEdit.Down(); +} + // ----------------------------------------------------------------------------- // // PrintProgressDialog @@ -1635,3 +1681,4 @@ void PrintProgressDialog::Paint( const Rectangle& ) aDecoView.DrawFrame( aFrameRect ); } } + From 6f059173a5959880e366be1c9d43345a0e7aa031 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 16 Jul 2009 11:37:53 +0000 Subject: [PATCH 126/283] #i92516# collation support --- vcl/inc/vcl/jobdata.hxx | 2 ++ vcl/source/gdi/print.cxx | 3 ++- vcl/source/gdi/print3.cxx | 15 ++++++++++----- vcl/source/window/printdlg.cxx | 9 ++++++++- vcl/unx/headless/svpprn.cxx | 25 ++++++++++++++++++++++--- vcl/unx/headless/svpprn.hxx | 1 + vcl/unx/inc/salprn.h | 1 + vcl/unx/source/gdi/salprnpsp.cxx | 25 ++++++++++++++++++++++--- vcl/unx/source/printer/jobdata.cxx | 22 ++++++++++++++++++++++ 9 files changed, 90 insertions(+), 13 deletions(-) diff --git a/vcl/inc/vcl/jobdata.hxx b/vcl/inc/vcl/jobdata.hxx index 4451c566b5bf..d328f41f5b5b 100644 --- a/vcl/inc/vcl/jobdata.hxx +++ b/vcl/inc/vcl/jobdata.hxx @@ -74,6 +74,8 @@ struct JobData JobData( const JobData& rData ) { *this = rData; } + void setCollate( bool bCollate ); + // creates a new buffer using new // it is up to the user to delete it again bool getStreamBuffer( void*& pData, int& bytes ); diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index a3e33f236166..f03080a8a699 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1288,9 +1288,10 @@ XubString Printer::GetPaperBinName( USHORT nPaperBin ) const // ----------------------------------------------------------------------- -BOOL Printer::SetCopyCount( USHORT nCopy, BOOL /*bCollate*/ ) +BOOL Printer::SetCopyCount( USHORT nCopy, BOOL bCollate ) { mnCopyCount = nCopy; + mbCollateCopy = bCollate; return TRUE; } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 583ef206df7e..a868be758c41 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -468,11 +468,16 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrcreateProgressDialog(); int nPages = i_pController->getFilteredPageCount(); - for( int nPage = 0; nPage < nPages; nPage++ ) + int nRepeatCount = bUserCopy ? mnCopyCount : 1; + for( int nIteration = 0; nIteration < nRepeatCount; nIteration++ ) { - if( nPage == nPages-1 ) - i_pController->setLastPage( sal_True ); - i_pController->printFilteredPage( nPage ); + for( int nPage = 0; nPage < nPages; nPage++ ) + { + if( nPage == nPages-1 && nIteration == nRepeatCount-1 ) + i_pController->setLastPage( sal_True ); + i_pController->printFilteredPage( nPage ); + } + // FIXME: duplex ? } EndJob(); @@ -1090,7 +1095,7 @@ void PrinterController::pushPropertiesToPrinter() if( pVal ) pVal->Value >>= nCopyCount; sal_Bool bCollate = sal_False; - pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); + pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); if( pVal ) pVal->Value >>= bCollate; mpImplData->mpPrinter->SetCopyCount( static_cast(nCopyCount), bCollate ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 20dfa502f61e..8b3560b1f119 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -507,7 +507,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), + makeAny( sal_Bool(isCollate()) ) ); + } else { if( pButton == &maJobPage.maSetupButton ) @@ -1335,6 +1340,8 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), makeAny( sal_Int32(maJobPage.maCopyCountField.GetValue()) ) ); + maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), + makeAny( sal_Bool(isCollate()) ) ); } return 0; } diff --git a/vcl/unx/headless/svpprn.cxx b/vcl/unx/headless/svpprn.cxx index ca95acab6e78..9610cdd001c6 100644 --- a/vcl/unx/headless/svpprn.cxx +++ b/vcl/unx/headless/svpprn.cxx @@ -790,7 +790,18 @@ ULONG PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT case PRINTER_CAPABILITIES_COPIES: return 0xffff; case PRINTER_CAPABILITIES_COLLATECOPIES: - return 0; + { + // see if the PPD contains a value to set Collate to True + JobData aData; + JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + + const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ) : NULL; + const PPDValue* pVal = pKey ? pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "True" ) ) ) : NULL; + + // PPDs don't mention the number of possible collated copies. + // so let's guess as many as we want ? + return pVal ? 0xffff : 0; + } case PRINTER_CAPABILITIES_SETORIENTATION: return 1; case PRINTER_CAPABILITIES_SETDUPLEX: @@ -844,6 +855,7 @@ PspSalPrinter::PspSalPrinter( SalInfoPrinter* pInfoPrinter ) m_bSwallowFaxNo( false ), m_pGraphics( NULL ), m_nCopies( 1 ), + m_bCollate( false ), m_pInfoPrinter( pInfoPrinter ) { } @@ -869,7 +881,7 @@ BOOL PspSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL /*bCollate*/, + ULONG nCopies, BOOL bCollate, ImplJobSetup* pJobSetup ) { vcl_sal::PrinterUpdate::jobStarted(); @@ -878,13 +890,17 @@ BOOL PspSalPrinter::StartJob( m_bPdf = false; m_aFileName = pFileName ? *pFileName : String(); m_aTmpFile = String(); - m_nCopies = nCopies; + m_nCopies = nCopies; + m_bCollate = bCollate; JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); if( m_nCopies > 1 ) + { // in case user did not do anything (m_nCopies=1) // take the default from jobsetup m_aJobData.m_nCopies = m_nCopies; + m_aJobData.setCollate( bCollate ); + } // check wether this printer is configured as fax int nMode = 0; @@ -984,9 +1000,12 @@ SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, BOOL ) m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, m_bSwallowFaxNo, m_pInfoPrinter ); m_pGraphics->SetLayout( 0 ); if( m_nCopies > 1 ) + { // in case user did not do anything (m_nCopies=1) // take the default from jobsetup m_aJobData.m_nCopies = m_nCopies; + m_aJobData.setCollate( m_nCopies > 1 && m_bCollate ); + } m_aPrintJob.StartPage( m_aJobData ); m_aPrinterGfx.Init( m_aPrintJob ); diff --git a/vcl/unx/headless/svpprn.hxx b/vcl/unx/headless/svpprn.hxx index dd1c0cb1d88e..154273f6da88 100644 --- a/vcl/unx/headless/svpprn.hxx +++ b/vcl/unx/headless/svpprn.hxx @@ -79,6 +79,7 @@ public: psp::JobData m_aJobData; psp::PrinterGfx m_aPrinterGfx; ULONG m_nCopies; + bool m_bCollate; SalInfoPrinter* m_pInfoPrinter; PspSalPrinter( SalInfoPrinter* ); diff --git a/vcl/unx/inc/salprn.h b/vcl/unx/inc/salprn.h index 7d46d24ce94c..b1c92300ac49 100644 --- a/vcl/unx/inc/salprn.h +++ b/vcl/unx/inc/salprn.h @@ -79,6 +79,7 @@ public: psp::JobData m_aJobData; psp::PrinterGfx m_aPrinterGfx; ULONG m_nCopies; + bool m_bCollate; SalInfoPrinter* m_pInfoPrinter; PspSalPrinter( SalInfoPrinter* ); diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx index 0891f0f9fb05..0b05e5e8fa14 100644 --- a/vcl/unx/source/gdi/salprnpsp.cxx +++ b/vcl/unx/source/gdi/salprnpsp.cxx @@ -892,7 +892,18 @@ ULONG PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT case PRINTER_CAPABILITIES_COPIES: return 0xffff; case PRINTER_CAPABILITIES_COLLATECOPIES: - return 0; + { + // see if the PPD contains a value to set Collate to True + JobData aData; + JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + + const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ) : NULL; + const PPDValue* pVal = pKey ? pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "True" ) ) ) : NULL; + + // PPDs don't mention the number of possible collated copies. + // so let's guess as many as we want ? + return pVal ? 0xffff : 0; + } case PRINTER_CAPABILITIES_SETORIENTATION: return 1; case PRINTER_CAPABILITIES_SETDUPLEX: @@ -926,6 +937,7 @@ ULONG PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT m_bSwallowFaxNo( false ), m_pGraphics( NULL ), m_nCopies( 1 ), + m_bCollate( false ), m_pInfoPrinter( pInfoPrinter ) { } @@ -951,7 +963,7 @@ BOOL PspSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL /*bCollate*/, + ULONG nCopies, BOOL bCollate, ImplJobSetup* pJobSetup ) { vcl_sal::PrinterUpdate::jobStarted(); @@ -960,13 +972,17 @@ BOOL PspSalPrinter::StartJob( m_bPdf = false; m_aFileName = pFileName ? *pFileName : String(); m_aTmpFile = String(); - m_nCopies = nCopies; + m_nCopies = nCopies; + m_bCollate = bCollate; JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); if( m_nCopies > 1 ) + { // in case user did not do anything (m_nCopies=1) // take the default from jobsetup m_aJobData.m_nCopies = m_nCopies; + m_aJobData.setCollate( bCollate ); + } // check wether this printer is configured as fax int nMode = 0; @@ -1076,9 +1092,12 @@ SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, BOOL ) m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, m_bSwallowFaxNo, m_pInfoPrinter ); m_pGraphics->SetLayout( 0 ); if( m_nCopies > 1 ) + { // in case user did not do anything (m_nCopies=1) // take the default from jobsetup m_aJobData.m_nCopies = m_nCopies; + m_aJobData.setCollate( m_nCopies > 1 && m_bCollate ); + } m_aPrintJob.StartPage( m_aJobData ); m_aPrinterGfx.Init( m_aPrintJob ); diff --git a/vcl/unx/source/printer/jobdata.cxx b/vcl/unx/source/printer/jobdata.cxx index 51e171d578d9..0410b349c93b 100644 --- a/vcl/unx/source/printer/jobdata.cxx +++ b/vcl/unx/source/printer/jobdata.cxx @@ -64,6 +64,28 @@ JobData& JobData::operator=(const JobData& rRight) return *this; } +void JobData::setCollate( bool bCollate ) +{ + const PPDParser* pParser = m_aContext.getParser(); + if( pParser ) + { + const PPDKey* pKey = pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); + if( pKey ) + { + const PPDValue* pVal = NULL; + if( bCollate ) + pVal = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "True" ) ) ); + else + { + pVal = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "False" ) ) ); + if( ! pVal ) + pVal = pKey->getValue( String( RTL_CONSTASCII_USTRINGPARAM( "None" ) ) ); + } + m_aContext.setValue( pKey, pVal ); + } + } +} + bool JobData::getStreamBuffer( void*& pData, int& bytes ) { // consistency checks From d1c3c9440be742fe67ff2f0e7497e32b41ae4b8a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 16 Jul 2009 12:41:37 +0000 Subject: [PATCH 127/283] #i101973# add configuration setting for administrator to switch off collation UI --- vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/window/printdlg.cxx | 43 ++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index b689ee66e058..1208c8890b1d 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -136,6 +136,8 @@ namespace vcl Image maNoCollateImg; Image maNoCollateHCImg; + long mnCollateUIMode; + JobTabPage( Window*, const ResId& ); virtual ~JobTabPage(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 8b3560b1f119..acb87756758f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -291,17 +291,17 @@ void PrintDialog::NUpTabPage::readFromSettings() SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ) ); sal_Int32 nVal = aValue.toInt32(); maNupRowsEdt.SetValue( sal_Int64( nVal > 1 ? nVal : 1) ); - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ) ); nVal = aValue.toInt32(); maNupColEdt.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ) ); if( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ) maNupPortrait.Check(); @@ -314,13 +314,13 @@ void PrintDialog::NUpTabPage::storeToSettings() { #if 0 SettingsConfigItem* pItem = SettingsConfigItem::get(); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ), maNupRowsEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ), maNupColEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_NUpPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ), rtl::OUString::createFromAscii( maNupPortrait.IsChecked() ? "true" : "false" ) ); #endif @@ -340,6 +340,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maCollateHCImg( VclResId( SV_PRINT_COLLATE_HC_IMG ) ) , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) + , mnCollateUIMode( 0 ) { FreeResource(); maPrinters.SMHID2( "JobPage", "PrinterList" ); @@ -361,34 +362,46 @@ void PrintDialog::JobTabPage::readFromSettings() SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); #if 0 // do not actually make copy count persistent // the assumption is that this would lead to a lot of unwanted copies - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ) ); sal_Int32 nVal = aValue.toInt32(); maCopyCountField.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); #endif - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); - maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CollateBox" ) ) ); + if( aValue.equalsIgnoreAsciiCaseAscii( "alwaysoff" ) ) + { + mnCollateUIMode = 1; + maCollateBox.Check( FALSE ); + maCollateBox.Enable( FALSE ); + } + else + { + mnCollateUIMode = 0; + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); + maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); + } } void PrintDialog::JobTabPage::storeToSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), maCopyCountField.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog_JobPage" ) ), + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) ); } @@ -1096,7 +1109,7 @@ void PrintDialog::setupOptionalUI() void PrintDialog::checkControlDependencies() { if( maJobPage.maCopyCountField.GetValue() > 1 ) - maJobPage.maCollateBox.Enable( TRUE ); + maJobPage.maCollateBox.Enable( maJobPage.mnCollateUIMode == 0 ); else maJobPage.maCollateBox.Enable( FALSE ); From e1ede83e9d1d354bbf454fb76ae95084f681c1e6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 17 Jul 2009 00:30:17 +0000 Subject: [PATCH 128/283] add exceptions for stl --- tools/source/memtools/makefile.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/source/memtools/makefile.mk b/tools/source/memtools/makefile.mk index 037dadbf4a46..51d831ec0fed 100644 --- a/tools/source/memtools/makefile.mk +++ b/tools/source/memtools/makefile.mk @@ -47,6 +47,8 @@ SLOFILES= $(SLO)$/contnr.obj \ $(SLO)$/mempool.obj \ $(SLO)$/multisel.obj +EXCEPTIONSFILES= $(SLO)$/multisel.obj $(OBJ)$/multisel.obj + OBJFILES= $(OBJ)$/contnr.obj \ $(OBJ)$/table.obj \ $(OBJ)$/unqidx.obj \ From 7ad0431b233f8e37a45f60583a7e77e349ed171e Mon Sep 17 00:00:00 2001 From: Release Engineers Date: Tue, 21 Jul 2009 13:29:33 +0000 Subject: [PATCH 129/283] Create DEV300_m53 milestone tag from trunk@274201 From f3f952731fa35c7618d9c929ccb0773ad841fbf2 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 22 Jul 2009 17:16:34 +0000 Subject: [PATCH 130/283] #i92516# adapt to new UI spec --- vcl/inc/vcl/arrange.hxx | 6 +- vcl/inc/vcl/fixed.hxx | 1 + vcl/inc/vcl/print.hxx | 2 +- vcl/inc/vcl/prndlg.hxx | 51 ++++--- vcl/inc/vcl/svids.hrc | 13 +- vcl/source/control/fixed.cxx | 8 ++ vcl/source/control/lstbox.cxx | 1 + vcl/source/gdi/print3.cxx | 8 +- vcl/source/src/print.src | 86 ++++++++---- vcl/source/window/printdlg.cxx | 238 +++++++++++++++++++++++---------- 10 files changed, 295 insertions(+), 119 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index f350b9ae110d..2a9d83b7b769 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -200,16 +200,18 @@ namespace vcl class Spacer : public WindowArranger { WindowArranger::Element m_aElement; + Size m_aSize; public: - Spacer( WindowArranger* i_pParent = NULL, sal_Int32 i_nPrio = 20 ) + Spacer( WindowArranger* i_pParent = NULL, sal_Int32 i_nPrio = 20, const Size& i_rSize = Size( 0, 0 ) ) : WindowArranger( i_pParent ) , m_aElement( NULL, boost::shared_ptr(), i_nPrio ) + , m_aSize( i_rSize ) {} virtual ~Spacer() {} virtual Size getOptimalSize( WindowSizeType ) const - { return Size( 0, 0 ); } + { return m_aSize; } virtual void resize() {} virtual void setParentWindow( Window* ) {} virtual size_t countElements() const { return 1; } diff --git a/vcl/inc/vcl/fixed.hxx b/vcl/inc/vcl/fixed.hxx index ba576f280b83..39135826e38e 100644 --- a/vcl/inc/vcl/fixed.hxx +++ b/vcl/inc/vcl/fixed.hxx @@ -174,6 +174,7 @@ public: virtual void StateChanged( StateChangedType nType ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); virtual void UserDraw( const UserDrawEvent& rUDEvt ); + virtual Size GetOptimalSize(WindowSizeType eType) const; void SetImage( const Image& rImage ); const Image& GetImage() const { return maImage; } diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 339dee01d86d..1dc9a9958ad5 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -571,7 +571,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next // subgroup or group begins // setting bJobPage = true will make the subgroup appear on the first page of the print dialog - static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, bool i_bJobPage = false, bool i_bInternalOnly = false ); + static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, const rtl::OUString& i_rGroupHint = rtl::OUString(), bool i_bInternalOnly = false ); // create a bool option (usually a checkbox) static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 1208c8890b1d..5577592bc775 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -53,16 +53,6 @@ namespace vcl { class PrintDialog : public ModalDialog { - class PrinterListBox : public ListBox - { - public: - PrinterListBox( Window* i_pParent, const ResId& i_rId ) - : ListBox( i_pParent, i_rId ) - {} - virtual ~PrinterListBox() {} - virtual void RequestHelp( const HelpEvent& i_rHEvt ); - }; - class PrintPreviewWindow : public Window { GDIMetaFile maMtf; @@ -121,11 +111,19 @@ namespace vcl class JobTabPage : public TabPage { public: - PrinterListBox maPrinters; + FixedLine maPrinterFL; + ListBox maPrinters; + FixedText maStatusLabel; + FixedText maStatusTxt; + FixedText maLocationLabel; + FixedText maLocationTxt; + FixedText maCommentLabel; + FixedText maCommentTxt; + PushButton maSetupButton; - CheckBox maToFileBox; FixedLine maCopies; + FixedLine maCopySpacer; FixedText maCopyCount; NumericField maCopyCountField; CheckBox maCollateBox; @@ -138,11 +136,33 @@ namespace vcl long mnCollateUIMode; + vcl::RowOrColumn maLayout; + boost::shared_ptr mxPrintRange; + JobTabPage( Window*, const ResId& ); virtual ~JobTabPage(); void readFromSettings(); void storeToSettings(); + + virtual void Resize(); + + void setupLayout(); + }; + + class OutputOptPage : public TabPage + { + public: + FixedLine maOptionsLine; + CheckBox maToFileBox; + CheckBox maCollateSingleJobsBox; + CheckBox maReverseOrderBox; + + OutputOptPage( Window*, const ResId& ); + virtual ~OutputOptPage(); + + void readFromSettings(); + void storeToSettings(); }; OKButton maOKButton; @@ -156,6 +176,7 @@ namespace vcl TabControl maTabCtrl; NUpTabPage maNUpPage; JobTabPage maJobPage; + OutputOptPage maOptionsPage; FixedLine maButtonLine; @@ -176,10 +197,8 @@ namespace vcl Size maNupPortraitSize; Size maNupLandscapeSize; - rtl::OUString maCommentText; - rtl::OUString maStatusText; - rtl::OUString maLocationText; - rtl::OUString maTypeText; + rtl::OUString maPrintToFileText; + rtl::OUString maPrintText; vcl::RowOrColumn maPreviewCtrlRow; Rectangle maPreviewBackground; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index a774717e8078..b00f1742fced 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -114,8 +114,8 @@ #define SV_PRINT_PRT_NUP_PAGEREPEAT_EDT 23 #define SV_PRINT_TAB_JOB 2 -#define SV_PRINT_PRINTERS 1 -#define SV_PRINT_PRT_TOFILE 2 +#define SV_PRINT_PRINTERS_FL 1 +#define SV_PRINT_PRINTERS 2 #define SV_PRINT_PRT_SETUP 3 #define SV_PRINT_RANGE 4 #define SV_PRINT_ALL 5 @@ -133,6 +133,15 @@ #define SV_PRINT_COLLATE_HC_IMG 17 #define SV_PRINT_NOCOLLATE_HC_IMG 18 #define SV_PRINT_NOPAGES 19 +#define SV_PRINT_STATUS_TXT 20 +#define SV_PRINT_LOCATION_TXT 21 +#define SV_PRINT_COMMENT_TXT 22 + +#define SV_PRINT_TAB_OPT 3 +#define SV_PRINT_OPT_PRINT_FL 1 +#define SV_PRINT_OPT_TOFILE 2 +#define SV_PRINT_OPT_SINGLEJOBS 3 +#define SV_PRINT_OPT_REVERSE 4 #define SV_DLG_PRINT_PROGRESS 2049 #define SV_PRINT_PROGRESS_CANCEL 1 diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index 530e928532e1..0bf440e9c349 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -1094,6 +1094,14 @@ void FixedImage::Paint( const Rectangle& ) // ----------------------------------------------------------------------- +Size FixedImage::GetOptimalSize( WindowSizeType ) const +{ + const Image* pImage = GetSettings().GetStyleSettings().GetHighContrastMode() ? &maImageHC : &maImage; + return pImage->GetSizePixel(); +} + +// ----------------------------------------------------------------------- + void FixedImage::UserDraw( const UserDrawEvent& ) { } diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 05ddd5ce3bd2..37c289851898 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -108,6 +108,7 @@ void ListBox::ImplInitListBoxData() mnDDHeight = 0; mbDDAutoSize = TRUE; mnSaveValue = LISTBOX_ENTRY_NOTFOUND; + mnLineCount = 0; } // ----------------------------------------------------------------------- diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index a868be758c41..db77313db446 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1266,14 +1266,14 @@ Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle, con } Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, - bool i_bJobPage, bool i_bInternalOnly ) + const rtl::OUString& i_rGroupHint, bool i_bInternalOnly ) { PropertyValue aAddProps[2]; sal_Int32 nUsed = 0; - if( i_bJobPage ) + if( i_rGroupHint.getLength() ) { - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PutOnJobPage" ) ); - aAddProps[nUsed++].Value <<= sal_True; + aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GroupingHint" ) ); + aAddProps[nUsed++].Value <<= i_rGroupHint; } if( i_bInternalOnly ) { diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 8a589c4b18ed..3a3afd8c568a 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -101,23 +101,6 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "No pages"; }; - String SV_PRINT_PRT_TYPE - { - Text [en-US] = "Type: %s"; - }; - String SV_PRINT_PRT_STATUS - { - Text [en-US] = "Status: %s"; - }; - String SV_PRINT_PRT_LOCATION - { - Text [en-US] = "Location: %s"; - }; - String SV_PRINT_PRT_COMMENT - { - Text [en-US] = "Comment: %s"; - }; - TabPage SV_PRINT_TAB_NUP { Text [en-US] = "N-Up"; @@ -296,14 +279,38 @@ ModalDialog SV_DLG_PRINT TabPage SV_PRINT_TAB_JOB { - Text [en-US] = "Job Setup"; + Text [en-US] = "General"; Hide = TRUE; + FixedLine SV_PRINT_PRINTERS_FL + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 10 ); + Text [ en-US ] = "Prin~ter"; + }; ListBox SV_PRINT_PRINTERS { Pos = MAP_APPFONT( 5, 5 ); - Size = MAP_APPFONT( 100, 200 ); - DropDown = TRUE; + Size = MAP_APPFONT( 100, 80 ); + Border = TRUE; + }; + FixedText SV_PRINT_STATUS_TXT + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 10 ); + Text [en-US] = "Status:"; + }; + FixedText SV_PRINT_LOCATION_TXT + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 10 ); + Text [en-US] = "Location"; + }; + FixedText SV_PRINT_COMMENT_TXT + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 100, 10 ); + Text [en-US] = "Comment:"; }; PushButton SV_PRINT_PRT_SETUP { @@ -311,17 +318,11 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 50, 15 ); Text [en-US] = "Properties..."; }; - CheckBox SV_PRINT_PRT_TOFILE - { - Pos = MAP_APPFONT( 10, 20 ); - Size = MAP_APPFONT( 200, 12 ); - Text [en-US] = "Print to file"; - }; FixedLine SV_PRINT_COPIES { Pos = MAP_APPFONT( 5, 35 ); Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "Copies"; + Text [en-US] = "Print Range and Copies"; }; FixedText SV_PRINT_COPYCOUNT { @@ -371,6 +372,37 @@ ModalDialog SV_DLG_PRINT ImageBitmap = Bitmap { File = "ncollate_h.png" ; }; }; }; + + TabPage SV_PRINT_TAB_OPT + { + Text [en-US] = "Options"; + Hide = TRUE; + + FixedLine SV_PRINT_PRT_NUP + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 150, 10 ); + Text [en-US] = "Options"; + }; + CheckBox SV_PRINT_OPT_TOFILE + { + Pos = MAP_APPFONT( 10, 20 ); + Size = MAP_APPFONT( 200, 12 ); + Text [en-US] = "Print to ~file"; + }; + CheckBox SV_PRINT_OPT_SINGLEJOBS + { + Pos = MAP_APPFONT( 10, 35 ); + Size = MAP_APPFONT( 200, 12 ); + Text [en-US] = "~Create single print jobs for collated output"; + }; + CheckBox SV_PRINT_OPT_REVERSE + { + Pos = MAP_APPFONT( 10, 50 ); + Size = MAP_APPFONT( 200, 12 ); + Text [en-US] = "Print in ~reverse page order"; + }; + }; }; ModelessDialog SV_DLG_PRINT_PROGRESS diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index acb87756758f..a52f1a954315 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -60,14 +60,6 @@ using namespace com::sun::star::beans; #define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ) ) ) #define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) ) -void PrintDialog::PrinterListBox::RequestHelp( const HelpEvent& i_rHEvt ) -{ - if( i_rHEvt.GetMode() & HELPMODE_QUICK ) - Help::ShowBalloon( this, i_rHEvt.GetMousePosPixel(), GetHelpText() ); - else - ListBox::RequestHelp( i_rHEvt ); -} - PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ), mfScaleX( 1 ), @@ -328,10 +320,17 @@ void PrintDialog::NUpTabPage::storeToSettings() PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) - , maPrinters( this, VclResId( SV_PRINT_PRINTERS) ) + , maPrinterFL( this, VclResId( SV_PRINT_PRINTERS_FL ) ) + , maPrinters( this, VclResId( SV_PRINT_PRINTERS ) ) + , maStatusLabel( this, VclResId( SV_PRINT_STATUS_TXT ) ) + , maStatusTxt( this, 0 ) + , maLocationLabel( this, VclResId( SV_PRINT_LOCATION_TXT ) ) + , maLocationTxt( this, 0 ) + , maCommentLabel( this, VclResId( SV_PRINT_COMMENT_TXT ) ) + , maCommentTxt( this, 0 ) , maSetupButton( this, VclResId( SV_PRINT_PRT_SETUP ) ) - , maToFileBox( this, VclResId( SV_PRINT_PRT_TOFILE ) ) , maCopies( this, VclResId( SV_PRINT_COPIES ) ) + , maCopySpacer( this, WB_VERT ) , maCopyCount( this, VclResId( SV_PRINT_COPYCOUNT ) ) , maCopyCountField( this, VclResId( SV_PRINT_COPYCOUNT_FIELD ) ) , maCollateBox( this, VclResId( SV_PRINT_COLLATE ) ) @@ -343,29 +342,96 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , mnCollateUIMode( 0 ) { FreeResource(); + maPrinterFL.SMHID2( "JobPage", "Printer" ); maPrinters.SMHID2( "JobPage", "PrinterList" ); + maStatusLabel.SMHID2( "JobPage", "StatusLabel" ); + maStatusTxt.SMHID2( "JobPage", "StatusText" ); + maLocationLabel.SMHID2( "JobPage", "LocationLabel" ); + maLocationTxt.SMHID2( "JobPage", "LocationText" ); + maCommentLabel.SMHID2( "JobPage", "CommentLabel" ); + maCommentTxt.SMHID2( "JobPage", "CommentText" ); maSetupButton.SMHID2( "JobPage", "Setup" ); - maToFileBox.SMHID2( "JobPage", "ToFile" ); maCopies.SMHID2( "JobPage", "CopiesLine" ); + maCopySpacer.SMHID2( "JobPage", "CopySpacer" ); maCopyCount.SMHID2( "JobPage", "CopiesText" ); maCopyCountField.SMHID2( "JobPage", "Copies" ); maCollateBox.SMHID2( "JobPage", "Collate" ); maCollateImage.SMHID2( "JobPage", "CollateImage" ); + + maCopySpacer.Show(); + maStatusTxt.Show(); + maCommentTxt.Show(); + maLocationTxt.Show(); + + setupLayout(); } PrintDialog::JobTabPage::~JobTabPage() { } +void PrintDialog::JobTabPage::setupLayout() +{ + // HACK: this is not a dropdown box, but the dropdown line count + // sets the results of GetOptimalSize in a normal ListBox + maPrinters.SetDropDownLineCount( 4 ); + + Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + + maLayout.setParentWindow( this ); + maLayout.setOuterBorder( aBorder.Width() ); + + // add printer fixed line + maLayout.addWindow( &maPrinterFL ); + // add print LB + maLayout.addWindow( &maPrinters ); + + // create a row for stati and properties button + boost::shared_ptr< vcl::RowOrColumn > xStateRow( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xStateRow ); + boost::shared_ptr< vcl::RowOrColumn > xLabelCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) ); + xStateRow->addChild( xLabelCol ); + xLabelCol->addWindow( &maStatusLabel ); + xLabelCol->addWindow( &maLocationLabel ); + xLabelCol->addWindow( &maCommentLabel ); + + boost::shared_ptr< vcl::RowOrColumn > xStatusCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) ); + xStateRow->addChild( xStatusCol ); + xStatusCol->addWindow( &maStatusTxt ); + xStatusCol->addWindow( &maLocationTxt ); + xStatusCol->addWindow( &maCommentTxt ); + + xStateRow->addWindow( &maSetupButton ); + + // add print range and copies columns + maLayout.addWindow( &maCopies ); + boost::shared_ptr< vcl::RowOrColumn > xRangeRow( new vcl::RowOrColumn( &maLayout, false, aBorder.Width() ) ); + maLayout.addChild( xRangeRow ); + + // create print range and add to range row + mxPrintRange.reset( new vcl::RowOrColumn( xRangeRow.get() ) ); + xRangeRow->addChild( mxPrintRange ); + xRangeRow->addWindow( &maCopySpacer ); + + boost::shared_ptr< vcl::RowOrColumn > xCopyCollateCol( new vcl::RowOrColumn( xRangeRow.get() ) ); + xRangeRow->addChild( xCopyCollateCol ); + + // add copies row to copy/collate column + boost::shared_ptr< vcl::RowOrColumn > xCopiesRow( new vcl::RowOrColumn( xCopyCollateCol.get(), false, 0 ) ); + xCopyCollateCol->addChild( xCopiesRow ); + xCopiesRow->addWindow( &maCopyCount ); + xCopiesRow->addWindow( &maCopyCountField ); + boost::shared_ptr< vcl::RowOrColumn > xCollateRow( new vcl::RowOrColumn( xCopyCollateCol.get(), false, 0 ) ); + xCopyCollateCol->addChild( xCollateRow ); + xCollateRow->addWindow( &maCollateBox ); + xCollateRow->addWindow( &maCollateImage ); +} + void PrintDialog::JobTabPage::readFromSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); - maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); - #if 0 // do not actually make copy count persistent // the assumption is that this would lead to a lot of unwanted copies @@ -395,9 +461,6 @@ void PrintDialog::JobTabPage::readFromSettings() void PrintDialog::JobTabPage::storeToSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), - rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CopyCount" ) ), maCopyCountField.GetText() ); @@ -406,6 +469,47 @@ void PrintDialog::JobTabPage::storeToSettings() rtl::OUString::createFromAscii( maCollateBox.IsChecked() ? "true" : "false" ) ); } +void PrintDialog::JobTabPage::Resize() +{ + maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); +} + +PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rResId ) + : TabPage( i_pParent, i_rResId ) + , maOptionsLine( this, VclResId( SV_PRINT_OPT_PRINT_FL ) ) + , maToFileBox( this, VclResId( SV_PRINT_OPT_TOFILE ) ) + , maCollateSingleJobsBox( this, VclResId( SV_PRINT_OPT_SINGLEJOBS ) ) + , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) +{ + maOptionsLine.SMHID2( "OptPage", "Options" ); + maToFileBox.SMHID2( "OptPage", "ToFile" ); + maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" ); + maReverseOrderBox.SMHID2( "OptPage", "Reverse" ); +} + +PrintDialog::OutputOptPage::~OutputOptPage() +{ +} + +void PrintDialog::OutputOptPage::readFromSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + rtl::OUString aValue; + + aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); + maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); +} + +void PrintDialog::OutputOptPage::storeToSettings() +{ + SettingsConfigItem* pItem = SettingsConfigItem::get(); + pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ), + rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); +} + + PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rController ) : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) , maOKButton( this, VclResId( SV_PRINT_OK ) ) @@ -418,15 +522,12 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr aDynamicColumns; vcl::RowOrColumn* pCurColumn = 0; - aPrintRangeRow.setParentWindow( &maJobPage ); - aPrintRangeRow.setOuterBorder( nBorderWidth ); - Window* pCurParent = 0, *pDynamicPageParent = 0; USHORT nOptPageId = 9, nCurSubGroup = 0; bool bOnJobPage = false; @@ -687,7 +790,7 @@ void PrintDialog::setupOptionalUI() Sequence< rtl::OUString > aHelpTexts; sal_Int64 nMinValue = 0, nMaxValue = 0; sal_Int32 nCurHelpText = 0; - sal_Bool bOnJobPageValue = sal_False; + rtl::OUString aGroupingHint; rtl::OUString aDependsOnName; sal_Int32 nDependsOnValue = 0; sal_Bool bUseDependencyRow = sal_False; @@ -719,9 +822,9 @@ void PrintDialog::setupOptionalUI() rEntry.Value >>= bValue; bEnabled = bValue; } - else if( rEntry.Name.equalsAscii( "PutOnJobPage" ) ) + else if( rEntry.Name.equalsAscii( "GroupingHint" ) ) { - rEntry.Value >>= bOnJobPageValue; + rEntry.Value >>= aGroupingHint; } else if( rEntry.Name.equalsAscii( "DependsOnName" ) ) { @@ -758,7 +861,7 @@ void PrintDialog::setupOptionalUI() } if( aCtrlType.equalsAscii( "Group" ) || - ( ! pCurParent && ! (bOnJobPage || bOnJobPageValue) ) ) + ( ! pCurParent && ! (bOnJobPage || aGroupingHint.getLength() ) ) ) { // add new tab page TabPage* pNewGroup = new TabPage( &maTabCtrl ); @@ -781,13 +884,13 @@ void PrintDialog::setupOptionalUI() pCurColumn->setParentWindow( pNewGroup ); pCurColumn->setOuterBorder( nBorderWidth ); } - else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || bOnJobPageValue) ) + else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || aGroupingHint.getLength() ) ) { // change to job page or back if necessary - if( (bOnJobPage && ! bOnJobPageValue) || - (! bOnJobPage && bOnJobPageValue) ) + if( (bOnJobPage && ! aGroupingHint.getLength() ) || + (! bOnJobPage && aGroupingHint.getLength() ) ) { - bOnJobPage = bOnJobPageValue; + bOnJobPage = (aGroupingHint.getLength() != 0); if( bOnJobPage ) { pDynamicPageParent = pCurParent; // save current parent @@ -801,27 +904,31 @@ void PrintDialog::setupOptionalUI() if( bOnJobPage ) { - // create a new column in the PrintRange row - vcl::RowOrColumn* pNewColumn = new vcl::RowOrColumn( &aPrintRangeRow, true, nBorderWidth ); - aPrintRangeRow.addChild( pNewColumn ); - pCurColumn = pNewColumn; + if( aGroupingHint.equalsAscii( "PrintRange" ) ) + pCurColumn = maJobPage.mxPrintRange.get(); + else + pCurColumn = &maJobPage.maLayout; } else pCurColumn = aDynamicColumns.back(); // create group FixedLine - FixedLine* pNewSub = new FixedLine( pCurParent ); - maControls.push_front( pNewSub ); - pNewSub->SetText( aText ); - pNewSub->Show(); + if( ! aGroupingHint.equalsAscii( "PrintRange" ) || + ! pCurColumn->countElements() == 0 + ) + { + FixedLine* pNewSub = new FixedLine( pCurParent ); + maControls.push_front( pNewSub ); + pNewSub->SetText( aText ); + pNewSub->Show(); - // set help id - setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); - // set help text - setHelpText( pNewSub, aHelpTexts, 0 ); - - // add group to current column - pCurColumn->addWindow( pNewSub ); + // set help id + setSmartId( pNewSub, "FixedLine", sal_Int32( nCurSubGroup++ ) ); + // set help text + setHelpText( pNewSub, aHelpTexts, 0 ); + // add group to current column + pCurColumn->addWindow( pNewSub ); + } } else { @@ -1055,11 +1162,7 @@ void PrintDialog::setupOptionalUI() } // calculate job page - long nJobPageCurY = maJobPage.maCollateImage.GetPosPixel().Y(); - nJobPageCurY += maJobPage.maCollateImage.GetSizePixel().Height(); - - Size aMaxSize = aPrintRangeRow.getOptimalSize( WINDOWSIZE_PREFERRED ); - aMaxSize.Height() += nJobPageCurY; + Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); Size aMaxPageSize; for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); @@ -1095,8 +1198,6 @@ void PrintDialog::setupOptionalUI() // and finally arrange controls aTabSize = maTabCtrl.GetTabPageSizePixel(); - aPrintRangeRow.setManagedArea( Rectangle( Point( 0, nJobPageCurY ), - Size( aTabSize.Width(), aTabSize.Height() - nJobPageCurY ) ) ); for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); it != aDynamicColumns.end(); ++it ) { @@ -1184,14 +1285,16 @@ void PrintDialog::updatePrinterText() const QueueInfo* pInfo = Printer::GetQueueInfo( maJobPage.maPrinters.GetSelectEntry(), true ); if( pInfo ) { - rtl::OUStringBuffer aBuf( 256 ); - aBuf.append( searchAndReplace( maTypeText, "%s", 2, pInfo->GetDriver() ) ); - aBuf.append( sal_Unicode( '\n' ) ); - aBuf.append( searchAndReplace( maLocationText, "%s", 2, pInfo->GetLocation() ) ); - aBuf.append( sal_Unicode( '\n' ) ); - aBuf.append( searchAndReplace( maCommentText, "%s", 2, pInfo->GetComment() ) ); - aBuf.append( sal_Unicode( '\n' ) ); - maJobPage.maPrinters.SetHelpText( aBuf.makeStringAndClear() ); + maJobPage.maLocationTxt.SetText( pInfo->GetLocation() ); + maJobPage.maCommentTxt.SetText( pInfo->GetComment() ); + // FIXME: status text + maJobPage.maStatusTxt.SetText( String() ); + } + else + { + maJobPage.maLocationTxt.SetText( String() ); + maJobPage.maCommentTxt.SetText( String() ); + maJobPage.maStatusTxt.SetText( String() ); } } @@ -1319,6 +1422,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), makeAny( sal_Bool(isCollate()) ) ); + checkControlDependencies(); } else { From d3e83bb08919ad8f87a03069f0e12e9ccf6c8806 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 23 Jul 2009 17:22:34 +0000 Subject: [PATCH 131/283] #i92516# adapt new UX spec --- vcl/inc/vcl/prndlg.hxx | 6 +++ vcl/source/control/lstbox.cxx | 15 +++++++ vcl/source/gdi/print3.cxx | 2 +- vcl/source/src/print.src | 2 +- vcl/source/window/arrange.cxx | 2 +- vcl/source/window/printdlg.cxx | 73 ++++++++++++++++++++++++++-------- 6 files changed, 81 insertions(+), 19 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 5577592bc775..2569000dd9f0 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -158,11 +158,17 @@ namespace vcl CheckBox maCollateSingleJobsBox; CheckBox maReverseOrderBox; + vcl::RowOrColumn maLayout; + OutputOptPage( Window*, const ResId& ); virtual ~OutputOptPage(); void readFromSettings(); void storeToSettings(); + + virtual void Resize(); + + void setupLayout(); }; OKButton maOKButton; diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 37c289851898..476c5d8f4b7f 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1286,6 +1286,21 @@ Size ListBox::CalcMinimumSize() const } aSz = CalcWindowSize( aSz ); + + if ( IsDropDownBox() ) // check minimum height of dropdown box + { + ImplControlValue aControlValue; + Rectangle aRect( Point( 0, 0 ), aSz ); + Region aContent, aBound; + if( const_cast(this)->GetNativeControlRegion( + CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) ) + { + Rectangle aBoundRect( aBound.GetBoundRect() ); + if( aBoundRect.GetHeight() > aSz.Height() ) + aSz.Height() = aBoundRect.GetHeight(); + } + } + return aSz; } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index db77313db446..53326cb3efbd 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1032,7 +1032,7 @@ bool PrinterController::isUIOptionEnabled( const rtl::OUString& i_rProperty ) co sal_Bool bDepVal = sal_False; if( pVal->Value >>= nDepVal ) { - bEnabled = (nDepVal == it->second.mnDependsOnEntry); + bEnabled = (nDepVal == it->second.mnDependsOnEntry) || (it->second.mnDependsOnEntry == -1); } else if( pVal->Value >>= bDepVal ) { diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 3a3afd8c568a..1e09b7c9fcc1 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -103,7 +103,7 @@ ModalDialog SV_DLG_PRINT TabPage SV_PRINT_TAB_NUP { - Text [en-US] = "N-Up"; + Text [en-US] = "Page Layout"; Hide = TRUE; FixedLine SV_PRINT_PRT_NUP diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 917b04fcc855..665c83e5f2d5 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -353,7 +353,7 @@ void Indenter::resize() aPt.X() += m_nOuterBorder + m_nIndent; aPt.Y() += m_nOuterBorder; Size aSz( m_aManagedArea.GetSize() ); - aSz.Width() -= 2*m_nOuterBorder - m_nIndent; + aSz.Width() -= 2*m_nOuterBorder + m_nIndent; aSz.Height() -= 2*m_nOuterBorder; if( m_aElement.m_pElement ) m_aElement.m_pElement->SetPosSizePixel( aPt, aSz ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a52f1a954315..09d2532fa812 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -485,12 +485,31 @@ PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rRe maToFileBox.SMHID2( "OptPage", "ToFile" ); maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" ); maReverseOrderBox.SMHID2( "OptPage", "Reverse" ); + + setupLayout(); } PrintDialog::OutputOptPage::~OutputOptPage() { } +void PrintDialog::OutputOptPage::setupLayout() +{ + Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + + maLayout.setParentWindow( this ); + maLayout.setOuterBorder( aBorder.Width() ); + + maLayout.addWindow( &maOptionsLine ); + boost::shared_ptr xIndent( new vcl::Indenter( &maLayout, aBorder.Width() ) ); + maLayout.addChild( xIndent ); + boost::shared_ptr xCol( new vcl::RowOrColumn( xIndent.get(), aBorder.Height() ) ); + xIndent->setChild( xCol ); + xCol->addWindow( &maToFileBox ); + xCol->addWindow( &maCollateSingleJobsBox ); + xCol->addWindow( &maReverseOrderBox ); +} + void PrintDialog::OutputOptPage::readFromSettings() { SettingsConfigItem* pItem = SettingsConfigItem::get(); @@ -509,6 +528,11 @@ void PrintDialog::OutputOptPage::storeToSettings() rtl::OUString::createFromAscii( maToFileBox.IsChecked() ? "true" : "false" ) ); } +void PrintDialog::OutputOptPage::Resize() +{ + maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); +} + PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_rController ) : ModalDialog( i_pParent, VclResId( SV_DLG_PRINT ) ) @@ -542,11 +566,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr& i_r void PrintDialog::setupOptionalUI() { - const long nBorderWidth = maJobPage.maCopies.GetPosPixel().X(); + Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); std::vector aDynamicColumns; vcl::RowOrColumn* pCurColumn = 0; Window* pCurParent = 0, *pDynamicPageParent = 0; USHORT nOptPageId = 9, nCurSubGroup = 0; - bool bOnJobPage = false; + bool bOnStaticPage = false; std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap; @@ -861,12 +885,12 @@ void PrintDialog::setupOptionalUI() } if( aCtrlType.equalsAscii( "Group" ) || - ( ! pCurParent && ! (bOnJobPage || aGroupingHint.getLength() ) ) ) + ( ! pCurParent && ! (bOnStaticPage || aGroupingHint.getLength() ) ) ) { // add new tab page TabPage* pNewGroup = new TabPage( &maTabCtrl ); maControls.push_front( pNewGroup ); - pCurParent = pNewGroup; + pDynamicPageParent = pCurParent = pNewGroup; pNewGroup->SetText( aText ); maTabCtrl.InsertPage( ++nOptPageId, aText ); maTabCtrl.SetTabPage( nOptPageId, pNewGroup ); @@ -879,22 +903,21 @@ void PrintDialog::setupOptionalUI() // reset subgroup counter nCurSubGroup = 0; - aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, nBorderWidth ) ); + aDynamicColumns.push_back( new vcl::RowOrColumn( NULL, true, aBorder.Width() ) ); pCurColumn = aDynamicColumns.back(); pCurColumn->setParentWindow( pNewGroup ); - pCurColumn->setOuterBorder( nBorderWidth ); + pCurColumn->setOuterBorder( aBorder.Width() ); } else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || aGroupingHint.getLength() ) ) { // change to job page or back if necessary - if( (bOnJobPage && ! aGroupingHint.getLength() ) || - (! bOnJobPage && aGroupingHint.getLength() ) ) + if( (bOnStaticPage && ! aGroupingHint.getLength() ) || + (! bOnStaticPage && aGroupingHint.getLength() ) ) { - bOnJobPage = (aGroupingHint.getLength() != 0); - if( bOnJobPage ) + bOnStaticPage = (aGroupingHint.getLength() != 0); + if( bOnStaticPage ) { pDynamicPageParent = pCurParent; // save current parent - pCurParent = &maJobPage; // set job page as current parent } else { @@ -902,12 +925,23 @@ void PrintDialog::setupOptionalUI() } } - if( bOnJobPage ) + if( bOnStaticPage ) { if( aGroupingHint.equalsAscii( "PrintRange" ) ) + { pCurColumn = maJobPage.mxPrintRange.get(); + pCurParent = &maJobPage; // set job page as current parent + } + else if( aGroupingHint.equalsAscii( "OptionsPage" ) ) + { + pCurColumn = &maOptionsPage.maLayout; + pCurParent = &maOptionsPage; // set options page as current parent + } else + { pCurColumn = &maJobPage.maLayout; + pCurParent = &maJobPage; // set job page as current parent + } } else pCurColumn = aDynamicColumns.back(); @@ -929,6 +963,13 @@ void PrintDialog::setupOptionalUI() // add group to current column pCurColumn->addWindow( pNewSub ); } + + // add an indent to the current column + vcl::Indenter* pIndent = new vcl::Indenter( pCurColumn, aBorder.Width() ); + pCurColumn->addChild( pIndent ); + // and create a column inside the indent + pCurColumn = new vcl::RowOrColumn( pIndent ); + pIndent->setChild( pCurColumn ); } else { From 6d16b13150863dc7506506863e73e28d5ff569ad Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 24 Jul 2009 13:15:45 +0000 Subject: [PATCH 132/283] #i92516# adapt new print UI spec --- vcl/inc/vcl/arrange.hxx | 103 +++++++++++------ vcl/inc/vcl/prndlg.hxx | 15 ++- vcl/inc/vcl/svids.hrc | 1 + vcl/inc/vcl/tabctrl.hxx | 3 + vcl/source/control/tabctrl.cxx | 23 ++++ vcl/source/src/print.src | 6 +- vcl/source/window/arrange.cxx | 144 ++++++++++++++---------- vcl/source/window/printdlg.cxx | 198 +++++++++++++++++++-------------- 8 files changed, 311 insertions(+), 182 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 2a9d83b7b769..febbe69491a2 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -53,12 +53,13 @@ namespace vcl class WindowArranger { - protected: + protected: struct Element { Window* m_pElement; boost::shared_ptr m_pChild; sal_Int32 m_nExpandPriority; + Size m_aMinSize; Element() : m_pElement( NULL ) @@ -78,6 +79,7 @@ namespace vcl void deleteChild() { m_pChild.reset(); } sal_Int32 getExpandPriority() const; + Size getOptimalSize( WindowSizeType ) const; }; Window* m_pParentWindow; @@ -85,7 +87,12 @@ namespace vcl Rectangle m_aManagedArea; long m_nOuterBorder; - public: + virtual Element* getElement( size_t i_nIndex ) = NULL; + const Element* getConstElement( size_t i_nIndex ) const + { return const_cast(this)->getElement( i_nIndex ); } + + + public: WindowArranger( WindowArranger* i_pParent = NULL ) : m_pParentWindow( i_pParent ? i_pParent->m_pParentWindow : NULL ) , m_pParentArranger( i_pParent ) @@ -106,9 +113,39 @@ namespace vcl virtual void setParent( WindowArranger* ); virtual size_t countElements() const = 0; - virtual boost::shared_ptr getChild( size_t i_nIndex ) const = 0; - virtual Window* getWindow( size_t i_nIndex ) const = 0; - virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const = 0; + boost::shared_ptr getChild( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->m_pChild : boost::shared_ptr(); + } + Window* getWindow( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->m_pElement : NULL; + } + + sal_Int32 getExpandPriority( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->getExpandPriority() : 0; + } + + Size getMinimumSize( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->m_aMinSize : Size(); + } + + bool setMinimumSize( size_t i_nIndex, const Size& i_rMinSize ) + { + Element* pEle = getElement( i_nIndex ); + if( pEle ) + { + pEle->m_aMinSize = i_rMinSize; + resize(); + } + return pEle != NULL; + } void setManagedArea( const Rectangle& i_rArea ) { @@ -132,7 +169,12 @@ namespace vcl std::vector< WindowArranger::Element > m_aElements; void distributeRowWidth( std::vector< Size >& io_rSizes, long i_nUsedWidth, long i_nExtraWidth ); - public: + void distributeColumnHeight( std::vector< Size >& io_rSizes, long i_nUsedHeight, long i_nExtraHeight ); + protected: + virtual Element* getElement( size_t i_nIndex ) + { return i_nIndex < m_aElements.size() ? &m_aElements[ i_nIndex ] : 0; } + + public: RowOrColumn( WindowArranger* i_pParent = NULL, bool bColumn = true, long i_nBorderWidth = 5 ) : WindowArranger( i_pParent ) @@ -146,19 +188,16 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return m_aElements.size(); } - virtual boost::shared_ptr getChild( size_t i_nIndex ) const; - virtual Window* getWindow( size_t i_nIndex ) const; - virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const; // add a managed window at the given index // an index smaller than zero means add the window at the end - void addWindow( Window*, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ); + size_t addWindow( Window*, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ); void remove( Window* ); - void addChild( boost::shared_ptr const &, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ); + size_t addChild( boost::shared_ptr const &, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ); // convenience: use for addChild( new WindowArranger( ... ) ) constructs - void addChild( WindowArranger* i_pNewChild, sal_Int32 i_nExpandPrio = 0, sal_Int32 i_nIndex = -1 ) - { addChild( boost::shared_ptr( i_pNewChild ), i_nExpandPrio, i_nIndex ); } + size_t addChild( WindowArranger* i_pNewChild, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ) + { return addChild( boost::shared_ptr( i_pNewChild ), i_nExpandPrio, i_nIndex ); } void remove( boost::shared_ptr const & ); }; @@ -167,7 +206,11 @@ namespace vcl long m_nIndent; WindowArranger::Element m_aElement; - public: + protected: + virtual Element* getElement( size_t i_nIndex ) + { return i_nIndex == 0 ? &m_aElement : NULL; } + + public: Indenter( WindowArranger* i_pParent = NULL, long i_nIndent = 15 ) : WindowArranger( i_pParent ) , m_nIndent( i_nIndent ) @@ -179,10 +222,6 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } - virtual boost::shared_ptr getChild( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pChild : boost::shared_ptr(); } - virtual Window* getWindow( size_t i_nIndex ) const { return (i_nIndex == 0) ? m_aElement.m_pElement : NULL; } - virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const - { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } void setIndent( long i_nIndent ) { @@ -201,7 +240,12 @@ namespace vcl { WindowArranger::Element m_aElement; Size m_aSize; - public: + + protected: + virtual Element* getElement( size_t i_nIndex ) + { return i_nIndex == 0 ? &m_aElement : NULL; } + + public: Spacer( WindowArranger* i_pParent = NULL, sal_Int32 i_nPrio = 20, const Size& i_rSize = Size( 0, 0 ) ) : WindowArranger( i_pParent ) , m_aElement( NULL, boost::shared_ptr(), i_nPrio ) @@ -215,10 +259,6 @@ namespace vcl virtual void resize() {} virtual void setParentWindow( Window* ) {} virtual size_t countElements() const { return 1; } - virtual boost::shared_ptr getChild( size_t ) const { return boost::shared_ptr(); } - virtual Window* getWindow( size_t ) const { return NULL; } - virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const - { return (i_nIndex == 0) ? m_aElement.getExpandPriority() : 0; } }; class MatrixArranger : public WindowArranger @@ -256,7 +296,11 @@ namespace vcl { return static_cast< sal_uInt64 >(i_nX) | (static_cast< sal_uInt64>(i_nY) << 32 ); } Size getOptimalSize( WindowSizeType, std::vector& o_rColumnWidths, std::vector& o_rRowHeights ) const; - public: + protected: + virtual Element* getElement( size_t i_nIndex ) + { return i_nIndex < m_aElements.size() ? &m_aElements[ i_nIndex ] : 0; } + + public: MatrixArranger( WindowArranger* i_pParent = NULL, long i_nBorderX = 5, long i_nBorderY = 5 ) @@ -271,18 +315,15 @@ namespace vcl virtual void resize(); virtual void setParentWindow( Window* ); virtual size_t countElements() const { return m_aElements.size(); } - virtual boost::shared_ptr getChild( size_t i_nIndex ) const; - virtual Window* getWindow( size_t i_nIndex ) const; - virtual sal_Int32 getExpandPriority( size_t i_nIndex ) const; // add a managed window at the given matrix position - void addWindow( Window*, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); + size_t addWindow( Window*, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); void remove( Window* ); - void addChild( boost::shared_ptr const &, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); + size_t addChild( boost::shared_ptr const &, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); // convenience: use for addChild( new WindowArranger( ... ) ) constructs - void addChild( WindowArranger* i_pNewChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ) - { addChild( boost::shared_ptr( i_pNewChild ), i_nX, i_nY, i_nExpandPrio ); } + size_t addChild( WindowArranger* i_pNewChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ) + { return addChild( boost::shared_ptr( i_pNewChild ), i_nX, i_nY, i_nExpandPrio ); } void remove( boost::shared_ptr const & ); }; diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 2569000dd9f0..03ecdfc79979 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -45,6 +45,7 @@ #include "vcl/tabctrl.hxx" #include "vcl/tabpage.hxx" #include "vcl/arrange.hxx" +#include "vcl/virdev.hxx" #include #include @@ -56,17 +57,17 @@ namespace vcl class PrintPreviewWindow : public Window { GDIMetaFile maMtf; - double mfScaleX; - double mfScaleY; + Size maOrigSize; + VirtualDevice maPageVDev; public: PrintPreviewWindow( Window* pParent, const ResId& ); virtual ~PrintPreviewWindow(); virtual void Paint( const Rectangle& rRect ); virtual void Command( const CommandEvent& ); + virtual void Resize(); - void setPreview( const GDIMetaFile& ); - void setScale( double fScaleX, double fScaleY ); + void setPreview( const GDIMetaFile&, const Size& ); }; class NUpTabPage : public TabPage @@ -192,7 +193,6 @@ namespace vcl rtl::OUString maNoPageStr; sal_Int32 mnCurPage; sal_Int32 mnCachedPages; - Rectangle maPreviewSpace; Size maCurPageSize; std::list< Window* > maControls; @@ -206,8 +206,7 @@ namespace vcl rtl::OUString maPrintToFileText; rtl::OUString maPrintText; - vcl::RowOrColumn maPreviewCtrlRow; - Rectangle maPreviewBackground; + vcl::RowOrColumn maLayout; void updateNup(); void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); @@ -221,7 +220,6 @@ namespace vcl com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; virtual void Resize(); - virtual void Paint( const Rectangle& ); virtual void Command( const CommandEvent& ); DECL_LINK( SelectHdl, ListBox* ); @@ -234,6 +232,7 @@ namespace vcl DECL_LINK( UIOption_SelectHdl, ListBox* ); DECL_LINK( UIOption_ModifyHdl, Edit* ); + void setupLayout(); public: PrintDialog( Window*, const boost::shared_ptr< PrinterController >& ); virtual ~PrintDialog(); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index b00f1742fced..681017107a1b 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -87,6 +87,7 @@ #define SV_PRINT_PRT_STATUS 10 #define SV_PRINT_PRT_LOCATION 11 #define SV_PRINT_PRT_COMMENT 12 +#define SV_PRINT_TOFILE_TXT 13 #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP 1 diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index 25aa9d1ae581..f5e0b64b58ee 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -127,6 +127,9 @@ public: virtual void ActivatePage(); virtual long DeactivatePage(); + virtual Size GetOptimalSize(WindowSizeType eType) const; + void SetMinimumSizePixel( const Size& ); + void SetTabPageSizePixel( const Size& rSize ); Size GetTabPageSizePixel() const; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 9ff3e4f5a728..b13be2f43b3d 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -89,6 +89,7 @@ struct ImplTabCtrlData Point maItemsOffset; // offset of the tabitems std::vector< ImplTabItem > maItemList; ListBox* mpListBox; + Size maMinSize; }; // ----------------------------------------------------------------------- @@ -2303,3 +2304,25 @@ Point TabControl::GetItemsOffset() const } // ----------------------------------------------------------------------- + +Size TabControl::GetOptimalSize(WindowSizeType eType) const +{ + switch (eType) { + case WINDOWSIZE_MINIMUM: + return mpTabCtrlData ? mpTabCtrlData->maMinSize : Size(); + default: + return Control::GetOptimalSize( eType ); + } +} + +// ----------------------------------------------------------------------- + +void TabControl::SetMinimumSizePixel( const Size& i_rSize ) +{ + if( mpTabCtrlData ) + mpTabCtrlData->maMinSize = i_rSize; +} + +// ----------------------------------------------------------------------- + + diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 1e09b7c9fcc1..eb7ae8966d82 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -89,7 +89,6 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 140, 5 ); Size = MAP_APPFONT( 205, 175 ); -// DropDown = TRUE; }; FixedLine SV_PRINT_BUTTONLINE { @@ -101,6 +100,11 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "No pages"; }; + String SV_PRINT_TOFILE_TXT + { + Text [en-US] = "Print to file..."; + }; + TabPage SV_PRINT_TAB_NUP { Text [en-US] = "Page Layout"; diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 665c83e5f2d5..4f03706b4264 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -69,6 +69,21 @@ sal_Int32 WindowArranger::Element::getExpandPriority() const return nPrio; } +Size WindowArranger::Element::getOptimalSize( WindowSizeType i_eType ) const +{ + Size aResult; + if( m_pElement ) + aResult = m_pElement->GetOptimalSize( i_eType ); + else if( m_pChild ) + aResult = m_pChild->getOptimalSize( i_eType ); + if( aResult.Width() < m_aMinSize.Width() ) + aResult.Width() = m_aMinSize.Width(); + if( aResult.Height() < m_aMinSize.Height() ) + aResult.Height() = m_aMinSize.Height(); + + return aResult; +} + // ---------------------------------------- // vcl::RowOrColumn //----------------------------------------- @@ -82,21 +97,6 @@ RowOrColumn::~RowOrColumn() } } -boost::shared_ptr RowOrColumn::getChild( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : boost::shared_ptr(); -} - -Window* RowOrColumn::getWindow( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pElement : NULL; -} - -sal_Int32 RowOrColumn::getExpandPriority( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].getExpandPriority() : 0; -} - Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const { Size aRet( 0, 0 ); @@ -112,11 +112,7 @@ Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const it != m_aElements.end(); ++it ) { // get the size of type of the managed element - Size aElementSize( it->m_pElement - ? it->m_pElement->GetOptimalSize( i_eType ) - : it->m_pChild - ? it->m_pChild->getOptimalSize( i_eType ) - : Size() ); + Size aElementSize( it->getOptimalSize( i_eType ) ); if( m_bColumn ) { // add the distance between elements @@ -181,6 +177,43 @@ void RowOrColumn::distributeRowWidth( std::vector& io_rSizes, long /*i_nUs } } +void RowOrColumn::distributeColumnHeight( std::vector& io_rSizes, long /*i_nUsedHeight*/, long i_nExtraHeight ) +{ + if( ! io_rSizes.empty() && io_rSizes.size() == m_aElements.size() ) + { + // find all elements with the highest expand priority + size_t nElements = m_aElements.size(); + std::vector< size_t > aIndices; + sal_Int32 nHighPrio = 3; + for( size_t i = 0; i < nElements; i++ ) + { + sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); + if( nCurPrio > nHighPrio ) + { + aIndices.clear(); + nHighPrio = nCurPrio; + } + if( nCurPrio == nHighPrio ) + aIndices.push_back( i ); + } + + // distribute extra space evenly among elements + nElements = aIndices.size(); + if( nElements > 0 ) // sanity check + { + long nDelta = i_nExtraHeight / nElements; + for( size_t i = 0; i < nElements; i++ ) + { + io_rSizes[ aIndices[i] ].Height() += nDelta; + i_nExtraHeight -= nDelta; + } + // add the last pixels to the last row element + if( i_nExtraHeight > 0 && nElements > 0 ) + io_rSizes[aIndices.back()].Height() += i_nExtraHeight; + } + } +} + void RowOrColumn::resize() { // check if we can get optimal size, else fallback to minimal size @@ -203,11 +236,7 @@ void RowOrColumn::resize() long nUsedWidth = 2*m_nOuterBorder - (nElements ? m_nBorderWidth : 0); for( size_t i = 0; i < nElements; i++ ) { - aElementSizes[i] = m_aElements[i].m_pElement - ? m_aElements[i].m_pElement->GetOptimalSize( eType ) - : m_aElements[i].m_pChild - ? m_aElements[i].m_pChild->getOptimalSize( eType ) - : Size(); + aElementSizes[i] = m_aElements[i].getOptimalSize( eType ); if( m_bColumn ) { aElementSizes[i].Width() = m_aManagedArea.GetWidth() - 2* m_nOuterBorder; @@ -220,9 +249,11 @@ void RowOrColumn::resize() } } - long nExtraWidth = m_aManagedArea.GetWidth() - nUsedWidth; + long nExtraWidth = (m_bColumn ? m_aManagedArea.GetHeight() : m_aManagedArea.GetWidth()) - nUsedWidth; if( nExtraWidth > 0 ) - if( ! m_bColumn ) + if( m_bColumn ) + distributeColumnHeight( aElementSizes, nUsedWidth, nExtraWidth ); + else distributeRowWidth( aElementSizes, nUsedWidth, nExtraWidth ); // get starting position @@ -268,10 +299,14 @@ void RowOrColumn::setParentWindow( Window* i_pNewParent ) } } -void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio, sal_Int32 i_nIndex ) +size_t RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio, size_t i_nIndex ) { - if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) + size_t nIndex = i_nIndex; + if( i_nIndex >= m_aElements.size() ) + { + nIndex = m_aElements.size(); m_aElements.push_back( WindowArranger::Element( i_pWindow, boost::shared_ptr(), i_nExpandPrio ) ); + } else { std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); @@ -279,12 +314,17 @@ void RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio, sal_Int ++it; m_aElements.insert( it, WindowArranger::Element( i_pWindow, boost::shared_ptr(), i_nExpandPrio ) ); } + return nIndex; } -void RowOrColumn::addChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nExpandPrio, sal_Int32 i_nIndex ) +size_t RowOrColumn::addChild( boost::shared_ptr const & i_pChild, sal_Int32 i_nExpandPrio, size_t i_nIndex ) { - if( i_nIndex < 0 || size_t(i_nIndex) >= m_aElements.size() ) + size_t nIndex = i_nIndex; + if( i_nIndex >= m_aElements.size() ) + { + nIndex = m_aElements.size(); m_aElements.push_back( WindowArranger::Element( NULL, i_pChild, i_nExpandPrio ) ); + } else { std::vector< WindowArranger::Element >::iterator it = m_aElements.begin(); @@ -292,6 +332,7 @@ void RowOrColumn::addChild( boost::shared_ptr const & i_pChild, ++it; m_aElements.insert( it, WindowArranger::Element( NULL, i_pChild, i_nExpandPrio ) ); } + return nIndex; } void RowOrColumn::remove( Window* i_pWindow ) @@ -337,11 +378,7 @@ Indenter::~Indenter() Size Indenter::getOptimalSize( WindowSizeType i_eType ) const { - Size aSize( m_aElement.m_pElement - ? m_aElement.m_pElement->GetOptimalSize( i_eType ) - : m_aElement.m_pChild - ? m_aElement.m_pChild->getOptimalSize( i_eType ) - : Size() ); + Size aSize( m_aElement.getOptimalSize( i_eType ) ); aSize.Width() += 2*m_nOuterBorder + m_nIndent; aSize.Height() += 2*m_nOuterBorder; return aSize; @@ -419,11 +456,7 @@ Size MatrixArranger::getOptimalSize( WindowSizeType i_eType, std::vector& for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); it != m_aElements.end(); ++it ) { - Size aSize; - if( it->m_pElement ) - aSize = it->m_pElement->GetOptimalSize( i_eType ); - else if( it->m_pChild ) - aSize = it->m_pChild->getOptimalSize( i_eType ); + Size aSize( it->getOptimalSize( i_eType ) ); if( aSize.Width() > o_rColumnWidths[ it->m_nX ] ) o_rColumnWidths[ it->m_nX ] = aSize.Width(); if( aSize.Height() > o_rRowHeights[ it->m_nY ] ) @@ -513,28 +546,14 @@ void MatrixArranger::setParentWindow( Window* i_pNewParent ) } } -boost::shared_ptr MatrixArranger::getChild( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pChild : boost::shared_ptr(); -} - -Window* MatrixArranger::getWindow( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].m_pElement : NULL; -} - -sal_Int32 MatrixArranger::getExpandPriority( size_t i_nIndex ) const -{ - return i_nIndex < m_aElements.size() ? m_aElements[i_nIndex].getExpandPriority() : 0; -} - -void MatrixArranger::addWindow( Window* i_pWindow, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) +size_t MatrixArranger::addWindow( Window* i_pWindow, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) { sal_uInt64 nMapValue = getMap( i_nX, i_nY ); std::map< sal_uInt64, size_t >::const_iterator it = m_aMatrixMap.find( nMapValue ); + size_t nIndex = 0; if( it == m_aMatrixMap.end() ) { - m_aMatrixMap[ nMapValue ] = m_aElements.size(); + m_aMatrixMap[ nMapValue ] = nIndex = m_aElements.size(); m_aElements.push_back( MatrixElement( i_pWindow, i_nX, i_nY, boost::shared_ptr(), i_nExpandPrio ) ); } else @@ -545,7 +564,9 @@ void MatrixArranger::addWindow( Window* i_pWindow, sal_uInt32 i_nX, sal_uInt32 i rEle.m_nExpandPriority = i_nExpandPrio; rEle.m_nX = i_nX; rEle.m_nY = i_nY; + nIndex = it->second; } + return nIndex; } void MatrixArranger::remove( Window* i_pWindow ) @@ -565,13 +586,14 @@ void MatrixArranger::remove( Window* i_pWindow ) } } -void MatrixArranger::addChild( boost::shared_ptr const &i_pChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) +size_t MatrixArranger::addChild( boost::shared_ptr const &i_pChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) { sal_uInt64 nMapValue = getMap( i_nX, i_nY ); std::map< sal_uInt64, size_t >::const_iterator it = m_aMatrixMap.find( nMapValue ); + size_t nIndex = 0; if( it == m_aMatrixMap.end() ) { - m_aMatrixMap[ nMapValue ] = m_aElements.size(); + m_aMatrixMap[ nMapValue ] = nIndex = m_aElements.size(); m_aElements.push_back( MatrixElement( NULL, i_nX, i_nY, i_pChild, i_nExpandPrio ) ); } else @@ -582,7 +604,9 @@ void MatrixArranger::addChild( boost::shared_ptr const &i_pChild rEle.m_nExpandPriority = i_nExpandPrio; rEle.m_nX = i_nX; rEle.m_nY = i_nY; + nIndex = it->second; } + return nIndex; } void MatrixArranger::remove( boost::shared_ptr const &i_pChild ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 09d2532fa812..cd9e8712abaf 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -61,32 +61,66 @@ using namespace com::sun::star::beans; #define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) ) PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) - : Window( i_pParent, i_rId ), - mfScaleX( 1 ), - mfScaleY( 1 ) + : Window( i_pParent, i_rId ) + , maOrigSize( 10, 10 ) + , maPageVDev( *this ) { + SetPaintTransparent( TRUE ); + SetBackground(); + maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); } PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() { } +void PrintDialog::PrintPreviewWindow::Resize() +{ + Size aNewSize( GetSizePixel() ); + Size aScaledSize; + double fScale = 1.0; + if( maOrigSize.Width() > maOrigSize.Height() ) + { + aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * maOrigSize.Height() / maOrigSize.Width() ); + if( aScaledSize.Height() > aNewSize.Height() ) + fScale = double(aNewSize.Height())/double(aScaledSize.Height()); + } + else + { + aScaledSize = Size( aNewSize.Height() * maOrigSize.Width() / maOrigSize.Height(), aNewSize.Height() ); + if( aScaledSize.Width() > aNewSize.Width() ) + fScale = double(aNewSize.Width())/double(aScaledSize.Width()); + } + aScaledSize.Width() = long(aScaledSize.Width()*fScale); + aScaledSize.Height() = long(aScaledSize.Height()*fScale); + maPageVDev.SetOutputSizePixel( aScaledSize, FALSE ); +} + void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect ) { - Window::Paint( i_rRect ); - GDIMetaFile aMtf( maMtf ); - SetFillColor( Color( COL_WHITE ) ); - SetLineColor(); - DrawRect( Rectangle( Point( 0, 0 ), GetSizePixel() )); - Push(); - SetMapMode( MAP_100TH_MM ); + Size aPreviewSize = maPageVDev.GetOutputSizePixel(); + Size aSize( GetSizePixel() ); + Point aOffset( (aSize.Width() - aPreviewSize.Width()) / 2, + (aSize.Height() - aPreviewSize.Height()) / 2 ); + + const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) ); + double fScale = double(aLogicSize.Width())/double(maOrigSize.Width()); + + + maPageVDev.Erase(); + maPageVDev.Push(); + maPageVDev.SetMapMode( MAP_100TH_MM ); aMtf.WindStart(); - aMtf.Scale( mfScaleX, mfScaleY ); + aMtf.Scale( fScale, fScale ); aMtf.WindStart(); - aMtf.Play( this, Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ); - Pop(); + aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize ); + maPageVDev.Pop(); + + SetMapMode( MAP_PIXEL ); + maPageVDev.SetMapMode( MAP_PIXEL ); + DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev ); } void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) @@ -109,16 +143,10 @@ void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) } } -void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview ) +void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize ) { maMtf = i_rNewPreview; - Invalidate(); -} - -void PrintDialog::PrintPreviewWindow::setScale( double fScaleX, double fScaleY ) -{ - mfScaleX = fScaleX; - mfScaleY = fScaleY; + maOrigSize = i_rOrigSize; Invalidate(); } @@ -481,6 +509,7 @@ PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rRe , maCollateSingleJobsBox( this, VclResId( SV_PRINT_OPT_SINGLEJOBS ) ) , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) { + FreeResource(); maOptionsLine.SMHID2( "OptPage", "Options" ); maToFileBox.SMHID2( "OptPage", "ToFile" ); maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" ); @@ -552,19 +581,16 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr xPreviewAndTab( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xPreviewAndTab, 5 ); + + // setup column for preview and sub controls + boost::shared_ptr< vcl::RowOrColumn > xPreview( new vcl::RowOrColumn( xPreviewAndTab.get() ) ); + xPreviewAndTab->addChild( xPreview, 5 ); + xPreview->addWindow( &maPreviewWindow, 5 ); + // get a row for the preview controls + boost::shared_ptr< vcl::RowOrColumn > xPreviewCtrls( new vcl::RowOrColumn( xPreview.get(), false ) ); + xPreview->addChild( xPreviewCtrls ); + xPreviewCtrls->addWindow( &maPageEdit ); + xPreviewCtrls->addWindow( &maNumPagesText ); + boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); + xPreviewCtrls->addChild( xSpacer ); + xPreviewCtrls->addWindow( &maBackwardBtn ); + xPreviewCtrls->addWindow( &maForwardBtn ); + + // continue with the tab ctrl + xPreviewAndTab->addWindow( &maTabCtrl ); + + // add the button line + maLayout.addWindow( &maButtonLine ); + + // add the row for the buttons + boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xButtons ); + + // insert a spacer, buttons are right aligned + xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) ); + xButtons->addChild( xSpacer ); + Size aMinSize( maCancelButton.GetSizePixel() ); + xButtons->setMinimumSize( xButtons->addWindow( &maOKButton ), aMinSize ); + xButtons->setMinimumSize( xButtons->addWindow( &maCancelButton ), aMinSize ); +} + void PrintDialog::readFromSettings() { maJobPage.readFromSettings(); @@ -723,6 +794,7 @@ void PrintDialog::readFromSettings() break; } } + maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); } void PrintDialog::storeToSettings() @@ -1222,6 +1294,7 @@ void PrintDialog::setupOptionalUI() // resize dialog if necessary Size aTabSize = maTabCtrl.GetTabPageSizePixel(); + maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); if( aMaxSize.Height() > aTabSize.Height() || aMaxSize.Width() > aTabSize.Width() ) { Size aCurSize( GetSizePixel() ); @@ -1233,6 +1306,7 @@ void PrintDialog::setupOptionalUI() // and the tab ctrl needs more space, too aTabSize.Width() = aMaxSize.Width(); maTabCtrl.SetSizePixel( aTabSize ); + maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); } SetSizePixel( aCurSize ); } @@ -1375,32 +1449,11 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) GDIMetaFile aMtf; if( nPages > 0 ) maCurPageSize = maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); + else + maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - maPreviewWindow.setPreview( aMtf ); + maPreviewWindow.setPreview( aMtf, maCurPageSize ); } - // catch corner case of strange page size - if( maCurPageSize.Width() == 0 || maCurPageSize.Height() == 0 ) - maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - - Size aPreviewSize; - Point aPreviewPos = maPreviewSpace.TopLeft(); - const long nW = maPreviewSpace.GetSize().Width(); - const long nH = maPreviewSpace.GetSize().Height(); - if( maCurPageSize.Width() > maCurPageSize.Height() ) - { - aPreviewSize = Size( nW, nW * maCurPageSize.Height() / maCurPageSize.Width() ); - aPreviewPos.Y() += (maPreviewSpace.GetHeight() - aPreviewSize.Height())/2; - } - else - { - aPreviewSize = Size( nH * maCurPageSize.Width() / maCurPageSize.Height(), nH ); - aPreviewPos.X() += (maPreviewSpace.GetWidth() - aPreviewSize.Width())/2; - } - - maPreviewWindow.SetPosSizePixel( aPreviewPos, aPreviewSize ); - const Size aLogicSize( maPreviewWindow.PixelToLogic( maPreviewWindow.GetSizePixel(), MapMode( MAP_100TH_MM ) ) ); - maPreviewWindow.setScale( double(aLogicSize.Width())/double(maCurPageSize.Width()), - double(aLogicSize.Height())/double(maCurPageSize.Height()) ); } void PrintDialog::updateNup() @@ -1459,6 +1512,11 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { previewBackward(); } + else if( pButton == &maOptionsPage.maToFileBox ) + { + maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); + maLayout.resize(); + } else if( pButton == &maJobPage.maCollateBox ) { maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), @@ -1613,34 +1671,6 @@ IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) return 0; } -void PrintDialog::Paint( const Rectangle& i_rRect ) -{ - ModalDialog::Paint( i_rRect ); - - #if 0 - // sadly Tab panes are not a reliable choice for a grouping background - // since they depend on the tab items above in some themes - if( IsNativeControlSupported( CTRL_TAB_PANE, PART_ENTIRE_CONTROL) ) - { - Rectangle aPrevBg( maPreviewBackground ); - #ifdef QUARTZ - // FIXME: this interacts with vcl/aqua/source/gdi/salnativewidgets.cxx where - // some magic offsets are added to the area - aPrevBg.Top() += 10; - #endif - const ImplControlValue aControlValue( BUTTONVALUE_DONTKNOW, rtl::OUString(), 0 ); - - ControlState nState = CTRL_STATE_ENABLED; - Region aCtrlRegion( aPrevBg ); - DrawNativeControl( CTRL_TAB_PANE, PART_ENTIRE_CONTROL, aCtrlRegion, nState, - aControlValue, rtl::OUString() ); - } - #else - DecorationView aVw( this ); - aVw.DrawFrame( maPreviewBackground, FRAME_DRAW_IN ); - #endif -} - void PrintDialog::Command( const CommandEvent& rEvt ) { if( rEvt.GetCommand() == COMMAND_WHEEL ) @@ -1659,6 +1689,7 @@ void PrintDialog::Command( const CommandEvent& rEvt ) void PrintDialog::Resize() { + #if 0 Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); Size aWindowSize( GetOutputSizePixel() ); @@ -1705,6 +1736,9 @@ void PrintDialog::Resize() maPreviewBackground.Top() = aPixDiff.Height() - 2; maPreviewBackground.Right() = aPixDiff.Width() + nPreviewLength + 2; maPreviewBackground.Bottom() = maPreviewCtrlRow.getManagedArea().Bottom() + aPixDiff.Height(); + #else + maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); + #endif // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); From 90854d1828ab03e7dbfca7214cd3aec140d8a9f3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 25 Jul 2009 01:56:38 +0000 Subject: [PATCH 133/283] solve some rebase problems --- vcl/aqua/inc/salprn.h | 2 +- vcl/aqua/source/gdi/salprn.cxx | 19 +++++++++---------- vcl/inc/vcl/arrange.hxx | 2 +- vcl/source/window/printdlg.cxx | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index e265f800906d..a572641dd59e 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -120,7 +120,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; } // match width/height against known paper formats, possibly switching orientation - const vcl::PaperInfo* matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const; + const PaperInfo* matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const; void setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation ); private: diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 601adb3aa9b5..7a5b0c7ba483 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -128,6 +128,7 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const long nDPIX = 720, nDPIY = 720; NSSize aPaperSize = [mpPrintInfo paperSize]; + NSRect aImageRect = [mpPrintInfo imageablePageBounds]; if( mePageOrientation == ORIENTATION_PORTRAIT ) { // move mirrored CTM back into paper @@ -303,11 +304,11 @@ void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientatio { Orientation ePaperOrientation = ORIENTATION_PORTRAIT; - const vcl::PaperInfo* pPaper = matchPaper( (i_nWidth+50)/100, (i_nHeight+50)/100, ePaperOrientation ); + const PaperInfo* pPaper = matchPaper( (i_nWidth+50)/100, (i_nHeight+50)/100, ePaperOrientation ); if( pPaper ) { - NSString* pPaperName = [CreateNSString( pPaper->m_aPaperName ) autorelease]; + NSString* pPaperName = [CreateNSString( rtl::OStringToOUString(PaperInfo::toPSName(pPaper->getPaper()), RTL_TEXTENCODING_ASCII_US) ) autorelease]; [mpPrintInfo setPaperName: pPaperName]; } else if( i_nWidth > 0 && i_nHeight > 0 ) @@ -809,10 +810,8 @@ void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper]; if( aPaperSize.width > 0 && aPaperSize.height > 0 ) { - vcl::PaperInfo aInfo; - aInfo.m_aPaperName = GetOUString( pPaper ); - aInfo.m_nPaperWidth = (PtTo10Mu( aPaperSize.width ) + 50 ) / 100; - aInfo.m_nPaperHeight = (PtTo10Mu( aPaperSize.height ) + 50 ) / 100; + PaperInfo aInfo( (PtTo10Mu( aPaperSize.width ) + 50 ) / 100, + (PtTo10Mu( aPaperSize.height ) + 50 ) / 100 ); m_aPaperFormats.push_back( aInfo ); } } @@ -821,19 +820,19 @@ void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) } } -const vcl::PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const +const PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const { if( ! m_bPapersInit ) const_cast(this)->InitPaperFormats( NULL ); - const vcl::PaperInfo* pMatch = NULL; + const PaperInfo* pMatch = NULL; o_rOrientation = ORIENTATION_PORTRAIT; for( int n = 0; n < 2 ; n++ ) { for( size_t i = 0; i < m_aPaperFormats.size(); i++ ) { - if( abs( m_aPaperFormats[i].m_nPaperWidth - i_nWidth ) < 2 && - abs( m_aPaperFormats[i].m_nPaperHeight - i_nHeight ) < 2 ) + if( abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 2 && + abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 2 ) { pMatch = &m_aPaperFormats[i]; return pMatch; diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index febbe69491a2..54727d24755b 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -87,7 +87,7 @@ namespace vcl Rectangle m_aManagedArea; long m_nOuterBorder; - virtual Element* getElement( size_t i_nIndex ) = NULL; + virtual Element* getElement( size_t i_nIndex ) = 0; const Element* getConstElement( size_t i_nIndex ) const { return const_cast(this)->getElement( i_nIndex ); } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index cd9e8712abaf..3022151e4425 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -96,7 +96,7 @@ void PrintDialog::PrintPreviewWindow::Resize() maPageVDev.SetOutputSizePixel( aScaledSize, FALSE ); } -void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& i_rRect ) +void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { GDIMetaFile aMtf( maMtf ); From efe311f79e12853753d50ffaf73630dfc88c1c09 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 27 Jul 2009 17:10:15 +0000 Subject: [PATCH 134/283] #i92518# adapting new UX spec --- vcl/inc/vcl/prndlg.hxx | 44 ++-- vcl/inc/vcl/svids.hrc | 44 ++-- vcl/source/src/print.src | 176 +++++++--------- vcl/source/window/printdlg.cxx | 353 +++++++++++++++++---------------- 4 files changed, 299 insertions(+), 318 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 03ecdfc79979..6a8974ccb966 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -74,30 +74,30 @@ namespace vcl { public: FixedLine maNupLine; - FixedText maNupRowsTxt; - NumericField maNupRowsEdt; - FixedText maNupColTxt; + FixedText maNupPagesTxt; + ListBox maNupPagesBox; + + // controls for "Custom" page mode + FixedText maNupNumPagesTxt; NumericField maNupColEdt; - FixedText maNupRepTxt; - NumericField maNupRepEdt; + FixedText maNupTimesTxt; + NumericField maNupRowsEdt; + FixedText maPageMarginTxt; + MetricField maPageMarginEdt; + FixedText maSheetMarginTxt; + MetricField maSheetMarginEdt; + FixedText maNupOrientationTxt; + ListBox maNupOrientationBox; + + // page order ("left to right, then down") + FixedText maNupOrderTxt; + ListBox maNupOrderBox; + // border around each page CheckBox maBorderCB; - RadioButton maNupPortrait; - RadioButton maNupLandscape; - FixedLine maMargins; - FixedText maLeftMarginTxt; - MetricField maLeftMarginEdt; - FixedText maRightMarginTxt; - MetricField maRightMarginEdt; - FixedText maTopMarginTxt; - MetricField maTopMarginEdt; - FixedText maBottomMarginTxt; - MetricField maBottomMarginEdt; + vcl::RowOrColumn maLayout; - FixedText maHSpaceTxt; - MetricField maHSpaceEdt; - FixedText maVSpaceTxt; - MetricField maVSpaceEdt; + void setupLayout(); NUpTabPage( Window*, const ResId& ); virtual ~NUpTabPage(); @@ -203,11 +203,15 @@ namespace vcl Size maNupPortraitSize; Size maNupLandscapeSize; + // internal, used for automatic Nup-Portrait/landscape + Size maFirstPageSize; + rtl::OUString maPrintToFileText; rtl::OUString maPrintText; vcl::RowOrColumn maLayout; + Size getJobPageSize(); void updateNup(); void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); void setPreviewText( sal_Int32 ); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 681017107a1b..ed7f16cfb17c 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -90,29 +90,27 @@ #define SV_PRINT_TOFILE_TXT 13 #define SV_PRINT_TAB_NUP 1 -#define SV_PRINT_PRT_NUP 1 -#define SV_PRINT_PRT_NUP_ROWS_TXT 2 -#define SV_PRINT_PRT_NUP_ROWS_EDT 3 -#define SV_PRINT_PRT_NUP_COLUMNS_TXT 4 -#define SV_PRINT_PRT_NUP_COLUMNS_EDT 5 -#define SV_PRINT_PRT_NUP_PORTRAIT 6 -#define SV_PRINT_PRT_NUP_LANDSCAPE 7 -#define SV_PRINT_PRT_NUP_MARGINS_FL 8 -#define SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT 9 -#define SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT 10 -#define SV_PRINT_PRT_NUP_MARGINS_TOP_TXT 11 -#define SV_PRINT_PRT_NUP_MARGINS_TOP_EDT 12 -#define SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT 13 -#define SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT 14 -#define SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT 15 -#define SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT 16 -#define SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT 17 -#define SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT 18 -#define SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT 19 -#define SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT 20 -#define SV_PRINT_PRT_NUP_BORDER_CB 21 -#define SV_PRINT_PRT_NUP_PAGEREPEAT_TXT 22 -#define SV_PRINT_PRT_NUP_PAGEREPEAT_EDT 23 +#define SV_PRINT_PRT_NUP_LAYOUT_FL 1 +#define SV_PRINT_PRT_NUP_PAGES_TXT 2 +#define SV_PRINT_PRT_NUP_PAGES_BOX 2 +#define SV_PRINT_PRT_NUP_NUM_PAGES_TXT 3 +#define SV_PRINT_PRT_NUP_COLS_EDT 4 +#define SV_PRINT_PRT_NUP_TIMES_TXT 5 +#define SV_PRINT_PRT_NUP_ROWS_EDT 6 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT 7 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT 8 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT 9 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT 10 +#define SV_PRINT_PRT_NUP_ORIENTATION_TXT 12 +#define SV_PRINT_PRT_NUP_ORIENTATION_BOX 13 +#define SV_PRINT_PRT_NUP_ORDER_TXT 14 +#define SV_PRINT_PRT_NUP_ORDER_BOX 15 +#define SV_PRINT_PRT_NUP_BORDER_CB 16 + +#define SV_PRINT_PRT_NUP_ORIENTATION_AUTOMATIC 0 +#define SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT 1 +#define SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE 2 + #define SV_PRINT_TAB_JOB 2 #define SV_PRINT_PRINTERS_FL 1 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index eb7ae8966d82..600a690ef23d 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -110,19 +110,43 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "Page Layout"; Hide = TRUE; - FixedLine SV_PRINT_PRT_NUP + FixedLine SV_PRINT_PRT_NUP_LAYOUT_FL { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "N-Up printing"; + Text [en-US] = "Layout"; }; - FixedText SV_PRINT_PRT_NUP_ROWS_TXT + FixedText SV_PRINT_PRT_NUP_PAGES_TXT { Pos = MAP_APPFONT( 10, 20 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Rows"; + Text [en-US] = "Pages per ~sheet"; }; - NumericField SV_PRINT_PRT_NUP_ROWS_EDT + ListBox SV_PRINT_PRT_NUP_PAGES_BOX + { + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 80 ); + Border = TRUE; + DropDown = TRUE; + CurPos = 0; + StringList [en-US] = + { + < "1"; 1; >; + < "2"; 2; >; + < "4"; 4; >; + < "6"; 6; >; + < "9"; 9; >; + < "16"; 16; >; + < "Custom"; 0xffff; >; + }; + }; + FixedText SV_PRINT_PRT_NUP_NUM_PAGES_TXT + { + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "P~ages"; + }; + NumericField SV_PRINT_PRT_NUP_COLS_EDT { Pos = MAP_APPFONT( 55, 20 ); Size = MAP_APPFONT( 40, 12 ); @@ -132,13 +156,13 @@ ModalDialog SV_DLG_PRINT Maximum = 32; Value = 1; }; - FixedText SV_PRINT_PRT_NUP_COLUMNS_TXT + FixedText SV_PRINT_PRT_NUP_TIMES_TXT { Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "C~olumns"; + Text [en-US] = "~by"; }; - NumericField SV_PRINT_PRT_NUP_COLUMNS_EDT + NumericField SV_PRINT_PRT_NUP_ROWS_EDT { Pos = MAP_APPFONT( 55, 35 ); Size = MAP_APPFONT( 40, 12 ); @@ -148,53 +172,13 @@ ModalDialog SV_DLG_PRINT Maximum = 32; Value = 1; }; - FixedText SV_PRINT_PRT_NUP_PAGEREPEAT_TXT - { - Pos = MAP_APPFONT( 10, 50 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Repeat"; - }; - NumericField SV_PRINT_PRT_NUP_PAGEREPEAT_EDT - { - Pos = MAP_APPFONT( 55, 50 ); - Size = MAP_APPFONT( 40, 12 ); - Border = TRUE; - Spin = TRUE; - Minimum = 1; - Maximum = 32; - Value = 1; - }; - CheckBox SV_PRINT_PRT_NUP_BORDER_CB - { - Pos = MAP_APPFONT( 10, 65 ); - Size = MAP_APPFONT( 150, 12 ); - Text [en-US] = "~Draw a Border around each page"; - }; - RadioButton SV_PRINT_PRT_NUP_PORTRAIT - { - Pos = MAP_APPFONT( 110, 20 ); - Size = MAP_APPFONT( 90, 10 ); - Text [en-US] = "Po~rtrait"; - }; - RadioButton SV_PRINT_PRT_NUP_LANDSCAPE - { - Pos = MAP_APPFONT( 110, 30 ); - Size = MAP_APPFONT( 90, 10 ); - Text [en-US] = "~Landscape"; - }; - FixedLine SV_PRINT_PRT_NUP_MARGINS_FL - { - Pos = MAP_APPFONT( 5, 80 ); - Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "Margins"; - }; - FixedText SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT + FixedText SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT { Pos = MAP_APPFONT( 10, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Left"; + Text [en-US] = "~Margin between pages"; }; - MetricField SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT + MetricField SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT { Pos = MAP_APPFONT( 55, 95 ); Size = MAP_APPFONT( 40, 12 ); @@ -203,13 +187,13 @@ ModalDialog SV_DLG_PRINT Value = 0; Unit = FUNIT_MM; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT + FixedText SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT { Pos = MAP_APPFONT( 110, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Right"; + Text [en-US] = "Ma~rgin to sheet border"; }; - MetricField SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT + MetricField SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT { Pos = MAP_APPFONT( 155, 95 ); Size = MAP_APPFONT( 40, 12 ); @@ -218,66 +202,50 @@ ModalDialog SV_DLG_PRINT Value = 0; Unit = FUNIT_MM; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_TOP_TXT + FixedText SV_PRINT_PRT_NUP_ORIENTATION_TXT { - Pos = MAP_APPFONT( 10, 110 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Top"; + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "~Orientation"; }; - MetricField SV_PRINT_PRT_NUP_MARGINS_TOP_EDT + ListBox SV_PRINT_PRT_NUP_ORIENTATION_BOX { - Pos = MAP_APPFONT( 55, 110 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 40 ); Border = TRUE; - Value = 0; - Unit = FUNIT_MM; + DropDown = TRUE; + CurPos = 0; + StringList [en-US] = + { + < "Automatic"; SV_PRINT_PRT_NUP_ORIENTATION_AUTOMATIC; >; + < "Portrait"; SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT; >; + < "Landscape"; SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE; >; + }; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT + FixedText SV_PRINT_PRT_NUP_ORDER_TXT { - Pos = MAP_APPFONT( 110, 110 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Bottom"; + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "Order"; }; - MetricField SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT + ListBox SV_PRINT_PRT_NUP_ORDER_BOX { - Pos = MAP_APPFONT( 155, 110 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 20 ); + DropDown = TRUE; Border = TRUE; - Value = 0; - Unit = FUNIT_MM; + CurPos = 0; + StringList [en-US] = + { + < "left to right, then down"; 1; >; + < "top to bottom, then right"; 2; >; + }; }; - - FixedText SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT + CheckBox SV_PRINT_PRT_NUP_BORDER_CB { - Pos = MAP_APPFONT( 10, 130 ); - Size = MAP_APPFONT( 80, 10 ); - Text [en-US] = "~Horizontal spacing"; - }; - MetricField SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT - { - Pos = MAP_APPFONT( 95, 130 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; - Border = TRUE; - Value = 0; - Unit = FUNIT_MM; - }; - FixedText SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT - { - Pos = MAP_APPFONT( 10, 145 ); - Size = MAP_APPFONT( 80, 10 ); - Text [en-US] = "~Vertical spacing"; - }; - MetricField SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT - { - Pos = MAP_APPFONT( 95, 145 ); - Size = MAP_APPFONT( 40, 12 ); - Spin = TRUE; - Border = TRUE; - Value = 0; - Unit = FUNIT_MM; + Pos = MAP_APPFONT( 10, 65 ); + Size = MAP_APPFONT( 150, 12 ); + Text [en-US] = "~Draw a Border around each page"; }; }; @@ -382,7 +350,7 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "Options"; Hide = TRUE; - FixedLine SV_PRINT_PRT_NUP + FixedLine SV_PRINT_OPT_PRINT_FL { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 150, 10 ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 3022151e4425..dd618766451c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -147,39 +147,33 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi { maMtf = i_rNewPreview; maOrigSize = i_rOrigSize; + Resize(); Invalidate(); } PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) - , maNupLine( this, VclResId( SV_PRINT_PRT_NUP ) ) - , maNupRowsTxt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_TXT ) ) + , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) + , maNupPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_PAGES_TXT ) ) + , maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) ) + , maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) ) + , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) + , maNupTimesTxt( this, VclResId( SV_PRINT_PRT_NUP_TIMES_TXT ) ) , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) - , maNupColTxt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_TXT ) ) - , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLUMNS_EDT ) ) - , maNupRepTxt( this, VclResId( SV_PRINT_PRT_NUP_PAGEREPEAT_TXT ) ) - , maNupRepEdt( this, VclResId( SV_PRINT_PRT_NUP_PAGEREPEAT_EDT ) ) + , maPageMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT ) ) + , maPageMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT ) ) + , maSheetMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT ) ) + , maSheetMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT ) ) + , maNupOrientationTxt( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_TXT ) ) + , maNupOrientationBox( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_BOX ) ) + , maNupOrderTxt( this, VclResId( SV_PRINT_PRT_NUP_ORDER_TXT ) ) + , maNupOrderBox( this, VclResId( SV_PRINT_PRT_NUP_ORDER_BOX ) ) , maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) ) - , maNupPortrait( this, VclResId( SV_PRINT_PRT_NUP_PORTRAIT ) ) - , maNupLandscape( this, VclResId( SV_PRINT_PRT_NUP_LANDSCAPE ) ) - , maMargins( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_FL ) ) - , maLeftMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_LEFT_TXT ) ) - , maLeftMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_LEFT_EDT) ) - , maRightMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_RIGHT_TXT ) ) - , maRightMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_RIGHT_EDT ) ) - , maTopMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_TOP_TXT ) ) - , maTopMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_TOP_EDT ) ) - , maBottomMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_BOTTOM_TXT ) ) - , maBottomMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_BOTTOM_EDT ) ) - , maHSpaceTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_HSPACE_TXT ) ) - , maHSpaceEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_HSPACE_EDT ) ) - , maVSpaceTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_VSPACE_TXT ) ) - , maVSpaceEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_VSPACE_EDT ) ) { FreeResource(); // setup field units for metric fields - const LocaleDataWrapper& rLocWrap( maLeftMarginEdt.GetLocaleDataWrapper() ); + const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); FieldUnit eUnit = FUNIT_MM; USHORT nDigits = 0; if( rLocWrap.getMeasurementSystemEnum() == MEASURE_US ) @@ -188,162 +182,105 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) nDigits = 2; } // set units - maLeftMarginEdt.SetUnit( eUnit ); - maTopMarginEdt.SetUnit( eUnit ); - maRightMarginEdt.SetUnit( eUnit ); - maBottomMarginEdt.SetUnit( eUnit ); - maHSpaceEdt.SetUnit( eUnit ); - maVSpaceEdt.SetUnit( eUnit ); + maPageMarginEdt.SetUnit( eUnit ); + maSheetMarginEdt.SetUnit( eUnit ); // set precision - maLeftMarginEdt.SetDecimalDigits( nDigits ); - maTopMarginEdt.SetDecimalDigits( nDigits ); - maRightMarginEdt.SetDecimalDigits( nDigits ); - maBottomMarginEdt.SetDecimalDigits( nDigits ); - maHSpaceEdt.SetDecimalDigits( nDigits ); - maVSpaceEdt.SetDecimalDigits( nDigits ); + maPageMarginEdt.SetDecimalDigits( nDigits ); + maSheetMarginEdt.SetDecimalDigits( nDigits ); - maNupLine.SMHID2( "NUpPage", "NUPline" ); - maNupRowsTxt.SMHID2( "NUpPage", "NUPRowsText" ); - maNupRowsEdt.SMHID2( "NUpPage", "NUPRows" ); - maNupColTxt.SMHID2( "NUpPage", "NUPColumnsText" ); - maNupColEdt.SMHID2( "NUpPage", "NUPColumns" ); - maNupRepTxt.SMHID2( "NUpPage", "NUPRepeatText" ); - maNupRepEdt.SMHID2( "NUpPage", "NUPRepeat" ); - maNupPortrait.SMHID2( "NUpPage", "NUPPortrait" ); - maNupLandscape.SMHID2( "NUpPage", "NUPLandscape" ); - maBorderCB.SMHID2( "NUpPage", "NUPBorder" ); - maMargins.SMHID2( "NUpPage", "NUPMargins" ); - maLeftMarginTxt.SMHID2( "NUpPage", "NUPLeftText" ); - maLeftMarginEdt.SMHID2( "NUpPage", "NUPLeft" ); - maTopMarginTxt.SMHID2( "NUpPage", "NUPTopText" ); - maTopMarginEdt.SMHID2( "NUpPage", "NUPTop" ); - maRightMarginTxt.SMHID2( "NUpPage", "NUPRightText" ); - maRightMarginEdt.SMHID2( "NUpPage", "NUPRight" ); - maBottomMarginTxt.SMHID2( "NUpPage", "NUPBottomText" ); - maBottomMarginEdt.SMHID2( "NUpPage", "NUPBottom" ); - maHSpaceTxt.SMHID2( "NUpPage", "NUPHSpaceText" ); - maHSpaceEdt.SMHID2( "NUpPage", "NUPHSpace" ); - maVSpaceTxt.SMHID2( "NUpPage", "NUPVSpaceText" ); - maVSpaceEdt.SMHID2( "NUpPage", "NUPVSpace" ); + maNupLine.SMHID2("NUpPage", "Layout"); + maNupPagesTxt.SMHID2( "NUpPage", "PagesPerSheet" ); + maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" ); + maNupNumPagesTxt.SMHID2( "NUpPage", "Columns" ); + maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" ); + maNupTimesTxt.SMHID2( "NUpPage", "Rows" ); + maNupRowsEdt.SMHID2( "NUpPage", "RowsBox" ); + maPageMarginTxt.SMHID2( "NUpPage", "PageMargin" ); + maPageMarginEdt.SMHID2( "NUpPage", "PageMarginBox" ); + maSheetMarginTxt.SMHID2( "NUpPage", "SheetMargin" ); + maSheetMarginEdt.SMHID2( "NUpPage", "SheetMarginBox" ); + maNupOrientationTxt.SMHID2( "NUpPage", "Orientation" ); + maNupOrientationBox.SMHID2( "NUpPage", "OrientationBox" ); + maNupOrderTxt.SMHID2( "NUpPage", "Order" ); + maNupOrderBox.SMHID2( "NUpPage", "OrderBox" ); + maBorderCB.SMHID2( "NUpPage", "BorderBox" ); + + setupLayout(); } PrintDialog::NUpTabPage::~NUpTabPage() { } -void PrintDialog::NUpTabPage::Resize() +void PrintDialog::NUpTabPage::setupLayout() { Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - boost::shared_ptr aPage( new vcl::RowOrColumn() ); - aPage->setParentWindow( this ); - aPage->setOuterBorder( aBorder.Width() ); - aPage->addWindow( &maNupLine ); + maLayout.setParentWindow( this ); + maLayout.setOuterBorder( aBorder.Width() ); - boost::shared_ptr aNupIndent( new vcl::Indenter( aPage.get(), aBorder.Width() ) ); - aPage->addChild( aNupIndent ); - boost::shared_ptr aNupColumn( new vcl::RowOrColumn( aNupIndent.get() ) ); - aNupIndent->setChild( aNupColumn ); + maLayout.addWindow( &maNupLine ); + boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xRow ); + xRow->addWindow( &maNupPagesTxt ); + xRow->addWindow( &maNupPagesBox ); - boost::shared_ptr aNupRow( new vcl::RowOrColumn( aNupColumn.get(), false ) ); - aNupColumn->addChild( aNupRow ); - boost::shared_ptr aNupMat( new vcl::MatrixArranger( aNupRow.get(), aBorder.Width(), aBorder.Height() ) ); - aNupRow->addChild( aNupMat ); - aNupMat->addWindow( &maNupRowsTxt, 0, 0 ); - aNupMat->addWindow( &maNupRowsEdt, 1, 0 ); - aNupMat->addWindow( &maNupColTxt, 0, 1 ); - aNupMat->addWindow( &maNupColEdt, 1, 1 ); - aNupMat->addWindow( &maNupRepTxt, 0, 2 ); - aNupMat->addWindow( &maNupRepEdt, 1, 2 ); - boost::shared_ptr aOriCol( new vcl::RowOrColumn( aNupRow.get() ) ); - aNupRow->addChild( aOriCol ); - aOriCol->addWindow( &maNupPortrait ); - aOriCol->addWindow( &maNupLandscape ); + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( &maLayout ) ); + maLayout.addChild( xIndent ); + boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); + xIndent->setChild( xCol ); - aNupColumn->addWindow( &maBorderCB ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); + xRow->addWindow( &maNupNumPagesTxt ); + xRow->addWindow( &maNupColEdt ); + xRow->addWindow( &maNupTimesTxt ); + xRow->addWindow( &maNupRowsEdt ); - aPage->addWindow( &maMargins ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); + xRow->addWindow( &maPageMarginTxt ); + xRow->addWindow( &maPageMarginEdt ); - boost::shared_ptr aMargIndent( new vcl::Indenter( aPage.get(), aBorder.Width() ) ); - aPage->addChild( aMargIndent ); - boost::shared_ptr aMargColumn( new vcl::RowOrColumn( aMargIndent.get(), true, 2*aBorder.Height() ) ); - aMargIndent->setChild( aMargColumn ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); + xRow->addWindow( &maSheetMarginTxt ); + xRow->addWindow( &maSheetMarginEdt ); - boost::shared_ptr aMargMat( new vcl::MatrixArranger( aMargIndent.get(), aBorder.Width(), aBorder.Height() ) ); - aMargColumn->addChild( aMargMat ); - aMargMat->addWindow( &maLeftMarginTxt, 0, 0 ); - aMargMat->addWindow( &maLeftMarginEdt, 1, 0 ); - aMargMat->addWindow( &maRightMarginTxt, 3, 0 ); - aMargMat->addWindow( &maRightMarginEdt, 4, 0 ); - aMargMat->addWindow( &maTopMarginTxt, 0, 1 ); - aMargMat->addWindow( &maTopMarginEdt, 1, 1 ); - aMargMat->addWindow( &maBottomMarginTxt, 3, 1 ); - aMargMat->addWindow( &maBottomMarginEdt, 4, 1 ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); + xRow->addWindow( &maNupOrientationTxt ); + xRow->addWindow( &maNupOrientationBox ); - boost::shared_ptr aSpacingMat( new vcl::MatrixArranger( aPage.get(), aBorder.Width(), aBorder.Height() ) ); - aMargColumn->addChild( aSpacingMat ); - aSpacingMat->addWindow( &maHSpaceTxt, 0, 0 ); - aSpacingMat->addWindow( &maHSpaceEdt, 1, 0 ); - aSpacingMat->addWindow( &maVSpaceTxt, 0, 1 ); - aSpacingMat->addWindow( &maVSpaceEdt, 1, 1 ); + xRow.reset( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xRow ); + xRow->addWindow( &maNupOrderTxt ); + xRow->addWindow( &maNupOrderBox ); - aPage->setManagedArea( Rectangle( Point(), GetOutputSizePixel() ) ); + maLayout.addWindow( &maBorderCB ); +} + +void PrintDialog::NUpTabPage::Resize() +{ + maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) ); } void PrintDialog::NUpTabPage::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS ) { - maLeftMarginEdt.SetValue( maLeftMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); - maTopMarginEdt.SetValue( maTopMarginEdt.Normalize( i_rMPS.nTopMargin ), FUNIT_100TH_MM ); - maRightMarginEdt.SetValue( maRightMarginEdt.Normalize( i_rMPS.nRightMargin ), FUNIT_100TH_MM ); - maBottomMarginEdt.SetValue( maBottomMarginEdt.Normalize( i_rMPS.nBottomMargin ), FUNIT_100TH_MM ); - maHSpaceEdt.SetValue( maHSpaceEdt.Normalize( i_rMPS.nHorizontalSpacing ), FUNIT_100TH_MM ); - maVSpaceEdt.SetValue( maVSpaceEdt.Normalize( i_rMPS.nVerticalSpacing ), FUNIT_100TH_MM ); + maSheetMarginEdt.SetValue( maSheetMarginEdt.Normalize( i_rMPS.nLeftMargin ), FUNIT_100TH_MM ); + maPageMarginEdt.SetValue( maPageMarginEdt.Normalize( i_rMPS.nHorizontalSpacing ), FUNIT_100TH_MM ); maBorderCB.Check( i_rMPS.bDrawBorder ); maNupRowsEdt.SetValue( i_rMPS.nRows ); maNupColEdt.SetValue( i_rMPS.nColumns ); - maNupRepEdt.SetValue( i_rMPS.nRepeat ); } void PrintDialog::NUpTabPage::readFromSettings() { - #if 0 - SettingsConfigItem* pItem = SettingsConfigItem::get(); - rtl::OUString aValue; - - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ) ); - sal_Int32 nVal = aValue.toInt32(); - maNupRowsEdt.SetValue( sal_Int64( nVal > 1 ? nVal : 1) ); - - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ) ); - nVal = aValue.toInt32(); - maNupColEdt.SetValue( sal_Int64(nVal > 1 ? nVal : 1) ); - - aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ) ); - if( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ) - maNupPortrait.Check(); - else - maNupLandscape.Check(); - #endif } void PrintDialog::NUpTabPage::storeToSettings() { - #if 0 - SettingsConfigItem* pItem = SettingsConfigItem::get(); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Rows" ) ), - maNupRowsEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Columns" ) ), - maNupColEdt.GetText() ); - pItem->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NUp-Portrait" ) ), - rtl::OUString::createFromAscii( maNupPortrait.IsChecked() ? "true" : "false" ) ); - #endif } PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) @@ -650,13 +587,11 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetMultipage() ); @@ -670,8 +605,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetPageCount() > 0 ) + maFirstPageSize = maPController->getPageFile( 0, aMtf, true ); + } + return maFirstPageSize; +} + void PrintDialog::updateNup() { - int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); - int nCols = int(maNUpPage.maNupColEdt.GetValue()); - int nRepeat = int(maNUpPage.maNupRepEdt.GetValue()); + int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); + int nCols = int(maNUpPage.maNupColEdt.GetValue()); + long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM ))); + long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM ))); PrinterController::MultiPageSetup aMPS; aMPS.nRows = nRows; aMPS.nColumns = nCols; - aMPS.nRepeat = nRepeat; - aMPS.aPaperSize = maNUpPage.maNupPortrait.IsChecked() - ? maNupPortraitSize : maNupLandscapeSize; - aMPS.nLeftMargin = long(maNUpPage.maLeftMarginEdt.Denormalize(maNUpPage.maLeftMarginEdt.GetValue( FUNIT_100TH_MM ))); - aMPS.nTopMargin = long(maNUpPage.maTopMarginEdt.Denormalize(maNUpPage.maTopMarginEdt.GetValue( FUNIT_100TH_MM ))); - aMPS.nRightMargin = long(maNUpPage.maRightMarginEdt.Denormalize(maNUpPage.maRightMarginEdt.GetValue( FUNIT_100TH_MM ))); - aMPS.nBottomMargin = long(maNUpPage.maBottomMarginEdt.Denormalize(maNUpPage.maBottomMarginEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nRepeat = 1; + aMPS.nLeftMargin = + aMPS.nTopMargin = + aMPS.nRightMargin = + aMPS.nBottomMargin = nSheetMargin; - aMPS.nHorizontalSpacing = long(maNUpPage.maHSpaceEdt.Denormalize(maNUpPage.maHSpaceEdt.GetValue( FUNIT_100TH_MM ))); - aMPS.nVerticalSpacing = long(maNUpPage.maVSpaceEdt.Denormalize(maNUpPage.maVSpaceEdt.GetValue( FUNIT_100TH_MM ))); + aMPS.nHorizontalSpacing = + aMPS.nVerticalSpacing = nPageMargin; aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); + int nOrientationMode = int(maNUpPage.maNupOrientationBox.GetEntryData( + maNUpPage.maNupOrientationBox.GetSelectEntryPos() )); + if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE ) + { + aMPS.aPaperSize = maNupLandscapeSize; + } + else if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT ) + { + aMPS.aPaperSize = maNupPortraitSize; + } + else // automatic mode + { + // get size of first real page to see if it is portrait or landscape + // we assume same page sizes for all the pages for this + Size aPageSize = getJobPageSize(); + + Size aMultiSize( aPageSize.Width() * nCols, aPageSize.Height() * nRows ); + if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape + aMPS.aPaperSize = maNupLandscapeSize; + else + aMPS.aPaperSize = maNupPortraitSize; + } + maPController->setMultipage( aMPS ); preparePreview( true, true ); @@ -1494,6 +1461,52 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) // update text fields updatePrinterText(); } + else if( pBox == &maNUpPage.maNupOrientationBox ) + { + updateNup(); + } + else if( pBox == &maNUpPage.maNupPagesBox ) + { + long nPages = long(maNUpPage.maNupPagesBox.GetEntryData(maNUpPage.maNupPagesBox.GetSelectEntryPos())); + int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); + int nCols = int(maNUpPage.maNupColEdt.GetValue()); + bool bCustom = false; + + if( nPages == 1 ) + nRows = nCols = 1; + else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 ) + { + Size aJobPageSize( getJobPageSize() ); + bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height(); + if( nPages == 2 ) + { + if( bPortrait ) + nRows = 1, nCols = 2; + else + nRows = 2, nCols = 1; + } + else if( nPages == 4 ) + nRows = nCols = 2; + else if( nPages == 6 ) + { + if( bPortrait ) + nRows = 2, nCols = 3; + else + nRows = 3, nCols = 2; + } + else if( nPages == 9 ) + nRows = nCols = 3; + else if( nPages == 16 ) + nRows = nCols = 4; + } + else + bCustom = true; + + maNUpPage.maNupRowsEdt.SetValue( nRows ); + maNUpPage.maNupColEdt.SetValue( nCols ); + updateNup(); + } + return 0; } @@ -1530,7 +1543,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maPController->getPrinter()->Setup( this ); } checkControlDependencies(); - if( pButton == &maNUpPage.maNupPortrait || pButton == &maNUpPage.maNupLandscape || pButton == &maNUpPage.maBorderCB ) + if( pButton == &maNUpPage.maBorderCB ) updateNup(); } return 0; @@ -1539,10 +1552,8 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) { checkControlDependencies(); - if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt || pEdit == &maNUpPage.maNupRepEdt || - pEdit == &maNUpPage.maLeftMarginEdt || pEdit == &maNUpPage.maTopMarginEdt || - pEdit == &maNUpPage.maRightMarginEdt || pEdit == &maNUpPage.maBottomMarginEdt || - pEdit == &maNUpPage.maHSpaceEdt || pEdit == &maNUpPage.maVSpaceEdt + if( pEdit == &maNUpPage.maNupRowsEdt || pEdit == &maNUpPage.maNupColEdt || + pEdit == &maNUpPage.maSheetMarginEdt || pEdit == &maNUpPage.maPageMarginEdt ) { updateNup(); From 93e111d0778d7555df7b5a01042183687595f872 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 27 Jul 2009 18:42:13 +0000 Subject: [PATCH 135/283] #i92518# adapting new UX spec --- vcl/inc/vcl/arrange.hxx | 5 ++++ vcl/inc/vcl/print.hxx | 4 +-- vcl/inc/vcl/prndlg.hxx | 4 +++ vcl/inc/vcl/svids.hrc | 2 ++ vcl/source/control/button.cxx | 7 ++++-- vcl/source/src/print.src | 11 ++++++++ vcl/source/window/arrange.cxx | 44 ++++++++++++++++++++++++++------ vcl/source/window/printdlg.cxx | 46 ++++++++++++++++++++++++++++++---- 8 files changed, 106 insertions(+), 17 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 54727d24755b..b4e32350d685 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -60,11 +60,13 @@ namespace vcl boost::shared_ptr m_pChild; sal_Int32 m_nExpandPriority; Size m_aMinSize; + bool m_bHidden; Element() : m_pElement( NULL ) , m_pChild() , m_nExpandPriority( 0 ) + , m_bHidden( false ) {} Element( Window* i_pWin, @@ -74,6 +76,7 @@ namespace vcl : m_pElement( i_pWin ) , m_pChild( i_pChild ) , m_nExpandPriority( i_nExpandPriority ) + , m_bHidden( false ) {} void deleteChild() { m_pChild.reset(); } @@ -147,6 +150,8 @@ namespace vcl return pEle != NULL; } + void show( bool i_bShow = true, bool i_bImmediateUpdate = true ); + void setManagedArea( const Rectangle& i_rArea ) { m_aManagedArea = i_rArea; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 0241168bba0a..a6563d2b75ed 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -419,8 +419,8 @@ public: MultiPageSetup() : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) - , nLeftMargin( 0 ), nTopMargin( 0 ) - , nRightMargin( 0 ), nBottomMargin( 0 ) + , nLeftMargin( 500 ), nTopMargin( 500 ) + , nRightMargin( 500 ), nBottomMargin( 500 ) , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) , bDrawBorder( true ) { diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 6a8974ccb966..3f2fa7d3eb3b 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -96,6 +96,7 @@ namespace vcl CheckBox maBorderCB; vcl::RowOrColumn maLayout; + boost::shared_ptr< vcl::WindowArranger >mxAdvancedControls; void setupLayout(); @@ -114,6 +115,8 @@ namespace vcl public: FixedLine maPrinterFL; ListBox maPrinters; + PushButton maDetailsBtn; + FixedText maDetailsTxt; FixedText maStatusLabel; FixedText maStatusTxt; FixedText maLocationLabel; @@ -139,6 +142,7 @@ namespace vcl vcl::RowOrColumn maLayout; boost::shared_ptr mxPrintRange; + boost::shared_ptr mxDetails; JobTabPage( Window*, const ResId& ); virtual ~JobTabPage(); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index ed7f16cfb17c..9e24cffe48a1 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -135,6 +135,8 @@ #define SV_PRINT_STATUS_TXT 20 #define SV_PRINT_LOCATION_TXT 21 #define SV_PRINT_COMMENT_TXT 22 +#define SV_PRINT_DETAILS_BTN 23 +#define SV_PRINT_DETAILS_TXT 24 #define SV_PRINT_TAB_OPT 3 #define SV_PRINT_OPT_PRINT_FL 1 diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 2e2342fc6fc8..852e7983ac06 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1991,8 +1991,11 @@ Size PushButton::CalcMinimumSize( long nMaxWidth ) const } // cf. ImplDrawPushButton ... - aSize.Width() += 8; - aSize.Height() += 8; + if( (GetStyle() & WB_SMALLSTYLE) == 0 ) + { + aSize.Width() += 8; + aSize.Height() += 8; + } return CalcWindowSize( aSize ); } diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 600a690ef23d..63d5bc6047c5 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -266,6 +266,17 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 100, 80 ); Border = TRUE; }; + PushButton SV_PRINT_DETAILS_BTN + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 5, 5 ); + }; + FixedText SV_PRINT_DETAILS_TXT + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "Printer details"; + }; FixedText SV_PRINT_STATUS_TXT { Pos = MAP_APPFONT( 5, 5 ); diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 4f03706b4264..e392a1cc7d5e 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -53,6 +53,31 @@ void WindowArranger::setParent( WindowArranger* i_pParent ) setParentWindow( m_pParentWindow ); } +void WindowArranger::show( bool i_bShow, bool i_bImmediateUpdate ) +{ + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + Element* pEle = getElement( i ); + if( pEle ) // sanity check + { + pEle->m_bHidden = ! i_bShow; + if( pEle->m_pElement ) + pEle->m_pElement->Show( i_bShow ); + if( pEle->m_pChild.get() ) + pEle->m_pChild->show( i_bShow, false ); + } + } + if( i_bImmediateUpdate ) + { + // find the topmost parent + WindowArranger* pResize = this; + while( pResize->m_pParentArranger ) + pResize = pResize->m_pParentArranger; + pResize->resize(); + } +} + sal_Int32 WindowArranger::Element::getExpandPriority() const { sal_Int32 nPrio = m_nExpandPriority; @@ -72,14 +97,17 @@ sal_Int32 WindowArranger::Element::getExpandPriority() const Size WindowArranger::Element::getOptimalSize( WindowSizeType i_eType ) const { Size aResult; - if( m_pElement ) - aResult = m_pElement->GetOptimalSize( i_eType ); - else if( m_pChild ) - aResult = m_pChild->getOptimalSize( i_eType ); - if( aResult.Width() < m_aMinSize.Width() ) - aResult.Width() = m_aMinSize.Width(); - if( aResult.Height() < m_aMinSize.Height() ) - aResult.Height() = m_aMinSize.Height(); + if( ! m_bHidden ) + { + if( m_pElement && m_pElement->IsVisible() ) + aResult = m_pElement->GetOptimalSize( i_eType ); + else if( m_pChild ) + aResult = m_pChild->getOptimalSize( i_eType ); + if( aResult.Width() < m_aMinSize.Width() ) + aResult.Width() = m_aMinSize.Width(); + if( aResult.Height() < m_aMinSize.Height() ) + aResult.Height() = m_aMinSize.Height(); + } return aResult; } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index dd618766451c..79cb63cbfa3d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -228,6 +228,9 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( &maLayout ) ); maLayout.addChild( xIndent ); + // remember advanced controls to show/hide + mxAdvancedControls = xIndent; + boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); @@ -259,6 +262,9 @@ void PrintDialog::NUpTabPage::setupLayout() xRow->addWindow( &maNupOrderBox ); maLayout.addWindow( &maBorderCB ); + + // initially advanced controls are not show, rows=columns=1 + mxAdvancedControls->show( false, false ); } void PrintDialog::NUpTabPage::Resize() @@ -287,6 +293,8 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maPrinterFL( this, VclResId( SV_PRINT_PRINTERS_FL ) ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS ) ) + , maDetailsBtn( this, VclResId( SV_PRINT_DETAILS_BTN ) ) + , maDetailsTxt( this, VclResId( SV_PRINT_DETAILS_TXT ) ) , maStatusLabel( this, VclResId( SV_PRINT_STATUS_TXT ) ) , maStatusTxt( this, 0 ) , maLocationLabel( this, VclResId( SV_PRINT_LOCATION_TXT ) ) @@ -351,9 +359,25 @@ void PrintDialog::JobTabPage::setupLayout() // add print LB maLayout.addWindow( &maPrinters ); + // create a row for details button/text and properties button + boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) ); + maLayout.addChild( xDetRow ); + xDetRow->addWindow( &maDetailsBtn ); + xDetRow->addWindow( &maDetailsTxt ); + xDetRow->addChild( new vcl::Spacer( xDetRow.get(), 2 ) ); + xDetRow->addWindow( &maSetupButton ); + + // create an indent for details + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( &maLayout ) ); + maLayout.addChild( xIndent ); + // remember details controls + mxDetails = xIndent; + // create a column for the details + boost::shared_ptr< vcl::RowOrColumn > xDetCol( new vcl::RowOrColumn( xIndent.get() ) ); + xIndent->setChild( xDetCol ); // create a row for stati and properties button - boost::shared_ptr< vcl::RowOrColumn > xStateRow( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xStateRow ); + boost::shared_ptr< vcl::RowOrColumn > xStateRow( new vcl::RowOrColumn( xDetCol.get(), false ) ); + xDetCol->addChild( xStateRow ); boost::shared_ptr< vcl::RowOrColumn > xLabelCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) ); xStateRow->addChild( xLabelCol ); xLabelCol->addWindow( &maStatusLabel ); @@ -366,8 +390,6 @@ void PrintDialog::JobTabPage::setupLayout() xStatusCol->addWindow( &maLocationTxt ); xStatusCol->addWindow( &maCommentTxt ); - xStateRow->addWindow( &maSetupButton ); - // add print range and copies columns maLayout.addWindow( &maCopies ); boost::shared_ptr< vcl::RowOrColumn > xRangeRow( new vcl::RowOrColumn( &maLayout, false, aBorder.Width() ) ); @@ -390,6 +412,11 @@ void PrintDialog::JobTabPage::setupLayout() xCopyCollateCol->addChild( xCollateRow ); xCollateRow->addWindow( &maCollateBox ); xCollateRow->addWindow( &maCollateImage ); + + maDetailsBtn.SetSymbol( SYMBOL_SPIN_DOWN ); + maDetailsBtn.SetSmallSymbol(); + maDetailsBtn.SetStyle( maDetailsBtn.GetStyle() | (WB_SMALLSTYLE | WB_BEVELBUTTON) ); + mxDetails->show( false, false ); } void PrintDialog::JobTabPage::readFromSettings() @@ -605,6 +632,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrGetSelectEntry() ); - maJobPage.maPrinters.SelectEntry( aNewPrinter ); // set new printer maPController->setPrinter( boost::shared_ptr( new Printer( aNewPrinter ) ) ); // update text fields @@ -1505,6 +1534,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) maNUpPage.maNupRowsEdt.SetValue( nRows ); maNUpPage.maNupColEdt.SetValue( nCols ); updateNup(); + maNUpPage.mxAdvancedControls->show( bCustom ); } return 0; @@ -1530,6 +1560,12 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); maLayout.resize(); } + else if( pButton == &maJobPage.maDetailsBtn ) + { + bool bShow = ! maJobPage.maStatusTxt.IsVisible(); + maJobPage.maDetailsBtn.SetSymbol( bShow ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN ); + maJobPage.mxDetails->show( bShow ); + } else if( pButton == &maJobPage.maCollateBox ) { maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ), From d5f589e89e11326a62312647db3052d52f07de62 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 28 Jul 2009 11:54:16 +0000 Subject: [PATCH 136/283] #i92518# need sensible defaults for N-Up printing --- vcl/inc/vcl/print.hxx | 6 +++--- vcl/source/window/printdlg.cxx | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index a6563d2b75ed..5282be1bb5ed 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -419,10 +419,10 @@ public: MultiPageSetup() : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) - , nLeftMargin( 500 ), nTopMargin( 500 ) - , nRightMargin( 500 ), nBottomMargin( 500 ) + , nLeftMargin( 0 ), nTopMargin( 0 ) + , nRightMargin( 0 ), nBottomMargin( 0 ) , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) - , bDrawBorder( true ) + , bDrawBorder( false ) { } }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 79cb63cbfa3d..1a13d2ebca52 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1499,10 +1499,15 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) long nPages = long(maNUpPage.maNupPagesBox.GetEntryData(maNUpPage.maNupPagesBox.GetSelectEntryPos())); int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); int nCols = int(maNUpPage.maNupColEdt.GetValue()); + long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM ))); + long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM ))); bool bCustom = false; if( nPages == 1 ) + { nRows = nCols = 1; + nSheetMargin = 0; + } else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 ) { Size aJobPageSize( getJobPageSize() ); @@ -1527,12 +1532,16 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) nRows = nCols = 3; else if( nPages == 16 ) nRows = nCols = 4; + nPageMargin = 500; + nSheetMargin = 500; } else bCustom = true; maNUpPage.maNupRowsEdt.SetValue( nRows ); maNUpPage.maNupColEdt.SetValue( nCols ); + maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM ); + maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM ); updateNup(); maNUpPage.mxAdvancedControls->show( bCustom ); } From 6c352e02d29d4da91d3c9a5c4add344b8696faed Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 28 Jul 2009 19:01:04 +0000 Subject: [PATCH 137/283] #i92518# adapt UI spec --- vcl/inc/vcl/arrange.hxx | 1 + vcl/inc/vcl/print.hxx | 48 ++++++++----- vcl/inc/vcl/prndlg.hxx | 1 + vcl/source/gdi/print3.cxx | 122 ++++++++++++++++----------------- vcl/source/window/arrange.cxx | 63 ++++++++++++----- vcl/source/window/printdlg.cxx | 95 +++++++++++++++---------- 6 files changed, 196 insertions(+), 134 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index b4e32350d685..3ef93311ee58 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -83,6 +83,7 @@ namespace vcl sal_Int32 getExpandPriority() const; Size getOptimalSize( WindowSizeType ) const; + bool isVisible() const; }; Window* m_pParentWindow; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 5282be1bb5ed..dd276e76c760 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -547,17 +547,34 @@ class VCL_DLLPUBLIC PrinterOptionsHelper { return getStringValue( rtl::OUString::createFromAscii( i_pPropName ), i_rDefault ); } // helper functions for user to create a single control + struct UIControlOptions + { + rtl::OUString maDependsOnName; + sal_Int32 mnDependsOnEntry; + sal_Bool mbAttachToDependency; + rtl::OUString maGroupHint; + sal_Bool mbInternalOnly; + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps; + + UIControlOptions( const rtl::OUString& i_rDependsOnName = rtl::OUString(), + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False, + const rtl::OUString& i_rGroupHint = rtl::OUString(), + sal_Bool i_bInternalOnly = sal_False + ) + : maDependsOnName( i_rDependsOnName ) + , mnDependsOnEntry( i_nDependsOnEntry ) + , mbAttachToDependency( i_bAttachToDependency ) + , maGroupHint( i_rGroupHint ) + , mbInternalOnly( sal_False ) {} + }; // general control static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpText, const rtl::OUString& i_rType, const com::sun::star::beans::PropertyValue* i_pValue = NULL, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1, - sal_Bool i_bAttachToDependency = sal_False, - const com::sun::star::beans::PropertyValue* i_pAddProps = NULL, - sal_Int32 i_nAddProps = 0 + const UIControlOptions& i_rControlOptions = UIControlOptions() ); // create a group (e.g. a TabPage); following controls will be grouped in it until the next // group begins @@ -566,16 +583,17 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // create a subgroup (e.g. a FixedLine); following controls will be grouped in it until the next // subgroup or group begins // setting bJobPage = true will make the subgroup appear on the first page of the print dialog - static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, const rtl::OUString& i_rGroupHint = rtl::OUString(), bool i_bInternalOnly = false ); + static com::sun::star::uno::Any getSubgroupControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); // create a bool option (usually a checkbox) static com::sun::star::uno::Any getBoolControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1, - sal_Bool i_bAttachToDependency = sal_False + const UIControlOptions& i_rControlOptions = UIControlOptions() ); // create a set of choices (either a radio button group or a list box) @@ -585,9 +603,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const com::sun::star::uno::Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, const rtl::OUString& i_rType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ), - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1, - sal_Bool i_bAttachToDependency = sal_False + const UIControlOptions& i_rControlOptions = UIControlOptions() ); // create an integer range (e.g. a spin field) @@ -598,9 +614,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper sal_Int32 i_nValue, sal_Int32 i_nMinValue = -1, sal_Int32 i_nMaxValue = -2, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1, - sal_Bool i_bAttachToDependency = sal_False + const UIControlOptions& i_rControlOptions = UIControlOptions() ); // create a string field @@ -609,9 +623,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, const rtl::OUString& i_rValue, - const rtl::OUString* i_pDependsOnName = NULL, - sal_Int32 i_nDependsOnEntry = -1, - sal_Bool i_bAttachToDependency = sal_False + const UIControlOptions& i_rControlOptions = UIControlOptions() ); }; diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 3f2fa7d3eb3b..5af1c85cbba6 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -164,6 +164,7 @@ namespace vcl CheckBox maReverseOrderBox; vcl::RowOrColumn maLayout; + boost::shared_ptr mxOptGroup; OutputOptPage( Window*, const ResId& ); virtual ~OutputOptPage(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 53326cb3efbd..64e7bf0c5576 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1195,11 +1195,7 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, const Sequence< rtl::OUString >& i_rHelpTexts, const rtl::OUString& i_rType, const PropertyValue* i_pVal, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry, - sal_Bool i_bAttachToDependency, - const PropertyValue* i_pAddProps, - sal_Int32 i_nAddProps + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { sal_Int32 nElements = @@ -1207,10 +1203,18 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + (i_rTitle.getLength() ? 1 : 0) // Text + (i_rHelpTexts.getLength() ? 1 : 0) // HelpText + (i_pVal ? 1 : 0) // Property - + (i_pDependsOnName ? (i_nDependsOnEntry != -1 ? 2 : 1) : 0) // dependencies - + (i_pDependsOnName && i_bAttachToDependency ? 1 : 0) // attach to dependency - + i_nAddProps + + i_rControlOptions.maAddProps.getLength() // additional props + + (i_rControlOptions.maGroupHint.getLength() ? 1 : 0) // grouping + + (i_rControlOptions.mbInternalOnly ? 1 : 0) // internal hint ; + if( i_rControlOptions.maDependsOnName.getLength() ) + { + nElements += 1; + if( i_rControlOptions.mnDependsOnEntry != -1 ) + nElements += 1; + if( i_rControlOptions.mbAttachToDependency ) + nElements += 1; + } Sequence< PropertyValue > aCtrl( nElements ); sal_Int32 nUsed = 0; @@ -1231,23 +1235,35 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property" ) ); aCtrl[nUsed++].Value = makeAny( *i_pVal ); } - if( i_pDependsOnName ) + if( i_rControlOptions.maDependsOnName.getLength() ) { aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnName" ) ); - aCtrl[nUsed++].Value = makeAny( *i_pDependsOnName ); - if( i_nDependsOnEntry != -1 ) + aCtrl[nUsed++].Value = makeAny( i_rControlOptions.maDependsOnName ); + if( i_rControlOptions.mnDependsOnEntry != -1 ) { aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DependsOnEntry" ) ); - aCtrl[nUsed++].Value = makeAny( i_nDependsOnEntry ); + aCtrl[nUsed++].Value = makeAny( i_rControlOptions.mnDependsOnEntry ); } - if( i_bAttachToDependency ) + if( i_rControlOptions.mbAttachToDependency ) { aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AttachToDependency" ) ); - aCtrl[nUsed++].Value = makeAny( i_bAttachToDependency ); + aCtrl[nUsed++].Value = makeAny( i_rControlOptions.mbAttachToDependency ); } } - for( sal_Int32 i = 0; i < i_nAddProps; i++ ) - aCtrl[ nUsed++ ] = i_pAddProps[i]; + if( i_rControlOptions.maGroupHint.getLength() ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GroupingHint" ) ); + aCtrl[nUsed++].Value <<= i_rControlOptions.maGroupHint; + } + if( i_rControlOptions.mbInternalOnly ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InternalUIOnly" ) ); + aCtrl[nUsed++].Value <<= sal_True; + } + + sal_Int32 nAddProps = i_rControlOptions.maAddProps.getLength(); + for( sal_Int32 i = 0; i < nAddProps; i++ ) + aCtrl[ nUsed++ ] = i_rControlOptions.maAddProps[i]; DBG_ASSERT( nUsed == nElements, "nUsed != nElements, probable heap corruption" ); @@ -1265,21 +1281,11 @@ Any PrinterOptionsHelper::getGroupControlOpt( const rtl::OUString& i_rTitle, con return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) ); } -Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, - const rtl::OUString& i_rGroupHint, bool i_bInternalOnly ) +Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, + const rtl::OUString& i_rHelpText, + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions + ) { - PropertyValue aAddProps[2]; - sal_Int32 nUsed = 0; - if( i_rGroupHint.getLength() ) - { - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GroupingHint" ) ); - aAddProps[nUsed++].Value <<= i_rGroupHint; - } - if( i_bInternalOnly ) - { - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InternalUIOnly" ) ); - aAddProps[nUsed++].Value <<= sal_True; - } Sequence< rtl::OUString > aHelpText; if( i_rHelpText.getLength() > 0 ) { @@ -1287,16 +1293,14 @@ Any PrinterOptionsHelper::getSubgroupControlOpt( const rtl::OUString& i_rTitle, *aHelpText.getArray() = i_rHelpText; } return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Subgroup" ) ), - NULL, NULL, -1, sal_False, aAddProps, nUsed ); + NULL, i_rControlOptions ); } Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, sal_Bool i_bValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry, - sal_Bool i_bAttachToDependency + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { Sequence< rtl::OUString > aHelpText; @@ -1308,7 +1312,7 @@ Any PrinterOptionsHelper::getBoolControlOpt( const rtl::OUString& i_rTitle, PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_bValue ); - return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, i_pDependsOnName, i_nDependsOnEntry, i_bAttachToDependency ); + return getUIControlOpt( i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bool" ) ), &aVal, i_rControlOptions ); } Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, @@ -1317,20 +1321,19 @@ Any PrinterOptionsHelper::getChoiceControlOpt( const rtl::OUString& i_rTitle, const Sequence< rtl::OUString >& i_rChoices, sal_Int32 i_nValue, const rtl::OUString& i_rType, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry, - sal_Bool i_bAttachToDependency + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { - PropertyValue aAddProps[2]; - sal_Int32 nUsed = 0; - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); - aAddProps[nUsed++].Value = makeAny( i_rChoices ); + UIControlOptions aOpt( i_rControlOptions ); + sal_Int32 nUsed = aOpt.maAddProps.getLength(); + aOpt.maAddProps.realloc( nUsed + 1 ); + aOpt.maAddProps[nUsed].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Choices" ) ); + aOpt.maAddProps[nUsed].Value = makeAny( i_rChoices ); PropertyValue aVal; aVal.Name = i_rProperty; aVal.Value = makeAny( i_nValue ); - return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, i_pDependsOnName, i_nDependsOnEntry, i_bAttachToDependency, aAddProps, nUsed ); + return getUIControlOpt( i_rTitle, i_rHelpText, i_rType, &aVal, aOpt ); } Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, @@ -1339,19 +1342,18 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, sal_Int32 i_nValue, sal_Int32 i_nMinValue, sal_Int32 i_nMaxValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry, - sal_Bool i_bAttachToDependency + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { - PropertyValue aAddProps[2]; - sal_Int32 nUsed = 0; + UIControlOptions aOpt( i_rControlOptions ); if( i_nMaxValue >= i_nMinValue ) { - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinValue" ) ); - aAddProps[nUsed++].Value = makeAny( i_nMinValue ); - aAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxValue" ) ); - aAddProps[nUsed++].Value = makeAny( i_nMaxValue ); + sal_Int32 nUsed = aOpt.maAddProps.getLength(); + aOpt.maAddProps.realloc( nUsed + 2 ); + aOpt.maAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinValue" ) ); + aOpt.maAddProps[nUsed++].Value = makeAny( i_nMinValue ); + aOpt.maAddProps[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxValue" ) ); + aOpt.maAddProps[nUsed++].Value = makeAny( i_nMaxValue ); } Sequence< rtl::OUString > aHelpText; @@ -1367,19 +1369,15 @@ Any PrinterOptionsHelper::getRangeControlOpt( const rtl::OUString& i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Range" ) ), &aVal, - i_pDependsOnName, - i_nDependsOnEntry, - i_bAttachToDependency, - aAddProps, nUsed ); + aOpt + ); } Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, const rtl::OUString& i_rHelpText, const rtl::OUString& i_rProperty, const rtl::OUString& i_rValue, - const rtl::OUString* i_pDependsOnName, - sal_Int32 i_nDependsOnEntry, - sal_Bool i_bAttachToDependency + const PrinterOptionsHelper::UIControlOptions& i_rControlOptions ) { Sequence< rtl::OUString > aHelpText; @@ -1395,8 +1393,6 @@ Any PrinterOptionsHelper::getEditControlOpt( const rtl::OUString& i_rTitle, aHelpText, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Edit" ) ), &aVal, - i_pDependsOnName, - i_nDependsOnEntry, - i_bAttachToDependency, - 0, 0 ); + i_rControlOptions + ); } diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index e392a1cc7d5e..ae578f8e5337 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -68,6 +68,19 @@ void WindowArranger::show( bool i_bShow, bool i_bImmediateUpdate ) pEle->m_pChild->show( i_bShow, false ); } } + if( m_pParentArranger ) + { + nEle = m_pParentArranger->countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + Element* pEle = m_pParentArranger->getElement( i ); + if( pEle && pEle->m_pChild.get() == this ) + { + pEle->m_bHidden = ! i_bShow; + break; + } + } + } if( i_bImmediateUpdate ) { // find the topmost parent @@ -78,6 +91,18 @@ void WindowArranger::show( bool i_bShow, bool i_bImmediateUpdate ) } } +bool WindowArranger::Element::isVisible() const +{ + bool bVisible = false; + if( ! m_bHidden ) + { + bVisible = true; + if( m_pElement ) + bVisible = m_pElement->IsVisible(); + } + return bVisible; +} + sal_Int32 WindowArranger::Element::getExpandPriority() const { sal_Int32 nPrio = m_nExpandPriority; @@ -178,19 +203,22 @@ void RowOrColumn::distributeRowWidth( std::vector& io_rSizes, long /*i_nUs sal_Int32 nHighPrio = 0; for( size_t i = 0; i < nElements; i++ ) { - sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); - if( nCurPrio > nHighPrio ) + if( m_aElements[ i ].isVisible() ) { - aIndices.clear(); - nHighPrio = nCurPrio; + sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); + if( nCurPrio > nHighPrio ) + { + aIndices.clear(); + nHighPrio = nCurPrio; + } + if( nCurPrio == nHighPrio ) + aIndices.push_back( i ); } - if( nCurPrio == nHighPrio ) - aIndices.push_back( i ); } - // distribute extra space evenly among elements + // distribute extra space evenly among collected elements nElements = aIndices.size(); - if( nElements > 0 ) // sanity check + if( nElements > 0 ) { long nDelta = i_nExtraWidth / nElements; for( size_t i = 0; i < nElements; i++ ) @@ -215,19 +243,22 @@ void RowOrColumn::distributeColumnHeight( std::vector& io_rSizes, long /*i sal_Int32 nHighPrio = 3; for( size_t i = 0; i < nElements; i++ ) { - sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); - if( nCurPrio > nHighPrio ) + if( m_aElements[ i ].isVisible() ) { - aIndices.clear(); - nHighPrio = nCurPrio; + sal_Int32 nCurPrio = m_aElements[ i ].getExpandPriority(); + if( nCurPrio > nHighPrio ) + { + aIndices.clear(); + nHighPrio = nCurPrio; + } + if( nCurPrio == nHighPrio ) + aIndices.push_back( i ); } - if( nCurPrio == nHighPrio ) - aIndices.push_back( i ); } - // distribute extra space evenly among elements + // distribute extra space evenly among collected elements nElements = aIndices.size(); - if( nElements > 0 ) // sanity check + if( nElements > 0 ) { long nDelta = i_nExtraHeight / nElements; for( size_t i = 0; i < nElements; i++ ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1a13d2ebca52..81fa42cc064c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -498,6 +498,7 @@ void PrintDialog::OutputOptPage::setupLayout() maLayout.addChild( xIndent ); boost::shared_ptr xCol( new vcl::RowOrColumn( xIndent.get(), aBorder.Height() ) ); xIndent->setChild( xCol ); + mxOptGroup = xCol; xCol->addWindow( &maToFileBox ); xCol->addWindow( &maCollateSingleJobsBox ); xCol->addWindow( &maReverseOrderBox ); @@ -829,6 +830,7 @@ void PrintDialog::setupOptionalUI() Window* pCurParent = 0, *pDynamicPageParent = 0; USHORT nOptPageId = 9, nCurSubGroup = 0; bool bOnStaticPage = false; + bool bSubgroupOnStaticPage = false; std::multimap< rtl::OUString, vcl::RowOrColumn* > aPropertyToDependencyRowMap; @@ -917,6 +919,52 @@ void PrintDialog::setupOptionalUI() } } + // is it necessary to switch between static and dynamic pages ? + bool bSwitchPage = false; + if( aGroupingHint.getLength() ) + bSwitchPage = true; + else if( aCtrlType.equalsAscii( "Subgroup" ) || (bOnStaticPage && ! bSubgroupOnStaticPage ) ) + bSwitchPage = true; + if( bSwitchPage ) + { + // restore to dynamic + pCurParent = pDynamicPageParent; + pCurColumn = aDynamicColumns.empty() ? NULL : aDynamicColumns.back(); + bOnStaticPage = false; + bSubgroupOnStaticPage = false; + + if( aGroupingHint.equalsAscii( "PrintRange" ) ) + { + pCurColumn = maJobPage.mxPrintRange.get(); + pCurParent = &maJobPage; // set job page as current parent + bOnStaticPage = true; + } + else if( aGroupingHint.equalsAscii( "OptionsPage" ) ) + { + pCurColumn = &maOptionsPage.maLayout; + pCurParent = &maOptionsPage; // set options page as current parent + bOnStaticPage = true; + } + else if( aGroupingHint.equalsAscii( "OptionsPageOptGroup" ) ) + { + pCurColumn = maOptionsPage.mxOptGroup.get(); + pCurParent = &maOptionsPage; // set options page as current parent + bOnStaticPage = true; + } + else if( aGroupingHint.equalsAscii( "LayoutPage" ) ) + { + pCurColumn = &maNUpPage.maLayout; + pCurParent = &maNUpPage; // set layout page as current parent + bOnStaticPage = true; + } + else if( aGroupingHint.getLength() ) + { + pCurColumn = &maJobPage.maLayout; + pCurParent = &maJobPage; // set job page as current parent + bOnStaticPage = true; + } + } + if( aCtrlType.equalsAscii( "Group" ) || ( ! pCurParent && ! (bOnStaticPage || aGroupingHint.getLength() ) ) ) { @@ -940,45 +988,12 @@ void PrintDialog::setupOptionalUI() pCurColumn = aDynamicColumns.back(); pCurColumn->setParentWindow( pNewGroup ); pCurColumn->setOuterBorder( aBorder.Width() ); + bSubgroupOnStaticPage = false; + bOnStaticPage = false; } else if( aCtrlType.equalsAscii( "Subgroup" ) && (pCurParent || aGroupingHint.getLength() ) ) { - // change to job page or back if necessary - if( (bOnStaticPage && ! aGroupingHint.getLength() ) || - (! bOnStaticPage && aGroupingHint.getLength() ) ) - { - bOnStaticPage = (aGroupingHint.getLength() != 0); - if( bOnStaticPage ) - { - pDynamicPageParent = pCurParent; // save current parent - } - else - { - pCurParent = pDynamicPageParent; // set current tab page as parent - } - } - - if( bOnStaticPage ) - { - if( aGroupingHint.equalsAscii( "PrintRange" ) ) - { - pCurColumn = maJobPage.mxPrintRange.get(); - pCurParent = &maJobPage; // set job page as current parent - } - else if( aGroupingHint.equalsAscii( "OptionsPage" ) ) - { - pCurColumn = &maOptionsPage.maLayout; - pCurParent = &maOptionsPage; // set options page as current parent - } - else - { - pCurColumn = &maJobPage.maLayout; - pCurParent = &maJobPage; // set job page as current parent - } - } - else - pCurColumn = aDynamicColumns.back(); - + bSubgroupOnStaticPage = (aGroupingHint.getLength() != 0); // create group FixedLine if( ! aGroupingHint.equalsAscii( "PrintRange" ) || ! pCurColumn->countElements() == 0 @@ -1235,6 +1250,13 @@ void PrintDialog::setupOptionalUI() } } + // print range empty (currently math only) -> hide print range and spacer line + if( maJobPage.mxPrintRange->countElements() == 0 ) + { + maJobPage.mxPrintRange->show( false, false ); + maJobPage.maCopySpacer.Show( FALSE ); + } + // calculate job page Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); @@ -1405,7 +1427,6 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) boost::shared_ptr aPrt( maPController->getPrinter() ); - if( i_bNewPage ) { const MapMode aMapMode( MAP_100TH_MM ); From a155b13c1e9f7367724c0f24e1bc2ac6397be6ce Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 29 Jul 2009 09:56:25 +0000 Subject: [PATCH 138/283] fix a warning --- vcl/inc/vcl/print.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index dd276e76c760..4ceca0d9a3ef 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -566,7 +566,7 @@ class VCL_DLLPUBLIC PrinterOptionsHelper , mnDependsOnEntry( i_nDependsOnEntry ) , mbAttachToDependency( i_bAttachToDependency ) , maGroupHint( i_rGroupHint ) - , mbInternalOnly( sal_False ) {} + , mbInternalOnly( i_bInternalOnly ) {} }; // general control From 3599f931a9a021209c1ea0da8bec8d9d07664021 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 29 Jul 2009 11:48:58 +0000 Subject: [PATCH 139/283] #i92516# resize dialog if details get to large --- vcl/source/window/printdlg.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 81fa42cc064c..f2b4ceb89c00 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1595,6 +1595,15 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) bool bShow = ! maJobPage.maStatusTxt.IsVisible(); maJobPage.maDetailsBtn.SetSymbol( bShow ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN ); maJobPage.mxDetails->show( bShow ); + // enlarge dialog if necessary + Size aMinSize( maJobPage.maLayout.getOptimalSize( WINDOWSIZE_MINIMUM ) ); + Size aCurSize( maJobPage.GetSizePixel() ); + if( aCurSize.Height() < aMinSize.Height() ) + { + Size aDlgSize( GetOutputSizePixel() ); + aDlgSize.Height() += aMinSize.Height() - aCurSize.Height(); + SetOutputSizePixel( aDlgSize ); + } } else if( pButton == &maJobPage.maCollateBox ) { From 3d292304d4a5c8135558a76d1ff7e819326cff83 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 29 Jul 2009 15:36:16 +0000 Subject: [PATCH 140/283] #i92516# make native implementation more palatable --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 123 +++++++++++++----- vcl/source/src/print.src | 1 + 2 files changed, 89 insertions(+), 35 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 645de97d7ac3..f6d9ff7b7d9c 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -87,7 +87,8 @@ class ControllerProperties NSTextField* mpPageEdit; NSStepper* mpStepper; NSTextView* mpPagesLabel; - + ResStringArray maLocalizedStrings; + public: ControllerProperties( vcl::PrinterController* i_pController, NSPrintOperation* i_pOp, @@ -105,9 +106,18 @@ class ControllerProperties mpPreview( nil ), mpPageEdit( nil ), mpStepper( nil ), - mpPagesLabel( nil ) + mpPagesLabel( nil ), + maLocalizedStrings( VclResId( SV_PRINT_NATIVE_STRINGS ) ) { mpState->bNeedRestart = false; + DBG_ASSERT( maLocalizedStrings.Count() >= 4, "resources not found !" ); + } + + rtl::OUString getMoreString() + { + return maLocalizedStrings.Count() >= 4 + ? rtl::OUString( maLocalizedStrings.GetString( 3 ) ) + : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "More" ) ); } void updatePrintJob() @@ -131,7 +141,7 @@ class ControllerProperties { #if 0 // Warning: bad hack ahead - // Apple does not give as a chance of changing the page count, + // Apple does not give us a chance of changing the page count, // and they don't let us cancel the dialog either // hack: send a cancel message to the window displaying our views. // this is ugly. @@ -324,11 +334,7 @@ class ControllerProperties void setupPreview( ControlTarget* i_pCtrlTarget ) { - // get some needed resources - ResStringArray aStrings( VclResId( SV_PRINT_NATIVE_STRINGS ) ); - - DBG_ASSERT( aStrings.Count() >= 3, "resources not found !" ); - if( aStrings.Count() < 3 ) + if( maLocalizedStrings.Count() < 3 ) return; // get the preview control @@ -340,7 +346,7 @@ class ControllerProperties // create a box to put the preview controls in mpPreviewBox = [[NSBox alloc] initWithFrame: aPreviewFrame]; - [mpPreviewBox setTitle: [CreateNSString( aStrings.GetString( 0 ) ) autorelease]]; + [mpPreviewBox setTitle: [CreateNSString( maLocalizedStrings.GetString( 0 ) ) autorelease]]; [mpAccessoryView addSubview: [mpPreviewBox autorelease]]; // now create the image view of the preview @@ -368,7 +374,7 @@ class ControllerProperties [mpPagesLabel setSelectable: NO]; [mpPagesLabel setDrawsBackground: NO]; [mpPagesLabel setString: [pText autorelease]]; - [mpPagesLabel setToolTip: [CreateNSString( aStrings.GetString( 2 ) ) autorelease]]; + [mpPagesLabel setToolTip: [CreateNSString( maLocalizedStrings.GetString( 2 ) ) autorelease]]; [mpPreviewBox addSubview: [mpPagesLabel autorelease]]; NSRect aFieldRect = { { 45, 5 }, { 35, 25 } }; @@ -376,7 +382,7 @@ class ControllerProperties [mpPageEdit setEditable: YES]; [mpPageEdit setSelectable: YES]; [mpPageEdit setDrawsBackground: YES]; - [mpPageEdit setToolTip: [CreateNSString( aStrings.GetString( 1 ) ) autorelease]]; + [mpPageEdit setToolTip: [CreateNSString( maLocalizedStrings.GetString( 1 ) ) autorelease]]; [mpPreviewBox addSubview: [mpPageEdit autorelease]]; // add a stepper control @@ -570,6 +576,37 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) rMaxSize.height = aUnion.size.height; } +static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) +{ + // loop over all contained tab pages + NSArray* pTabbedViews = [pTabView tabViewItems]; + int nViews = [pTabbedViews count]; + for( int i = 0; i < nViews; i++ ) + { + NSTabViewItem* pItem = (NSTabViewItem*)[pTabbedViews objectAtIndex: i]; + NSView* pView = [pItem view]; + if( pView ) + { + NSRect aRect = [pView frame]; + double nDiff = aTabSize.height - aRect.size.height; + aRect.size = aTabSize; + [pView setFrame: aRect]; + + NSArray* pSubViews = [pView subviews]; + unsigned int nSubViews = [pSubViews count]; + + // move everything up + for( unsigned int n = 0; n < nSubViews; n++ ) + { + NSView* pCurSubView = [pSubViews objectAtIndex: n]; + NSRect aFrame = [pCurSubView frame]; + aFrame.origin.y += nDiff; + [pCurSubView setFrame: aFrame]; + } + } + } +} + @implementation AquaPrintAccessoryView +(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withController: (vcl::PrinterController*)pController withState: (PrintAccessoryViewState*)pState; @@ -664,8 +701,14 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) { // since our build target is MacOSX 10.4 we can have only one accessory view // so we have a single accessory view that is tabbed for grouping - if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent ) + if( aCtrlType.equalsAscii( "Group" ) + || ! pCurParent + || ( aCtrlType.equalsAscii( "Subgroup" ) && nCurY < -200 && ! bIgnore ) + ) { + rtl::OUString aGroupTitle( aText ); + if( aCtrlType.equalsAscii( "Subgroup" ) ) + aGroupTitle = pControllerProperties->getMoreString(); // set size of current parent if( pCurParent ) adjustViewAndChildren( pCurParent, aMaxTabSize ); @@ -673,7 +716,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // new tab item if( ! aText.getLength() ) aText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OOo" ) ); - NSString* pLabel = CreateNSString( aText ); + NSString* pLabel = CreateNSString( aGroupTitle ); NSTabViewItem* pItem = [[NSTabViewItem alloc] initWithIdentifier: pLabel ]; [pItem setLabel: pLabel]; [pTabView addTabViewItem: pItem]; @@ -682,7 +725,9 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) [pLabel release]; // reset indent - nCurX = 0; + nCurX = 20; + // reset Y + nCurY = 0; } if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) @@ -690,6 +735,19 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) bIgnoreSubgroup = bIgnore; if( bIgnore ) continue; + + // if this is not the first view on the page + // insert a separator + NSArray* pArray = [pCurParent subviews]; + if( pArray && [pArray count] > 0 ) + { + NSRect aSepRect = { { 0, nCurY - 15 }, { 300, 15 } }; + NSBox* pBox = [[NSBox alloc] initWithFrame: aSepRect]; + [pBox setBoxType: NSBoxSeparator]; + [pCurParent addSubview: pBox]; + + nCurY -= 15; + } NSString* pText = CreateNSString( aText ); NSRect aTextRect = { { 0, 0 }, { 300, 15 } }; @@ -833,21 +891,17 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) NSString* pText = CreateNSString( aText ); // measure the text - NSFont* pFont = [NSFont labelFontOfSize: 0]; + NSFont* pFont = [NSFont controlContentFontOfSize: 0]; NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont forKey: NSFontAttributeName]; NSSize aTextSize = [pText sizeWithAttributes: pDict]; - // FIXME: the only thing reliable about sizeWithAttributes is - // that the size it outputs is way too small for our NSTextView - // that would not matter so much if NSTextView's fitToSize actually - // did something out of the box, alas it doesn't. This probably needs more - // fiddling with NSTextView's and NSTextContainer's parameters, however - // since this already almost cost me my sanity a Murphy factor of 1.5 - // will have to suffice for the time being. - aTextSize.width *= 1.5; + // leave a little space + aTextSize.width += 10; aTextSize.height += 3; - NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; + + // don't indent attached lists, looks bad in the existing cases + NSRect aTextRect = { { nCurX /* + nAttachOffset*/, 0 }, aTextSize }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; [pTextView setEditable: NO]; @@ -861,7 +915,8 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) aTextRect = [pTextView frame]; - NSRect aBtnRect = { { nCurX + nAttachOffset + aTextRect.size.width, 0 }, { 0, 15 } }; + // don't indent attached lists, looks bad in the existing cases + NSRect aBtnRect = { { nCurX /*+ nAttachOffset*/ + aTextRect.size.width, 0 }, { 0, 15 } }; NSPopUpButton* pBtn = [[NSPopUpButton alloc] initWithFrame: aBtnRect pullsDown: NO]; // iterate options @@ -915,20 +970,15 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) { // add a label NSString* pText = CreateNSString( aText ); - NSFont* pFont = [NSFont labelFontOfSize: 0]; + NSFont* pFont = [NSFont controlContentFontOfSize: 0]; NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont forKey: NSFontAttributeName]; NSSize aTextSize = [pText sizeWithAttributes: pDict]; - // FIXME: the only thing reliable about sizeWithAttributes is - // that the size it outputs is way too small for our NSTextView - // that would not matter so much if NSTextView's fitToSize actually - // did something out of the box, alas it doesn't. This probably needs more - // fiddling with NSTextView's and NSTextContainer's parameters, however - // since this already almost cost me my sanity a Murphy factor of 1.5 - // will have to suffice for the time being. - aTextSize.width *= 1.5; + // leave a little space + aTextSize.width += 10; aTextSize.height += 3; + NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; @@ -1049,7 +1099,10 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) } pControllerProperties->updateEnableState(); adjustViewAndChildren( pCurParent, aMaxTabSize ); - + + // now reposition everything again so it is upper bound + adjustTabViews( pTabView, aMaxTabSize ); + // find the minimum needed tab size NSSize aTabCtrlSize = [pTabView minimumSize]; aTabCtrlSize.height += aMaxTabSize.height + 10; diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 63d5bc6047c5..80ad8aee7409 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -419,5 +419,6 @@ StringArray SV_PRINT_NATIVE_STRINGS < "Preview"; >; < "Page Number"; >; < "Number of pages"; >; + < "More"; >; }; }; From 20914171a71d95d9451c4e3743f2fcf62045418d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Jul 2009 13:52:50 +0000 Subject: [PATCH 141/283] #i92518# n-up ordering --- vcl/inc/vcl/print.hxx | 26 ++++---- vcl/inc/vcl/prndlg.hxx | 23 +++++++ vcl/inc/vcl/svids.hrc | 2 + vcl/source/gdi/print3.cxx | 16 ++++- vcl/source/src/print.src | 4 +- vcl/source/window/arrange.cxx | 2 +- vcl/source/window/printdlg.cxx | 110 +++++++++++++++++++++++++++++---- 7 files changed, 155 insertions(+), 28 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 4ceca0d9a3ef..128393f3dd3f 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -402,20 +402,23 @@ class VCL_DLLPUBLIC PrinterController protected: PrinterController( const boost::shared_ptr& ); public: + enum NupOrderType + { LRTB, TBLR }; struct MultiPageSetup { // all metrics in 100th mm - int nRows; - int nColumns; - int nRepeat; - Size aPaperSize; - long nLeftMargin; - long nTopMargin; - long nRightMargin; - long nBottomMargin; - long nHorizontalSpacing; - long nVerticalSpacing; - bool bDrawBorder; + int nRows; + int nColumns; + int nRepeat; + Size aPaperSize; + long nLeftMargin; + long nTopMargin; + long nRightMargin; + long nBottomMargin; + long nHorizontalSpacing; + long nVerticalSpacing; + bool bDrawBorder; + PrinterController::NupOrderType nOrder; MultiPageSetup() : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) @@ -423,6 +426,7 @@ public: , nRightMargin( 0 ), nBottomMargin( 0 ) , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) , bDrawBorder( false ) + , nOrder( LRTB ) { } }; diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 5af1c85cbba6..cb472474aefc 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -70,6 +70,27 @@ namespace vcl void setPreview( const GDIMetaFile&, const Size& ); }; + class ShowNupOrderWindow : public Window + { + int mnOrderMode; + int mnRows; + int mnColumns; + void ImplInitSettings(); + public: + ShowNupOrderWindow( Window* pParent ); + virtual ~ShowNupOrderWindow(); + + virtual void Paint( const Rectangle& ); + + void setValues( int i_nOrderMode, int i_nColumns, int i_nRows ) + { + mnOrderMode = i_nOrderMode; + mnRows = i_nRows; + mnColumns = i_nColumns; + Invalidate(); + } + }; + class NUpTabPage : public TabPage { public: @@ -92,11 +113,13 @@ namespace vcl // page order ("left to right, then down") FixedText maNupOrderTxt; ListBox maNupOrderBox; + ShowNupOrderWindow maNupOrderWin; // border around each page CheckBox maBorderCB; vcl::RowOrColumn maLayout; boost::shared_ptr< vcl::WindowArranger >mxAdvancedControls; + boost::shared_ptr< vcl::RowOrColumn > mxLayoutGroup; void setupLayout(); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 9e24cffe48a1..7550cb9106a7 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -111,6 +111,8 @@ #define SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT 1 #define SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE 2 +#define SV_PRINT_PRT_NUP_ORDER_LRTD 0 +#define SV_PRINT_PRT_NUP_ORDER_TDLR 1 #define SV_PRINT_TAB_JOB 2 #define SV_PRINT_PRINTERS_FL 1 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 64e7bf0c5576..27c326569bfb 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -689,6 +689,18 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o Size aPageSize = getPageFile( nPage, aPageFile, i_bMayUseCache ); if( aPageSize.Width() && aPageSize.Height() ) { + long nCellX = 0, nCellY = 0; + switch( rMPS.nOrder ) + { + case PrinterController::LRTB: + nCellX = (nSubPage % rMPS.nColumns); + nCellY = (nSubPage / rMPS.nColumns); + break; + case PrinterController::TBLR: + nCellX = (nSubPage / rMPS.nRows); + nCellY = (nSubPage % rMPS.nRows); + break; + } // scale the metafile down to a sub page size double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); @@ -699,8 +711,8 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o // move the subpage so it is centered in its "cell" long nOffX = (aSubPageSize.Width() - long(double(aPageSize.Width()) * fScale)) / 2; long nOffY = (aSubPageSize.Height() - long(double(aPageSize.Height()) * fScale)) / 2; - long nX = rMPS.nLeftMargin + nOffX + nAdvX * (nSubPage % rMPS.nColumns); - long nY = rMPS.nTopMargin + nOffY + nAdvY * (nSubPage / rMPS.nColumns); + long nX = rMPS.nLeftMargin + nOffX + nAdvX * nCellX; + long nY = rMPS.nTopMargin + nOffY + nAdvY * nCellY; aPageFile.Move( nX, nY ); aPageFile.WindStart(); // calculate border rectangle diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 80ad8aee7409..e8d418555274 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -237,8 +237,8 @@ ModalDialog SV_DLG_PRINT CurPos = 0; StringList [en-US] = { - < "left to right, then down"; 1; >; - < "top to bottom, then right"; 2; >; + < "left to right, then down"; SV_PRINT_PRT_NUP_ORDER_LRTD; >; + < "top to bottom, then right"; SV_PRINT_PRT_NUP_ORDER_TDLR; >; }; }; CheckBox SV_PRINT_PRT_NUP_BORDER_CB diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index ae578f8e5337..ac92ae56f8d0 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -106,7 +106,7 @@ bool WindowArranger::Element::isVisible() const sal_Int32 WindowArranger::Element::getExpandPriority() const { sal_Int32 nPrio = m_nExpandPriority; - if( m_pChild ) + if( m_pChild && m_nExpandPriority >= 0 ) { size_t nElements = m_pChild->countElements(); for( size_t i = 0; i < nElements; i++ ) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f2b4ceb89c00..206f5d9f9ac4 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -151,6 +151,70 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi Invalidate(); } +PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( Window* i_pParent ) + : Window( i_pParent, WB_BORDER ) + , mnOrderMode( 0 ) + , mnRows( 1 ) + , mnColumns( 1 ) +{ + ImplInitSettings(); +} + +PrintDialog::ShowNupOrderWindow::~ShowNupOrderWindow() +{ +} + +void PrintDialog::ShowNupOrderWindow::ImplInitSettings() +{ + SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) ); +} + +void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) +{ + Window::Paint( i_rRect ); + SetMapMode( MAP_PIXEL ); + SetTextColor( GetSettings().GetStyleSettings().GetFieldTextColor() ); + + int nPages = mnRows * mnColumns; + Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); + aFont.SetSize( Size( 0, 24 ) ); + SetFont( aFont ); + Size aTextSize( GetTextWidth( rtl::OUString::valueOf( sal_Int32(nPages+1) ) ), GetTextHeight() ); + + Size aOutSize( GetOutputSizePixel() ); + Size aSubSize( aOutSize.Width() / mnColumns, aOutSize.Height() / mnRows ); + // calculate font size: shrink the sample text so it fits + double fX = double(aSubSize.Width())/double(aTextSize.Width()); + double fY = double(aSubSize.Height())/double(aTextSize.Height()); + double fScale = (fX < fY) ? fX : fY; + long nFontHeight = long(24.0*fScale) - 3; + if( nFontHeight < 5 ) + nFontHeight = 5; + aFont.SetSize( Size( 0, nFontHeight ) ); + SetFont( aFont ); + long nTextHeight = GetTextHeight(); + for( int i = 0; i < nPages; i++ ) + { + rtl::OUString aPageText( rtl::OUString::valueOf( sal_Int32(i+1) ) ); + int nX = 0, nY = 0; + switch( mnOrderMode ) + { + case SV_PRINT_PRT_NUP_ORDER_LRTD: + nX = (i % mnColumns); nY = (i / mnColumns); + break; + case SV_PRINT_PRT_NUP_ORDER_TDLR: + nX = (i / mnRows); nY = (i % mnRows); + break; + } + Size aTextSize( GetTextWidth( aPageText ), nTextHeight ); + int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2; + int nDeltaY = (aSubSize.Height() - aTextSize.Height()) / 2; + DrawText( Point( nX * aSubSize.Width() + nDeltaX, + nY * aSubSize.Height() + nDeltaY ), + aPageText ); + } +} + PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) @@ -168,10 +232,13 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maNupOrientationBox( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_BOX ) ) , maNupOrderTxt( this, VclResId( SV_PRINT_PRT_NUP_ORDER_TXT ) ) , maNupOrderBox( this, VclResId( SV_PRINT_PRT_NUP_ORDER_BOX ) ) + , maNupOrderWin( this ) , maBorderCB( this, VclResId( SV_PRINT_PRT_NUP_BORDER_CB ) ) { FreeResource(); + maNupOrderWin.Show(); + // setup field units for metric fields const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); FieldUnit eUnit = FUNIT_MM; @@ -223,15 +290,29 @@ void PrintDialog::NUpTabPage::setupLayout() maLayout.addWindow( &maNupLine ); boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) ); maLayout.addChild( xRow ); + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) ); + xRow->addChild( xIndent ); + + boost::shared_ptr< vcl::RowOrColumn > xShowNupCol( new vcl::RowOrColumn( xRow.get() ) ); + xRow->addChild( xShowNupCol, -1 ); + xShowNupCol->setMinimumSize( xShowNupCol->addWindow( &maNupOrderWin ), Size( 70, 70 ) ); + boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xShowNupCol.get() ) ); + xShowNupCol->addChild( xSpacer ); + + boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); + xIndent->setChild( xCol ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); xRow->addWindow( &maNupPagesTxt ); xRow->addWindow( &maNupPagesBox ); - boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( &maLayout ) ); - maLayout.addChild( xIndent ); + xIndent.reset( new vcl::Indenter( xCol.get() ) ); + xCol->addChild( xIndent ); // remember advanced controls to show/hide mxAdvancedControls = xIndent; - boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); + mxLayoutGroup = xCol; + xCol.reset( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); @@ -256,12 +337,12 @@ void PrintDialog::NUpTabPage::setupLayout() xRow->addWindow( &maNupOrientationTxt ); xRow->addWindow( &maNupOrientationBox ); - xRow.reset( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xRow ); + xRow.reset( new vcl::RowOrColumn( mxLayoutGroup.get(), false ) ); + mxLayoutGroup->addChild( xRow ); xRow->addWindow( &maNupOrderTxt ); xRow->addWindow( &maNupOrderBox ); - maLayout.addWindow( &maBorderCB ); + mxLayoutGroup->addWindow( &maBorderCB ); // initially advanced controls are not show, rows=columns=1 mxAdvancedControls->show( false, false ); @@ -953,7 +1034,7 @@ void PrintDialog::setupOptionalUI() } else if( aGroupingHint.equalsAscii( "LayoutPage" ) ) { - pCurColumn = &maNUpPage.maLayout; + pCurColumn = maNUpPage.mxLayoutGroup.get(); pCurParent = &maNUpPage; // set layout page as current parent bOnStaticPage = true; } @@ -1473,16 +1554,19 @@ void PrintDialog::updateNup() aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); + int nOrderMode = int(maNUpPage.maNupOrderBox.GetEntryData( + maNUpPage.maNupOrderBox.GetSelectEntryPos() )); + if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTD ) + aMPS.nOrder = PrinterController::LRTB; + else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TDLR ) + aMPS.nOrder = PrinterController::TBLR; + int nOrientationMode = int(maNUpPage.maNupOrientationBox.GetEntryData( maNUpPage.maNupOrientationBox.GetSelectEntryPos() )); if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE ) - { aMPS.aPaperSize = maNupLandscapeSize; - } else if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT ) - { aMPS.aPaperSize = maNupPortraitSize; - } else // automatic mode { // get size of first real page to see if it is portrait or landscape @@ -1498,6 +1582,8 @@ void PrintDialog::updateNup() maPController->setMultipage( aMPS ); + maNUpPage.maNupOrderWin.setValues( nOrderMode, nCols, nRows ); + preparePreview( true, true ); } @@ -1511,7 +1597,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) // update text fields updatePrinterText(); } - else if( pBox == &maNUpPage.maNupOrientationBox ) + else if( pBox == &maNUpPage.maNupOrientationBox || pBox == &maNUpPage.maNupOrderBox ) { updateNup(); } From ea2ff673857fc3a973ab828ffb9b5b32a2c99689 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Jul 2009 15:11:07 +0000 Subject: [PATCH 142/283] #i92518# reverse print --- vcl/inc/vcl/print.hxx | 2 ++ vcl/source/gdi/print3.cxx | 29 ++++++++++++++++++++++++++++- vcl/source/src/print.src | 2 +- vcl/source/window/printdlg.cxx | 12 ++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 128393f3dd3f..94680d10d3e7 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -497,6 +497,8 @@ public: SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; SAL_DLLPRIVATE void setLastPage( sal_Bool i_bLastPage ); + SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse ); + SAL_DLLPRIVATE bool getReversePrint() const; SAL_DLLPRIVATE void pushPropertiesToPrinter(); SAL_DLLPRIVATE void setJobState( com::sun::star::view::PrintableState ); }; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 27c326569bfb..72f955e428cb 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -152,6 +152,7 @@ public: Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; sal_Bool mbLastPage; + sal_Bool mbReversePageOrder; view::PrintableState meJobState; vcl::PrinterController::MultiPageSetup maMultiPage; @@ -162,6 +163,7 @@ public: ImplPrinterControllerData() : mbLastPage( sal_False ), + mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), mpProgress( NULL ) {} @@ -315,6 +317,14 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr } } + beans::PropertyValue* pReverseVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ) ); + if( pReverseVal ) + { + sal_Bool bReverse = sal_False; + pReverseVal->Value >>= bReverse; + pController->setReversePrint( bReverse ); + } + // check if the printer brings up its own dialog // in that case leave the work to that dialog const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); @@ -654,6 +664,11 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o rMPS.nLeftMargin == 0 && rMPS.nRightMargin == 0 && rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 ) { + if( mpImplData->mbReversePageOrder ) + { + int nDocPages = getPageCount(); + i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; + } return getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); } @@ -683,7 +698,9 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o { // map current sub page to real page int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; - if( nPage < nDocPages ) + if( mpImplData->mbReversePageOrder ) + nPage = nDocPages - 1 - nPage; + if( nPage >= 0 && nPage < nDocPages ) { GDIMetaFile aPageFile; Size aPageSize = getPageFile( nPage, aPageFile, i_bMayUseCache ); @@ -846,6 +863,16 @@ void PrinterController::setLastPage( sal_Bool i_bLastPage ) mpImplData->mbLastPage = i_bLastPage; } +void PrinterController::setReversePrint( sal_Bool i_bReverse ) +{ + mpImplData->mbReversePageOrder = i_bReverse; +} + +bool PrinterController::getReversePrint() const +{ + return mpImplData->mbReversePageOrder; +} + Sequence< PropertyValue > PrinterController::getJobProperties( const Sequence< PropertyValue >& i_rMergeList ) const { std::hash_set< rtl::OUString, rtl::OUStringHash > aMergeSet; diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index e8d418555274..bb2c18af5146 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -305,7 +305,7 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 5, 35 ); Size = MAP_APPFONT( 150, 10 ); - Text [en-US] = "Print Range and Copies"; + Text [en-US] = "Range and Copies"; }; FixedText SV_PRINT_COPYCOUNT { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 206f5d9f9ac4..74b43a4f25aa 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -650,6 +650,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrgetReversePrint() ); + // get the first page preparePreview( true, true ); @@ -717,6 +720,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetReversePrint( bChecked ); + maPController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ), + makeAny( bChecked ) ); + preparePreview( true, true ); + } else { if( pButton == &maJobPage.maSetupButton ) From 8cee10d466e46d4f159e639809b7ceae4495355a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Jul 2009 17:31:08 +0000 Subject: [PATCH 143/283] #i92518# label cleanup --- vcl/inc/vcl/arrange.hxx | 39 ++++++++- vcl/source/src/print.src | 2 + vcl/source/window/arrange.cxx | 148 ++++++++++++++++++++++----------- vcl/source/window/printdlg.cxx | 72 +++++++++------- 4 files changed, 180 insertions(+), 81 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 3ef93311ee58..5278657b5294 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -113,7 +113,8 @@ namespace vcl // there can be only one parent window and all managed windows MUST // be direct children of that window // violating that condition will result in undefined behavior - virtual void setParentWindow( Window* ) = 0; + virtual void setParentWindow( Window* ); + virtual void setParent( WindowArranger* ); virtual size_t countElements() const = 0; @@ -192,7 +193,6 @@ namespace vcl virtual Size getOptimalSize( WindowSizeType ) const; virtual void resize(); - virtual void setParentWindow( Window* ); virtual size_t countElements() const { return m_aElements.size(); } // add a managed window at the given index @@ -207,6 +207,39 @@ namespace vcl void remove( boost::shared_ptr const & ); }; + class LabeledElement : public WindowArranger + { + WindowArranger::Element m_aLabel; + WindowArranger::Element m_aElement; + long m_nDistance; + protected: + virtual Element* getElement( size_t i_nIndex ) + { + if( i_nIndex == 0 ) + return &m_aLabel; + else if( i_nIndex == 1 ) + return &m_aElement; + return 0; + } + + public: + LabeledElement( WindowArranger* i_pParent = NULL, long i_nDistance = 5 ) + : WindowArranger( i_pParent ) + , m_nDistance( i_nDistance ) + {} + + virtual ~LabeledElement(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual size_t countElements() const { return 2; } + + void setLabel( Window* ); + void setLabel( boost::shared_ptr const & ); + void setElement( Window* ); + void setElement( boost::shared_ptr const & ); + }; + class Indenter : public WindowArranger { long m_nIndent; @@ -226,7 +259,6 @@ namespace vcl virtual Size getOptimalSize( WindowSizeType ) const; virtual void resize(); - virtual void setParentWindow( Window* ); virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } void setIndent( long i_nIndent ) @@ -319,7 +351,6 @@ namespace vcl virtual Size getOptimalSize( WindowSizeType ) const; virtual void resize(); - virtual void setParentWindow( Window* ); virtual size_t countElements() const { return m_aElements.size(); } // add a managed window at the given matrix position diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index bb2c18af5146..aab695f8bf93 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -145,6 +145,7 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 10, 10 ); Text [en-US] = "P~ages"; + VCenter = TRUE; }; NumericField SV_PRINT_PRT_NUP_COLS_EDT { @@ -161,6 +162,7 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 40, 10 ); Text [en-US] = "~by"; + VCenter = TRUE; }; NumericField SV_PRINT_PRT_NUP_ROWS_EDT { diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index ac92ae56f8d0..e09c34d9c1fb 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -53,6 +53,28 @@ void WindowArranger::setParent( WindowArranger* i_pParent ) setParentWindow( m_pParentWindow ); } +void WindowArranger::setParentWindow( Window* i_pNewParent ) +{ + m_pParentWindow = i_pNewParent; + + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + Element* pEle = getElement( i ); + if( pEle ) // sanity check + { + #if OSL_DEBUG_LEVEL > 0 + if( pEle->m_pElement ) + { + OSL_VERIFY( pEle->m_pElement->GetParent() == i_pNewParent ); + } + #endif + if( pEle->m_pChild ) + pEle->m_pChild->setParentWindow( i_pNewParent ); + } + } +} + void WindowArranger::show( bool i_bShow, bool i_bImmediateUpdate ) { size_t nEle = countElements(); @@ -341,23 +363,6 @@ void RowOrColumn::resize() } } -void RowOrColumn::setParentWindow( Window* i_pNewParent ) -{ - m_pParentWindow = i_pNewParent; - for( std::vector< WindowArranger::Element >::const_iterator it = m_aElements.begin(); - it != m_aElements.end(); ++it ) - { - #if OSL_DEBUG_LEVEL > 0 - if( it->m_pElement ) - { - OSL_VERIFY( it->m_pElement->GetParent() == i_pNewParent ); - } - #endif - if( it->m_pChild ) - it->m_pChild->setParentWindow( i_pNewParent ); - } -} - size_t RowOrColumn::addWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio, size_t i_nIndex ) { size_t nIndex = i_nIndex; @@ -426,6 +431,85 @@ void RowOrColumn::remove( boost::shared_ptr const & i_pChild ) } } +// ---------------------------------------- +// vcl::LabeledElement +//----------------------------------------- + +LabeledElement::~LabeledElement() +{ + m_aLabel.deleteChild(); + m_aElement.deleteChild(); +} + +Size LabeledElement::getOptimalSize( WindowSizeType i_eType ) const +{ + Size aRet( m_aLabel.getOptimalSize( WINDOWSIZE_MINIMUM ) ); + if( aRet.Width() != 0 ) + aRet.Width() += m_nDistance; + Size aElementSize( m_aElement.getOptimalSize( i_eType ) ); + aRet.Width() += aElementSize.Width(); + if( aElementSize.Height() > aRet.Height() ) + aRet.Height() = aElementSize.Height(); + if( aRet.Height() != 0 ) + aRet.Height() += 2*m_nOuterBorder; + + return aRet; +} + +void LabeledElement::resize() +{ + Size aLabelSize( m_aLabel.getOptimalSize( WINDOWSIZE_MINIMUM ) ); + Size aElementSize( m_aElement.getOptimalSize( WINDOWSIZE_PREFERRED ) ); + if( m_nDistance + aLabelSize.Width() + aElementSize.Width() > m_aManagedArea.GetWidth() ) + aElementSize = m_aElement.getOptimalSize( WINDOWSIZE_MINIMUM ); + + // align label and element vertically in LabeledElement + long nYOff = (m_aManagedArea.GetHeight() - 2*m_nOuterBorder - aLabelSize.Height()) / 2; + Point aPos( m_aManagedArea.Left(), + m_aManagedArea.Top() + m_nOuterBorder + nYOff ); + Size aSize( aLabelSize ); + if( m_aLabel.m_pElement ) + m_aLabel.m_pElement->SetPosSizePixel( aPos, aSize ); + else if( m_aLabel.m_pChild.get() ) + m_aLabel.m_pChild->setManagedArea( Rectangle( aPos, aSize ) ); + + aPos.X() += aSize.Width() + m_nDistance; + nYOff = (m_aManagedArea.GetHeight() - 2*m_nOuterBorder - aElementSize.Height()) / 2; + aPos.Y() = m_aManagedArea.Top() + m_nOuterBorder + nYOff; + aSize.Width() = aElementSize.Width(); + aSize.Height() = m_aManagedArea.GetHeight() - 2*m_nOuterBorder; + if( aPos.X() + aSize.Width() < m_aManagedArea.Right() ) + aSize.Width() = m_aManagedArea.Right() - aPos.X(); + if( m_aElement.m_pElement ) + m_aElement.m_pElement->SetPosSizePixel( aPos, aSize ); + else if( m_aElement.m_pChild.get() ) + m_aElement.m_pChild->setManagedArea( Rectangle( aPos, aSize ) ); +} + +void LabeledElement::setLabel( Window* i_pLabel ) +{ + m_aLabel.m_pElement = i_pLabel; + m_aLabel.m_pChild.reset(); +} + +void LabeledElement::setLabel( boost::shared_ptr const & i_pLabel ) +{ + m_aLabel.m_pElement = NULL; + m_aLabel.m_pChild = i_pLabel; +} + +void LabeledElement::setElement( Window* i_pElement ) +{ + m_aElement.m_pElement = i_pElement; + m_aElement.m_pChild.reset(); +} + +void LabeledElement::setElement( boost::shared_ptr const & i_pElement ) +{ + m_aElement.m_pElement = NULL; + m_aElement.m_pChild = i_pElement; +} + // ---------------------------------------- // vcl::Indenter //----------------------------------------- @@ -472,19 +556,6 @@ void Indenter::setChild( boost::shared_ptr const & i_pChild, sal m_aElement.m_nExpandPriority = i_nExpandPrio; } -void Indenter::setParentWindow( Window* i_pNewParent ) -{ - m_pParentWindow = i_pNewParent; - #if OSL_DEBUG_LEVEL > 0 - if( m_aElement.m_pElement ) - { - OSL_VERIFY( m_aElement.m_pElement->GetParent() == i_pNewParent ); - } - #endif - if( m_aElement.m_pChild ) - m_aElement.m_pChild->setParentWindow( i_pNewParent ); -} - // ---------------------------------------- // vcl::MatrixArranger //----------------------------------------- @@ -588,23 +659,6 @@ void MatrixArranger::resize() } } -void MatrixArranger::setParentWindow( Window* i_pNewParent ) -{ - m_pParentWindow = i_pNewParent; - for( std::vector< MatrixElement >::const_iterator it = m_aElements.begin(); - it != m_aElements.end(); ++it ) - { - #if OSL_DEBUG_LEVEL > 0 - if( it->m_pElement ) - { - OSL_VERIFY( it->m_pElement->GetParent() == i_pNewParent ); - } - #endif - if( it->m_pChild ) - it->m_pChild->setParentWindow( i_pNewParent ); - } -} - size_t MatrixArranger::addWindow( Window* i_pWindow, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio ) { sal_uInt64 nMapValue = getMap( i_nX, i_nY ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 74b43a4f25aa..9537b2a8eeab 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -301,10 +301,10 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); - xRow->addWindow( &maNupPagesTxt ); - xRow->addWindow( &maNupPagesBox ); + boost::shared_ptr< vcl::LabeledElement > xLabel( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maNupPagesTxt ); + xLabel->setElement( &maNupPagesBox ); xIndent.reset( new vcl::Indenter( xCol.get() ) ); xCol->addChild( xIndent ); @@ -322,25 +322,25 @@ void PrintDialog::NUpTabPage::setupLayout() xRow->addWindow( &maNupTimesTxt ); xRow->addWindow( &maNupRowsEdt ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); - xRow->addWindow( &maPageMarginTxt ); - xRow->addWindow( &maPageMarginEdt ); + xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maPageMarginTxt ); + xLabel->setElement( &maPageMarginEdt ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); - xRow->addWindow( &maSheetMarginTxt ); - xRow->addWindow( &maSheetMarginEdt ); + xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maSheetMarginTxt ); + xLabel->setElement( &maSheetMarginEdt ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); - xRow->addWindow( &maNupOrientationTxt ); - xRow->addWindow( &maNupOrientationBox ); + xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maNupOrientationTxt ); + xLabel->setElement( &maNupOrientationBox ); - xRow.reset( new vcl::RowOrColumn( mxLayoutGroup.get(), false ) ); - mxLayoutGroup->addChild( xRow ); - xRow->addWindow( &maNupOrderTxt ); - xRow->addWindow( &maNupOrderBox ); + xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maNupOrderTxt ); + xLabel->setElement( &maNupOrderBox ); mxLayoutGroup->addWindow( &maBorderCB ); @@ -485,14 +485,14 @@ void PrintDialog::JobTabPage::setupLayout() xRangeRow->addChild( xCopyCollateCol ); // add copies row to copy/collate column - boost::shared_ptr< vcl::RowOrColumn > xCopiesRow( new vcl::RowOrColumn( xCopyCollateCol.get(), false, 0 ) ); + boost::shared_ptr< vcl::LabeledElement > xCopiesRow( new vcl::LabeledElement( xCopyCollateCol.get() ) ); xCopyCollateCol->addChild( xCopiesRow ); - xCopiesRow->addWindow( &maCopyCount ); - xCopiesRow->addWindow( &maCopyCountField ); - boost::shared_ptr< vcl::RowOrColumn > xCollateRow( new vcl::RowOrColumn( xCopyCollateCol.get(), false, 0 ) ); + xCopiesRow->setLabel( &maCopyCount ); + xCopiesRow->setElement( &maCopyCountField ); + boost::shared_ptr< vcl::LabeledElement > xCollateRow( new vcl::LabeledElement( xCopyCollateCol.get() ) ); xCopyCollateCol->addChild( xCollateRow ); - xCollateRow->addWindow( &maCollateBox ); - xCollateRow->addWindow( &maCollateImage ); + xCollateRow->setLabel( &maCollateBox ); + xCollateRow->setElement( &maCollateImage ); maDetailsBtn.SetSymbol( SYMBOL_SPIN_DOWN ); maDetailsBtn.SetSmallSymbol(); @@ -1222,6 +1222,7 @@ void PrintDialog::setupOptionalUI() pCurColumn->addChild( pFieldColumn ); aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pFieldColumn ) ); + vcl::LabeledElement* pLabel = NULL; if( aText.getLength() ) { // add a FixedText: @@ -1234,7 +1235,9 @@ void PrintDialog::setupOptionalUI() setSmartId( pHeading, "FixedText", -1, aPropertyName ); // add to row - pFieldColumn->addWindow( pHeading ); + pLabel = new vcl::LabeledElement( pFieldColumn ); + pFieldColumn->addChild( pLabel ); + pLabel->setLabel( pHeading ); } if( aCtrlType.equalsAscii( "List" ) ) @@ -1266,7 +1269,10 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pList] = aPropertyName; // finish the pair - pFieldColumn->addWindow( pList ); + if( pLabel ) + pLabel->setElement( pList ); + else + pFieldColumn->addWindow( pList ); } else if( aCtrlType.equalsAscii( "Range" ) ) { @@ -1298,7 +1304,10 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pField] = aPropertyName; // add to row - pFieldColumn->addWindow( pField ); + if( pLabel ) + pLabel->setElement( pField ); + else + pFieldColumn->addWindow( pField ); } else if( aCtrlType.equalsAscii( "Edit" ) ) { @@ -1323,7 +1332,10 @@ void PrintDialog::setupOptionalUI() maControlToPropertyMap[pField] = aPropertyName; // add to row - pFieldColumn->addWindow( pField, 2 ); + if( pLabel ) + pLabel->setElement( pField ); + else + pFieldColumn->addWindow( pField, 2 ); } } else From d88fd8b7532a5c5564044f27bac699c064ab1a75 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 30 Jul 2009 18:05:46 +0000 Subject: [PATCH 144/283] fix a warning --- vcl/source/window/printdlg.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9537b2a8eeab..7cf6a2696b63 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -179,13 +179,13 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); aFont.SetSize( Size( 0, 24 ) ); SetFont( aFont ); - Size aTextSize( GetTextWidth( rtl::OUString::valueOf( sal_Int32(nPages+1) ) ), GetTextHeight() ); + Size aSampleTextSize( GetTextWidth( rtl::OUString::valueOf( sal_Int32(nPages+1) ) ), GetTextHeight() ); Size aOutSize( GetOutputSizePixel() ); Size aSubSize( aOutSize.Width() / mnColumns, aOutSize.Height() / mnRows ); // calculate font size: shrink the sample text so it fits - double fX = double(aSubSize.Width())/double(aTextSize.Width()); - double fY = double(aSubSize.Height())/double(aTextSize.Height()); + double fX = double(aSubSize.Width())/double(aSampleTextSize.Width()); + double fY = double(aSubSize.Height())/double(aSampleTextSize.Height()); double fScale = (fX < fY) ? fX : fY; long nFontHeight = long(24.0*fScale) - 3; if( nFontHeight < 5 ) From b80cb739622f8e2d3bf385249f950803c0e3c8ac Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 07:34:21 +0000 Subject: [PATCH 145/283] fix a warning --- vcl/source/window/printdlg.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 7cf6a2696b63..d7f3b68611ef 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1570,15 +1570,15 @@ void PrintDialog::updateNup() aMPS.bDrawBorder = maNUpPage.maBorderCB.IsChecked(); - int nOrderMode = int(maNUpPage.maNupOrderBox.GetEntryData( - maNUpPage.maNupOrderBox.GetSelectEntryPos() )); + int nOrderMode = int(sal_IntPtr(maNUpPage.maNupOrderBox.GetEntryData( + maNUpPage.maNupOrderBox.GetSelectEntryPos() ))); if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_LRTD ) aMPS.nOrder = PrinterController::LRTB; else if( nOrderMode == SV_PRINT_PRT_NUP_ORDER_TDLR ) aMPS.nOrder = PrinterController::TBLR; - int nOrientationMode = int(maNUpPage.maNupOrientationBox.GetEntryData( - maNUpPage.maNupOrientationBox.GetSelectEntryPos() )); + int nOrientationMode = int(sal_IntPtr(maNUpPage.maNupOrientationBox.GetEntryData( + maNUpPage.maNupOrientationBox.GetSelectEntryPos() ))); if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE ) aMPS.aPaperSize = maNupLandscapeSize; else if( nOrientationMode == SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT ) From 592a5f3139812ee92f86e0f135da6f0c317f5624 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 11:38:53 +0000 Subject: [PATCH 146/283] #i92518# adjust button line margin --- vcl/inc/vcl/arrange.hxx | 28 +++++++++++++++++--- vcl/source/window/arrange.cxx | 47 +++++++++++++++++----------------- vcl/source/window/printdlg.cxx | 8 +++--- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index 5278657b5294..e5cc37245f98 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -61,12 +61,20 @@ namespace vcl sal_Int32 m_nExpandPriority; Size m_aMinSize; bool m_bHidden; + long m_nLeftBorder; + long m_nTopBorder; + long m_nRightBorder; + long m_nBottomBorder; Element() : m_pElement( NULL ) , m_pChild() , m_nExpandPriority( 0 ) , m_bHidden( false ) + , m_nLeftBorder( 0 ) + , m_nTopBorder( 0 ) + , m_nRightBorder( 0 ) + , m_nBottomBorder( 0 ) {} Element( Window* i_pWin, @@ -77,6 +85,10 @@ namespace vcl , m_pChild( i_pChild ) , m_nExpandPriority( i_nExpandPriority ) , m_bHidden( false ) + , m_nLeftBorder( 0 ) + , m_nTopBorder( 0 ) + , m_nRightBorder( 0 ) + , m_nBottomBorder( 0 ) {} void deleteChild() { m_pChild.reset(); } @@ -84,6 +96,7 @@ namespace vcl sal_Int32 getExpandPriority() const; Size getOptimalSize( WindowSizeType ) const; bool isVisible() const; + void setPosSize( const Point&, const Size& ); }; Window* m_pParentWindow; @@ -145,13 +158,22 @@ namespace vcl { Element* pEle = getElement( i_nIndex ); if( pEle ) - { pEle->m_aMinSize = i_rMinSize; - resize(); - } return pEle != NULL; } + void setBorders( size_t i_nIndex, long i_nLeft, long i_nTop, long i_nRight, long i_nBottom ) + { + Element* pEle = getElement( i_nIndex ); + if( pEle ) + { + pEle->m_nLeftBorder = i_nLeft; + pEle->m_nRightBorder = i_nRight; + pEle->m_nTopBorder = i_nTop; + pEle->m_nBottomBorder = i_nBottom; + } + } + void show( bool i_bShow = true, bool i_bImmediateUpdate = true ); void setManagedArea( const Rectangle& i_rArea ) diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index e09c34d9c1fb..5f8ef943271e 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -154,11 +154,27 @@ Size WindowArranger::Element::getOptimalSize( WindowSizeType i_eType ) const aResult.Width() = m_aMinSize.Width(); if( aResult.Height() < m_aMinSize.Height() ) aResult.Height() = m_aMinSize.Height(); + aResult.Width() += m_nLeftBorder + m_nRightBorder; + aResult.Height() += m_nTopBorder + m_nBottomBorder; } return aResult; } +void WindowArranger::Element::setPosSize( const Point& i_rPos, const Size& i_rSize ) +{ + Point aPoint( i_rPos ); + Size aSize( i_rSize ); + aPoint.X() += m_nLeftBorder; + aPoint.Y() += m_nTopBorder; + aSize.Width() -= m_nLeftBorder + m_nRightBorder; + aSize.Height() -= m_nTopBorder + m_nBottomBorder; + if( m_pElement ) + m_pElement->SetPosSizePixel( aPoint, aSize ); + else if( m_pChild ) + m_pChild->setManagedArea( Rectangle( aPoint, aSize ) ); +} + // ---------------------------------------- // vcl::RowOrColumn //----------------------------------------- @@ -332,10 +348,12 @@ void RowOrColumn::resize() long nExtraWidth = (m_bColumn ? m_aManagedArea.GetHeight() : m_aManagedArea.GetWidth()) - nUsedWidth; if( nExtraWidth > 0 ) + { if( m_bColumn ) distributeColumnHeight( aElementSizes, nUsedWidth, nExtraWidth ); else distributeRowWidth( aElementSizes, nUsedWidth, nExtraWidth ); + } // get starting position Point aElementPos( m_aManagedArea.TopLeft() ); @@ -348,14 +366,7 @@ void RowOrColumn::resize() { // get the size of type of the managed element - if( m_aElements[i].m_pElement ) // this actually is a window - { - m_aElements[i].m_pElement->SetPosSizePixel( aElementPos, aElementSizes[i] ); - } - else if( m_aElements[i].m_pChild ) - { - m_aElements[i].m_pChild->setManagedArea( Rectangle( aElementPos, aElementSizes[i] ) ); - } + m_aElements[i].setPosSize( aElementPos, aElementSizes[i] ); if( m_bColumn ) aElementPos.Y() += m_nBorderWidth + aElementSizes[i].Height(); else @@ -468,10 +479,7 @@ void LabeledElement::resize() Point aPos( m_aManagedArea.Left(), m_aManagedArea.Top() + m_nOuterBorder + nYOff ); Size aSize( aLabelSize ); - if( m_aLabel.m_pElement ) - m_aLabel.m_pElement->SetPosSizePixel( aPos, aSize ); - else if( m_aLabel.m_pChild.get() ) - m_aLabel.m_pChild->setManagedArea( Rectangle( aPos, aSize ) ); + m_aLabel.setPosSize( aPos, aSize ); aPos.X() += aSize.Width() + m_nDistance; nYOff = (m_aManagedArea.GetHeight() - 2*m_nOuterBorder - aElementSize.Height()) / 2; @@ -480,10 +488,7 @@ void LabeledElement::resize() aSize.Height() = m_aManagedArea.GetHeight() - 2*m_nOuterBorder; if( aPos.X() + aSize.Width() < m_aManagedArea.Right() ) aSize.Width() = m_aManagedArea.Right() - aPos.X(); - if( m_aElement.m_pElement ) - m_aElement.m_pElement->SetPosSizePixel( aPos, aSize ); - else if( m_aElement.m_pChild.get() ) - m_aElement.m_pChild->setManagedArea( Rectangle( aPos, aSize ) ); + m_aElement.setPosSize( aPos, aSize ); } void LabeledElement::setLabel( Window* i_pLabel ) @@ -535,10 +540,7 @@ void Indenter::resize() Size aSz( m_aManagedArea.GetSize() ); aSz.Width() -= 2*m_nOuterBorder + m_nIndent; aSz.Height() -= 2*m_nOuterBorder; - if( m_aElement.m_pElement ) - m_aElement.m_pElement->SetPosSizePixel( aPt, aSz ); - else if( m_aElement.m_pChild ) - m_aElement.m_pChild->setManagedArea( Rectangle( aPt, aSz ) ); + m_aElement.setPosSize( aPt, aSz ); } void Indenter::setWindow( Window* i_pWindow, sal_Int32 i_nExpandPrio ) @@ -652,10 +654,7 @@ void MatrixArranger::resize() { Point aCellPos( aColumnX[it->m_nX], aRowY[it->m_nY] ); Size aCellSize( aColumnWidths[it->m_nX], aRowHeights[it->m_nY] ); - if( it->m_pElement ) - it->m_pElement->SetPosSizePixel( aCellPos, aCellSize ); - else if( it->m_pChild ) - it->m_pChild->setManagedArea( Rectangle( aCellPos, aCellSize ) ); + it->setPosSize( aCellPos, aCellSize ); } } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index d7f3b68611ef..6e15d71117c3 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -394,6 +394,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) , mnCollateUIMode( 0 ) + , maLayout( NULL, true, 0 ) { FreeResource(); maPrinterFL.SMHID2( "JobPage", "Printer" ); @@ -784,10 +785,10 @@ void PrintDialog::setupLayout() Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); maLayout.setParentWindow( this ); - maLayout.setOuterBorder( aBorder.Width() ); boost::shared_ptr< vcl::RowOrColumn > xPreviewAndTab( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xPreviewAndTab, 5 ); + size_t nIndex = maLayout.addChild( xPreviewAndTab, 5 ); + maLayout.setBorders( nIndex, aBorder.Width(), aBorder.Width(), aBorder.Width(), 0 ); // setup column for preview and sub controls boost::shared_ptr< vcl::RowOrColumn > xPreview( new vcl::RowOrColumn( xPreviewAndTab.get() ) ); @@ -811,7 +812,8 @@ void PrintDialog::setupLayout() // add the row for the buttons boost::shared_ptr< vcl::RowOrColumn > xButtons( new vcl::RowOrColumn( &maLayout, false ) ); - maLayout.addChild( xButtons ); + nIndex = maLayout.addChild( xButtons ); + maLayout.setBorders( nIndex, aBorder.Width(), 0, aBorder.Width(), aBorder.Width() ); // insert a spacer, buttons are right aligned xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) ); From 167cb4386db37471d9038e4b9d52a91d76885d79 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 12:02:23 +0000 Subject: [PATCH 147/283] #i92518# border for page preview --- vcl/source/window/printdlg.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 6e15d71117c3..c25eff97d2d1 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -77,6 +77,9 @@ PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() void PrintDialog::PrintPreviewWindow::Resize() { Size aNewSize( GetSizePixel() ); + // leave small space for decoration + aNewSize.Width() -= 2; + aNewSize.Height() -= 2; Size aScaledSize; double fScale = 1.0; if( maOrigSize.Width() > maOrigSize.Height() ) @@ -121,6 +124,10 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) SetMapMode( MAP_PIXEL ); maPageVDev.SetMapMode( MAP_PIXEL ); DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev ); + + DecorationView aVw( this ); + aOffset.X() -= 1; aOffset.Y() -=1; aPreviewSize.Width() += 2; aPreviewSize.Height() += 2; + aVw.DrawFrame( Rectangle( aOffset, aPreviewSize ), FRAME_DRAW_GROUP ); } void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) From 27324679eba1bc69f026a846b2605e8ccff71a35 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 12:23:00 +0000 Subject: [PATCH 148/283] #i92518# label layout, set correct tab page size --- vcl/inc/vcl/arrange.hxx | 4 +++- vcl/source/window/arrange.cxx | 17 +++++++++++++++-- vcl/source/window/printdlg.cxx | 14 +++++++++----- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index e5cc37245f98..e31be4ac8c67 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -234,6 +234,7 @@ namespace vcl WindowArranger::Element m_aLabel; WindowArranger::Element m_aElement; long m_nDistance; + int m_nLabelStyle; protected: virtual Element* getElement( size_t i_nIndex ) { @@ -245,9 +246,10 @@ namespace vcl } public: - LabeledElement( WindowArranger* i_pParent = NULL, long i_nDistance = 5 ) + LabeledElement( WindowArranger* i_pParent = NULL, int i_nLabelStyle = 0, long i_nDistance = 5 ) : WindowArranger( i_pParent ) , m_nDistance( i_nDistance ) + , m_nLabelStyle( i_nLabelStyle ) {} virtual ~LabeledElement(); diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 5f8ef943271e..8b3ed40db72e 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -486,8 +486,21 @@ void LabeledElement::resize() aPos.Y() = m_aManagedArea.Top() + m_nOuterBorder + nYOff; aSize.Width() = aElementSize.Width(); aSize.Height() = m_aManagedArea.GetHeight() - 2*m_nOuterBorder; - if( aPos.X() + aSize.Width() < m_aManagedArea.Right() ) - aSize.Width() = m_aManagedArea.Right() - aPos.X(); + + // label style + // 0: position left and right + // 1: keep the element close to label and grow it + // 2: keep the element close and don't grow it + if( m_nLabelStyle == 0) + { + if( aPos.X() + aSize.Width() < m_aManagedArea.Right() ) + aPos.X() = m_aManagedArea.Right() - aSize.Width(); + } + else if( m_nLabelStyle == 1 ) + { + if( aPos.X() + aSize.Width() < m_aManagedArea.Right() ) + aSize.Width() = m_aManagedArea.Right() - aPos.X(); + } m_aElement.setPosSize( aPos, aSize ); } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index c25eff97d2d1..48ffb3711ab3 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -324,10 +324,14 @@ void PrintDialog::NUpTabPage::setupLayout() xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); xCol->addChild( xRow ); - xRow->addWindow( &maNupNumPagesTxt ); - xRow->addWindow( &maNupColEdt ); - xRow->addWindow( &maNupTimesTxt ); - xRow->addWindow( &maNupRowsEdt ); + xLabel.reset( new vcl::LabeledElement( xRow.get() ) ); + xRow->addChild( xLabel, 1 ); + xLabel->setLabel( &maNupNumPagesTxt ); + xLabel->setElement( &maNupColEdt ); + xLabel.reset( new vcl::LabeledElement( xRow.get() ) ); + xRow->addChild( xLabel ); + xLabel->setLabel( &maNupTimesTxt ); + xLabel->setElement( &maNupRowsEdt ); xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); xCol->addChild( xLabel ); @@ -1405,7 +1409,7 @@ void PrintDialog::setupOptionalUI() for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); it != aDynamicColumns.end(); ++it ) { - (*it)->setManagedArea( Rectangle( Point(), aMaxPageSize ) ); + (*it)->setManagedArea( Rectangle( Point(), aTabSize ) ); delete *it; *it = NULL; } From f6914ef7a3a9821fa0e81e0025dbc0752140fb92 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 12:39:45 +0000 Subject: [PATCH 149/283] #i92518# special handle PrintRange subgroups --- vcl/source/window/printdlg.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 48ffb3711ab3..9e02de6908ab 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -807,7 +807,8 @@ void PrintDialog::setupLayout() xPreview->addWindow( &maPreviewWindow, 5 ); // get a row for the preview controls boost::shared_ptr< vcl::RowOrColumn > xPreviewCtrls( new vcl::RowOrColumn( xPreview.get(), false ) ); - xPreview->addChild( xPreviewCtrls ); + nIndex = xPreview->addChild( xPreviewCtrls ); + xPreview->setBorders( nIndex, aBorder.Width()*3, 0, aBorder.Width()*3, 0 ); xPreviewCtrls->addWindow( &maPageEdit ); xPreviewCtrls->addWindow( &maNumPagesText ); boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); @@ -1097,7 +1098,11 @@ void PrintDialog::setupOptionalUI() ! pCurColumn->countElements() == 0 ) { - FixedLine* pNewSub = new FixedLine( pCurParent ); + Window* pNewSub = NULL; + if( aGroupingHint.equalsAscii( "PrintRange" ) ) + pNewSub = new FixedText( pCurParent, WB_VCENTER ); + else + pNewSub = new FixedLine( pCurParent ); maControls.push_front( pNewSub ); pNewSub->SetText( aText ); pNewSub->Show(); From d660523d686f1085077b44c9d1b5c79a1724b9d6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 15:16:11 +0000 Subject: [PATCH 150/283] #i92518# lates UI changes --- vcl/inc/vcl/prndlg.hxx | 6 +- vcl/inc/vcl/svids.hrc | 32 +++++---- vcl/source/src/print.src | 49 ++++++++++--- vcl/source/window/printdlg.cxx | 123 +++++++++++++++++++++++++++------ vcl/source/window/window2.cxx | 1 - 5 files changed, 166 insertions(+), 45 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index cb472474aefc..6e3b4b0508c7 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -95,7 +95,9 @@ namespace vcl { public: FixedLine maNupLine; - FixedText maNupPagesTxt; + RadioButton maDefaultBtn; + RadioButton maBrochureBtn; + RadioButton maPagesBtn; ListBox maNupPagesBox; // controls for "Custom" page mode @@ -120,6 +122,7 @@ namespace vcl vcl::RowOrColumn maLayout; boost::shared_ptr< vcl::WindowArranger >mxAdvancedControls; boost::shared_ptr< vcl::RowOrColumn > mxLayoutGroup; + boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; void setupLayout(); @@ -129,6 +132,7 @@ namespace vcl void readFromSettings(); void storeToSettings(); void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); + void enableNupControls( bool bEnable ); virtual void Resize(); }; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 7550cb9106a7..9ce6d2781012 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -91,21 +91,23 @@ #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP_LAYOUT_FL 1 -#define SV_PRINT_PRT_NUP_PAGES_TXT 2 -#define SV_PRINT_PRT_NUP_PAGES_BOX 2 -#define SV_PRINT_PRT_NUP_NUM_PAGES_TXT 3 -#define SV_PRINT_PRT_NUP_COLS_EDT 4 -#define SV_PRINT_PRT_NUP_TIMES_TXT 5 -#define SV_PRINT_PRT_NUP_ROWS_EDT 6 -#define SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT 7 -#define SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT 8 -#define SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT 9 -#define SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT 10 -#define SV_PRINT_PRT_NUP_ORIENTATION_TXT 12 -#define SV_PRINT_PRT_NUP_ORIENTATION_BOX 13 -#define SV_PRINT_PRT_NUP_ORDER_TXT 14 -#define SV_PRINT_PRT_NUP_ORDER_BOX 15 -#define SV_PRINT_PRT_NUP_BORDER_CB 16 +#define SV_PRINT_PRT_NUP_DEFAULT_BTN 2 +#define SV_PRINT_PRT_NUP_BROCHURE_BTN 3 +#define SV_PRINT_PRT_NUP_PAGES_BTN 4 +#define SV_PRINT_PRT_NUP_PAGES_BOX 5 +#define SV_PRINT_PRT_NUP_NUM_PAGES_TXT 6 +#define SV_PRINT_PRT_NUP_COLS_EDT 7 +#define SV_PRINT_PRT_NUP_TIMES_TXT 8 +#define SV_PRINT_PRT_NUP_ROWS_EDT 9 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT 10 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT 11 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT 12 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT 13 +#define SV_PRINT_PRT_NUP_ORIENTATION_TXT 14 +#define SV_PRINT_PRT_NUP_ORIENTATION_BOX 15 +#define SV_PRINT_PRT_NUP_ORDER_TXT 16 +#define SV_PRINT_PRT_NUP_ORDER_BOX 17 +#define SV_PRINT_PRT_NUP_BORDER_CB 18 #define SV_PRINT_PRT_NUP_ORIENTATION_AUTOMATIC 0 #define SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT 1 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index aab695f8bf93..a7be46fa6a59 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -67,6 +67,7 @@ ModalDialog SV_DLG_PRINT SVLook = TRUE; Spin = FALSE; Border = TRUE; + HelpText [en-US] = "Select page to display in preview."; }; FixedText SV_PRINT_PAGE_TXT { @@ -79,11 +80,13 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 95, 140 ); Size = MAP_APPFONT( 15, 12 ); + HelpText [en-US] = "Scroll one page forward."; }; PushButton SV_PRINT_PAGE_BACKWARD { Pos = MAP_APPFONT( 80, 140 ); Size = MAP_APPFONT( 15, 12 ); + HelpText [en-US] = "Scroll one page backward."; }; TabControl SV_PRINT_TABCTRL { @@ -116,11 +119,25 @@ ModalDialog SV_DLG_PRINT Size = MAP_APPFONT( 150, 10 ); Text [en-US] = "Layout"; }; - FixedText SV_PRINT_PRT_NUP_PAGES_TXT + RadioButton SV_PRINT_PRT_NUP_DEFAULT_BTN { - Pos = MAP_APPFONT( 10, 20 ); - Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Pages per ~sheet"; + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "~Default"; + HelpText [en-US] = "Print one page per sheet of paper."; + }; + RadioButton SV_PRINT_PRT_NUP_BROCHURE_BTN + { + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text = ""; + }; + RadioButton SV_PRINT_PRT_NUP_PAGES_BTN + { + Pos = MAP_APPFONT( 0, 0 ); + Size = MAP_APPFONT( 10, 10 ); + Text [en-US] = "Pa~ges per sheet"; + HelpText [en-US] = "Print multiple pages per sheet of paper."; }; ListBox SV_PRINT_PRT_NUP_PAGES_BOX { @@ -129,6 +146,7 @@ ModalDialog SV_DLG_PRINT Border = TRUE; DropDown = TRUE; CurPos = 0; + HelpText [en-US] = "Select how many pages to print per sheet of paper."; StringList [en-US] = { < "1"; 1; >; @@ -156,12 +174,13 @@ ModalDialog SV_DLG_PRINT Minimum = 1; Maximum = 32; Value = 1; + HelpText [en-US] = "Select number of columns."; }; FixedText SV_PRINT_PRT_NUP_TIMES_TXT { Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~by"; + Text [en-US] = "b~y"; VCenter = TRUE; }; NumericField SV_PRINT_PRT_NUP_ROWS_EDT @@ -173,12 +192,13 @@ ModalDialog SV_DLG_PRINT Minimum = 1; Maximum = 32; Value = 1; + HelpText [en-US] = "Select number of rows."; }; FixedText SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT { Pos = MAP_APPFONT( 10, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "~Margin between pages"; + Text [en-US] = "Margin between ~pages"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT { @@ -188,12 +208,13 @@ ModalDialog SV_DLG_PRINT Border = TRUE; Value = 0; Unit = FUNIT_MM; + HelpText [en-US] = "Select margin between individual pages on each sheet of paper."; }; FixedText SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT { Pos = MAP_APPFONT( 110, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Ma~rgin to sheet border"; + Text [en-US] = "Margin to ~sheet border"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT { @@ -203,6 +224,7 @@ ModalDialog SV_DLG_PRINT Border = TRUE; Value = 0; Unit = FUNIT_MM; + HelpText [en-US] = "Select margin between the printed pages and paper edge."; }; FixedText SV_PRINT_PRT_NUP_ORIENTATION_TXT { @@ -223,6 +245,7 @@ ModalDialog SV_DLG_PRINT < "Portrait"; SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT; >; < "Landscape"; SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE; >; }; + HelpText [en-US] = "Select the orientation of the paper."; }; FixedText SV_PRINT_PRT_NUP_ORDER_TXT { @@ -242,12 +265,14 @@ ModalDialog SV_DLG_PRINT < "left to right, then down"; SV_PRINT_PRT_NUP_ORDER_LRTD; >; < "top to bottom, then right"; SV_PRINT_PRT_NUP_ORDER_TDLR; >; }; + HelpText [en-US] = "Select order in which pages are to be printed."; }; CheckBox SV_PRINT_PRT_NUP_BORDER_CB { Pos = MAP_APPFONT( 10, 65 ); Size = MAP_APPFONT( 150, 12 ); - Text [en-US] = "~Draw a Border around each page"; + Text [en-US] = "Draw a border around each page"; + HelpText [en-US] = "Check to draw a border around each page."; }; }; @@ -267,11 +292,13 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 100, 80 ); Border = TRUE; + HelpText [en-US] = "Select the printer to print on."; }; PushButton SV_PRINT_DETAILS_BTN { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 5, 5 ); + HelpText [en-US] = "Show/Hide detailed information of the selected printer."; }; FixedText SV_PRINT_DETAILS_TXT { @@ -302,6 +329,7 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 115, 5 ); Size = MAP_APPFONT( 50, 15 ); Text [en-US] = "Properties..."; + HelpText [en-US] = "Call the setup dialog of the selected printer."; }; FixedLine SV_PRINT_COPIES { @@ -324,6 +352,7 @@ ModalDialog SV_DLG_PRINT Minimum = 1; Maximum = 16384; Value = 1; + HelpText [en-US] = "Select the number of copies to be produced."; }; FixedImage SV_PRINT_COLLATE_IMAGE { @@ -335,6 +364,7 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 95, 45 ); Size = MAP_APPFONT( 70, 10 ); Text [en-US] = "Collate"; + HelpText [en-US] = "Select whether copies should be collated or not."; }; Image SV_PRINT_COLLATE_IMG @@ -374,18 +404,21 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 10, 20 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print to ~file"; + HelpText [en-US] = "Check to send output to a file instead of the actual printer."; }; CheckBox SV_PRINT_OPT_SINGLEJOBS { Pos = MAP_APPFONT( 10, 35 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "~Create single print jobs for collated output"; + HelpText [en-US] = "Check to not rely on the printer to create collated copies but create a print job for each copy instead."; }; CheckBox SV_PRINT_OPT_REVERSE { Pos = MAP_APPFONT( 10, 50 ); Size = MAP_APPFONT( 200, 12 ); Text [en-US] = "Print in ~reverse page order"; + HelpText [en-US] = "Check to print pages in reverse order."; }; }; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 9e02de6908ab..6613f16a798b 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -225,7 +225,9 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) - , maNupPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_PAGES_TXT ) ) + , maDefaultBtn( this, VclResId( SV_PRINT_PRT_NUP_DEFAULT_BTN ) ) + , maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) ) + , maPagesBtn( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BTN ) ) , maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) ) , maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) @@ -245,6 +247,9 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) FreeResource(); maNupOrderWin.Show(); + maDefaultBtn.Check( TRUE ); + maBrochureBtn.Show( FALSE ); + enableNupControls( false ); // setup field units for metric fields const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); @@ -264,7 +269,9 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maSheetMarginEdt.SetDecimalDigits( nDigits ); maNupLine.SMHID2("NUpPage", "Layout"); - maNupPagesTxt.SMHID2( "NUpPage", "PagesPerSheet" ); + maDefaultBtn.SMHID2("NUpPage", "Default" ); + maBrochureBtn.SMHID2("NUpPage", "Brochure" ); + maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" ); maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" ); maNupNumPagesTxt.SMHID2( "NUpPage", "Columns" ); maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" ); @@ -287,6 +294,25 @@ PrintDialog::NUpTabPage::~NUpTabPage() { } +void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) +{ + maNupPagesBox.Enable( bEnable ); + maNupNumPagesTxt.Enable( bEnable ); + maNupColEdt.Enable( bEnable ); + maNupTimesTxt.Enable( bEnable ); + maNupRowsEdt.Enable( bEnable ); + maPageMarginTxt.Enable( bEnable ); + maPageMarginEdt.Enable( bEnable ); + maSheetMarginTxt.Enable( bEnable ); + maSheetMarginEdt.Enable( bEnable ); + maNupOrientationTxt.Enable( bEnable ); + maNupOrientationBox.Enable( bEnable ); + maNupOrderTxt.Enable( bEnable ); + maNupOrderBox.Enable( bEnable ); + maNupOrderWin.Enable( bEnable ); + maBorderCB.Enable( bEnable ); +} + void PrintDialog::NUpTabPage::setupLayout() { Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); @@ -308,22 +334,37 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); + xCol->addWindow( &maDefaultBtn ); + xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); + xCol->addChild( xRow ); + xRow->addWindow( &maBrochureBtn ); + // remember brochure row for dependencies + mxBrochureDep = xRow; boost::shared_ptr< vcl::LabeledElement > xLabel( new vcl::LabeledElement( xCol.get() ) ); xCol->addChild( xLabel ); - xLabel->setLabel( &maNupPagesTxt ); + xLabel->setLabel( &maPagesBtn ); xLabel->setElement( &maNupPagesBox ); xIndent.reset( new vcl::Indenter( xCol.get() ) ); xCol->addChild( xIndent ); - // remember advanced controls to show/hide - mxAdvancedControls = xIndent; mxLayoutGroup = xCol; xCol.reset( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); + boost::shared_ptr< vcl::RowOrColumn > xAdvCol( new vcl::RowOrColumn( xCol.get() ) ); + xCol->addChild( xAdvCol ); + // remember advanced controls to show/hide + mxAdvancedControls = xAdvCol; + + xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); + xCol->addChild( xLabel ); + xLabel->setLabel( &maNupOrderTxt ); + xLabel->setElement( &maNupOrderBox ); + xCol->addWindow( &maBorderCB ); + + xRow.reset( new vcl::RowOrColumn( xAdvCol.get(), false ) ); + xAdvCol->addChild( xRow ); xLabel.reset( new vcl::LabeledElement( xRow.get() ) ); xRow->addChild( xLabel, 1 ); xLabel->setLabel( &maNupNumPagesTxt ); @@ -333,28 +374,21 @@ void PrintDialog::NUpTabPage::setupLayout() xLabel->setLabel( &maNupTimesTxt ); xLabel->setElement( &maNupRowsEdt ); - xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); + xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); + xAdvCol->addChild( xLabel ); xLabel->setLabel( &maPageMarginTxt ); xLabel->setElement( &maPageMarginEdt ); - xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); + xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); + xAdvCol->addChild( xLabel ); xLabel->setLabel( &maSheetMarginTxt ); xLabel->setElement( &maSheetMarginEdt ); - xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); + xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); + xAdvCol->addChild( xLabel ); xLabel->setLabel( &maNupOrientationTxt ); xLabel->setElement( &maNupOrientationBox ); - xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); - xLabel->setLabel( &maNupOrderTxt ); - xLabel->setElement( &maNupOrderBox ); - - mxLayoutGroup->addWindow( &maBorderCB ); - // initially advanced controls are not show, rows=columns=1 mxAdvancedControls->show( false, false ); } @@ -733,6 +767,8 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetChild( pCurColumn ); } + // EVIL + else if( aCtrlType.equalsAscii( "Bool" ) && + aGroupingHint.equalsAscii( "LayoutPage" ) && + aPropertyName.equalsAscii( "PrintBrochure" ) + ) + { + maNUpPage.maBrochureBtn.SetText( aText ); + maNUpPage.maBrochureBtn.Show(); + setHelpText( &maNUpPage.maBrochureBtn, aHelpTexts, 0 ); + + sal_Bool bVal = sal_False; + PropertyValue* pVal = maPController->getValue( aPropertyName ); + if( pVal ) + pVal->Value >>= bVal; + maNUpPage.maBrochureBtn.Check( bVal ); + maNUpPage.maBrochureBtn.Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); + maNUpPage.maBrochureBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); + + maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, &maNUpPage.maBrochureBtn ) ); + maControlToPropertyMap[&maNUpPage.maBrochureBtn] = aPropertyName; + + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, maNUpPage.mxBrochureDep.get() ) ); + } else { vcl::RowOrColumn* pSaveCurColumn = pCurColumn; @@ -1710,6 +1769,30 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); maLayout.resize(); } + else if( pButton == &maNUpPage.maDefaultBtn ) + { + maNUpPage.enableNupControls( false ); + } + else if( pButton == &maNUpPage.maBrochureBtn ) + { + PropertyValue* pVal = getValueForWindow( pButton ); + if( pVal ) + { + sal_Bool bVal = maNUpPage.maBrochureBtn.IsChecked(); + pVal->Value <<= bVal; + + checkOptionalControlDependencies(); + + // update preview and page settings + preparePreview(); + } + if( maNUpPage.maBrochureBtn.IsChecked() ) + maNUpPage.enableNupControls( false ); + } + else if( pButton == &maNUpPage.maPagesBtn ) + { + maNUpPage.enableNupControls( true ); + } else if( pButton == &maJobPage.maDetailsBtn ) { bool bShow = ! maJobPage.maStatusTxt.IsVisible(); diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index d70f607a6cc6..af2043fda516 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1459,7 +1459,6 @@ ULONG Window::GetHelpId() const void Window::SetSmartHelpId( const SmartId& aId, SmartIdUpdateMode aMode ) { - mpWindowImpl->maHelpText = String(); // create SmartId if required if ( (aMode == SMART_SET_STR) || (aMode == SMART_SET_ALL) || ( (aMode == SMART_SET_SMART) && aId.HasString() ) ) { From 555cb390d2bffdd7fde2e86e3141f83a2f63017a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 1 Aug 2009 15:43:09 +0000 Subject: [PATCH 151/283] #i92518# lates UI changes --- vcl/source/src/print.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index a7be46fa6a59..673f1f00e54e 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -452,7 +452,7 @@ StringArray SV_PRINT_NATIVE_STRINGS ItemList [en-US] = { < "Preview"; >; - < "Page Number"; >; + < "Page number"; >; < "Number of pages"; >; < "More"; >; }; From aa1bc916363ca7ad301aea22bb2e162aadad784b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 3 Aug 2009 11:26:33 +0000 Subject: [PATCH 152/283] #i92518# latest fashion updates --- vcl/inc/vcl/prndlg.hxx | 4 +- vcl/source/window/printdlg.cxx | 157 +++++++++++++++++---------------- 2 files changed, 85 insertions(+), 76 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 6e3b4b0508c7..3f82c6aef266 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -95,9 +95,8 @@ namespace vcl { public: FixedLine maNupLine; - RadioButton maDefaultBtn; - RadioButton maBrochureBtn; RadioButton maPagesBtn; + RadioButton maBrochureBtn; ListBox maNupPagesBox; // controls for "Custom" page mode @@ -245,6 +244,7 @@ namespace vcl Size getJobPageSize(); void updateNup(); + void updateNupFromPages(); void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); void setPreviewText( sal_Int32 ); void updatePrinterText(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 6613f16a798b..4bd358035cb6 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -225,9 +225,8 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) : TabPage( i_pParent, rResId ) , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) - , maDefaultBtn( this, VclResId( SV_PRINT_PRT_NUP_DEFAULT_BTN ) ) - , maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) ) , maPagesBtn( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BTN ) ) + , maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) ) , maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) ) , maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) @@ -247,9 +246,8 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) FreeResource(); maNupOrderWin.Show(); - maDefaultBtn.Check( TRUE ); + maPagesBtn.Check( TRUE ); maBrochureBtn.Show( FALSE ); - enableNupControls( false ); // setup field units for metric fields const LocaleDataWrapper& rLocWrap( maPageMarginEdt.GetLocaleDataWrapper() ); @@ -269,7 +267,6 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maSheetMarginEdt.SetDecimalDigits( nDigits ); maNupLine.SMHID2("NUpPage", "Layout"); - maDefaultBtn.SMHID2("NUpPage", "Default" ); maBrochureBtn.SMHID2("NUpPage", "Brochure" ); maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" ); maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" ); @@ -323,7 +320,7 @@ void PrintDialog::NUpTabPage::setupLayout() maLayout.addWindow( &maNupLine ); boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) ); maLayout.addChild( xRow ); - boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) ); + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get(), 3*aBorder.Width() ) ); xRow->addChild( xIndent ); boost::shared_ptr< vcl::RowOrColumn > xShowNupCol( new vcl::RowOrColumn( xRow.get() ) ); @@ -332,24 +329,19 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xShowNupCol.get() ) ); xShowNupCol->addChild( xSpacer ); - boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); - xIndent->setChild( xCol ); - xCol->addWindow( &maDefaultBtn ); - xRow.reset( new vcl::RowOrColumn( xCol.get(), false ) ); - xCol->addChild( xRow ); - xRow->addWindow( &maBrochureBtn ); - // remember brochure row for dependencies - mxBrochureDep = xRow; - boost::shared_ptr< vcl::LabeledElement > xLabel( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); + boost::shared_ptr< vcl::RowOrColumn > xMainCol( new vcl::RowOrColumn( xIndent.get() ) ); + xIndent->setChild( xMainCol ); + + boost::shared_ptr< vcl::LabeledElement > xLabel( new vcl::LabeledElement( xMainCol.get() ) ); + xMainCol->addChild( xLabel ); xLabel->setLabel( &maPagesBtn ); xLabel->setElement( &maNupPagesBox ); - xIndent.reset( new vcl::Indenter( xCol.get() ) ); - xCol->addChild( xIndent ); + xIndent.reset( new vcl::Indenter( xMainCol.get() ) ); + xMainCol->addChild( xIndent ); - mxLayoutGroup = xCol; - xCol.reset( new vcl::RowOrColumn( xIndent.get() ) ); + mxLayoutGroup = xMainCol; + boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); xIndent->setChild( xCol ); boost::shared_ptr< vcl::RowOrColumn > xAdvCol( new vcl::RowOrColumn( xCol.get() ) ); @@ -389,6 +381,15 @@ void PrintDialog::NUpTabPage::setupLayout() xLabel->setLabel( &maNupOrientationTxt ); xLabel->setElement( &maNupOrientationBox ); + xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); + xMainCol->addChild( xRow ); + xRow->addWindow( &maBrochureBtn ); + // remember brochure row for dependencies + mxBrochureDep = xRow; + + xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, 2*aBorder.Width() ) ) ); + xMainCol->addChild( xSpacer ); + // initially advanced controls are not show, rows=columns=1 mxAdvancedControls->show( false, false ); } @@ -439,7 +440,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maNoCollateImg( VclResId( SV_PRINT_NOCOLLATE_IMG ) ) , maNoCollateHCImg( VclResId( SV_PRINT_NOCOLLATE_HC_IMG ) ) , mnCollateUIMode( 0 ) - , maLayout( NULL, true, 0 ) + , maLayout( NULL, true ) { FreeResource(); maPrinterFL.SMHID2( "JobPage", "Printer" ); @@ -767,7 +768,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrshow( bCustom ); + + updateNup(); +} + void PrintDialog::updateNup() { int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); @@ -1696,54 +1750,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) } else if( pBox == &maNUpPage.maNupPagesBox ) { - long nPages = long(maNUpPage.maNupPagesBox.GetEntryData(maNUpPage.maNupPagesBox.GetSelectEntryPos())); - int nRows = int(maNUpPage.maNupRowsEdt.GetValue()); - int nCols = int(maNUpPage.maNupColEdt.GetValue()); - long nPageMargin = long(maNUpPage.maPageMarginEdt.Denormalize(maNUpPage.maPageMarginEdt.GetValue( FUNIT_100TH_MM ))); - long nSheetMargin = long(maNUpPage.maSheetMarginEdt.Denormalize(maNUpPage.maSheetMarginEdt.GetValue( FUNIT_100TH_MM ))); - bool bCustom = false; - - if( nPages == 1 ) - { - nRows = nCols = 1; - nSheetMargin = 0; - } - else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 ) - { - Size aJobPageSize( getJobPageSize() ); - bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height(); - if( nPages == 2 ) - { - if( bPortrait ) - nRows = 1, nCols = 2; - else - nRows = 2, nCols = 1; - } - else if( nPages == 4 ) - nRows = nCols = 2; - else if( nPages == 6 ) - { - if( bPortrait ) - nRows = 2, nCols = 3; - else - nRows = 3, nCols = 2; - } - else if( nPages == 9 ) - nRows = nCols = 3; - else if( nPages == 16 ) - nRows = nCols = 4; - nPageMargin = 500; - nSheetMargin = 500; - } - else - bCustom = true; - - maNUpPage.maNupRowsEdt.SetValue( nRows ); - maNUpPage.maNupColEdt.SetValue( nCols ); - maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM ); - maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM ); - updateNup(); - maNUpPage.mxAdvancedControls->show( bCustom ); + updateNupFromPages(); } return 0; @@ -1769,10 +1776,6 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) maOKButton.SetText( maOptionsPage.maToFileBox.IsChecked() ? maPrintToFileText : maPrintText ); maLayout.resize(); } - else if( pButton == &maNUpPage.maDefaultBtn ) - { - maNUpPage.enableNupControls( false ); - } else if( pButton == &maNUpPage.maBrochureBtn ) { PropertyValue* pVal = getValueForWindow( pButton ); @@ -1787,11 +1790,17 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) preparePreview(); } if( maNUpPage.maBrochureBtn.IsChecked() ) + { + maNUpPage.maNupPagesBox.SelectEntryPos( 0 ); + updateNupFromPages(); + maNUpPage.mxAdvancedControls->show( false ); maNUpPage.enableNupControls( false ); + } } else if( pButton == &maNUpPage.maPagesBtn ) { maNUpPage.enableNupControls( true ); + updateNupFromPages(); } else if( pButton == &maJobPage.maDetailsBtn ) { From 360a88378c48cba41958327bb05c8d82f82ba234 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 3 Aug 2009 15:15:39 +0000 Subject: [PATCH 153/283] #i92518# latest fashion updates --- vcl/source/window/printdlg.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 4bd358035cb6..902c2213681d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -320,7 +320,7 @@ void PrintDialog::NUpTabPage::setupLayout() maLayout.addWindow( &maNupLine ); boost::shared_ptr< vcl::RowOrColumn > xRow( new vcl::RowOrColumn( &maLayout, false ) ); maLayout.addChild( xRow ); - boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get(), 3*aBorder.Width() ) ); + boost::shared_ptr< vcl::Indenter > xIndent( new vcl::Indenter( xRow.get() ) ); xRow->addChild( xIndent ); boost::shared_ptr< vcl::RowOrColumn > xShowNupCol( new vcl::RowOrColumn( xRow.get() ) ); @@ -337,7 +337,7 @@ void PrintDialog::NUpTabPage::setupLayout() xLabel->setLabel( &maPagesBtn ); xLabel->setElement( &maNupPagesBox ); - xIndent.reset( new vcl::Indenter( xMainCol.get() ) ); + xIndent.reset( new vcl::Indenter( xMainCol.get(), 3*aBorder.Width() ) ); xMainCol->addChild( xIndent ); mxLayoutGroup = xMainCol; @@ -381,6 +381,9 @@ void PrintDialog::NUpTabPage::setupLayout() xLabel->setLabel( &maNupOrientationTxt ); xLabel->setElement( &maNupOrientationBox ); + xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, aBorder.Width() ) ) ); + xMainCol->addChild( xSpacer ); + xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); xMainCol->addChild( xRow ); xRow->addWindow( &maBrochureBtn ); From a793801516881bf70ffbf7dcb8284d53a0f2246d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 3 Aug 2009 15:51:37 +0000 Subject: [PATCH 154/283] #i92518# latest fashion updates --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/inc/vcl/svids.hrc | 23 +++++++------- vcl/source/src/print.src | 5 ++++ vcl/source/window/printdlg.cxx | 55 ++++++++++++++++++++++++++-------- 4 files changed, 61 insertions(+), 23 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 3f82c6aef266..5cf9faac5b9c 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -205,6 +205,7 @@ namespace vcl OKButton maOKButton; CancelButton maCancelButton; + HelpButton maHelpButton; PrintPreviewWindow maPreviewWindow; NumericField maPageEdit; FixedText maNumPagesText; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 9ce6d2781012..5ec6ff3d9901 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -77,17 +77,18 @@ #define SV_DLG_PRINT 2048 #define SV_PRINT_OK 1 #define SV_PRINT_CANCEL 2 -#define SV_PRINT_PAGE_PREVIEW 3 -#define SV_PRINT_PAGE_TXT 4 -#define SV_PRINT_PAGE_FORWARD 5 -#define SV_PRINT_PAGE_BACKWARD 6 -#define SV_PRINT_PAGE_EDIT 7 -#define SV_PRINT_TABCTRL 8 -#define SV_PRINT_PRT_TYPE 9 -#define SV_PRINT_PRT_STATUS 10 -#define SV_PRINT_PRT_LOCATION 11 -#define SV_PRINT_PRT_COMMENT 12 -#define SV_PRINT_TOFILE_TXT 13 +#define SV_PRINT_HELP 3 +#define SV_PRINT_PAGE_PREVIEW 4 +#define SV_PRINT_PAGE_TXT 5 +#define SV_PRINT_PAGE_FORWARD 6 +#define SV_PRINT_PAGE_BACKWARD 7 +#define SV_PRINT_PAGE_EDIT 8 +#define SV_PRINT_TABCTRL 9 +#define SV_PRINT_PRT_TYPE 10 +#define SV_PRINT_PRT_STATUS 11 +#define SV_PRINT_PRT_LOCATION 12 +#define SV_PRINT_PRT_COMMENT 13 +#define SV_PRINT_TOFILE_TXT 14 #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP_LAYOUT_FL 1 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 673f1f00e54e..a7cd7bc237e0 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -53,6 +53,11 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 295, 195 ); Size = MAP_APPFONT( 50, 15 ); }; + HelpButton SV_PRINT_HELP + { + Pos = MAP_APPFONT( 5, 5 ); + Size = MAP_APPFONT( 50, 15 ); + }; Window SV_PRINT_PAGE_PREVIEW { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 902c2213681d..eeb42437f47a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -44,6 +44,7 @@ #include "vcl/configsettings.hxx" #include "vcl/help.hxx" #include "vcl/decoview.hxx" +#include "vcl/svapp.hxx" #include "unotools/localedatawrapper.hxx" @@ -393,7 +394,7 @@ void PrintDialog::NUpTabPage::setupLayout() xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, 2*aBorder.Width() ) ) ); xMainCol->addChild( xSpacer ); - // initially advanced controls are not show, rows=columns=1 + // initially advanced controls are not shown, rows=columns=1 mxAdvancedControls->show( false, false ); } @@ -663,6 +664,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr 1 maCancelButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); #endif + maHelpButton.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maForwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maBackwardBtn.SetClickHdl( LINK( this, PrintDialog, ClickHdl ) ); maJobPage.maCollateBox.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); @@ -866,10 +869,12 @@ void PrintDialog::setupLayout() nIndex = maLayout.addChild( xButtons ); maLayout.setBorders( nIndex, aBorder.Width(), 0, aBorder.Width(), aBorder.Width() ); - // insert a spacer, buttons are right aligned + Size aMinSize( maCancelButton.GetSizePixel() ); + // insert help button + xButtons->setMinimumSize( xButtons->addWindow( &maHelpButton ), aMinSize ); + // insert a spacer, cancel and OK buttons are right aligned xSpacer.reset( new vcl::Spacer( xButtons.get(), 2 ) ); xButtons->addChild( xSpacer ); - Size aMinSize( maCancelButton.GetSizePixel() ); xButtons->setMinimumSize( xButtons->addWindow( &maOKButton ), aMinSize ); xButtons->setMinimumSize( xButtons->addWindow( &maCancelButton ), aMinSize ); } @@ -958,6 +963,14 @@ static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_r i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] ); } +void updateMaxSize( const Size& i_rCheckSize, Size& o_rMaxSize ) +{ + if( i_rCheckSize.Width() > o_rMaxSize.Width() ) + o_rMaxSize.Width() = i_rCheckSize.Width(); + if( i_rCheckSize.Height() > o_rMaxSize.Height() ) + o_rMaxSize.Height() = i_rCheckSize.Height(); +} + void PrintDialog::setupOptionalUI() { Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); @@ -1436,21 +1449,17 @@ void PrintDialog::setupOptionalUI() // calculate job page Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); + // and layout page + updateMaxSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); + // and options page + updateMaxSize( maOptionsPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ), aMaxSize ); - Size aMaxPageSize; for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); it != aDynamicColumns.end(); ++it ) { Size aPageSize( (*it)->getOptimalSize( WINDOWSIZE_PREFERRED ) ); - if( aPageSize.Width() > aMaxPageSize.Width() ) - aMaxPageSize.Width() = aPageSize.Width(); - if( aPageSize.Height() > aMaxPageSize.Height() ) - aMaxPageSize.Height() = aPageSize.Height(); + updateMaxSize( aPageSize, aMaxSize ); } - if( aMaxPageSize.Width() > aMaxSize.Width() ) - aMaxSize.Width() = aMaxPageSize.Width(); - if( aMaxPageSize.Height() > aMaxSize.Height() ) - aMaxSize.Height() = aMaxPageSize.Height(); // resize dialog if necessary Size aTabSize = maTabCtrl.GetTabPageSizePixel(); @@ -1679,6 +1688,18 @@ void PrintDialog::updateNupFromPages() maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM ); maNUpPage.mxAdvancedControls->show( bCustom ); + if( bCustom ) + { + // see if we have to enlarge the dialog to make the tab page fit + Size aCurSize( maNUpPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ) ); + Size aTabSize( maTabCtrl.GetTabPageSizePixel() ); + if( aTabSize.Height() < aCurSize.Height() ) + { + Size aDlgSize( GetSizePixel() ); + aDlgSize.Height() += aCurSize.Height() - aTabSize.Height(); + SetSizePixel( aDlgSize ); + } + } updateNup(); } @@ -1766,6 +1787,16 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) storeToSettings(); EndDialog( pButton == &maOKButton ); } + else if( pButton == &maHelpButton ) + { + // start help system + Help* pHelp = Application::GetHelp(); + if( pHelp ) + { + // FIXME: find out proper help URL and use here + pHelp->Start( 0, GetParent() ); + } + } else if( pButton == &maForwardBtn ) { previewForward(); From e22c6a289e98b6ee7889b41851cad6fff5b67361 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Aug 2009 14:46:00 +0000 Subject: [PATCH 155/283] #i103253# #i103252# fix headless printing, duplicate free --- vcl/aqua/source/gdi/salprn.cxx | 10 ++++++++-- vcl/source/gdi/print3.cxx | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 7a5b0c7ba483..b3bc494bde17 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -40,6 +40,7 @@ #include "vcl/salptype.hxx" #include "vcl/print.hxx" #include "vcl/unohelp.hxx" +#include "vcl/svapp.hxx" #include @@ -545,6 +546,8 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, beans::PropertyValue* pMonitor = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); if( pMonitor ) pMonitor->Value >>= bShowProgressPanel; + if( Application::IsHeadlessModeEnabled() ) + bShowProgressPanel = sal_False; // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) // how do I know when that might be ? @@ -607,7 +610,10 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, [pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rController.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies]; [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting]; [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage]; - [pPrintDict setObject: [[NSNumber numberWithInt: mnCurPageRangeCount] autorelease] forKey: NSPrintLastPage]; + // #i103253# weird: for some reason, autoreleasing the value below like the others above + // leads do a double free malloc error. Why this value should behave differently from all the others + // is a mystery. + [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage]; // create print operation @@ -616,7 +622,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( pPrintOperation ) { NSObject* pReleaseAfterUse = nil; - bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() ); + bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() && ! Application::IsHeadlessModeEnabled() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 72f955e428cb..8251c5f2f506 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -267,7 +267,7 @@ void Printer::PrintJob( const boost::shared_ptr& i_pControlle ) { sal_Bool bSynchronous = sal_False; - beans::PropertyValue* pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + beans::PropertyValue* pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Wait" ) ) ); if( pVal ) pVal->Value >>= bSynchronous; @@ -329,7 +329,10 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr // in that case leave the work to that dialog const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); bool bIsQuick = rQuick.Len() && rQuick.EqualsIgnoreCaseAscii( "true" ); - if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && ! bIsQuick ) + if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && + ! bIsQuick && + ! Application::IsHeadlessModeEnabled() + ) { try { @@ -1108,7 +1111,7 @@ void PrinterController::createProgressDialog() if( pMonitor ) pMonitor->Value >>= bShow; - if( bShow ) + if( bShow && ! Application::IsHeadlessModeEnabled() ) { mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCount() ); mpImplData->mpProgress->Show(); From 4bcda09aeec59e01797f96a163f408b642491a46 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Aug 2009 15:02:39 +0000 Subject: [PATCH 156/283] #i96606# fix API print (no dialogs) --- vcl/aqua/source/gdi/salprn.cxx | 5 ++--- vcl/inc/vcl/print.hxx | 2 ++ vcl/source/gdi/print3.cxx | 11 ++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index b3bc494bde17..d68c026d5ebe 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -40,7 +40,6 @@ #include "vcl/salptype.hxx" #include "vcl/print.hxx" #include "vcl/unohelp.hxx" -#include "vcl/svapp.hxx" #include @@ -546,7 +545,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, beans::PropertyValue* pMonitor = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); if( pMonitor ) pMonitor->Value >>= bShowProgressPanel; - if( Application::IsHeadlessModeEnabled() ) + if( ! i_rController.isShowDialogs() ) bShowProgressPanel = sal_False; // FIXME: jobStarted() should be done after the print dialog has ended (if there is one) @@ -622,7 +621,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( pPrintOperation ) { NSObject* pReleaseAfterUse = nil; - bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() && ! Application::IsHeadlessModeEnabled() ); + bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() && i_rController.isShowDialogs() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 94680d10d3e7..789571bc7d0e 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -486,6 +486,8 @@ public: void abortJob(); + bool isShowDialogs() const; + // implementation details, not usable outside vcl SAL_DLLPRIVATE int getFilteredPageCount(); SAL_DLLPRIVATE Size getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 8251c5f2f506..c7ad36a48d7c 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -331,7 +331,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr bool bIsQuick = rQuick.Len() && rQuick.EqualsIgnoreCaseAscii( "true" ); if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && ! bIsQuick && - ! Application::IsHeadlessModeEnabled() + pController->isShowDialogs() ) { try @@ -1143,6 +1143,15 @@ void PrinterController::pushPropertiesToPrinter() mpImplData->mpPrinter->SetCopyCount( static_cast(nCopyCount), bCollate ); } +bool PrinterController::isShowDialogs() const +{ + sal_Bool bApi = sal_False; + const com::sun::star::beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsApi" ) ) ); + if( pVal ) + pVal->Value >>= bApi; + return ! bApi && ! Application::IsHeadlessModeEnabled(); +} + /* * PrinterOptionsHelper **/ From 712176f85a73d77d7cfef92350ebfaa3d30ef79f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Aug 2009 15:46:46 +0000 Subject: [PATCH 157/283] get rid of old cruft --- vcl/aqua/inc/salprn.h | 7 +-- vcl/aqua/source/gdi/salprn.cxx | 22 +++------ vcl/inc/vcl/print.hxx | 2 +- vcl/inc/vcl/salprn.hxx | 4 +- vcl/os2/inc/salprn.h | 4 +- vcl/os2/source/gdi/salprn.cxx | 4 +- vcl/source/gdi/print.cxx | 82 -------------------------------- vcl/source/gdi/print3.cxx | 21 +++++--- vcl/unx/headless/svpprn.hxx | 4 +- vcl/unx/inc/salprn.h | 4 +- vcl/unx/source/gdi/salprnpsp.cxx | 15 ++---- vcl/win/inc/salprn.h | 4 +- vcl/win/source/gdi/salprn.cxx | 4 +- 13 files changed, 52 insertions(+), 125 deletions(-) diff --git a/vcl/aqua/inc/salprn.h b/vcl/aqua/inc/salprn.h index a572641dd59e..bf9c3c25bc87 100644 --- a/vcl/aqua/inc/salprn.h +++ b/vcl/aqua/inc/salprn.h @@ -106,8 +106,7 @@ class AquaSalInfoPrinter : public SalInfoPrinter const String& rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterController& i_rController, - bool bIsQuickJob ); + vcl::PrinterController& i_rController ); BOOL EndJob(); BOOL AbortJob(); SalGraphics* StartPage( ImplJobSetup* i_pSetupData, BOOL i_bNewJobData ); @@ -142,7 +141,9 @@ class AquaSalPrinter : public SalPrinter virtual BOOL StartJob( const XubString* i_pFileName, const XubString& i_rJobName, const XubString& i_rAppName, - ULONG i_nCopies, BOOL i_bCollate, + ULONG i_nCopies, + bool i_bCollate, + bool i_bDirect, ImplJobSetup* i_pSetupData ); // implement pull model print system virtual BOOL StartJob( const String* i_pFileName, diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index d68c026d5ebe..6575f89d3fa0 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -519,8 +519,8 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, const String& i_rJobName, const String& i_rAppName, ImplJobSetup* i_pSetupData, - vcl::PrinterController& i_rController, - bool bIsQuickJob ) + vcl::PrinterController& i_rController + ) { if( mbJob ) return FALSE; @@ -621,7 +621,7 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, if( pPrintOperation ) { NSObject* pReleaseAfterUse = nil; - bool bShowPanel = (! bIsQuickJob && getUseNativeDialog() && i_rController.isShowDialogs() ); + bool bShowPanel = (! i_rController.isDirectPrint() && getUseNativeDialog() && i_rController.isShowDialogs() ); [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ]; [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO]; @@ -736,17 +736,7 @@ BOOL AquaSalPrinter::StartJob( const String* i_pFileName, ImplJobSetup* i_pSetupData, vcl::PrinterController& i_rController ) { - bool bIsQuickJob = false; - std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator quick_it = - i_pSetupData->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ); - - if( quick_it != i_pSetupData->maValueMap.end() ) - { - if( quick_it->second.equalsIgnoreAsciiCaseAscii( "true" ) ) - bIsQuickJob = true; - } - - return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController, bIsQuickJob ); + return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController ); } // ----------------------------------------------------------------------- @@ -754,7 +744,9 @@ BOOL AquaSalPrinter::StartJob( const String* i_pFileName, BOOL AquaSalPrinter::StartJob( const XubString* i_pFileName, const XubString& i_rJobName, const XubString& i_rAppName, - ULONG i_nCopies, BOOL i_bCollate, + ULONG i_nCopies, + bool i_bCollate, + bool i_bDirect, ImplJobSetup* i_pSetupData ) { DBG_ERROR( "should never be called" ); diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 789571bc7d0e..d5d42466b611 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -270,7 +270,6 @@ private: private: SAL_DLLPRIVATE void ImplEndPrint(); - SAL_DLLPRIVATE BOOL StartJob( const XubString& rJobName ); SAL_DLLPRIVATE BOOL EndJob(); SAL_DLLPRIVATE Printer( const Printer& rPrinter ); SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter ); @@ -487,6 +486,7 @@ public: void abortJob(); bool isShowDialogs() const; + bool isDirectPrint() const; // implementation details, not usable outside vcl SAL_DLLPRIVATE int getFilteredPageCount(); diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx index 4ffa969a674f..73f5454457cf 100644 --- a/vcl/inc/vcl/salprn.hxx +++ b/vcl/inc/vcl/salprn.hxx @@ -116,7 +116,9 @@ public: // public for Sal Implementation virtual BOOL StartJob( const String* pFileName, const String& rJobName, const String& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ) = 0; // implement for pull model print systems only, diff --git a/vcl/os2/inc/salprn.h b/vcl/os2/inc/salprn.h index bddb29f61442..2c95965bc609 100644 --- a/vcl/os2/inc/salprn.h +++ b/vcl/os2/inc/salprn.h @@ -135,7 +135,9 @@ public: virtual BOOL StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/os2/source/gdi/salprn.cxx b/vcl/os2/source/gdi/salprn.cxx index b8207ed317f2..a31a4bb779f8 100644 --- a/vcl/os2/source/gdi/salprn.cxx +++ b/vcl/os2/source/gdi/salprn.cxx @@ -1559,7 +1559,9 @@ Os2SalPrinter::~Os2SalPrinter() BOOL Os2SalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ) { DEVOPENSTRUC aDevOpenStruc; diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 0ff5f283b5fa..eee954076278 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1257,88 +1257,6 @@ IMPL_LINK( Printer, ImplDestroyPrinterAsync, void*, pSalPrinter ) // ----------------------------------------------------------------------- -BOOL Printer::StartJob( const XubString& rJobName ) -{ - mnError = PRINTER_OK; - - if ( IsDisplayPrinter() ) - return FALSE; - - if ( IsJobActive() || IsPrinting() ) - return FALSE; - - ULONG nCopies = mnCopyCount; - BOOL bCollateCopy = mbCollateCopy; - BOOL bUserCopy = FALSE; - if ( nCopies > 1 ) - { - ULONG nDevCopy; - - if ( bCollateCopy ) - nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COLLATECOPIES ); - else - nDevCopy = GetCapabilities( PRINTER_CAPABILITIES_COPIES ); - - // Muessen Kopien selber gemacht werden? - if ( nCopies > nDevCopy ) - { - bUserCopy = TRUE; - nCopies = 1; - bCollateCopy = FALSE; - } - } - else - bCollateCopy = FALSE; - - ImplSVData* pSVData = ImplGetSVData(); - mpPrinter = pSVData->mpDefInst->CreatePrinter( mpInfoPrinter ); - - if ( !mpPrinter ) - return FALSE; - - XubString* pPrintFile; - if ( mbPrintFile ) - pPrintFile = &maPrintFile; - else - pPrintFile = NULL; - - // #125075# StartJob can Reschedule on Windows, sfx - // depends on IsPrinting() in case of closing a document - BOOL bSaveNewJobSetup = mbNewJobSetup; - mbNewJobSetup = FALSE; - String aSaveJobName = maJobName; - maJobName = rJobName; - mnCurPage = 1; - mnCurPrintPage = 1; - mbPrinting = TRUE; - - if( ! ImplGetSVData()->maGDIData.mbPrinterPullModel ) - { - if ( !mpPrinter->StartJob( pPrintFile, rJobName, Application::GetDisplayName(), - nCopies, bCollateCopy, - maJobSetup.ImplGetConstData() ) ) - { - mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); - if ( !mnError ) - mnError = PRINTER_GENERALERROR; - pSVData->mpDefInst->DestroyPrinter( mpPrinter ); - mbNewJobSetup = bSaveNewJobSetup; - maJobName = aSaveJobName; - mnCurPage = 0; - mnCurPrintPage = 0; - mbPrinting = FALSE; - mpPrinter = NULL; - return FALSE; - } - } - - mbJobActive = TRUE; - - return TRUE; -} - -// ----------------------------------------------------------------------- - BOOL Printer::EndJob() { BOOL bRet = FALSE; diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index c7ad36a48d7c..1888fbdcad49 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -327,10 +327,8 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr // check if the printer brings up its own dialog // in that case leave the work to that dialog - const String& rQuick( i_rInitSetup.GetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ) ); - bool bIsQuick = rQuick.Len() && rQuick.EqualsIgnoreCaseAscii( "true" ); if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && - ! bIsQuick && + ! pController->isDirectPrint() && pController->isShowDialogs() ) { @@ -382,8 +380,8 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr 1 ) { @@ -475,7 +473,9 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrStartJob( pPrintFile, i_rJobName, Application::GetDisplayName(), - nCopies, bCollateCopy, + nCopies, + bCollateCopy, + i_pController->isDirectPrint(), maJobSetup.ImplGetConstData() ) ) { mbJobActive = TRUE; @@ -1152,6 +1152,15 @@ bool PrinterController::isShowDialogs() const return ! bApi && ! Application::IsHeadlessModeEnabled(); } +bool PrinterController::isDirectPrint() const +{ + sal_Bool bDirect = sal_False; + const com::sun::star::beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDirect" ) ) ); + if( pVal ) + pVal->Value >>= bDirect; + return bDirect == sal_True; +} + /* * PrinterOptionsHelper **/ diff --git a/vcl/unx/headless/svpprn.hxx b/vcl/unx/headless/svpprn.hxx index 154273f6da88..8f5a47fed118 100644 --- a/vcl/unx/headless/svpprn.hxx +++ b/vcl/unx/headless/svpprn.hxx @@ -90,7 +90,9 @@ public: virtual BOOL StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/unx/inc/salprn.h b/vcl/unx/inc/salprn.h index b1c92300ac49..59a5c3eef56a 100644 --- a/vcl/unx/inc/salprn.h +++ b/vcl/unx/inc/salprn.h @@ -90,7 +90,9 @@ public: virtual BOOL StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx index dcdb3431ce59..d47e30a89633 100644 --- a/vcl/unx/source/gdi/salprnpsp.cxx +++ b/vcl/unx/source/gdi/salprnpsp.cxx @@ -928,7 +928,9 @@ BOOL PspSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pJobSetup ) { vcl_sal::PrinterUpdate::jobStarted(); @@ -990,15 +992,6 @@ BOOL PspSalPrinter::StartJob( } m_aPrinterGfx.Init( m_aJobData ); - bool bIsQuickJob = false; - std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator quick_it = - pJobSetup->maValueMap.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ) ); - if( quick_it != pJobSetup->maValueMap.end() ) - { - if( quick_it->second.equalsIgnoreAsciiCaseAscii( "true" ) ) - bIsQuickJob = true; - } - // set/clear backwards compatibility flag bool bStrictSO52Compatibility = false; std::hash_map::const_iterator compat_it = @@ -1011,7 +1004,7 @@ BOOL PspSalPrinter::StartJob( } m_aPrinterGfx.setStrictSO52Compatibility( bStrictSO52Compatibility ); - return m_aPrintJob.StartJob( m_aTmpFile.Len() ? m_aTmpFile : m_aFileName, nMode, rJobName, rAppName, m_aJobData, &m_aPrinterGfx, bIsQuickJob ) ? TRUE : FALSE; + return m_aPrintJob.StartJob( m_aTmpFile.Len() ? m_aTmpFile : m_aFileName, nMode, rJobName, rAppName, m_aJobData, &m_aPrinterGfx, bDirect ) ? TRUE : FALSE; } // ----------------------------------------------------------------------- diff --git a/vcl/win/inc/salprn.h b/vcl/win/inc/salprn.h index 09473cf518e0..890ff70bc3d6 100644 --- a/vcl/win/inc/salprn.h +++ b/vcl/win/inc/salprn.h @@ -116,7 +116,9 @@ public: virtual BOOL StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ); virtual BOOL EndJob(); virtual BOOL AbortJob(); diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx index 7b0dfaf1fa98..8fe9b5d8f4d0 100644 --- a/vcl/win/source/gdi/salprn.cxx +++ b/vcl/win/source/gdi/salprn.cxx @@ -1966,7 +1966,9 @@ static int lcl_StartDocA( HDC hDC, DOCINFOA* pInfo, WinSalPrinter* pPrt ) BOOL WinSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString&, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool bDirect, ImplJobSetup* pSetupData ) { mnError = 0; From aafa25d0a440418cbcff23521862eadcc3c1466f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 5 Aug 2009 16:16:07 +0000 Subject: [PATCH 158/283] get rid of old cruft --- vcl/unx/headless/svpprn.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vcl/unx/headless/svpprn.cxx b/vcl/unx/headless/svpprn.cxx index a0834ed40be6..94d857e230b8 100644 --- a/vcl/unx/headless/svpprn.cxx +++ b/vcl/unx/headless/svpprn.cxx @@ -845,7 +845,9 @@ BOOL PspSalPrinter::StartJob( const XubString* pFileName, const XubString& rJobName, const XubString& rAppName, - ULONG nCopies, BOOL bCollate, + ULONG nCopies, + bool bCollate, + bool /*bDirect*/, ImplJobSetup* pJobSetup ) { vcl_sal::PrinterUpdate::jobStarted(); From cda2521771d4166377f72a811e1801337954b22d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 6 Aug 2009 09:00:23 +0000 Subject: [PATCH 159/283] #i92516# fix a layout problem, fix a warning --- vcl/source/window/printdlg.cxx | 55 ++++------------------------------ vcl/win/source/gdi/salprn.cxx | 2 +- 2 files changed, 6 insertions(+), 51 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index eeb42437f47a..3395e4aff62d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -580,6 +580,7 @@ void PrintDialog::JobTabPage::readFromSettings() rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Collate" ) ) ); maCollateBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); } + Resize(); } void PrintDialog::JobTabPage::storeToSettings() @@ -1489,6 +1490,10 @@ void PrintDialog::setupOptionalUI() delete *it; *it = NULL; } + maJobPage.Resize(); + maNUpPage.Resize(); + maOptionsPage.Resize(); + Resize(); } void PrintDialog::checkControlDependencies() @@ -2029,57 +2034,7 @@ void PrintDialog::Command( const CommandEvent& rEvt ) void PrintDialog::Resize() { - #if 0 - Size aPixDiff( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); - Size aWindowSize( GetOutputSizePixel() ); - - // position buttons from lower end, right to left - Size aBtnSize( maCancelButton.GetSizePixel() ); - Rectangle aBtnRect( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(), - aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ), - aBtnSize ); - maCancelButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - aBtnSize = maOKButton.GetSizePixel(); - aBtnRect = Rectangle( Point( aBtnRect.Left() - aPixDiff.Width() - aBtnSize.Width(), - aWindowSize.Height() - aPixDiff.Height() - aBtnSize.Height() ), - aBtnSize ); - maOKButton.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - aBtnSize = maButtonLine.GetSizePixel(); - - // position fixed line above buttons - aBtnRect = Rectangle( Point( 0, aBtnRect.Top() - aPixDiff.Width() - aBtnSize.Height()/2 ), - Size( aWindowSize.Width(), aBtnSize.Height() ) ); - maButtonLine.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - - // position tab control on upper right - aBtnSize = maTabCtrl.GetSizePixel(); - aBtnRect = Rectangle( Point( aWindowSize.Width() - aPixDiff.Width() - aBtnSize.Width(), - aPixDiff.Height() ), - Size( aBtnSize.Width(), maButtonLine.GetPosPixel().Y() - 2*aPixDiff.Height() ) ); - maTabCtrl.SetPosSizePixel( aBtnRect.TopLeft(), aBtnRect.GetSize() ); - - // set size for preview - long nMaxX = maTabCtrl.GetPosPixel().X() - 2*aPixDiff.Width(); - long nMaxY = maButtonLine.GetPosPixel().Y() - - 4 * aPixDiff.Height() - - maForwardBtn.GetSizePixel().Height(); - long nPreviewLength = std::min( nMaxX, nMaxY ); - maPreviewSpace = Rectangle( Point( aPixDiff.Width(), 2 * aPixDiff.Height() ), - Size( nPreviewLength, nPreviewLength ) ); - - // position text and slider below preview, aligned - Size aPrefSize( maPreviewCtrlRow.getOptimalSize( WINDOWSIZE_PREFERRED ) ); - aPrefSize.Width() = nPreviewLength - 2* aPixDiff.Width(); - Point aCtrlPos( 2*aPixDiff.Width(), 3*aPixDiff.Height() + nPreviewLength ); - maPreviewCtrlRow.setManagedArea( Rectangle( aCtrlPos, aPrefSize ) ); - maPreviewBackground.Left() = aPixDiff.Width() - 2; - maPreviewBackground.Top() = aPixDiff.Height() - 2; - maPreviewBackground.Right() = aPixDiff.Width() + nPreviewLength + 2; - maPreviewBackground.Bottom() = maPreviewCtrlRow.getManagedArea().Bottom() + aPixDiff.Height(); - #else maLayout.setManagedArea( Rectangle( Point( 0, 0 ), GetSizePixel() ) ); - #endif - // and do the preview; however the metafile does not need to be gotten anew preparePreview( false ); diff --git a/vcl/win/source/gdi/salprn.cxx b/vcl/win/source/gdi/salprn.cxx index 8fe9b5d8f4d0..f4f55dd0adbf 100644 --- a/vcl/win/source/gdi/salprn.cxx +++ b/vcl/win/source/gdi/salprn.cxx @@ -1968,7 +1968,7 @@ BOOL WinSalPrinter::StartJob( const XubString* pFileName, const XubString&, ULONG nCopies, bool bCollate, - bool bDirect, + bool /*bDirect*/, ImplJobSetup* pSetupData ) { mnError = 0; From 1472eca629ac41b88ccd492a7fecfbe90a0a90c7 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 6 Aug 2009 18:36:51 +0000 Subject: [PATCH 160/283] #i92516# fix some more layout problems --- vcl/source/control/lstbox.cxx | 6 ++++- vcl/source/window/printdlg.cxx | 15 ++++++----- vcl/win/source/gdi/salnativewidgets-luna.cxx | 27 ++++++++++++++++++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 553ea46f3bce..7c9842c278d1 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1274,7 +1274,11 @@ Size ListBox::CalcMinimumSize() const else { aSz.Height() = mpImplLB->CalcSize( 1 ).Height(); - aSz.Width() = mpImplLB->GetMaxEntryWidth(); + // size to maxmimum entry width and add a little breathing space + aSz.Width() = mpImplLB->GetMaxEntryWidth() + 4; + // do not create ultrathin ListBoxes, it doesn't look good + if( aSz.Width() < GetSettings().GetStyleSettings().GetScrollBarSize() ) + aSz.Width() = GetSettings().GetStyleSettings().GetScrollBarSize(); // try native borders; scrollbar size may not be a good indicator // see how large the edit area inside is to estimate what is needed for the dropdown diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 3395e4aff62d..30f96f4d8081 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1467,22 +1467,23 @@ void PrintDialog::setupOptionalUI() maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); if( aMaxSize.Height() > aTabSize.Height() || aMaxSize.Width() > aTabSize.Width() ) { - Size aCurSize( GetSizePixel() ); + Size aCurSize( GetOutputSizePixel() ); if( aMaxSize.Height() > aTabSize.Height() ) + { aCurSize.Height() += aMaxSize.Height() - aTabSize.Height(); + aTabSize.Height() = aMaxSize.Height(); + } if( aMaxSize.Width() > aTabSize.Width() ) { aCurSize.Width() += aMaxSize.Width() - aTabSize.Width(); // and the tab ctrl needs more space, too aTabSize.Width() = aMaxSize.Width(); - maTabCtrl.SetSizePixel( aTabSize ); - maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); } - SetSizePixel( aCurSize ); + maTabCtrl.SetTabPageSizePixel( aTabSize ); + maTabCtrl.SetMinimumSizePixel( maTabCtrl.GetSizePixel() ); } // and finally arrange controls - aTabSize = maTabCtrl.GetTabPageSizePixel(); for( std::vector< vcl::RowOrColumn* >::iterator it = aDynamicColumns.begin(); it != aDynamicColumns.end(); ++it ) { @@ -1493,7 +1494,9 @@ void PrintDialog::setupOptionalUI() maJobPage.Resize(); maNUpPage.Resize(); maOptionsPage.Resize(); - Resize(); + + Size aSz = maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); + SetOutputSizePixel( aSz ); } void PrintDialog::checkControlDependencies() diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index 5a5703e10944..d1fb2b67c3ec 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -337,7 +337,7 @@ BOOL ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc, cons } -Rectangle ImplGetThemeRect( HTHEME hTheme, HDC hDC, int iPart, int iState, const Rectangle& aRect ) +Rectangle ImplGetThemeRect( HTHEME hTheme, HDC hDC, int iPart, int iState, const Rectangle& aRect, THEMESIZE eTS = TS_TRUE ) { SIZE aSz; RECT rc; @@ -345,7 +345,7 @@ Rectangle ImplGetThemeRect( HTHEME hTheme, HDC hDC, int iPart, int iState, const rc.right = aRect.nRight; rc.top = aRect.nTop; rc.bottom = aRect.nBottom; - HRESULT hr = vsAPI.GetThemePartSize( hTheme, hDC, iPart, iState, NULL, TS_TRUE, &aSz ); // TS_TRUE returns optimal size + HRESULT hr = vsAPI.GetThemePartSize( hTheme, hDC, iPart, iState, NULL, eTS, &aSz ); // TS_TRUE returns optimal size if( hr == S_OK ) return Rectangle( 0, 0, aSz.cx, aSz.cy ); else @@ -1109,6 +1109,29 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, bRet = TRUE; } } + + if( (nType == CTRL_LISTBOX || nType == CTRL_COMBOBOX ) && nPart == PART_ENTIRE_CONTROL ) + { + HTHEME hTheme = getThemeHandle( mhWnd, L"Combobox"); + if( hTheme ) + { + Rectangle aBoxRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, CP_DROPDOWNBUTTON, + CBXS_NORMAL, aBoxRect ) ); + Rectangle aBrdRect( ImplGetThemeRect( hTheme, hDC, CP_BORDER, + CBB_HOT, aBoxRect ) ); + aRect.Top() -= aBrdRect.GetHeight(); + if( aRect.GetHeight() > aBoxRect.GetHeight() ) + aBoxRect.Bottom() = aBoxRect.Top() + aRect.GetHeight(); + if( aRect.GetWidth() > aBoxRect.GetWidth() ) + aBoxRect.Right() = aBoxRect.Left() + aRect.GetWidth(); + rNativeContentRegion = aBoxRect; + rNativeBoundingRegion = rNativeContentRegion; + if( !aRect.IsEmpty() ) + bRet = TRUE; + } + } + ReleaseDC( mhWnd, hDC ); return( bRet ); } From 659a2ca6381666dcfb293aa91e5ae03423e0455b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 7 Aug 2009 12:32:48 +0000 Subject: [PATCH 161/283] #i92516# fix some more layout problems --- vcl/source/control/edit.cxx | 16 ++++++++- vcl/source/window/printdlg.cxx | 11 +++++++ vcl/win/source/gdi/salnativewidgets-luna.cxx | 34 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 2ee0ab168a86..ccdff4d401f7 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2836,7 +2836,21 @@ Size Edit::CalcMinimumSize() const Size aMinSize ( CalcSize( 3 ) ); if( aSize.Width() < aMinSize.Width() ) aSize.Width() = aMinSize.Width(); - return CalcWindowSize( aSize ); + aSize = CalcWindowSize( aSize ); + + // ask NWF what if it has an opinion, too + ImplControlValue aControlValue; + Rectangle aRect( Point( 0, 0 ), aSize ); + Region aContent, aBound; + if( const_cast(this)->GetNativeControlRegion( + CTRL_EDITBOX, PART_ENTIRE_CONTROL, + aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) ) + { + Rectangle aBoundRect( aBound.GetBoundRect() ); + if( aBoundRect.GetHeight() > aSize.Height() ) + aSize.Height() = aBoundRect.GetHeight(); + } + return aSize; } // ----------------------------------------------------------------------- diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 30f96f4d8081..45c503f51fce 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1448,6 +1448,17 @@ void PrintDialog::setupOptionalUI() maJobPage.maCopySpacer.Show( FALSE ); } +#ifdef WNT + // FIXME: the GetNativeControlRegion call on Windows has some issues + // (which skew the results of GetOptimalSize()) + // however fixing this thoroughly needs to take interaction with paint into + // acoount, making the right fix less simple. Fix this the right way + // at some point. For now simply add some space at the lowest element + size_t nIndex = maJobPage.maLayout.countElements(); + if( nIndex > 0 ) // sanity check + maJobPage.maLayout.setBorders( nIndex-1, 0, 0, 0, aBorder.Width() ); +#endif + // calculate job page Size aMaxSize = maJobPage.maLayout.getOptimalSize( WINDOWSIZE_PREFERRED ); // and layout page diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index d1fb2b67c3ec..5c85d5d67144 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -1132,6 +1132,40 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, } } + if( (nType == CTRL_EDITBOX || nType == CTRL_SPINBOX) && nPart == PART_ENTIRE_CONTROL ) + { + HTHEME hTheme = getThemeHandle( mhWnd, L"Edit"); + if( hTheme ) + { + // get borderr size + Rectangle aBoxRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, EP_BACKGROUNDWITHBORDER, + EBWBS_HOT, aBoxRect ) ); + // ad app font height + NONCLIENTMETRICSW aNonClientMetrics; + aNonClientMetrics.cbSize = sizeof( aNonClientMetrics ); + if ( SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, sizeof( aNonClientMetrics ), &aNonClientMetrics, 0 ) ) + { + long nFontHeight = aNonClientMetrics.lfMessageFont.lfHeight; + if( nFontHeight < 0 ) + nFontHeight = -nFontHeight; + + if( aRect.GetHeight() && nFontHeight ) + { + aRect.Bottom() += aRect.GetHeight(); + aRect.Bottom() += nFontHeight; + if( aRect.GetHeight() > aBoxRect.GetHeight() ) + aBoxRect.Bottom() = aBoxRect.Top() + aRect.GetHeight(); + if( aRect.GetWidth() > aBoxRect.GetWidth() ) + aBoxRect.Right() = aBoxRect.Left() + aRect.GetWidth(); + rNativeContentRegion = aBoxRect; + rNativeBoundingRegion = rNativeContentRegion; + bRet = TRUE; + } + } + } + } + ReleaseDC( mhWnd, hDC ); return( bRet ); } From 052a24595fb966ef7f910865c1ff2cb45cf5471c Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 7 Aug 2009 12:42:34 +0000 Subject: [PATCH 162/283] #i92516# fix a layout problem --- vcl/source/control/edit.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index ccdff4d401f7..2b6f20977689 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2846,7 +2846,7 @@ Size Edit::CalcMinimumSize() const CTRL_EDITBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) ) { - Rectangle aBoundRect( aBound.GetBoundRect() ); + Rectangle aBoundRect( aContent.GetBoundRect() ); if( aBoundRect.GetHeight() > aSize.Height() ) aSize.Height() = aBoundRect.GetHeight(); } From 68362c81847e6ce0233e26ad325f331c8907ecd9 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 7 Aug 2009 14:27:26 +0000 Subject: [PATCH 163/283] #i99162# override paper format with driver dialog --- vcl/inc/vcl/print.hxx | 1 + vcl/source/gdi/print3.cxx | 58 ++++++++++++++++++++++++++++++---- vcl/source/window/printdlg.cxx | 9 ++++-- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index d5d42466b611..732a37244d7f 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -503,6 +503,7 @@ public: SAL_DLLPRIVATE bool getReversePrint() const; SAL_DLLPRIVATE void pushPropertiesToPrinter(); SAL_DLLPRIVATE void setJobState( com::sun::star::view::PrintableState ); + SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent ); }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1888fbdcad49..ef742f36d316 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -161,6 +161,10 @@ public: ImplPageCache maPageCache; + // set by user through printer config dialog + // if set, pages are centered and trimmed onto the fixed page + Size maFixedPageSize; + ImplPrinterControllerData() : mbLastPage( sal_False ), mbReversePageOrder( sal_False ), @@ -168,6 +172,15 @@ public: mpProgress( NULL ) {} ~ImplPrinterControllerData() { delete mpProgress; } + + Size getRealPaperSize( const Size& i_rPageSize ) const + { + if( maFixedPageSize.Width() > 0 && maFixedPageSize.Height() > 0 ) + return maFixedPageSize; + if( maMultiPage.nRows * maMultiPage.nColumns > 1 ) + return maMultiPage.aPaperSize; + return i_rPageSize; + } }; PrinterController::PrinterController() @@ -540,11 +553,32 @@ const boost::shared_ptr& PrinterController::getPrinter() const void PrinterController::setPrinter( const boost::shared_ptr& i_rPrinter ) { mpImplData->mpPrinter = i_rPrinter; - Size aPaperSize( i_rPrinter->PixelToLogic( i_rPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), makeAny( rtl::OUString( i_rPrinter->GetName() ) ) ); } +bool PrinterController::setupPrinter( Window* i_pParent ) +{ + bool bRet = false; + if( mpImplData->mpPrinter.get() ) + { + Size aPaperSize( mpImplData->mpPrinter->PixelToLogic( + mpImplData->mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + bRet = mpImplData->mpPrinter->Setup( i_pParent ); + if( bRet ) + { + // was the papersize overridden ? if so we need to take action + Size aNewPaperSize( mpImplData->mpPrinter->PixelToLogic( + mpImplData->mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + if( aNewPaperSize != aPaperSize ) + { + mpImplData->maFixedPageSize = aNewPaperSize; + } + } + } + return bRet; +} + static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) { Size aPageSize = pPrinter->GetPaperSize(); @@ -660,7 +694,7 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o if( nSubPages < 1 ) nSubPages = 1; - // there is no filtering to be done (and especially the page size of the + // there is no filtering to be done (and possibly the page size of the // original page is to be set), when N-Up is "neutral" that is there is // only one subpage and the margins are 0 if( nSubPages == 1 && @@ -672,10 +706,22 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o int nDocPages = getPageCount(); i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; } - return getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); + Size aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); + Size aPaperSize = mpImplData->getRealPaperSize( aPageSize ); + if( aPaperSize != aPageSize ) + { + // user overridden page size, center Metafile + o_rMtf.WindStart(); + long nDX = (aPaperSize.Width() - aPageSize.Width()) / 2; + long nDY = (aPaperSize.Height() - aPageSize.Height()) / 2; + o_rMtf.Move( nDX, nDY ); + o_rMtf.WindStart(); + o_rMtf.SetPrefSize( aPaperSize ); + } + return aPaperSize; } - Size aPaperSize( mpImplData->maMultiPage.aPaperSize ); + Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) ); // multi page area: paper size minus margins + one time spacing right and down // the added spacing is so each subpage can be calculated including its spacing Size aMPArea( aPaperSize ); @@ -832,8 +878,8 @@ void PrinterController::printFilteredPage( int i_nPage ) // in N-Up printing set the correct page size mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); - if( bMultiPageOutput ) - mpImplData->mpPrinter->SetPaperSizeUser( aPageSize = mpImplData->maMultiPage.aPaperSize ); + // aPageSize was filtered through mpImplData->getRealPaperSize already by getFilteredPageFile() + mpImplData->mpPrinter->SetPaperSizeUser( aPageSize ); // actually print the page mpImplData->mpPrinter->ImplStartPage(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 45c503f51fce..24a94d0e2b3f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1884,15 +1884,18 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) makeAny( bChecked ) ); preparePreview( true, true ); } + else if( pButton == &maNUpPage.maBorderCB ) + { + updateNup(); + } else { if( pButton == &maJobPage.maSetupButton ) { - maPController->getPrinter()->Setup( this ); + maPController->setupPrinter( this ); + preparePreview( true, true ); } checkControlDependencies(); - if( pButton == &maNUpPage.maBorderCB ) - updateNup(); } return 0; } From fb470c6f6c2da484102bd338e672d65348d95336 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 10 Aug 2009 16:48:53 +0000 Subject: [PATCH 164/283] #i92516# more changes for final UI spec --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 4 +- vcl/inc/vcl/arrange.hxx | 31 +++ vcl/inc/vcl/print.hxx | 3 + vcl/inc/vcl/prndlg.hxx | 10 +- vcl/inc/vcl/svids.hrc | 40 +-- vcl/source/gdi/print3.cxx | 37 ++- vcl/source/src/print.src | 20 +- vcl/source/window/arrange.cxx | 245 ++++++++++++++---- vcl/source/window/printdlg.cxx | 117 ++++----- 9 files changed, 362 insertions(+), 145 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index f6d9ff7b7d9c..df08faf43686 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -97,7 +97,7 @@ class ControllerProperties PrintAccessoryViewState* i_pState ) : mpController( i_pController ), mnNextTag( 0 ), - mnLastPageCount( i_pController->getPageCount() ), + mnLastPageCount( i_pController->getPageCountProtected() ), mpState( i_pState ), mpOp( i_pOp ), mpAccessoryView( i_pAccessoryView ), @@ -125,7 +125,7 @@ class ControllerProperties // TODO: refresh page count etc from mpController // page range may have changed depending on options - sal_Int32 nPages = mpController->getPageCount(); + sal_Int32 nPages = mpController->getPageCountProtected(); #if OSL_DEBUG_LEVEL > 1 if( nPages != mnLastPageCount ) fprintf( stderr, "trouble: number of pages changed from %ld to %ld !\n", mnLastPageCount, nPages ); diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx index e31be4ac8c67..309d0bf930ea 100644 --- a/vcl/inc/vcl/arrange.hxx +++ b/vcl/inc/vcl/arrange.hxx @@ -142,6 +142,8 @@ namespace vcl return pEle ? pEle->m_pElement : NULL; } + virtual bool isVisible() const; // true if any element is visible + sal_Int32 getExpandPriority( size_t i_nIndex ) const { const Element* pEle = getConstElement( i_nIndex ); @@ -227,6 +229,8 @@ namespace vcl size_t addChild( WindowArranger* i_pNewChild, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ) { return addChild( boost::shared_ptr( i_pNewChild ), i_nExpandPrio, i_nIndex ); } void remove( boost::shared_ptr const & ); + + long getBorderWidth() const { return m_nBorderWidth; } }; class LabeledElement : public WindowArranger @@ -234,6 +238,7 @@ namespace vcl WindowArranger::Element m_aLabel; WindowArranger::Element m_aElement; long m_nDistance; + long m_nLabelColumnWidth; int m_nLabelStyle; protected: virtual Element* getElement( size_t i_nIndex ) @@ -249,6 +254,7 @@ namespace vcl LabeledElement( WindowArranger* i_pParent = NULL, int i_nLabelStyle = 0, long i_nDistance = 5 ) : WindowArranger( i_pParent ) , m_nDistance( i_nDistance ) + , m_nLabelColumnWidth( 0 ) , m_nLabelStyle( i_nLabelStyle ) {} @@ -262,6 +268,30 @@ namespace vcl void setLabel( boost::shared_ptr const & ); void setElement( Window* ); void setElement( boost::shared_ptr const & ); + void setLabelColumnWidth( long i_nWidth ) + { m_nLabelColumnWidth = i_nWidth; } + + Size getLabelSize( WindowSizeType i_eType ) const + { return m_aLabel.getOptimalSize( i_eType ); } + Size getElementSize( WindowSizeType i_eType ) const + { return m_aElement.getOptimalSize( i_eType ); } + }; + + class LabelColumn : public RowOrColumn + { + long getLabelWidth() const; + public: + LabelColumn( WindowArranger* i_pParent = NULL, long i_nBorderWidth = 5 ) + : RowOrColumn( i_pParent, true, i_nBorderWidth ) + {} + virtual ~LabelColumn(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + + // returns the index of the added label + size_t addRow( Window* i_pLabel, boost::shared_ptr const& i_rElement, long i_nIndent = 0 ); + size_t addRow( Window* i_pLabel, Window* i_pElement, long i_nIndent = 0 ); }; class Indenter : public WindowArranger @@ -321,6 +351,7 @@ namespace vcl virtual void resize() {} virtual void setParentWindow( Window* ) {} virtual size_t countElements() const { return 1; } + virtual bool isVisible() const { return true; } }; class MatrixArranger : public WindowArranger diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 732a37244d7f..ce4bc7ba63cb 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -504,6 +504,9 @@ public: SAL_DLLPRIVATE void pushPropertiesToPrinter(); SAL_DLLPRIVATE void setJobState( com::sun::star::view::PrintableState ); SAL_DLLPRIVATE bool setupPrinter( Window* i_pDlgParent ); + + SAL_DLLPRIVATE int getPageCountProtected() const; + SAL_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const; }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 5cf9faac5b9c..55874728a536 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -104,10 +104,12 @@ namespace vcl NumericField maNupColEdt; FixedText maNupTimesTxt; NumericField maNupRowsEdt; - FixedText maPageMarginTxt; + FixedText maPageMarginTxt1; MetricField maPageMarginEdt; - FixedText maSheetMarginTxt; + FixedText maPageMarginTxt2; + FixedText maSheetMarginTxt1; MetricField maSheetMarginEdt; + FixedText maSheetMarginTxt2; FixedText maNupOrientationTxt; ListBox maNupOrientationBox; @@ -119,8 +121,6 @@ namespace vcl CheckBox maBorderCB; vcl::RowOrColumn maLayout; - boost::shared_ptr< vcl::WindowArranger >mxAdvancedControls; - boost::shared_ptr< vcl::RowOrColumn > mxLayoutGroup; boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; void setupLayout(); @@ -133,6 +133,8 @@ namespace vcl void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); void enableNupControls( bool bEnable ); + void showAdvancedControls( bool ); + virtual void Resize(); }; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 5ec6ff3d9901..427ee4426a09 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -90,25 +90,27 @@ #define SV_PRINT_PRT_COMMENT 13 #define SV_PRINT_TOFILE_TXT 14 -#define SV_PRINT_TAB_NUP 1 -#define SV_PRINT_PRT_NUP_LAYOUT_FL 1 -#define SV_PRINT_PRT_NUP_DEFAULT_BTN 2 -#define SV_PRINT_PRT_NUP_BROCHURE_BTN 3 -#define SV_PRINT_PRT_NUP_PAGES_BTN 4 -#define SV_PRINT_PRT_NUP_PAGES_BOX 5 -#define SV_PRINT_PRT_NUP_NUM_PAGES_TXT 6 -#define SV_PRINT_PRT_NUP_COLS_EDT 7 -#define SV_PRINT_PRT_NUP_TIMES_TXT 8 -#define SV_PRINT_PRT_NUP_ROWS_EDT 9 -#define SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT 10 -#define SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT 11 -#define SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT 12 -#define SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT 13 -#define SV_PRINT_PRT_NUP_ORIENTATION_TXT 14 -#define SV_PRINT_PRT_NUP_ORIENTATION_BOX 15 -#define SV_PRINT_PRT_NUP_ORDER_TXT 16 -#define SV_PRINT_PRT_NUP_ORDER_BOX 17 -#define SV_PRINT_PRT_NUP_BORDER_CB 18 +#define SV_PRINT_TAB_NUP 1 +#define SV_PRINT_PRT_NUP_LAYOUT_FL 1 +#define SV_PRINT_PRT_NUP_DEFAULT_BTN 2 +#define SV_PRINT_PRT_NUP_BROCHURE_BTN 3 +#define SV_PRINT_PRT_NUP_PAGES_BTN 4 +#define SV_PRINT_PRT_NUP_PAGES_BOX 5 +#define SV_PRINT_PRT_NUP_NUM_PAGES_TXT 6 +#define SV_PRINT_PRT_NUP_COLS_EDT 7 +#define SV_PRINT_PRT_NUP_TIMES_TXT 8 +#define SV_PRINT_PRT_NUP_ROWS_EDT 9 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_1_TXT 10 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT 11 +#define SV_PRINT_PRT_NUP_MARGINS_PAGES_2_TXT 12 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_1_TXT 13 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT 14 +#define SV_PRINT_PRT_NUP_MARGINS_SHEET_2_TXT 15 +#define SV_PRINT_PRT_NUP_ORIENTATION_TXT 16 +#define SV_PRINT_PRT_NUP_ORIENTATION_BOX 17 +#define SV_PRINT_PRT_NUP_ORDER_TXT 18 +#define SV_PRINT_PRT_NUP_ORDER_BOX 19 +#define SV_PRINT_PRT_NUP_BORDER_CB 20 #define SV_PRINT_PRT_NUP_ORIENTATION_AUTOMATIC 0 #define SV_PRINT_PRT_NUP_ORIENTATION_PORTRAIT 1 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index ef742f36d316..bb8c3ba1e041 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -352,7 +352,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr { GDIMetaFile aPageFile; i_pController->setLastPage( sal_True ); - if( i_pController->getPageCount() > 0 ) + if( i_pController->getPageCountProtected() > 0 ) i_pController->getFilteredPageFile( 0, aPageFile ); return; } @@ -599,6 +599,28 @@ static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& return aPageSize; } +int PrinterController::getPageCountProtected() const +{ + const MapMode aMapMode( MAP_100TH_MM ); + + mpImplData->mpPrinter->Push(); + mpImplData->mpPrinter->SetMapMode( aMapMode ); + int nPages = getPageCount(); + mpImplData->mpPrinter->Pop(); + return nPages; +} + +Sequence< beans::PropertyValue > PrinterController::getPageParametersProtected( int i_nPage ) const +{ + const MapMode aMapMode( MAP_100TH_MM ); + + mpImplData->mpPrinter->Push(); + mpImplData->mpPrinter->SetMapMode( aMapMode ); + Sequence< beans::PropertyValue > aResult( getPageParameters( i_nPage ) ); + mpImplData->mpPrinter->Pop(); + return aResult; +} + Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { // update progress if necessary @@ -626,7 +648,7 @@ Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, o_rMtf.Clear(); // get page parameters - Sequence< PropertyValue > aPageParm( getPageParameters( i_nUnfilteredPage ) ); + Sequence< PropertyValue > aPageParm( getPageParametersProtected( i_nUnfilteredPage ) ); const MapMode aMapMode( MAP_100TH_MM ); mpImplData->mpPrinter->Push(); @@ -677,7 +699,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD } // clip to page rect - o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); + // o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); // append the subpage io_rSubPage.WindStart(); @@ -703,7 +725,7 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o { if( mpImplData->mbReversePageOrder ) { - int nDocPages = getPageCount(); + int nDocPages = getPageCountProtected(); i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; } Size aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); @@ -742,7 +764,7 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o o_rMtf.SetPrefMapMode( MapMode( MAP_100TH_MM ) ); o_rMtf.AddAction( new MetaMapModeAction( MapMode( MAP_100TH_MM ) ) ); - int nDocPages = getPageCount(); + int nDocPages = getPageCountProtected(); for( int nSubPage = 0; nSubPage < nSubPages; nSubPage++ ) { // map current sub page to real page @@ -801,7 +823,7 @@ int PrinterController::getFilteredPageCount() int nDiv = mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns; if( nDiv < 1 ) nDiv = 1; - return (getPageCount() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; + return (getPageCountProtected() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; } void PrinterController::printFilteredPage( int i_nPage ) @@ -822,7 +844,6 @@ void PrinterController::printFilteredPage( int i_nPage ) } } - bool bMultiPageOutput = mpImplData->maMultiPage.nRows != 1 || mpImplData->maMultiPage.nColumns != 1; ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); @@ -1159,7 +1180,7 @@ void PrinterController::createProgressDialog() if( bShow && ! Application::IsHeadlessModeEnabled() ) { - mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCount() ); + mpImplData->mpProgress = new PrintProgressDialog( NULL, getPageCountProtected() ); mpImplData->mpProgress->Show(); } } diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index a7cd7bc237e0..5c04af603c93 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -199,11 +199,11 @@ ModalDialog SV_DLG_PRINT Value = 1; HelpText [en-US] = "Select number of rows."; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT + FixedText SV_PRINT_PRT_NUP_MARGINS_PAGES_1_TXT { Pos = MAP_APPFONT( 10, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Margin between ~pages"; + Text [en-US] = "~Distance"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT { @@ -215,11 +215,17 @@ ModalDialog SV_DLG_PRINT Unit = FUNIT_MM; HelpText [en-US] = "Select margin between individual pages on each sheet of paper."; }; - FixedText SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT + FixedText SV_PRINT_PRT_NUP_MARGINS_PAGES_2_TXT + { + Pos = MAP_APPFONT( 10, 95 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "between pages"; + }; + FixedText SV_PRINT_PRT_NUP_MARGINS_SHEET_1_TXT { Pos = MAP_APPFONT( 110, 95 ); Size = MAP_APPFONT( 40, 10 ); - Text [en-US] = "Margin to ~sheet border"; + Text [en-US] = "~Margin"; }; MetricField SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT { @@ -231,6 +237,12 @@ ModalDialog SV_DLG_PRINT Unit = FUNIT_MM; HelpText [en-US] = "Select margin between the printed pages and paper edge."; }; + FixedText SV_PRINT_PRT_NUP_MARGINS_SHEET_2_TXT + { + Pos = MAP_APPFONT( 110, 95 ); + Size = MAP_APPFONT( 40, 10 ); + Text [en-US] = "to sheet border"; + }; FixedText SV_PRINT_PRT_NUP_ORIENTATION_TXT { Pos = MAP_APPFONT( 0, 0 ); diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 8b3ed40db72e..7e019dc7e5ac 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -113,14 +113,27 @@ void WindowArranger::show( bool i_bShow, bool i_bImmediateUpdate ) } } +bool WindowArranger::isVisible() const +{ + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + const Element* pEle = getConstElement( i ); + if( pEle->isVisible() ) + return true; + } + return false; +} + bool WindowArranger::Element::isVisible() const { bool bVisible = false; if( ! m_bHidden ) { - bVisible = true; if( m_pElement ) bVisible = m_pElement->IsVisible(); + else if( m_pChild ) + bVisible = m_pChild->isVisible(); } return bVisible; } @@ -191,43 +204,47 @@ RowOrColumn::~RowOrColumn() Size RowOrColumn::getOptimalSize( WindowSizeType i_eType ) const { Size aRet( 0, 0 ); - if( ! m_aElements.empty() ) + for( std::vector< WindowArranger::Element >::const_iterator it = m_aElements.begin(); + it != m_aElements.end(); ++it ) { + if( it->isVisible() ) + { + // get the size of type of the managed element + Size aElementSize( it->getOptimalSize( i_eType ) ); + if( m_bColumn ) + { + // add the distance between elements + aRet.Height() += m_nBorderWidth; + // check if the width needs adjustment + if( aRet.Width() < aElementSize.Width() ) + aRet.Width() = aElementSize.Width(); + aRet.Height() += aElementSize.Height(); + } + else + { + // add the distance between elements + aRet.Width() += m_nBorderWidth; + // check if the height needs adjustment + if( aRet.Height() < aElementSize.Height() ) + aRet.Height() = aElementSize.Height(); + aRet.Width() += aElementSize.Width(); + } + } + } + + if( aRet.Width() != 0 || aRet.Height() != 0 ) + { + // subtract the border for the first element if( m_bColumn ) aRet.Height() -= m_nBorderWidth; else aRet.Width() -= m_nBorderWidth; - } - for( std::vector< WindowArranger::Element >::const_iterator it = m_aElements.begin(); - it != m_aElements.end(); ++it ) - { - // get the size of type of the managed element - Size aElementSize( it->getOptimalSize( i_eType ) ); - if( m_bColumn ) - { - // add the distance between elements - aRet.Height() += m_nBorderWidth; - // check if the width needs adjustment - if( aRet.Width() < aElementSize.Width() ) - aRet.Width() = aElementSize.Width(); - aRet.Height() += aElementSize.Height(); - } - else - { - // add the distance between elements - aRet.Width() += m_nBorderWidth; - // check if the height needs adjustment - if( aRet.Height() < aElementSize.Height() ) - aRet.Height() = aElementSize.Height(); - aRet.Width() += aElementSize.Width(); - } + // add the outer border + aRet.Width() += 2*m_nOuterBorder; + aRet.Height() += 2*m_nOuterBorder; } - // add the outer border - aRet.Width() += 2*m_nOuterBorder; - aRet.Height() += 2*m_nOuterBorder; - return aRet; } @@ -333,16 +350,19 @@ void RowOrColumn::resize() long nUsedWidth = 2*m_nOuterBorder - (nElements ? m_nBorderWidth : 0); for( size_t i = 0; i < nElements; i++ ) { - aElementSizes[i] = m_aElements[i].getOptimalSize( eType ); - if( m_bColumn ) + if( m_aElements[i].isVisible() ) { - aElementSizes[i].Width() = m_aManagedArea.GetWidth() - 2* m_nOuterBorder; - nUsedWidth += aElementSizes[i].Height() + m_nBorderWidth; - } - else - { - aElementSizes[i].Height() = m_aManagedArea.GetHeight() - 2* m_nOuterBorder; - nUsedWidth += aElementSizes[i].Width() + m_nBorderWidth; + aElementSizes[i] = m_aElements[i].getOptimalSize( eType ); + if( m_bColumn ) + { + aElementSizes[i].Width() = m_aManagedArea.GetWidth() - 2* m_nOuterBorder; + nUsedWidth += aElementSizes[i].Height() + m_nBorderWidth; + } + else + { + aElementSizes[i].Height() = m_aManagedArea.GetHeight() - 2* m_nOuterBorder; + nUsedWidth += aElementSizes[i].Width() + m_nBorderWidth; + } } } @@ -365,12 +385,14 @@ void RowOrColumn::resize() for( size_t i = 0; i < nElements; i++ ) { // get the size of type of the managed element - - m_aElements[i].setPosSize( aElementPos, aElementSizes[i] ); - if( m_bColumn ) - aElementPos.Y() += m_nBorderWidth + aElementSizes[i].Height(); - else - aElementPos.X() += m_nBorderWidth + aElementSizes[i].Width(); + if( m_aElements[i].isVisible() ) + { + m_aElements[i].setPosSize( aElementPos, aElementSizes[i] ); + if( m_bColumn ) + aElementPos.Y() += m_nBorderWidth + aElementSizes[i].Height(); + else + aElementPos.X() += m_nBorderWidth + aElementSizes[i].Width(); + } } } @@ -456,7 +478,12 @@ Size LabeledElement::getOptimalSize( WindowSizeType i_eType ) const { Size aRet( m_aLabel.getOptimalSize( WINDOWSIZE_MINIMUM ) ); if( aRet.Width() != 0 ) - aRet.Width() += m_nDistance; + { + if( m_nLabelColumnWidth != 0 ) + aRet.Width() = m_nLabelColumnWidth; + else + aRet.Width() += m_nDistance; + } Size aElementSize( m_aElement.getOptimalSize( i_eType ) ); aRet.Width() += aElementSize.Width(); if( aElementSize.Height() > aRet.Height() ) @@ -479,6 +506,8 @@ void LabeledElement::resize() Point aPos( m_aManagedArea.Left(), m_aManagedArea.Top() + m_nOuterBorder + nYOff ); Size aSize( aLabelSize ); + if( m_nLabelColumnWidth != 0 ) + aSize.Width() = m_nLabelColumnWidth; m_aLabel.setPosSize( aPos, aSize ); aPos.X() += aSize.Width() + m_nDistance; @@ -528,6 +557,130 @@ void LabeledElement::setElement( boost::shared_ptr const & i_pEl m_aElement.m_pChild = i_pElement; } +// ---------------------------------------- +// vcl::LabelColumn +//----------------------------------------- +LabelColumn::~LabelColumn() +{ +} + +long LabelColumn::getLabelWidth() const +{ + long nWidth = 0; + + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + const Element* pEle = getConstElement( i ); + if( pEle && pEle->m_pChild.get() ) + { + const LabeledElement* pLabel = dynamic_cast< const LabeledElement* >(pEle->m_pChild.get()); + if( pLabel ) + { + Window* pLW = pLabel->getWindow( 0 ); + if( pLW ) + { + Size aLabSize( pLW->GetOptimalSize( WINDOWSIZE_MINIMUM ) ); + if( aLabSize.Width() > nWidth ) + nWidth = aLabSize.Width(); + } + } + } + } + return nWidth + getBorderWidth(); +} + +Size LabelColumn::getOptimalSize( WindowSizeType i_eType ) const +{ + long nWidth = getLabelWidth(); + Size aColumnSize; + + // every child is a LabeledElement + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + Size aElementSize; + const Element* pEle = getConstElement( i ); + if( pEle && pEle->m_pChild.get() ) + { + const LabeledElement* pLabel = dynamic_cast< const LabeledElement* >(pEle->m_pChild.get()); + if( pLabel ) // we have a label + { + aElementSize = pLabel->getLabelSize( WINDOWSIZE_MINIMUM ); + if( aElementSize.Width() ) + aElementSize.Width() = nWidth; + Size aSize( pLabel->getElementSize( i_eType ) ); + aElementSize.Width() += aSize.Width(); + if( aSize.Height() > aElementSize.Height() ) + aElementSize.Height() = aSize.Height(); + } + else // a non label, just treat it as a row + { + aElementSize = pEle->getOptimalSize( i_eType ); + } + } + else if( pEle && pEle->m_pElement ) // a general window, treat is as a row + { + aElementSize = pEle->getOptimalSize( i_eType ); + } + if( aElementSize.Width() ) + { + aElementSize.Width() += 2*m_nOuterBorder; + if( aElementSize.Width() > aColumnSize.Width() ) + aColumnSize.Width() = aElementSize.Width(); + } + if( aElementSize.Height() ) + { + aColumnSize.Height() += getBorderWidth() + aElementSize.Height(); + } + } + if( nEle > 0 && aColumnSize.Height() ) + { + aColumnSize.Height() -= getBorderWidth(); // for the first element + aColumnSize.Height() += 2*m_nOuterBorder; + } + return aColumnSize; +} + +void LabelColumn::resize() +{ + long nWidth = getLabelWidth(); + size_t nEle = countElements(); + for( size_t i = 0; i < nEle; i++ ) + { + Element* pEle = getElement( i ); + if( pEle && pEle->m_pChild.get() ) + { + LabeledElement* pLabel = dynamic_cast< LabeledElement* >(pEle->m_pChild.get()); + if( pLabel ) + pLabel->setLabelColumnWidth( nWidth ); + } + } + RowOrColumn::resize(); +} + +size_t LabelColumn::addRow( Window* i_pLabel, boost::shared_ptr const& i_rElement, long i_nIndent ) +{ + boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 2 ) ); + xLabel->setLabel( i_pLabel ); + xLabel->setBorders( 0, i_nIndent, 0, 0, 0 ); + xLabel->setElement( i_rElement ); + size_t nIndex = addChild( xLabel ); + resize(); + return nIndex; +} + +size_t LabelColumn::addRow( Window* i_pLabel, Window* i_pElement, long i_nIndent ) +{ + boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 2 ) ); + xLabel->setLabel( i_pLabel ); + xLabel->setBorders( 0, i_nIndent, 0, 0, 0 ); + xLabel->setElement( i_pElement ); + size_t nIndex = addChild( xLabel ); + resize(); + return nIndex; +} + // ---------------------------------------- // vcl::Indenter //----------------------------------------- diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 24a94d0e2b3f..390d53e49fb5 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -233,10 +233,12 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) , maNupTimesTxt( this, VclResId( SV_PRINT_PRT_NUP_TIMES_TXT ) ) , maNupRowsEdt( this, VclResId( SV_PRINT_PRT_NUP_ROWS_EDT ) ) - , maPageMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_TXT ) ) + , maPageMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_1_TXT ) ) , maPageMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_EDT ) ) - , maSheetMarginTxt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_TXT ) ) + , maPageMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_PAGES_2_TXT ) ) + , maSheetMarginTxt1( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_1_TXT ) ) , maSheetMarginEdt( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_EDT ) ) + , maSheetMarginTxt2( this, VclResId( SV_PRINT_PRT_NUP_MARGINS_SHEET_2_TXT ) ) , maNupOrientationTxt( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_TXT ) ) , maNupOrientationBox( this, VclResId( SV_PRINT_PRT_NUP_ORIENTATION_BOX ) ) , maNupOrderTxt( this, VclResId( SV_PRINT_PRT_NUP_ORDER_TXT ) ) @@ -275,10 +277,12 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" ); maNupTimesTxt.SMHID2( "NUpPage", "Rows" ); maNupRowsEdt.SMHID2( "NUpPage", "RowsBox" ); - maPageMarginTxt.SMHID2( "NUpPage", "PageMargin" ); + maPageMarginTxt1.SMHID2( "NUpPage", "PageMargin" ); maPageMarginEdt.SMHID2( "NUpPage", "PageMarginBox" ); - maSheetMarginTxt.SMHID2( "NUpPage", "SheetMargin" ); + maPageMarginTxt2.SMHID2( "NUpPage", "PageMarginCont" ); + maSheetMarginTxt1.SMHID2( "NUpPage", "SheetMargin" ); maSheetMarginEdt.SMHID2( "NUpPage", "SheetMarginBox" ); + maSheetMarginTxt2.SMHID2( "NUpPage", "SheetMarginCont" ); maNupOrientationTxt.SMHID2( "NUpPage", "Orientation" ); maNupOrientationBox.SMHID2( "NUpPage", "OrientationBox" ); maNupOrderTxt.SMHID2( "NUpPage", "Order" ); @@ -299,10 +303,12 @@ void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) maNupColEdt.Enable( bEnable ); maNupTimesTxt.Enable( bEnable ); maNupRowsEdt.Enable( bEnable ); - maPageMarginTxt.Enable( bEnable ); + maPageMarginTxt1.Enable( bEnable ); maPageMarginEdt.Enable( bEnable ); - maSheetMarginTxt.Enable( bEnable ); + maPageMarginTxt2.Enable( bEnable ); + maSheetMarginTxt1.Enable( bEnable ); maSheetMarginEdt.Enable( bEnable ); + maSheetMarginTxt2.Enable( bEnable ); maNupOrientationTxt.Enable( bEnable ); maNupOrientationBox.Enable( bEnable ); maNupOrderTxt.Enable( bEnable ); @@ -311,9 +317,27 @@ void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) maBorderCB.Enable( bEnable ); } +void PrintDialog::NUpTabPage::showAdvancedControls( bool i_bShow ) +{ + maNupNumPagesTxt.Show( i_bShow ); + maNupColEdt.Show( i_bShow ); + maNupTimesTxt.Show( i_bShow ); + maNupRowsEdt.Show( i_bShow ); + maPageMarginTxt1.Show( i_bShow ); + maPageMarginEdt.Show( i_bShow ); + maPageMarginTxt2.Show( i_bShow ); + maSheetMarginTxt1.Show( i_bShow ); + maSheetMarginEdt.Show( i_bShow ); + maSheetMarginTxt2.Show( i_bShow ); + maNupOrientationTxt.Show( i_bShow ); + maNupOrientationBox.Show( i_bShow ); + maLayout.resize(); +} + void PrintDialog::NUpTabPage::setupLayout() { Size aBorder( LogicToPixel( Size( 5, 5 ), MapMode( MAP_APPFONT ) ) ); + long nIndent = 3*aBorder.Width(); maLayout.setParentWindow( this ); maLayout.setOuterBorder( aBorder.Width() ); @@ -330,72 +354,41 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xShowNupCol.get() ) ); xShowNupCol->addChild( xSpacer ); - boost::shared_ptr< vcl::RowOrColumn > xMainCol( new vcl::RowOrColumn( xIndent.get() ) ); + boost::shared_ptr< vcl::LabelColumn > xMainCol( new vcl::LabelColumn( xIndent.get() ) ); xIndent->setChild( xMainCol ); - boost::shared_ptr< vcl::LabeledElement > xLabel( new vcl::LabeledElement( xMainCol.get() ) ); - xMainCol->addChild( xLabel ); - xLabel->setLabel( &maPagesBtn ); - xLabel->setElement( &maNupPagesBox ); + xMainCol->addRow( &maPagesBtn, &maNupPagesBox ); - xIndent.reset( new vcl::Indenter( xMainCol.get(), 3*aBorder.Width() ) ); - xMainCol->addChild( xIndent ); + xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); + xMainCol->addRow( &maNupNumPagesTxt, xRow, nIndent ); + xRow->addWindow( &maNupColEdt ); + xRow->addWindow( &maNupTimesTxt ); + xRow->addWindow( &maNupRowsEdt ); - mxLayoutGroup = xMainCol; - boost::shared_ptr< vcl::RowOrColumn > xCol( new vcl::RowOrColumn( xIndent.get() ) ); - xIndent->setChild( xCol ); + boost::shared_ptr< vcl::LabeledElement > xLab( new vcl::LabeledElement( xMainCol.get(), 2 ) ); + xLab->setLabel( &maPageMarginEdt ); + xLab->setElement( &maPageMarginTxt2 ); + xMainCol->addRow( &maPageMarginTxt1, xLab, nIndent ); - boost::shared_ptr< vcl::RowOrColumn > xAdvCol( new vcl::RowOrColumn( xCol.get() ) ); - xCol->addChild( xAdvCol ); - // remember advanced controls to show/hide - mxAdvancedControls = xAdvCol; + xLab.reset( new vcl::LabeledElement( xMainCol.get(), 2 ) ); + xLab->setLabel( &maSheetMarginEdt ); + xLab->setElement( &maSheetMarginTxt2 ); + xMainCol->addRow( &maSheetMarginTxt1, xLab, nIndent ); - xLabel.reset( new vcl::LabeledElement( xCol.get() ) ); - xCol->addChild( xLabel ); - xLabel->setLabel( &maNupOrderTxt ); - xLabel->setElement( &maNupOrderBox ); - xCol->addWindow( &maBorderCB ); - - xRow.reset( new vcl::RowOrColumn( xAdvCol.get(), false ) ); - xAdvCol->addChild( xRow ); - xLabel.reset( new vcl::LabeledElement( xRow.get() ) ); - xRow->addChild( xLabel, 1 ); - xLabel->setLabel( &maNupNumPagesTxt ); - xLabel->setElement( &maNupColEdt ); - xLabel.reset( new vcl::LabeledElement( xRow.get() ) ); - xRow->addChild( xLabel ); - xLabel->setLabel( &maNupTimesTxt ); - xLabel->setElement( &maNupRowsEdt ); - - xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); - xAdvCol->addChild( xLabel ); - xLabel->setLabel( &maPageMarginTxt ); - xLabel->setElement( &maPageMarginEdt ); - - xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); - xAdvCol->addChild( xLabel ); - xLabel->setLabel( &maSheetMarginTxt ); - xLabel->setElement( &maSheetMarginEdt ); - - xLabel.reset( new vcl::LabeledElement( xAdvCol.get() ) ); - xAdvCol->addChild( xLabel ); - xLabel->setLabel( &maNupOrientationTxt ); - xLabel->setElement( &maNupOrientationBox ); + xMainCol->addRow( &maNupOrientationTxt, &maNupOrientationBox, nIndent ); + xMainCol->addRow( &maNupOrderTxt, &maNupOrderBox, nIndent ); + xMainCol->setBorders( xMainCol->addWindow( &maBorderCB ), nIndent, 0, 0, 0 ); xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, aBorder.Width() ) ) ); xMainCol->addChild( xSpacer ); xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); - xMainCol->addChild( xRow ); - xRow->addWindow( &maBrochureBtn ); + xMainCol->addRow( &maBrochureBtn, xRow ); // remember brochure row for dependencies mxBrochureDep = xRow; - xSpacer.reset( new vcl::Spacer( xMainCol.get(), 0, Size( 10, 2*aBorder.Width() ) ) ); - xMainCol->addChild( xSpacer ); - // initially advanced controls are not shown, rows=columns=1 - mxAdvancedControls->show( false, false ); + showAdvancedControls( false ); } void PrintDialog::NUpTabPage::Resize() @@ -1105,7 +1098,7 @@ void PrintDialog::setupOptionalUI() } else if( aGroupingHint.equalsAscii( "LayoutPage" ) ) { - pCurColumn = maNUpPage.mxLayoutGroup.get(); + pCurColumn = &maNUpPage.maLayout; pCurParent = &maNUpPage; // set layout page as current parent bOnStaticPage = true; } @@ -1329,7 +1322,7 @@ void PrintDialog::setupOptionalUI() setSmartId( pHeading, "FixedText", -1, aPropertyName ); // add to row - pLabel = new vcl::LabeledElement( pFieldColumn ); + pLabel = new vcl::LabeledElement( pFieldColumn, 2 ); pFieldColumn->addChild( pLabel ); pLabel->setLabel( pHeading ); } @@ -1651,7 +1644,7 @@ Size PrintDialog::getJobPageSize() { maFirstPageSize = maNupPortraitSize; GDIMetaFile aMtf; - if( maPController->getPageCount() > 0 ) + if( maPController->getPageCountProtected() > 0 ) maFirstPageSize = maPController->getPageFile( 0, aMtf, true ); } return maFirstPageSize; @@ -1706,7 +1699,7 @@ void PrintDialog::updateNupFromPages() maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM ); maNUpPage.maSheetMarginEdt.SetValue( maNUpPage.maSheetMarginEdt.Normalize( nSheetMargin ), FUNIT_100TH_MM ); - maNUpPage.mxAdvancedControls->show( bCustom ); + maNUpPage.showAdvancedControls( bCustom ); if( bCustom ) { // see if we have to enlarge the dialog to make the tab page fit @@ -1846,7 +1839,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) { maNUpPage.maNupPagesBox.SelectEntryPos( 0 ); updateNupFromPages(); - maNUpPage.mxAdvancedControls->show( false ); + maNUpPage.showAdvancedControls( false ); maNUpPage.enableNupControls( false ); } } From feb06438cf2e7eca712923305c729874693d6f5a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 10 Aug 2009 18:44:52 +0000 Subject: [PATCH 165/283] #i92516# more changes for final UI spec --- vcl/source/window/printdlg.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 390d53e49fb5..1914b0008643 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -160,7 +160,7 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi } PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( Window* i_pParent ) - : Window( i_pParent, WB_BORDER ) + : Window( i_pParent, WB_NOBORDER ) , mnOrderMode( 0 ) , mnRows( 1 ) , mnColumns( 1 ) @@ -221,6 +221,8 @@ void PrintDialog::ShowNupOrderWindow::Paint( const Rectangle& i_rRect ) nY * aSubSize.Height() + nDeltaY ), aPageText ); } + DecorationView aVw( this ); + aVw.DrawFrame( Rectangle( Point( 0, 0), aOutSize ), FRAME_DRAW_GROUP ); } PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) @@ -487,8 +489,10 @@ void PrintDialog::JobTabPage::setupLayout() // create a row for details button/text and properties button boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) ); maLayout.addChild( xDetRow ); - xDetRow->addWindow( &maDetailsBtn ); - xDetRow->addWindow( &maDetailsTxt ); + boost::shared_ptr< vcl::LabeledElement > xDetLbl( new vcl::LabeledElement( xDetRow.get() ) ); + xDetRow->addChild( xDetLbl ); + xDetLbl->setLabel( &maDetailsBtn ); + xDetLbl->setElement( &maDetailsTxt ); xDetRow->addChild( new vcl::Spacer( xDetRow.get(), 2 ) ); xDetRow->addWindow( &maSetupButton ); @@ -1635,6 +1639,10 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); maPreviewWindow.setPreview( aMtf, maCurPageSize ); + + maForwardBtn.Enable( mnCurPage < nPages-1 ); + maBackwardBtn.Enable( mnCurPage != 0 ); + maPageEdit.Enable( nPages > 1 ); } } From 5e7db5f15fb042234fc7e3b3b692a03de137da36 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 11 Aug 2009 15:50:07 +0000 Subject: [PATCH 166/283] #i92516# final UI changes --- vcl/inc/vcl/prndlg.hxx | 3 +- vcl/source/window/printdlg.cxx | 75 ++++++++++++++++++++-------------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 55874728a536..182b77c1827d 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -59,6 +59,7 @@ namespace vcl GDIMetaFile maMtf; Size maOrigSize; VirtualDevice maPageVDev; + rtl::OUString maReplacementString; public: PrintPreviewWindow( Window* pParent, const ResId& ); virtual ~PrintPreviewWindow(); @@ -67,7 +68,7 @@ namespace vcl virtual void Command( const CommandEvent& ); virtual void Resize(); - void setPreview( const GDIMetaFile&, const Size& ); + void setPreview( const GDIMetaFile&, const Size&, const rtl::OUString& ); }; class ShowNupOrderWindow : public Window diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1914b0008643..09ae7cabf5d2 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -102,33 +102,49 @@ void PrintDialog::PrintPreviewWindow::Resize() void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) { - GDIMetaFile aMtf( maMtf ); - - Size aPreviewSize = maPageVDev.GetOutputSizePixel(); Size aSize( GetSizePixel() ); - Point aOffset( (aSize.Width() - aPreviewSize.Width()) / 2, - (aSize.Height() - aPreviewSize.Height()) / 2 ); + if( maReplacementString.getLength() != 0 ) + { + // replacement is active + Push(); + Rectangle aTextRect( Point( 0, 0 ), aSize ); + Font aFont( GetSettings().GetStyleSettings().GetFieldFont() ); + aFont.SetSize( Size( 0, aSize.Height()/12 ) ); + SetFont( aFont ); + DrawText( aTextRect, maReplacementString, + TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE + ); + Pop(); + } + else + { + GDIMetaFile aMtf( maMtf ); - const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) ); - double fScale = double(aLogicSize.Width())/double(maOrigSize.Width()); + Size aPreviewSize = maPageVDev.GetOutputSizePixel(); + Point aOffset( (aSize.Width() - aPreviewSize.Width()) / 2, + (aSize.Height() - aPreviewSize.Height()) / 2 ); + + const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) ); + double fScale = double(aLogicSize.Width())/double(maOrigSize.Width()); - maPageVDev.Erase(); - maPageVDev.Push(); - maPageVDev.SetMapMode( MAP_100TH_MM ); - aMtf.WindStart(); - aMtf.Scale( fScale, fScale ); - aMtf.WindStart(); - aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize ); - maPageVDev.Pop(); + maPageVDev.Erase(); + maPageVDev.Push(); + maPageVDev.SetMapMode( MAP_100TH_MM ); + aMtf.WindStart(); + aMtf.Scale( fScale, fScale ); + aMtf.WindStart(); + aMtf.Play( &maPageVDev, Point( 0, 0 ), aLogicSize ); + maPageVDev.Pop(); - SetMapMode( MAP_PIXEL ); - maPageVDev.SetMapMode( MAP_PIXEL ); - DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev ); + SetMapMode( MAP_PIXEL ); + maPageVDev.SetMapMode( MAP_PIXEL ); + DrawOutDev( aOffset, aPreviewSize, Point( 0, 0 ), aPreviewSize, maPageVDev ); - DecorationView aVw( this ); - aOffset.X() -= 1; aOffset.Y() -=1; aPreviewSize.Width() += 2; aPreviewSize.Height() += 2; - aVw.DrawFrame( Rectangle( aOffset, aPreviewSize ), FRAME_DRAW_GROUP ); + DecorationView aVw( this ); + aOffset.X() -= 1; aOffset.Y() -=1; aPreviewSize.Width() += 2; aPreviewSize.Height() += 2; + aVw.DrawFrame( Rectangle( aOffset, aPreviewSize ), FRAME_DRAW_GROUP ); + } } void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) @@ -151,10 +167,14 @@ void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) } } -void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize ) +void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, + const Size& i_rOrigSize, + const rtl::OUString& i_rReplacement + ) { maMtf = i_rNewPreview; maOrigSize = i_rOrigSize; + maReplacementString = i_rReplacement; Resize(); Invalidate(); } @@ -1602,13 +1622,8 @@ void PrintDialog::updatePrinterText() void PrintDialog::setPreviewText( sal_Int32 ) { - if( mnCachedPages != 0 ) - { - rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) ); - maNumPagesText.SetText( aNewText ); - } - else - maNumPagesText.SetText( maNoPageStr ); + rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) ); + maNumPagesText.SetText( aNewText ); } void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) @@ -1638,7 +1653,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) else maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - maPreviewWindow.setPreview( aMtf, maCurPageSize ); + maPreviewWindow.setPreview( aMtf, maCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr ); maForwardBtn.Enable( mnCurPage < nPages-1 ); maBackwardBtn.Enable( mnCurPage != 0 ); From 6e492713b1d5f680e7f0f65c184184332c2619f6 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 11 Aug 2009 16:04:23 +0000 Subject: [PATCH 167/283] #i92516# add: PrinterOptionsHelper::setValue --- vcl/inc/vcl/print.hxx | 5 +++++ vcl/source/gdi/print3.cxx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index ce4bc7ba63cb..0a290cb6adcc 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -542,6 +542,11 @@ class VCL_DLLPUBLIC PrinterOptionsHelper // returns an empty Any for not existing properties com::sun::star::uno::Any getValue( const rtl::OUString& i_rPropertyName ) const; + // change a value in the property set; this will not have an effect to an eventual PrinterController + // the user of setValue must decide whether it is necessary to set the value there also + void setValue( const rtl::OUString& i_rPropertyName, const com::sun::star::uno::Any& i_rValue ); + void setValue( const char* i_pPropertyName, const com::sun::star::uno::Any& i_rValue ) + { setValue( rtl::OUString::createFromAscii( i_pPropertyName ), i_rValue ); } sal_Bool getBoolValue( const rtl::OUString& i_rPropertyName, sal_Bool i_bDefault = sal_False ) const; // convenience for fixed strings diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index bb8c3ba1e041..bd18110574b6 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1241,6 +1241,11 @@ Any PrinterOptionsHelper::getValue( const rtl::OUString& i_rPropertyName ) const return aRet; } +void PrinterOptionsHelper::setValue( const rtl::OUString& i_rPropertyName, const Any& i_rValue ) +{ + m_aPropertyMap[ i_rPropertyName ] = i_rValue; +} + bool PrinterOptionsHelper::hasProperty( const rtl::OUString& i_rPropertyName ) const { Any aRet; From 4cd5a62fc2763b867e4ef1277110cadc3caea366 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 12 Aug 2009 09:46:09 +0000 Subject: [PATCH 168/283] #i92516# add missing help ids --- vcl/source/window/printdlg.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 09ae7cabf5d2..979dbdbde99e 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -291,6 +291,7 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maPageMarginEdt.SetDecimalDigits( nDigits ); maSheetMarginEdt.SetDecimalDigits( nDigits ); + SMHID1( "NUpPage" ); maNupLine.SMHID2("NUpPage", "Layout"); maBrochureBtn.SMHID2("NUpPage", "Brochure" ); maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" ); @@ -462,6 +463,8 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maLayout( NULL, true ) { FreeResource(); + + SMHID1( "JobPage" ); maPrinterFL.SMHID2( "JobPage", "Printer" ); maPrinters.SMHID2( "JobPage", "PrinterList" ); maStatusLabel.SMHID2( "JobPage", "StatusLabel" ); @@ -624,6 +627,7 @@ PrintDialog::OutputOptPage::OutputOptPage( Window* i_pParent, const ResId& i_rRe , maReverseOrderBox( this, VclResId( SV_PRINT_OPT_REVERSE ) ) { FreeResource(); + SMHID1( "OptPage" ); maOptionsLine.SMHID2( "OptPage", "Options" ); maToFileBox.SMHID2( "OptPage", "ToFile" ); maCollateSingleJobsBox.SMHID2( "OptPage", "SingleJobs" ); @@ -826,6 +830,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Wed, 12 Aug 2009 12:30:24 +0000 Subject: [PATCH 169/283] #i96402# set duplex mode from API --- vcl/source/gdi/print3.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index bd18110574b6..8338e6128561 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -45,6 +45,7 @@ #include "com/sun/star/ui/dialogs/XFilterManager.hpp" #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" +#include "com/sun/star/view/DuplexMode.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/awt/Size.hpp" #include "comphelper/processfactory.hxx" @@ -1208,6 +1209,20 @@ void PrinterController::pushPropertiesToPrinter() if( pVal ) pVal->Value >>= bCollate; mpImplData->mpPrinter->SetCopyCount( static_cast(nCopyCount), bCollate ); + + // duplex mode + pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DuplexMode" ) ) ); + if( pVal ) + { + sal_Int16 nDuplex = view::DuplexMode::UNKNOWN; + pVal->Value >>= nDuplex; + switch( nDuplex ) + { + case view::DuplexMode::OFF: mpImplData->mpPrinter->SetDuplexMode( DUPLEX_OFF ); break; + case view::DuplexMode::LONGEDGE: mpImplData->mpPrinter->SetDuplexMode( DUPLEX_LONGEDGE ); break; + case view::DuplexMode::SHORTEDGE: mpImplData->mpPrinter->SetDuplexMode( DUPLEX_SHORTEDGE ); break; + } + } } bool PrinterController::isShowDialogs() const From 14ede6d1a846952d8a7e283fb174b2804666c7f3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 12 Aug 2009 12:59:21 +0000 Subject: [PATCH 170/283] #i92516# set smart helpid on parent like old help ids --- vcl/inc/vcl/tabctrl.hxx | 2 +- vcl/source/control/tabctrl.cxx | 46 ++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index f5e0b64b58ee..09f4550dd8e5 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -73,7 +73,7 @@ private: BOOL mbRestoreUnqId; BOOL mbSingleLine; BOOL mbScroll; - BOOL mbColored; + BOOL mbRestoreSmartId; BOOL mbSmallInvalidate; BOOL mbExtraSpace; Link maActivateHdl; diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index b13be2f43b3d..24da946574de 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -30,26 +30,23 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include +#include "tools/debug.hxx" -#ifndef _SV_RC_H -#include -#endif -#include -#ifndef _SV_APP_HXX -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "tools/rc.h" +#include "vcl/svdata.hxx" +#include "vcl/svapp.hxx" +#include "vcl/help.hxx" +#include "vcl/event.hxx" +#include "vcl/menu.hxx" +#include "vcl/button.hxx" +#include "vcl/tabpage.hxx" +#include "vcl/tabctrl.hxx" +#include "vcl/controllayout.hxx" +#include "vcl/sound.hxx" +#include "vcl/lstbox.hxx" +#include "vcl/smartid.hxx" -#include +#include "vcl/window.h" #include #include @@ -156,7 +153,7 @@ void TabControl::ImplInit( Window* pParent, WinBits nStyle ) mbRestoreUnqId = FALSE; mbSingleLine = FALSE; mbScroll = FALSE; - mbColored = FALSE; + mbRestoreSmartId = FALSE; mbSmallInvalidate = FALSE; mbExtraSpace = FALSE; mpTabCtrlData = new ImplTabCtrlData; @@ -713,6 +710,8 @@ void TabControl::ImplChangeTabPage( USHORT nId, USHORT nOldId ) pCtrlParent->SetHelpId( 0 ); if ( mbRestoreUnqId ) pCtrlParent->SetUniqueId( 0 ); + if( mbRestoreSmartId ) + pCtrlParent->SetSmartHelpId( SmartId() ); pOldPage->DeactivatePage(); } @@ -720,8 +719,8 @@ void TabControl::ImplChangeTabPage( USHORT nId, USHORT nOldId ) { pPage->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() ); - // Hier Page aktivieren, damit die Controls entsprechend umgeschaltet - // werden koennen und HilfeId gegebenenfalls beim Parent umsetzen + // activate page here so the conbtrols can be switched + // also set the help id of the parent window to that of the tab page if ( !GetHelpId() ) { mbRestoreHelpId = TRUE; @@ -732,6 +731,11 @@ void TabControl::ImplChangeTabPage( USHORT nId, USHORT nOldId ) mbRestoreUnqId = TRUE; pCtrlParent->SetUniqueId( pPage->GetUniqueId() ); } + if( ! GetSmartHelpId().HasAny() ) + { + mbRestoreSmartId = TRUE; + pCtrlParent->SetSmartHelpId( pPage->GetSmartHelpId() ); + } pPage->ActivatePage(); From 2c142f8529e0a0c3aa18d7d5819f95cab90efc86 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 12 Aug 2009 16:37:34 +0000 Subject: [PATCH 171/283] #i92516# corrected paper size handling --- vcl/aqua/source/gdi/salprn.cxx | 10 +++++----- vcl/inc/vcl/prndlg.hxx | 1 - vcl/source/window/printdlg.cxx | 10 ++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 6575f89d3fa0..a9a58799f4db 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -304,7 +304,7 @@ void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientatio { Orientation ePaperOrientation = ORIENTATION_PORTRAIT; - const PaperInfo* pPaper = matchPaper( (i_nWidth+50)/100, (i_nHeight+50)/100, ePaperOrientation ); + const PaperInfo* pPaper = matchPaper( i_nWidth, i_nHeight, ePaperOrientation ); if( pPaper ) { @@ -807,8 +807,8 @@ void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData ) NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper]; if( aPaperSize.width > 0 && aPaperSize.height > 0 ) { - PaperInfo aInfo( (PtTo10Mu( aPaperSize.width ) + 50 ) / 100, - (PtTo10Mu( aPaperSize.height ) + 50 ) / 100 ); + PaperInfo aInfo( PtTo10Mu( aPaperSize.width ), + PtTo10Mu( aPaperSize.height ) ); m_aPaperFormats.push_back( aInfo ); } } @@ -828,8 +828,8 @@ const PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, { for( size_t i = 0; i < m_aPaperFormats.size(); i++ ) { - if( abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 2 && - abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 2 ) + if( abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 50 && + abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 50 ) { pMatch = &m_aPaperFormats[i]; return pMatch; diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 182b77c1827d..6c347900aa3d 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -228,7 +228,6 @@ namespace vcl rtl::OUString maNoPageStr; sal_Int32 mnCurPage; sal_Int32 mnCachedPages; - Size maCurPageSize; std::list< Window* > maControls; std::map< Window*, rtl::OUString > maControlToPropertyMap; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 979dbdbde99e..71adbad3f225 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1647,18 +1647,16 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) maPageEdit.SetMin( 1 ); maPageEdit.SetMax( nPages ); - boost::shared_ptr aPrt( maPController->getPrinter() ); - if( i_bNewPage ) { const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; if( nPages > 0 ) - maCurPageSize = maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); - else - maCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); + maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); - maPreviewWindow.setPreview( aMtf, maCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr ); + boost::shared_ptr aPrt( maPController->getPrinter() ); + Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); + maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr ); maForwardBtn.Enable( mnCurPage < nPages-1 ); maBackwardBtn.Enable( mnCurPage != 0 ); From 5366ddcc1129a384ec9585d54689b991fbe80efd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 13 Aug 2009 11:31:18 +0000 Subject: [PATCH 172/283] #i92516# set correct page size for N-Up in getFilteredPage() --- vcl/source/gdi/print3.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 8338e6128561..375947c867ec 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -816,6 +816,9 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o } o_rMtf.WindStart(); + mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); + mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize ); + return aPaperSize; } From b0434f112b7e3dc67dec0c0165e3fd49086c7fb5 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 13 Aug 2009 15:10:43 +0000 Subject: [PATCH 173/283] #i92516# handle MAP_PIXEL in preview --- vcl/inc/vcl/prndlg.hxx | 4 +++- vcl/inc/vcl/virdev.hxx | 11 +++++++++-- vcl/source/gdi/virdev.cxx | 29 +++++++++++++++++++++-------- vcl/source/window/printdlg.cxx | 10 ++++++++-- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 6c347900aa3d..9ea5be6e10b8 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -68,7 +68,9 @@ namespace vcl virtual void Command( const CommandEvent& ); virtual void Resize(); - void setPreview( const GDIMetaFile&, const Size&, const rtl::OUString& ); + void setPreview( const GDIMetaFile&, const Size&, const rtl::OUString&, + sal_Int32 i_nDPIX, sal_Int32 i_nDPIY + ); }; class ShowNupOrderWindow : public Window diff --git a/vcl/inc/vcl/virdev.hxx b/vcl/inc/vcl/virdev.hxx index bc21dde6f4ac..ea2b49eb8290 100644 --- a/vcl/inc/vcl/virdev.hxx +++ b/vcl/inc/vcl/virdev.hxx @@ -74,7 +74,6 @@ private: #define REFDEV_FORCE_ZERO_EXTLEAD 0x80 SAL_DLLPRIVATE bool ForceZeroExtleadBug() const { return ((meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD) != 0); } - public: VirtualDevice( USHORT nBitCount = 0 ); VirtualDevice( const OutputDevice& rCompDev, @@ -115,11 +114,19 @@ public: REFDEV_MODE06 = 1, // 600 dpi REFDEV_MODE48 = 2, // 4800 dpi REFDEV_MODE_MSO1 = 3, - REFDEV_MODE_PDF1 = 4 }; + REFDEV_MODE_PDF1 = 4, + REFDEV_CUSTOM = 5 + }; void SetReferenceDevice( RefDevMode ); void Compat_ZeroExtleadBug(); // enable workaround for #i60495# + + void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ); + +private: + SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ); + }; #endif // _SV_VIRDEV_HXX diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx index f1c532a9295f..a13e272e368b 100644 --- a/vcl/source/gdi/virdev.cxx +++ b/vcl/source/gdi/virdev.cxx @@ -359,27 +359,40 @@ BOOL VirtualDevice::SetOutputSizePixel( const Size& rNewSize, BOOL bErase ) // ----------------------------------------------------------------------- -void VirtualDevice::SetReferenceDevice( RefDevMode eRefDevMode ) +void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode ) { - switch( eRefDevMode ) + sal_Int32 nDPIX = 600, nDPIY = 600; + switch( i_eRefDevMode ) { case REFDEV_NONE: default: DBG_ASSERT( FALSE, "VDev::SetRefDev illegal argument!" ); - // fall through + break; case REFDEV_MODE06: - mnDPIX = mnDPIY = 600; + nDPIX = nDPIY = 600; break; case REFDEV_MODE48: - mnDPIX = mnDPIY = 4800; + nDPIX = nDPIY = 4800; break; case REFDEV_MODE_MSO1: - mnDPIX = mnDPIY = 6*1440; + nDPIX = nDPIY = 6*1440; break; case REFDEV_MODE_PDF1: - mnDPIX = mnDPIY = 720; + nDPIX = nDPIY = 720; break; } + ImplSetReferenceDevice( i_eRefDevMode, nDPIX, nDPIY ); +} + +void VirtualDevice::SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ) +{ + ImplSetReferenceDevice( REFDEV_CUSTOM, i_nDPIX, i_nDPIY ); +} + +void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ) +{ + mnDPIX = i_nDPIX; + mnDPIY = i_nDPIY; EnableOutput( FALSE ); // prevent output on reference device mbScreenComp = FALSE; @@ -391,7 +404,7 @@ void VirtualDevice::SetReferenceDevice( RefDevMode eRefDevMode ) // avoid adjusting font lists when already in refdev mode BYTE nOldRefDevMode = meRefDevMode; BYTE nOldCompatFlag = (BYTE)meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD; - meRefDevMode = (BYTE)(eRefDevMode | nOldCompatFlag); + meRefDevMode = (BYTE)(i_eRefDevMode | nOldCompatFlag); if( (nOldRefDevMode ^ nOldCompatFlag) != REFDEV_NONE ) return; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 71adbad3f225..38ddb66877d0 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -169,12 +169,16 @@ void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize, - const rtl::OUString& i_rReplacement + const rtl::OUString& i_rReplacement, + sal_Int32 i_nDPIX, + sal_Int32 i_nDPIY ) { maMtf = i_rNewPreview; maOrigSize = i_rOrigSize; maReplacementString = i_rReplacement; + maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); + maPageVDev.EnableOutput( TRUE ); Resize(); Invalidate(); } @@ -1656,7 +1660,9 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) boost::shared_ptr aPrt( maPController->getPrinter() ); Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr ); + maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr, + aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY() + ); maForwardBtn.Enable( mnCurPage < nPages-1 ); maBackwardBtn.Enable( mnCurPage != 0 ); From 15929d6d5da7c38a6cbe7aabcd56ed1a5a23faf6 Mon Sep 17 00:00:00 2001 From: Release Engineers Date: Fri, 14 Aug 2009 16:37:51 +0000 Subject: [PATCH 174/283] Create DEV300_m55 milestone tag from trunk@275000 From 12bb9be1d55b74bb2ff7a01f778919b6fead9045 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 15 Aug 2009 16:24:00 +0000 Subject: [PATCH 175/283] #92516# hid for vcl dialog --- vcl/inc/vcl/solar.hrc | 314 ++++++++++++++++++++++++++++++++++++++++++ vcl/inc/vcl/svids.hrc | 4 + vcl/prj/d.lst | 1 + vcl/util/hidother.src | 34 +++++ vcl/util/makefile.mk | 1 + 5 files changed, 354 insertions(+) create mode 100644 vcl/inc/vcl/solar.hrc create mode 100644 vcl/util/hidother.src diff --git a/vcl/inc/vcl/solar.hrc b/vcl/inc/vcl/solar.hrc new file mode 100644 index 000000000000..a0cfcddd1b92 --- /dev/null +++ b/vcl/inc/vcl/solar.hrc @@ -0,0 +1,314 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2009 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SOLAR_HRC +#define _SOLAR_HRC + +// defines ------------------------------------------------------------------ + +#define CREATERESMGR_NAME( Name ) #Name +#define CREATERESMGR( Name ) ResMgr::CreateResMgr( CREATERESMGR_NAME( Name ) ) + +#define RID_SFX_START 260 +#define RID_SFX_END 9999 + +#define RID_LIB_START 10000 +#define RID_LIB_END 19999 + +#define RID_SVX_START (RID_LIB_START) +#define RID_SVX_END (RID_LIB_START+499) + +#define RID_SBASIC_START (RID_LIB_START+500) +#define RID_SBASIC_END (RID_LIB_START+2999) + +#define RID_BASIC_START (RID_LIB_START+3000) +#define RID_BASIC_END (RID_LIB_START+4499) + +#define RID_UUI_START (RID_LIB_START+4500) +#define RID_UUI_END (RID_LIB_START+4599) + +#define RID_HELP_START (RID_LIB_START+4600) +#define RID_HELP_END (RID_LIB_START+4799) + +#define RID_MAIL_START (RID_LIB_START+4800) +#define RID_MAIL_END (RID_LIB_START+4849) + +#define RID_BASICIDE_START (RID_LIB_START+4850) +#define RID_BASICIDE_END (RID_LIB_START+4949) + +#define RID_SVXITEMS_START (RID_LIB_START+4950) +#define RID_SVXITEMS_END (RID_LIB_START+5599) + +#define RID_SBA_START (RID_LIB_START+5600) +#define RID_SBA_END (RID_LIB_START+5649) + +#define RID_ISETBRW_START (RID_LIB_START+5650) +#define RID_ISETBRW_END (RID_LIB_START+5699) + +#define RID_EXTENSIONS_START (RID_LIB_START+5700) +#define RID_EXTENSIONS_END (RID_LIB_START+5799) + +#define RID_EDIT_START (RID_LIB_START+5800) +#define RID_EDIT_END (RID_LIB_START+5899) + +#define RID_EDIT_START (RID_LIB_START+5800) +#define RID_EDIT_END (RID_LIB_START+5899) + +#define RID_OUTL_START (RID_LIB_START+5900) +#define RID_OUTL_END (RID_LIB_START+5919) + +#define RID_SVTOOLS_START (RID_LIB_START+5920) +#define RID_SVTOOLS_END (RID_LIB_START+5999) + +#define RID_INET_START (RID_LIB_START+6000) +#define RID_INET_END (RID_LIB_START+6059) + +#define RID_SO2_START (RID_LIB_START+6060) +#define RID_SO2_END (RID_LIB_START+6099) + +#define RID_GOODIES_START (RID_LIB_START+6100) +#define RID_GOODIES_END (RID_LIB_START+6149) + +#define RID_SJ_START (RID_LIB_START+6150) +#define RID_SJ_END (RID_LIB_START+6199) + +#define RID_SI_START (RID_LIB_START+6200) +#define RID_SI_END (RID_LIB_START+6399) + +#define RID_DLG_START (RID_LIB_START+6400) +#define RID_DLG_END (RID_LIB_START+6499) + +#define RID_OFA_START (RID_LIB_START+6500) +#define RID_OFA_END (RID_LIB_START+6999) + +#define RID_CHANNEL_START (RID_LIB_START+7000) +#define RID_CHANNEL_END (RID_LIB_START+7499) + +#define RID_CHAOS_START (RID_LIB_START+7500) +#define RID_CHAOS_END (RID_LIB_START+7999) + +#define RID_FORMS_START (RID_LIB_START+8000) +#define RID_FORMS_END (RID_LIB_START+8999) + +#define RID_FORMLAYER_START (RID_LIB_START+9000) +#define RID_FORMLAYER_END (RID_LIB_START+9199) + +#define RID_DBACCESS_START (RID_LIB_START+9200) +#define RID_DBACCESS_END (RID_LIB_START+9699) + +#define RID_MORE_EXTENSIONS_START (RID_LIB_START+9700) +#define RID_MORE_EXTENSIONS_END (RID_LIB_START+9999) + +#define RID_DB_EXTENSIONS_START (RID_LIB_START+10000) +#define RID_DB_EXTENSIONS_END (RID_LIB_START+10199) + +#define RID_FILTER_START (RID_LIB_START+10200) +#define RID_FILTER_END (RID_LIB_START+10299) + +#define RID_APP_START 20000 +#define RID_APP_END 31999 + +#define RID_SW_START (20000) +#define RID_SW_END (25999) + +#define RID_SC_START (26000) +#define RID_SC_END (26999) + +#define RID_SD_START (27000) +#define RID_SD_END (27999) + +#define RID_Sa_START (28000) +#define RID_Sa_END (28999) + +#define RID_Sb_START (29000) +#define RID_Sb_END (29999) + +#define RID_OBJ_START (30000) +#define RID_OBJ_END (32767) + +#define RID_SIM_START (RID_OBJ_START+ 0) +#define RID_SIM_END (RID_OBJ_START+ 255) + +#define RID_SMA_START (RID_OBJ_START+ 256) +#define RID_SMA_END (RID_OBJ_START+ 511) + +#define RID_SCH_START (RID_OBJ_START+ 512) +#define RID_SCH_END (RID_OBJ_START+ 767) + +#define RID_RPT_START (RID_OBJ_START+768) +#define RID_RPT_END (RID_OBJ_START+1000) + +#define RID_FORMULA_START (RID_OBJ_START+1001) +#define RID_FORMULA_END (RID_OBJ_START+1200) +// Help-Ids -------------------------------------------------------------- + +#define HID_OK_BUTTON 0 +#define HID_CANCEL_BUTTON 0 +#define HID_HELP_BUTTON 0 + +#define HID_START 32768 + +#define HID_VCL_START (HID_START+100) +#define HID_VCL_END (HID_START+150) + +#define HID_SVTOOLS_START (HID_START+200) +#define HID_SVTOOLS_END (HID_START+299) + +#define HID_SFX_START (HID_START+300) +#define HID_SFX_END (HID_START+999) + +#define HID_LIB_START (HID_START+1000) +#define HID_LIB_END (HID_START+19999) + +#define HID_SVX_START (HID_LIB_START) +#define HID_SVX_END (HID_LIB_START+431) + +#define HID_WIZARD_START (HID_LIB_START+432) +#define HID_WIZARD_END (HID_LIB_START+999) +//please note: There is also HID_WIZARD2 below + +#define HID_EXTENSIONS_START (HID_LIB_START+1000) +#define HID_EXTENSIONS_END (HID_LIB_START+1099) + +#define HID_SO2_START (HID_LIB_START+1100) +#define HID_SO2_END (HID_LIB_START+1149) + +#define HID_MAIL_START (HID_LIB_START+1150) +#define HID_MAIL_END (HID_LIB_START+1199) + +#define HID_INET_START (HID_LIB_START+1200) +#define HID_INET_END (HID_LIB_START+1259) + +#define HID_OFA_START (HID_LIB_START+1260) +#define HID_OFA_END (HID_LIB_START+1399) + +#define HID_HELP_START (HID_LIB_START+2000) +#define HID_HELP_END (HID_LIB_START+2050) + +#define HID_CHAOS_START (HID_LIB_START+2051) +#define HID_CHAOS_END (HID_LIB_START+2069) + +#define HID_UUI_START (HID_LIB_START+2070) +#define HID_UUI_END (HID_LIB_START+2099) + +#define HID_GOODIES_START (HID_LIB_START+2100) +#define HID_GOODIES_END (HID_LIB_START+2199) + +#if 0 // currently unused range +#define HID_SCHEDULE_START (HID_LIB_START+2200) +#define HID_SCHEDULE_END (HID_LIB_START+3399) +#endif + +#define HID_CHANNEL_START (HID_LIB_START+3400) +#define HID_CHANNEL_END (HID_LIB_START+3499) + +#define HID_SBA_START (HID_LIB_START+ 3500) +#define HID_SBA_END (HID_LIB_START+ 3999) + +#define HID_FORMS_START (HID_LIB_START+4000) +#define HID_FORMS_END (HID_LIB_START+4999) + +#define HID_DBACCESS_START (HID_LIB_START+5000) +#define HID_DBACCESS_END (HID_LIB_START+5299) + +#define HID_PORTAL_START (HID_LIB_START+5300) +#define HID_PORTAL_END (HID_LIB_START+5599) + +#define HID_PORTAL_ADMIN_START (HID_LIB_START+5600) +#define HID_PORTAL_ADMIN_END (HID_LIB_START+5999) + +#define HID_SYNCACCESS_START (HID_LIB_START+6000) +#define HID_SYNCACCESS_END (HID_LIB_START+6099) + +#define HID_SVX_EXT0_START (HID_LIB_START+6100) +#define HID_SVX_EXT0_END (HID_LIB_START+6599) + +#define HID_FRAMEWORK_START (HID_LIB_START+6600) +#define HID_FRAMEWORK_END (HID_LIB_START+6999) + +#define HID_WIZARD2_START (HID_LIB_START+7000) +#define HID_WIZARD2_END (HID_LIB_START+8999) + +#define HID_DESKTOP_START (HID_LIB_START+9000) +#define HID_DESKTOP_END (HID_LIB_START+9299) + +#define HID_XMLSECURITY_START (HID_LIB_START+9300) +#define HID_XMLSECURITY_END (HID_LIB_START+9999) + +#define HID_APP_START (HID_START+20000) +#define HID_APP_END (HID_START+29999) + +#define HID_SW_START (HID_START+20000) +#define HID_SW_END (HID_START+24999) + +#define HID_SC_START (HID_START+25000) +#define HID_SC_END (HID_START+26999) + +#define HID_SD_START (HID_START+27000) +#define HID_SD_END (HID_START+27999) + +#define HID_Sa_START (HID_START+28000) +#define HID_Sa_END (HID_START+28999) + +#define HID_Sb_START (HID_START+29000) +#define HID_Sb_END (HID_START+29999) + +#define HID_OBJ_START (HID_START+30000) +#define HID_OBJ_END (HID_START+32767) + +#define HID_SIM_START (HID_OBJ_START+ 0) +#define HID_SIM_END (HID_OBJ_START+ 239) + +#define HID_AVMEDIA_START (HID_OBJ_START+ 240) +#define HID_AVMEDIA_END (HID_OBJ_START+ 255) + +#define HID_SMA_START (HID_OBJ_START+ 256) +#define HID_SMA_END (HID_OBJ_START+ 511) + +#define HID_SCH_START (HID_OBJ_START+ 512) +#define HID_SCH_END (HID_OBJ_START+ 767) + +#define HID_BASICIDE_START (HID_OBJ_START+ 768) +#define HID_BASICIDE_END (HID_OBJ_START+1023) + +#define HID_SMA2_START (HID_OBJ_START+1024) +#define HID_SMA2_END (HID_OBJ_START+1280) + +#define HID_FILTER_START (HID_OBJ_START+1281) +#define HID_FILTER_END (HID_OBJ_START+1580) + +#define HID_LICENSING_START (HID_OBJ_START+1581) +#define HID_LICENSING_END (HID_OBJ_START+1680) + +#define HID_RPT_START (HID_OBJ_START+1681) +#define HID_RPT_END (HID_OBJ_START+2080) + +#define HID_FORMULA_START (HID_OBJ_START+2081) +#define HID_FORMULA_END (HID_OBJ_START+2280) + +#endif + diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 427ee4426a09..f21aa6a4cd20 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -31,6 +31,8 @@ #ifndef _SV_SVIDS_HRC #define _SV_SVIDS_HRC +#include "vcl/solar.hrc" + #define SV_RESID_STDOFFSET 0 #define SV_RESID_WINOFFSET 1 #define SV_RESID_OS2OFFSET 2 @@ -249,4 +251,6 @@ #define SV_ICON_ID_MACRO 17 #define SV_ICON_ID_PRINTERADMIN 501 +#define HID_PRINTDLG HID_VCL_START + #endif // _SV_SVIDS_HRC diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst index a8b308aea462..1fb975c129d9 100644 --- a/vcl/prj/d.lst +++ b/vcl/prj/d.lst @@ -15,6 +15,7 @@ mkdir: %_DEST%\inc%_EXT%\vcl\plug\vcl ..\%__SRC%\obj\salmain.obj %_DEST%\lib%_EXT%\salmain.obj ..\%__SRC%\obj\salmain.o %_DEST%\lib%_EXT%\salmain.o +..\inc\vcl\solar.hrc %_DEST%\inc%_EXT%\vcl\solar.hrc ..\inc\vcl\accel.hxx %_DEST%\inc%_EXT%\vcl\accel.hxx ..\inc\vcl\alpha.hxx %_DEST%\inc%_EXT%\vcl\alpha.hxx ..\inc\vcl\animate.hxx %_DEST%\inc%_EXT%\vcl\animate.hxx diff --git a/vcl/util/hidother.src b/vcl/util/hidother.src new file mode 100644 index 000000000000..ab10a1e4c4ea --- /dev/null +++ b/vcl/util/hidother.src @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: hidother.src,v $ + * $Revision: 1.20 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vcl/svids.hrc" + +hidspecial HID_PRINTDLG { HelpID = HID_PRINTDLG; }; + diff --git a/vcl/util/makefile.mk b/vcl/util/makefile.mk index 96c28980118f..000db0e34f3d 100644 --- a/vcl/util/makefile.mk +++ b/vcl/util/makefile.mk @@ -35,6 +35,7 @@ PRJNAME=vcl TARGET=vcl TARGETTYPE=GUI USE_DEFFILE=TRUE +GEN_HID_OTHER=TRUE .IF "$(SNDFILE_LIBS)"!="" SNDFILELIB=$(SNDFILE_LIBS) From 25b00175008c8a8f027d752e92dee0df7c4fb0bd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 15 Aug 2009 16:25:13 +0000 Subject: [PATCH 176/283] #92516# hid for vcl dialog --- svtools/bmpmaker/bmp.cxx | 2 +- svtools/bmpmaker/bmpsum.cxx | 2 +- svtools/inc/svtools/helpid.hrc | 2 +- svtools/inc/svtools/solar.hrc | 312 ------------------ svtools/inc/svtools/svtools.hrc | 2 +- svtools/prj/d.lst | 1 - .../filter/SvFilterOptionsDialog.cxx | 2 +- svtools/source/filter.vcl/filter/filter.cxx | 2 +- svtools/source/plugapp/testtool.src | 2 +- svtools/source/uno/unoifac2.hrc | 2 +- svtools/workben/unodialog/udlg_global.hrc | 2 +- 11 files changed, 9 insertions(+), 322 deletions(-) delete mode 100644 svtools/inc/svtools/solar.hrc diff --git a/svtools/bmpmaker/bmp.cxx b/svtools/bmpmaker/bmp.cxx index df20c7e05376..52e2cb5fa7b0 100644 --- a/svtools/bmpmaker/bmp.cxx +++ b/svtools/bmpmaker/bmp.cxx @@ -43,7 +43,7 @@ using namespace std; #include -#include "svtools/solar.hrc" +#include "vcl/solar.hrc" #include "filedlg.hxx" #include "bmpcore.hxx" #include "bmp.hrc" diff --git a/svtools/bmpmaker/bmpsum.cxx b/svtools/bmpmaker/bmpsum.cxx index 0633eb4c6a09..6ba0ac3cfc78 100644 --- a/svtools/bmpmaker/bmpsum.cxx +++ b/svtools/bmpmaker/bmpsum.cxx @@ -45,7 +45,7 @@ #include #include -#include "svtools/solar.hrc" +#include "vcl/solar.hrc" #define EXIT_NOERROR 0x00000000 #define EXIT_INVALIDFILE 0x00000001 diff --git a/svtools/inc/svtools/helpid.hrc b/svtools/inc/svtools/helpid.hrc index efbb0d2628d9..d18120b8c0d4 100644 --- a/svtools/inc/svtools/helpid.hrc +++ b/svtools/inc/svtools/helpid.hrc @@ -33,7 +33,7 @@ // include --------------------------------------------------------------- -#include +#include // Help-Ids -------------------------------------------------------------- diff --git a/svtools/inc/svtools/solar.hrc b/svtools/inc/svtools/solar.hrc deleted file mode 100644 index 348422ef6477..000000000000 --- a/svtools/inc/svtools/solar.hrc +++ /dev/null @@ -1,312 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: solar.hrc,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SOLAR_HRC -#define _SOLAR_HRC - -// defines ------------------------------------------------------------------ - -#define CREATERESMGR_NAME( Name ) #Name -#define CREATERESMGR( Name ) ResMgr::CreateResMgr( CREATERESMGR_NAME( Name ) ) - -#define RID_SFX_START 260 -#define RID_SFX_END 9999 - -#define RID_LIB_START 10000 -#define RID_LIB_END 19999 - -#define RID_SVX_START (RID_LIB_START) -#define RID_SVX_END (RID_LIB_START+499) - -#define RID_SBASIC_START (RID_LIB_START+500) -#define RID_SBASIC_END (RID_LIB_START+2999) - -#define RID_BASIC_START (RID_LIB_START+3000) -#define RID_BASIC_END (RID_LIB_START+4499) - -#define RID_UUI_START (RID_LIB_START+4500) -#define RID_UUI_END (RID_LIB_START+4599) - -#define RID_HELP_START (RID_LIB_START+4600) -#define RID_HELP_END (RID_LIB_START+4799) - -#define RID_MAIL_START (RID_LIB_START+4800) -#define RID_MAIL_END (RID_LIB_START+4849) - -#define RID_BASICIDE_START (RID_LIB_START+4850) -#define RID_BASICIDE_END (RID_LIB_START+4949) - -#define RID_SVXITEMS_START (RID_LIB_START+4950) -#define RID_SVXITEMS_END (RID_LIB_START+5599) - -#define RID_SBA_START (RID_LIB_START+5600) -#define RID_SBA_END (RID_LIB_START+5649) - -#define RID_ISETBRW_START (RID_LIB_START+5650) -#define RID_ISETBRW_END (RID_LIB_START+5699) - -#define RID_EXTENSIONS_START (RID_LIB_START+5700) -#define RID_EXTENSIONS_END (RID_LIB_START+5799) - -#define RID_EDIT_START (RID_LIB_START+5800) -#define RID_EDIT_END (RID_LIB_START+5899) - -#define RID_EDIT_START (RID_LIB_START+5800) -#define RID_EDIT_END (RID_LIB_START+5899) - -#define RID_OUTL_START (RID_LIB_START+5900) -#define RID_OUTL_END (RID_LIB_START+5919) - -#define RID_SVTOOLS_START (RID_LIB_START+5920) -#define RID_SVTOOLS_END (RID_LIB_START+5999) - -#define RID_INET_START (RID_LIB_START+6000) -#define RID_INET_END (RID_LIB_START+6059) - -#define RID_SO2_START (RID_LIB_START+6060) -#define RID_SO2_END (RID_LIB_START+6099) - -#define RID_GOODIES_START (RID_LIB_START+6100) -#define RID_GOODIES_END (RID_LIB_START+6149) - -#define RID_SJ_START (RID_LIB_START+6150) -#define RID_SJ_END (RID_LIB_START+6199) - -#define RID_SI_START (RID_LIB_START+6200) -#define RID_SI_END (RID_LIB_START+6399) - -#define RID_DLG_START (RID_LIB_START+6400) -#define RID_DLG_END (RID_LIB_START+6499) - -#define RID_OFA_START (RID_LIB_START+6500) -#define RID_OFA_END (RID_LIB_START+6999) - -#define RID_CHANNEL_START (RID_LIB_START+7000) -#define RID_CHANNEL_END (RID_LIB_START+7499) - -#define RID_CHAOS_START (RID_LIB_START+7500) -#define RID_CHAOS_END (RID_LIB_START+7999) - -#define RID_FORMS_START (RID_LIB_START+8000) -#define RID_FORMS_END (RID_LIB_START+8999) - -#define RID_FORMLAYER_START (RID_LIB_START+9000) -#define RID_FORMLAYER_END (RID_LIB_START+9199) - -#define RID_DBACCESS_START (RID_LIB_START+9200) -#define RID_DBACCESS_END (RID_LIB_START+9699) - -#define RID_MORE_EXTENSIONS_START (RID_LIB_START+9700) -#define RID_MORE_EXTENSIONS_END (RID_LIB_START+9999) - -#define RID_DB_EXTENSIONS_START (RID_LIB_START+10000) -#define RID_DB_EXTENSIONS_END (RID_LIB_START+10199) - -#define RID_FILTER_START (RID_LIB_START+10200) -#define RID_FILTER_END (RID_LIB_START+10299) - -#define RID_APP_START 20000 -#define RID_APP_END 31999 - -#define RID_SW_START (20000) -#define RID_SW_END (25999) - -#define RID_SC_START (26000) -#define RID_SC_END (26999) - -#define RID_SD_START (27000) -#define RID_SD_END (27999) - -#define RID_Sa_START (28000) -#define RID_Sa_END (28999) - -#define RID_Sb_START (29000) -#define RID_Sb_END (29999) - -#define RID_OBJ_START (30000) -#define RID_OBJ_END (32767) - -#define RID_SIM_START (RID_OBJ_START+ 0) -#define RID_SIM_END (RID_OBJ_START+ 255) - -#define RID_SMA_START (RID_OBJ_START+ 256) -#define RID_SMA_END (RID_OBJ_START+ 511) - -#define RID_SCH_START (RID_OBJ_START+ 512) -#define RID_SCH_END (RID_OBJ_START+ 767) - -#define RID_RPT_START (RID_OBJ_START+768) -#define RID_RPT_END (RID_OBJ_START+1000) - -#define RID_FORMULA_START (RID_OBJ_START+1001) -#define RID_FORMULA_END (RID_OBJ_START+1200) -// Help-Ids -------------------------------------------------------------- - -#define HID_OK_BUTTON 0 -#define HID_CANCEL_BUTTON 0 -#define HID_HELP_BUTTON 0 - -#define HID_START 32768 - -#define HID_SVTOOLS_START (HID_START+200) -#define HID_SVTOOLS_END (HID_START+299) - -#define HID_SFX_START (HID_START+300) -#define HID_SFX_END (HID_START+999) - -#define HID_LIB_START (HID_START+1000) -#define HID_LIB_END (HID_START+19999) - -#define HID_SVX_START (HID_LIB_START) -#define HID_SVX_END (HID_LIB_START+431) - -#define HID_WIZARD_START (HID_LIB_START+432) -#define HID_WIZARD_END (HID_LIB_START+999) -//please note: There is also HID_WIZARD2 below - -#define HID_EXTENSIONS_START (HID_LIB_START+1000) -#define HID_EXTENSIONS_END (HID_LIB_START+1099) - -#define HID_SO2_START (HID_LIB_START+1100) -#define HID_SO2_END (HID_LIB_START+1149) - -#define HID_MAIL_START (HID_LIB_START+1150) -#define HID_MAIL_END (HID_LIB_START+1199) - -#define HID_INET_START (HID_LIB_START+1200) -#define HID_INET_END (HID_LIB_START+1259) - -#define HID_OFA_START (HID_LIB_START+1260) -#define HID_OFA_END (HID_LIB_START+1399) - -#define HID_HELP_START (HID_LIB_START+2000) -#define HID_HELP_END (HID_LIB_START+2050) - -#define HID_CHAOS_START (HID_LIB_START+2051) -#define HID_CHAOS_END (HID_LIB_START+2069) - -#define HID_UUI_START (HID_LIB_START+2070) -#define HID_UUI_END (HID_LIB_START+2099) - -#define HID_GOODIES_START (HID_LIB_START+2100) -#define HID_GOODIES_END (HID_LIB_START+2199) - -#define HID_SCHEDULE_START (HID_LIB_START+2200) -#define HID_SCHEDULE_END (HID_LIB_START+3399) - -#define HID_CHANNEL_START (HID_LIB_START+3400) -#define HID_CHANNEL_END (HID_LIB_START+3499) - -#define HID_SBA_START (HID_LIB_START+ 3500) -#define HID_SBA_END (HID_LIB_START+ 3999) - -#define HID_FORMS_START (HID_LIB_START+4000) -#define HID_FORMS_END (HID_LIB_START+4999) - -#define HID_DBACCESS_START (HID_LIB_START+5000) -#define HID_DBACCESS_END (HID_LIB_START+5299) - -#define HID_PORTAL_START (HID_LIB_START+5300) -#define HID_PORTAL_END (HID_LIB_START+5599) - -#define HID_PORTAL_ADMIN_START (HID_LIB_START+5600) -#define HID_PORTAL_ADMIN_END (HID_LIB_START+5999) - -#define HID_SYNCACCESS_START (HID_LIB_START+6000) -#define HID_SYNCACCESS_END (HID_LIB_START+6099) - -#define HID_SVX_EXT0_START (HID_LIB_START+6100) -#define HID_SVX_EXT0_END (HID_LIB_START+6599) - -#define HID_FRAMEWORK_START (HID_LIB_START+6600) -#define HID_FRAMEWORK_END (HID_LIB_START+6999) - -#define HID_WIZARD2_START (HID_LIB_START+7000) -#define HID_WIZARD2_END (HID_LIB_START+8999) - -#define HID_DESKTOP_START (HID_LIB_START+9000) -#define HID_DESKTOP_END (HID_LIB_START+9299) - -#define HID_XMLSECURITY_START (HID_LIB_START+9300) -#define HID_XMLSECURITY_END (HID_LIB_START+9999) - -#define HID_APP_START (HID_START+20000) -#define HID_APP_END (HID_START+29999) - -#define HID_SW_START (HID_START+20000) -#define HID_SW_END (HID_START+24999) - -#define HID_SC_START (HID_START+25000) -#define HID_SC_END (HID_START+26999) - -#define HID_SD_START (HID_START+27000) -#define HID_SD_END (HID_START+27999) - -#define HID_Sa_START (HID_START+28000) -#define HID_Sa_END (HID_START+28999) - -#define HID_Sb_START (HID_START+29000) -#define HID_Sb_END (HID_START+29999) - -#define HID_OBJ_START (HID_START+30000) -#define HID_OBJ_END (HID_START+32767) - -#define HID_SIM_START (HID_OBJ_START+ 0) -#define HID_SIM_END (HID_OBJ_START+ 239) - -#define HID_AVMEDIA_START (HID_OBJ_START+ 240) -#define HID_AVMEDIA_END (HID_OBJ_START+ 255) - -#define HID_SMA_START (HID_OBJ_START+ 256) -#define HID_SMA_END (HID_OBJ_START+ 511) - -#define HID_SCH_START (HID_OBJ_START+ 512) -#define HID_SCH_END (HID_OBJ_START+ 767) - -#define HID_BASICIDE_START (HID_OBJ_START+ 768) -#define HID_BASICIDE_END (HID_OBJ_START+1023) - -#define HID_SMA2_START (HID_OBJ_START+1024) -#define HID_SMA2_END (HID_OBJ_START+1280) - -#define HID_FILTER_START (HID_OBJ_START+1281) -#define HID_FILTER_END (HID_OBJ_START+1580) - -#define HID_LICENSING_START (HID_OBJ_START+1581) -#define HID_LICENSING_END (HID_OBJ_START+1680) - -#define HID_RPT_START (HID_OBJ_START+1681) -#define HID_RPT_END (HID_OBJ_START+2080) - -#define HID_FORMULA_START (HID_OBJ_START+2081) -#define HID_FORMULA_END (HID_OBJ_START+2280) - -#endif - diff --git a/svtools/inc/svtools/svtools.hrc b/svtools/inc/svtools/svtools.hrc index 245d31a2dd21..0be076d6333a 100644 --- a/svtools/inc/svtools/svtools.hrc +++ b/svtools/inc/svtools/svtools.hrc @@ -30,7 +30,7 @@ #ifndef _SVTOOLS_HRC #define _SVTOOLS_HRC "$Revision: 1.0" -#include +#include #define RID_SVTOOLS_BITMAP_START (RID_SVTOOLS_START + 0) #define RID_SVTOOLS_IMAGELIST_START (RID_SVTOOLS_START + 0) diff --git a/svtools/prj/d.lst b/svtools/prj/d.lst index 6b85194db6c1..0db11da707f3 100644 --- a/svtools/prj/d.lst +++ b/svtools/prj/d.lst @@ -117,7 +117,6 @@ mkdir: %_DEST%\inc%_EXT%\svtools ..\inc\svtools\cnclhint.hxx %_DEST%\inc%_EXT%\svtools\cnclhint.hxx ..\inc\svtools\inettype.hxx %_DEST%\inc%_EXT%\svtools\inettype.hxx ..\inc\svtools\brwhead.hxx %_DEST%\inc%_EXT%\svtools\brwhead.hxx -..\inc\svtools\solar.hrc %_DEST%\inc%_EXT%\svtools\solar.hrc ..\inc\scriptedtext.hxx %_DEST%\inc%_EXT%\svtools\scriptedtext.hxx ..\inc\svtools\stdctrl.hxx %_DEST%\inc%_EXT%\svtools\stdctrl.hxx ..\inc\svtools\stritem.hxx %_DEST%\inc%_EXT%\svtools\stritem.hxx diff --git a/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx index 1bc83575ec38..2502a8bcea01 100644 --- a/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx @@ -37,7 +37,7 @@ #include "FilterConfigCache.hxx" #include #include -#include +#include #include #include "dlgexpor.hxx" #include "dlgejpg.hxx" diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx index f87fabc7973d..7465a925627f 100644 --- a/svtools/source/filter.vcl/filter/filter.cxx +++ b/svtools/source/filter.vcl/filter/filter.cxx @@ -54,7 +54,7 @@ #include "jpeg.hxx" #include "xbmread.hxx" #include "xpmread.hxx" -#include +#include #include "strings.hrc" #include "sgffilt.hxx" #include "osl/module.hxx" diff --git a/svtools/source/plugapp/testtool.src b/svtools/source/plugapp/testtool.src index 599675a6c494..4333dedd4255 100644 --- a/svtools/source/plugapp/testtool.src +++ b/svtools/source/plugapp/testtool.src @@ -28,7 +28,7 @@ * ************************************************************************/ #include "testtool.hrc" -#include +#include #define Control_Control 5 diff --git a/svtools/source/uno/unoifac2.hrc b/svtools/source/uno/unoifac2.hrc index 4e8cf0303da5..64941b1c3013 100644 --- a/svtools/source/uno/unoifac2.hrc +++ b/svtools/source/uno/unoifac2.hrc @@ -33,7 +33,7 @@ #ifndef _SOLAR_HRC -#include +#include #endif //! Um den Überblick über alle benutzten HelpID's zu behalten sind diese diff --git a/svtools/workben/unodialog/udlg_global.hrc b/svtools/workben/unodialog/udlg_global.hrc index 71a67cd2b7e8..6fa2679e3386 100644 --- a/svtools/workben/unodialog/udlg_global.hrc +++ b/svtools/workben/unodialog/udlg_global.hrc @@ -31,7 +31,7 @@ #ifndef SVTOOLS_UDLG_GLOBAL_HRC #define SVTOOLS_UDLG_GLOBAL_HRC -#include +#include //===================================================================== //= bases From 5ea9defaaa271df2fd8d42341ea04796c91f31af Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 15 Aug 2009 16:43:25 +0000 Subject: [PATCH 177/283] #i92516# move solar.hrc to vcl --- goodies/inc/goodies.hrc | 2 +- goodies/inc/pch/precompiled_goodies.hxx | 2 +- goodies/source/filter.vcl/egif/egif.cxx | 2 +- goodies/source/filter.vcl/eos2met/eos2met.cxx | 2 +- goodies/source/filter.vcl/epbm/epbm.cxx | 2 +- goodies/source/filter.vcl/epgm/epgm.cxx | 2 +- goodies/source/filter.vcl/epict/epict.cxx | 2 +- goodies/source/filter.vcl/eppm/eppm.cxx | 2 +- goodies/source/filter.vcl/eps/eps.cxx | 2 +- goodies/source/filter.vcl/etiff/etiff.cxx | 2 +- goodies/source/filter.vcl/ipcd/ipcd.cxx | 2 +- goodies/source/inv/invader.cxx | 2 +- goodies/source/unographic/provider.cxx | 2 +- goodies/source/unographic/transformer.cxx | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/goodies/inc/goodies.hrc b/goodies/inc/goodies.hrc index 18584985a603..0cad63e4efdd 100644 --- a/goodies/inc/goodies.hrc +++ b/goodies/inc/goodies.hrc @@ -31,7 +31,7 @@ #define _GOODIES_HRC #ifndef _SOLAR_HRC -#include +#include #endif // Dialoge --------------------------------------------------------------- diff --git a/goodies/inc/pch/precompiled_goodies.hxx b/goodies/inc/pch/precompiled_goodies.hxx index b0d1ba09410b..8df95abff7ce 100644 --- a/goodies/inc/pch/precompiled_goodies.hxx +++ b/goodies/inc/pch/precompiled_goodies.hxx @@ -100,7 +100,7 @@ #include "svtools/fltcall.hxx" #include "svtools/itemprop.hxx" #include "svtools/lstner.hxx" -#include "svtools/solar.hrc" +#include "vcl/solar.hrc" #include "svtools/stdctrl.hxx" #include "svtools/svarray.hxx" diff --git a/goodies/source/filter.vcl/egif/egif.cxx b/goodies/source/filter.vcl/egif/egif.cxx index e1547c7339d0..6cef33de0187 100644 --- a/goodies/source/filter.vcl/egif/egif.cxx +++ b/goodies/source/filter.vcl/egif/egif.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "giflzwc.hxx" diff --git a/goodies/source/filter.vcl/eos2met/eos2met.cxx b/goodies/source/filter.vcl/eos2met/eos2met.cxx index b176d186a217..eabf720f7838 100644 --- a/goodies/source/filter.vcl/eos2met/eos2met.cxx +++ b/goodies/source/filter.vcl/eos2met/eos2met.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include "strings.hrc" #include "dlgeos2.hxx" diff --git a/goodies/source/filter.vcl/epbm/epbm.cxx b/goodies/source/filter.vcl/epbm/epbm.cxx index 92aeb501e141..2913452df4a9 100644 --- a/goodies/source/filter.vcl/epbm/epbm.cxx +++ b/goodies/source/filter.vcl/epbm/epbm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/epgm/epgm.cxx b/goodies/source/filter.vcl/epgm/epgm.cxx index b6056339f11e..435a53da6b9f 100644 --- a/goodies/source/filter.vcl/epgm/epgm.cxx +++ b/goodies/source/filter.vcl/epgm/epgm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/epict/epict.cxx b/goodies/source/filter.vcl/epict/epict.cxx index 4df7abea01fc..3de76263538d 100644 --- a/goodies/source/filter.vcl/epict/epict.cxx +++ b/goodies/source/filter.vcl/epict/epict.cxx @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/goodies/source/filter.vcl/eppm/eppm.cxx b/goodies/source/filter.vcl/eppm/eppm.cxx index 8cd71176e31b..5d682a215f6a 100644 --- a/goodies/source/filter.vcl/eppm/eppm.cxx +++ b/goodies/source/filter.vcl/eppm/eppm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/eps/eps.cxx b/goodies/source/filter.vcl/eps/eps.cxx index 8a163659050a..cda3da68aaa5 100644 --- a/goodies/source/filter.vcl/eps/eps.cxx +++ b/goodies/source/filter.vcl/eps/eps.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/goodies/source/filter.vcl/etiff/etiff.cxx b/goodies/source/filter.vcl/etiff/etiff.cxx index 12289cb8f0a9..c4bd6524627b 100644 --- a/goodies/source/filter.vcl/etiff/etiff.cxx +++ b/goodies/source/filter.vcl/etiff/etiff.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/goodies/source/filter.vcl/ipcd/ipcd.cxx b/goodies/source/filter.vcl/ipcd/ipcd.cxx index f70d1c8b84c5..b0d7cbc1eabb 100644 --- a/goodies/source/filter.vcl/ipcd/ipcd.cxx +++ b/goodies/source/filter.vcl/ipcd/ipcd.cxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include //============================ PCDReader ================================== diff --git a/goodies/source/inv/invader.cxx b/goodies/source/inv/invader.cxx index be15ff2e75d4..4e91536e577b 100644 --- a/goodies/source/inv/invader.cxx +++ b/goodies/source/inv/invader.cxx @@ -37,7 +37,7 @@ #include "invader.hrc" #include "strings.hrc" #include "score.hxx" -#include +#include #include #include #include diff --git a/goodies/source/unographic/provider.cxx b/goodies/source/unographic/provider.cxx index 2eb0aede9bdf..b332dd4233e2 100644 --- a/goodies/source/unographic/provider.cxx +++ b/goodies/source/unographic/provider.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/goodies/source/unographic/transformer.cxx b/goodies/source/unographic/transformer.cxx index 4422d161d7c4..ee4371172514 100644 --- a/goodies/source/unographic/transformer.cxx +++ b/goodies/source/unographic/transformer.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include From b1a1ddc401bb154812ab311339381747c48c531f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 14:40:01 +0000 Subject: [PATCH 178/283] #i92516# fix several small issues (helpids, taborder, property names) --- vcl/source/window/printdlg.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 38ddb66877d0..7d8dc893c1be 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -58,8 +58,8 @@ using namespace com::sun::star::uno; using namespace com::sun::star::beans; #define HELPID_PREFIX ".HelpId:vcl:PrintDialog" -#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ) ) ) -#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ) ) ) +#define SMHID2( a, b ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ":" b ) ), HID_PRINTDLG ) ) +#define SMHID1( a ) SetSmartHelpId( SmartId( String( RTL_CONSTASCII_USTRINGPARAM( HELPID_PREFIX ":" a ) ), HID_PRINTDLG ) ) PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const ResId& i_rId ) : Window( i_pParent, i_rId ) @@ -477,7 +477,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) maLocationTxt.SMHID2( "JobPage", "LocationText" ); maCommentLabel.SMHID2( "JobPage", "CommentLabel" ); maCommentTxt.SMHID2( "JobPage", "CommentText" ); - maSetupButton.SMHID2( "JobPage", "Setup" ); + maSetupButton.SMHID2( "JobPage", "Properties" ); maCopies.SMHID2( "JobPage", "CopiesLine" ); maCopySpacer.SMHID2( "JobPage", "CopySpacer" ); maCopyCount.SMHID2( "JobPage", "CopiesText" ); @@ -981,7 +981,7 @@ static void setSmartId( Window* i_pWindow, const char* i_pType, sal_Int32 i_nId aBuf.append( sal_Unicode( ':' ) ); aBuf.append( i_nId ); } - i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear() ) ); + i_pWindow->SetSmartHelpId( SmartId( aBuf.makeStringAndClear(), HID_PRINTDLG ) ); } static void setHelpText( Window* i_pWindow, const Sequence< rtl::OUString >& i_rHelpTexts, sal_Int32 i_nIndex ) @@ -1204,7 +1204,7 @@ void PrintDialog::setupOptionalUI() // EVIL else if( aCtrlType.equalsAscii( "Bool" ) && aGroupingHint.equalsAscii( "LayoutPage" ) && - aPropertyName.equalsAscii( "PrintBrochure" ) + aPropertyName.equalsAscii( "PrintProspect" ) ) { maNUpPage.maBrochureBtn.SetText( aText ); From 6b0adfa6f596666120cc069a4b1a6d486a122852 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 15:41:35 +0000 Subject: [PATCH 179/283] dispatch HID_PRINTDLG on help button --- vcl/source/window/printdlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 7d8dc893c1be..fef24e58ce5a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1838,7 +1838,7 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) if( pHelp ) { // FIXME: find out proper help URL and use here - pHelp->Start( 0, GetParent() ); + pHelp->Start( HID_PRINTDLG, GetParent() ); } } else if( pButton == &maForwardBtn ) From f604695c795a5d608bb35d64885beb7e6b7e6296 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 17 Aug 2009 17:34:09 +0000 Subject: [PATCH 180/283] #i92516# handle pageoffset in vcl instead of application --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 10 +- vcl/inc/vcl/print.hxx | 14 ++- vcl/source/gdi/print.cxx | 20 ++++ vcl/source/gdi/print3.cxx | 105 +++++++++++------- vcl/source/window/printdlg.cxx | 5 +- 5 files changed, 104 insertions(+), 50 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index df08faf43686..52f6c8c5b575 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -307,17 +307,17 @@ class ControllerProperties if( i_nPage >= 0 && nPages > i_nPage ) { GDIMetaFile aMtf; - Size aPageSize( mpController->getFilteredPageFile( i_nPage, aMtf, false ) ); + PrinterController::PageSize aPageSize( mpController->getFilteredPageFile( i_nPage, aMtf, false ) ); VirtualDevice aDev; Size aLogicSize( aDev.PixelToLogic( aPixelSize, MapMode( MAP_100TH_MM ) ) ); - double fScaleX = double(aLogicSize.Width())/double(aPageSize.Width()); - double fScaleY = double(aLogicSize.Height())/double(aPageSize.Height()); + double fScaleX = double(aLogicSize.Width())/double(aPageSize.aSize.Width()); + double fScaleY = double(aLogicSize.Height())/double(aPageSize.aSize.Height()); double fScale = (fScaleX < fScaleY) ? fScaleX : fScaleY; aMtf.WindStart(); aMtf.Scale( fScale, fScale ); aMtf.WindStart(); - aLogicSize.Width() = long(double(aPageSize.Width()) * fScale); - aLogicSize.Height() = long(double(aPageSize.Height()) * fScale); + aLogicSize.Width() = long(double(aPageSize.aSize.Width()) * fScale); + aLogicSize.Height() = long(double(aPageSize.aSize.Height()) * fScale); aPixelSize = aDev.LogicToPixel( aLogicSize, MapMode( MAP_100TH_MM ) ); aDev.SetOutputSizePixel( aPixelSize ); aMtf.WindStart(); diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 0a290cb6adcc..fe6d5b7c6f00 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -430,6 +430,16 @@ public: } }; + struct PageSize + { + Size aSize; // in 100th mm + bool bFullPaper; // full paper, not only imageable area is printed + + PageSize( const Size& i_rSize = Size( 21000, 29700 ), + bool i_bFullPaper = false + ) : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {} + }; + PrinterController(); virtual ~PrinterController(); @@ -490,8 +500,8 @@ public: // implementation details, not usable outside vcl SAL_DLLPRIVATE int getFilteredPageCount(); - SAL_DLLPRIVATE Size getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); - SAL_DLLPRIVATE Size getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); + SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); + SAL_DLLPRIVATE PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache = false ); SAL_DLLPRIVATE void printFilteredPage( int i_nPage ); SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr& ); SAL_DLLPRIVATE void setOptionChangeHdl( const Link& ); diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index eee954076278..72e8380b28a0 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -510,6 +510,26 @@ void Printer::ImplUpdatePageData() mnOutWidth, mnOutHeight, maPageOffset.X(), maPageOffset.Y(), maPaperSize.Width(), maPaperSize.Height() ); + static const char* pDebugOffset = getenv( "SAL_DBG_PAGEOFFSET" ); + if( pDebugOffset ) + { + rtl::OString aLine( pDebugOffset ); + sal_Int32 nIndex = 0; + rtl::OString aToken( aLine.getToken( 0, ',', nIndex ) ); + sal_Int32 nLeft = aToken.toInt32(); + sal_Int32 nTop = nLeft; + if( nIndex > 0 ) + { + rtl::OString aToken( aLine.getToken( 0, ',', nIndex ) ); + nTop = aToken.toInt32(); + } + maPageOffset = LogicToPixel( Point( static_cast(nLeft), + static_cast(nTop) ), + MapMode( MAP_100TH_MM ) + ); + mnOutWidth = maPaperSize.Width() - 2*maPageOffset.X(); + mnOutWidth = maPaperSize.Width() - 2*maPageOffset.Y(); + } } // ----------------------------------------------------------------------- diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 375947c867ec..c134a0d21f8c 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -60,7 +60,13 @@ using namespace vcl; class ImplPageCache { - std::vector< GDIMetaFile > maPages; + struct CacheEntry + { + GDIMetaFile aPage; + PrinterController::PageSize aSize; + }; + + std::vector< CacheEntry > maPages; std::vector< sal_Int32 > maPageNumbers; std::vector< sal_Int32 > maCacheRanking; @@ -92,10 +98,11 @@ public: } // caution: does not ensure uniqueness - void insert( sal_Int32 i_nPageNo, const GDIMetaFile& i_rPage ) + void insert( sal_Int32 i_nPageNo, const GDIMetaFile& i_rPage, const PrinterController::PageSize& i_rSize ) { sal_Int32 nReplacePage = maCacheRanking.back(); - maPages[ nReplacePage ] = i_rPage; + maPages[ nReplacePage ].aPage = i_rPage; + maPages[ nReplacePage ].aSize = i_rSize; maPageNumbers[ nReplacePage ] = i_nPageNo; // cache insertion means in our case, the page was just queried // so update the ranking @@ -105,19 +112,19 @@ public: // caution: bad algorithm; should there ever be reason to increase the cache size beyond 6 // this needs to be urgently rewritten. However do NOT increase the cache size lightly, // whole pages can be rather memory intensive - const GDIMetaFile* get( sal_Int32 i_nPageNo ) + bool get( sal_Int32 i_nPageNo, GDIMetaFile& o_rPageFile, PrinterController::PageSize& o_rSize ) { - const GDIMetaFile* pRet = NULL; for( sal_Int32 i = 0; i < nCacheSize; ++i ) { if( maPageNumbers[i] == i_nPageNo ) { updateRanking( i ); - pRet = &maPages[i]; - break; + o_rPageFile = maPages[i].aPage; + o_rSize = maPages[i].aSize; + return true; } } - return pRet; + return false; } void invalidate() @@ -125,7 +132,7 @@ public: for( sal_Int32 i = 0; i < nCacheSize; ++i ) { maPageNumbers[i] = -1; - maPages[i].Clear(); + maPages[i].aPage.Clear(); maCacheRanking[i] = nCacheSize - i - 1; } } @@ -580,21 +587,28 @@ bool PrinterController::setupPrinter( Window* i_pParent ) return bRet; } -static Size modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) +static PrinterController::PageSize modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) { - Size aPageSize = pPrinter->GetPaperSize(); + PrinterController::PageSize aPageSize; + aPageSize.aSize = pPrinter->GetPaperSize(); for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) { if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) { awt::Size aSize; i_rProps[ nProperty].Value >>= aSize; - aPageSize.Width() = aSize.Width; - aPageSize.Height() = aSize.Height; + aPageSize.aSize.Width() = aSize.Width; + aPageSize.aSize.Height() = aSize.Height; Size aCurSize( pPrinter->GetPaperSize() ); - if( aPageSize != aCurSize ) - pPrinter->SetPaperSizeUser( aPageSize ); + if( aPageSize.aSize != aCurSize ) + pPrinter->SetPaperSizeUser( aPageSize.aSize ); + } + if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) + { + sal_Bool bVal = sal_False; + i_rProps[ nProperty].Value >>= bVal; + aPageSize.bFullPaper = static_cast(bVal); } } return aPageSize; @@ -622,25 +636,24 @@ Sequence< beans::PropertyValue > PrinterController::getPageParametersProtected( return aResult; } -Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) +PrinterController::PageSize PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { // update progress if necessary if( mpImplData->mpProgress ) { // do nothing if printing is canceled if( mpImplData->mpProgress->isCanceled() ) - return Size(); + return PrinterController::PageSize(); mpImplData->mpProgress->tick(); Application::Reschedule( true ); } if( i_bMayUseCache ) { - const GDIMetaFile* pCached = mpImplData->maPageCache.get( i_nUnfilteredPage ); - if( pCached ) + PrinterController::PageSize aPageSize; + if( mpImplData->maPageCache.get( i_nUnfilteredPage, o_rMtf, aPageSize ) ) { - o_rMtf = *pCached; - return pCached->GetPrefSize(); + return aPageSize; } } else @@ -656,9 +669,9 @@ Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, mpImplData->mpPrinter->SetMapMode( aMapMode ); // modify job setup if necessary - Size aPageSize = modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); + PrinterController::PageSize aPageSize = modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); - o_rMtf.SetPrefSize( aPageSize ); + o_rMtf.SetPrefSize( aPageSize.aSize ); o_rMtf.SetPrefMapMode( aMapMode ); mpImplData->mpPrinter->EnableOutput( FALSE ); @@ -672,7 +685,7 @@ Size PrinterController::getPageFile( int i_nUnfilteredPage, GDIMetaFile& o_rMtf, mpImplData->mpPrinter->Pop(); if( i_bMayUseCache ) - mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf ); + mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf, aPageSize ); return aPageSize; } @@ -710,7 +723,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD o_rMtf.AddAction( new MetaPopAction() ); } -Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) +PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) { const MultiPageSetup& rMPS( mpImplData->maMultiPage ); int nSubPages = rMPS.nRows * rMPS.nColumns; @@ -729,19 +742,20 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o int nDocPages = getPageCountProtected(); i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; } - Size aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); - Size aPaperSize = mpImplData->getRealPaperSize( aPageSize ); - if( aPaperSize != aPageSize ) + PrinterController::PageSize aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); + Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize ); + if( aPaperSize != aPageSize.aSize ) { // user overridden page size, center Metafile o_rMtf.WindStart(); - long nDX = (aPaperSize.Width() - aPageSize.Width()) / 2; - long nDY = (aPaperSize.Height() - aPageSize.Height()) / 2; + long nDX = (aPaperSize.Width() - aPageSize.aSize.Width()) / 2; + long nDY = (aPaperSize.Height() - aPageSize.aSize.Height()) / 2; o_rMtf.Move( nDX, nDY ); o_rMtf.WindStart(); o_rMtf.SetPrefSize( aPaperSize ); + aPageSize.aSize = aPaperSize; } - return aPaperSize; + return aPageSize; } Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) ); @@ -775,8 +789,8 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o if( nPage >= 0 && nPage < nDocPages ) { GDIMetaFile aPageFile; - Size aPageSize = getPageFile( nPage, aPageFile, i_bMayUseCache ); - if( aPageSize.Width() && aPageSize.Height() ) + PrinterController::PageSize aPageSize = getPageFile( nPage, aPageFile, i_bMayUseCache ); + if( aPageSize.aSize.Width() && aPageSize.aSize.Height() ) { long nCellX = 0, nCellY = 0; switch( rMPS.nOrder ) @@ -791,23 +805,23 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o break; } // scale the metafile down to a sub page size - double fScaleX = double(aSubPageSize.Width())/double(aPageSize.Width()); - double fScaleY = double(aSubPageSize.Height())/double(aPageSize.Height()); + double fScaleX = double(aSubPageSize.Width())/double(aPageSize.aSize.Width()); + double fScaleY = double(aSubPageSize.Height())/double(aPageSize.aSize.Height()); double fScale = std::min( fScaleX, fScaleY ); aPageFile.Scale( fScale, fScale ); aPageFile.WindStart(); // move the subpage so it is centered in its "cell" - long nOffX = (aSubPageSize.Width() - long(double(aPageSize.Width()) * fScale)) / 2; - long nOffY = (aSubPageSize.Height() - long(double(aPageSize.Height()) * fScale)) / 2; + long nOffX = (aSubPageSize.Width() - long(double(aPageSize.aSize.Width()) * fScale)) / 2; + long nOffY = (aSubPageSize.Height() - long(double(aPageSize.aSize.Height()) * fScale)) / 2; long nX = rMPS.nLeftMargin + nOffX + nAdvX * nCellX; long nY = rMPS.nTopMargin + nOffY + nAdvY * nCellY; aPageFile.Move( nX, nY ); aPageFile.WindStart(); // calculate border rectangle Rectangle aSubPageRect( Point( nX, nY ), - Size( long(double(aPageSize.Width())*fScale), - long(double(aPageSize.Height())*fScale) ) ); + Size( long(double(aPageSize.aSize.Width())*fScale), + long(double(aPageSize.aSize.Height())*fScale) ) ); // append subpage to page appendSubPage( o_rMtf, aSubPageRect, aPageFile, rMPS.bDrawBorder ); @@ -819,7 +833,7 @@ Size PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize ); - return aPaperSize; + return PrinterController::PageSize( aPaperSize ); } int PrinterController::getFilteredPageCount() @@ -836,7 +850,7 @@ void PrinterController::printFilteredPage( int i_nPage ) return; GDIMetaFile aPageFile; - Size aPageSize = getFilteredPageFile( i_nPage, aPageFile ); + PrinterController::PageSize aPageSize = getFilteredPageFile( i_nPage, aPageFile ); if( mpImplData->mpProgress ) { @@ -904,7 +918,14 @@ void PrinterController::printFilteredPage( int i_nPage ) // in N-Up printing set the correct page size mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); // aPageSize was filtered through mpImplData->getRealPaperSize already by getFilteredPageFile() - mpImplData->mpPrinter->SetPaperSizeUser( aPageSize ); + mpImplData->mpPrinter->SetPaperSizeUser( aPageSize.aSize ); + // if full paper are is meant, move the output to accomodate for pageoffset + if( aPageSize.bFullPaper ) + { + Point aPageOffset( mpImplData->mpPrinter->GetPageOffset() ); + aCleanedFile.WindStart(); + aCleanedFile.Move( -aPageOffset.X(), -aPageOffset.Y() ); + } // actually print the page mpImplData->mpPrinter->ImplStartPage(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index fef24e58ce5a..1128a1f52e10 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1677,7 +1677,10 @@ Size PrintDialog::getJobPageSize() maFirstPageSize = maNupPortraitSize; GDIMetaFile aMtf; if( maPController->getPageCountProtected() > 0 ) - maFirstPageSize = maPController->getPageFile( 0, aMtf, true ); + { + PrinterController::PageSize aPageSize = maPController->getPageFile( 0, aMtf, true ); + maFirstPageSize = aPageSize.aSize; + } } return maFirstPageSize; } From 7b510ce2c097f6b9d57d48afb48f0d1e92b4196b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 18 Aug 2009 15:58:46 +0000 Subject: [PATCH 181/283] #i92516# getNativeControlRegion for edits and spinboxes --- vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 9dbb218403d0..a49ef063af57 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -1087,6 +1087,19 @@ BOOL GtkSalGraphics::getNativeControlRegion( ControlType nType, rNativeContentRegion = Region( aIndicatorRect ); returnVal = TRUE; } + if( (nType == CTRL_EDITBOX || nType == CTRL_SPINBOX) && nPart == PART_ENTIRE_CONTROL ) + { + NWEnsureGTKEditBox( m_nScreen ); + GtkWidget* widget = gWidgetData[m_nScreen].gEditBoxWidget; + GtkRequisition aReq; + gtk_widget_size_request( widget, &aReq ); + Rectangle aEditRect = rControlRegion.GetBoundRect(); + aEditRect = Rectangle( aEditRect.TopLeft(), + Size( aEditRect.GetWidth(), aReq.height+1 ) ); + rNativeBoundingRegion = Region( aEditRect ); + rNativeContentRegion = rNativeBoundingRegion; + returnVal = TRUE; + } return( returnVal ); } From 8802e7ab5f59b4e4a8ba6dced48660710d9ea9ab Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 18 Aug 2009 16:07:05 +0000 Subject: [PATCH 182/283] #i92516# align radio buttons and dependencies properly --- vcl/source/window/printdlg.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1128a1f52e10..bf1d38678821 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1309,9 +1309,11 @@ void PrintDialog::setupOptionalUI() pVal->Value >>= nSelectVal; for( sal_Int32 m = 0; m < aChoices.getLength(); m++ ) { - vcl::RowOrColumn* pDependencyRow = new vcl::RowOrColumn( pCurColumn, false ); - pRadioColumn->addChild( pDependencyRow ); - aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow ) ); + boost::shared_ptr pLabel( new vcl::LabeledElement( pRadioColumn, 1 ) ); + pRadioColumn->addChild( pLabel ); + boost::shared_ptr pDependencyRow( new vcl::RowOrColumn( pLabel.get(), false ) ); + pLabel->setElement( pDependencyRow ); + aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, pDependencyRow.get() ) ); RadioButton* pBtn = new RadioButton( pCurParent, m == 0 ? WB_GROUP : 0 ); maControls.push_front( pBtn ); @@ -1329,7 +1331,7 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pBtn, aHelpTexts, nCurHelpText++ ); // add the radio button to the column - pDependencyRow->addWindow( pBtn ); + pLabel->setLabel( pBtn ); } } else if( ( aCtrlType.equalsAscii( "List" ) || From a45b7400bb5d3d0ae0521789c67a7e2700734973 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 19 Aug 2009 08:31:45 +0000 Subject: [PATCH 183/283] fix a warning --- vcl/source/gdi/print.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 72e8380b28a0..f7db0b56f4ca 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -520,7 +520,7 @@ void Printer::ImplUpdatePageData() sal_Int32 nTop = nLeft; if( nIndex > 0 ) { - rtl::OString aToken( aLine.getToken( 0, ',', nIndex ) ); + aToken = aLine.getToken( 0, ',', nIndex ); nTop = aToken.toInt32(); } maPageOffset = LogicToPixel( Point( static_cast(nLeft), From 0f190044c038ccd3cd0dc12f6c5a81a9f2b9216e Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 19 Aug 2009 09:12:32 +0000 Subject: [PATCH 184/283] #i92516# new print UI --- vcl/source/gdi/print3.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index c134a0d21f8c..479095d94265 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -581,6 +581,7 @@ bool PrinterController::setupPrinter( Window* i_pParent ) if( aNewPaperSize != aPaperSize ) { mpImplData->maFixedPageSize = aNewPaperSize; + mpImplData->maPageCache.invalidate(); } } } From fd5fd47540a78b8cbe5fc1d3a541642aee09ba6f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 20 Aug 2009 15:09:25 +0000 Subject: [PATCH 185/283] #i92516# clean up graphics state at end of page --- vcl/aqua/inc/salgdi.h | 1 + vcl/aqua/source/gdi/salgdiutils.cxx | 6 ++++++ vcl/aqua/source/gdi/salprn.cxx | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h index 11abd6086ce7..fa8f45b27a68 100644 --- a/vcl/aqua/inc/salgdi.h +++ b/vcl/aqua/inc/salgdi.h @@ -175,6 +175,7 @@ public: void RefreshRect(float lX, float lY, float lWidth, float lHeight); void SetState(); + void UnsetState(); virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight ); virtual bool unionClipRegion( const ::basegfx::B2DPolyPolygon& ); diff --git a/vcl/aqua/source/gdi/salgdiutils.cxx b/vcl/aqua/source/gdi/salgdiutils.cxx index 066268791b11..338ab9b8cae0 100755 --- a/vcl/aqua/source/gdi/salgdiutils.cxx +++ b/vcl/aqua/source/gdi/salgdiutils.cxx @@ -126,6 +126,12 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex // ---------------------------------------------------------------------- +void AquaSalGraphics::UnsetState() +{ + if( mrContext ) + CGContextRestoreGState( mrContext ); +} + void AquaSalGraphics::SetState() { CGContextRestoreGState( mrContext ); diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index a9a58799f4db..cdc11162557e 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -138,7 +138,7 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const dY -= aPaperSize.height - aImageRect.size.height - aImageRect.origin.y; CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY ); // scale to be top/down and reflect our "virtual" DPI - CGContextScaleCTM( i_rContext, 0.1, -0.1 ); + CGContextScaleCTM( i_rContext, 72.0/double(nDPIX), -(72.0/double(nDPIY)) ); } else { @@ -152,7 +152,7 @@ void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const dY = -aPaperSize.width; CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX ); // scale to be top/down and reflect our "virtual" DPI - CGContextScaleCTM( i_rContext, -0.1, 0.1 ); + CGContextScaleCTM( i_rContext, -(72.0/double(nDPIY)), (72.0/double(nDPIX)) ); } mpGraphics->SetPrinterGraphics( i_rContext, nDPIX, nDPIY, 1.0 ); } @@ -705,6 +705,7 @@ SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, BOOL i_b BOOL AquaSalInfoPrinter::EndPage() { + mpGraphics->UnsetState(); return TRUE; } From e0b99ef4ddf793db58e34378c748441ee982447f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Fri, 21 Aug 2009 15:30:14 +0000 Subject: [PATCH 186/283] resolve conflicts --- vcl/aqua/source/gdi/salprn.cxx | 10 +++++--- vcl/inc/vcl/gdimtf.hxx | 8 ++++++ vcl/source/control/lstbox.cxx | 46 +++++++++++++++++++++------------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index cdc11162557e..799a620345d7 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -336,11 +336,15 @@ BOOL AquaSalInfoPrinter::SetData( ULONG i_nFlags, ImplJobSetup* io_pSetupData ) if( (i_nFlags & SAL_JOBSET_PAPERSIZE) != 0) { // set paper format - long width = 0, height = 0; + long width = 21000, height = 29700; if( io_pSetupData->mePaperFormat == PAPER_USER ) { - width = io_pSetupData->mnPaperWidth; - height = io_pSetupData->mnPaperHeight; + // #i101108# sanity check + if( io_pSetupData->mnPaperWidth && io_pSetupData->mnPaperHeight ) + { + width = io_pSetupData->mnPaperWidth; + height = io_pSetupData->mnPaperHeight; + } } else { diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx index 48b39d290872..e4acd55439cc 100644 --- a/vcl/inc/vcl/gdimtf.hxx +++ b/vcl/inc/vcl/gdimtf.hxx @@ -165,6 +165,14 @@ public: void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); void Rotate( long nAngle10 ); void Clip( const Rectangle& ); + /* get the bound rect of the contained actions + * caveats: + * - clip actions will limit the contained actions, + * but the current clipregion of the passed OutputDevice will not + * - coordinates of actions will be transformed to preferred mapmode + * - the returned rectangle is relative to the preferred mapmode of the metafile + */ + Rectangle GetBoundRect( OutputDevice& i_rReference ); void Adjust( short nLuminancePercent = 0, short nContrastPercent = 0, short nChannelRPercent = 0, short nChannelGPercent = 0, diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 7c9842c278d1..55a5e8bfd282 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -31,21 +31,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#ifndef _SV_RC_H -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "tools/rc.h" + +#include "vcl/svdata.hxx" +#include "vcl/decoview.hxx" +#include "vcl/event.hxx" +#include "vcl/scrbar.hxx" +#include "vcl/button.hxx" +#include "vcl/edit.hxx" +#include "vcl/subedit.hxx" +#include "vcl/ilstbox.hxx" +#include "vcl/lstbox.hxx" +#include "vcl/combobox.hxx" +#include "vcl/controllayout.hxx" + +#include "tools/debug.hxx" @@ -128,9 +128,7 @@ void ListBox::ImplInit( Window* pParent, WinBits nStyle ) GetBorder( nLeft, nTop, nRight, nBottom ); mnDDHeight = (USHORT)(GetTextHeight() + nTop + nBottom + 4); - // FIXME: this is currently only on mac/aqua - if( ImplGetSVData()->maNWFData.mbNoFocusRects && - IsNativeWidgetEnabled() && + if( IsNativeWidgetEnabled() && IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) ) { ImplControlValue aControlValue; @@ -651,6 +649,7 @@ void ListBox::Resize() long nTop = 0; long nBottom = aOutSz.Height(); + // note: in case of no border, pBorder will actually be this Window *pBorder = GetWindow( WINDOW_BORDER ); ImplControlValue aControlValue; Point aPoint; @@ -679,6 +678,17 @@ void ListBox::Resize() // use the themes drop down size Rectangle aContentRect = aContent.GetBoundRect(); + if( ! (GetStyle() & WB_BORDER) && ImplGetSVData()->maNWFData.mbNoFocusRects ) + { + // no border but focus ring behavior -> we have a problem; the + // native rect relies on the border to draw the focus + // let's do the best we can and center vertically, so it doesn't look + // completely wrong. + Size aSz( GetOutputSizePixel() ); + long nDiff = aContentRect.Top() - (aSz.Height() - aContentRect.GetHeight())/2; + aContentRect.Top() -= nDiff; + aContentRect.Bottom() -= nDiff; + } mpImplWin->SetPosSizePixel( aContentRect.TopLeft(), aContentRect.GetSize() ); } else From 4569c69eba08f7cb102d05d72e5cf23bed0eb68b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 24 Aug 2009 15:31:08 +0000 Subject: [PATCH 187/283] #i92516# protect against setting the clip region between printed pages --- vcl/aqua/inc/salgdi.h | 2 ++ vcl/aqua/source/gdi/salgdi.cxx | 12 ++++++++---- vcl/aqua/source/gdi/salgdiutils.cxx | 29 ++++++++++++++++++++++++++--- vcl/aqua/source/gdi/salprn.cxx | 2 +- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h index fa8f45b27a68..c4cca1982215 100644 --- a/vcl/aqua/inc/salgdi.h +++ b/vcl/aqua/inc/salgdi.h @@ -176,6 +176,8 @@ public: void SetState(); void UnsetState(); + // InvalidateContext does an UnsetState and sets mrContext to 0 + void InvalidateContext(); virtual BOOL unionClipRegion( long nX, long nY, long nWidth, long nHeight ); virtual bool unionClipRegion( const ::basegfx::B2DPolyPolygon& ); diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index f8410a47dfd6..223aeff0d02f 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -597,7 +597,8 @@ void AquaSalGraphics::EndSetClipRegion() void AquaSalGraphics::SetLineColor() { maLineColor.SetAlpha( 0.0 ); // transparent - CGContextSetStrokeColor( mrContext, maLineColor.AsArray() ); + if( CheckContext() ) + CGContextSetStrokeColor( mrContext, maLineColor.AsArray() ); } // ----------------------------------------------------------------------- @@ -605,7 +606,8 @@ void AquaSalGraphics::SetLineColor() void AquaSalGraphics::SetLineColor( SalColor nSalColor ) { maLineColor = RGBAColor( nSalColor ); - CGContextSetStrokeColor( mrContext, maLineColor.AsArray() ); + if( CheckContext() ) + CGContextSetStrokeColor( mrContext, maLineColor.AsArray() ); } // ----------------------------------------------------------------------- @@ -613,7 +615,8 @@ void AquaSalGraphics::SetLineColor( SalColor nSalColor ) void AquaSalGraphics::SetFillColor() { maFillColor.SetAlpha( 0.0 ); // transparent - CGContextSetFillColor( mrContext, maFillColor.AsArray() ); + if( CheckContext() ) + CGContextSetFillColor( mrContext, maFillColor.AsArray() ); } // ----------------------------------------------------------------------- @@ -621,7 +624,8 @@ void AquaSalGraphics::SetFillColor() void AquaSalGraphics::SetFillColor( SalColor nSalColor ) { maFillColor = RGBAColor( nSalColor ); - CGContextSetFillColor( mrContext, maFillColor.AsArray() ); + if( CheckContext() ) + CGContextSetFillColor( mrContext, maFillColor.AsArray() ); } // ----------------------------------------------------------------------- diff --git a/vcl/aqua/source/gdi/salgdiutils.cxx b/vcl/aqua/source/gdi/salgdiutils.cxx index b7420cb8f53a..6df50f79e9d0 100755 --- a/vcl/aqua/source/gdi/salgdiutils.cxx +++ b/vcl/aqua/source/gdi/salgdiutils.cxx @@ -68,6 +68,13 @@ void AquaSalGraphics::SetPrinterGraphics( CGContextRef xContext, long nDPIX, lon mnRealDPIX = nDPIX; mnRealDPIY = nDPIY; + // a previously set clip path is now invalid + if( mxClipPath ) + { + CGPathRelease( mxClipPath ); + mxClipPath = NULL; + } + if( mrContext ) { CGContextSetFillColorSpace( mrContext, GetSalData()->mxRGBSpace ); @@ -126,10 +133,26 @@ void AquaSalGraphics::SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContex // ---------------------------------------------------------------------- +void AquaSalGraphics::InvalidateContext() +{ + UnsetState(); + mrContext = 0; +} + +// ---------------------------------------------------------------------- + void AquaSalGraphics::UnsetState() { if( mrContext ) + { CGContextRestoreGState( mrContext ); + mrContext = 0; + } + if( mxClipPath ) + { + CGPathRelease( mxClipPath ); + mxClipPath = NULL; + } } void AquaSalGraphics::SetState() @@ -140,9 +163,9 @@ void AquaSalGraphics::SetState() // setup clipping if( mxClipPath ) { - CGContextBeginPath( mrContext ); // discard any existing path + CGContextBeginPath( mrContext ); // discard any existing path CGContextAddPath( mrContext, mxClipPath ); // set the current path to the clipping path - CGContextClip( mrContext ); // use it for clipping + CGContextClip( mrContext ); // use it for clipping } // set RGB colorspace and line and fill colors @@ -211,7 +234,7 @@ bool AquaSalGraphics::CheckContext() CGContextRelease( rReleaseContext ); } - DBG_ASSERT( mrContext, "<<>> AquaSalGraphics::CheckContext() FAILED!!!!\n" ); + DBG_ASSERT( mrContext || mbPrinter, "<<>> AquaSalGraphics::CheckContext() FAILED!!!!\n" ); return (mrContext != NULL); } diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 799a620345d7..079629216df6 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -709,7 +709,7 @@ SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, BOOL i_b BOOL AquaSalInfoPrinter::EndPage() { - mpGraphics->UnsetState(); + mpGraphics->InvalidateContext(); return TRUE; } From 5ab7598b54dc41208c5a1d1655daece59c8f6752 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 24 Aug 2009 17:27:29 +0000 Subject: [PATCH 188/283] #i92516# HELP_DEBUG for non static controls --- vcl/inc/vcl/window.h | 3 ++- vcl/source/window/printdlg.cxx | 2 ++ vcl/source/window/window.cxx | 21 +++++++++++++++++++++ vcl/source/window/window2.cxx | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/vcl/inc/vcl/window.h b/vcl/inc/vcl/window.h index d745f3dcf081..563849873e3b 100644 --- a/vcl/inc/vcl/window.h +++ b/vcl/inc/vcl/window.h @@ -358,7 +358,8 @@ public: mbToolbarFloatingWindow:1, mbCallHandlersDuringInputDisabled:1, mbDisableAccessibleLabelForRelation:1, - mbDisableAccessibleLabeledByRelation:1; + mbDisableAccessibleLabeledByRelation:1, + mbHelpTextDynamic:1; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; }; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index bf1d38678821..4f25a9f296a8 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -471,6 +471,7 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) SMHID1( "JobPage" ); maPrinterFL.SMHID2( "JobPage", "Printer" ); maPrinters.SMHID2( "JobPage", "PrinterList" ); + maDetailsBtn.SMHID2( "JobPage", "DetailsBtn" ); maStatusLabel.SMHID2( "JobPage", "StatusLabel" ); maStatusTxt.SMHID2( "JobPage", "StatusText" ); maLocationLabel.SMHID2( "JobPage", "LocationLabel" ); @@ -837,6 +838,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrmbCallHandlersDuringInputDisabled = FALSE; // TRUE: call event handlers even if input is disabled mpWindowImpl->mbDisableAccessibleLabelForRelation = FALSE; // TRUE: do not set LabelFor relation on accessible objects mpWindowImpl->mbDisableAccessibleLabeledByRelation = FALSE; // TRUE: do not set LabeledBy relation on accessible objects + mpWindowImpl->mbHelpTextDynamic = FALSE; // TRUE: append help id in HELP_DEBUG case mbEnableRTL = Application::GetSettings().GetLayoutRTL(); // TRUE: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active } @@ -1269,7 +1270,10 @@ void Window::ImplLoadRes( const ResId& rResId ) if ( nObjMask & WINDOW_TEXT ) SetText( ReadStringRes() ); if ( nObjMask & WINDOW_HELPTEXT ) + { SetHelpText( ReadStringRes() ); + mpWindowImpl->mbHelpTextDynamic = TRUE; + } if ( nObjMask & WINDOW_QUICKTEXT ) SetQuickHelpText( ReadStringRes() ); if ( nObjMask & WINDOW_EXTRALONG ) @@ -8099,9 +8103,26 @@ const XubString& Window::GetHelpText() const ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this ); else ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( nNumHelpId, this ); + mpWindowImpl->mbHelpTextDynamic = FALSE; } } } + else if( mpWindowImpl->mbHelpTextDynamic && (nNumHelpId || bStrHelpId) ) + { + static const char* pEnv = getenv( "HELP_DEBUG" ); + if( pEnv && *pEnv ) + { + rtl::OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.Len() ); + aTxt.append( mpWindowImpl->maHelpText ); + aTxt.appendAscii( "\n+++++++++++++++\n" ); + if( bStrHelpId ) + aTxt.append( rtl::OUString( aStrHelpId ) ); + else + aTxt.append( sal_Int32( nNumHelpId ) ); + mpWindowImpl->maHelpText = aTxt.makeStringAndClear(); + } + mpWindowImpl->mbHelpTextDynamic = FALSE; + } return mpWindowImpl->maHelpText; } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index af2043fda516..a9bc93863829 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -1999,6 +1999,7 @@ BOOL Window::IsZoom() const void Window::SetHelpText( const XubString& rHelpText ) { mpWindowImpl->maHelpText = rHelpText; + mpWindowImpl->mbHelpTextDynamic = TRUE; } void Window::SetQuickHelpText( const XubString& rHelpText ) From c5581dc245fa52b23fe4ab0bfc06501e76c404fe Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 25 Aug 2009 08:52:05 +0000 Subject: [PATCH 189/283] #i92516# cosmetics --- vcl/inc/vcl/print.hxx | 2 +- vcl/source/src/print.src | 4 ++-- vcl/source/window/printdlg.cxx | 11 +++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index fe6d5b7c6f00..2f8a96c690d3 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -423,7 +423,7 @@ public: : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) , nLeftMargin( 0 ), nTopMargin( 0 ) , nRightMargin( 0 ), nBottomMargin( 0 ) - , nHorizontalSpacing( 500 ), nVerticalSpacing( 500 ) + , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 ) , bDrawBorder( false ) , nOrder( LRTB ) { diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 5c04af603c93..5b8ca0447b31 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -32,7 +32,7 @@ ModalDialog SV_DLG_PRINT { - Text [en-US] = "Printing"; + Text [en-US] = "Print"; Closeable = TRUE; Sizeable = TRUE; Moveable = TRUE; @@ -333,7 +333,7 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 100, 10 ); - Text [en-US] = "Location"; + Text [en-US] = "Location:"; }; FixedText SV_PRINT_COMMENT_TXT { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 4f25a9f296a8..d03fd435c191 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -879,13 +879,16 @@ void PrintDialog::setupLayout() // get a row for the preview controls boost::shared_ptr< vcl::RowOrColumn > xPreviewCtrls( new vcl::RowOrColumn( xPreview.get(), false ) ); nIndex = xPreview->addChild( xPreviewCtrls ); - xPreview->setBorders( nIndex, aBorder.Width()*3, 0, aBorder.Width()*3, 0 ); + boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); + xPreviewCtrls->addChild( xSpacer ); xPreviewCtrls->addWindow( &maPageEdit ); xPreviewCtrls->addWindow( &maNumPagesText ); - boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); + xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); xPreviewCtrls->addChild( xSpacer ); xPreviewCtrls->addWindow( &maBackwardBtn ); xPreviewCtrls->addWindow( &maForwardBtn ); + xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); + xPreviewCtrls->addChild( xSpacer ); // continue with the tab ctrl xPreviewAndTab->addWindow( &maTabCtrl ); @@ -1727,8 +1730,8 @@ void PrintDialog::updateNupFromPages() nRows = nCols = 3; else if( nPages == 16 ) nRows = nCols = 4; - nPageMargin = 500; - nSheetMargin = 500; + nPageMargin = 0; + nSheetMargin = 0; } else bCustom = true; From b2cbc1f25f2ea3249b07d7509fbf777886744ee8 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 26 Aug 2009 15:14:10 +0000 Subject: [PATCH 190/283] size preview decently --- vcl/source/window/printdlg.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index d03fd435c191..557a2f478c3c 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -826,7 +826,26 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrsetOptionChangeHdl( LINK( this, PrintDialog, UIOptionsChanged ) ); // set min size pixel to current size - SetMinOutputSizePixel( GetOutputSizePixel() ); + Size aOutSize( GetOutputSizePixel() ); + SetMinOutputSizePixel( aOutSize ); + + // if there is space enough, enlarge the preview so it gets roughly as + // high as the tab control + if( aOutSize.Width() < 768 ) + { + Size aJobPageSize( getJobPageSize() ); + Size aTabSize( maTabCtrl.GetSizePixel() ); + long nOptPreviewWidth = aTabSize.Height() * aJobPageSize.Width() / aJobPageSize.Height(); + // add space for borders + nOptPreviewWidth += 15; + if( aOutSize.Width() - aTabSize.Width() < nOptPreviewWidth ) + { + aOutSize.Width() = aTabSize.Width() + nOptPreviewWidth; + if( aOutSize.Width() > 768 ) // don't enlarge the dialog too much + aOutSize.Width() = 768; + SetOutputSizePixel( aOutSize ); + } + } // restore settings from last run readFromSettings(); From 7e43a54274902c7bfc3126034e29c1e88b13b70a Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 26 Aug 2009 15:46:13 +0000 Subject: [PATCH 191/283] details with nicer indentation --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/inc/vcl/svids.hrc | 1 + vcl/source/src/print.src | 5 +++++ vcl/source/window/printdlg.cxx | 28 +++++++++++----------------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 9ea5be6e10b8..0f5288c9d6bd 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -244,6 +244,7 @@ namespace vcl rtl::OUString maPrintToFileText; rtl::OUString maPrintText; + rtl::OUString maDefPrtText; vcl::RowOrColumn maLayout; diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index f21aa6a4cd20..1959a2df3152 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -91,6 +91,7 @@ #define SV_PRINT_PRT_LOCATION 12 #define SV_PRINT_PRT_COMMENT 13 #define SV_PRINT_TOFILE_TXT 14 +#define SV_PRINT_DEFPRT_TXT 15 #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP_LAYOUT_FL 1 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 5b8ca0447b31..8df7d33e2fed 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -113,6 +113,11 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "Print to file..."; }; + String SV_PRINT_DEFPRT_TXT + { + Text [en-US] = "Default printer"; + }; + TabPage SV_PRINT_TAB_NUP { Text [en-US] = "Page Layout"; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 557a2f478c3c..45c3de5a29be 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -530,22 +530,11 @@ void PrintDialog::JobTabPage::setupLayout() // remember details controls mxDetails = xIndent; // create a column for the details - boost::shared_ptr< vcl::RowOrColumn > xDetCol( new vcl::RowOrColumn( xIndent.get() ) ); - xIndent->setChild( xDetCol ); - // create a row for stati and properties button - boost::shared_ptr< vcl::RowOrColumn > xStateRow( new vcl::RowOrColumn( xDetCol.get(), false ) ); - xDetCol->addChild( xStateRow ); - boost::shared_ptr< vcl::RowOrColumn > xLabelCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) ); - xStateRow->addChild( xLabelCol ); - xLabelCol->addWindow( &maStatusLabel ); - xLabelCol->addWindow( &maLocationLabel ); - xLabelCol->addWindow( &maCommentLabel ); - - boost::shared_ptr< vcl::RowOrColumn > xStatusCol( new vcl::RowOrColumn( xStateRow.get(), true, aBorder.Height() ) ); - xStateRow->addChild( xStatusCol ); - xStatusCol->addWindow( &maStatusTxt ); - xStatusCol->addWindow( &maLocationTxt ); - xStatusCol->addWindow( &maCommentTxt ); + boost::shared_ptr< vcl::LabelColumn > xLabelCol( new vcl::LabelColumn( xIndent.get(), aBorder.Height() ) ); + xIndent->setChild( xLabelCol ); + xLabelCol->addRow( &maStatusLabel, &maStatusTxt ); + xLabelCol->addRow( &maLocationLabel, &maLocationTxt ); + xLabelCol->addRow( &maCommentLabel, &maCommentTxt ); // add print range and copies columns maLayout.addWindow( &maCopies ); @@ -707,6 +696,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrGetLocation() ); maJobPage.maCommentTxt.SetText( pInfo->GetComment() ); // FIXME: status text - maJobPage.maStatusTxt.SetText( String() ); + rtl::OUString aStatus; + if( aDefPrt == pInfo->GetPrinterName() ) + aStatus = maDefPrtText; + maJobPage.maStatusTxt.SetText( aStatus ); } else { From b5022546b067c67611075b81ced67a3a0d45ca08 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Wed, 26 Aug 2009 16:28:12 +0000 Subject: [PATCH 192/283] #i92516# user paper override not functional in all cases --- vcl/source/gdi/print3.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 479095d94265..926f44f13692 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -189,6 +189,7 @@ public: return maMultiPage.aPaperSize; return i_rPageSize; } + PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps ); }; PrinterController::PrinterController() @@ -588,10 +589,10 @@ bool PrinterController::setupPrinter( Window* i_pParent ) return bRet; } -static PrinterController::PageSize modifyJobSetup( Printer* pPrinter, const Sequence< PropertyValue >& i_rProps ) +PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( const Sequence< PropertyValue >& i_rProps ) { PrinterController::PageSize aPageSize; - aPageSize.aSize = pPrinter->GetPaperSize(); + aPageSize.aSize = mpPrinter->GetPaperSize(); for( sal_Int32 nProperty = 0, nPropertyCount = i_rProps.getLength(); nProperty < nPropertyCount; ++nProperty ) { if( i_rProps[ nProperty ].Name.equalsAscii( "PageSize" ) ) @@ -601,9 +602,10 @@ static PrinterController::PageSize modifyJobSetup( Printer* pPrinter, const Sequ aPageSize.aSize.Width() = aSize.Width; aPageSize.aSize.Height() = aSize.Height; - Size aCurSize( pPrinter->GetPaperSize() ); - if( aPageSize.aSize != aCurSize ) - pPrinter->SetPaperSizeUser( aPageSize.aSize ); + Size aCurSize( mpPrinter->GetPaperSize() ); + Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); + if( aRealPaperSize != aCurSize ) + mpPrinter->SetPaperSizeUser( aRealPaperSize ); } if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) { @@ -670,7 +672,7 @@ PrinterController::PageSize PrinterController::getPageFile( int i_nUnfilteredPag mpImplData->mpPrinter->SetMapMode( aMapMode ); // modify job setup if necessary - PrinterController::PageSize aPageSize = modifyJobSetup( mpImplData->mpPrinter.get(), aPageParm ); + PrinterController::PageSize aPageSize = mpImplData->modifyJobSetup( aPageParm ); o_rMtf.SetPrefSize( aPageSize.aSize ); o_rMtf.SetPrefMapMode( aMapMode ); From 5a6ece62b1df0c10a4997e3432756c632901ca75 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Wed, 26 Aug 2009 17:16:32 +0000 Subject: [PATCH 193/283] more cosmetics --- vcl/source/window/arrange.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/arrange.cxx b/vcl/source/window/arrange.cxx index 7e019dc7e5ac..0199af7ed50d 100644 --- a/vcl/source/window/arrange.cxx +++ b/vcl/source/window/arrange.cxx @@ -661,7 +661,7 @@ void LabelColumn::resize() size_t LabelColumn::addRow( Window* i_pLabel, boost::shared_ptr const& i_rElement, long i_nIndent ) { - boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 2 ) ); + boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 1 ) ); xLabel->setLabel( i_pLabel ); xLabel->setBorders( 0, i_nIndent, 0, 0, 0 ); xLabel->setElement( i_rElement ); @@ -672,7 +672,7 @@ size_t LabelColumn::addRow( Window* i_pLabel, boost::shared_ptr size_t LabelColumn::addRow( Window* i_pLabel, Window* i_pElement, long i_nIndent ) { - boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 2 ) ); + boost::shared_ptr< LabeledElement > xLabel( new LabeledElement( this, 1 ) ); xLabel->setLabel( i_pLabel ); xLabel->setBorders( 0, i_nIndent, 0, 0, 0 ); xLabel->setElement( i_pElement ); From 4e0267c10be60f4e938e3f32b39ea1181496fd89 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 13:41:02 +0000 Subject: [PATCH 194/283] #i92516# IsFirstPage property --- vcl/source/gdi/print3.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 926f44f13692..f4a718abc3b9 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -159,6 +159,7 @@ public: PropertyToIndexMap maPropertyToIndex; Link maOptionChangeHdl; ControlDependencyMap maControlDependencies; + sal_Bool mbFirstPage; sal_Bool mbLastPage; sal_Bool mbReversePageOrder; view::PrintableState meJobState; @@ -174,6 +175,7 @@ public: Size maFixedPageSize; ImplPrinterControllerData() : + mbFirstPage( sal_True ), mbLastPage( sal_False ), mbReversePageOrder( sal_False ), meJobState( view::PrintableState_JOB_STARTED ), @@ -690,6 +692,9 @@ PrinterController::PageSize PrinterController::getPageFile( int i_nUnfilteredPag if( i_bMayUseCache ) mpImplData->maPageCache.insert( i_nUnfilteredPage, o_rMtf, aPageSize ); + // reset "FirstPage" property to false now we've gotten at least our first one + mpImplData->mbFirstPage = sal_False; + return aPageSize; } @@ -987,6 +992,14 @@ Sequence< PropertyValue > PrinterController::getJobProperties( const Sequence< P if( aMergeSet.find( mpImplData->maUIProperties[i].Name ) == aMergeSet.end() ) aResult[nCur++] = mpImplData->maUIProperties[i]; } + // append IsFirstPage + if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ) ) == aMergeSet.end() ) + { + PropertyValue aVal; + aVal.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFirstPage" ) ); + aVal.Value <<= mpImplData->mbFirstPage; + aResult[nCur++] = aVal; + } // append IsLastPage if( aMergeSet.find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsLastPage" ) ) ) == aMergeSet.end() ) { From 0b66a79a38b3f6fb1790307f6459a62efec35442 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 13:48:47 +0000 Subject: [PATCH 195/283] #i92516# no progress on api print --- vcl/source/gdi/print3.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index f4a718abc3b9..2056df3a7d3d 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1218,6 +1218,16 @@ void PrinterController::createProgressDialog() beans::PropertyValue* pMonitor = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) ); if( pMonitor ) pMonitor->Value >>= bShow; + else + { + const com::sun::star::beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsApi" ) ) ); + if( pVal ) + { + sal_Bool bApi = sal_False; + pVal->Value >>= bApi; + bShow = ! bApi; + } + } if( bShow && ! Application::IsHeadlessModeEnabled() ) { From c9bf01e4958f7d9dd7876c10a6476bc0d84c7ea0 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 16:08:23 +0000 Subject: [PATCH 196/283] #i92516# imporve CalcMinimumSize --- vcl/source/control/edit.cxx | 3 +++ vcl/source/control/lstbox.cxx | 1 + 2 files changed, 4 insertions(+) diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 2b6f20977689..7c02b9aadbbd 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2836,6 +2836,9 @@ Size Edit::CalcMinimumSize() const Size aMinSize ( CalcSize( 3 ) ); if( aSize.Width() < aMinSize.Width() ) aSize.Width() = aMinSize.Width(); + // add some space between text entry an border + aSize.Height() += 4; + aSize = CalcWindowSize( aSize ); // ask NWF what if it has an opinion, too diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 55a5e8bfd282..ce1f4f5ce22a 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -1284,6 +1284,7 @@ Size ListBox::CalcMinimumSize() const else { aSz.Height() = mpImplLB->CalcSize( 1 ).Height(); + aSz.Height() += 4; // add a space between entry and border // size to maxmimum entry width and add a little breathing space aSz.Width() = mpImplLB->GetMaxEntryWidth() + 4; // do not create ultrathin ListBoxes, it doesn't look good From 2fbe64f3eca3bb4f2d881ae764d9362a2d3c8b5f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 16:14:43 +0000 Subject: [PATCH 197/283] #i92516# set page marging to 0 in 1 page case --- vcl/source/window/printdlg.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 45c3de5a29be..032343f10020 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1718,6 +1718,7 @@ void PrintDialog::updateNupFromPages() { nRows = nCols = 1; nSheetMargin = 0; + nPageMargin = 0; } else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 ) { From b380b1cb316a12e1ee8cce2749686c0f4fd99425 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 17:19:25 +0000 Subject: [PATCH 198/283] #i92516# margin logic in dialog --- vcl/source/gdi/print3.cxx | 24 +++++++++------------- vcl/source/window/printdlg.cxx | 37 +++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 2056df3a7d3d..b56016a3cfbd 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -707,26 +707,22 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD // save gstate o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION | PUSH_MAPMODE ) ); - // draw a border - if( i_bDrawBorder ) - { - Rectangle aBorderRect( i_rClipRect ); - aBorderRect.Left() -= 100; - aBorderRect.Top() -= 100; - aBorderRect.Right() += 100; - aBorderRect.Bottom() += 100; - o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); - o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); - o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); - } - // clip to page rect - // o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); + o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); // append the subpage io_rSubPage.WindStart(); io_rSubPage.Play( o_rMtf ); + // draw a border + if( i_bDrawBorder ) + { + Rectangle aBorderRect( i_rClipRect ); + o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); + o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); + o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); + } + // restore gstate o_rMtf.AddAction( new MetaPopAction() ); } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 032343f10020..5fb63275f5d8 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1750,6 +1750,41 @@ void PrintDialog::updateNupFromPages() else bCustom = true; + if( nPages > 1 ) + { + // set upper limits for margins based on job page size and rows/columns + Size aSize( getJobPageSize() ); + + // maximum sheet distance: 1/2 sheet + long nHorzMax = aSize.Width()/2; + long nVertMax = aSize.Height()/2; + if( nSheetMargin > nHorzMax ) + nSheetMargin = nHorzMax; + if( nSheetMargin > nVertMax ) + nSheetMargin = nVertMax; + + maNUpPage.maSheetMarginEdt.SetMax( + maNUpPage.maSheetMarginEdt.Normalize( + nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); + + // maximum page distance + nHorzMax = (aSize.Width() - 2*nSheetMargin); + if( nCols > 1 ) + nHorzMax /= (nCols-1); + nVertMax = (aSize.Height() - 2*nSheetMargin); + if( nRows > 1 ) + nHorzMax /= (nRows-1); + + if( nPageMargin > nHorzMax ) + nPageMargin = nHorzMax; + if( nPageMargin > nVertMax ) + nPageMargin = nVertMax; + + maNUpPage.maPageMarginEdt.SetMax( + maNUpPage.maSheetMarginEdt.Normalize( + nHorzMax > nVertMax ? nVertMax : nHorzMax ), FUNIT_100TH_MM ); + } + maNUpPage.maNupRowsEdt.SetValue( nRows ); maNUpPage.maNupColEdt.SetValue( nCols ); maNUpPage.maPageMarginEdt.SetValue( maNUpPage.maPageMarginEdt.Normalize( nPageMargin ), FUNIT_100TH_MM ); @@ -1956,7 +1991,7 @@ IMPL_LINK( PrintDialog, ModifyHdl, Edit*, pEdit ) pEdit == &maNUpPage.maSheetMarginEdt || pEdit == &maNUpPage.maPageMarginEdt ) { - updateNup(); + updateNupFromPages(); } else if( pEdit == &maPageEdit ) { From a2df349f777528b652637415364e7a97d25603ca Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 31 Aug 2009 17:28:02 +0000 Subject: [PATCH 199/283] #i92516# make formula editor look a little better --- vcl/source/window/printdlg.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 5fb63275f5d8..2d1bbf43e607 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -550,11 +550,11 @@ void PrintDialog::JobTabPage::setupLayout() xRangeRow->addChild( xCopyCollateCol ); // add copies row to copy/collate column - boost::shared_ptr< vcl::LabeledElement > xCopiesRow( new vcl::LabeledElement( xCopyCollateCol.get() ) ); + boost::shared_ptr< vcl::LabeledElement > xCopiesRow( new vcl::LabeledElement( xCopyCollateCol.get(), 2 ) ); xCopyCollateCol->addChild( xCopiesRow ); xCopiesRow->setLabel( &maCopyCount ); xCopiesRow->setElement( &maCopyCountField ); - boost::shared_ptr< vcl::LabeledElement > xCollateRow( new vcl::LabeledElement( xCopyCollateCol.get() ) ); + boost::shared_ptr< vcl::LabeledElement > xCollateRow( new vcl::LabeledElement( xCopyCollateCol.get(), 2 ) ); xCopyCollateCol->addChild( xCollateRow ); xCollateRow->setLabel( &maCollateBox ); xCollateRow->setElement( &maCollateImage ); From 29572d6eebbd0a72cc7f244b613ed029e2b1ac54 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 1 Sep 2009 18:17:36 +0000 Subject: [PATCH 200/283] #i104668# fix IsLasPage handling --- vcl/source/gdi/print3.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index b56016a3cfbd..7a85091c052f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -762,6 +762,11 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte return aPageSize; } + // set last page property really only on the very last page to be rendered + // that is on the last subpage of a NUp run + sal_Bool bIsLastPage = mpImplData->mbLastPage; + mpImplData->mbLastPage = sal_False; + Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) ); // multi page area: paper size minus margins + one time spacing right and down // the added spacing is so each subpage can be calculated including its spacing @@ -789,7 +794,16 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte // map current sub page to real page int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; if( mpImplData->mbReversePageOrder ) + { nPage = nDocPages - 1 - nPage; + if( nPage == 0 ) + mpImplData->mbLastPage = bIsLastPage; + } + else + { + if( nPage == nDocPages-1 ) + mpImplData->mbLastPage = bIsLastPage; + } if( nPage >= 0 && nPage < nDocPages ) { GDIMetaFile aPageFile; From eb7e3a297515f8f603c8372b4276d6a14c09ef40 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 13:44:16 +0000 Subject: [PATCH 201/283] #i104763# inform app about need to reformat --- vcl/source/gdi/print3.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 7a85091c052f..88006a845936 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -585,6 +585,11 @@ bool PrinterController::setupPrinter( Window* i_pParent ) { mpImplData->maFixedPageSize = aNewPaperSize; mpImplData->maPageCache.invalidate(); + awt::Size aOverrideSize; + aOverrideSize.Width = aNewPaperSize.Width(); + aOverrideSize.Height = aNewPaperSize.Height(); + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OverridePageSize" ) ), + makeAny( aOverrideSize ) ); } } } From da62b0feb684b34ab191fb0f03ed5432c14cba97 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 15:20:56 +0000 Subject: [PATCH 202/283] #i104693# nearest paper matching --- vcl/inc/vcl/print.hxx | 3 +- vcl/source/gdi/print.cxx | 51 ++++++++++++++++++++++++++++++++-- vcl/source/gdi/print3.cxx | 8 ++++-- vcl/source/window/printdlg.cxx | 9 ++++++ 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 2f8a96c690d3..fe906988de2c 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -261,7 +261,7 @@ private: const XubString* pDriver ); SAL_DLLPRIVATE void ImplUpdatePageData(); SAL_DLLPRIVATE void ImplUpdateFontList(); - SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& ); + SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup&, bool bMatchNearest ); DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr& ); @@ -331,6 +331,7 @@ public: USHORT GetPaperBin() const; BOOL SetPaper( Paper ePaper ); BOOL SetPaperSizeUser( const Size& rSize ); + BOOL SetPaperSizeUser( const Size& rSize, bool bMatchNearest ); Paper GetPaper() const; // returns number of available paper formats diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index f7db0b56f4ca..c70835de47e7 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -974,12 +974,13 @@ USHORT Printer::GetPaperBin() const // ----------------------------------------------------------------------- // Map user paper format to a available printer paper formats -void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) +void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNearest ) { ImplJobSetup* pSetupData = aJobSetup.ImplGetData(); int nLandscapeAngle = GetLandscapeAngle(); int nPaperCount = GetPaperInfoCount(); + bool bFound = false; PaperInfo aInfo(pSetupData->mnPaperWidth, pSetupData->mnPaperHeight); @@ -993,6 +994,7 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.getWidth(), rPaperInfo.getHeight() ); pSetupData->meOrientation = ORIENTATION_PORTRAIT; + bFound = true; break; } } @@ -1016,10 +1018,48 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup ) pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.getWidth(), rPaperInfo.getHeight() ); pSetupData->meOrientation = ORIENTATION_LANDSCAPE; + bFound = true; break; } } } + + if( ! bFound && bMatchNearest ) + { + sal_Int64 nBestMatch = SAL_MAX_INT64; + int nBestIndex = 0; + Orientation eBestOrientation = ORIENTATION_PORTRAIT; + for( int i = 0; i < nPaperCount; i++ ) + { + const PaperInfo& rPaperInfo = GetPaperInfo( i ); + + // check protrait match + sal_Int64 nDX = pSetupData->mnPaperWidth - rPaperInfo.getWidth(); + sal_Int64 nDY = pSetupData->mnPaperHeight - rPaperInfo.getHeight(); + sal_Int64 nMatch = nDX*nDX + nDY*nDY; + if( nMatch < nBestMatch ) + { + nBestMatch = nMatch; + nBestIndex = i; + eBestOrientation = ORIENTATION_PORTRAIT; + } + + // check landscape match + nDX = pSetupData->mnPaperWidth - rPaperInfo.getHeight(); + nDY = pSetupData->mnPaperHeight - rPaperInfo.getWidth(); + nMatch = nDX*nDX + nDY*nDY; + if( nMatch < nBestMatch ) + { + nBestMatch = nMatch; + nBestIndex = i; + eBestOrientation = ORIENTATION_LANDSCAPE; + } + } + const PaperInfo& rBestInfo = GetPaperInfo( nBestIndex ); + pSetupData->mePaperFormat = ImplGetPaperFormat( rBestInfo.getWidth(), + rBestInfo.getHeight() ); + pSetupData->meOrientation = eBestOrientation; + } } // ----------------------------------------------------------------------- @@ -1050,7 +1090,7 @@ BOOL Printer::SetPaper( Paper ePaper ) ImplReleaseGraphics(); if ( ePaper == PAPER_USER ) - ImplFindPaperFormatForUserSize( aJobSetup ); + ImplFindPaperFormatForUserSize( aJobSetup, false ); if ( mpInfoPrinter->SetData( SAL_JOBSET_PAPERSIZE|SAL_JOBSET_ORIENTATION, pSetupData ) ) { ImplUpdateJobSetupPaper( aJobSetup ); @@ -1070,6 +1110,11 @@ BOOL Printer::SetPaper( Paper ePaper ) // ----------------------------------------------------------------------- BOOL Printer::SetPaperSizeUser( const Size& rSize ) +{ + return SetPaperSizeUser( rSize, false ); +} + +BOOL Printer::SetPaperSizeUser( const Size& rSize, bool bMatchNearest ) { if ( mbInPrintPage ) return FALSE; @@ -1094,7 +1139,7 @@ BOOL Printer::SetPaperSizeUser( const Size& rSize ) } ImplReleaseGraphics(); - ImplFindPaperFormatForUserSize( aJobSetup ); + ImplFindPaperFormatForUserSize( aJobSetup, bMatchNearest ); // Changing the paper size can also change the orientation! if ( mpInfoPrinter->SetData( SAL_JOBSET_PAPERSIZE|SAL_JOBSET_ORIENTATION, pSetupData ) ) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 88006a845936..f8bf4aa6df80 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -191,6 +191,8 @@ public: return maMultiPage.aPaperSize; return i_rPageSize; } + bool isFixedPageSize() const + { return maFixedPageSize.Width() != 0 && maFixedPageSize.Height() != 0; } PrinterController::PageSize modifyJobSetup( const Sequence< PropertyValue >& i_rProps ); }; @@ -612,7 +614,7 @@ PrinterController::PageSize vcl::ImplPrinterControllerData::modifyJobSetup( cons Size aCurSize( mpPrinter->GetPaperSize() ); Size aRealPaperSize( getRealPaperSize( aPageSize.aSize ) ); if( aRealPaperSize != aCurSize ) - mpPrinter->SetPaperSizeUser( aRealPaperSize ); + mpPrinter->SetPaperSizeUser( aRealPaperSize, ! isFixedPageSize() ); } if( i_rProps[ nProperty ].Name.equalsAscii( "PageIncludesNonprintableArea" ) ) { @@ -854,7 +856,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte o_rMtf.WindStart(); mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); - mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize ); + mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize, ! mpImplData->isFixedPageSize() ); return PrinterController::PageSize( aPaperSize ); } @@ -941,7 +943,7 @@ void PrinterController::printFilteredPage( int i_nPage ) // in N-Up printing set the correct page size mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); // aPageSize was filtered through mpImplData->getRealPaperSize already by getFilteredPageFile() - mpImplData->mpPrinter->SetPaperSizeUser( aPageSize.aSize ); + mpImplData->mpPrinter->SetPaperSizeUser( aPageSize.aSize, ! mpImplData->isFixedPageSize() ); // if full paper are is meant, move the output to accomodate for pageoffset if( aPageSize.bFullPaper ) { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 2d1bbf43e607..f98dcdf0da2d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -174,6 +174,15 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi sal_Int32 i_nDPIY ) { + #if OSL_DEBUG_LEVEL > 0 + rtl::OUStringBuffer aBuf( 256 ); + aBuf.appendAscii( "PageSize: " ); + aBuf.append( sal_Int32( i_rOrigSize.Width()/100) ); + aBuf.appendAscii( "mm x " ); + aBuf.append( sal_Int32( i_rOrigSize.Height()/100) ); + aBuf.appendAscii( "mm" ); + SetQuickHelpText( aBuf.makeStringAndClear() ); + #endif maMtf = i_rNewPreview; maOrigSize = i_rOrigSize; maReplacementString = i_rReplacement; From ea4051a25356bdb6ad9501cf1d17a6f726382fab Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 16:05:37 +0000 Subject: [PATCH 203/283] #i104664# resize on collpsing details --- vcl/inc/vcl/prndlg.hxx | 3 +++ vcl/source/window/printdlg.cxx | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 0f5288c9d6bd..3164de82fbeb 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -248,6 +248,9 @@ namespace vcl vcl::RowOrColumn maLayout; + Size maDetailsCollapsedSize; + Size maDetailsExpandedSize; + Size getJobPageSize(); void updateNup(); void updateNupFromPages(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index f98dcdf0da2d..99b36e2b942a 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1953,14 +1953,31 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton ) bool bShow = ! maJobPage.maStatusTxt.IsVisible(); maJobPage.maDetailsBtn.SetSymbol( bShow ? SYMBOL_SPIN_UP : SYMBOL_SPIN_DOWN ); maJobPage.mxDetails->show( bShow ); - // enlarge dialog if necessary - Size aMinSize( maJobPage.maLayout.getOptimalSize( WINDOWSIZE_MINIMUM ) ); - Size aCurSize( maJobPage.GetSizePixel() ); - if( aCurSize.Height() < aMinSize.Height() ) + if( bShow ) { + maDetailsCollapsedSize = GetOutputSizePixel(); + // enlarge dialog if necessary + Size aMinSize( maJobPage.maLayout.getOptimalSize( WINDOWSIZE_MINIMUM ) ); + Size aCurSize( maJobPage.GetSizePixel() ); + if( aCurSize.Height() < aMinSize.Height() ) + { + Size aDlgSize( GetOutputSizePixel() ); + aDlgSize.Height() += aMinSize.Height() - aCurSize.Height(); + SetOutputSizePixel( aDlgSize ); + } + maDetailsExpandedSize = GetOutputSizePixel(); + } + else if( maDetailsCollapsedSize.Width() > 0 && + maDetailsCollapsedSize.Height() > 0 ) + { + // if the user did not resize the dialog + // make it smaller again on collapsing the details Size aDlgSize( GetOutputSizePixel() ); - aDlgSize.Height() += aMinSize.Height() - aCurSize.Height(); - SetOutputSizePixel( aDlgSize ); + if( aDlgSize == maDetailsExpandedSize && + aDlgSize.Height() > maDetailsCollapsedSize.Height() ) + { + SetOutputSizePixel( maDetailsCollapsedSize ); + } } } else if( pButton == &maJobPage.maCollateBox ) From 38287624c6dbe3d622a4e73e69db78a6412a6abd Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 16:36:29 +0000 Subject: [PATCH 204/283] #i104662# reverse page order affects sheets now instead of doc pages --- vcl/source/gdi/print3.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index f8bf4aa6df80..2d8cb6f96f19 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -741,6 +741,13 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte if( nSubPages < 1 ) nSubPages = 1; + // reverse sheet order + if( mpImplData->mbReversePageOrder ) + { + int nDocPages = getFilteredPageCount(); + i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; + } + // there is no filtering to be done (and possibly the page size of the // original page is to be set), when N-Up is "neutral" that is there is // only one subpage and the margins are 0 @@ -748,11 +755,6 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte rMPS.nLeftMargin == 0 && rMPS.nRightMargin == 0 && rMPS.nTopMargin == 0 && rMPS.nBottomMargin == 0 ) { - if( mpImplData->mbReversePageOrder ) - { - int nDocPages = getPageCountProtected(); - i_nFilteredPage = nDocPages - 1 - i_nFilteredPage; - } PrinterController::PageSize aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize ); if( aPaperSize != aPageSize.aSize ) @@ -802,9 +804,11 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; if( mpImplData->mbReversePageOrder ) { - nPage = nDocPages - 1 - nPage; - if( nPage == 0 ) + if( nSubPage == nSubPages-1 || + nPage == nDocPages-1 ) + { mpImplData->mbLastPage = bIsLastPage; + } } else { From 27786389d04a4cbf24afc0abe9ed583cdd09d52f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 16:53:57 +0000 Subject: [PATCH 205/283] catch wrong page number in sfx --- vcl/aqua/source/gdi/salprn.cxx | 15 ++++++--------- vcl/source/gdi/print3.cxx | 3 +-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 079629216df6..3bf229d1927f 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -651,17 +651,14 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, mnCurPageRangeCount = 1; } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages ); - // inform applictation that it can release its data + // inform application that it can release its data // this is awkward, but the XRenderable interface has no method for this, // so we need to call XRenderadble::render one last time with IsLastPage = TRUE - if( nAllPages > 0 ) - { - i_rController.setLastPage( sal_True ); - GDIMetaFile aPageFile; - if( mrContext ) - SetupPrinterGraphics( mrContext ); - i_rController.getFilteredPageFile( 0, aPageFile ); - } + i_rController.setLastPage( sal_True ); + GDIMetaFile aPageFile; + if( mrContext ) + SetupPrinterGraphics( mrContext ); + i_rController.getFilteredPageFile( 0, aPageFile ); i_rController.setJobState( bWasAborted ? view::PrintableState_JOB_ABORTED diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 2d8cb6f96f19..56da675f0030 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -365,8 +365,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr { GDIMetaFile aPageFile; i_pController->setLastPage( sal_True ); - if( i_pController->getPageCountProtected() > 0 ) - i_pController->getFilteredPageFile( 0, aPageFile ); + i_pController->getFilteredPageFile( 0, aPageFile ); return; } if( aDlg.isPrintToFile() ) From 468bcdbd0b5fc182580dc30467f2d38df1c9b09f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 17:04:07 +0000 Subject: [PATCH 206/283] merge strings from string review --- vcl/source/src/print.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 8df7d33e2fed..f53d055c4dbe 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -110,7 +110,7 @@ ModalDialog SV_DLG_PRINT String SV_PRINT_TOFILE_TXT { - Text [en-US] = "Print to file..."; + Text [en-US] = "Print to File..."; }; String SV_PRINT_DEFPRT_TXT @@ -326,7 +326,7 @@ ModalDialog SV_DLG_PRINT { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 10, 10 ); - Text [en-US] = "Printer details"; + Text [en-US] = "Details"; }; FixedText SV_PRINT_STATUS_TXT { From 3100b1dbb85dd3a5f1d41be0d03214592ad4fb7f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 19:48:08 +0000 Subject: [PATCH 207/283] themed disclosure button --- vcl/inc/vcl/button.hxx | 13 +++++- vcl/inc/vcl/prndlg.hxx | 3 +- vcl/inc/vcl/svdata.hxx | 5 +++ vcl/inc/vcl/svids.hrc | 6 ++- vcl/source/app/svmain.cxx | 20 ++++++++++ vcl/source/control/button.cxx | 73 ++++++++++++++++++++++++++++++++++ vcl/source/src/images.src | 20 ++++++++++ vcl/source/src/print.src | 9 +---- vcl/source/window/printdlg.cxx | 15 ++----- 9 files changed, 141 insertions(+), 23 deletions(-) diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index 94df24a9cea7..05f21192e4c8 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -416,7 +416,6 @@ private: SAL_DLLPRIVATE void ImplInitCheckBoxData(); SAL_DLLPRIVATE WinBits ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ); SAL_DLLPRIVATE void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground ); - SAL_DLLPRIVATE void ImplDrawCheckBoxState(); SAL_DLLPRIVATE void ImplInvalidateOrDrawCheckBoxState(); SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, ULONG nDrawFlags, const Point& rPos, const Size& rSize, @@ -436,10 +435,11 @@ protected: SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); SAL_DLLPRIVATE virtual void FillLayoutData() const; + SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState(); + SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; } public: SAL_DLLPRIVATE void ImplCheck(); SAL_DLLPRIVATE void ImplSetMinimumNWFSize(); - public: CheckBox( Window* pParent, WinBits nStyle = 0 ); CheckBox( Window* pParent, const ResId& rResId ); @@ -538,4 +538,13 @@ public: ~TriStateBox(); }; +class VCL_DLLPUBLIC DisclosureButton : public CheckBox +{ +protected: + SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState(); +public: + DisclosureButton( Window* pParent, WinBits nStyle = 0 ); + DisclosureButton( Window* pParent, const ResId& rResId ); +}; + #endif // _SV_BUTTON_HXX diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 3164de82fbeb..e905c0ecfe37 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -146,8 +146,7 @@ namespace vcl public: FixedLine maPrinterFL; ListBox maPrinters; - PushButton maDetailsBtn; - FixedText maDetailsTxt; + DisclosureButton maDetailsBtn; FixedText maStatusLabel; FixedText maStatusTxt; FixedText maLocationLabel; diff --git a/vcl/inc/vcl/svdata.hxx b/vcl/inc/vcl/svdata.hxx index bde902c3fbcd..de2ae32a71b2 100644 --- a/vcl/inc/vcl/svdata.hxx +++ b/vcl/inc/vcl/svdata.hxx @@ -86,6 +86,7 @@ class Timer; class AutoTimer; class Help; class ImageList; +class Image; class PopupMenu; class Application; class OutputDevice; @@ -247,6 +248,10 @@ struct ImplSVCtrlData ImageList* mpSplitVPinImgList; // ImageList for Vertikale SplitWindows (PIN's) ImageList* mpSplitHArwImgList; // ImageList for Horizontale SplitWindows (Arrows) ImageList* mpSplitVArwImgList; // ImageList for Vertikale SplitWindows (Arrows) + Image* mpDisclosurePlus; + Image* mpDisclosurePlusHC; + Image* mpDisclosureMinus; + Image* mpDisclosureMinusHC; ImplTBDragMgr* mpTBDragMgr; // DragMgr for ToolBox USHORT mnCheckStyle; // CheckBox-Style for ImageList-Update USHORT mnRadioStyle; // Radio-Style for ImageList-Update diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 1959a2df3152..c54dfb70c3ed 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -60,6 +60,11 @@ #define SV_RESID_BITMAP_CLOSEDOC 1052 #define SV_RESID_BITMAP_CLOSEDOCHC 1053 +#define SV_DISCLOSURE_PLUS 1060 +#define SV_DISCLOSURE_MINUS 1061 +#define SV_DISCLOSURE_PLUS_HC 1062 +#define SV_DISCLOSURE_MINUS_HC 1063 + #define SV_RESID_MENU_EDIT 2000 #define SV_MENU_EDIT_UNDO 1 #define SV_MENU_EDIT_CUT 2 @@ -146,7 +151,6 @@ #define SV_PRINT_LOCATION_TXT 21 #define SV_PRINT_COMMENT_TXT 22 #define SV_PRINT_DETAILS_BTN 23 -#define SV_PRINT_DETAILS_TXT 24 #define SV_PRINT_TAB_OPT 3 #define SV_PRINT_OPT_PRINT_FL 1 diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index 6c09978e37b1..b08198fb3acd 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -444,6 +444,26 @@ void DeInitVCL() delete pSVData->maCtrlData.mpSplitVArwImgList; pSVData->maCtrlData.mpSplitVArwImgList = NULL; } + if ( pSVData->maCtrlData.mpDisclosurePlus ) + { + delete pSVData->maCtrlData.mpDisclosurePlus; + pSVData->maCtrlData.mpDisclosurePlus = NULL; + } + if ( pSVData->maCtrlData.mpDisclosurePlusHC ) + { + delete pSVData->maCtrlData.mpDisclosurePlusHC; + pSVData->maCtrlData.mpDisclosurePlusHC = NULL; + } + if ( pSVData->maCtrlData.mpDisclosureMinus ) + { + delete pSVData->maCtrlData.mpDisclosureMinus; + pSVData->maCtrlData.mpDisclosureMinus = NULL; + } + if ( pSVData->maCtrlData.mpDisclosureMinusHC ) + { + delete pSVData->maCtrlData.mpDisclosureMinusHC; + pSVData->maCtrlData.mpDisclosureMinusHC = NULL; + } if ( pSVData->mpDefaultWin ) { delete pSVData->mpDefaultWin; diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 852e7983ac06..605c84a11820 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -4389,3 +4389,76 @@ TriStateBox::TriStateBox( Window* pParent, const ResId& rResId ) : TriStateBox::~TriStateBox() { } + +// ======================================================================= + +DisclosureButton::DisclosureButton( Window* pParent, WinBits nStyle ) : + CheckBox( pParent, WB_NOBORDER ) +{ +} + +// ----------------------------------------------------------------------- + +DisclosureButton::DisclosureButton( Window* pParent, const ResId& rResId ) : + CheckBox( pParent, rResId.SetRT( RSC_CHECKBOX ) ) +{ +} + +// ----------------------------------------------------------------------- + +void DisclosureButton::ImplDrawCheckBoxState() +{ + /* HACK: DisclosureButton is currently assuming, that the disclosure sign + will fit into the rectangle occupied by a normal checkbox on all themes. + If this does not hold true for some theme, ImplGetCheckImageSize + would have to be overloaded for DisclosureButton; also GetNativeControlRegion + for CTRL_LISTNODE would have to be implemented and taken into account + */ + + Rectangle aStateRect( GetStateRect() ); + + ImplControlValue aControlValue( GetState() == STATE_CHECK ? BUTTONVALUE_ON : BUTTONVALUE_OFF, rtl::OUString(), 0 ); + Region aCtrlRegion( aStateRect ); + ControlState nState = 0; + + if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED; + if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT; + if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED; + if ( IsMouseOver() && aStateRect.IsInside( GetPointerPosPixel() ) ) + nState |= CTRL_STATE_ROLLOVER; + + if( ! DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL, aCtrlRegion, nState, + aControlValue, rtl::OUString() ) ) + { + ImplSVCtrlData& rCtrlData( ImplGetSVData()->maCtrlData ); + if( ! rCtrlData.mpDisclosurePlus ) + rCtrlData.mpDisclosurePlus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_PLUS ) ) ); + if( ! rCtrlData.mpDisclosurePlusHC ) + rCtrlData.mpDisclosurePlusHC = new Image( BitmapEx( VclResId( SV_DISCLOSURE_PLUS_HC ) ) ); + if( ! rCtrlData.mpDisclosureMinus ) + rCtrlData.mpDisclosureMinus = new Image( BitmapEx( VclResId( SV_DISCLOSURE_MINUS ) ) ); + if( ! rCtrlData.mpDisclosureMinusHC ) + rCtrlData.mpDisclosureMinusHC = new Image( BitmapEx( VclResId( SV_DISCLOSURE_MINUS_HC ) ) ); + + Image* pImg = NULL; + if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + pImg = IsChecked() ? rCtrlData.mpDisclosureMinusHC : rCtrlData.mpDisclosurePlusHC; + else + pImg = IsChecked() ? rCtrlData.mpDisclosureMinus : rCtrlData.mpDisclosurePlus; + + DBG_ASSERT( pImg, "no disclosure image" ); + if( ! pImg ) + return; + + USHORT nStyle = 0; + if( ! IsEnabled() ) + nStyle |= IMAGE_DRAW_DISABLE; + + Size aSize( aStateRect.GetSize() ); + Size aImgSize( pImg->GetSizePixel() ); + Point aOff( (aSize.Width() - aImgSize.Width())/2, + (aSize.Height() - aImgSize.Height())/2 ); + aOff += aStateRect.TopLeft(); + DrawImage( aOff, *pImg, nStyle ); + } +} diff --git a/vcl/source/src/images.src b/vcl/source/src/images.src index a2b057c8d234..5a0e7b412a58 100644 --- a/vcl/source/src/images.src +++ b/vcl/source/src/images.src @@ -833,3 +833,23 @@ Bitmap (SV_ICON_SMALL_HC_START + SV_ICON_ID_PRINTERADMIN) File = "printeradmin_16_h.png" ; }; +Bitmap SV_DISCLOSURE_PLUS +{ + File = "plus.png"; +}; + +Bitmap SV_DISCLOSURE_PLUS_HC +{ + File = "plus_sch.png"; +}; + +Bitmap SV_DISCLOSURE_MINUS +{ + File = "minus.png"; +}; + +Bitmap SV_DISCLOSURE_MINUS_HC +{ + File = "minus_sch.png"; +}; + diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index f53d055c4dbe..24c49bd6c80a 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -316,17 +316,12 @@ ModalDialog SV_DLG_PRINT Border = TRUE; HelpText [en-US] = "Select the printer to print on."; }; - PushButton SV_PRINT_DETAILS_BTN + CheckBox SV_PRINT_DETAILS_BTN { Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 5, 5 ); - HelpText [en-US] = "Show/Hide detailed information of the selected printer."; - }; - FixedText SV_PRINT_DETAILS_TXT - { - Pos = MAP_APPFONT( 5, 5 ); - Size = MAP_APPFONT( 10, 10 ); Text [en-US] = "Details"; + HelpText [en-US] = "Show/Hide detailed information of the selected printer."; }; FixedText SV_PRINT_STATUS_TXT { diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 99b36e2b942a..708ee35a5755 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -454,7 +454,6 @@ PrintDialog::JobTabPage::JobTabPage( Window* i_pParent, const ResId& rResId ) , maPrinterFL( this, VclResId( SV_PRINT_PRINTERS_FL ) ) , maPrinters( this, VclResId( SV_PRINT_PRINTERS ) ) , maDetailsBtn( this, VclResId( SV_PRINT_DETAILS_BTN ) ) - , maDetailsTxt( this, VclResId( SV_PRINT_DETAILS_TXT ) ) , maStatusLabel( this, VclResId( SV_PRINT_STATUS_TXT ) ) , maStatusTxt( this, 0 ) , maLocationLabel( this, VclResId( SV_PRINT_LOCATION_TXT ) ) @@ -526,10 +525,7 @@ void PrintDialog::JobTabPage::setupLayout() // create a row for details button/text and properties button boost::shared_ptr< vcl::RowOrColumn > xDetRow( new vcl::RowOrColumn( &maLayout, false ) ); maLayout.addChild( xDetRow ); - boost::shared_ptr< vcl::LabeledElement > xDetLbl( new vcl::LabeledElement( xDetRow.get() ) ); - xDetRow->addChild( xDetLbl ); - xDetLbl->setLabel( &maDetailsBtn ); - xDetLbl->setElement( &maDetailsTxt ); + xDetRow->addWindow( &maDetailsBtn ); xDetRow->addChild( new vcl::Spacer( xDetRow.get(), 2 ) ); xDetRow->addWindow( &maSetupButton ); @@ -568,9 +564,7 @@ void PrintDialog::JobTabPage::setupLayout() xCollateRow->setLabel( &maCollateBox ); xCollateRow->setElement( &maCollateImage ); - maDetailsBtn.SetSymbol( SYMBOL_SPIN_DOWN ); - maDetailsBtn.SetSmallSymbol(); - maDetailsBtn.SetStyle( maDetailsBtn.GetStyle() | (WB_SMALLSTYLE | WB_BEVELBUTTON) ); + // maDetailsBtn.SetStyle( maDetailsBtn.GetStyle() | (WB_SMALLSTYLE | WB_BEVELBUTTON) ); mxDetails->show( false, false ); } @@ -796,7 +790,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptrshow( bShow ); if( bShow ) { From a2224ea9eb1e05f1317f6ea3529f1653d00bd2b9 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 8 Sep 2009 20:01:56 +0000 Subject: [PATCH 208/283] fix warning --- vcl/source/control/button.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 605c84a11820..23235e14f448 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -4392,7 +4392,7 @@ TriStateBox::~TriStateBox() // ======================================================================= -DisclosureButton::DisclosureButton( Window* pParent, WinBits nStyle ) : +DisclosureButton::DisclosureButton( Window* pParent, WinBits ) : CheckBox( pParent, WB_NOBORDER ) { } From 25f26445ab686fbbb064e620ebee39950a7fdc43 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 10 Sep 2009 14:34:56 +0000 Subject: [PATCH 209/283] #i104932# take page offset into account in N-Up printing --- vcl/source/gdi/print3.cxx | 6 ++++-- vcl/source/window/printdlg.cxx | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 56da675f0030..c08abea15c7f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -776,7 +776,8 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte mpImplData->mbLastPage = sal_False; Size aPaperSize( mpImplData->getRealPaperSize( mpImplData->maMultiPage.aPaperSize ) ); - // multi page area: paper size minus margins + one time spacing right and down + + // multi page area: page size minus margins + one time spacing right and down // the added spacing is so each subpage can be calculated including its spacing Size aMPArea( aPaperSize ); aMPArea.Width() -= rMPS.nLeftMargin + rMPS.nRightMargin; @@ -858,10 +859,11 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte } o_rMtf.WindStart(); + // subsequent getPageFile calls have changed the paper, reset it to current value mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize, ! mpImplData->isFixedPageSize() ); - return PrinterController::PageSize( aPaperSize ); + return PrinterController::PageSize( aPaperSize, true ); } int PrinterController::getFilteredPageCount() diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 708ee35a5755..c6ac00eba9e5 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1678,10 +1678,18 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) { const MapMode aMapMode( MAP_100TH_MM ); GDIMetaFile aMtf; - if( nPages > 0 ) - maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); - boost::shared_ptr aPrt( maPController->getPrinter() ); + if( nPages > 0 ) + { + PrinterController::PageSize aPageSize = + maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache ); + if( ! aPageSize.bFullPaper ) + { + Point aOff( aPrt->PixelToLogic( aPrt->GetPageOffsetPixel(), aMapMode ) ); + aMtf.Move( aOff.X(), aOff.Y() ); + } + } + Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr, aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY() From 3aeb0fc95cf16c28c75095cfe5e720afb786e781 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Sat, 12 Sep 2009 11:22:22 +0000 Subject: [PATCH 210/283] solve problems with transparency and N-Up --- vcl/inc/vcl/outdev.hxx | 2 ++ vcl/inc/vcl/print.hxx | 2 ++ vcl/source/gdi/print2.cxx | 13 +++++++--- vcl/source/gdi/print3.cxx | 50 ++++++++++++++++++++++----------------- 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index f4e42846dd5e..6791afc5cff9 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -1136,6 +1136,8 @@ public: false: output metafile is unchanged input metafile @attention this is a member method, so current state can influence the result ! + @attention the output metafile is prepared in pixel mode for the currentOutputDevice + state. It can not be moved or rotated reliably anymore. */ bool RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf, long nMaxBmpDPIX, long nMaxBmpDPIY, diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index fe906988de2c..563a603f1917 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -518,6 +518,8 @@ public: SAL_DLLPRIVATE int getPageCountProtected() const; SAL_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getPageParametersProtected( int i_nPage ) const; + + SAL_DLLPRIVATE ULONG removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut ); }; class VCL_DLLPUBLIC PrinterOptionsHelper diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 21c6b59f53a4..4e2e78efe9e2 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -1108,7 +1108,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // ==================================================== // - Point aTmpPoint; + Point aPageOffset; Size aTmpSize( GetOutputSizePixel() ); if( mpPDFWriter ) { @@ -1118,7 +1118,14 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // also add error code to PDFWriter mpPDFWriter->insertError( vcl::PDFWriter::Warning_Transparency_Converted ); } - const Rectangle aOutputRect( aTmpPoint, aTmpSize ); + else if( meOutDevType == OUTDEV_PRINTER ) + { + Printer* pThis = dynamic_cast(this); + aPageOffset = pThis->GetPageOffsetPixel(); + aPageOffset = Point( 0, 0 ) - aPageOffset; + aTmpSize = pThis->GetPaperSizePixel(); + } + const Rectangle aOutputRect( aPageOffset, aTmpSize ); bool bTiling = dynamic_cast(this) != NULL; // iterate over all aCCList members and generate bitmaps for the special ones @@ -1226,7 +1233,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, pCurrAct->Execute( &aPaintVDev ); } - if( !( nActionNum % 4 ) ) + if( !( nActionNum % 8 ) ) Application::Reschedule(); } diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index c08abea15c7f..23b2f04272a4 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -874,24 +874,8 @@ int PrinterController::getFilteredPageCount() return (getPageCountProtected() * mpImplData->maMultiPage.nRepeat + (nDiv-1)) / nDiv; } -void PrinterController::printFilteredPage( int i_nPage ) +ULONG PrinterController::removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut ) { - if( mpImplData->meJobState != view::PrintableState_JOB_STARTED ) - return; - - GDIMetaFile aPageFile; - PrinterController::PageSize aPageSize = getFilteredPageFile( i_nPage, aPageFile ); - - if( mpImplData->mpProgress ) - { - // do nothing if printing is canceled - if( mpImplData->mpProgress->isCanceled() ) - { - setJobState( view::PrintableState_JOB_ABORTED ); - return; - } - } - ULONG nRestoreDrawMode = mpImplData->mpPrinter->GetDrawMode(); sal_Int32 nMaxBmpDPIX = mpImplData->mpPrinter->ImplGetDPIX(); sal_Int32 nMaxBmpDPIY = mpImplData->mpPrinter->ImplGetDPIY(); @@ -936,14 +920,31 @@ void PrinterController::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetDrawMode( mpImplData->mpPrinter->GetDrawMode() | DRAWMODE_NOTRANSPARENCY ); } - GDIMetaFile aCleanedFile; - mpImplData->mpPrinter->RemoveTransparenciesFromMetaFile( aPageFile, aCleanedFile, nMaxBmpDPIX, nMaxBmpDPIY, + mpImplData->mpPrinter->RemoveTransparenciesFromMetaFile( i_rIn, o_rOut, nMaxBmpDPIX, nMaxBmpDPIY, rPrinterOptions.IsReduceTransparency(), rPrinterOptions.GetReducedTransparencyMode() == PRINTER_TRANSPARENCY_AUTO, rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency() ); + return nRestoreDrawMode; +} - mpImplData->mpPrinter->EnableOutput( TRUE ); +void PrinterController::printFilteredPage( int i_nPage ) +{ + if( mpImplData->meJobState != view::PrintableState_JOB_STARTED ) + return; + + GDIMetaFile aPageFile; + PrinterController::PageSize aPageSize = getFilteredPageFile( i_nPage, aPageFile ); + + if( mpImplData->mpProgress ) + { + // do nothing if printing is canceled + if( mpImplData->mpProgress->isCanceled() ) + { + setJobState( view::PrintableState_JOB_ABORTED ); + return; + } + } // in N-Up printing set the correct page size mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); @@ -953,10 +954,15 @@ void PrinterController::printFilteredPage( int i_nPage ) if( aPageSize.bFullPaper ) { Point aPageOffset( mpImplData->mpPrinter->GetPageOffset() ); - aCleanedFile.WindStart(); - aCleanedFile.Move( -aPageOffset.X(), -aPageOffset.Y() ); + aPageFile.WindStart(); + aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y() ); } + GDIMetaFile aCleanedFile; + ULONG nRestoreDrawMode = removeTransparencies( aPageFile, aCleanedFile ); + + mpImplData->mpPrinter->EnableOutput( TRUE ); + // actually print the page mpImplData->mpPrinter->ImplStartPage(); From 8a793295f4eb6530ac55654353de1ac1a33dd170 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 14 Sep 2009 16:02:43 +0000 Subject: [PATCH 211/283] #i104933# enhance RemoveTransparenciesFromMetafile for N-Up printing --- vcl/inc/vcl/outdev.hxx | 3 ++- vcl/source/gdi/print2.cxx | 20 ++++++++++++++++++-- vcl/source/gdi/print3.cxx | 12 +++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index 6791afc5cff9..2d4b52c5ee7e 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -1143,7 +1143,8 @@ public: long nMaxBmpDPIX, long nMaxBmpDPIY, bool bReduceTransparency, bool bTransparencyAutoMode, - bool bDownsampleBitmaps + bool bDownsampleBitmaps, + const Color& rBackground = Color( COL_TRANSPARENT ) ); /** Retrieve downsampled and cropped bitmap diff --git a/vcl/source/gdi/print2.cxx b/vcl/source/gdi/print2.cxx index 4e2e78efe9e2..9d435af5f4b1 100644 --- a/vcl/source/gdi/print2.cxx +++ b/vcl/source/gdi/print2.cxx @@ -646,7 +646,9 @@ static bool ImplIsActionHandlingTransparency( const MetaAction& rAct ) bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf, long nMaxBmpDPIX, long nMaxBmpDPIY, bool bReduceTransparency, bool bTransparencyAutoMode, - bool bDownsampleBitmaps ) + bool bDownsampleBitmaps, + const Color& rBackground + ) { MetaAction* pCurrAct; bool bTransparent( false ); @@ -735,6 +737,20 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, bool bStillBackground=true; // true until first non-bg action nActionNum=0; nLastBgAction=-1; pCurrAct=const_cast(rInMtf).FirstAction(); + if( rBackground != Color( COL_TRANSPARENT ) ) + { + aBackgroundComponent.aBgColor = rBackground; + if( meOutDevType == OUTDEV_PRINTER ) + { + Printer* pThis = dynamic_cast(this); + Point aPageOffset = pThis->GetPageOffsetPixel(); + aPageOffset = Point( 0, 0 ) - aPageOffset; + Size aSize = pThis->GetPaperSizePixel(); + aBackgroundComponent.aBounds = Rectangle( aPageOffset, aSize ); + } + else + aBackgroundComponent.aBounds = Rectangle( Point( 0, 0 ), GetOutputSizePixel() ); + } while( pCurrAct && bStillBackground ) { switch( pCurrAct->GetType() ) @@ -878,7 +894,7 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, // // if aBBCurrAct is empty, it will intersect with no - // aCCList member. Thus, we can safe us the check. + // aCCList member. Thus, we can save the check. // Furthermore, this ensures that non-output-generating // actions get their own aCCList entry, which is necessary // when copying them to the output metafile (see stage 4 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 23b2f04272a4..5aab3fe87acf 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -920,10 +920,19 @@ ULONG PrinterController::removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& mpImplData->mpPrinter->SetDrawMode( mpImplData->mpPrinter->GetDrawMode() | DRAWMODE_NOTRANSPARENCY ); } + Color aBg( COL_TRANSPARENT ); // default: let RemoveTransparenciesFromMetaFile do its own background logic + if( mpImplData->maMultiPage.nRows * mpImplData->maMultiPage.nColumns > 1 ) + { + // in N-Up printing we have no "page" background operation + // we also have no way to determine the paper color + // so let's go for white, which will kill 99.9% of the real cases + aBg = Color( COL_WHITE ); + } mpImplData->mpPrinter->RemoveTransparenciesFromMetaFile( i_rIn, o_rOut, nMaxBmpDPIX, nMaxBmpDPIY, rPrinterOptions.IsReduceTransparency(), rPrinterOptions.GetReducedTransparencyMode() == PRINTER_TRANSPARENCY_AUTO, - rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency() + rPrinterOptions.IsReduceBitmaps() && rPrinterOptions.IsReducedBitmapIncludesTransparency(), + aBg ); return nRestoreDrawMode; } @@ -950,6 +959,7 @@ void PrinterController::printFilteredPage( int i_nPage ) mpImplData->mpPrinter->SetMapMode( MAP_100TH_MM ); // aPageSize was filtered through mpImplData->getRealPaperSize already by getFilteredPageFile() mpImplData->mpPrinter->SetPaperSizeUser( aPageSize.aSize, ! mpImplData->isFixedPageSize() ); + // if full paper are is meant, move the output to accomodate for pageoffset if( aPageSize.bFullPaper ) { From 2589f7adbf0066980b8da68355c2d48369465764 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 14 Sep 2009 17:23:44 +0000 Subject: [PATCH 212/283] #i104662# fix IsLastPage handling --- vcl/source/gdi/print3.cxx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 5aab3fe87acf..98f6530d5b49 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -802,18 +802,10 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte { // map current sub page to real page int nPage = (i_nFilteredPage * nSubPages + nSubPage) / rMPS.nRepeat; - if( mpImplData->mbReversePageOrder ) + if( nSubPage == nSubPages-1 || + nPage == nDocPages-1 ) { - if( nSubPage == nSubPages-1 || - nPage == nDocPages-1 ) - { - mpImplData->mbLastPage = bIsLastPage; - } - } - else - { - if( nPage == nDocPages-1 ) - mpImplData->mbLastPage = bIsLastPage; + mpImplData->mbLastPage = bIsLastPage; } if( nPage >= 0 && nPage < nDocPages ) { From 7857f07d09265f58b2c17c4f619f4aad81b1c43d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 22 Sep 2009 18:14:05 +0200 Subject: [PATCH 213/283] #i97509# continued matrix tooling and adapting the usages now to all the ooo code --- basegfx/inc/basegfx/matrix/b2dhommatrix.hxx | 10 + .../inc/basegfx/matrix/b2dhommatrixtools.hxx | 205 +++++++++-- basegfx/source/matrix/b2dhommatrix.cxx | 174 ++-------- basegfx/source/matrix/b2dhommatrixtools.cxx | 324 ++++++++++++++++++ basegfx/source/polygon/b2dlinegeometry.cxx | 9 +- basegfx/source/polygon/b2dpolygonclipper.cxx | 7 +- basegfx/source/polygon/b2dpolygontools.cxx | 54 +-- basegfx/source/polygon/b2dsvgpolypolygon.cxx | 6 +- basegfx/source/tools/gradienttools.cxx | 17 +- basegfx/source/tools/unopolypolygon.cxx | 6 +- canvas/source/directx/dx_canvashelper.cxx | 13 +- .../directx/dx_canvashelper_texturefill.cxx | 4 +- .../source/simplecanvas/simplecanvasimpl.cxx | 11 +- canvas/source/tools/canvastools.cxx | 11 +- canvas/source/tools/surface.cxx | 11 +- cppcanvas/source/mtfrenderer/bitmapaction.cxx | 19 +- cppcanvas/source/mtfrenderer/implrenderer.cxx | 27 +- cppcanvas/source/mtfrenderer/mtftools.cxx | 11 +- cppcanvas/source/mtfrenderer/textaction.cxx | 5 +- vcl/aqua/source/gdi/salgdi.cxx | 4 +- vcl/os2/source/gdi/salgdi3.cxx | 6 +- vcl/source/gdi/region.cxx | 9 +- vcl/source/gdi/sallayout.cxx | 7 +- vcl/source/glyphs/gcach_ftyp.cxx | 4 +- vcl/unx/source/gdi/salgdi.cxx | 8 +- vcl/win/source/gdi/salgdi3.cxx | 6 +- 26 files changed, 614 insertions(+), 354 deletions(-) diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx index c7c79d0cd6e9..10b023c5f68c 100644 --- a/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx +++ b/basegfx/inc/basegfx/matrix/b2dhommatrix.hxx @@ -52,12 +52,22 @@ namespace basegfx B2DHomMatrix(const B2DHomMatrix& rMat); ~B2DHomMatrix(); + /** constructor to allow setting all needed values for a 3x2 matrix at once. The + parameter f_0x1 e.g. is the same as using set(0, 1, f) + */ + B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2); + /// unshare this matrix with all internally shared instances void makeUnique(); double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); + /** allow setting all needed values for a 3x2 matrix in one call. The + parameter f_0x1 e.g. is the same as using set(0, 1, f) + */ + void set3x2(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2); + // test if last line is default to see if last line needs to be // involved in calculations bool isLastLineDefault() const; diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx index 0b200b812bed..c90f673a8194 100644 --- a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx +++ b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx @@ -40,45 +40,190 @@ namespace basegfx { - class DecomposedB2DHomMatrixContainer + namespace tools { - private: - B2DHomMatrix maB2DHomMatrix; - B2DVector maScale; - B2DVector maTranslate; - double mfRotate; - double mfShearX; + /** If the rotation angle is an approximate multiple of pi/2, + force fSin/fCos to -1/0/1, to maintain orthogonality (which + might also be advantageous for the other cases, but: for + multiples of pi/2, the exact values _can_ be attained. It + would be largely unintuitive, if a 180 degrees rotation + would introduce slight roundoff errors, instead of exactly + mirroring the coordinate system) + */ + void createSinCosOrthogonal(double& o_rSin, double& rCos, double fRadiant); - // bitfield - unsigned mbDecomposed : 1; + /** Tooling methods for on-the-fly matrix generation e.g. for inline + multiplications + */ + B2DHomMatrix createScaleB2DHomMatrix(double fScaleX, double fScaleY); + B2DHomMatrix createShearXB2DHomMatrix(double fShearX); + B2DHomMatrix createShearYB2DHomMatrix(double fShearY); + B2DHomMatrix createRotateB2DHomMatrix(double fRadiant); + B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY); - void impCheckDecompose() + /// inline versions for parameters as tuples + inline B2DHomMatrix createScaleB2DHomMatrix(const B2DTuple& rScale) { - if(!mbDecomposed) + return createScaleB2DHomMatrix(rScale.getX(), rScale.getY()); + } + + inline B2DHomMatrix createTranslateB2DHomMatrix(const B2DTuple& rTranslate) + { + return createTranslateB2DHomMatrix(rTranslate.getX(), rTranslate.getY()); + } + + /** Tooling methods for faster completely combined matrix creation + when scale, shearX, rotation and translation needs to be done in + exactly that order. It's faster since it direcly calculates + each matrix value based on a symbolic calculation of the three + matrix multiplications. + Inline versions for parameters as tuples added, too. + */ + B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix( + double fScaleX, double fScaleY, + double fShearX, + double fRadiant, + double fTranslateX, double fTranslateY); + inline B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix( + const B2DTuple& rScale, + double fShearX, + double fRadiant, + const B2DTuple& rTranslate) + { + return createScaleShearXRotateTranslateB2DHomMatrix( + rScale.getX(), rScale.getY(), + fShearX, + fRadiant, + rTranslate.getX(), rTranslate.getY()); + } + + B2DHomMatrix createShearXRotateTranslateB2DHomMatrix( + double fShearX, + double fRadiant, + double fTranslateX, double fTranslateY); + inline B2DHomMatrix createShearXRotateTranslateB2DHomMatrix( + double fShearX, + double fRadiant, + const B2DTuple& rTranslate) + { + return createShearXRotateTranslateB2DHomMatrix( + fShearX, + fRadiant, + rTranslate.getX(), rTranslate.getY()); + } + + B2DHomMatrix createScaleTranslateB2DHomMatrix( + double fScaleX, double fScaleY, + double fTranslateX, double fTranslateY); + inline B2DHomMatrix createScaleTranslateB2DHomMatrix( + const B2DTuple& rScale, + const B2DTuple& rTranslate) + { + return createScaleTranslateB2DHomMatrix( + rScale.getX(), rScale.getY(), + rTranslate.getX(), rTranslate.getY()); + } + + /// special for the often used case of rotation around a point + B2DHomMatrix createRotateAroundPoint( + double fPointX, double fPointY, + double fRadiant); + inline B2DHomMatrix createRotateAroundPoint( + const B2DTuple& rPoint, + double fRadiant) + { + return createRotateAroundPoint( + rPoint.getX(), rPoint.getY(), + fRadiant); + } + } // end of namespace tools +} // end of namespace basegfx + +/////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace tools + { + class B2DHomMatrixBufferedDecompose + { + private: + B2DVector maScale; + B2DVector maTranslate; + double mfRotate; + double mfShearX; + + public: + B2DHomMatrixBufferedDecompose(const B2DHomMatrix& rB2DHomMatrix) + : maScale(), + maTranslate(), + mfRotate(0.0), + mfShearX(0.0) { - maB2DHomMatrix.decompose(maScale, maTranslate, mfRotate, mfShearX); - mbDecomposed = true; + rB2DHomMatrix.decompose(maScale, maTranslate, mfRotate, mfShearX); } - } - public: - DecomposedB2DHomMatrixContainer(const B2DHomMatrix& rB2DHomMatrix) - : maB2DHomMatrix(rB2DHomMatrix), - maScale(), - maTranslate(), - mfRotate(0.0), - mfShearX(0.0), - mbDecomposed(false) + // data access + B2DHomMatrix getB2DHomMatrix() const + { + return createScaleShearXRotateTranslateB2DHomMatrix( + maScale, mfShearX, mfRotate, maTranslate); + } + + const B2DVector& getScale() const { return maScale; } + const B2DVector& getTranslate() const { return maTranslate; } + double getRotate() const { return mfRotate; } + double getShearX() const { return mfShearX; } + }; + } // end of namespace tools +} // end of namespace basegfx + +/////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + namespace tools + { + class B2DHomMatrixBufferedOnDemandDecompose { - } + private: + B2DHomMatrix maB2DHomMatrix; + B2DVector maScale; + B2DVector maTranslate; + double mfRotate; + double mfShearX; - // data access - const B2DHomMatrix& getB2DHomMatrix() const { return maB2DHomMatrix; } - const B2DVector& getScale() const { const_cast< DecomposedB2DHomMatrixContainer* >(this)->impCheckDecompose(); return maScale; } - const B2DVector& getTranslate() const { const_cast< DecomposedB2DHomMatrixContainer* >(this)->impCheckDecompose(); return maTranslate; } - double getRotate() const { const_cast< DecomposedB2DHomMatrixContainer* >(this)->impCheckDecompose(); return mfRotate; } - double getShearX() const { const_cast< DecomposedB2DHomMatrixContainer* >(this)->impCheckDecompose(); return mfShearX; } - }; + // bitfield + unsigned mbDecomposed : 1; + + void impCheckDecompose() + { + if(!mbDecomposed) + { + maB2DHomMatrix.decompose(maScale, maTranslate, mfRotate, mfShearX); + mbDecomposed = true; + } + } + + public: + B2DHomMatrixBufferedOnDemandDecompose(const B2DHomMatrix& rB2DHomMatrix) + : maB2DHomMatrix(rB2DHomMatrix), + maScale(), + maTranslate(), + mfRotate(0.0), + mfShearX(0.0), + mbDecomposed(false) + { + } + + // data access + const B2DHomMatrix& getB2DHomMatrix() const { return maB2DHomMatrix; } + const B2DVector& getScale() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return maScale; } + const B2DVector& getTranslate() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return maTranslate; } + double getRotate() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return mfRotate; } + double getShearX() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return mfShearX; } + }; + } // end of namespace tools } // end of namespace basegfx /////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 352113fa8ed3..a7777352effb 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -36,6 +36,9 @@ #include #include #include +#include + +/////////////////////////////////////////////////////////////////////////////// namespace basegfx { @@ -60,6 +63,17 @@ namespace basegfx { } + B2DHomMatrix::B2DHomMatrix(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) + : mpImpl( IdentityMatrix::get() ) // use common identity matrix, will be made unique with 1st set-call + { + mpImpl->set(0, 0, f_0x0); + mpImpl->set(0, 1, f_0x1); + mpImpl->set(0, 2, f_0x2); + mpImpl->set(1, 0, f_1x0); + mpImpl->set(1, 1, f_1x1); + mpImpl->set(1, 2, f_1x2); + } + B2DHomMatrix& B2DHomMatrix::operator=(const B2DHomMatrix& rMat) { mpImpl = rMat.mpImpl; @@ -81,6 +95,16 @@ namespace basegfx mpImpl->set(nRow, nColumn, fValue); } + void B2DHomMatrix::set3x2(double f_0x0, double f_0x1, double f_0x2, double f_1x0, double f_1x1, double f_1x2) + { + mpImpl->set(0, 0, f_0x0); + mpImpl->set(0, 1, f_0x1); + mpImpl->set(0, 2, f_0x2); + mpImpl->set(1, 0, f_1x0); + mpImpl->set(1, 1, f_1x1); + mpImpl->set(1, 2, f_1x2); + } + bool B2DHomMatrix::isLastLineDefault() const { return mpImpl->isLastLineDefault(); @@ -206,56 +230,9 @@ namespace basegfx if(!fTools::equalZero(fRadiant)) { double fSin(0.0); - double fCos(0.0); - - // is the rotation angle an approximate multiple of pi/2? - // If yes, force fSin/fCos to -1/0/1, to maintain - // orthogonality (which might also be advantageous for the - // other cases, but: for multiples of pi/2, the exact - // values _can_ be attained. It would be largely - // unintuitive, if a 180 degrees rotation would introduce - // slight roundoff errors, instead of exactly mirroring - // the coordinate system). - if( fTools::equalZero( fmod( fRadiant, F_PI2 ) ) ) - { - // determine quadrant - const sal_Int32 nQuad( - (4 + fround( 4/F_2PI*fmod( fRadiant, F_2PI ) )) % 4 ); - switch( nQuad ) - { - case 0: // -2pi,0,2pi - fSin = 0.0; - fCos = 1.0; - break; - - case 1: // -3/2pi,1/2pi - fSin = 1.0; - fCos = 0.0; - break; - - case 2: // -pi,pi - fSin = 0.0; - fCos = -1.0; - break; - - case 3: // -1/2pi,3/2pi - fSin = -1.0; - fCos = 0.0; - break; - - default: - OSL_ENSURE( false, - "B2DHomMatrix::rotate(): Impossible case reached" ); - } - } - else - { - // TODO(P1): Maybe use glibc's sincos here (though - // that's kinda non-portable...) - fSin = sin(fRadiant); - fCos = cos(fRadiant); - } + double fCos(1.0); + tools::createSinCosOrthogonal(fSin, fCos, fRadiant); Impl2DHomMatrix aRotMat; aRotMat.set(0, 0, fCos); @@ -474,104 +451,7 @@ namespace basegfx return true; } - -/* Old version: Used 3D decompose when shaer was involved and also a determinant test - (but only in that case). Keeping as comment since it also worked and to allow a - fallback in case the new version makes trouble somehow. Definitely missing in the 2nd - case is the sign correction for Y-Scale, this would need to be added following the above - pattern - - bool B2DHomMatrix::decompose(B2DTuple& rScale, B2DTuple& rTranslate, double& rRotate, double& rShearX) const - { - // when perspective is used, decompose is not made here - if(!mpImpl->isLastLineDefault()) - return false; - - // test for rotation and shear - if(fTools::equalZero(get(0, 1)) - && fTools::equalZero(get(1, 0))) - { - // no rotation and shear, direct value extraction - rRotate = rShearX = 0.0; - - // copy scale values - rScale.setX(get(0, 0)); - rScale.setY(get(1, 1)); - - // copy translation values - rTranslate.setX(get(0, 2)); - rTranslate.setY(get(1, 2)); - - return true; - } - else - { - // test if shear is zero. That's the case, if the unit vectors in the matrix - // are perpendicular -> scalar is zero - const ::basegfx::B2DVector aUnitVecX(get(0, 0), get(1, 0)); - const ::basegfx::B2DVector aUnitVecY(get(0, 1), get(1, 1)); - - if(fTools::equalZero(aUnitVecX.scalar(aUnitVecY))) - { - // no shear, direct value extraction - rShearX = 0.0; - - // calculate rotation - rShearX = 0.0; - rRotate = atan2(aUnitVecX.getY(), aUnitVecX.getX()); - - // calculate scale values - rScale.setX(aUnitVecX.getLength()); - rScale.setY(aUnitVecY.getLength()); - - // copy translation values - rTranslate.setX(get(0, 2)); - rTranslate.setY(get(1, 2)); - - return true; - } - else - { - // If determinant is zero, decomposition is not possible - if(0.0 == determinant()) - return false; - - // copy 2x2 matrix and translate vector to 3x3 matrix - ::basegfx::B3DHomMatrix a3DHomMat; - - a3DHomMat.set(0, 0, get(0, 0)); - a3DHomMat.set(0, 1, get(0, 1)); - a3DHomMat.set(1, 0, get(1, 0)); - a3DHomMat.set(1, 1, get(1, 1)); - a3DHomMat.set(0, 3, get(0, 2)); - a3DHomMat.set(1, 3, get(1, 2)); - - ::basegfx::B3DTuple r3DScale, r3DTranslate, r3DRotate, r3DShear; - - if(a3DHomMat.decompose(r3DScale, r3DTranslate, r3DRotate, r3DShear)) - { - // copy scale values - rScale.setX(r3DScale.getX()); - rScale.setY(r3DScale.getY()); - - // copy shear - rShearX = r3DShear.getX(); - - // copy rotate - rRotate = r3DRotate.getZ(); - - // copy translate - rTranslate.setX(r3DTranslate.getX()); - rTranslate.setY(r3DTranslate.getY()); - - return true; - } - } - } - - return false; - } */ - } // end of namespace basegfx +/////////////////////////////////////////////////////////////////////////////// // eof diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx index 59a1ff432fc7..c9c3180d3e4a 100644 --- a/basegfx/source/matrix/b2dhommatrixtools.cxx +++ b/basegfx/source/matrix/b2dhommatrixtools.cxx @@ -38,6 +38,330 @@ namespace basegfx { + namespace tools + { + void createSinCosOrthogonal(double& o_rSin, double& o_rCos, double fRadiant) + { + if( fTools::equalZero( fmod( fRadiant, F_PI2 ) ) ) + { + // determine quadrant + const sal_Int32 nQuad( + (4 + fround( 4/F_2PI*fmod( fRadiant, F_2PI ) )) % 4 ); + switch( nQuad ) + { + case 0: // -2pi,0,2pi + o_rSin = 0.0; + o_rCos = 1.0; + break; + + case 1: // -3/2pi,1/2pi + o_rSin = 1.0; + o_rCos = 0.0; + break; + + case 2: // -pi,pi + o_rSin = 0.0; + o_rCos = -1.0; + break; + + case 3: // -1/2pi,3/2pi + o_rSin = -1.0; + o_rCos = 0.0; + break; + + default: + OSL_ENSURE( false, "createSinCos: Impossible case reached" ); + } + } + else + { + // TODO(P1): Maybe use glibc's sincos here (though + // that's kinda non-portable...) + o_rSin = sin(fRadiant); + o_rCos = cos(fRadiant); + } + } + + B2DHomMatrix createScaleB2DHomMatrix(double fScaleX, double fScaleY) + { + B2DHomMatrix aRetval; + const double fOne(1.0); + + if(!fTools::equal(fScaleX, fOne)) + { + aRetval.set(0, 0, fScaleX); + } + + if(!fTools::equal(fScaleY, fOne)) + { + aRetval.set(1, 1, fScaleY); + } + + return aRetval; + } + + B2DHomMatrix createShearXB2DHomMatrix(double fShearX) + { + B2DHomMatrix aRetval; + + if(!fTools::equalZero(fShearX)) + { + aRetval.set(0, 1, fShearX); + } + + return aRetval; + } + + B2DHomMatrix createShearYB2DHomMatrix(double fShearY) + { + B2DHomMatrix aRetval; + + if(!fTools::equalZero(fShearY)) + { + aRetval.set(1, 0, fShearY); + } + + return aRetval; + } + + B2DHomMatrix createRotateB2DHomMatrix(double fRadiant) + { + B2DHomMatrix aRetval; + + if(!fTools::equalZero(fRadiant)) + { + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + aRetval.set(0, 0, fCos); + aRetval.set(1, 1, fCos); + aRetval.set(1, 0, fSin); + aRetval.set(0, 1, -fSin); + } + + return aRetval; + } + + B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY) + { + B2DHomMatrix aRetval; + + if(!(fTools::equalZero(fTranslateX) && fTools::equalZero(fTranslateY))) + { + aRetval.set(0, 2, fTranslateX); + aRetval.set(1, 2, fTranslateY); + } + + return aRetval; + } + + B2DHomMatrix createScaleShearXRotateTranslateB2DHomMatrix( + double fScaleX, double fScaleY, + double fShearX, + double fRadiant, + double fTranslateX, double fTranslateY) + { + const double fOne(1.0); + + if(fTools::equal(fScaleX, fOne) && fTools::equal(fScaleY, fOne)) + { + /// no scale, take shortcut + return createShearXRotateTranslateB2DHomMatrix(fShearX, fRadiant, fTranslateX, fTranslateY); + } + else + { + /// scale used + if(fTools::equalZero(fShearX)) + { + /// no shear + if(fTools::equalZero(fRadiant)) + { + /// no rotate, take shortcut + return createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, fTranslateX, fTranslateY); + } + else + { + /// rotate and scale used, no shear + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fCos * fScaleX, + /* Row 0, Column 1 */ fScaleY * -fSin, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ fSin * fScaleX, + /* Row 1, Column 1 */ fScaleY * fCos, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + } + else + { + /// scale and shear used + if(fTools::equalZero(fRadiant)) + { + /// scale and shear, but no rotate + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fScaleX, + /* Row 0, Column 1 */ fScaleY * fShearX, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ 0.0, + /* Row 1, Column 1 */ fScaleY, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + else + { + /// scale, shear and rotate used + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fCos * fScaleX, + /* Row 0, Column 1 */ fScaleY * ((fCos * fShearX) - fSin), + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ fSin * fScaleX, + /* Row 1, Column 1 */ fScaleY * ((fSin * fShearX) + fCos), + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + } + } + } + + B2DHomMatrix createShearXRotateTranslateB2DHomMatrix( + double fShearX, + double fRadiant, + double fTranslateX, double fTranslateY) + { + if(fTools::equalZero(fShearX)) + { + /// no shear + if(fTools::equalZero(fRadiant)) + { + /// no shear, no rotate, take shortcut + return createTranslateB2DHomMatrix(fTranslateX, fTranslateY); + } + else + { + /// no shear, but rotate used + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fCos, + /* Row 0, Column 1 */ -fSin, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ fSin, + /* Row 1, Column 1 */ fCos, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + } + else + { + /// shear used + if(fTools::equalZero(fRadiant)) + { + /// no rotate, but shear used + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ 1.0, + /* Row 0, Column 1 */ fShearX, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ 0.0, + /* Row 1, Column 1 */ 1.0, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + else + { + /// shear and rotate used + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fCos, + /* Row 0, Column 1 */ (fCos * fShearX) - fSin, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ fSin, + /* Row 1, Column 1 */ (fSin * fShearX) + fCos, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + } + } + + B2DHomMatrix createScaleTranslateB2DHomMatrix( + double fScaleX, double fScaleY, + double fTranslateX, double fTranslateY) + { + const double fOne(1.0); + + if(fTools::equal(fScaleX, fOne) && fTools::equal(fScaleY, fOne)) + { + /// no scale, take shortcut + return createTranslateB2DHomMatrix(fTranslateX, fTranslateY); + } + else + { + /// scale used + if(fTools::equalZero(fTranslateX) && fTools::equalZero(fTranslateY)) + { + /// no translate, but scale. + B2DHomMatrix aRetval; + + aRetval.set(0, 0, fScaleX); + aRetval.set(1, 1, fScaleY); + + return aRetval; + } + else + { + /// translate and scale + B2DHomMatrix aRetval( + /* Row 0, Column 0 */ fScaleX, + /* Row 0, Column 1 */ 0.0, + /* Row 0, Column 2 */ fTranslateX, + /* Row 1, Column 0 */ 0.0, + /* Row 1, Column 1 */ fScaleY, + /* Row 1, Column 2 */ fTranslateY); + + return aRetval; + } + } + } + + B2DHomMatrix createRotateAroundPoint( + double fPointX, double fPointY, + double fRadiant) + { + B2DHomMatrix aRetval; + + if(!fTools::equalZero(fRadiant)) + { + aRetval = createTranslateB2DHomMatrix(-fPointX, -fPointY); + aRetval.rotate(fRadiant); + aRetval.translate(fPointX, fPointY); + } + + return aRetval; + } + } // end of namespace tools } // end of namespace basegfx /////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx index 1a9264ab769e..c22b5ea94011 100644 --- a/basegfx/source/polygon/b2dlinegeometry.cxx +++ b/basegfx/source/polygon/b2dlinegeometry.cxx @@ -40,6 +40,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// @@ -85,11 +86,9 @@ namespace basegfx // get size of the arrow const B2DRange aArrowSize(getRange(rArrow)); - // build ArrowTransform - B2DHomMatrix aArrowTransform; - - // center in X, align with axis in Y - aArrowTransform.translate(-aArrowSize.getCenter().getX(), -aArrowSize.getMinimum().getY()); + // build ArrowTransform; center in X, align with axis in Y + B2DHomMatrix aArrowTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aArrowSize.getCenter().getX(), -aArrowSize.getMinimum().getY())); // scale to target size const double fArrowScale(fWidth / (aArrowSize.getRange().getX())); diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx index f0d325942c07..87e44ed3d063 100644 --- a/basegfx/source/polygon/b2dpolygonclipper.cxx +++ b/basegfx/source/polygon/b2dpolygonclipper.cxx @@ -40,6 +40,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// @@ -361,11 +362,10 @@ namespace basegfx else if(rCandidate.count()) { const B2DVector aEdge(rPointB - rPointA); - B2DHomMatrix aMatrixTransform; B2DPolygon aCandidate(rCandidate); // translate and rotate polygon so that given edge is on x axis - aMatrixTransform.translate(-rPointA.getX(), -rPointA.getY()); + B2DHomMatrix aMatrixTransform(basegfx::tools::createTranslateB2DHomMatrix(-rPointA.getX(), -rPointA.getY())); aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); aCandidate.transform(aMatrixTransform); @@ -395,11 +395,10 @@ namespace basegfx else if(rCandidate.count()) { const B2DVector aEdge(rPointB - rPointA); - B2DHomMatrix aMatrixTransform; B2DPolyPolygon aCandidate(rCandidate); // translate and rotate polygon so that given edge is on x axis - aMatrixTransform.translate(-rPointA.getX(), -rPointA.getY()); + B2DHomMatrix aMatrixTransform(basegfx::tools::createTranslateB2DHomMatrix(-rPointA.getX(), -rPointA.getY())); aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); aCandidate.transform(aMatrixTransform); diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index c1e5dc80d8c4..6e288786df6d 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -34,7 +34,6 @@ #include #include #include - #include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include #include #include @@ -1887,29 +1887,10 @@ namespace basegfx B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ) { - const double fOne(1.0); B2DPolygon aRetval(createPolygonFromUnitCircle()); + const B2DHomMatrix aMatrix(createScaleTranslateB2DHomMatrix(fRadiusX, fRadiusY, rCenter.getX(), rCenter.getY())); - // transformation necessary? - const sal_Bool bScale(!fTools::equal(fRadiusX, fOne) || !fTools::equal(fRadiusY, fOne)); - const sal_Bool bTranslate(!rCenter.equalZero()); - - if(bScale || bTranslate) - { - B2DHomMatrix aMatrix; - - if(bScale) - { - aMatrix.scale(fRadiusX, fRadiusY); - } - - if(bTranslate) - { - aMatrix.translate(rCenter.getX(), rCenter.getY()); - } - - aRetval.transform(aMatrix); - } + aRetval.transform(aMatrix); return aRetval; } @@ -2050,28 +2031,9 @@ namespace basegfx B2DPolygon createPolygonFromEllipseSegment( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, double fStart, double fEnd ) { B2DPolygon aRetval(createPolygonFromUnitEllipseSegment(fStart, fEnd)); + const B2DHomMatrix aMatrix(createScaleTranslateB2DHomMatrix(fRadiusX, fRadiusY, rCenter.getX(), rCenter.getY())); - // transformation necessary? - const double fOne(1.0); - const sal_Bool bScale(!fTools::equal(fRadiusX, fOne) || !fTools::equal(fRadiusY, fOne)); - const sal_Bool bTranslate(!rCenter.equalZero()); - - if(bScale || bTranslate) - { - B2DHomMatrix aMatrix; - - if(bScale) - { - aMatrix.scale(fRadiusX, fRadiusY); - } - - if(bTranslate) - { - aMatrix.translate(rCenter.getX(), rCenter.getY()); - } - - aRetval.transform(aMatrix); - } + aRetval.transform(aMatrix); return aRetval; } @@ -2701,11 +2663,7 @@ namespace basegfx if(nPointCount) { - B2DHomMatrix aMatrix; - - aMatrix.translate(-rCenter.getX(), -rCenter.getY()); - aMatrix.rotate(fAngle); - aMatrix.translate(rCenter.getX(), rCenter.getY()); + const B2DHomMatrix aMatrix(basegfx::tools::createRotateAroundPoint(rCenter, fAngle)); aRetval.transform(aMatrix); } diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx index 2247c237d90f..e38ec3809fb1 100644 --- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx +++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -705,7 +706,7 @@ namespace basegfx // |y1'| = |-sin phi cos phi| |(y1 - y2)/2| const B2DPoint p1(nLastX, nLastY); const B2DPoint p2(nX, nY); - B2DHomMatrix aTransform; aTransform.rotate(-fPhi*M_PI/180); + B2DHomMatrix aTransform(basegfx::tools::createRotateB2DHomMatrix(-fPhi*M_PI/180)); const B2DPoint p1_prime( aTransform * B2DPoint(((p1-p2)/2.0)) ); @@ -797,8 +798,7 @@ namespace basegfx fTheta1, fTheta2 )); // transform ellipse by rotation & move to final center - aTransform.identity(); - aTransform.scale(fRX,fRY); + aTransform = basegfx::tools::createScaleB2DHomMatrix(fRX, fRY); aTransform.translate(aCenter_prime.getX(), aCenter_prime.getY()); aTransform.rotate(fPhi*M_PI/180); diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx index 9e78039cd590..51989899ebf4 100644 --- a/basegfx/source/tools/gradienttools.cxx +++ b/basegfx/source/tools/gradienttools.cxx @@ -32,9 +32,9 @@ #include "precompiled_basegfx.hxx" #include - #include #include +#include namespace basegfx { @@ -79,9 +79,8 @@ namespace basegfx B2DPoint aCenter(0.5, 0.5); aCenter *= o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maTextureTransform.translate(-aCenter.getX(), -aCenter.getY()); - o_rGradientInfo.maTextureTransform.rotate(fAngle); - o_rGradientInfo.maTextureTransform.translate(aCenter.getX(), aCenter.getY()); + o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) + * o_rGradientInfo.maTextureTransform; } // add object translate @@ -158,9 +157,8 @@ namespace basegfx B2DPoint aCenter(0.5, 0.5); aCenter *= o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maTextureTransform.translate(-aCenter.getX(), -aCenter.getY()); - o_rGradientInfo.maTextureTransform.rotate(fAngle); - o_rGradientInfo.maTextureTransform.translate(aCenter.getX(), aCenter.getY()); + o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) + * o_rGradientInfo.maTextureTransform; } } @@ -232,9 +230,8 @@ namespace basegfx B2DPoint aCenter(0.5, 0.5); aCenter *= o_rGradientInfo.maTextureTransform; - o_rGradientInfo.maTextureTransform.translate(-aCenter.getX(), -aCenter.getY()); - o_rGradientInfo.maTextureTransform.rotate(fAngle); - o_rGradientInfo.maTextureTransform.translate(aCenter.getX(), aCenter.getY()); + o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) + * o_rGradientInfo.maTextureTransform; } // add defined offsets after rotation diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 6d8fcd83edb0..05dbe5b1c823 100755 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -44,8 +44,8 @@ #include #include #include - #include +#include using namespace ::com::sun::star; @@ -138,9 +138,7 @@ namespace unotools if( !aOffset.equalZero() ) { - B2DHomMatrix aTranslate; - aTranslate.translate( aOffset.getX(), aOffset.getY() ); - + const B2DHomMatrix aTranslate(tools::createTranslateB2DHomMatrix(aOffset)); aSrcPoly.transform( aTranslate ); } diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx index 0642b6c50efb..dcb65c94ae3c 100755 --- a/canvas/source/directx/dx_canvashelper.cxx +++ b/canvas/source/directx/dx_canvashelper.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -733,10 +734,8 @@ namespace dxcanvas // add output offset if( !maOutputOffset.equalZero() ) { - ::basegfx::B2DHomMatrix aOutputOffset; - aOutputOffset.translate( maOutputOffset.getX(), - maOutputOffset.getY() ); - + const basegfx::B2DHomMatrix aOutputOffset(basegfx::tools::createTranslateB2DHomMatrix( + maOutputOffset.getX(), maOutputOffset.getY())); aTransform = aOutputOffset * aTransform; } @@ -774,10 +773,8 @@ namespace dxcanvas // add output offset if( !maOutputOffset.equalZero() ) { - ::basegfx::B2DHomMatrix aOutputOffset; - aOutputOffset.translate( maOutputOffset.getX(), - maOutputOffset.getY() ); - + const basegfx::B2DHomMatrix aOutputOffset(basegfx::tools::createTranslateB2DHomMatrix( + maOutputOffset.getX(), maOutputOffset.getY())); aTransform = aOutputOffset * aTransform; } diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx index f291d197c4de..73a2d49bfb62 100755 --- a/canvas/source/directx/dx_canvashelper_texturefill.cxx +++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -452,8 +453,7 @@ namespace dxcanvas aFillBrush.SetColor( aFillColor ); const double nCurrScale( (nStepCount-i)/(double)nStepCount ); - aScaleMatrix.identity(); - aScaleMatrix.translate( -0.5, -0.5 ); + aScaleMatrix = basegfx::tools::createTranslateB2DHomMatrix(-0.5, -0.5); // handle anisotrophic polygon scaling if( rValues.mnAspectRatio < 1.0 ) diff --git a/canvas/source/simplecanvas/simplecanvasimpl.cxx b/canvas/source/simplecanvas/simplecanvasimpl.cxx index 185979b0220e..7ca251458d22 100644 --- a/canvas/source/simplecanvas/simplecanvasimpl.cxx +++ b/canvas/source/simplecanvas/simplecanvasimpl.cxx @@ -46,6 +46,7 @@ #include #include +#include #include "canvas/canvastools.hxx" @@ -287,10 +288,7 @@ namespace ::sal_Int8 nTextDirection ) throw (uno::RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - - basegfx::B2DHomMatrix offsetTransform; - offsetTransform.translate(aOutPos.X,aOutPos.Y); - + const basegfx::B2DHomMatrix offsetTransform(basegfx::tools::createTranslateB2DHomMatrix(aOutPos.X,aOutPos.Y)); rendering::RenderState aRenderState( createStrokingRenderState() ); tools::appendToRenderState(aRenderState, offsetTransform); @@ -305,10 +303,7 @@ namespace const geometry::RealPoint2D& aLeftTop ) throw (uno::RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); - - basegfx::B2DHomMatrix offsetTransform; - offsetTransform.translate(aLeftTop.X,aLeftTop.Y); - + const basegfx::B2DHomMatrix offsetTransform(basegfx::tools::createTranslateB2DHomMatrix(aLeftTop.X,aLeftTop.Y)); rendering::RenderState aRenderState( createStrokingRenderState() ); tools::appendToRenderState(aRenderState, offsetTransform); diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx index 23d6124e4cb8..278789637c72 100644 --- a/canvas/source/tools/canvastools.cxx +++ b/canvas/source/tools/canvastools.cxx @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -679,9 +680,8 @@ namespace canvas i_transformation ); // now move resulting left,top point of bounds to (0,0) - ::basegfx::B2DHomMatrix aCorrectedTransform; - aCorrectedTransform.translate( -aTransformedRect.getMinX(), - -aTransformedRect.getMinY() ); + const basegfx::B2DHomMatrix aCorrectedTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aTransformedRect.getMinX(), -aTransformedRect.getMinY())); // prepend to original transformation o_transform = aCorrectedTransform * i_transformation; @@ -745,9 +745,8 @@ namespace canvas transformation ); // now move resulting left,top point of bounds to (0,0) - ::basegfx::B2DHomMatrix aCorrectedTransform; - aCorrectedTransform.translate( -aTransformedRect.getMinX(), - -aTransformedRect.getMinY() ); + basegfx::B2DHomMatrix aCorrectedTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aTransformedRect.getMinX(), -aTransformedRect.getMinY())); // scale to match outRect const double xDenom( aTransformedRect.getWidth() ); diff --git a/canvas/source/tools/surface.cxx b/canvas/source/tools/surface.cxx index c3161758ea3e..96162f6d78af 100644 --- a/canvas/source/tools/surface.cxx +++ b/canvas/source/tools/surface.cxx @@ -33,6 +33,7 @@ #include "surface.hxx" #include +#include #include #include @@ -150,9 +151,8 @@ namespace canvas // 4) scale to normalized device coordinates // 5) flip y-axis // 6) translate to account for viewport transform - ::basegfx::B2DHomMatrix aTransform; - aTransform.translate(maSourceOffset.getX(), - maSourceOffset.getY()); + basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix( + maSourceOffset.getX(), maSourceOffset.getY())); aTransform = aTransform * rTransform; aTransform.translate(::basegfx::fround(rPos.getX()), ::basegfx::fround(rPos.getY())); @@ -277,8 +277,7 @@ namespace canvas // 1) offset of surface subarea // 2) surface transform // 3) translation to output position [rPos] - ::basegfx::B2DHomMatrix aTransform; - aTransform.translate(aPos1.getX(),aPos1.getY()); + basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(aPos1.getX(), aPos1.getY())); aTransform = aTransform * rTransform; aTransform.translate(::basegfx::fround(rPos.getX()), ::basegfx::fround(rPos.getY())); @@ -380,7 +379,7 @@ namespace canvas // be transformed by the overall transform and uv coordinates will // be calculated from the result, and this is why we need to use // integer coordinates here... - ::basegfx::B2DHomMatrix aTransform; + basegfx::B2DHomMatrix aTransform; aTransform = aTransform * rTransform; aTransform.translate(::basegfx::fround(rPos.getX()), ::basegfx::fround(rPos.getY())); diff --git a/cppcanvas/source/mtfrenderer/bitmapaction.cxx b/cppcanvas/source/mtfrenderer/bitmapaction.cxx index 355dd336e2c5..4f54b10c4879 100644 --- a/cppcanvas/source/mtfrenderer/bitmapaction.cxx +++ b/cppcanvas/source/mtfrenderer/bitmapaction.cxx @@ -35,25 +35,21 @@ #include #include #include - #include #include #include - #include - #include #include #include #include #include - #include - #include "cachedprimitivebase.hxx" #include "bitmapaction.hxx" #include "outdevstate.hxx" #include "mtftools.hxx" +#include using namespace ::com::sun::star; @@ -112,9 +108,7 @@ namespace cppcanvas // Setup transformation such that the next render call is // moved rPoint away. - ::basegfx::B2DHomMatrix aLocalTransformation; - aLocalTransformation.translate( rDstPoint.getX(), - rDstPoint.getY() ); + const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createTranslateB2DHomMatrix(rDstPoint)); ::canvas::tools::appendToRenderState( maState, aLocalTransformation ); @@ -144,15 +138,12 @@ namespace cppcanvas // moved rPoint away, and scaled according to the ratio // given by src and dst size. const ::Size aBmpSize( rBmpEx.GetSizePixel() ); - ::basegfx::B2DHomMatrix aLocalTransformation; const ::basegfx::B2DVector aScale( rDstSize.getX() / aBmpSize.Width(), rDstSize.getY() / aBmpSize.Height() ); - aLocalTransformation.scale( aScale.getX(), aScale.getY() ); - aLocalTransformation.translate( rDstPoint.getX(), - rDstPoint.getY() ); - ::canvas::tools::appendToRenderState( maState, - aLocalTransformation ); + const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createScaleTranslateB2DHomMatrix( + aScale, rDstPoint)); + ::canvas::tools::appendToRenderState( maState, aLocalTransformation ); // correct clip (which is relative to original transform) tools::modifyClip( maState, diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index c6f9a295b332..9af540b889ea 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -34,19 +34,14 @@ #include #include #include - #include #include #include - #include - #include #include #include - #include - #include #include #include @@ -59,7 +54,6 @@ #include #include #include - #include #include #include @@ -73,7 +67,6 @@ #include #include #include - #include #include #include @@ -84,11 +77,9 @@ #include #include #include - #include #include #include - #include #include #include @@ -96,15 +87,13 @@ #include #include #include - #include #include #include - #include - #include "mtftools.hxx" #include "outdevstate.hxx" +#include using namespace ::com::sun::star; @@ -729,12 +718,11 @@ namespace cppcanvas fabs( aBounds.getHeight()*sin(nRotation) ) + fabs( aBounds.getWidth()*cos(nRotation) ))); - aTextureTransformation.scale( nScale, nScale ); - - // translate back origin to center of + // scale and translate back origin to center of // primitive - aTextureTransformation.translate( 0.5*aBounds.getWidth(), - 0.5*aBounds.getHeight() ); + aTextureTransformation = basegfx::tools::createScaleTranslateB2DHomMatrix( + nScale, nScale, 0.5*aBounds.getWidth(), 0.5*aBounds.getHeight()) + * aTextureTransformation; } break; @@ -856,9 +844,8 @@ namespace cppcanvas aTextureTransformation.scale( nScaleX, nScaleY ); // rotate texture according to gradient rotation - aTextureTransformation.translate( -0.5*nScaleX, -0.5*nScaleY ); - aTextureTransformation.rotate( nRotation ); - aTextureTransformation.translate( 0.5*nScaleX, 0.5*nScaleY ); + aTextureTransformation = basegfx::tools::createRotateAroundPoint(0.5*nScaleX, 0.5*nScaleY, nRotation) + * aTextureTransformation; aTextureTransformation.translate( nOffsetX, nOffsetY ); } diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx index e4e227955da6..b6a548aa49be 100644 --- a/cppcanvas/source/mtfrenderer/mtftools.cxx +++ b/cppcanvas/source/mtfrenderer/mtftools.cxx @@ -34,10 +34,8 @@ #include #include #include - #include #include - #include #include #include @@ -45,16 +43,15 @@ #include #include #include - #include #include #include #include #include - #include "mtftools.hxx" #include "outdevstate.hxx" #include "polypolyaction.hxx" +#include @@ -111,9 +108,9 @@ namespace cppcanvas const ::Size aSizePixel( rVDev.LogicToPixel( aSizeLogic ) ); - o_rMatrix.identity(); - o_rMatrix.scale( aSizePixel.Width() / (double)aSizeLogic.Width(), - aSizePixel.Height() / (double)aSizeLogic.Height() ); + o_rMatrix = basegfx::tools::createScaleB2DHomMatrix( + aSizePixel.Width() / (double)aSizeLogic.Width(), + aSizePixel.Height() / (double)aSizeLogic.Height() ); return o_rMatrix; } diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx index f1191e6e57f3..038b68c3008e 100644 --- a/cppcanvas/source/mtfrenderer/textaction.cxx +++ b/cppcanvas/source/mtfrenderer/textaction.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -93,9 +94,7 @@ namespace cppcanvas NULL, &rState.fontRotation ); - ::basegfx::B2DHomMatrix aLocalTransformation; - - aLocalTransformation.rotate( rState.fontRotation ); + basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createRotateB2DHomMatrix(rState.fontRotation)); aLocalTransformation.translate( rStartPoint.getX(), rStartPoint.getY() ); ::canvas::tools::appendToRenderState( o_rRenderState, diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index e0905fe1d377..8d57d56a3667 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -1753,9 +1753,7 @@ BOOL AquaSalGraphics::GetGlyphOutline( long nGlyphId, basegfx::B2DPolyPolygon& r GgoClosePathProc( &aGgoData ); if( mfFontScale != 1.0 ) { - basegfx::B2DHomMatrix aScale; - aScale.scale( +mfFontScale, +mfFontScale ); - rPolyPoly.transform( aScale ); + rPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(+mfFontScale, +mfFontScale)); } return true; } diff --git a/vcl/os2/source/gdi/salgdi3.cxx b/vcl/os2/source/gdi/salgdi3.cxx index 573fa7336fb0..b25feee266e4 100644 --- a/vcl/os2/source/gdi/salgdi3.cxx +++ b/vcl/os2/source/gdi/salgdi3.cxx @@ -1361,10 +1361,8 @@ BOOL Os2SalGraphics::GetGlyphOutline( long nIndex, ::basegfx::B2DPolyPolygon& rB // rescaling needed for the PolyPolygon conversion if( rB2DPolyPoly.count() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( 1.0/256, 1.0/256 ); - aMatrix.scale( mfFontScale, mfFontScale ); - rB2DPolyPoly.transform( aMatrix ); + const double fFactor((1.0/256) * mfFontScale); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor)); } return bRet; diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx index b98712419cf1..9cced7de3651 100644 --- a/vcl/source/gdi/region.cxx +++ b/vcl/source/gdi/region.cxx @@ -49,6 +49,7 @@ #include #include #include +#include // ======================================================================= // @@ -1300,9 +1301,7 @@ void Region::Move( long nHorzMove, long nVertMove ) mpImplRegion->mpPolyPoly->Move( nHorzMove, nVertMove ); else if( mpImplRegion->mpB2DPolyPoly ) { - ::basegfx::B2DHomMatrix aTransform; - aTransform.translate( nHorzMove, nVertMove ); - mpImplRegion->mpB2DPolyPoly->transform( aTransform ); + mpImplRegion->mpB2DPolyPoly->transform(basegfx::tools::createTranslateB2DHomMatrix(nHorzMove, nVertMove)); } else { @@ -1343,9 +1342,7 @@ void Region::Scale( double fScaleX, double fScaleY ) mpImplRegion->mpPolyPoly->Scale( fScaleX, fScaleY ); else if( mpImplRegion->mpB2DPolyPoly ) { - ::basegfx::B2DHomMatrix aTransform; - aTransform.scale( fScaleX, fScaleY ); - mpImplRegion->mpB2DPolyPoly->transform( aTransform ); + mpImplRegion->mpB2DPolyPoly->transform(basegfx::tools::createScaleB2DHomMatrix(fScaleX, fScaleY)); } else { diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 21ac05a498fc..b69a9c365f08 100755 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #ifndef _TL_DEBUG_HXX @@ -891,10 +892,8 @@ bool SalLayout::GetOutline( SalGraphics& rSalGraphics, { if( aPos.X() || aPos.Y() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.translate( aPos.X(), aPos.Y() ); - aGlyphOutline.transform( aMatrix ); - } + aGlyphOutline.transform(basegfx::tools::createTranslateB2DHomMatrix(aPos.X(), aPos.Y())); + } // insert outline at correct position rVector.push_back( aGlyphOutline ); diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index 712c2334b35c..820f3f0d74a9 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -2280,9 +2280,7 @@ bool FreetypeServerFont::GetGlyphOutline( int nGlyphIndex, // convert to basegfx polypolygon // TODO: get rid of the intermediate tools polypolygon rB2DPolyPoly = aToolPolyPolygon.getB2DPolyPolygon(); - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( +1.0/(1<<6), -1.0/(1<<6) ); - rB2DPolyPoly.transform( aMatrix ); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix( +1.0/(1<<6), -1.0/(1<<6) )); return true; } diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 4d3e40840a7b..d140610f7875 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1506,9 +1506,7 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : && !basegfx::fTools::equalZero( rLineWidth.getY() ) ) { // prepare for createAreaGeometry() with anisotropic linewidth - basegfx::B2DHomMatrix aAnisoMatrix; - aAnisoMatrix.scale( 1.0, rLineWidth.getX() / rLineWidth.getY() ); - aPolygon.transform( aAnisoMatrix ); + aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getX() / rLineWidth.getY())); } // AW: reSegment no longer needed; new createAreaGeometry will remove exteme positions @@ -1523,9 +1521,7 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : && !basegfx::fTools::equalZero( rLineWidth.getX() ) ) { // postprocess createAreaGeometry() for anisotropic linewidth - basegfx::B2DHomMatrix aAnisoMatrix; - aAnisoMatrix.scale( 1.0, rLineWidth.getY() / rLineWidth.getX() ); - aPolygon.transform( aAnisoMatrix ); + aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX())); } // temporarily adjust brush color to pen color diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 73f4d8320acc..0da51ccc2de9 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -65,6 +65,7 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolypolygon.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "sft.hxx" @@ -2480,9 +2481,8 @@ BOOL WinSalGraphics::GetGlyphOutline( long nIndex, // rescaling needed for the PolyPolygon conversion if( rB2DPolyPoly.count() ) { - ::basegfx::B2DHomMatrix aMatrix; - aMatrix.scale( mfFontScale/256, mfFontScale/256 ); - rB2DPolyPoly.transform( aMatrix ); + const double fFactor(mfFontScale/256); + rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor)); } return bRet; From 56fba7ddfd5f3527aacd92dfac254c3312cf5f14 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 24 Sep 2009 14:07:59 +0200 Subject: [PATCH 214/283] #i97509# optimized createRotateAroundPoint --- basegfx/source/matrix/b2dhommatrixtools.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx index c9c3180d3e4a..2c71193f6352 100644 --- a/basegfx/source/matrix/b2dhommatrixtools.cxx +++ b/basegfx/source/matrix/b2dhommatrixtools.cxx @@ -354,9 +354,18 @@ namespace basegfx if(!fTools::equalZero(fRadiant)) { - aRetval = createTranslateB2DHomMatrix(-fPointX, -fPointY); - aRetval.rotate(fRadiant); - aRetval.translate(fPointX, fPointY); + double fSin(0.0); + double fCos(1.0); + + createSinCosOrthogonal(fSin, fCos, fRadiant); + + aRetval.set3x2( + /* Row 0, Column 0 */ fCos, + /* Row 0, Column 1 */ -fSin, + /* Row 0, Column 2 */ (fPointX * (1.0 - fCos)) + (fSin * fPointY), + /* Row 1, Column 0 */ fSin, + /* Row 1, Column 1 */ fCos, + /* Row 1, Column 2 */ (fPointY * (1.0 - fCos)) - (fSin * fPointX)); } return aRetval; From 9d16cddca24d8734f60e2b9836cba9202ee90bdb Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 29 Sep 2009 15:35:35 +0200 Subject: [PATCH 215/283] #i105323# speedup of 3D handling mostly for CustomShapes; HitTest and interactions optimized --- basegfx/source/polygon/b3dpolygontools.cxx | 153 +++++++++++++++++---- 1 file changed, 124 insertions(+), 29 deletions(-) diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index ea303886dd88..52e0f0fcc36f 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -875,52 +875,147 @@ namespace basegfx } else { + bool bRetval(false); const B3DVector aPlaneNormal(rCandidate.getNormal()); if(!aPlaneNormal.equalZero()) { - const double fAbsX(fabs(aPlaneNormal.getX())); - const double fAbsY(fabs(aPlaneNormal.getY())); - const double fAbsZ(fabs(aPlaneNormal.getZ())); + const sal_uInt32 nPointCount(rCandidate.count()); - if(fAbsX > fAbsY && fAbsX > fAbsZ) + if(nPointCount) { - // normal points mostly in X-Direction, use YZ-Polygon projection for check - B3DHomMatrix aTrans; + B3DPoint aCurrentPoint(rCandidate.getB3DPoint(nPointCount - 1)); + const double fAbsX(fabs(aPlaneNormal.getX())); + const double fAbsY(fabs(aPlaneNormal.getY())); + const double fAbsZ(fabs(aPlaneNormal.getZ())); - aTrans.set(0, 0, 0.0); - aTrans.set(0, 1, 1.0); - aTrans.set(1, 1, 0.0); - aTrans.set(1, 2, 1.0); + if(fAbsX > fAbsY && fAbsX > fAbsZ) + { + // normal points mostly in X-Direction, use YZ-Polygon projection for check + // x -> y, y -> z + for(sal_uInt32 a(0); a < nPointCount; a++) + { + const B3DPoint aPreviousPoint(aCurrentPoint); + aCurrentPoint = rCandidate.getB3DPoint(a); - const B2DPolygon aYZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans)); + // cross-over in Z? + const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ())); + const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ())); - return isInside(aYZ, B2DPoint(rPoint.getY(), rPoint.getZ()), bWithBorder); - } - else if(fAbsY > fAbsX && fAbsY > fAbsZ) - { - // normal points mostly in Y-Direction, use XZ-Polygon projection for check - B3DHomMatrix aTrans; + if(bCompZA != bCompZB) + { + // cross-over in Y? + const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY())); + const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY())); - aTrans.set(1, 1, 0.0); - aTrans.set(1, 2, 1.0); + if(bCompYA == bCompYB) + { + if(bCompYA) + { + bRetval = !bRetval; + } + } + else + { + const double fCompare( + aCurrentPoint.getY() - (aCurrentPoint.getZ() - rPoint.getZ()) * + (aPreviousPoint.getY() - aCurrentPoint.getY()) / + (aPreviousPoint.getZ() - aCurrentPoint.getZ())); - const B2DPolygon aXZ(createB2DPolygonFromB3DPolygon(rCandidate, aTrans)); + if(fTools::more(fCompare, rPoint.getY())) + { + bRetval = !bRetval; + } + } + } + } + } + else if(fAbsY > fAbsX && fAbsY > fAbsZ) + { + // normal points mostly in Y-Direction, use XZ-Polygon projection for check + // x -> x, y -> z + for(sal_uInt32 a(0); a < nPointCount; a++) + { + const B3DPoint aPreviousPoint(aCurrentPoint); + aCurrentPoint = rCandidate.getB3DPoint(a); - return isInside(aXZ, B2DPoint(rPoint.getX(), rPoint.getZ()), bWithBorder); - } - else - { - // normal points mostly in Z-Direction, use XY-Polygon projection for check - B3DHomMatrix aTrans; + // cross-over in Z? + const bool bCompZA(fTools::more(aPreviousPoint.getZ(), rPoint.getZ())); + const bool bCompZB(fTools::more(aCurrentPoint.getZ(), rPoint.getZ())); - const B2DPolygon aXY(createB2DPolygonFromB3DPolygon(rCandidate, aTrans)); + if(bCompZA != bCompZB) + { + // cross-over in X? + const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX())); + const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX())); - return isInside(aXY, B2DPoint(rPoint.getX(), rPoint.getY()), bWithBorder); + if(bCompXA == bCompXB) + { + if(bCompXA) + { + bRetval = !bRetval; + } + } + else + { + const double fCompare( + aCurrentPoint.getX() - (aCurrentPoint.getZ() - rPoint.getZ()) * + (aPreviousPoint.getX() - aCurrentPoint.getX()) / + (aPreviousPoint.getZ() - aCurrentPoint.getZ())); + + if(fTools::more(fCompare, rPoint.getX())) + { + bRetval = !bRetval; + } + } + } + } + } + else + { + // normal points mostly in Z-Direction, use XY-Polygon projection for check + // x -> x, y -> y + for(sal_uInt32 a(0); a < nPointCount; a++) + { + const B3DPoint aPreviousPoint(aCurrentPoint); + aCurrentPoint = rCandidate.getB3DPoint(a); + + // cross-over in Y? + const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY())); + const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY())); + + if(bCompYA != bCompYB) + { + // cross-over in X? + const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX())); + const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX())); + + if(bCompXA == bCompXB) + { + if(bCompXA) + { + bRetval = !bRetval; + } + } + else + { + const double fCompare( + aCurrentPoint.getX() - (aCurrentPoint.getY() - rPoint.getY()) * + (aPreviousPoint.getX() - aCurrentPoint.getX()) / + (aPreviousPoint.getY() - aCurrentPoint.getY())); + + if(fTools::more(fCompare, rPoint.getX())) + { + bRetval = !bRetval; + } + } + } + } + } } } - return false; + return bRetval; } } From a6d693d98547c8aa172b5044c36b71160f8ad8f7 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 7 Oct 2009 14:25:40 +0200 Subject: [PATCH 216/283] #i105323# added FastPath for 3D scene HitTest for 3d CustomShapes by re-using the buffered last render result from the ScenePrimitive2D --- vcl/inc/vcl/bitmapex.hxx | 13 +++++++ vcl/source/gdi/bitmapex.cxx | 73 +++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx index 3da80ce8c2f1..e5ddf50f1efa 100644 --- a/vcl/inc/vcl/bitmapex.hxx +++ b/vcl/inc/vcl/bitmapex.hxx @@ -381,6 +381,19 @@ public: const BmpFilterParam* pFilterParam = NULL, const Link* pProgress = NULL ); + /** Get transparency at given position + + @param nX + integer X-Position in Bitmap + + @param nY + integer Y-Position in Bitmap + + @return transparency value in the range of [0 .. 255] where + 0 is not transparent, 255 is fully transparent + */ + sal_uInt8 GetTransparency(sal_Int32 nX, sal_Int32 nY) const; + public: friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ); diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index cfcac8851089..6626a12d29a2 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -47,6 +47,7 @@ #include #endif #include +#include // ------------ // - BitmapEx - @@ -761,6 +762,78 @@ void BitmapEx::Draw( OutputDevice* pOutDev, // ------------------------------------------------------------------ +sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const +{ + sal_uInt8 nTransparency(0xff); + + if(!aBitmap.IsEmpty()) + { + if(nX >= 0 && nX < aBitmapSize.Width() && nY >= 0 && nY < aBitmapSize.Height()) + { + switch(eTransparent) + { + case TRANSPARENT_NONE: + { + // not transparent, ergo all covered + nTransparency = 0x00; + break; + } + case TRANSPARENT_COLOR: + { + Bitmap aTestBitmap(aBitmap); + BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + + if(pRead) + { + const Color aColor(Color(pRead->GetColor(nY, nX))); + + // if color is not equal to TransparentColor, we are not transparent + if(aColor != aTransparentColor) + { + nTransparency = 0x00; + } + + aTestBitmap.ReleaseAccess(pRead); + } + break; + } + case TRANSPARENT_BITMAP: + { + if(!aMask.IsEmpty()) + { + Bitmap aTestBitmap(aMask); + BitmapReadAccess* pRead = aTestBitmap.AcquireReadAccess(); + + if(pRead) + { + const BitmapColor aBitmapColor(pRead->GetPixel(nY, nX)); + + if(bAlpha) + { + nTransparency = aBitmapColor.GetIndex(); + } + else + { + if(0x00 != aBitmapColor.GetIndex()) + { + nTransparency = 0x00; + } + } + + aTestBitmap.ReleaseAccess(pRead); + } + } + break; + } + } + } + } + + return nTransparency; +} + +// ------------------------------------------------------------------ + SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ) { rBitmapEx.aBitmap.Write( rOStm ); From f678fbae66d80e762faa29e7ab0fe3703f005275 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 8 Oct 2009 17:35:07 +0200 Subject: [PATCH 217/283] #i105459# enhanced circles/ellipes for more mathematical correctness --- .../inc/basegfx/polygon/b2dpolygontools.hxx | 61 ---- basegfx/source/polygon/b2dpolygontools.cxx | 271 +++++++++--------- 2 files changed, 139 insertions(+), 193 deletions(-) diff --git a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx index 5eff6b0b9cc1..47ff41b75e70 100644 --- a/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx +++ b/basegfx/inc/basegfx/polygon/b2dpolygontools.hxx @@ -288,14 +288,6 @@ namespace basegfx */ B2DPolygon createPolygonFromCircle( const B2DPoint& rCenter, double fRadius ); - /** append a unit circle with one point and the control vectors to the given polygon - */ - void appendUnitCircleQuadrant(B2DPolygon& rPolygon, sal_uInt32 nQuadrant, bool bEndPoint); - - /** append a segment of unit circle with one point and the control vectors to the given polygon - */ - void appendUnitCircleQuadrantSegment(B2DPolygon& rPolygon, sal_uInt32 nQuadrant, double fStart, double fEnd, bool bEndPoint); - /** create a polygon which describes the unit circle and close it @param nStartQuadrant @@ -325,59 +317,6 @@ namespace basegfx */ B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ); - /** append a unit circle with one point and the control vectors to the given polygon - */ - void appendUnitCircleQuadrant(B2DPolygon& rPolygon, sal_uInt32 nQuadrant); - - /** append a segment of unit circle with start point, the control vectors and end point to the given polygon - */ - void appendUnitCircleQuadrantSegment(B2DPolygon& rPolygon, sal_uInt32 nQuadrant, double fStart, double fEnd); - - /** Create an ellipse polygon with given radii. - - This method creates an ellipse approximation consisting of - four cubic bezier segments, which approximate the given - ellipse with an error of less than 0.5 percent. - - @param rCenter - Center point of the circle - - @param fRadiusX - Radius of the ellipse in X direction - - @param fRadiusY - Radius of the ellipse in Y direction - - @param fStart - Start angle where the ellipe segment starts in the range [0.0 .. 2PI[ - - @param fEnd - End angle where the ellipe segment ends in the range [0.0 .. 2PI[ - */ - B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ); - - /** Create an ellipse polygon with given radii and the given angles, from start to end - - This method creates an ellipse approximation consisting of - four cubic bezier segments, which approximate the given - ellipse with an error of less than 0.5 percent. - - @param rCenter - Center point of the circle - - @param fRadiusX - Radius of the ellipse in X direction - - @param fRadiusY - Radius of the ellipse in Y direction - - @param fStart - Start angle where the ellipe segment starts in the range [0.0 .. 2PI[ - - @param fEnd - End angle where the ellipe segment ends in the range [0.0 .. 2PI[ - */ - /** Create an unit ellipse polygon with the given angles, from start to end */ B2DPolygon createPolygonFromEllipseSegment( const B2DPoint& rCenter, double fRadiusX, double fRadiusY, double fStart, double fEnd ); diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 6e288786df6d..da3fa202c2a4 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ #ifdef DBG_UTIL static double fAngleBoundStartValue = ANGLE_BOUND_START_VALUE; #endif +#define STEPSPERQUARTER (3) ////////////////////////////////////////////////////////////////////////////// @@ -1832,57 +1834,94 @@ namespace basegfx return createPolygonFromEllipse( rCenter, fRadius, fRadius ); } - void appendUnitCircleQuadrant(B2DPolygon& rPolygon, sal_uInt32 nQuadrant) + B2DPolygon impCreateUnitCircle(sal_uInt32 nStartQuadrant) { - const double fZero(0.0); - const double fOne(1.0); + B2DPolygon aUnitCircle; const double fKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); + const double fScaledKappa(fKappa * (1.0 / STEPSPERQUARTER)); + const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(F_PI2 / STEPSPERQUARTER)); - // create closed unit-circle with 4 segments - switch(nQuadrant) + B2DPoint aPoint(1.0, 0.0); + B2DPoint aForward(1.0, fScaledKappa); + B2DPoint aBackward(1.0, -fScaledKappa); + + if(0 != nStartQuadrant) { - case 0 : // first quadrant - { - rPolygon.append(B2DPoint(fOne, fZero)); - rPolygon.appendBezierSegment(B2DPoint(fOne, fKappa), B2DPoint(fKappa, fOne), B2DPoint(fZero, fOne)); - break; - } - case 1 : // second quadrant - { - rPolygon.append(B2DPoint(fZero, fOne)); - rPolygon.appendBezierSegment(B2DPoint(-fKappa, fOne), B2DPoint(-fOne, fKappa), B2DPoint(-fOne, fZero)); - break; - } - case 2 : // third quadrant - { - rPolygon.append(B2DPoint(-fOne, fZero)); - rPolygon.appendBezierSegment(B2DPoint(-fOne, -fKappa), B2DPoint(-fKappa, -fOne), B2DPoint(fZero, -fOne)); - break; - } - default : // last quadrant - { - rPolygon.append(B2DPoint(fZero, -fOne)); - rPolygon.appendBezierSegment(B2DPoint(fKappa, -fOne), B2DPoint(fOne, -fKappa), B2DPoint(fOne, fZero)); - break; - } + const B2DHomMatrix aQuadrantMatrix(createRotateB2DHomMatrix(F_PI2 * (nStartQuadrant % 4))); + aPoint *= aQuadrantMatrix; + aBackward *= aQuadrantMatrix; + aForward *= aQuadrantMatrix; } + + aUnitCircle.append(aPoint); + + for(sal_uInt32 a(0); a < STEPSPERQUARTER * 4; a++) + { + aPoint *= aRotateMatrix; + aBackward *= aRotateMatrix; + aUnitCircle.appendBezierSegment(aForward, aBackward, aPoint); + aForward *= aRotateMatrix; + } + + aUnitCircle.setClosed(true); + aUnitCircle.removeDoublePoints(); + + return aUnitCircle; } B2DPolygon createPolygonFromUnitCircle(sal_uInt32 nStartQuadrant) { - B2DPolygon aRetval; + switch(nStartQuadrant % 4) + { + case 1 : + { + static B2DPolygon aUnitCircleStartQuadrantOne; - // create unit-circle with all 4 segments, close it - appendUnitCircleQuadrant(aRetval, nStartQuadrant % 4); nStartQuadrant++; - appendUnitCircleQuadrant(aRetval, nStartQuadrant % 4); nStartQuadrant++; - appendUnitCircleQuadrant(aRetval, nStartQuadrant % 4); nStartQuadrant++; - appendUnitCircleQuadrant(aRetval, nStartQuadrant % 4); nStartQuadrant++; - aRetval.setClosed(true); + if(!aUnitCircleStartQuadrantOne.count()) + { + ::osl::Mutex m_mutex; + aUnitCircleStartQuadrantOne = impCreateUnitCircle(1); + } - // remove double points between segments created by segmented creation - aRetval.removeDoublePoints(); + return aUnitCircleStartQuadrantOne; + } + case 2 : + { + static B2DPolygon aUnitCircleStartQuadrantTwo; - return aRetval; + if(!aUnitCircleStartQuadrantTwo.count()) + { + ::osl::Mutex m_mutex; + aUnitCircleStartQuadrantTwo = impCreateUnitCircle(2); + } + + return aUnitCircleStartQuadrantTwo; + } + case 3 : + { + static B2DPolygon aUnitCircleStartQuadrantThree; + + if(!aUnitCircleStartQuadrantThree.count()) + { + ::osl::Mutex m_mutex; + aUnitCircleStartQuadrantThree = impCreateUnitCircle(3); + } + + return aUnitCircleStartQuadrantThree; + } + default : // case 0 : + { + static B2DPolygon aUnitCircleStartQuadrantZero; + + if(!aUnitCircleStartQuadrantZero.count()) + { + ::osl::Mutex m_mutex; + aUnitCircleStartQuadrantZero = impCreateUnitCircle(0); + } + + return aUnitCircleStartQuadrantZero; + } + } } B2DPolygon createPolygonFromEllipse( const B2DPoint& rCenter, double fRadiusX, double fRadiusY ) @@ -1895,63 +1934,6 @@ namespace basegfx return aRetval; } - void appendUnitCircleQuadrantSegment(B2DPolygon& rPolygon, sal_uInt32 nQuadrant, double fStart, double fEnd) - { - OSL_ENSURE(fStart >= 0.0 && fStart <= 1.0, "appendUnitCircleQuadrantSegment: Access out of range (!)"); - OSL_ENSURE(fEnd >= 0.0 && fEnd <= 1.0, "appendUnitCircleQuadrantSegment: Access out of range (!)"); - OSL_ENSURE(fEnd >= fStart, "appendUnitCircleQuadrantSegment: Access out of range (!)"); - const double fOne(1.0); - const bool bStartIsZero(fTools::equalZero(fStart)); - const bool bEndIsOne(fTools::equal(fEnd, fOne)); - - if(bStartIsZero && bEndIsOne) - { - // add completely - appendUnitCircleQuadrant(rPolygon, nQuadrant); - } - else - { - // split and add - B2DPolygon aQuadrant; - appendUnitCircleQuadrant(aQuadrant, nQuadrant); - const bool bStartEndEqual(fTools::equal(fStart, fEnd)); - - if(bStartEndEqual) - { - if(bStartIsZero) - { - // both zero, add start point - rPolygon.append(aQuadrant.getB2DPoint(0L)); - } - else if(bEndIsOne) - { - // both one, add end point - rPolygon.append(aQuadrant.getB2DPoint(1L)); - } - else - { - // both equal but not zero, add split point - B2DCubicBezier aCubicBezier( - aQuadrant.getB2DPoint(0L), aQuadrant.getNextControlPoint(0L), - aQuadrant.getPrevControlPoint(1L), aQuadrant.getB2DPoint(1L)); - - aCubicBezier.split(fStart, &aCubicBezier, 0); - rPolygon.append(aCubicBezier.getEndPoint()); - } - } - else - { - B2DCubicBezier aCubicBezier( - aQuadrant.getB2DPoint(0L), aQuadrant.getNextControlPoint(0L), - aQuadrant.getPrevControlPoint(1L), aQuadrant.getB2DPoint(1L)); - - aCubicBezier = aCubicBezier.snippet(fStart, fEnd); - rPolygon.append(aCubicBezier.getStartPoint()); - rPolygon.appendBezierSegment(aCubicBezier.getControlPointA(), aCubicBezier.getControlPointB(), aCubicBezier.getEndPoint()); - } - } - } - B2DPolygon createPolygonFromUnitEllipseSegment( double fStart, double fEnd ) { B2DPolygon aRetval; @@ -1978,49 +1960,74 @@ namespace basegfx fEnd = 0.0; } - const sal_uInt32 nQuadrantStart(sal_uInt32(fStart / F_PI2) % 4L); - const sal_uInt32 nQuadrantEnd(sal_uInt32(fEnd / F_PI2) % 4L); - sal_uInt32 nCurrentQuadrant(nQuadrantStart); - bool bStartDone(false); - bool bEndDone(false); - - do + if(fTools::equal(fStart, fEnd)) { - if(!bStartDone && nQuadrantStart == nCurrentQuadrant) + // same start and end angle, add single point + aRetval.append(B2DPoint(cos(fStart), sin(fStart))); + } + else + { + const sal_uInt32 nSegments(STEPSPERQUARTER * 4); + const double fAnglePerSegment(F_PI2 / STEPSPERQUARTER); + const sal_uInt32 nStartSegment(sal_uInt32(fStart / fAnglePerSegment) % nSegments); + const sal_uInt32 nEndSegment(sal_uInt32(fEnd / fAnglePerSegment) % nSegments); + const double fKappa((M_SQRT2 - 1.0) * 4.0 / 3.0); + const double fScaledKappa(fKappa * (1.0 / STEPSPERQUARTER)); + + B2DPoint aSegStart(cos(fStart), sin(fStart)); + aRetval.append(aSegStart); + + if(nStartSegment == nEndSegment && fTools::more(fEnd, fStart)) { - if(nQuadrantStart == nQuadrantEnd && fTools::moreOrEqual(fEnd, fStart)) - { - // both in one quadrant and defining the complete segment, create start to end - double fSplitOffsetStart((fStart - (nCurrentQuadrant * F_PI2)) / F_PI2); - double fSplitOffsetEnd((fEnd - (nCurrentQuadrant * F_PI2)) / F_PI2); - appendUnitCircleQuadrantSegment(aRetval, nCurrentQuadrant, fSplitOffsetStart, fSplitOffsetEnd); - bStartDone = bEndDone = true; - } - else - { - // create start to quadrant end - const double fSplitOffsetStart((fStart - (nCurrentQuadrant * F_PI2)) / F_PI2); - appendUnitCircleQuadrantSegment(aRetval, nCurrentQuadrant, fSplitOffsetStart, 1.0); - bStartDone = true; - } - } - else if(!bEndDone && nQuadrantEnd == nCurrentQuadrant) - { - // create quadrant start to end - const double fSplitOffsetEnd((fEnd - (nCurrentQuadrant * F_PI2)) / F_PI2); - appendUnitCircleQuadrantSegment(aRetval, nCurrentQuadrant, 0.0, fSplitOffsetEnd); - bEndDone = true; + // start and end in one sector and in the right order, create in one segment + const B2DPoint aSegEnd(cos(fEnd), sin(fEnd)); + const double fFactor(fScaledKappa * ((fEnd - fStart) / fAnglePerSegment)); + + aRetval.appendBezierSegment( + aSegStart + (B2DPoint(-aSegStart.getY(), aSegStart.getX()) * fFactor), + aSegEnd - (B2DPoint(-aSegEnd.getY(), aSegEnd.getX()) * fFactor), + aSegEnd); } else { - // add quadrant completely - appendUnitCircleQuadrant(aRetval, nCurrentQuadrant); - } + double fSegEndRad((nStartSegment + 1) * fAnglePerSegment); + double fFactor(fScaledKappa * ((fSegEndRad - fStart) / fAnglePerSegment)); + B2DPoint aSegEnd(cos(fSegEndRad), sin(fSegEndRad)); - // next step - nCurrentQuadrant = (nCurrentQuadrant + 1L) % 4L; + aRetval.appendBezierSegment( + aSegStart + (B2DPoint(-aSegStart.getY(), aSegStart.getX()) * fFactor), + aSegEnd - (B2DPoint(-aSegEnd.getY(), aSegEnd.getX()) * fFactor), + aSegEnd); + + sal_uInt32 nSegment((nStartSegment + 1) % nSegments); + aSegStart = aSegEnd; + + while(nSegment != nEndSegment) + { + // No end in this sector, add full sector. + fSegEndRad = (nSegment + 1) * fAnglePerSegment; + aSegEnd = B2DPoint(cos(fSegEndRad), sin(fSegEndRad)); + + aRetval.appendBezierSegment( + aSegStart + (B2DPoint(-aSegStart.getY(), aSegStart.getX()) * fScaledKappa), + aSegEnd - (B2DPoint(-aSegEnd.getY(), aSegEnd.getX()) * fScaledKappa), + aSegEnd); + + nSegment = (nSegment + 1) % nSegments; + aSegStart = aSegEnd; + } + + // End in this sector + const double fSegStartRad(nSegment * fAnglePerSegment); + fFactor = fScaledKappa * ((fEnd - fSegStartRad) / fAnglePerSegment); + aSegEnd = B2DPoint(cos(fEnd), sin(fEnd)); + + aRetval.appendBezierSegment( + aSegStart + (B2DPoint(-aSegStart.getY(), aSegStart.getX()) * fFactor), + aSegEnd - (B2DPoint(-aSegEnd.getY(), aSegEnd.getX()) * fFactor), + aSegEnd); + } } - while(!(bStartDone && bEndDone)); // remove double points between segments created by segmented creation aRetval.removeDoublePoints(); From da090fbc35805969d00cef772108fa5be756d331 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 13 Oct 2009 12:39:07 +0200 Subject: [PATCH 218/283] #i65491# move first page features to document setup --- vcl/inc/vcl/printerjob.hxx | 2 +- vcl/unx/source/printergfx/printerjob.cxx | 45 ++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/vcl/inc/vcl/printerjob.hxx b/vcl/inc/vcl/printerjob.hxx index 9880700d4008..e445a81d54c8 100644 --- a/vcl/inc/vcl/printerjob.hxx +++ b/vcl/inc/vcl/printerjob.hxx @@ -91,7 +91,7 @@ private: // private methods bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup ); bool writeSetup( osl::File* pFile, const JobData& ); - bool writePageSetup( osl::File* pFile, const JobData& ); + bool writePageSetup( osl::File* pFile, const JobData&, bool bWriteFeatures = true ); void writeJobPatch( osl::File* File, const JobData& ); bool writeProlog (osl::File* pFile, const JobData& ); diff --git a/vcl/unx/source/printergfx/printerjob.cxx b/vcl/unx/source/printergfx/printerjob.cxx index 783dd5ff2b47..1c42cafa4cb9 100644 --- a/vcl/unx/source/printergfx/printerjob.cxx +++ b/vcl/unx/source/printergfx/printerjob.cxx @@ -681,14 +681,6 @@ PrinterJob::StartPage (const JobData& rJobSetup) if( ! (pPageHeader && pPageBody) ) return sal_False; - /* #i7262# write setup only before first page - * don't do this in StartJob since the jobsetup there may be - * different. - */ - bool bSuccess = true; - if( 1 == maPageList.size() ) - m_aDocumentJobData = rJobSetup; - // write page header according to Document Structuring Conventions (DSC) WritePS (pPageHeader, "%%Page: "); WritePS (pPageHeader, aPageNo); @@ -722,13 +714,25 @@ PrinterJob::StartPage (const JobData& rJobSetup) WritePS (pPageHeader, pBBox); - if (bSuccess) - bSuccess = writePageSetup ( pPageHeader, rJobSetup ); - if(bSuccess) + /* #i7262# #i65491# write setup only before first page + * (to %%Begin(End)Setup, instead of %%Begin(End)PageSetup) + * don't do this in StartJob since the jobsetup there may be + * different. + */ + bool bWriteFeatures = true; + if( 1 == maPageList.size() ) + { + m_aDocumentJobData = rJobSetup; + bWriteFeatures = false; + } + + if ( writePageSetup( pPageHeader, rJobSetup, bWriteFeatures ) ) + { m_aLastJobData = rJobSetup; + return true; + } - - return bSuccess; + return false; } sal_Bool @@ -828,12 +832,9 @@ bool PrinterJob::writeFeatureList( osl::File* pFile, const JobData& rJob, bool b if( pKey->getSetupType() == PPDKey::DocumentSetup ) bEmit = true; } - else - { - if( pKey->getSetupType() == PPDKey::PageSetup || - pKey->getSetupType() == PPDKey::AnySetup ) - bEmit = true; - } + if( pKey->getSetupType() == PPDKey::PageSetup || + pKey->getSetupType() == PPDKey::AnySetup ) + bEmit = true; if( bEmit ) { const PPDValue* pValue = rJob.m_aContext.getValue( pKey ); @@ -866,13 +867,13 @@ bool PrinterJob::writeFeatureList( osl::File* pFile, const JobData& rJob, bool b return bSuccess; } -bool PrinterJob::writePageSetup( osl::File* pFile, const JobData& rJob ) +bool PrinterJob::writePageSetup( osl::File* pFile, const JobData& rJob, bool bWriteFeatures ) { bool bSuccess = true; WritePS (pFile, "%%BeginPageSetup\n%\n"); - - bSuccess = writeFeatureList( pFile, rJob, false ); + if ( bWriteFeatures ) + bSuccess = writeFeatureList( pFile, rJob, false ); WritePS (pFile, "%%EndPageSetup\n"); sal_Char pTranslate [128]; From 04ee83054bd6b805262d7e0feba400da13b0c303 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 13 Oct 2009 13:40:45 +0200 Subject: [PATCH 219/283] #i105822# leave printer in correct state in both cached and uncached case of getFilteredPageFile --- vcl/source/gdi/print3.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 98f6530d5b49..09728a5f5a14 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -756,6 +756,8 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte { PrinterController::PageSize aPageSize = getPageFile( i_nFilteredPage, o_rMtf, i_bMayUseCache ); Size aPaperSize = mpImplData->getRealPaperSize( aPageSize.aSize ); + mpImplData->mpPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); + mpImplData->mpPrinter->SetPaperSizeUser( aPaperSize, ! mpImplData->isFixedPageSize() ); if( aPaperSize != aPageSize.aSize ) { // user overridden page size, center Metafile From 727411be78c3ac7300caa688f8085a9952e7c85d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 14 Oct 2009 13:55:31 +0200 Subject: [PATCH 220/283] #i105655# commiting changes so far for preparing linux version --- canvas/source/cairo/cairo_canvashelper.cxx | 50 +++++++++++-- canvas/source/cairo/cairo_canvashelper.hxx | 1 + canvas/source/directx/dx_canvashelper.cxx | 11 ++- canvas/source/directx/dx_impltools.cxx | 67 +++++++++++++---- canvas/source/directx/dx_impltools.hxx | 15 ++-- canvas/source/directx/dx_linepolypolygon.cxx | 4 +- canvas/source/directx/dx_linepolypolygon.hxx | 2 +- cppcanvas/source/mtfrenderer/implrenderer.cxx | 19 ++++- vcl/inc/vcl/cvtsvm.hxx | 2 + vcl/inc/vcl/lineinfo.hxx | 23 +++--- vcl/source/gdi/cvtsvm.cxx | 38 +++++++++- vcl/source/gdi/lineinfo.cxx | 30 +++++++- vcl/source/gdi/outdev.cxx | 27 ++++--- vcl/win/source/gdi/salgdi_gdiplus.cxx | 72 +++++++++++++++++-- 14 files changed, 303 insertions(+), 58 deletions(-) diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 9cf2dd978759..5469010f2745 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -958,6 +958,7 @@ namespace cairocanvas void CanvasHelper::doPolyPolygonPath( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon, Operation aOperation, + bool bNoLineJoin, const uno::Sequence< rendering::Texture >* pTextures, Cairo* pCairo ) const { @@ -967,10 +968,46 @@ namespace cairocanvas if( !pCairo ) pCairo = mpCairo.get(); - doPolyPolygonImplementation( rPolyPoly, aOperation, - pCairo, pTextures, - mpSurfaceProvider, - xPolyPolygon->getFillRule() ); + if(bNoLineJoin && Stroke == aOperation) + { + // emulate rendering::PathJoinType::NONE by painting single edges + for(sal_uInt32 a(0); a < rPolyPoly.count(); a++) + { + const basegfx::B2DPolygon aCandidate(rPolyPoly.getB2DPolygon(a)); + const sal_uInt32 nPointCount(aCandidate.count()); + + if(nPointCount) + { + const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount + 1: nPointCount); + basegfx::B2DPolygon aEdge; + aEdge.append(aCandidate.getB2DPoint(0)); + aEdge.append(basegfx::B2DPoint(0.0, 0.0)); + + for(sal_uInt32 a(0); a < nEdgeCount; a++) + { + const sal_uInt32 nNextIndex((a + 1) % nPointCount); + aEdge.setB2DPoint(1, aCandidate.getB2DPoint(nNextIndex)); + aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a)); + aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex)); + + doPolyPolygonImplementation( aEdge, aOperation, + pCairo, pTextures, + mpSurfaceProvider, + xPolyPolygon->getFillRule() ); + + // prepare next step + aEdge.setB2DPoint(0, aEdge.getB2DPoint(1)); + } + } + } + } + else + { + doPolyPolygonImplementation( rPolyPoly, aOperation, + pCairo, pTextures, + mpSurfaceProvider, + xPolyPolygon->getFillRule() ); + } } uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas* , @@ -1039,9 +1076,12 @@ namespace cairocanvas break; } + bool bNoLineJoin(false); + switch( strokeAttributes.JoinType ) { // cairo doesn't have join type NONE so we use MITER as it's pretty close case rendering::PathJoinType::NONE: + bNoLineJoin = true; case rendering::PathJoinType::MITER: cairo_set_line_join( mpCairo.get(), CAIRO_LINE_JOIN_MITER ); break; @@ -1063,7 +1103,7 @@ namespace cairocanvas // TODO(rodo) use LineArray of strokeAttributes - doPolyPolygonPath( xPolyPolygon, Stroke ); + doPolyPolygonPath( xPolyPolygon, Stroke, bNoLineJoin ); cairo_restore( mpCairo.get() ); } else diff --git a/canvas/source/cairo/cairo_canvashelper.hxx b/canvas/source/cairo/cairo_canvashelper.hxx index 1e69a9f41e5b..90d365d63b3c 100644 --- a/canvas/source/cairo/cairo_canvashelper.hxx +++ b/canvas/source/cairo/cairo_canvashelper.hxx @@ -276,6 +276,7 @@ namespace cairocanvas void doPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, Operation aOperation, + bool bNoLineJoin = false, const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL, ::cairo::Cairo* pCairo=NULL ) const; diff --git a/canvas/source/directx/dx_canvashelper.cxx b/canvas/source/directx/dx_canvashelper.cxx index dcb65c94ae3c..607f7c076e21 100755 --- a/canvas/source/directx/dx_canvashelper.cxx +++ b/canvas/source/directx/dx_canvashelper.cxx @@ -368,7 +368,11 @@ namespace dxcanvas pGraphics->GetPixelOffsetMode() ); pGraphics->SetPixelOffsetMode( Gdiplus::PixelOffsetModeNone ); - aPen.SetMiterLimit( static_cast< Gdiplus::REAL >(strokeAttributes.MiterLimit) ); + const bool bIsMiter(rendering::PathJoinType::MITER == strokeAttributes.JoinType); + const bool bIsNone(rendering::PathJoinType::NONE == strokeAttributes.JoinType); + + if(bIsMiter) + aPen.SetMiterLimit( static_cast< Gdiplus::REAL >(strokeAttributes.MiterLimit) ); const ::std::vector< Gdiplus::REAL >& rDashArray( ::comphelper::sequenceToContainer< ::std::vector< Gdiplus::REAL > >( @@ -381,9 +385,10 @@ namespace dxcanvas aPen.SetLineCap( gdiCapFromCap(strokeAttributes.StartCapType), gdiCapFromCap(strokeAttributes.EndCapType), Gdiplus::DashCapFlat ); - aPen.SetLineJoin( gdiJoinFromJoin(strokeAttributes.JoinType) ); + if(!bIsNone) + aPen.SetLineJoin( gdiJoinFromJoin(strokeAttributes.JoinType) ); - GraphicsPathSharedPtr pPath( tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon ) ); + GraphicsPathSharedPtr pPath( tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon, bIsNone ) ); // TODO(E1): Return value Gdiplus::Status hr = pGraphics->DrawPath( &aPen, pPath.get() ); diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx index 40164c9a1d87..4f5b92d6bcb5 100755 --- a/canvas/source/directx/dx_impltools.cxx +++ b/canvas/source/directx/dx_impltools.cxx @@ -194,7 +194,8 @@ namespace dxcanvas void graphicsPathFromB2DPolygon( GraphicsPathSharedPtr& rOutput, ::std::vector< Gdiplus::PointF >& rPoints, - const ::basegfx::B2DPolygon& rPoly ) + const ::basegfx::B2DPolygon& rPoly, + bool bNoLineJoin) { const sal_uInt32 nPoints( rPoly.count() ); @@ -241,7 +242,18 @@ namespace dxcanvas rPoints[nCurrOutput++] = Gdiplus::PointF( static_cast(rPoint.getX()), static_cast(rPoint.getY()) ); - rOutput->AddBeziers( &rPoints[0], nCurrOutput ); + if(bNoLineJoin && nCurrOutput > 7) + { + for(sal_uInt32 a(3); a < nCurrOutput; a+=3) + { + rOutput->StartFigure(); + rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]); + } + } + else + { + rOutput->AddBeziers( &rPoints[0], nCurrOutput ); + } } else { @@ -251,7 +263,20 @@ namespace dxcanvas // Therefore, simply don't pass the last two // points here. if( nCurrOutput > 3 ) - rOutput->AddBeziers( &rPoints[0], nCurrOutput-2 ); + { + if(bNoLineJoin && nCurrOutput > 7) + { + for(sal_uInt32 a(3); a < nCurrOutput; a+=3) + { + rOutput->StartFigure(); + rOutput->AddBezier(rPoints[a - 3], rPoints[a - 2], rPoints[a - 1], rPoints[a]); + } + } + else + { + rOutput->AddBeziers( &rPoints[0], nCurrOutput-2 ); + } + } } } else @@ -267,10 +292,27 @@ namespace dxcanvas static_cast(rPoint.getY()) ); } - rOutput->AddLines( &rPoints[0], nPoints ); + if(bNoLineJoin && nPoints > 2) + { + for(sal_uInt32 a(1); a < nPoints; a++) + { + rOutput->StartFigure(); + rOutput->AddLine(rPoints[a - 1], rPoints[a]); + } + + if(bClosedPolygon) + { + rOutput->StartFigure(); + rOutput->AddLine(rPoints[nPoints - 1], rPoints[0]); + } + } + else + { + rOutput->AddLines( &rPoints[0], nPoints ); + } } - if( bClosedPolygon ) + if( bClosedPolygon && !bNoLineJoin ) rOutput->CloseFigure(); } } @@ -426,17 +468,17 @@ namespace dxcanvas return pRes; } - GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly ) + GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly, bool bNoLineJoin ) { GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() ); ::std::vector< Gdiplus::PointF > aPoints; - graphicsPathFromB2DPolygon( pRes, aPoints, rPoly ); + graphicsPathFromB2DPolygon( pRes, aPoints, rPoly, bNoLineJoin ); return pRes; } - GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly ) + GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly, bool bNoLineJoin ) { GraphicsPathSharedPtr pRes( new Gdiplus::GraphicsPath() ); ::std::vector< Gdiplus::PointF > aPoints; @@ -446,24 +488,25 @@ namespace dxcanvas { graphicsPathFromB2DPolygon( pRes, aPoints, - rPoly.getB2DPolygon( nCurrPoly ) ); + rPoly.getB2DPolygon( nCurrPoly ), + bNoLineJoin); } return pRes; } - GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly ) + GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly, bool bNoLineJoin ) { LinePolyPolygon* pPolyImpl = dynamic_cast< LinePolyPolygon* >( xPoly.get() ); if( pPolyImpl ) { - return pPolyImpl->getGraphicsPath(); + return pPolyImpl->getGraphicsPath( bNoLineJoin ); } else { return tools::graphicsPathFromB2DPolyPolygon( - polyPolygonFromXPolyPolygon2D( xPoly ) ); + polyPolygonFromXPolyPolygon2D( xPoly ), bNoLineJoin ); } } diff --git a/canvas/source/directx/dx_impltools.hxx b/canvas/source/directx/dx_impltools.hxx index 072d1063235d..222b1a927305 100755 --- a/canvas/source/directx/dx_impltools.hxx +++ b/canvas/source/directx/dx_impltools.hxx @@ -107,11 +107,18 @@ namespace dxcanvas GraphicsPathSharedPtr graphicsPathFromRealPoint2DSequence( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& ); - GraphicsPathSharedPtr graphicsPathFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly ); - GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly ); + GraphicsPathSharedPtr graphicsPathFromB2DPolygon( + const ::basegfx::B2DPolygon& rPoly, + bool bNoLineJoin = false); + + GraphicsPathSharedPtr graphicsPathFromB2DPolyPolygon( + const ::basegfx::B2DPolyPolygon& rPoly, + bool bNoLineJoin = false); + + GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( + const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >&, + bool bNoLineJoin = false ); - GraphicsPathSharedPtr graphicsPathFromXPolyPolygon2D( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XPolyPolygon2D >& ); bool drawGdiPlusBitmap( const GraphicsSharedPtr& rGraphics, const BitmapSharedPtr& rBitmap ); bool drawDIBits( const ::boost::shared_ptr< Gdiplus::Graphics >& rGraphics, diff --git a/canvas/source/directx/dx_linepolypolygon.cxx b/canvas/source/directx/dx_linepolypolygon.cxx index e63adc3dc613..9a5569384eae 100755 --- a/canvas/source/directx/dx_linepolypolygon.cxx +++ b/canvas/source/directx/dx_linepolypolygon.cxx @@ -46,14 +46,14 @@ namespace dxcanvas { } - GraphicsPathSharedPtr LinePolyPolygon::getGraphicsPath() const + GraphicsPathSharedPtr LinePolyPolygon::getGraphicsPath( bool bNoLineJoin ) const { // generate GraphicsPath only on demand (gets deleted as soon // as any of the modifying methods above touches the // B2DPolyPolygon). if( !mpPath ) { - mpPath = tools::graphicsPathFromB2DPolyPolygon( getPolyPolygonUnsafe() ); + mpPath = tools::graphicsPathFromB2DPolyPolygon( getPolyPolygonUnsafe(), bNoLineJoin ); mpPath->SetFillMode( const_cast(this)->getFillRule() == rendering::FillRule_EVEN_ODD ? Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding ); } diff --git a/canvas/source/directx/dx_linepolypolygon.hxx b/canvas/source/directx/dx_linepolypolygon.hxx index 431cd1b87b4f..3e061d76e768 100755 --- a/canvas/source/directx/dx_linepolypolygon.hxx +++ b/canvas/source/directx/dx_linepolypolygon.hxx @@ -45,7 +45,7 @@ namespace dxcanvas public: explicit LinePolyPolygon( const ::basegfx::B2DPolyPolygon& ); - GraphicsPathSharedPtr getGraphicsPath() const; + GraphicsPathSharedPtr getGraphicsPath( bool bNoLineJoin = false) const; private: // overridden, to clear mpPath diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index 9af540b889ea..8ea2ae453a97 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -275,10 +275,25 @@ namespace (getState( rParms.mrStates ).mapModeTransform * aWidth).getX(); // setup reasonable defaults - o_rStrokeAttributes.MiterLimit = 1.0; + o_rStrokeAttributes.MiterLimit = 15.0; // 1.0 was no good default; GDI+'s limit is 10.0, our's is 15.0 o_rStrokeAttributes.StartCapType = rendering::PathCapType::BUTT; o_rStrokeAttributes.EndCapType = rendering::PathCapType::BUTT; - o_rStrokeAttributes.JoinType = rendering::PathJoinType::MITER; + + switch(rLineInfo.GetLineJoin()) + { + default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE + o_rStrokeAttributes.JoinType = rendering::PathJoinType::NONE; + break; + case basegfx::B2DLINEJOIN_BEVEL: + o_rStrokeAttributes.JoinType = rendering::PathJoinType::BEVEL; + break; + case basegfx::B2DLINEJOIN_MITER: + o_rStrokeAttributes.JoinType = rendering::PathJoinType::MITER; + break; + case basegfx::B2DLINEJOIN_ROUND: + o_rStrokeAttributes.JoinType = rendering::PathJoinType::ROUND; + break; + } if( LINE_DASH == rLineInfo.GetStyle() ) { diff --git a/vcl/inc/vcl/cvtsvm.hxx b/vcl/inc/vcl/cvtsvm.hxx index 8a17015d99cf..cf4f3117a6ed 100644 --- a/vcl/inc/vcl/cvtsvm.hxx +++ b/vcl/inc/vcl/cvtsvm.hxx @@ -85,6 +85,8 @@ #define GDI_COMMENT_COMMENT 1031 #define GDI_UNICODE_COMMENT 1032 +#define GDI_LINEJOIN_ACTION 1033 + // ---------------- // - SVMConverter - // ---------------- diff --git a/vcl/inc/vcl/lineinfo.hxx b/vcl/inc/vcl/lineinfo.hxx index 60fdc3a3a0b0..a57513b2826b 100644 --- a/vcl/inc/vcl/lineinfo.hxx +++ b/vcl/inc/vcl/lineinfo.hxx @@ -32,9 +32,9 @@ #define _SV_LINEINFO_HXX #include - #include #include +#include // ---------------- // - ImplLineInfo - @@ -44,14 +44,16 @@ class SvStream; struct ImplLineInfo { - ULONG mnRefCount; - LineStyle meStyle; - long mnWidth; - USHORT mnDashCount; - long mnDashLen; - USHORT mnDotCount; - long mnDotLen; - long mnDistance; + ULONG mnRefCount; + LineStyle meStyle; + long mnWidth; + USHORT mnDashCount; + long mnDashLen; + USHORT mnDotCount; + long mnDotLen; + long mnDistance; + + basegfx::B2DLineJoin meLineJoin; ImplLineInfo(); ImplLineInfo( const ImplLineInfo& rImplLineInfo ); @@ -107,6 +109,9 @@ public: void SetDistance( long nDistance ); long GetDistance() const { return mpImplLineInfo->mnDistance; } + void SetLineJoin(basegfx::B2DLineJoin eLineJoin); + basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; } + BOOL IsDefault() const { return( !mpImplLineInfo->mnWidth && ( LINE_SOLID == mpImplLineInfo->meStyle ) ); } friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo ); diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index c1c02b673658..86d7d6bb39ee 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -483,6 +483,14 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } break; + case (GDI_LINEJOIN_ACTION) : + { + INT16 nLineJoin(0); + rIStm >> nLineJoin; + aLineInfo.SetLineJoin((basegfx::B2DLineJoin)nLineJoin); + } + break; + case( GDI_RECT_ACTION ): { ImplReadRect( rIStm, aRect ); @@ -1247,12 +1255,20 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { MetaLineAction* pAct = (MetaLineAction*) pAction; const LineInfo& rInfo = pAct->GetLineInfo(); - const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) ); + const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); + const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); if( bFatLine ) { ImplWritePushAction( rOStm ); ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() ); + + if(bLineJoin) + { + rOStm << (INT16) GDI_LINEJOIN_ACTION; + rOStm << (INT32) 6; + rOStm << (INT16) rInfo.GetLineJoin(); + } } rOStm << (INT16) GDI_LINE_ACTION; @@ -1265,6 +1281,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { ImplWritePopAction( rOStm ); nCount += 3; + + if(bLineJoin) + { + nCount += 1; + } } } break; @@ -1356,12 +1377,20 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, const Polygon& rPoly = pAct->GetPolygon(); const LineInfo& rInfo = pAct->GetLineInfo(); const USHORT nPoints = rPoly.GetSize(); - const BOOL bFatLine = ( !rInfo.IsDefault() && ( LINE_NONE != rInfo.GetStyle() ) ); + const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); + const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); if( bFatLine ) { ImplWritePushAction( rOStm ); ImplWriteLineColor( rOStm, rLineCol, 1, rInfo.GetWidth() ); + + if(bLineJoin) + { + rOStm << (INT16) GDI_LINEJOIN_ACTION; + rOStm << (INT32) 6; + rOStm << (INT16) rInfo.GetLineJoin(); + } } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1377,6 +1406,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { ImplWritePopAction( rOStm ); nCount += 3; + + if(bLineJoin) + { + nCount += 1; + } } } break; diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx index 98f16713a145..85a48f2b0f5e 100644 --- a/vcl/source/gdi/lineinfo.cxx +++ b/vcl/source/gdi/lineinfo.cxx @@ -49,7 +49,8 @@ ImplLineInfo::ImplLineInfo() : mnDashLen ( 0 ), mnDotCount ( 0 ), mnDotLen ( 0 ), - mnDistance ( 0 ) + mnDistance ( 0 ), + meLineJoin ( basegfx::B2DLINEJOIN_ROUND ) { } @@ -63,7 +64,8 @@ ImplLineInfo::ImplLineInfo( const ImplLineInfo& rImplLineInfo ) : mnDashLen ( rImplLineInfo.mnDashLen ), mnDotCount ( rImplLineInfo.mnDotCount ), mnDotLen ( rImplLineInfo.mnDotLen ), - mnDistance ( rImplLineInfo.mnDistance ) + mnDistance ( rImplLineInfo.mnDistance ), + meLineJoin ( rImplLineInfo.meLineJoin ) { } @@ -209,6 +211,19 @@ void LineInfo::SetDistance( long nDistance ) // ----------------------------------------------------------------------- +void LineInfo::SetLineJoin(basegfx::B2DLineJoin eLineJoin) +{ + DBG_CHKTHIS( LineInfo, NULL ); + + if(eLineJoin != mpImplLineInfo->meLineJoin) + { + ImplMakeUnique(); + mpImplLineInfo->meLineJoin = eLineJoin; + } +} + +// ----------------------------------------------------------------------- + SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) { VersionCompat aCompat( rIStm, STREAM_READ ); @@ -225,6 +240,12 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) rIStm >> rImplLineInfo.mnDistance; } + if( aCompat.GetVersion() >= 3 ) + { + // version 3 + rIStm >> nTmp16; rImplLineInfo.meLineJoin = (basegfx::B2DLineJoin) nTmp16; + } + return rIStm; } @@ -232,7 +253,7 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ) SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo ) { - VersionCompat aCompat( rOStm, STREAM_WRITE, 2 ); + VersionCompat aCompat( rOStm, STREAM_WRITE, 3 ); // version 1 rOStm << (UINT16) rImplLineInfo.meStyle << rImplLineInfo.mnWidth; @@ -242,6 +263,9 @@ SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo ) rOStm << rImplLineInfo.mnDotCount << rImplLineInfo.mnDotLen; rOStm << rImplLineInfo.mnDistance; + // since version3 + rOStm << (UINT16) rImplLineInfo.meLineJoin; + return rOStm; } diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 5b543258cb0b..e86256bc4830 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2541,7 +2541,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) && LINE_SOLID == rLineInfo.GetStyle()) { - DrawPolyLine(rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), basegfx::B2DLINEJOIN_ROUND); + DrawPolyLine(rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin()); return; } @@ -3042,7 +3042,12 @@ void OutputDevice::DrawPolyLine( SetFillColor(aOldLineColor); ImplInitFillColor(); - ImpDrawPolyPolygonWithB2DPolyPolygon(aAreaPolyPolygon); + // draw usig a loop; else the topology will paint a PolyPolygon + for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++) + { + ImpDrawPolyPolygonWithB2DPolyPolygon( + basegfx::B2DPolyPolygon(aAreaPolyPolygon.getB2DPolygon(a))); + } SetLineColor(aOldLineColor); ImplInitLineColor(); @@ -3059,14 +3064,16 @@ void OutputDevice::DrawPolyLine( } } } - - // fallback to old polygon drawing if needed. This will really - // use ImplLineConverter, but still try to AA lines - const Polygon aToolsPolygon( rB2DPolygon ); - LineInfo aLineInfo; - if( fLineWidth != 0.0 ) - aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); - ImpDrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo ); + else + { + // fallback to old polygon drawing if needed. This will really + // use ImplLineConverter, but still try to AA lines + const Polygon aToolsPolygon( rB2DPolygon ); + LineInfo aLineInfo; + if( fLineWidth != 0.0 ) + aLineInfo.SetWidth( static_cast(fLineWidth+0.5) ); + ImpDrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo ); + } } // ----------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salgdi_gdiplus.cxx b/vcl/win/source/gdi/salgdi_gdiplus.cxx index 5c00c786e22d..a9d346e74476 100644 --- a/vcl/win/source/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/source/gdi/salgdi_gdiplus.cxx @@ -62,9 +62,9 @@ // ----------------------------------------------------------------------- -void impAddB2DPolygonToGDIPlusGraphicsPath(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon) +void impAddB2DPolygonToGDIPlusGraphicsPathReal(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon, bool bNoLineJoin) { - const sal_uInt32 nCount(rPolygon.count()); + sal_uInt32 nCount(rPolygon.count()); if(nCount) { @@ -97,8 +97,58 @@ void impAddB2DPolygonToGDIPlusGraphicsPath(Gdiplus::GraphicsPath& rPath, const b if(a + 1 < nEdgeCount) { - aCurr = aNext; aFCurr = aFNext; + + if(bNoLineJoin) + { + rPath.StartFigure(); + } + } + } + } +} + +void impAddB2DPolygonToGDIPlusGraphicsPathInteger(Gdiplus::GraphicsPath& rPath, const basegfx::B2DPolygon& rPolygon, bool bNoLineJoin) +{ + sal_uInt32 nCount(rPolygon.count()); + + if(nCount) + { + const sal_uInt32 nEdgeCount(rPolygon.isClosed() ? nCount : nCount - 1); + const bool bControls(rPolygon.areControlPointsUsed()); + basegfx::B2DPoint aCurr(rPolygon.getB2DPoint(0)); + Gdiplus::Point aICurr(INT(aCurr.getX()), INT(aCurr.getY())); + + for(sal_uInt32 a(0); a < nEdgeCount; a++) + { + const sal_uInt32 nNextIndex((a + 1) % nCount); + const basegfx::B2DPoint aNext(rPolygon.getB2DPoint(nNextIndex)); + const Gdiplus::Point aINext(INT(aNext.getX()), INT(aNext.getY())); + + if(bControls && (rPolygon.isNextControlPointUsed(a) || rPolygon.isPrevControlPointUsed(nNextIndex))) + { + const basegfx::B2DPoint aCa(rPolygon.getNextControlPoint(a)); + const basegfx::B2DPoint aCb(rPolygon.getPrevControlPoint(nNextIndex)); + + rPath.AddBezier( + aICurr, + Gdiplus::Point(INT(aCa.getX()), INT(aCa.getY())), + Gdiplus::Point(INT(aCb.getX()), INT(aCb.getY())), + aINext); + } + else + { + rPath.AddLine(aICurr, aINext); + } + + if(a + 1 < nEdgeCount) + { + aICurr = aINext; + + if(bNoLineJoin) + { + rPath.StartFigure(); + } } } } @@ -123,7 +173,7 @@ bool WinSalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly aPath.StartFigure(); // #i101491# not needed for first run } - impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolyPolygon.getB2DPolygon(a)); + impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolyPolygon.getB2DPolygon(a), false); aPath.CloseFigure(); } @@ -152,11 +202,16 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas Gdiplus::Color aTestColor(255, SALCOLOR_RED(maLineColor), SALCOLOR_GREEN(maLineColor), SALCOLOR_BLUE(maLineColor)); Gdiplus::Pen aTestPen(aTestColor, Gdiplus::REAL(rLineWidths.getX())); Gdiplus::GraphicsPath aPath; + bool bNoLineJoin(false); switch(eLineJoin) { default : // basegfx::B2DLINEJOIN_NONE : { + if(basegfx::fTools::more(rLineWidths.getX(), 0.0)) + { + bNoLineJoin = true; + } break; } case basegfx::B2DLINEJOIN_BEVEL : @@ -179,7 +234,14 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas } } - impAddB2DPolygonToGDIPlusGraphicsPath(aPath, rPolygon); + if(nCount > 250 && basegfx::fTools::more(rLineWidths.getX(), 1.5)) + { + impAddB2DPolygonToGDIPlusGraphicsPathInteger(aPath, rPolygon, bNoLineJoin); + } + else + { + impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolygon, bNoLineJoin); + } if(rPolygon.isClosed()) { From 5b2480b968b3f375e0d9e43becb54c6897d0820d Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 15 Oct 2009 14:27:12 +0200 Subject: [PATCH 221/283] #i105655# commiting changes2 so far for preparing linux version --- basegfx/test/basegfx2d.cxx | 2 +- vcl/inc/vcl/outdev.hxx | 3 + vcl/source/gdi/implncvt.cxx | 577 ------------------------------ vcl/source/gdi/implncvt.hxx | 78 ---- vcl/source/gdi/makefile.mk | 1 - vcl/source/gdi/outdev.cxx | 256 ++++++++----- vcl/source/gdi/pdfwriter_impl.cxx | 4 +- vcl/source/gdi/salgdilayout.cxx | 1 - vcl/unx/source/gdi/salgdi.cxx | 3 + 9 files changed, 166 insertions(+), 759 deletions(-) delete mode 100644 vcl/source/gdi/implncvt.cxx delete mode 100644 vcl/source/gdi/implncvt.hxx diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index 8b732e465a51..07d6eb4c54e5 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -483,7 +483,7 @@ public: while ( nIndex >= 0 ); CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", - nCount==18); + nCount==50); const B2DPolygon aRect( tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) )); diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index f4e42846dd5e..f824151737d2 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -577,6 +577,9 @@ public: // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. Contains no AA check. SAL_DLLPRIVATE bool ImpTryDrawPolyLineDirect(const basegfx::B2DPolygon& rB2DPolygon, double fLineWidth, basegfx::B2DLineJoin eLineJoin); + // Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area) + void impPaintLineGeometryWithEvtlExpand(const LineInfo& rInfo, basegfx::B2DPolyPolygon aLinePolyPolygon); + protected: OutputDevice(); diff --git a/vcl/source/gdi/implncvt.cxx b/vcl/source/gdi/implncvt.cxx deleted file mode 100644 index e59fde15b5be..000000000000 --- a/vcl/source/gdi/implncvt.cxx +++ /dev/null @@ -1,577 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: implncvt.cxx,v $ - * $Revision: 1.10.136.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_vcl.hxx" -#include -#ifndef _SV_IMPLNCVT_HXX -#include "implncvt.hxx" -#endif - -// ----------- -// - Defines - -// ----------- - -#define CURVE_LEFT 1 -#define CURVE_RIGHT 2 -#define CURVE_STRAIGHTON 3 - -// ----------------- -// - ImplFloatPoint -// ----------------- - -struct ImplFloatPoint -{ - double fX; - double fY; - - inline ImplFloatPoint() {} - inline ImplFloatPoint( const Point& rPoint ) { fX = rPoint.X(); fY = rPoint.Y(); } - inline ImplFloatPoint( double _fX, double _fY ) { fX = _fX; fY = _fY; } - inline ImplFloatPoint( const ImplFloatPoint& rPoint ) { fX = rPoint.fX; fY = rPoint.fY; } - inline ~ImplFloatPoint() {} - - void operator+=( const ImplFloatPoint& rPoint ) { fX += rPoint.fX; fY += rPoint.fY; } - void operator-=( const ImplFloatPoint& rPoint ) { fX -= rPoint.fX; fY -= rPoint.fY; } - void operator*=( const double& rD ) { fX *= rD; fY *= rD; } - BOOL operator==( const ImplFloatPoint& rPoint ) const { return ( ( rPoint.fX == fX ) && ( rPoint.fY == fY ) ); } - void operator=( const Point& rPoint ) { fX = rPoint.X(); fY = rPoint.Y(); } - - ImplFloatPoint GetOVec( const ImplFloatPoint& rPoint ) const; - ImplFloatPoint GetNVec( const ImplFloatPoint& rPoint ) const; -}; - -// ----------------------------------------------------------------------------- - -ImplFloatPoint ImplFloatPoint::GetOVec( const ImplFloatPoint& rPoint ) const -{ - double fxt = rPoint.fX - fX; - double fyt = rPoint.fY - fY; - double fL; - - if( fyt != 0.0 ) - { - fyt = -fxt / fyt; - fL = sqrt( 1 + fyt * fyt ); - - return ImplFloatPoint( 1.0 / fL, fyt / fL ); - } - else - return ImplFloatPoint( fyt, ( fxt > 0.0 ) ? 1.0 : -1.0 ); -}; - -// ----------------------------------------------------------------------------- - -ImplFloatPoint ImplFloatPoint::GetNVec( const ImplFloatPoint& rPoint ) const -{ - const double fxt = rPoint.fX - fX; - const double fyt = rPoint.fY - fY; - const double fL = hypot( fxt, fyt ); - - return ImplFloatPoint( fxt / fL, fyt / fL ); -}; - -// -------------------- -// - ImplLineConverter -// -------------------- - -ImplLineConverter::ImplLineConverter( const Polygon& rPolygon, const LineInfo& rLineInfo, const Point* pRefPoint ) : - mbRefPoint ( FALSE ), - mfWidthHalf ( rLineInfo.GetWidth() >> 1 ), - maLineInfo ( rLineInfo ), - mpFloat0 ( new ImplFloatPoint[ 6 ] ), - mpFloat1 ( new ImplFloatPoint[ 6 ] ), - mnLines ( 0 ), - mpFloatPoint ( NULL ) -{ - UINT16 nIndex, nPolySize = rPolygon.GetSize(); - if ( nPolySize ) - { - if( rPolygon.GetFlags( 0 ) == POLY_NORMAL ) - { - mpFloatPoint = new ImplFloatPoint[ nPolySize ]; - mpFloatPoint[ 0 ] = rPolygon[ 0 ]; - - nIndex = 0; - - while( ++nIndex < nPolySize ) // doppelte Punkte eliminieren und ein FloatPointArray anlegen - { - if( rPolygon.GetFlags( nIndex ) == POLY_NORMAL ) - { - double nxt = mpFloatPoint[ mnLines ].fX; - double nyt = mpFloatPoint[ mnLines ].fY; - - if ( ( nxt == rPolygon[ nIndex ].X() ) && ( nyt == rPolygon[ nIndex ].Y() ) ) - continue; - - mpFloatPoint[ ++mnLines ] = rPolygon[ nIndex ]; - } - else - { - DBG_ERROR( "Bezier points not supported!" ); - } - } - mbClosed = ( mpFloatPoint[ 0 ] == mpFloatPoint[ mnLines ] ) ; - - if ( ( mnLines == 1 ) && ( maLineInfo.GetStyle() == LINE_DASH ) ) - { - BOOL bX = mpFloatPoint[ 0 ].fY == mpFloatPoint[ 1 ].fY; - BOOL bY = mpFloatPoint[ 0 ].fX == mpFloatPoint[ 1 ].fX; - mbRefPoint = pRefPoint && ( bX || bY ); - if ( mbRefPoint ) - { - if ( !maLineInfo.GetDashCount() ) - { - maLineInfo.SetDashCount( maLineInfo.GetDotCount() ); - maLineInfo.SetDashLen( maLineInfo.GetDotLen() ); - maLineInfo.SetDotCount( 0 ); - } - INT32 nDistance = maLineInfo.GetDistance(); - INT32 nDashLen = maLineInfo.GetDashCount() * ( maLineInfo.GetDashLen() + nDistance ); - INT32 nDotLen = maLineInfo.GetDotCount() * ( maLineInfo.GetDotLen() + nDistance ); - if ( bX ) - { - if ( mpFloatPoint[ 1 ].fX > mpFloatPoint[ 0 ].fX ) - { - ImplFloatPoint aFloat = mpFloatPoint[ 0 ]; - mpFloatPoint[ 0 ] = mpFloatPoint[ 1 ]; - mpFloatPoint[ 1 ] = aFloat; - } - mnRefDistance = (INT32)mpFloatPoint[ mnLines ].fX - pRefPoint->X(); - } - else - { - if ( mpFloatPoint[ 1 ].fY > mpFloatPoint[ 0 ].fY ) - { - ImplFloatPoint aFloat = mpFloatPoint[ 0 ]; - mpFloatPoint[ 0 ] = mpFloatPoint[ 1 ]; - mpFloatPoint[ 1 ] = aFloat; - } - mnRefDistance = (INT32)mpFloatPoint[ mnLines ].fY - pRefPoint->Y(); - } - -// mnRefDistance = ( (INT32)mpFloatPoint[ mnLines ].fX - pRefPoint->X() ) + -// ( (INT32)mpFloatPoint[ mnLines ].fY - pRefPoint->Y() ); - - mnRefDistance = mnRefDistance % ( nDashLen + nDotLen ); - if ( mnRefDistance < 0 ) - mnRefDistance = ( nDashLen + nDotLen ) + mnRefDistance; - } - } - } - } -}; - -//------------------------------------------------------------------------ - -ImplLineConverter::~ImplLineConverter() -{ - delete[] mpFloat0; - delete[] mpFloat1; - delete[] mpFloatPoint; -}; - -//------------------------------------------------------------------------ - -const Polygon* ImplLineConverter::ImplGetFirst() -{ - mnFloat1Points = 0; - mnLinesAvailable = mnLines; - - if ( mnLines ) - { - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - mfDashDotLenght = mnDashCount ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - - if ( mbRefPoint ) - { - INT32 nDistance = maLineInfo.GetDistance(); - INT32 nDashLen = maLineInfo.GetDashLen() + nDistance; - INT32 nDashesLen = maLineInfo.GetDashCount() * nDashLen; - INT32 nDotLen = maLineInfo.GetDotLen() + nDistance; - - if ( mnRefDistance >= nDashesLen ) - { - // get dotcount - if ( nDotLen ) - { - INT32 nLen = ( mnRefDistance - nDashesLen ) % nDotLen; - if ( nLen >= maLineInfo.GetDotLen() ) - { - mnDotCount -= 1 + ( mnRefDistance - nDashesLen ) / nDotLen; - if ( mnDotCount ) - mnDashCount = 0; - else - mnDotCount = maLineInfo.GetDotCount(); - mfDashDotLenght = 0.0; - mfDistanceLenght = ( maLineInfo.GetDotLen() + nDistance ) - nLen; - } - else - { - mnDashCount = 0; - mfDashDotLenght = maLineInfo.GetDotLen() - nLen; - mnDotCount -= ( mnRefDistance - nDashesLen ) / nDotLen; - } - } - } - else - { - if ( nDashLen ) - { - // get dashcount - INT32 nLen = mnRefDistance % nDashLen; - if ( nLen >= maLineInfo.GetDashLen() ) - { - mfDashDotLenght = 0.0; - mfDistanceLenght = ( maLineInfo.GetDashLen() + nDistance ) - nLen; - mnDashCount -= 1 + ( mnRefDistance / nDashLen ); - } - else - { - mfDashDotLenght = maLineInfo.GetDashLen() - nLen; - mnDashCount -= ( mnRefDistance / nDashLen ); - } - } - } - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - if ( ( mfDashDotLenght == 0.0 ) && ( mfDistanceLenght == 0.0 ) ) - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - } - return ImplGetNext(); -}; - -//------------------------------------------------------------------------ - -const Polygon* ImplLineConverter::ImplGetNext() -{ - while( mnFloat1Points || mnLinesAvailable ) - { - if ( maLineInfo.GetWidth() > 1 ) - { - if ( !mnFloat1Points ) - { - ImplFloatPoint aPointA( mpFloatPoint[ mnLinesAvailable-- ] ); - ImplFloatPoint aPointB( mpFloatPoint[ mnLinesAvailable ] ); - ImplFloatPoint aOVecAB( aPointA.GetOVec( aPointB ) ); - ImplFloatPoint aN1Vec( aPointA.GetNVec( aPointB ) ); - aN1Vec *= mfWidthHalf; - - if ( !mbClosed && ( ( mnLinesAvailable + 1 ) == mnLines ) ) - aPointA -= aN1Vec; - - aOVecAB *= mfWidthHalf; - mpFloat0[ 0 ] = aPointA; - mpFloat0[ 0 ] -= aOVecAB; - mpFloat0[ 3 ] = aPointA; - mpFloat0[ 3 ] += aOVecAB; - mpFloat0[ 1 ] = aPointB; - mpFloat0[ 1 ] -= aOVecAB; - mpFloat0[ 2 ] = aPointB; - mpFloat0[ 2 ] += aOVecAB; - - double f1D = ( aN1Vec.fX == 0 ) ? 1 : ( aN1Vec.fY / aN1Vec.fX ); - double f2D = -f1D; - - mnFloat0Points = 4; - - int nDirection; - - BOOL bContinues = ( mnLinesAvailable || mbClosed ); - if ( bContinues ) - { - ImplFloatPoint aPointC; - - if ( mnLinesAvailable ) - aPointC = mpFloatPoint[ mnLinesAvailable - 1 ]; - else - aPointC = mpFloatPoint[ mnLines - 1 ]; - - ImplFloatPoint aOVecBC( aPointB.GetOVec( aPointC ) ); - aOVecBC *= mfWidthHalf; - ImplFloatPoint aPointR0( aPointB ); - aPointR0 -= aOVecBC; - ImplFloatPoint aPointR1( aPointB ); - aPointR1 += aOVecBC; - ImplFloatPoint aN2Vec( aPointB.GetNVec( aPointC ) ); - aN2Vec *= mfWidthHalf; - - f2D = ( fabs( aN2Vec.fX ) < 0.00000001 ) ? 1 : ( aN2Vec.fY / aN2Vec.fX ); - if ( fabs( f1D - f2D ) < 0.00000001 ) - nDirection = CURVE_STRAIGHTON; - else - { - if ( ( aN1Vec.fX * aN2Vec.fY - aN1Vec.fY * aN2Vec.fX ) > 0 ) - nDirection = CURVE_LEFT; - else - nDirection = CURVE_RIGHT; - } - if ( nDirection != CURVE_STRAIGHTON ) - { - double fWidth; - ImplFloatPoint aDestPoint; - if ( hypot( aPointR0.fX - aPointA.fX, aPointR0.fY - aPointA.fY ) > hypot( aPointR1.fX - aPointA.fX, aPointR1.fY - aPointA.fY ) ) - aDestPoint = aPointR0; - else - aDestPoint = aPointR1; - - UINT16 nFirst = 0; - if ( aN1Vec.fY > 0 ) - { - if ( nDirection != CURVE_RIGHT ) - nFirst++; - } - else - { - if ( nDirection == CURVE_RIGHT ) - nFirst++; - } - fWidth = hypot( mpFloat0[ 1 + nFirst ].fX - aDestPoint.fX, mpFloat0[ 1 + nFirst ].fY - aDestPoint.fY ); - fWidth = sqrt( fWidth * fWidth / 2 ); - if ( fWidth > mfWidthHalf ) - { - // Spitzer Winkel : - mnFloat0Points = 6; - mpFloat0[ (4 + nFirst) ^ 1 ] = aDestPoint; - aDestPoint -= aN2Vec; - mpFloat0[ 4 + nFirst ] = aDestPoint; - mpFloat0[ 1 + nFirst ] += aN1Vec; - } - else - { - // Stumpferwinkel : Schnittpunkt wird berechnet - mnFloat0Points = 5; - ImplFloatPoint aSourcePoint; - double fX = 0; - double fY; - double fBDest = 0; - double fBSource = 0; - aSourcePoint = mpFloat0[ 1 + nFirst ]; - - int nValid = 0; - - if ( fabs( aN2Vec.fX ) < 0.00000001 ) - { - fX = aDestPoint.fX; - nValid = 1; - } - else - fBDest = aDestPoint.fY - ( aN2Vec.fY / aN2Vec.fX * aDestPoint.fX ); - - if ( fabs( aN1Vec.fX ) < 0.000000001 ) - { - fX = aSourcePoint.fX; - nValid = 2; - } - else - fBSource = aSourcePoint.fY - ( aN1Vec.fY / aN1Vec.fX * aSourcePoint.fX ); - - if ( !nValid ) - fX = ( fBSource - fBDest ) / ( aN2Vec.fY / aN2Vec.fX - aN1Vec.fY / aN1Vec.fX ); - if ( nValid < 2 ) - fY = aN1Vec.fY / aN1Vec.fX * fX + fBSource; - else - fY = aN2Vec.fY / aN2Vec.fX * fX + fBDest; - - mpFloat0[ 1 + nFirst ].fX = fX; - mpFloat0[ 1 + nFirst ].fY = fY; - mpFloat0[ 4 ] = aDestPoint; - } - } - else if ( ( aN1Vec.fX - aN2Vec.fX + aN1Vec.fY - aN2Vec.fY ) != 0 ) // besitzt zweiter Richtungsvektor die gleiche Steigung aber andere - bContinues = FALSE; // Richtung, dann wird hinten noch eine halbe Linienbreite angehaengt - } - if ( !bContinues ) - { - mpFloat0[ 1 ] += aN1Vec; - mpFloat0[ 2 ] += aN1Vec; - } - } - else - { - mnFloat0Points = mnFloat1Points; - ImplFloatPoint* pTemp = mpFloat1; - mpFloat1 = mpFloat0; - mpFloat0 = pTemp; - } - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - double fLenghtDone = 0; - double fLenght = ( mfDashDotLenght > 0.0 ) ? mfDashDotLenght : mfDistanceLenght; - - double fDistance; - - fDistance = hypot( mpFloat0[ 0 ].fX - mpFloat0[ 1 ].fX, mpFloat0[ 0 ].fY - mpFloat0[ 1 ].fY ); - if ( mnFloat0Points == 5 ) - { - double fDist = hypot( mpFloat0[ 2 ].fX - mpFloat0[ 3 ].fX, mpFloat0[ 2 ].fY - mpFloat0[ 3 ].fY ); - if ( fDist < fDistance ) - fDistance = fDist; - } - - if ( fDistance > fLenght ) - { - fLenghtDone = fLenght; - - ImplFloatPoint aNVec( mpFloat0[ 0 ].GetNVec( mpFloat0[ 1 ] ) ); - aNVec *= fLenght; - mnFloat1Points = mnFloat0Points; - ImplFloatPoint* pTemp = mpFloat1; - mpFloat1 = mpFloat0; - mpFloat0 = pTemp; - mnFloat0Points = 4; - mpFloat0[ 0 ] = mpFloat0[ 1 ] = mpFloat1[ 0 ]; - mpFloat0[ 1 ] += aNVec; - mpFloat0[ 2 ] = mpFloat0[ 3 ] = mpFloat1[ 3 ]; - mpFloat0[ 2 ] += aNVec; - - mpFloat1[ 0 ] = mpFloat0[ 1 ]; - mpFloat1[ 3 ] = mpFloat0[ 2 ]; - } - else - { - mnFloat1Points = 0; - fLenghtDone = fDistance; - } - - if ( mfDashDotLenght > 0.0 ) - { // Ein Dash oder Dot wurde erzeugt - mfDashDotLenght -= fLenghtDone; - if ( mfDashDotLenght == 0.0 ) - { // Komplett erzeugt - if ( mnDashCount ) - mnDashCount--; - else - mnDotCount--; - - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - else - { // Das erzeugte Polygon muessen wir ignorieren - mfDistanceLenght -= fLenghtDone; - if ( mfDistanceLenght == 0.0 ) - mfDashDotLenght = ( mnDashCount ) ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - continue; - } - } - maPolygon.SetSize( (UINT16)mnFloat0Points ); - UINT16 i = 0; - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 0 ].fX ), FRound( mpFloat0[ 0 ].fY ) ); - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 1 ].fX ), FRound( mpFloat0[ 1 ].fY ) ); - if ( mnFloat0Points > 4 ) - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 4 ].fX ), FRound( mpFloat0[ 4 ].fY ) ); - if ( mnFloat0Points > 5 ) - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 5 ].fX ), FRound( mpFloat0[ 5 ].fY ) ); - maPolygon[ i++ ] = Point( FRound( mpFloat0[ 2 ].fX ), FRound( mpFloat0[ 2 ].fY ) ); - maPolygon[ i ] = Point( FRound( mpFloat0[ 3 ].fX ), FRound( mpFloat0[ 3 ].fY ) ); - - } - else - { - if ( !mnFloat1Points ) - { - mpFloat0[ 0 ] = mpFloatPoint[ mnLinesAvailable-- ]; - mpFloat0[ 1 ] = mpFloatPoint[ mnLinesAvailable ]; - } - else - { - mpFloat0[ 0 ] = mpFloat1[ 0 ]; - mpFloat0[ 1 ] = mpFloat1[ 1 ]; - } - if ( maLineInfo.GetStyle() == LINE_DASH ) - { - double fLenghtDone = 0; - double fLenght = ( mfDashDotLenght > 0.0 ) ? mfDashDotLenght : mfDistanceLenght; - double fDistance; - fDistance = hypot( mpFloat0[ 0 ].fX - mpFloat0[ 1 ].fX, mpFloat0[ 0 ].fY - mpFloat0[ 1 ].fY ); - if ( fDistance > fLenght ) - { - fLenghtDone = fLenght; - ImplFloatPoint aNVec( mpFloat0[ 0 ].GetNVec( mpFloat0[ 1 ] ) ); - aNVec *= fLenght; - mpFloat1[ 1 ] = mpFloat0[ 1 ]; - mpFloat0[ 1 ] = mpFloat0[ 0 ]; - mpFloat0[ 1 ] += aNVec; - mpFloat1[ 0 ] = mpFloat0[ 1 ]; - mnFloat1Points = 2; - } - else - { - mnFloat1Points = 0; - fLenghtDone = fDistance; - } - if ( mfDashDotLenght > 0.0 ) - { // Ein Dash oder Dot wurde erzeugt - mfDashDotLenght -= fLenghtDone; - if ( mfDashDotLenght == 0.0 ) - { // Komplett erzeugt - if ( mnDashCount ) - mnDashCount--; - else - mnDotCount--; - - if ( ! ( mnDashCount | mnDotCount ) ) - { - mnDashCount = maLineInfo.GetDashCount(); - mnDotCount = maLineInfo.GetDotCount(); - } - mfDistanceLenght = maLineInfo.GetDistance(); - } - } - else - { // Das erzeugte Polygon muessen wir ignorieren - mfDistanceLenght -= fLenghtDone; - if ( mfDistanceLenght == 0.0 ) - mfDashDotLenght = ( mnDashCount ) ? maLineInfo.GetDashLen() : maLineInfo.GetDotLen(); - continue; - } - } - maPolygon.SetSize( 2 ); - maPolygon[ 0 ] = Point( (long)mpFloat0[ 0 ].fX, (long)mpFloat0[ 0 ].fY ); - maPolygon[ 1 ] = Point( (long)mpFloat0[ 1 ].fX, (long)mpFloat0[ 1 ].fY ); - } - return &maPolygon; - } - return NULL; -}; diff --git a/vcl/source/gdi/implncvt.hxx b/vcl/source/gdi/implncvt.hxx deleted file mode 100644 index 2d369d12f253..000000000000 --- a/vcl/source/gdi/implncvt.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: implncvt.hxx,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SV_LINECONV_HXX -#define _SV_LINECONV_HXX - -#include -#include - -// -------------------- -// - ImplLineConverter -// -------------------- - -struct ImplFloatPoint; - -class ImplLineConverter -{ - BOOL mbClosed; - BOOL mbRefPoint; - INT32 mnRefDistance; - - double mfWidthHalf; - LineInfo maLineInfo; - - double mfDashDotLenght; - double mfDistanceLenght; - - UINT32 mnDashCount; - UINT32 mnDotCount; - - Polygon maPolygon; - UINT32 mnFloat0Points; - ImplFloatPoint* mpFloat0; - UINT32 mnFloat1Points; - ImplFloatPoint* mpFloat1; - - UINT32 mnLinesAvailable; - UINT32 mnLines; - - ImplFloatPoint* mpFloatPoint; - - public: - - ImplLineConverter( const Polygon& rPoly, const LineInfo& rLineInfo, const Point* pRefPoint ); - ~ImplLineConverter(); - - const Polygon* ImplGetFirst(); - const Polygon* ImplGetNext(); -}; - -#endif diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index a09ae92dcb5e..bdc08118979a 100644 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -81,7 +81,6 @@ SLOFILES= $(SLO)$/salmisc.obj \ $(SLO)$/imagerepository.obj \ $(SLO)$/impprn.obj \ $(SLO)$/impvect.obj \ - $(SLO)$/implncvt.obj \ $(SLO)$/jobset.obj \ $(SLO)$/lineinfo.obj \ $(SLO)$/mapmod.obj \ diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index e86256bc4830..7352f5ed45d9 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -77,6 +76,8 @@ #include #include +#include + using namespace ::com::sun::star; DBG_NAME( OutputDevice ) @@ -2325,6 +2326,130 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt ) // ----------------------------------------------------------------------- +void OutputDevice::impPaintLineGeometryWithEvtlExpand( + const LineInfo& rInfo, + basegfx::B2DPolyPolygon aLinePolyPolygon) +{ + const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) + && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) + && ROP_OVERPAINT == GetRasterOp() + && IsLineColor()); + basegfx::B2DPolyPolygon aFillPolyPolygon; + const bool bDashUsed(LINE_DASH == rInfo.GetStyle()); + const bool bLineWidthUsed(rInfo.GetWidth() > 1); + + if(bDashUsed && aLinePolyPolygon.count()) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(rInfo.GetDashLen()); + const double fDotLen(rInfo.GetDotLen()); + const double fDistance(rInfo.GetDistance()); + + for(sal_uInt16 a(0); a < rInfo.GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } + + for(sal_uInt16 b(0); b < rInfo.GetDotCount(); b++) + { + fDotDashArray.push_back(fDotLen); + fDotDashArray.push_back(fDistance); + } + + const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + + if(fAccumulated > 0.0) + { + basegfx::B2DPolyPolygon aResult; + + for(sal_uInt32 c(0); c < aLinePolyPolygon.count(); c++) + { + basegfx::B2DPolyPolygon aLineTraget; + basegfx::tools::applyLineDashing( + aLinePolyPolygon.getB2DPolygon(c), + fDotDashArray, + &aLineTraget); + aResult.append(aLineTraget); + } + + aLinePolyPolygon = aResult; + } + } + + if(bLineWidthUsed && aLinePolyPolygon.count()) + { + const double fHalfLineWidth((rInfo.GetWidth() * 0.5) + 0.5); + + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + aFillPolyPolygon.append(basegfx::tools::createAreaGeometry( + aLinePolyPolygon.getB2DPolygon(a), + fHalfLineWidth, + rInfo.GetLineJoin())); + } + + aLinePolyPolygon.clear(); + } + + GDIMetaFile* pOldMetaFile = mpMetaFile; + mpMetaFile = NULL; + + if(aLinePolyPolygon.count()) + { + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + bool bDone(false); + + if(bTryAA) + { + bDone = mpGraphics->DrawPolyLine(aCandidate, basegfx::B2DVector(1.0, 1.0), basegfx::B2DLINEJOIN_NONE, this); + } + + if(!bDone) + { + const Polygon aPolygon(aCandidate); + mpGraphics->DrawPolyLine(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this); + } + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor( maLineColor ); + const Color aOldFillColor( maFillColor ); + + SetLineColor(); + ImplInitLineColor(); + SetFillColor( aOldLineColor ); + ImplInitFillColor(); + + bool bDone(false); + + if(bTryAA) + { + bDone = mpGraphics->DrawPolyPolygon(aFillPolyPolygon, 0.0, this); + } + + if(!bDone) + { + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + mpGraphics->DrawPolygon(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this); + } + } + + SetFillColor( aOldFillColor ); + SetLineColor( aOldLineColor ); + } + + mpMetaFile = pOldMetaFile; +} + +// ----------------------------------------------------------------------- + void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, const LineInfo& rLineInfo ) { @@ -2352,47 +2477,22 @@ void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt, if ( mbOutputClipped ) return; + const Point aStartPt( ImplLogicToDevicePixel( rStartPt ) ); + const Point aEndPt( ImplLogicToDevicePixel( rEndPt ) ); const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); + const bool bDashUsed(LINE_DASH == aInfo.GetStyle()); + const bool bLineWidthUsed(aInfo.GetWidth() > 1); - if( ( aInfo.GetWidth() > 1L ) || ( LINE_DASH == aInfo.GetStyle() ) ) + if(bDashUsed || bLineWidthUsed) { - Polygon aPoly( 2 ); aPoly[ 0 ] = rStartPt; aPoly[ 1 ] = rEndPt; - GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( ImplLogicToDevicePixel( aPoly ), aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); + basegfx::B2DPolygon aLinePolygon; + aLinePolygon.append(basegfx::B2DPoint(aStartPt.X(), aStartPt.Y())); + aLinePolygon.append(basegfx::B2DPoint(aEndPt.X(), aEndPt.Y())); - mpMetaFile = NULL; - - if ( aInfo.GetWidth() > 1 ) - { - const Color aOldLineColor( maLineColor ); - const Color aOldFillColor( maFillColor ); - - SetLineColor(); - ImplInitLineColor(); - SetFillColor( aOldLineColor ); - ImplInitFillColor(); - - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawPolygon( pPoly->GetSize(), (const SalPoint*) pPoly->GetConstPointAry(), this ); - - SetFillColor( aOldFillColor ); - SetLineColor( aOldLineColor ); - } - else - { - if ( mbInitLineColor ) - ImplInitLineColor(); - - for ( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawLine( (*pPoly)[ 0 ].X(), (*pPoly)[ 0 ].Y(), (*pPoly)[ 1 ].X(), (*pPoly)[ 1 ].Y(), this ); - } - mpMetaFile = pOldMetaFile; + impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aLinePolygon)); } else { - const Point aStartPt( ImplLogicToDevicePixel( rStartPt ) ); - const Point aEndPt( ImplLogicToDevicePixel( rEndPt ) ); - if ( mbInitLineColor ) ImplInitLineColor(); @@ -2553,7 +2653,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo) { - USHORT nPoints = rPoly.GetSize(); + const USHORT nPoints(rPoly.GetSize()); if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() ) return; @@ -2561,11 +2661,19 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI Polygon aPoly = ImplLogicToDevicePixel( rPoly ); // #100127# LineInfo is not curve-safe, subdivide always - if( aPoly.HasFlags() ) - { - aPoly = ImplSubdivideBezier( aPoly ); - nPoints = aPoly.GetSize(); - } + // + // What shall this mean? It's wrong to subdivide here when the + // polygon is a fat line. In that case, the painted geometry + // WILL be much different. + // I also have no idea how this could be related to the given ID + // which reads 'consolidate boost versions' in the task description. + // Removing. + // + //if( aPoly.HasFlags() ) + //{ + // aPoly = ImplSubdivideBezier( aPoly ); + // nPoints = aPoly.GetSize(); + //} // we need a graphics if ( !mpGraphics && !ImplGetGraphics() ) @@ -2577,67 +2685,20 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI if ( mbOutputClipped ) return; - const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); - const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW) - && mpGraphics->supportsOperation(OutDevSupport_B2DDraw) - && ROP_OVERPAINT == GetRasterOp() - && IsLineColor()); - - if( aInfo.GetWidth() > 1L ) - { - const Color aOldLineColor( maLineColor ); - const Color aOldFillColor( maFillColor ); - GDIMetaFile* pOldMetaFile = mpMetaFile; - ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); - - mpMetaFile = NULL; - SetLineColor(); + if ( mbInitLineColor ) ImplInitLineColor(); - SetFillColor( aOldLineColor ); - ImplInitFillColor(); - bool bDone(false); - if(bTryAA) - { - // #i101491# try AAed version - // Use old on-the-fly geometry preparation, combine with AA - bool bSuccess(true); + const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) ); + const bool bDashUsed(LINE_DASH == aInfo.GetStyle()); + const bool bLineWidthUsed(aInfo.GetWidth() > 1); - for(const Polygon* pPoly = aLineCvt.ImplGetFirst(); bSuccess && pPoly; pPoly = aLineCvt.ImplGetNext()) - { - bSuccess = mpGraphics->DrawPolyPolygon(basegfx::B2DPolyPolygon(pPoly->getB2DPolygon()), 0.0, this); - } - - if(bSuccess) - { - bDone = true; - } - } - - if(!bDone) - { - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - { - mpGraphics->DrawPolygon( pPoly->GetSize(), (const SalPoint*) pPoly->GetConstPointAry(), this ); - } - } - - SetLineColor( aOldLineColor ); - SetFillColor( aOldFillColor ); - mpMetaFile = pOldMetaFile; + if(bDashUsed || bLineWidthUsed) + { + impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aPoly.getB2DPolygon())); } else { - if ( mbInitLineColor ) - ImplInitLineColor(); - if ( LINE_DASH == aInfo.GetStyle() ) - { - ImplLineConverter aLineCvt( aPoly, aInfo, ( mbRefPoint ) ? &maRefPoint : NULL ); - for( const Polygon* pPoly = aLineCvt.ImplGetFirst(); pPoly; pPoly = aLineCvt.ImplGetNext() ) - mpGraphics->DrawPolyLine( pPoly->GetSize(), (const SalPoint*)pPoly->GetConstPointAry(), this ); - } - else - mpGraphics->DrawPolyLine( nPoints, (const SalPoint*) aPoly.GetConstPointAry(), this ); + mpGraphics->DrawPolyLine(nPoints, (const SalPoint*)aPoly.GetConstPointAry(), this); } if( mpAlphaVDev ) @@ -3066,8 +3127,7 @@ void OutputDevice::DrawPolyLine( } else { - // fallback to old polygon drawing if needed. This will really - // use ImplLineConverter, but still try to AA lines + // fallback to old polygon drawing if needed const Polygon aToolsPolygon( rB2DPolygon ); LineInfo aLineInfo; if( fLineWidth != 0.0 ) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2cbebf6f23e2..9d68b13553eb 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -61,11 +61,9 @@ #include #include #include - -#include "implncvt.hxx" - #include "cppuhelper/implbase1.hxx" #include +#include using namespace vcl; using namespace rtl; diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 1e9572887e0b..c1f987377c67 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index d140610f7875..e128b7d150fa 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1494,6 +1494,9 @@ bool X11SalGraphics::drawPolyLine(const ::basegfx::B2DPolygon& rPolygon, const : // the used basegfx::tools::createAreaGeometry is simply too // expensive with very big polygons; fallback to caller (who // should use ImplLineConverter normally) + // AW: ImplLineConverter had to be removed since it does not even + // know LineJoins, so the fallback will now prepare the line geometry + // the same way. return false; } const XRenderPeer& rRenderPeer = XRenderPeer::GetInstance(); From 8ec2ce18b769ea980fede28ef899a25f770c2f4d Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 15 Oct 2009 18:35:07 +0200 Subject: [PATCH 222/283] #i105731# sort printerlist --- vcl/source/src/print.src | 1 + 1 file changed, 1 insertion(+) diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 24c49bd6c80a..856ba88525fa 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -314,6 +314,7 @@ ModalDialog SV_DLG_PRINT Pos = MAP_APPFONT( 5, 5 ); Size = MAP_APPFONT( 100, 80 ); Border = TRUE; + Sort = TRUE; HelpText [en-US] = "Select the printer to print on."; }; CheckBox SV_PRINT_DETAILS_BTN From a06a509c4d7e03ec4bddbd1595c4e135a3355a9b Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Mon, 19 Oct 2009 14:46:44 +0200 Subject: [PATCH 223/283] #i105729# for convenience allow to modify disabled dependencies thereby automatically changing the dependent value appropriately --- vcl/inc/vcl/print.hxx | 12 ++++ vcl/inc/vcl/prndlg.hxx | 6 +- vcl/source/gdi/print3.cxx | 52 ++++++++++++++ vcl/source/window/printdlg.cxx | 119 +++++++++++++++++++++++++++++---- 4 files changed, 174 insertions(+), 15 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 563a603f1917..25ace16aea52 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -477,6 +477,18 @@ public: */ void enableUIOption( const rtl::OUString& rPropName, bool bEnable ); bool isUIOptionEnabled( const rtl::OUString& rPropName ) const; + /* returns the property name rPropName depends on or an empty string + if no dependency exists. + */ + rtl::OUString getDependency( const rtl::OUString& rPropName ) const; + /* makeEnabled will chage the property rPropName depends on to the value + that makes rPropName enabled. If the dependency itself is also disabled, + no action will be performed. + + returns the property name rPropName depends on or an empty string + if no change was made. + */ + rtl::OUString makeEnabled( const rtl::OUString& rPropName ); virtual int getPageCount() const = 0; // must be overloaded by the app /* get the page parameters, namely the jobsetup that should be active for the page diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index e905c0ecfe37..95dfef827b90 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -232,8 +232,10 @@ namespace vcl std::list< Window* > maControls; std::map< Window*, rtl::OUString > maControlToPropertyMap; - std::multimap< rtl::OUString, Window* > maPropertyToWindowMap; + std::map< rtl::OUString, std::vector< Window* > > + maPropertyToWindowMap; std::map< Window*, sal_Int32 > maControlToNumValMap; + std::set< rtl::OUString > maReverseDependencySet; Size maNupPortraitSize; Size maNupLandscapeSize; @@ -258,6 +260,8 @@ namespace vcl void updatePrinterText(); void checkControlDependencies(); void checkOptionalControlDependencies(); + void makeEnabled( Window* ); + void updateWindowFromProperty( const rtl::OUString& ); void setupOptionalUI(); void readFromSettings(); void storeToSettings(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 09728a5f5a14..6c56bba090ab 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1237,6 +1237,58 @@ bool PrinterController::isUIOptionEnabled( const rtl::OUString& i_rProperty ) co return bEnabled; } +rtl::OUString PrinterController::getDependency( const rtl::OUString& i_rProperty ) const +{ + rtl::OUString aDependency; + + vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it = + mpImplData->maControlDependencies.find( i_rProperty ); + if( it != mpImplData->maControlDependencies.end() ) + aDependency = it->second.maDependsOnName; + + return aDependency; +} + +rtl::OUString PrinterController::makeEnabled( const rtl::OUString& i_rProperty ) +{ + rtl::OUString aDependency; + + vcl::ImplPrinterControllerData::ControlDependencyMap::const_iterator it = + mpImplData->maControlDependencies.find( i_rProperty ); + if( it != mpImplData->maControlDependencies.end() ) + { + if( isUIOptionEnabled( it->second.maDependsOnName ) ) + { + aDependency = it->second.maDependsOnName; + const com::sun::star::beans::PropertyValue* pVal = getValue( aDependency ); + OSL_ENSURE( pVal, "unknown property in dependency" ); + if( pVal ) + { + sal_Int32 nDepVal = 0; + sal_Bool bDepVal = sal_False; + if( pVal->Value >>= nDepVal ) + { + if( it->second.mnDependsOnEntry != -1 ) + { + setValue( aDependency, makeAny( sal_Int32( it->second.mnDependsOnEntry ) ) ); + } + } + else if( pVal->Value >>= bDepVal ) + { + setValue( aDependency, makeAny( sal_Bool( it->second.mnDependsOnEntry != 0 ) ) ); + } + else + { + // if the type does not match something is awry + OSL_ENSURE( 0, "strange type in control dependency" ); + } + } + } + } + + return aDependency; +} + void PrinterController::setOptionChangeHdl( const Link& i_rHdl ) { mpImplData->maOptionChangeHdl = i_rHdl; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index c6ac00eba9e5..d4fe42ce3edb 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -334,7 +334,7 @@ PrintDialog::NUpTabPage::~NUpTabPage() void PrintDialog::NUpTabPage::enableNupControls( bool bEnable ) { - maNupPagesBox.Enable( bEnable ); + maNupPagesBox.Enable( TRUE ); maNupNumPagesTxt.Enable( bEnable ); maNupColEdt.Enable( bEnable ); maNupTimesTxt.Enable( bEnable ); @@ -1114,6 +1114,9 @@ void PrintDialog::setupOptionalUI() } } + // bUseDependencyRow should only be true if a dependency exists + bUseDependencyRow = bUseDependencyRow && (aDependsOnName.getLength() != 0); + // is it necessary to switch between static and dynamic pages ? bool bSwitchPage = false; if( aGroupingHint.getLength() ) @@ -1236,7 +1239,7 @@ void PrintDialog::setupOptionalUI() maNUpPage.maBrochureBtn.Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); maNUpPage.maBrochureBtn.SetToggleHdl( LINK( this, PrintDialog, ClickHdl ) ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, &maNUpPage.maBrochureBtn ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( &maNUpPage.maBrochureBtn ); maControlToPropertyMap[&maNUpPage.maBrochureBtn] = aPropertyName; aPropertyToDependencyRowMap.insert( std::pair< rtl::OUString, vcl::RowOrColumn* >( aPropertyName, maNUpPage.mxBrochureDep.get() ) ); @@ -1245,7 +1248,7 @@ void PrintDialog::setupOptionalUI() { vcl::RowOrColumn* pSaveCurColumn = pCurColumn; - if( bUseDependencyRow && aDependsOnName.getLength() ) + if( bUseDependencyRow ) { // find the correct dependency row (if any) std::pair< std::multimap< rtl::OUString, vcl::RowOrColumn* >::iterator, @@ -1261,6 +1264,7 @@ void PrintDialog::setupOptionalUI() if( aDepRange.first != aPropertyToDependencyRowMap.end() ) { pCurColumn = aDepRange.first->second; + maReverseDependencySet.insert( aPropertyName ); } } } @@ -1277,10 +1281,9 @@ void PrintDialog::setupOptionalUI() if( pVal ) pVal->Value >>= bVal; pNewBox->Check( bVal ); - pNewBox->Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != NULL ); pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pNewBox ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( pNewBox ); maControlToPropertyMap[pNewBox] = aPropertyName; // set help id @@ -1336,10 +1339,9 @@ void PrintDialog::setupOptionalUI() maControls.push_front( pBtn ); pBtn->SetText( aChoices[m] ); pBtn->Check( m == nSelectVal ); - pBtn->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) ); pBtn->Show(); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pBtn ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( pBtn ); maControlToPropertyMap[pBtn] = aPropertyName; maControlToNumValMap[pBtn] = m; @@ -1394,7 +1396,6 @@ void PrintDialog::setupOptionalUI() if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nSelectVal; pList->SelectEntryPos( static_cast(nSelectVal) ); - pList->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) ); pList->SetDropDownLineCount( static_cast(aChoices.getLength()) ); pList->Show(); @@ -1404,7 +1405,7 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pList, aHelpTexts, 0 ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pList ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( pList ); maControlToPropertyMap[pList] = aPropertyName; // finish the pair @@ -1429,8 +1430,6 @@ void PrintDialog::setupOptionalUI() if( pVal && pVal->Value.hasValue() ) pVal->Value >>= nCurVal; pField->SetValue( nCurVal ); - - pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -1439,7 +1438,7 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pField, aHelpTexts, 0 ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( pField ); maControlToPropertyMap[pField] = aPropertyName; // add to row @@ -1458,7 +1457,6 @@ void PrintDialog::setupOptionalUI() if( pVal && pVal->Value.hasValue() ) pVal->Value >>= aCurVal; pField->SetText( aCurVal ); - pField->Enable( maPController->isUIOptionEnabled( aPropertyName ) ); pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) ); pField->Show(); @@ -1467,7 +1465,7 @@ void PrintDialog::setupOptionalUI() // set help text setHelpText( pField, aHelpTexts, 0 ); - maPropertyToWindowMap.insert( std::pair< rtl::OUString, Window* >( aPropertyName, pField ) ); + maPropertyToWindowMap[ aPropertyName ].push_back( pField ); maControlToPropertyMap[pField] = aPropertyName; // add to row @@ -1486,6 +1484,9 @@ void PrintDialog::setupOptionalUI() } } + // update enable states + checkOptionalControlDependencies(); + // print range empty (currently math only) -> hide print range and spacer line if( maJobPage.mxPrintRange->countElements() == 0 ) { @@ -1608,6 +1609,24 @@ void PrintDialog::checkOptionalControlDependencies() it != maControlToPropertyMap.end(); ++it ) { bool bShouldbeEnabled = maPController->isUIOptionEnabled( it->second ); + if( ! bShouldbeEnabled ) + { + // enable controls that are directly attached to a dependency anyway + // if the normally disabled controls get modified, change the dependency + // so the control would be enabled + // example: in print range "Print All" is selected, "Page Range" is then of course + // not selected and the Edit for the Page Range would be disabled + // as a convenience we should enable the Edit anyway and automatically select + // "Page Range" instead of "Print All" if the Edit gets modified + if( maReverseDependencySet.find( it->second ) != maReverseDependencySet.end() ) + { + rtl::OUString aDep( maPController->getDependency( it->second ) ); + // if the dependency is at least enabled, then enable this control anyway + if( aDep.getLength() && maPController->isUIOptionEnabled( aDep ) ) + bShouldbeEnabled = true; + } + } + bool bIsEnabled = it->first->IsEnabled(); // Enable does not do a change check first, so can be less cheap than expected if( bShouldbeEnabled != bIsEnabled ) @@ -1888,6 +1907,8 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox*, pBox ) } else if( pBox == &maNUpPage.maNupPagesBox ) { + if( !maNUpPage.maPagesBtn.IsChecked() ) + maNUpPage.maPagesBtn.Check(); updateNupFromPages(); } @@ -2057,11 +2078,76 @@ PropertyValue* PrintDialog::getValueForWindow( Window* i_pWindow ) const return pVal; } +void PrintDialog::updateWindowFromProperty( const rtl::OUString& i_rProperty ) +{ + beans::PropertyValue* pValue = maPController->getValue( i_rProperty ); + std::map< rtl::OUString, std::vector< Window* > >::const_iterator it = maPropertyToWindowMap.find( i_rProperty ); + if( pValue && it != maPropertyToWindowMap.end() ) + { + const std::vector< Window* >& rWindows( it->second ); + if( ! rWindows.empty() ) + { + sal_Bool bVal = sal_False; + sal_Int32 nVal = -1; + if( pValue->Value >>= bVal ) + { + // we should have a CheckBox for this one + CheckBox* pBox = dynamic_cast< CheckBox* >( rWindows.front() ); + if( pBox ) + { + pBox->Check( bVal ); + } + else if( i_rProperty.equalsAscii( "PrintProspect" ) ) + { + // EVIL special case + if( bVal ) + maNUpPage.maBrochureBtn.Check(); + else + maNUpPage.maPagesBtn.Check(); + } + else + { + DBG_ASSERT( 0, "missing a checkbox" ); + } + } + else if( pValue->Value >>= nVal ) + { + // this could be a ListBox or a RadioButtonGroup + ListBox* pList = dynamic_cast< ListBox* >( rWindows.front() ); + if( pList ) + { + pList->SelectEntryPos( static_cast< USHORT >(nVal) ); + } + else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) ) + { + RadioButton* pBtn = dynamic_cast< RadioButton* >( rWindows[nVal] ); + DBG_ASSERT( pBtn, "unexpected control for property" ); + if( pBtn ) + pBtn->Check(); + } + } + } + } +} + +void PrintDialog::makeEnabled( Window* i_pWindow ) +{ + std::map< Window*, rtl::OUString >::const_iterator it = maControlToPropertyMap.find( i_pWindow ); + if( it != maControlToPropertyMap.end() ) + { + rtl::OUString aDependency( maPController->makeEnabled( it->second ) ); + if( aDependency.getLength() ) + updateWindowFromProperty( aDependency ); + } +} + IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox*, i_pBox ) { PropertyValue* pVal = getValueForWindow( i_pBox ); if( pVal ) { + makeEnabled( i_pBox ); + sal_Bool bVal = i_pBox->IsChecked(); pVal->Value <<= bVal; @@ -2084,6 +2170,7 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton*, i_pBtn ) std::map< Window*, sal_Int32 >::const_iterator it = maControlToNumValMap.find( i_pBtn ); if( pVal && it != maControlToNumValMap.end() ) { + makeEnabled( i_pBtn ); sal_Int32 nVal = it->second; pVal->Value <<= nVal; @@ -2102,6 +2189,8 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox*, i_pBox ) PropertyValue* pVal = getValueForWindow( i_pBox ); if( pVal ) { + makeEnabled( i_pBox ); + sal_Int32 nVal( i_pBox->GetSelectEntryPos() ); pVal->Value <<= nVal; @@ -2118,6 +2207,8 @@ IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit*, i_pBox ) PropertyValue* pVal = getValueForWindow( i_pBox ); if( pVal ) { + makeEnabled( i_pBox ); + NumericField* pNum = dynamic_cast(i_pBox); MetricField* pMetric = dynamic_cast(i_pBox); if( pNum ) From 88355430b706d2a16fef7ec237e22de946c869ae Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 22 Oct 2009 11:10:27 +0200 Subject: [PATCH 224/283] #i105655# most changes for MetaFile consumers done --- goodies/source/filter.vcl/epict/epict.cxx | 122 ++++++-- goodies/source/filter.vcl/epict/makefile.mk | 2 +- goodies/source/filter.vcl/eps/eps.cxx | 60 +++- svtools/source/filter.vcl/wmf/emfwr.cxx | 93 +++++- svtools/source/filter.vcl/wmf/emfwr.hxx | 4 + svtools/source/filter.vcl/wmf/wmfwr.cxx | 84 +++++- svtools/source/filter.vcl/wmf/wmfwr.hxx | 4 + svtools/util/makefile.mk | 1 + vcl/inc/vcl/cvtsvm.hxx | 2 + vcl/inc/vcl/lineinfo.hxx | 14 + vcl/source/gdi/cvtsvm.cxx | 310 ++++++++++++++++++-- vcl/source/gdi/lineinfo.cxx | 79 +++++ vcl/win/source/gdi/salgdi_gdiplus.cxx | 2 +- 13 files changed, 708 insertions(+), 69 deletions(-) diff --git a/goodies/source/filter.vcl/epict/epict.cxx b/goodies/source/filter.vcl/epict/epict.cxx index 4df7abea01fc..123aaa5e98c7 100644 --- a/goodies/source/filter.vcl/epict/epict.cxx +++ b/goodies/source/filter.vcl/epict/epict.cxx @@ -55,6 +55,9 @@ #include "dlgepct.hrc" #include "dlgepct.hxx" +#include +#include + //============================== PictWriter =================================== struct PictWriterAttrStackMember { @@ -77,7 +80,6 @@ struct PictPattern { sal_uInt32 nLo, nHi; }; - class PictWriter { private: @@ -178,6 +180,7 @@ private: void WriteTextArray(Point & rPoint, const String& rString, const sal_Int32 * pDXAry); + void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon); void WriteOpcodes(const GDIMetaFile & rMTF); void WriteHeader(const GDIMetaFile & rMTF); @@ -1371,6 +1374,65 @@ void PictWriter::WriteTextArray(Point & rPoint, const String& rString, const sal } } +void PictWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) +{ + if(rLinePolygon.count()) + { + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; + + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + aLinePolyPolygon = aLinePolyPolygon.getDefaultAdaptiveSubdivision(); + const sal_uInt32 nPolyCount(aLinePolyPolygon.count()); + SetAttrForFrame(); + + for(sal_uInt32 a(0); a < nPolyCount; a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + const sal_uInt32 nPointCount(aCandidate.count()); + + if(nPointCount) + { + const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount + 1 : nPointCount); + const basegfx::B2DPoint aCurr(aCandidate.getB2DPoint(0)); + Point nCurr(basegfx::fround(aCurr.getX()), basegfx::fround(aCurr.getY())); + + for(sal_uInt32 b(0); b < nEdgeCount; b++) + { + const sal_uInt32 nNextIndex((b + 1) % nPointCount); + const basegfx::B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex)); + const Point nNext(basegfx::fround(aNext.getX()), basegfx::fround(aNext.getY())); + + WriteOpcode_Line(nCurr, nNext); + nCurr = nNext; + } + } + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor(aLineColor); + const Color aOldFillColor(aFillColor); + + aLineColor = Color( COL_TRANSPARENT ); + aFillColor = aOldLineColor; + SetAttrForPaint(); + + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a).getDefaultAdaptiveSubdivision()); + WriteOpcode_Poly(PDM_PAINT, aPolygon); + } + + aLineColor = aOldLineColor; + aFillColor = aOldFillColor; + } + } +} void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) { @@ -1417,8 +1479,19 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) if( aLineColor != Color( COL_TRANSPARENT ) ) { - SetAttrForFrame(); - WriteOpcode_Line( pA->GetStartPoint(),pA->GetEndPoint() ); + if(pA->GetLineInfo().IsDefault()) + { + SetAttrForFrame(); + WriteOpcode_Line( pA->GetStartPoint(),pA->GetEndPoint() ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + } } break; } @@ -1571,24 +1644,35 @@ void PictWriter::WriteOpcodes( const GDIMetaFile & rMTF ) { const Polygon& rPoly = pA->GetPolygon(); - Polygon aSimplePoly; - if ( rPoly.HasFlags() ) - rPoly.GetSimple( aSimplePoly ); - else - aSimplePoly = rPoly; - - const USHORT nSize = aSimplePoly.GetSize(); - Point aLast; - - if ( nSize ) + if( rPoly.GetSize() ) { - SetAttrForFrame(); - aLast = aSimplePoly[0]; - - for ( USHORT i = 1; i < nSize; i++ ) + if(pA->GetLineInfo().IsDefault()) { - WriteOpcode_Line( aLast, aSimplePoly[i] ); - aLast = aSimplePoly[i]; + Polygon aSimplePoly; + if ( rPoly.HasFlags() ) + rPoly.GetSimple( aSimplePoly ); + else + aSimplePoly = rPoly; + + const USHORT nSize = aSimplePoly.GetSize(); + Point aLast; + + if ( nSize ) + { + SetAttrForFrame(); + aLast = aSimplePoly[0]; + + for ( USHORT i = 1; i < nSize; i++ ) + { + WriteOpcode_Line( aLast, aSimplePoly[i] ); + aLast = aSimplePoly[i]; + } + } + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); } } } diff --git a/goodies/source/filter.vcl/epict/makefile.mk b/goodies/source/filter.vcl/epict/makefile.mk index 33af96f1fb85..43a489dea78c 100644 --- a/goodies/source/filter.vcl/epict/makefile.mk +++ b/goodies/source/filter.vcl/epict/makefile.mk @@ -61,7 +61,7 @@ RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs SHL1TARGET= ept$(DLLPOSTFIX) SHL1IMPLIB= epict -SHL1STDLIBS= $(TOOLSLIB) $(VCLLIB) $(SVTOOLLIB) $(CPPULIB) $(SALLIB) +SHL1STDLIBS= $(TOOLSLIB) $(VCLLIB) $(SVTOOLLIB) $(CPPULIB) $(SALLIB) $(BASEGFXLIB) SHL1LIBS= $(SLB)$/epict.lib diff --git a/goodies/source/filter.vcl/eps/eps.cxx b/goodies/source/filter.vcl/eps/eps.cxx index 8a163659050a..b66c118dbf8a 100644 --- a/goodies/source/filter.vcl/eps/eps.cxx +++ b/goodies/source/filter.vcl/eps/eps.cxx @@ -701,7 +701,40 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, VirtualDevice& rVDev ) Polygon aPoly( ( (const MetaPolyLineAction*) pMA )->GetPolygon() ); const LineInfo& rLineInfo = ( ( const MetaPolyLineAction*)pMA )->GetLineInfo(); ImplWriteLineInfo( rLineInfo ); - ImplPolyLine( aPoly ); + + if(basegfx::B2DLINEJOIN_NONE == rLineInfo.GetLineJoin() + && rLineInfo.GetWidth() > 1) + { + // emulate B2DLINEJOIN_NONE by creating single edges + const sal_uInt16 nPoints(aPoly.GetSize()); + const bool bCurve(aPoly.HasFlags()); + + for(sal_uInt16 a(0); a + 1 < nPoints; a++) + { + if(bCurve + && POLY_NORMAL != aPoly.GetFlags(a + 1) + && a + 2 < nPoints + && POLY_NORMAL != aPoly.GetFlags(a + 2) + && a + 3 < nPoints) + { + const Polygon aSnippet(4, + aPoly.GetConstPointAry() + a, + aPoly.GetConstFlagAry() + a); + ImplPolyLine(aSnippet); + a += 2; + } + else + { + const Polygon aSnippet(2, + aPoly.GetConstPointAry() + a); + ImplPolyLine(aSnippet); + } + } + } + else + { + ImplPolyLine( aPoly ); + } } break; @@ -2343,8 +2376,29 @@ void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo ) SvtGraphicStroke::DashArray l_aDashArray; if ( rLineInfo.GetStyle() == LINE_DASH ) l_aDashArray.push_back( 2 ); - double fLWidth = ( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5; - ImplWriteLineInfo( fLWidth, 10.0, SvtGraphicStroke::capButt, SvtGraphicStroke::joinMiter, l_aDashArray ); + const double fLWidth(( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5); + const double fMiterLimit(15.0); + SvtGraphicStroke::JoinType aJoinType(SvtGraphicStroke::joinMiter); + + switch(rLineInfo.GetLineJoin()) + { + default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE + // do NOT use SvtGraphicStroke::joinNone here + // since it will be written as numerical value directly + // and is NOT a valid EPS value + break; + case basegfx::B2DLINEJOIN_MITER: + aJoinType = SvtGraphicStroke::joinMiter; + break; + case basegfx::B2DLINEJOIN_BEVEL: + aJoinType = SvtGraphicStroke::joinBevel; + break; + case basegfx::B2DLINEJOIN_ROUND: + aJoinType = SvtGraphicStroke::joinRound; + break; + } + + ImplWriteLineInfo( fLWidth, fMiterLimit, SvtGraphicStroke::capButt, aJoinType, l_aDashArray ); } //--------------------------------------------------------------------------------- diff --git a/svtools/source/filter.vcl/wmf/emfwr.cxx b/svtools/source/filter.vcl/wmf/emfwr.cxx index df56afc4a250..f516c2eefbd0 100644 --- a/svtools/source/filter.vcl/wmf/emfwr.cxx +++ b/svtools/source/filter.vcl/wmf/emfwr.cxx @@ -33,6 +33,8 @@ #include "emfwr.hxx" #include +#include +#include // ----------- // - Defines - @@ -829,6 +831,46 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const String rText, cons // ----------------------------------------------------------------------------- +void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) +{ + if(rLinePolygon.count()) + { + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; + + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + ImplWritePolygonRecord( Polygon(aCandidate), FALSE ); + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor(maVDev.GetLineColor()); + const Color aOldFillColor(maVDev.GetFillColor()); + + maVDev.SetLineColor(); + maVDev.SetFillColor(aOldLineColor); + + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + ImplWritePolyPolygonRecord(PolyPolygon(Polygon(aPolygon))); + } + + maVDev.SetLineColor(aOldLineColor); + maVDev.SetFillColor(aOldFillColor); + } + } +} + +// ----------------------------------------------------------------------------- + void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) { for( ULONG j = 0, nActionCount = rMtf.GetActionCount(); j < nActionCount; j++ ) @@ -871,20 +913,31 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) { const MetaLineAction* pA = (const MetaLineAction*) pAction; - ImplCheckLineAttr(); + if(pA->GetLineInfo().IsDefault()) + { + ImplCheckLineAttr(); - ImplBeginRecord( WIN_EMR_MOVETOEX ); - ImplWritePoint( pA->GetStartPoint() ); - ImplEndRecord(); + ImplBeginRecord( WIN_EMR_MOVETOEX ); + ImplWritePoint( pA->GetStartPoint() ); + ImplEndRecord(); - ImplBeginRecord( WIN_EMR_LINETO ); - ImplWritePoint( pA->GetEndPoint() ); - ImplEndRecord(); + ImplBeginRecord( WIN_EMR_LINETO ); + ImplWritePoint( pA->GetEndPoint() ); + ImplEndRecord(); - ImplBeginRecord( WIN_EMR_SETPIXELV ); - ImplWritePoint( pA->GetEndPoint() ); - ImplWriteColor( maVDev.GetLineColor() ); - ImplEndRecord(); + ImplBeginRecord( WIN_EMR_SETPIXELV ); + ImplWritePoint( pA->GetEndPoint() ); + ImplWriteColor( maVDev.GetLineColor() ); + ImplEndRecord(); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + } } } break; @@ -983,7 +1036,23 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case( META_POLYLINE_ACTION ): { if( maVDev.IsLineColor() ) - ImplWritePolygonRecord( ( (const MetaPolyLineAction*) pAction )->GetPolygon(), FALSE ); + { + const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction; + const Polygon& rPoly = pA->GetPolygon(); + + if( rPoly.GetSize() ) + { + if(pA->GetLineInfo().IsDefault()) + { + ImplWritePolygonRecord( rPoly, FALSE ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + Impl_handleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); + } + } + } } break; diff --git a/svtools/source/filter.vcl/wmf/emfwr.hxx b/svtools/source/filter.vcl/wmf/emfwr.hxx index 150aa1692ade..2d3c8801ba49 100644 --- a/svtools/source/filter.vcl/wmf/emfwr.hxx +++ b/svtools/source/filter.vcl/wmf/emfwr.hxx @@ -42,6 +42,9 @@ // - EMFWriter - // ------------- +class LineInfo; +namespace basegfx { class B2DPolygon; } + class EMFWriter { private: @@ -86,6 +89,7 @@ private: void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, UINT32 nROP ); void ImplWriteTextRecord( const Point& rPos, const String rText, const sal_Int32* pDXArray, sal_uInt32 nWidth ); + void Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon); void ImplWrite( const GDIMetaFile& rMtf ); public: diff --git a/svtools/source/filter.vcl/wmf/wmfwr.cxx b/svtools/source/filter.vcl/wmf/wmfwr.cxx index 3c3ca09692af..9b712e6f020c 100644 --- a/svtools/source/filter.vcl/wmf/wmfwr.cxx +++ b/svtools/source/filter.vcl/wmf/wmfwr.cxx @@ -42,8 +42,9 @@ #include //unicode::getUnicodeScriptType #endif - #include +#include +#include //====================== MS-Windows-defines =============================== @@ -1145,6 +1146,49 @@ void WMFWriter::SetAllAttr() } +void WMFWriter::HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon) +{ + if(rLinePolygon.count()) + { + basegfx::B2DPolyPolygon aLinePolyPolygon(rLinePolygon); + basegfx::B2DPolyPolygon aFillPolyPolygon; + + rInfo.applyToB2DPolyPolygon(aLinePolyPolygon, aFillPolyPolygon); + + if(aLinePolyPolygon.count()) + { + aSrcLineInfo = rInfo; + SetLineAndFillAttr(); + + for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a)); + WMFRecord_PolyLine(Polygon(aCandidate)); + } + } + + if(aFillPolyPolygon.count()) + { + const Color aOldLineColor(aSrcLineColor); + const Color aOldFillColor(aSrcFillColor); + + aSrcLineColor = Color( COL_TRANSPARENT ); + aSrcFillColor = aOldLineColor; + SetLineAndFillAttr(); + + for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++) + { + const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a)); + WMFRecord_Polygon(Polygon(aPolygon)); + } + + aSrcLineColor = aOldLineColor; + aSrcFillColor = aOldFillColor; + SetLineAndFillAttr(); + } + } +} + void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) { ULONG nA, nACount; @@ -1185,10 +1229,21 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) case META_LINE_ACTION: { const MetaLineAction* pA = (const MetaLineAction *) pMA; - aSrcLineInfo = pA->GetLineInfo(); - SetLineAndFillAttr(); - WMFRecord_MoveTo( pA->GetStartPoint() ); - WMFRecord_LineTo( pA->GetEndPoint() ); + if(pA->GetLineInfo().IsDefault()) + { + aSrcLineInfo = pA->GetLineInfo(); + SetLineAndFillAttr(); + WMFRecord_MoveTo( pA->GetStartPoint() ); + WMFRecord_LineTo( pA->GetEndPoint() ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + basegfx::B2DPolygon aPolygon; + aPolygon.append(basegfx::B2DPoint(pA->GetStartPoint().X(), pA->GetStartPoint().Y())); + aPolygon.append(basegfx::B2DPoint(pA->GetEndPoint().X(), pA->GetEndPoint().Y())); + HandleLineInfoPolyPolygons(pA->GetLineInfo(), aPolygon); + } } break; @@ -1250,9 +1305,22 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) case META_POLYLINE_ACTION: { const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pMA; - aSrcLineInfo = pA->GetLineInfo(); - SetLineAndFillAttr(); - WMFRecord_PolyLine( pA->GetPolygon() ); + const Polygon& rPoly = pA->GetPolygon(); + + if( rPoly.GetSize() ) + { + if(pA->GetLineInfo().IsDefault()) + { + aSrcLineInfo = pA->GetLineInfo(); + SetLineAndFillAttr(); + WMFRecord_PolyLine( rPoly ); + } + else + { + // LineInfo used; handle Dash/Dot and fat lines + HandleLineInfoPolyPolygons(pA->GetLineInfo(), rPoly.getB2DPolygon()); + } + } } break; diff --git a/svtools/source/filter.vcl/wmf/wmfwr.hxx b/svtools/source/filter.vcl/wmf/wmfwr.hxx index 48986a280404..03ca14e7633f 100644 --- a/svtools/source/filter.vcl/wmf/wmfwr.hxx +++ b/svtools/source/filter.vcl/wmf/wmfwr.hxx @@ -65,6 +65,9 @@ struct WMFWriterAttrStackMember // ------------- class StarSymbolToMSMultiFont; +class LineInfo; +namespace basegfx { class B2DPolygon; } + class WMFWriter { private: @@ -202,6 +205,7 @@ private: void SetLineAndFillAttr(); void SetAllAttr(); + void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon); void WriteRecords(const GDIMetaFile & rMTF); void WriteHeader(const GDIMetaFile & rMTF, BOOL bPlaceable); diff --git a/svtools/util/makefile.mk b/svtools/util/makefile.mk index 80596d23e866..e95c55706549 100644 --- a/svtools/util/makefile.mk +++ b/svtools/util/makefile.mk @@ -140,6 +140,7 @@ SHL1STDLIBS+= \ $(VCLLIB) \ $(SVLLIB) \ $(SOTLIB) \ + $(BASEGFXLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ $(I18NISOLANGLIB) \ diff --git a/vcl/inc/vcl/cvtsvm.hxx b/vcl/inc/vcl/cvtsvm.hxx index cf4f3117a6ed..c6f4f2c9a126 100644 --- a/vcl/inc/vcl/cvtsvm.hxx +++ b/vcl/inc/vcl/cvtsvm.hxx @@ -86,6 +86,8 @@ #define GDI_UNICODE_COMMENT 1032 #define GDI_LINEJOIN_ACTION 1033 +#define GDI_EXTENDEDPOLYGON_ACTION 1034 +#define GDI_LINEDASHDOT_ACTION 1035 // ---------------- // - SVMConverter - diff --git a/vcl/inc/vcl/lineinfo.hxx b/vcl/inc/vcl/lineinfo.hxx index a57513b2826b..33758046c41e 100644 --- a/vcl/inc/vcl/lineinfo.hxx +++ b/vcl/inc/vcl/lineinfo.hxx @@ -41,6 +41,7 @@ // ---------------- class SvStream; +namespace basegfx { class B2DPolyPolygon; } struct ImplLineInfo { @@ -116,6 +117,19 @@ public: friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo ); friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo ); + + // helper to check if line width or DashDot is used + bool isDashDotOrFatLineUsed() const; + + // helper to get decomposed polygon data with the LineInfo applied. The source + // hairline polygon is given in io_rLinePolyPolygon. Both given polygons may + // contain results; e.g. when no fat line but DasDot is defined, the resut will + // be in io_rLinePolyPolygon while o_rFillPolyPolygon will be empty. When fat line + // is defined, it will be vice-versa. If none is defined, io_rLinePolyPolygon will + // not be changed (but o_rFillPolyPolygon will be freed) + void applyToB2DPolyPolygon( + basegfx::B2DPolyPolygon& io_rLinePolyPolygon, + basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const; }; #endif // _SV_LINEINFO_HXX diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 86d7d6bb39ee..27ce6630116c 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -88,18 +88,6 @@ void ImplReadPoly( SvStream& rIStm, Polygon& rPoly ) // ------------------------------------------------------------------------ -void ImplWritePoly( SvStream& rOStm, const Polygon& rPoly ) -{ - INT32 nSize = rPoly.GetSize(); - - rOStm << nSize; - - for( INT32 i = 0; i < nSize; i++ ) - rOStm << rPoly[ (USHORT) i ]; -} - -// ------------------------------------------------------------------------ - void ImplReadPolyPoly( SvStream& rIStm, PolyPolygon& rPolyPoly ) { Polygon aPoly; @@ -131,13 +119,15 @@ void ImplWritePolyPolyAction( SvStream& rOStm, const PolyPolygon& rPolyPoly ) for( n = 0; n < nPoly; n++ ) { - const Polygon& rPoly = rPolyPoly[ n ]; - const USHORT nSize = rPoly.GetSize(); + // #i102224# + Polygon aSimplePoly; + rPolyPoly[n].AdaptiveSubdivide(aSimplePoly); + const USHORT nSize(aSimplePoly.GetSize()); rOStm << (INT32) nSize; for( USHORT j = 0; j < nSize; j++ ) - rOStm << rPoly[ j ]; + rOStm << aSimplePoly[ j ]; } } @@ -378,6 +368,128 @@ void ImplSkipActions( SvStream& rIStm, ULONG nSkipCount ) } } +// ------------------------------------------------------------------------ + +bool ImplWriteExtendedPolyPolygonAction(SvStream& rOStm, const PolyPolygon& rPolyPolygon, bool bOnlyWhenCurve) +{ + const sal_uInt16 nPolygonCount(rPolyPolygon.Count()); + + if(nPolygonCount) + { + sal_uInt32 nAllPolygonCount(0); + sal_uInt32 nAllPointCount(0); + sal_uInt32 nAllFlagCount(0); + sal_uInt16 a(0); + + for(a = 0; a < nPolygonCount; a++) + { + const Polygon& rCandidate = rPolyPolygon.GetObject(a); + const sal_uInt16 nPointCount(rCandidate.GetSize()); + + if(nPointCount) + { + nAllPolygonCount++; + nAllPointCount += nPointCount; + + if(rCandidate.HasFlags()) + { + nAllFlagCount += nPointCount; + } + } + } + + if((bOnlyWhenCurve && nAllFlagCount) || (!bOnlyWhenCurve && nAllPointCount)) + { + rOStm << (INT16) GDI_EXTENDEDPOLYGON_ACTION; + + const sal_Int32 nActionSize( + 4 + // Action size + 2 + // PolygonCount + (nAllPolygonCount * 2) + // Points per polygon + (nAllPointCount << 3) + // Points themselves + nAllPolygonCount + // Bool if (when poly has points) it has flags, too + nAllFlagCount); // Flags themselves + + rOStm << nActionSize; + rOStm << (sal_uInt16)nAllPolygonCount; + + for(a = 0; a < nPolygonCount; a++) + { + const Polygon& rCandidate = rPolyPolygon.GetObject(a); + const sal_uInt16 nPointCount(rCandidate.GetSize()); + + if(nPointCount) + { + rOStm << nPointCount; + + for(sal_uInt16 b(0); b < nPointCount; b++) + { + rOStm << rCandidate[b]; + } + + if(rCandidate.HasFlags()) + { + rOStm << (BYTE)true; + + for(sal_uInt16 c(0); c < nPointCount; c++) + { + rOStm << (BYTE)rCandidate.GetFlags(c); + } + } + else + { + rOStm << (BYTE)false; + } + } + } + + return true; + } + } + + return false; +} + +// ------------------------------------------------------------------------ + +void ImplReadExtendedPolyPolygonAction(SvStream& rIStm, PolyPolygon& rPolyPoly) +{ + rPolyPoly.Clear(); + sal_uInt16 nPolygonCount(0); + rIStm >> nPolygonCount; + + for(sal_uInt16 a(0); a < nPolygonCount; a++) + { + sal_uInt16 nPointCount(0); + rIStm >> nPointCount; + Polygon aCandidate(nPointCount); + + if(nPointCount) + { + for(sal_uInt16 b(0); b < nPointCount; b++) + { + rIStm >> aCandidate[b]; + } + + BYTE bHasFlags(false); + rIStm >> bHasFlags; + + if(bHasFlags) + { + BYTE aPolyFlags(0); + + for(sal_uInt16 c(0); c < nPointCount; c++) + { + rIStm >> aPolyFlags; + aCandidate.SetFlags(c, (PolyFlags)aPolyFlags); + } + } + } + + rPolyPoly.Insert(aCandidate); + } +} + // ---------------- // - SVMConverter - // ---------------- @@ -450,6 +562,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.SetPrefSize( aPrefSz ); rMtf.SetPrefMapMode( aMapMode ); + sal_uInt32 nLastPolygonAction(0); for( INT32 i = 0L; i < nActions; i++ ) { @@ -491,6 +604,91 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } break; + case (GDI_LINEDASHDOT_ACTION) : + { + INT16 a(0); + INT32 b(0); + + rIStm >> a; aLineInfo.SetDashCount(a); + rIStm >> b; aLineInfo.SetDashLen(b); + rIStm >> a; aLineInfo.SetDotCount(a); + rIStm >> b; aLineInfo.SetDotLen(b); + rIStm >> b; aLineInfo.SetDistance(b); + + if(((aLineInfo.GetDashCount() && aLineInfo.GetDashLen()) + || (aLineInfo.GetDotCount() && aLineInfo.GetDotLen())) + && aLineInfo.GetDistance()) + { + aLineInfo.SetStyle(LINE_DASH); + } + } + break; + + case (GDI_EXTENDEDPOLYGON_ACTION) : + { + // read the PolyPolygon in every case + PolyPolygon aInputPolyPolygon; + ImplReadExtendedPolyPolygonAction(rIStm, aInputPolyPolygon); + + // now check if it can be set somewhere + if(nLastPolygonAction < rMtf.GetActionCount()) + { + MetaPolyLineAction* pPolyLineAction = dynamic_cast< MetaPolyLineAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolyLineAction) + { + // replace MetaPolyLineAction when we have a single polygon. Do not rely on the + // same point count; the originally written GDI_POLYLINE_ACTION may have been + // Subdivided for better quality for older usages + if(1 == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolyLineAction( + aInputPolyPolygon.GetObject(0), + pPolyLineAction->GetLineInfo()), + nLastPolygonAction); + pPolyLineAction->Delete(); + } + } + else + { + MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast< MetaPolyPolygonAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolyPolygonAction) + { + // replace MetaPolyPolygonAction when we have a curved polygon. Do rely on the + // same sub-polygon count + if(pPolyPolygonAction->GetPolyPolygon().Count() == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolyPolygonAction( + aInputPolyPolygon), + nLastPolygonAction); + pPolyPolygonAction->Delete(); + } + } + else + { + MetaPolygonAction* pPolygonAction = dynamic_cast< MetaPolygonAction* >(rMtf.GetAction(nLastPolygonAction)); + + if(pPolygonAction) + { + // replace MetaPolygonAction + if(1 == aInputPolyPolygon.Count()) + { + rMtf.ReplaceAction( + new MetaPolygonAction( + aInputPolyPolygon.GetObject(0)), + nLastPolygonAction); + pPolygonAction->Delete(); + } + } + } + } + } + } + break; + case( GDI_RECT_ACTION ): { ImplReadRect( rIStm, aRect ); @@ -581,6 +779,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) case( GDI_POLYLINE_ACTION ): { ImplReadPoly( rIStm, aActionPoly ); + nLastPolygonAction = rMtf.GetActionCount(); if( bFatLine ) rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) ); @@ -602,7 +801,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) ); } else + { + nLastPolygonAction = rMtf.GetActionCount(); rMtf.AddAction( new MetaPolygonAction( aActionPoly ) ); + } } break; @@ -623,7 +825,10 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.AddAction( new MetaPolyLineAction( aPolyPoly[ nPoly ], aLineInfo ) ); } else + { + nLastPolygonAction = rMtf.GetActionCount(); rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) ); + } } break; @@ -1257,6 +1462,7 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, const LineInfo& rInfo = pAct->GetLineInfo(); const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); + const bool bLineDashDot(LINE_DASH == rInfo.GetStyle()); if( bFatLine ) { @@ -1269,6 +1475,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); + } } rOStm << (INT16) GDI_LINE_ACTION; @@ -1286,6 +1503,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + + if(bLineDashDot) + { + nCount += 1; + } } } break; @@ -1366,19 +1588,21 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, for( USHORT n = 0; n < nPoints; n++ ) rOStm << aChordPoly[ n ]; - nCount++; } break; case( META_POLYLINE_ACTION ): { + // #i102224# MetaPolyLineAction* pAct = (MetaPolyLineAction*) pAction; - const Polygon& rPoly = pAct->GetPolygon(); - const LineInfo& rInfo = pAct->GetLineInfo(); - const USHORT nPoints = rPoly.GetSize(); + Polygon aSimplePoly; + pAct->GetPolygon().AdaptiveSubdivide(aSimplePoly); + const LineInfo& rInfo = pAct->GetLineInfo(); + const USHORT nPoints(aSimplePoly.GetSize()); const bool bFatLine(!rInfo.IsDefault() && (LINE_NONE != rInfo.GetStyle())); const bool bLineJoin(bFatLine && basegfx::B2DLINEJOIN_ROUND != rInfo.GetLineJoin()); + const bool bLineDashDot(LINE_DASH == rInfo.GetStyle()); if( bFatLine ) { @@ -1391,6 +1615,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); + } } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1398,10 +1633,18 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) nPoints; for( USHORT n = 0; n < nPoints; n++ ) - rOStm << rPoly[ n ]; + { + rOStm << aSimplePoly[ n ]; + } nCount++; + const PolyPolygon aPolyPolygon(pAct->GetPolygon()); + if(ImplWriteExtendedPolyPolygonAction(rOStm, aPolyPolygon, true)) + { + nCount++; + } + if( bFatLine ) { ImplWritePopAction( rOStm ); @@ -1411,24 +1654,36 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + + if(bLineDashDot) + { + nCount += 1; + } } } break; case( META_POLYGON_ACTION ): { - MetaPolygonAction* pAct = (MetaPolygonAction*) pAction; - const Polygon& rPoly = pAct->GetPolygon(); - const USHORT nPoints = rPoly.GetSize(); + // #i102224# + MetaPolygonAction* pAct = (MetaPolygonAction*)pAction; + Polygon aSimplePoly; + pAct->GetPolygon().AdaptiveSubdivide(aSimplePoly); + const USHORT nPoints(aSimplePoly.GetSize()); rOStm << (INT16) GDI_POLYGON_ACTION; rOStm << (INT32) ( 8 + ( nPoints << 3 ) ); rOStm << (INT32) nPoints; for( USHORT n = 0; n < nPoints; n++ ) - rOStm << rPoly[ n ]; - + rOStm << aSimplePoly[ n ]; nCount++; + + const PolyPolygon aPolyPolygon(pAct->GetPolygon()); + if(ImplWriteExtendedPolyPolygonAction(rOStm, aPolyPolygon, true)) + { + nCount++; + } } break; @@ -1437,6 +1692,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, MetaPolyPolygonAction* pAct = (MetaPolyPolygonAction*) pAction; ImplWritePolyPolyAction( rOStm, pAct->GetPolyPolygon() ); nCount++; + + if(ImplWriteExtendedPolyPolygonAction(rOStm, pAct->GetPolyPolygon(), true)) + { + nCount++; + } } break; diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx index 85a48f2b0f5e..7aa50811106b 100644 --- a/vcl/source/gdi/lineinfo.cxx +++ b/vcl/source/gdi/lineinfo.cxx @@ -34,6 +34,10 @@ #include #include #include +#include +#include +#include +#include DBG_NAME( LineInfo ) @@ -283,3 +287,78 @@ SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo ) { return( rOStm << *rLineInfo.mpImplLineInfo ); } + +// ----------------------------------------------------------------------- + +bool LineInfo::isDashDotOrFatLineUsed() const +{ + return (LINE_DASH == GetStyle() || GetWidth() > 1); +} + +// ----------------------------------------------------------------------- + +void LineInfo::applyToB2DPolyPolygon( + basegfx::B2DPolyPolygon& io_rLinePolyPolygon, + basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const +{ + o_rFillPolyPolygon.clear(); + + if(io_rLinePolyPolygon.count()) + { + if(LINE_DASH == GetStyle()) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(GetDashLen()); + const double fDotLen(GetDotLen()); + const double fDistance(GetDistance()); + + for(sal_uInt16 a(0); a < GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } + + for(sal_uInt16 b(0); b < GetDotCount(); b++) + { + fDotDashArray.push_back(fDotLen); + fDotDashArray.push_back(fDistance); + } + + const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + + if(fAccumulated > 0.0) + { + basegfx::B2DPolyPolygon aResult; + + for(sal_uInt32 c(0); c < io_rLinePolyPolygon.count(); c++) + { + basegfx::B2DPolyPolygon aLineTraget; + basegfx::tools::applyLineDashing( + io_rLinePolyPolygon.getB2DPolygon(c), + fDotDashArray, + &aLineTraget); + aResult.append(aLineTraget); + } + + io_rLinePolyPolygon = aResult; + } + } + + if(GetWidth() > 1 && io_rLinePolyPolygon.count()) + { + const double fHalfLineWidth((GetWidth() * 0.5) + 0.5); + + for(sal_uInt32 a(0); a < io_rLinePolyPolygon.count(); a++) + { + o_rFillPolyPolygon.append(basegfx::tools::createAreaGeometry( + io_rLinePolyPolygon.getB2DPolygon(a), + fHalfLineWidth, + GetLineJoin())); + } + + io_rLinePolyPolygon.clear(); + } + } +} + +// ----------------------------------------------------------------------- diff --git a/vcl/win/source/gdi/salgdi_gdiplus.cxx b/vcl/win/source/gdi/salgdi_gdiplus.cxx index a9d346e74476..29e4ff1d801e 100644 --- a/vcl/win/source/gdi/salgdi_gdiplus.cxx +++ b/vcl/win/source/gdi/salgdi_gdiplus.cxx @@ -243,7 +243,7 @@ bool WinSalGraphics::drawPolyLine(const basegfx::B2DPolygon& rPolygon, const bas impAddB2DPolygonToGDIPlusGraphicsPathReal(aPath, rPolygon, bNoLineJoin); } - if(rPolygon.isClosed()) + if(rPolygon.isClosed() && !bNoLineJoin) { // #i101491# needed to create the correct line joins aPath.CloseFigure(); From 5de3269dcd48cd653837de3d576d7be3df679927 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 22 Oct 2009 13:19:51 +0200 Subject: [PATCH 225/283] #i105655# Last MetaFile changes; moved GDI_LINEDASHDOT_ACTION to the more common part in SVM export to also have it available for non-fat lines --- vcl/source/gdi/cvtsvm.cxx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 27ce6630116c..07b1a391adf4 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -1615,17 +1615,17 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm << (INT32) 6; rOStm << (INT16) rInfo.GetLineJoin(); } + } - if(bLineDashDot) - { - rOStm << (INT16) GDI_LINEDASHDOT_ACTION; - rOStm << (INT32) 4 + 16; - rOStm << (INT16)rInfo.GetDashCount(); - rOStm << (INT32)rInfo.GetDashLen(); - rOStm << (INT16)rInfo.GetDotCount(); - rOStm << (INT32)rInfo.GetDotLen(); - rOStm << (INT32)rInfo.GetDistance(); - } + if(bLineDashDot) + { + rOStm << (INT16) GDI_LINEDASHDOT_ACTION; + rOStm << (INT32) 4 + 16; + rOStm << (INT16)rInfo.GetDashCount(); + rOStm << (INT32)rInfo.GetDashLen(); + rOStm << (INT16)rInfo.GetDotCount(); + rOStm << (INT32)rInfo.GetDotLen(); + rOStm << (INT32)rInfo.GetDistance(); } rOStm << (INT16) GDI_POLYLINE_ACTION; @@ -1654,11 +1654,11 @@ ULONG SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, { nCount += 1; } + } - if(bLineDashDot) - { - nCount += 1; - } + if(bLineDashDot) + { + nCount += 1; } } break; From b14f33317528b0d3b44f5d24fbfb15a26cebb531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Sch=C3=B6nheit?= Date: Fri, 23 Oct 2009 12:10:07 +0200 Subject: [PATCH 226/283] #i106184# introduce a 'VerticalAlign' property for edit-like form controls --- svtools/source/control/filectrl.cxx | 3 + svtools/source/uno/unoiface.cxx | 80 -------------------- toolkit/source/awt/vclxwindows.cxx | 6 ++ toolkit/source/controls/formattedcontrol.cxx | 1 + toolkit/source/controls/unocontrols.cxx | 2 + vcl/inc/vcl/edit.hxx | 1 + vcl/source/control/edit.cxx | 21 +++-- 7 files changed, 28 insertions(+), 86 deletions(-) diff --git a/svtools/source/control/filectrl.cxx b/svtools/source/control/filectrl.cxx index d820dce097ed..f00cf45be0e6 100644 --- a/svtools/source/control/filectrl.cxx +++ b/svtools/source/control/filectrl.cxx @@ -78,6 +78,9 @@ WinBits FileControl::ImplInitStyle( WinBits nStyle ) maButton.SetStyle( (maButton.GetStyle()|WB_NOTABSTOP)&(~WB_TABSTOP) ); } + const WinBits nAlignmentStyle = ( WB_TOP | WB_VCENTER | WB_BOTTOM ); + maEdit.SetStyle( ( maEdit.GetStyle() & ~nAlignmentStyle ) | ( nStyle & nAlignmentStyle ) ); + if ( !(nStyle & WB_NOGROUP) ) nStyle |= WB_GROUP; diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index 54cc448ff89e..b4772f755452 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -551,86 +551,6 @@ void VCLXMultiLineEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) VCLXWindow::ImplGetPropertyIds( rIds, true ); } -// ---------------------------------------------------- -// class VCLXFileDialog -// ---------------------------------------------------- -/* -VCLXFileDialog::VCLXFileDialog() -{ -} - -VCLXFileDialog::~VCLXFileDialog() -{ -} - -::com::sun::star::uno::Any VCLXFileDialog::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::XXX*, this ) ); - return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); -} - -// ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( VCLXFileDialog ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XXX>* ) NULL ) -IMPL_XTYPEPROVIDER_END - -void VCLXFileDialog::setPath( const ::rtl::OUString& rPath ) -{ - ::vos::OGuard aGuard( GetMutex() ); - - FileDialog* pDlg = (FileDialog*)GetWindow(); - if ( pDlg ) - pDlg->SetPath( ::rtl::OUStringToOString( rPath, CHARSET_SYSTEM ) ); -} - -::rtl::OUString VCLXFileDialog::getPath() -{ - ::vos::OGuard aGuard( GetMutex() ); - - ::rtl::OUString aPath; - FileDialog* pDlg = (FileDialog*)GetWindow(); - if ( pDlg ) - aPath = StringToOUString( pDlg->GetPath(), CHARSET_SYSTEM ); - return aPath; -} - -void VCLXFileDialog::setFilters( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& rFilterNames, const ::com::sun::star::uno::Sequence< ::rtl::OUString>& rMasks ) -{ - ::vos::OGuard aGuard( GetMutex() ); - - FileDialog* pDlg = (FileDialog*)GetWindow(); - if ( pDlg ) - { - sal_uInt32 nFlts = rFilterNames.getLength(); - for ( sal_uInt32 n = 0; n < nFlts; n++ ) - pDlg->AddFilter( - ::rtl::OUStringToOString( rFilterNames.getConstArray()[n], CHARSET_SYSTEM ), - ::rtl::OUStringToOString( rMasks.getConstArray()[n], CHARSET_SYSTEM ) ); - } -} - -void VCLXFileDialog::setCurrentFilter( const ::rtl::OUString& rFilterName ) -{ - ::vos::OGuard aGuard( GetMutex() ); - - FileDialog* pDlg = (FileDialog*)GetWindow(); - if ( pDlg ) - pDlg->SetCurFilter( ::rtl::OUStringToOString( rFilterName, CHARSET_SYSTEM ) ); -} - -::rtl::OUString VCLXFileDialog::getCurrentFilter() -{ - ::vos::OGuard aGuard( GetMutex() ); - - ::rtl::OUString aFilter; - FileDialog* pDlg = (FileDialog*)GetWindow(); - if ( pDlg ) - aFilter = StringToOUString( pDlg->GetCurFilter(), CHARSET_SYSTEM ); - return aFilter; -} -*/ - // ---------------------------------------------------- // class VCLXFileControl // ---------------------------------------------------- diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index b49fa1a621d6..c44745c4c2de 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -3388,6 +3388,7 @@ void VCLXEdit::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_PAINTTRANSPARENT, BASEPROPERTY_AUTOHSCROLL, BASEPROPERTY_AUTOVSCROLL, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, 0); @@ -4280,6 +4281,7 @@ void VCLXDateField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_ENFORCE_FORMAT, BASEPROPERTY_TEXT, BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, @@ -4621,6 +4623,7 @@ void VCLXTimeField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_ENFORCE_FORMAT, BASEPROPERTY_TEXT, BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, @@ -4924,6 +4927,7 @@ void VCLXNumericField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VALUE_DOUBLE, BASEPROPERTY_ENFORCE_FORMAT, BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, @@ -5518,6 +5522,7 @@ void VCLXCurrencyField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_VALUE_DOUBLE, BASEPROPERTY_ENFORCE_FORMAT, BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, @@ -5865,6 +5870,7 @@ void VCLXPatternField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_TABSTOP, BASEPROPERTY_TEXT, BASEPROPERTY_HIDEINACTIVESELECTION, + BASEPROPERTY_VERTICALALIGN, BASEPROPERTY_WRITING_MODE, BASEPROPERTY_CONTEXT_WRITING_MODE, BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR, diff --git a/toolkit/source/controls/formattedcontrol.cxx b/toolkit/source/controls/formattedcontrol.cxx index 6171067f1185..5ac7a0237479 100644 --- a/toolkit/source/controls/formattedcontrol.cxx +++ b/toolkit/source/controls/formattedcontrol.cxx @@ -160,6 +160,7 @@ namespace toolkit ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR ); ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); ImplRegisterProperty( BASEPROPERTY_ENFORCE_FORMAT ); + ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); ImplRegisterProperty( BASEPROPERTY_WRITING_MODE ); ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE ); ImplRegisterProperty( BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR ); diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index 3abacef7b67f..9e508c884f59 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -476,6 +476,7 @@ void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) t // ---------------------------------------------------- UnoControlFileControlModel::UnoControlFileControlModel() { + ImplRegisterProperty( BASEPROPERTY_ALIGN ); ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); @@ -489,6 +490,7 @@ UnoControlFileControlModel::UnoControlFileControlModel() ImplRegisterProperty( BASEPROPERTY_READONLY ); ImplRegisterProperty( BASEPROPERTY_TABSTOP ); ImplRegisterProperty( BASEPROPERTY_TEXT ); + ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); ImplRegisterProperty( BASEPROPERTY_WRITING_MODE ); ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE ); ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); diff --git a/vcl/inc/vcl/edit.hxx b/vcl/inc/vcl/edit.hxx index 534d63b3427c..bb7d965503d2 100644 --- a/vcl/inc/vcl/edit.hxx +++ b/vcl/inc/vcl/edit.hxx @@ -120,6 +120,7 @@ private: SAL_DLLPRIVATE void ImplCopy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); SAL_DLLPRIVATE void ImplPaste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); SAL_DLLPRIVATE long ImplGetExtraOffset() const; + SAL_DLLPRIVATE long ImplGetTextYPosition() const; SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker() const; SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 5f41a441c6a1..3a5f9014e27a 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -492,6 +492,17 @@ void Edit::ImplInvalidateOrRepaint( xub_StrLen nStart, xub_StrLen nEnd ) // ----------------------------------------------------------------------- +long Edit::ImplGetTextYPosition() const +{ + if ( GetStyle() & WB_TOP ) + return ImplGetExtraOffset(); + else if ( GetStyle() & WB_BOTTOM ) + return GetOutputSizePixel().Height() - GetTextHeight() - ImplGetExtraOffset(); + return ( GetOutputSizePixel().Height() - GetTextHeight() ) / 2; +} + +// ----------------------------------------------------------------------- + void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout ) { if ( !IsReallyVisible() ) @@ -516,10 +527,8 @@ void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout ) GetCaretPositions( aText, pDX, nStart, nEnd ); } - // center vertically - long nH = GetOutputSize().Height(); long nTH = GetTextHeight(); - Point aPos( mnXOffset, (nH-nTH)/2 ); + Point aPos( mnXOffset, ImplGetTextYPosition() ); if( bLayout ) { @@ -1193,7 +1202,7 @@ void Edit::ImplShowCursor( BOOL bOnlyIfVisible ) long nCursorPosX = nTextPos + mnXOffset + ImplGetExtraOffset(); // Cursor muss im sichtbaren Bereich landen: - Size aOutSize = GetOutputSizePixel(); + const Size aOutSize = GetOutputSizePixel(); if ( (nCursorPosX < 0) || (nCursorPosX >= aOutSize.Width()) ) { long nOldXOffset = mnXOffset; @@ -1227,8 +1236,8 @@ void Edit::ImplShowCursor( BOOL bOnlyIfVisible ) ImplInvalidateOrRepaint(); } - long nTextHeight = GetTextHeight(); - long nCursorPosY = (aOutSize.Height()-nTextHeight) / 2; + const long nTextHeight = GetTextHeight(); + const long nCursorPosY = ImplGetTextYPosition(); pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) ); pCursor->SetSize( Size( nCursorWidth, nTextHeight ) ); pCursor->Show(); From ba9a8c89c5ad8e9f9cafd1ebccb87c010a0949b2 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 29 Oct 2009 12:50:25 +0100 Subject: [PATCH 227/283] #i106427# fill in page range --- vcl/source/gdi/print3.cxx | 45 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 6c56bba090ab..609fe5ad339b 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -322,6 +322,21 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr // reset last page property i_pController->setLastPage( sal_False ); + // update "PageRange" property inferring from other properties: + // case 1: "Pages" set from UNO API -> + // setup "Print Selection" and insert "PageRange" attribute + // case 2: "All pages" is selected + // update "Page range" attribute to have a sensible default, + // but leave "All" as selected + + // "Pages" attribute from API is now equivalent to "PageRange" + // AND "PrintContent" = 1 except calc where it is "PrintRange" = 1 + // Argh ! That sure needs cleaning up + beans::PropertyValue* pContentVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); + if( ! pContentVal ) + pContentVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); + + // case 1: UNO API has set "Pages" beans::PropertyValue* pPagesVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pages" ) ) ); if( pPagesVal ) { @@ -332,16 +347,36 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr // "Pages" attribute from API is now equivalent to "PageRange" // AND "PrintContent" = 1 except calc where it is "PrintRange" = 1 // Argh ! That sure needs cleaning up - beans::PropertyValue* pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ) ); - if( ! pVal ) - pVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); - if( pVal ) + if( pContentVal ) { - pVal->Value = makeAny( sal_Int32( 1 ) ); + pContentVal->Value = makeAny( sal_Int32( 1 ) ); i_pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), pPagesVal->Value ); } } } + // case 2: is "All" selected ? + else if( pContentVal ) + { + sal_Int32 nContent = -1; + if( pContentVal->Value >>= nContent ) + { + if( nContent == 0 ) + { + sal_Int32 nPages = i_pController->getPageCount(); + if( nPages > 0 ) + { + rtl::OUStringBuffer aBuf( 32 ); + aBuf.appendAscii( "1" ); + if( nPages > 1 ) + { + aBuf.appendAscii( "-" ); + aBuf.append( nPages ); + } + i_pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), makeAny( aBuf.makeStringAndClear() ) ); + } + } + } + } beans::PropertyValue* pReverseVal = i_pController->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintReverse" ) ) ); if( pReverseVal ) From 069ce0d6e5cc9994af9b6470c2cf02057db84d0f Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 29 Oct 2009 12:57:50 +0100 Subject: [PATCH 228/283] #i106402# tab order of preview cycle buttons --- vcl/inc/vcl/prndlg.hxx | 2 +- vcl/source/window/printdlg.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 95dfef827b90..c792b35c5cd9 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -213,8 +213,8 @@ namespace vcl PrintPreviewWindow maPreviewWindow; NumericField maPageEdit; FixedText maNumPagesText; - PushButton maForwardBtn; PushButton maBackwardBtn; + PushButton maForwardBtn; TabControl maTabCtrl; NUpTabPage maNUpPage; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index d4fe42ce3edb..66cac6f83a5d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -687,8 +687,8 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Thu, 29 Oct 2009 14:01:21 +0100 Subject: [PATCH 229/283] #i106341# catch division by zero in exotic case --- vcl/source/window/printdlg.cxx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 66cac6f83a5d..1e1a9006c405 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -83,15 +83,22 @@ void PrintDialog::PrintPreviewWindow::Resize() aNewSize.Height() -= 2; Size aScaledSize; double fScale = 1.0; - if( maOrigSize.Width() > maOrigSize.Height() ) + + // #i106435# catch corner case of Size(0,0) + Size aOrigSize( maOrigSize ); + if( aOrigSize.Width() < 1 ) + aOrigSize.Width() = aNewSize.Width(); + if( aOrigSize.Height() < 1 ) + aOrigSize.Height() = aNewSize.Height(); + if( aOrigSize.Width() > aOrigSize.Height() ) { - aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * maOrigSize.Height() / maOrigSize.Width() ); + aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * aOrigSize.Height() / aOrigSize.Width() ); if( aScaledSize.Height() > aNewSize.Height() ) fScale = double(aNewSize.Height())/double(aScaledSize.Height()); } else { - aScaledSize = Size( aNewSize.Height() * maOrigSize.Width() / maOrigSize.Height(), aNewSize.Height() ); + aScaledSize = Size( aNewSize.Height() * aOrigSize.Width() / aOrigSize.Height(), aNewSize.Height() ); if( aScaledSize.Width() > aNewSize.Width() ) fScale = double(aNewSize.Width())/double(aScaledSize.Width()); } @@ -125,7 +132,12 @@ void PrintDialog::PrintPreviewWindow::Paint( const Rectangle& ) (aSize.Height() - aPreviewSize.Height()) / 2 ); const Size aLogicSize( maPageVDev.PixelToLogic( aPreviewSize, MapMode( MAP_100TH_MM ) ) ); - double fScale = double(aLogicSize.Width())/double(maOrigSize.Width()); + Size aOrigSize( maOrigSize ); + if( aOrigSize.Width() < 1 ) + aOrigSize.Width() = aLogicSize.Width(); + if( aOrigSize.Height() < 1 ) + aOrigSize.Height() = aLogicSize.Height(); + double fScale = double(aLogicSize.Width())/double(aOrigSize.Width()); maPageVDev.Erase(); From 19b01b2cbe8df5c53a65b967c5da9e1eb1ff86ae Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 29 Oct 2009 14:22:34 +0100 Subject: [PATCH 230/283] #i106400# DisclosureButton should react on +/- keys --- vcl/inc/vcl/button.hxx | 2 ++ vcl/source/control/button.cxx | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index 05f21192e4c8..e9e515681fe9 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -545,6 +545,8 @@ protected: public: DisclosureButton( Window* pParent, WinBits nStyle = 0 ); DisclosureButton( Window* pParent, const ResId& rResId ); + + virtual void KeyInput( const KeyEvent& rKEvt ); }; #endif // _SV_BUTTON_HXX diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 71af9b3142c9..08992c903040 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -4457,3 +4457,22 @@ void DisclosureButton::ImplDrawCheckBoxState() DrawImage( aOff, *pImg, nStyle ); } } + +// ----------------------------------------------------------------------- + +void DisclosureButton::KeyInput( const KeyEvent& rKEvt ) +{ + KeyCode aKeyCode = rKEvt.GetKeyCode(); + + if( !aKeyCode.GetModifier() && + ( ( aKeyCode.GetCode() == KEY_ADD ) || + ( aKeyCode.GetCode() == KEY_SUBTRACT ) ) + ) + { + Check( aKeyCode.GetCode() == KEY_ADD ); + } + else + Button::KeyInput( rKEvt ); +} + + From f67254410da8c2aa533c70ef05352d07b3746462 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 29 Oct 2009 20:50:43 +0100 Subject: [PATCH 231/283] printerpullpages: #i106398# fix HC mode --- vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/window/printdlg.cxx | 35 ++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index c792b35c5cd9..162061984707 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -67,6 +67,7 @@ namespace vcl virtual void Paint( const Rectangle& rRect ); virtual void Command( const CommandEvent& ); virtual void Resize(); + virtual void DataChanged( const DataChangedEvent& ); void setPreview( const GDIMetaFile&, const Size&, const rtl::OUString&, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY @@ -269,6 +270,7 @@ namespace vcl virtual void Resize(); virtual void Command( const CommandEvent& ); + virtual void DataChanged( const DataChangedEvent& ); DECL_LINK( SelectHdl, ListBox* ); DECL_LINK( ClickHdl, Button* ); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1e1a9006c405..ecb52a7ee85d 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -75,6 +75,16 @@ PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() { } +void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDCEvt ) +{ + // react on settings changed + if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) + { + maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); + } + Window::DataChanged( i_rDCEvt ); +} + void PrintDialog::PrintPreviewWindow::Resize() { Size aNewSize( GetSizePixel() ); @@ -1568,6 +1578,14 @@ void PrintDialog::setupOptionalUI() SetOutputSizePixel( aSz ); } +void PrintDialog::DataChanged( const DataChangedEvent& i_rDCEvt ) +{ + // react on settings changed + if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) + checkControlDependencies(); + ModalDialog::DataChanged( i_rDCEvt ); +} + void PrintDialog::checkControlDependencies() { if( maJobPage.maCopyCountField.GetValue() > 1 ) @@ -1576,12 +1594,21 @@ void PrintDialog::checkControlDependencies() maJobPage.maCollateBox.Enable( FALSE ); Image aImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateImg : maJobPage.maNoCollateImg ); - if( GetSettings().GetStyleSettings().GetFieldColor().IsDark() ) - aImg = maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg; + Image aHCImg( maJobPage.maCollateBox.IsChecked() ? maJobPage.maCollateHCImg : maJobPage.maNoCollateHCImg ); + bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); + + Size aImgSize( aImg.GetSizePixel() ); + Size aHCImgSize( aHCImg.GetSizePixel() ); + + if( aHCImgSize.Width() > aImgSize.Width() ) + aImgSize.Width() = aHCImgSize.Width(); + if( aHCImgSize.Height() > aImgSize.Height() ) + aImgSize.Height() = aHCImgSize.Height(); // adjust size of image - maJobPage.maCollateImage.SetSizePixel( aImg.GetSizePixel() ); - maJobPage.maCollateImage.SetImage( aImg ); + maJobPage.maCollateImage.SetSizePixel( aImgSize ); + maJobPage.maCollateImage.SetImage( bHC ? aHCImg : aImg ); + maJobPage.maCollateImage.SetModeImage( aHCImg, BMP_COLOR_HIGHCONTRAST ); // enable setup button only for printers that can be setup bool bHaveSetup = maPController->getPrinter()->HasSupport( SUPPORT_SETUPDIALOG ); From 7556065aa7584df351c86ef801592347557aa5ef Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 29 Oct 2009 21:28:35 +0100 Subject: [PATCH 232/283] printerpullpages: #i106363# fix mouse over on disclosure button --- vcl/inc/vcl/button.hxx | 1 + vcl/source/control/button.cxx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx index e9e515681fe9..2073ecff524d 100644 --- a/vcl/inc/vcl/button.hxx +++ b/vcl/inc/vcl/button.hxx @@ -437,6 +437,7 @@ protected: SAL_DLLPRIVATE virtual void ImplDrawCheckBoxState(); SAL_DLLPRIVATE const Rectangle& GetStateRect() const { return maStateRect; } + SAL_DLLPRIVATE const Rectangle& GetMouseRect() const { return maMouseRect; } public: SAL_DLLPRIVATE void ImplCheck(); SAL_DLLPRIVATE void ImplSetMinimumNWFSize(); diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 08992c903040..aa121049ffe8 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -4419,7 +4419,7 @@ void DisclosureButton::ImplDrawCheckBoxState() if ( HasFocus() ) nState |= CTRL_STATE_FOCUSED; if ( ImplGetButtonState() & BUTTON_DRAW_DEFAULT ) nState |= CTRL_STATE_DEFAULT; if ( Window::IsEnabled() ) nState |= CTRL_STATE_ENABLED; - if ( IsMouseOver() && aStateRect.IsInside( GetPointerPosPixel() ) ) + if ( IsMouseOver() && GetMouseRect().IsInside( GetPointerPosPixel() ) ) nState |= CTRL_STATE_ROLLOVER; if( ! DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL, aCtrlRegion, nState, From 561697e7bafe9c4b31340e4c507907f16b03e1fc Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 30 Oct 2009 17:33:01 +0100 Subject: [PATCH 233/283] #i93514#: really fix locking for PropertyBag::setModified() --- comphelper/source/property/opropertybag.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/comphelper/source/property/opropertybag.cxx b/comphelper/source/property/opropertybag.cxx index 8b816e8c1ce9..caa895021103 100644 --- a/comphelper/source/property/opropertybag.cxx +++ b/comphelper/source/property/opropertybag.cxx @@ -240,7 +240,7 @@ namespace comphelper if ( !( _element >>= aProperty ) ) throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); // check whether the type is allowed, everything else will be checked // by m_aDynamicProperties @@ -254,6 +254,7 @@ namespace comphelper // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } @@ -346,7 +347,7 @@ namespace comphelper //-------------------------------------------------------------------- void SAL_CALL OPropertyBag::addProperty( const ::rtl::OUString& _rName, ::sal_Int16 _nAttributes, const Any& _rInitialValue ) throw (PropertyExistException, IllegalTypeException, IllegalArgumentException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); // check whether the type is allowed, everything else will be checked // by m_aDynamicProperties @@ -362,19 +363,21 @@ namespace comphelper // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } //-------------------------------------------------------------------- void SAL_CALL OPropertyBag::removeProperty( const ::rtl::OUString& _rName ) throw (UnknownPropertyException, NotRemoveableException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); + ::osl::ClearableMutexGuard g( m_aMutex ); m_aDynamicProperties.removeProperty( _rName ); // our property info is dirty m_pArrayHelper.reset(); + g.clear(); setModified(sal_True); } From ff9f90cf28852703366e853ab7e4f9d5218c8f35 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 30 Oct 2009 17:36:02 +0100 Subject: [PATCH 234/283] #i105295#: fix various uninitialized variables reported by valgrind in: IMapObject::IMapObject() [incompatible interface change!] --- svtools/inc/svtools/imapobj.hxx | 2 +- svtools/source/misc/imap.cxx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/svtools/inc/svtools/imapobj.hxx b/svtools/inc/svtools/imapobj.hxx index 3671bf50878c..8f95c41d1c54 100644 --- a/svtools/inc/svtools/imapobj.hxx +++ b/svtools/inc/svtools/imapobj.hxx @@ -96,7 +96,7 @@ public: static rtl_TextEncoding nActualTextEncoding; - IMapObject() {}; + IMapObject(); IMapObject( const String& rURL, const String& rAltText, const String& rDesc, diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index 9fb60111094e..965292803e43 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -64,6 +64,12 @@ UINT16 IMapObject::nActualTextEncoding = (UINT16) RTL_TEXTENCODING_DONTKNOW; #pragma optimize ( "", off ) #endif +IMapObject::IMapObject() + : bActive( false ) + , nReadVersion( 0 ) +{ +} + IMapObject::IMapObject( const String& rURL, const String& rAltText, const String& rDesc, const String& rTarget, const String& rName, BOOL bURLActive ) : aURL( rURL ) @@ -72,6 +78,7 @@ IMapObject::IMapObject( const String& rURL, const String& rAltText, const String , aTarget( rTarget ) , aName( rName ) , bActive( bURLActive ) +, nReadVersion( 0 ) { } From d2b148f667115467247e985816595fd951f9bd7b Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 2 Nov 2009 11:46:52 +0100 Subject: [PATCH 235/283] printerpullpages: #i106435# fix a division by zero error --- vcl/source/window/printdlg.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index ecb52a7ee85d..801d7999f692 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -850,6 +850,10 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Mon, 2 Nov 2009 12:38:16 +0100 Subject: [PATCH 236/283] add the implementation name to the assertion text if copying a property fails --- comphelper/source/property/property.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx index fe6cbaa9d767..14b3b8f9169d 100644 --- a/comphelper/source/property/property.cxx +++ b/comphelper/source/property/property.cxx @@ -38,15 +38,11 @@ #include #if OSL_DEBUG_LEVEL > 0 - #ifndef _RTL_STRBUF_HXX_ #include - #endif - #ifndef _CPPUHELPER_EXC_HLP_HXX_ #include - #endif - #ifndef _OSL_THREAD_H_ #include - #endif + #include + #include #endif #include #include @@ -71,6 +67,8 @@ namespace comphelper using ::com::sun::star::uno::cpp_queryInterface; using ::com::sun::star::uno::cpp_acquire; using ::com::sun::star::uno::cpp_release; + using ::com::sun::star::lang::XServiceInfo; + using ::com::sun::star::uno::UNO_QUERY; /** === end UNO using === **/ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; @@ -110,7 +108,18 @@ void copyProperties(const Reference& _rxSource, ::rtl::OStringBuffer aBuffer; aBuffer.append( "::comphelper::copyProperties: could not copy property '" ); aBuffer.append( ::rtl::OString( pSourceProps->Name.getStr(), pSourceProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US ) ); - aBuffer.append( "' to the destination set.\n" ); + aBuffer.append( "' to the destination set (a '" ); + + Reference< XServiceInfo > xSI( _rxDest, UNO_QUERY ); + if ( xSI.is() ) + { + aBuffer.append( ::rtl::OUStringToOString( xSI->getImplementationName(), osl_getThreadTextEncoding() ) ); + } + else + { + aBuffer.append( typeid( *_rxDest.get() ).name() ); + } + aBuffer.append( "' implementation).\n" ); Any aException( ::cppu::getCaughtException() ); aBuffer.append( "Caught an exception of type '" ); From b7362dfa446a3876529d7223306675f3b7d371c8 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 2 Nov 2009 19:08:00 +0100 Subject: [PATCH 237/283] #i105745#: tools/stream.hxx: API change: make SvMemoryStream::GetSize() private introduce new public SvMemoryStream::GetEndOfData() --- sot/source/sdstor/stgstrms.cxx | 2 +- sot/source/sdstor/stgstrms.hxx | 3 +-- svtools/source/filter.vcl/filter/filter2.cxx | 3 ++- svtools/source/numbers/numhead.cxx | 2 +- tools/inc/tools/stream.hxx | 5 ++++- vcl/source/gdi/bmpconv.cxx | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx index 46ae3529439c..0e20af6118af 100644 --- a/sot/source/sdstor/stgstrms.cxx +++ b/sot/source/sdstor/stgstrms.cxx @@ -1104,7 +1104,7 @@ StgTmpStrm::~StgTmpStrm() } } -ULONG StgTmpStrm::GetSize() +ULONG StgTmpStrm::GetSize() const { ULONG n; if( pStrm ) diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx index 806d562af6d0..fd7971da3aba 100644 --- a/sot/source/sdstor/stgstrms.hxx +++ b/sot/source/sdstor/stgstrms.hxx @@ -167,8 +167,7 @@ public: ~StgTmpStrm(); BOOL Copy( StgTmpStrm& ); void SetSize( ULONG ); - using SvMemoryStream::GetSize; - ULONG GetSize(); + ULONG GetSize() const; }; #endif diff --git a/svtools/source/filter.vcl/filter/filter2.cxx b/svtools/source/filter.vcl/filter/filter2.cxx index d570dd34e50f..9e0e3ba43d54 100644 --- a/svtools/source/filter.vcl/filter/filter2.cxx +++ b/svtools/source/filter.vcl/filter/filter2.cxx @@ -471,7 +471,8 @@ BOOL GraphicDescriptor::ImpDetectJPG( SvStream& rStm, BOOL bExtendedInfo ) // Groesse des verbleibenden Puffers ermitteln if ( bLinked ) - nMax = ( (SvMemoryStream&) rStm ).GetSize() - 16; + nMax = static_cast< SvMemoryStream& >(rStm).GetEndOfData() + - 16; else nMax = DATA_SIZE - 16; diff --git a/svtools/source/numbers/numhead.cxx b/svtools/source/numbers/numhead.cxx index 7e79aad624f3..921442de1b66 100644 --- a/svtools/source/numbers/numhead.cxx +++ b/svtools/source/numbers/numhead.cxx @@ -139,7 +139,7 @@ ImpSvNumMultipleReadHeader::ImpSvNumMultipleReadHeader(SvStream& rNewStream) : ImpSvNumMultipleReadHeader::~ImpSvNumMultipleReadHeader() { - DBG_ASSERT( pMemStream->Tell() == pMemStream->GetSize(), + DBG_ASSERT( pMemStream->Tell() == pMemStream->GetEndOfData(), "Sizes nicht vollstaendig gelesen" ); delete pMemStream; delete [] pBuf; diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index bacaac89fe44..23496322fa4c 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -776,6 +776,9 @@ class TOOLS_DLLPUBLIC SvMemoryStream : public SvStream SvMemoryStream (const SvMemoryStream&); SvMemoryStream & operator= (const SvMemoryStream&); + friend class SvCacheStream; + sal_Size GetSize() const { return nSize; } + protected: sal_Size nSize; sal_Size nResize; @@ -817,7 +820,7 @@ public: virtual void ResetError(); - sal_Size GetSize() const { return nSize; } + sal_Size GetEndOfData() const { return nEndOfData; } const void* GetData() { Flush(); return pBuf; } operator const void*() { Flush(); return pBuf; } virtual sal_uInt16 IsA() const; diff --git a/vcl/source/gdi/bmpconv.cxx b/vcl/source/gdi/bmpconv.cxx index 9d9b81ba50d4..03d85acb0159 100644 --- a/vcl/source/gdi/bmpconv.cxx +++ b/vcl/source/gdi/bmpconv.cxx @@ -192,7 +192,8 @@ BmpTransporter::BmpTransporter( const Bitmap& rBM ) m_aSize.Height = rBM.GetSizePixel().Height(); SvMemoryStream aStream; rBM.Write( aStream, FALSE, TRUE ); - m_aBM = Sequence((const sal_Int8*)aStream.GetData(), aStream.GetSize() ); + m_aBM = Sequence(static_cast(aStream.GetData()), + aStream.GetEndOfData()); } BmpTransporter::~BmpTransporter() From d12dff9041a47602e6a655a67dacddcfd9cbe86b Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 12 Nov 2009 11:26:43 +0100 Subject: [PATCH 238/283] aw078 #i106541# commited in-between stable version with already advanced metafile decomposition for security reasons --- goodies/inc/grfmgr.hxx | 2 +- goodies/source/graphic/grfmgr.cxx | 4 +- vcl/source/gdi/metaact.cxx | 77 ++++++++++++++++++------------- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/goodies/inc/grfmgr.hxx b/goodies/inc/grfmgr.hxx index b44c27ea65e3..1ef351ae6d32 100644 --- a/goodies/inc/grfmgr.hxx +++ b/goodies/inc/grfmgr.hxx @@ -353,7 +353,7 @@ public: void ReleaseFromCache(); const Graphic& GetGraphic() const; - void SetGraphic( const Graphic& rGraphic ); + void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = 0); void SetGraphic( const Graphic& rGraphic, const String& rLink ); /** Get graphic transformed according to given attributes diff --git a/goodies/source/graphic/grfmgr.cxx b/goodies/source/graphic/grfmgr.cxx index 5cb37a51e81f..cccc51ff7049 100644 --- a/goodies/source/graphic/grfmgr.cxx +++ b/goodies/source/graphic/grfmgr.cxx @@ -845,7 +845,7 @@ const Graphic& GraphicObject::GetGraphic() const // ----------------------------------------------------------------------------- -void GraphicObject::SetGraphic( const Graphic& rGraphic ) +void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj ) { mpMgr->ImplUnregisterObj( *this ); @@ -858,7 +858,7 @@ void GraphicObject::SetGraphic( const Graphic& rGraphic ) delete mpLink, mpLink = NULL; delete mpSimpleCache, mpSimpleCache = NULL; - mpMgr->ImplRegisterObj( *this, maGraphic ); + mpMgr->ImplRegisterObj( *this, maGraphic, 0, pCopyObj); if( mpSwapOutTimer ) mpSwapOutTimer->Start(); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 4fe9a41be797..0587e661b7e8 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -52,14 +52,6 @@ inline void ImplScalePoint( Point& rPt, double fScaleX, double fScaleY ) // ------------------------------------------------------------------------ -inline void ImplScaleSize( Size& rSz, double fScaleX, double fScaleY ) -{ - rSz.Width() = FRound( fScaleX * rSz.Width() ); - rSz.Height() = FRound( fScaleY * rSz.Height() ); -} - -// ------------------------------------------------------------------------ - inline void ImplScaleRect( Rectangle& rRect, double fScaleX, double fScaleY ) { Point aTL( rRect.TopLeft() ); @@ -69,6 +61,7 @@ inline void ImplScaleRect( Rectangle& rRect, double fScaleX, double fScaleY ) ImplScalePoint( aBR, fScaleX, fScaleY ); rRect = Rectangle( aTL, aBR ); + rRect.Justify(); } // ------------------------------------------------------------------------ @@ -85,7 +78,7 @@ inline void ImplScaleLineInfo( LineInfo& rLineInfo, double fScaleX, double fScal { if( !rLineInfo.IsDefault() ) { - const double fScale = ( fScaleX + fScaleY ) * 0.5; + const double fScale = ( fabs(fScaleX) + fabs(fScaleY) ) * 0.5; rLineInfo.SetWidth( FRound( fScale * rLineInfo.GetWidth() ) ); rLineInfo.SetDashLen( FRound( fScale * rLineInfo.GetDashLen() ) ); @@ -598,8 +591,8 @@ void MetaRoundRectAction::Move( long nHorzMove, long nVertMove ) void MetaRoundRectAction::Scale( double fScaleX, double fScaleY ) { ImplScaleRect( maRect, fScaleX, fScaleY ); - mnHorzRound = FRound( mnHorzRound * fScaleX ); - mnVertRound = FRound( mnVertRound * fScaleY ); + mnHorzRound = FRound( mnHorzRound * fabs(fScaleX) ); + mnVertRound = FRound( mnVertRound * fabs(fScaleY) ); } // ------------------------------------------------------------------------ @@ -1396,7 +1389,7 @@ void MetaTextArrayAction::Scale( double fScaleX, double fScaleY ) if ( mpDXAry && mnLen ) { for ( USHORT i = 0, nCount = mnLen; i < nCount; i++ ) - mpDXAry[ i ] = FRound( mpDXAry[ i ] * fScaleX ); + mpDXAry[ i ] = FRound( mpDXAry[ i ] * fabs(fScaleX) ); } } @@ -1524,7 +1517,7 @@ void MetaStretchTextAction::Move( long nHorzMove, long nVertMove ) void MetaStretchTextAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPt, fScaleX, fScaleY ); - mnWidth = (ULONG)FRound( mnWidth * fScaleX ); + mnWidth = (ULONG)FRound( mnWidth * fabs(fScaleX) ); } // ------------------------------------------------------------------------ @@ -1717,7 +1710,7 @@ void MetaTextLineAction::Move( long nHorzMove, long nVertMove ) void MetaTextLineAction::Scale( double fScaleX, double fScaleY ) { ImplScalePoint( maPos, fScaleX, fScaleY ); - mnWidth = FRound( mnWidth * fScaleX ); + mnWidth = FRound( mnWidth * fabs(fScaleX) ); } // ------------------------------------------------------------------------ @@ -1876,8 +1869,10 @@ void MetaBmpScaleAction::Move( long nHorzMove, long nVertMove ) void MetaBmpScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -1953,8 +1948,10 @@ void MetaBmpScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaBmpScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2099,8 +2096,10 @@ void MetaBmpExScaleAction::Move( long nHorzMove, long nVertMove ) void MetaBmpExScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2176,8 +2175,10 @@ void MetaBmpExScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaBmpExScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2328,8 +2329,10 @@ void MetaMaskScaleAction::Move( long nHorzMove, long nVertMove ) void MetaMaskScaleAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPt, fScaleX, fScaleY ); - ImplScaleSize( maSz, fScaleX, fScaleY ); + Rectangle aRectangle(maPt, maSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPt = aRectangle.TopLeft(); + maSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -2408,8 +2411,10 @@ void MetaMaskScalePartAction::Move( long nHorzMove, long nVertMove ) void MetaMaskScalePartAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maDstPt, fScaleX, fScaleY ); - ImplScaleSize( maDstSz, fScaleX, fScaleY ); + Rectangle aRectangle(maDstPt, maDstSz); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maDstPt = aRectangle.TopLeft(); + maDstSz = aRectangle.GetSize(); } // ------------------------------------------------------------------------ @@ -3486,9 +3491,9 @@ MetaAction* MetaFontAction::Clone() void MetaFontAction::Scale( double fScaleX, double fScaleY ) { - Size aSize( maFont.GetSize() ); - - ImplScaleSize( aSize, fScaleX, fScaleY ); + const Size aSize( + FRound(maFont.GetSize().Width() * fabs(fScaleX)), + FRound(maFont.GetSize().Height() * fabs(fScaleY))); maFont.SetSize( aSize ); } @@ -3766,14 +3771,18 @@ MetaAction* MetaFloatTransparentAction::Clone() void MetaFloatTransparentAction::Move( long nHorzMove, long nVertMove ) { maPoint.Move( nHorzMove, nVertMove ); + maMtf.Move(nHorzMove, nVertMove); } // ------------------------------------------------------------------------ void MetaFloatTransparentAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPoint, fScaleX, fScaleY ); - ImplScaleSize( maSize, fScaleX, fScaleY ); + Rectangle aRectangle(maPoint, maSize); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPoint = aRectangle.TopLeft(); + maSize = aRectangle.GetSize(); + maMtf.Scale(fScaleX, fScaleY); } // ------------------------------------------------------------------------ @@ -3847,8 +3856,10 @@ void MetaEPSAction::Move( long nHorzMove, long nVertMove ) void MetaEPSAction::Scale( double fScaleX, double fScaleY ) { - ImplScalePoint( maPoint, fScaleX, fScaleY ); - ImplScaleSize( maSize, fScaleX, fScaleY ); + Rectangle aRectangle(maPoint, maSize); + ImplScaleRect( aRectangle, fScaleX, fScaleY ); + maPoint = aRectangle.TopLeft(); + maSize = aRectangle.GetSize(); } // ------------------------------------------------------------------------ From fe537060e40a6d0c5411a800fd5c518d04a6209c Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 13 Nov 2009 11:04:06 +0100 Subject: [PATCH 239/283] sb116: #i106845# removed obsolete IRIX port --- goodies/source/filter.vcl/ios2met/ios2met.cxx | 2 +- rsc/source/parser/rsclex.cxx | 2 +- rsc/source/parser/rsclex.hxx | 2 +- rsc/source/rsc/makefile.mk | 4 ---- svtools/inc/svtools/svarray.hxx | 2 +- tools/inc/tools/inetdef.hxx | 2 -- tools/inc/tools/solar.h | 2 -- tools/source/fsys/unx.cxx | 2 +- vcl/source/glyphs/glyphcache.cxx | 2 -- vcl/unx/inc/salunx.h | 6 ------ vcl/unx/source/app/i18n_ic.cxx | 4 ++-- vcl/unx/source/app/i18n_im.cxx | 2 +- vcl/unx/source/app/saldisp.cxx | 7 ++----- vcl/unx/source/app/saltimer.cxx | 3 --- vcl/unx/source/printer/printerinfomanager.cxx | 2 +- 15 files changed, 11 insertions(+), 33 deletions(-) diff --git a/goodies/source/filter.vcl/ios2met/ios2met.cxx b/goodies/source/filter.vcl/ios2met/ios2met.cxx index 0fbf24f56029..8c3c19e22379 100644 --- a/goodies/source/filter.vcl/ios2met/ios2met.cxx +++ b/goodies/source/filter.vcl/ios2met/ios2met.cxx @@ -846,7 +846,7 @@ void OS2METReader::ReadRelLine(BOOL bGivenPos, USHORT nOrderLen) if (nPolySize==0) return; Polygon aPolygon(nPolySize); for (i=0; i> nunsignedbyte; aP0.X()+=(INT8)nunsignedbyte; *pOS2MET >> nunsignedbyte; aP0.Y()+=(INT8)nunsignedbyte; diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx index 3c2c95e541d1..8c34637fa304 100644 --- a/rsc/source/parser/rsclex.cxx +++ b/rsc/source/parser/rsclex.cxx @@ -317,7 +317,7 @@ int yylex() /****************** yyerror **********************************************/ #ifdef RS6000 extern "C" void yyerror( char* pMessage ) -#elif defined HP9000 || defined SCO || defined IRIX || defined SOLARIS +#elif defined HP9000 || defined SCO || defined SOLARIS extern "C" void yyerror( const char* pMessage ) #else void yyerror( char* pMessage ) diff --git a/rsc/source/parser/rsclex.hxx b/rsc/source/parser/rsclex.hxx index 89feed4dd132..63afd0b208c7 100644 --- a/rsc/source/parser/rsclex.hxx +++ b/rsc/source/parser/rsclex.hxx @@ -107,7 +107,7 @@ class ObjectStack { extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion extern "C" void yyerror( char * ); extern "C" int yylex( void ); -#elif defined( HP9000 ) || defined( SCO ) || defined ( IRIX ) || defined ( SOLARIS ) +#elif defined( HP9000 ) || defined( SCO ) || defined ( SOLARIS ) extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion extern "C" void yyerror( const char * ); extern "C" int yylex( void ); diff --git a/rsc/source/rsc/makefile.mk b/rsc/source/rsc/makefile.mk index 40e2d77740a3..89abd22207d9 100644 --- a/rsc/source/rsc/makefile.mk +++ b/rsc/source/rsc/makefile.mk @@ -40,10 +40,6 @@ ENABLE_EXCEPTIONS=true .INCLUDE : settings.mk -.IF "$(OS)"=="IRIX" -NOOPTFILES= $(OBJ)$/rsc.obj -.ENDIF - OBJFILES= $(OBJ)$/rsc.obj .INCLUDE : target.mk diff --git a/svtools/inc/svtools/svarray.hxx b/svtools/inc/svtools/svarray.hxx index 3ab3676fa5e0..1518c20f5084 100644 --- a/svtools/inc/svtools/svarray.hxx +++ b/svtools/inc/svtools/svarray.hxx @@ -1034,7 +1034,7 @@ public:\ #define C40_PTR_REPLACE( c, p) Replace( (c const *) p ) #define C40_GETPOS( c, r) GetPos( (c const *)r ) #else -#if defined WTC || defined IRIX || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400) +#if defined WTC || defined ICC || defined HPUX || (defined GCC && __GNUC__ >= 3) || (defined(WNT) && _MSC_VER >= 1400) #define C40_INSERT( c, p, n ) Insert( (c const *&) p, n ) #define C40_PUSH( c, p) Push( (c const *&) p ) #define C40_PTR_INSERT( c, p ) Insert( (c const *&) p ) diff --git a/tools/inc/tools/inetdef.hxx b/tools/inc/tools/inetdef.hxx index 38cd8935e06b..d9861f64961d 100644 --- a/tools/inc/tools/inetdef.hxx +++ b/tools/inc/tools/inetdef.hxx @@ -61,8 +61,6 @@ #define TOOLS_INETDEF_OS "FreeBSD/amd64" #elif defined SINIX #define TOOLS_INETDEF_OS "SINIX" -#elif defined IRIX -#define TOOLS_INETDEF_OS "IRIX" #else // AIX, HPUX, SOLARIS, ... #define TOOLS_INETDEF_OS "Unix" #endif // AIX, HPUX, SOLARIS, ... diff --git a/tools/inc/tools/solar.h b/tools/inc/tools/solar.h index 46fe42b9c36f..4fe00adc9da0 100644 --- a/tools/inc/tools/solar.h +++ b/tools/inc/tools/solar.h @@ -391,8 +391,6 @@ template inline T Abs(T a) { return (a>=0?a:-a); } #define __DLLEXTENSION "fi.so" #elif defined FREEBSD && defined X86_64 #define __DLLEXTENSION "fx.so" -#elif defined IRIX - #define __DLLEXTENSION "im.so" #elif defined MACOSX && defined POWERPC #define __DLLEXTENSION "mxp.dylib" #elif defined MACOSX && defined X86 diff --git a/tools/source/fsys/unx.cxx b/tools/source/fsys/unx.cxx index 76910683df13..4a2e3c6ad76a 100644 --- a/tools/source/fsys/unx.cxx +++ b/tools/source/fsys/unx.cxx @@ -36,7 +36,7 @@ #include #include #include -#if defined HPUX || defined LINUX || defined IRIX +#if defined HPUX || defined LINUX #include #define mnttab mntent #elif defined SCO diff --git a/vcl/source/glyphs/glyphcache.cxx b/vcl/source/glyphs/glyphcache.cxx index e3e840e40730..17e70c539254 100644 --- a/vcl/source/glyphs/glyphcache.cxx +++ b/vcl/source/glyphs/glyphcache.cxx @@ -79,9 +79,7 @@ GlyphCache::~GlyphCache() // ----------------------------------------------------------------------- -#ifndef IRIX inline -#endif size_t GlyphCache::IFSD_Hash::operator()( const ImplFontSelectData& rFontSelData ) const { // TODO: is it worth to improve this hash function? diff --git a/vcl/unx/inc/salunx.h b/vcl/unx/inc/salunx.h index cdf45fd30867..c1fee6c68d94 100644 --- a/vcl/unx/inc/salunx.h +++ b/vcl/unx/inc/salunx.h @@ -38,12 +38,6 @@ #include #include #include -#elif defined IRIX -#ifdef __cplusplus -#include -#endif -#include -#include #endif #include #include diff --git a/vcl/unx/source/app/i18n_ic.cxx b/vcl/unx/source/app/i18n_ic.cxx index cacffbcfdbb1..bb8f86d93e01 100644 --- a/vcl/unx/source/app/i18n_ic.cxx +++ b/vcl/unx/source/app/i18n_ic.cxx @@ -340,7 +340,7 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) : if ( mnPreeditStyle != XIMPreeditNone ) { -#if defined LINUX || defined FREEBSD || defined NETBSD || defined IRIX +#if defined LINUX || defined FREEBSD || defined NETBSD if ( mpPreeditAttributes != NULL ) #endif mpAttributes = XVaAddToNestedList( mpAttributes, @@ -348,7 +348,7 @@ SalI18N_InputContext::SalI18N_InputContext ( SalFrame *pFrame ) : } if ( mnStatusStyle != XIMStatusNone ) { -#if defined LINUX || defined FREEBSD || defined NETBSD || defined IRIX +#if defined LINUX || defined FREEBSD || defined NETBSD if ( mpStatusAttributes != NULL ) #endif mpAttributes = XVaAddToNestedList( mpAttributes, diff --git a/vcl/unx/source/app/i18n_im.cxx b/vcl/unx/source/app/i18n_im.cxx index ae472d6323f4..0a48c054167f 100644 --- a/vcl/unx/source/app/i18n_im.cxx +++ b/vcl/unx/source/app/i18n_im.cxx @@ -59,7 +59,7 @@ using namespace vcl; #include "i18n_cb.hxx" -#if defined(SOLARIS) || defined(LINUX) || defined(IRIX) +#if defined(SOLARIS) || defined(LINUX) extern "C" char * XSetIMValues(XIM im, ...); #endif diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index 07955d426b8c..cfd568ac9b6c 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -38,16 +38,13 @@ #include #include #include -#if defined(IRIX) -#include -#endif #include #include #include #include #include -#if defined(SOLARIS) || defined(IRIX) +#if defined(SOLARIS) #include #include #endif @@ -898,7 +895,7 @@ void SalDisplay::Init() sscanf( pProperties, "%li", &nProperties_ ); else { -#if defined DBG_UTIL || defined SUN || defined LINUX || defined FREEBSD || defined IRIX +#if defined DBG_UTIL || defined SUN || defined LINUX || defined FREEBSD nProperties_ |= PROPERTY_FEATURE_Maximize; #endif // Server Bugs & Properties diff --git a/vcl/unx/source/app/saltimer.cxx b/vcl/unx/source/app/saltimer.cxx index bf8aa202b066..afcecc0d0667 100644 --- a/vcl/unx/source/app/saltimer.cxx +++ b/vcl/unx/source/app/saltimer.cxx @@ -32,9 +32,6 @@ #include "precompiled_vcl.hxx" #include -#if defined(IRIX) -#include -#endif #include #include #include diff --git a/vcl/unx/source/printer/printerinfomanager.cxx b/vcl/unx/source/printer/printerinfomanager.cxx index b3e5b4667a6a..53cd662db8e0 100644 --- a/vcl/unx/source/printer/printerinfomanager.cxx +++ b/vcl/unx/source/printer/printerinfomanager.cxx @@ -441,7 +441,7 @@ void PrinterInfoManager::initialize() * porters: please append your platform to the Solaris * case if your platform has SystemV printing per default. */ - #if defined SOLARIS || defined(IRIX) + #if defined SOLARIS aValue = "lp"; #else aValue = "lpr"; From 4d4bfb28a75c7887a46fec3c0f71260781ae0471 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 16 Nov 2009 14:59:17 +0100 Subject: [PATCH 240/283] #i84012# +getLocalName --- unotools/inc/unotools/confignode.hxx | 3 +++ unotools/source/config/confignode.cxx | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/unotools/inc/unotools/confignode.hxx b/unotools/inc/unotools/confignode.hxx index 580274004e1a..2e305030fa2b 100644 --- a/unotools/inc/unotools/confignode.hxx +++ b/unotools/inc/unotools/confignode.hxx @@ -88,6 +88,9 @@ namespace utl /// dtor ~OConfigurationNode() {} + /// returns the local name of the node + ::rtl::OUString getLocalName() const; + /** open a sub node @param _rPath access path of the to-be-opened sub node. May be a hierarchical path. */ diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx index 4b1b9fe272db..56d258461e95 100644 --- a/unotools/source/config/confignode.cxx +++ b/unotools/source/config/confignode.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #if OSL_DEBUG_LEVEL > 0 @@ -138,6 +139,22 @@ namespace utl clear(); } + //------------------------------------------------------------------------ + ::rtl::OUString OConfigurationNode::getLocalName() const + { + ::rtl::OUString sLocalName; + try + { + Reference< XNamed > xNamed( m_xDirectAccess, UNO_QUERY_THROW ); + sLocalName = xNamed->getName(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sLocalName; + } + //------------------------------------------------------------------------ ::rtl::OUString OConfigurationNode::normalizeName(const ::rtl::OUString& _rName, NAMEORIGIN _eOrigin) const { @@ -155,13 +172,9 @@ namespace utl else sName = xEscaper->unescapeString(sName); } - catch(IllegalArgumentException&) - { - OSL_ENSURE(sal_False, "OConfigurationNode::normalizeName: illegal argument (caught an exception saying so)!"); - } catch(Exception&) { - OSL_ENSURE(sal_False, "OConfigurationNode::normalizeName: caught an exception!"); + DBG_UNHANDLED_EXCEPTION(); } } } From d04edead2cc8bcb9f2bfef829f1a25ec75070fc3 Mon Sep 17 00:00:00 2001 From: npower Developer Date: Wed, 18 Nov 2009 11:25:15 +0000 Subject: [PATCH 241/283] menuincustomtoolbar: #i105626#: implement menu for custom toolbar ( and some item style override capability ) --- vcl/inc/vcl/menu.hxx | 2 ++ vcl/inc/vcl/toolbox.hxx | 3 +++ vcl/source/window/toolbox.cxx | 26 ++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/vcl/inc/vcl/menu.hxx b/vcl/inc/vcl/menu.hxx index 8d3ac4e8b505..66f35823b06a 100644 --- a/vcl/inc/vcl/menu.hxx +++ b/vcl/inc/vcl/menu.hxx @@ -93,6 +93,8 @@ typedef USHORT MenuItemBits; #define MIB_POPUPSELECT ((MenuItemBits)0x0020) // not in rsc/vclsrc.hxx because only a prelimitary solution #define MIB_NOSELECT ((MenuItemBits)0x0040) +#define MIB_ICON ((MenuItemBits)0x0080) +#define MIB_TEXT ((MenuItemBits)0x0100) #define MENU_FLAG_NOAUTOMNEMONICS 0x0001 #define MENU_FLAG_HIDEDISABLEDENTRIES 0x0002 diff --git a/vcl/inc/vcl/toolbox.hxx b/vcl/inc/vcl/toolbox.hxx index 6e4c300ccc40..c2547e4b01ba 100644 --- a/vcl/inc/vcl/toolbox.hxx +++ b/vcl/inc/vcl/toolbox.hxx @@ -124,6 +124,9 @@ typedef USHORT ToolBoxItemBits; #define TIB_DROPDOWN ((ToolBoxItemBits)0x0020) #define TIB_REPEAT ((ToolBoxItemBits)0x0040) #define TIB_DROPDOWNONLY ((ToolBoxItemBits)0x0080 | TIB_DROPDOWN) // this button has only drop down functionality +#define TIB_TEXT_ONLY ((ToolBoxItemBits)0x0100) +#define TIB_ICON_ONLY ((ToolBoxItemBits)0x0200) +#define TIB_TEXTICON ((ToolBoxItemBits) TIB_TEXT_ONLY | TIB_ICON_ONLY ) // ----------------- // - ToolBox-Types - diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 8aa4926f5e1a..ef58ea9e6bc6 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -229,6 +229,22 @@ int ToolBox::ImplGetDragWidth( ToolBox* pThis ) } return width; } + +ButtonType determineButtonType( ImplToolItem* pItem, ButtonType defaultType ) +{ + ButtonType tmpButtonType = defaultType; + ToolBoxItemBits nBits( pItem->mnBits & 0x300 ); + if ( nBits & TIB_TEXTICON ) // item has custom setting + { + tmpButtonType = BUTTON_SYMBOLTEXT; + if ( nBits == TIB_TEXT_ONLY ) + tmpButtonType = BUTTON_TEXT; + else if ( nBits == TIB_ICON_ONLY ) + tmpButtonType = BUTTON_SYMBOL; + } + return tmpButtonType; +} + // ----------------------------------------------------------------------- void ToolBox::ImplUpdateDragArea( ToolBox *pThis ) @@ -1992,12 +2008,13 @@ BOOL ToolBox::ImplCalcItem() bText = FALSE; else bText = TRUE; - + ButtonType tmpButtonType = determineButtonType( &(*it), meButtonType ); // default to toolbox setting if ( bImage || bText ) { + it->mbEmptyBtn = FALSE; - if ( meButtonType == BUTTON_SYMBOL ) + if ( tmpButtonType == BUTTON_SYMBOL ) { // we're drawing images only if ( bImage || !bText ) @@ -2011,7 +2028,7 @@ BOOL ToolBox::ImplCalcItem() it->mbVisibleText = TRUE; } } - else if ( meButtonType == BUTTON_TEXT ) + else if ( tmpButtonType == BUTTON_TEXT ) { // we're drawing text only if ( bText || !bImage ) @@ -3625,7 +3642,8 @@ void ToolBox::ImplDrawItem( USHORT nPos, BOOL bHighlight, BOOL bPaint, BOOL bLay // determine what has to be drawn on the button: image, text or both BOOL bImage; BOOL bText; - pItem->DetermineButtonDrawStyle( meButtonType, bImage, bText ); + ButtonType tmpButtonType = determineButtonType( pItem, meButtonType ); // default to toolbox setting + pItem->DetermineButtonDrawStyle( tmpButtonType, bImage, bText ); // compute output values long nBtnWidth = aBtnSize.Width()-SMALLBUTTON_HSIZE; From d1eb6b5cb7482385397f03b56ef396905c5490e5 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Wed, 18 Nov 2009 13:08:25 +0100 Subject: [PATCH 242/283] aw078: changes after resync to DEV300m64 --- basegfx/test/basegfx2d.cxx | 4 +++- goodies/source/filter.vcl/eps/eps.cxx | 3 +-- vcl/aqua/source/gdi/salgdi.cxx | 1 + vcl/source/gdi/bitmapex.cxx | 2 +- vcl/source/glyphs/gcach_ftyp.cxx | 1 + vcl/unx/source/gdi/salgdi.cxx | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index b4c9453c1d3c..eadd99d31a42 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -484,8 +484,10 @@ public: } while ( nIndex >= 0 ); + // Adapted number of spaces from 50 to 67 because of the new circle construction + // methods which produce more points and thus more spaces, too. CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", - nCount==50); + nCount==67); const B2DPolygon aRect( tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) )); diff --git a/goodies/source/filter.vcl/eps/eps.cxx b/goodies/source/filter.vcl/eps/eps.cxx index b66c118dbf8a..5a4c1163b952 100644 --- a/goodies/source/filter.vcl/eps/eps.cxx +++ b/goodies/source/filter.vcl/eps/eps.cxx @@ -388,7 +388,7 @@ BOOL PSWriter::WritePS( const Graphic& rGraphic, SvStream& rTargetStream, Filter bTextFillColor = TRUE; aTextFillColor = Color( COL_BLACK ); fLineWidth = 1; - fMiterLimit = 10; + fMiterLimit = 15; // use same limit as most graphic systems and basegfx eLineCap = SvtGraphicStroke::capButt; eJoinType = SvtGraphicStroke::joinMiter; aBackgroundColor = Color( COL_WHITE ); @@ -2377,7 +2377,6 @@ void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo ) if ( rLineInfo.GetStyle() == LINE_DASH ) l_aDashArray.push_back( 2 ); const double fLWidth(( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5); - const double fMiterLimit(15.0); SvtGraphicStroke::JoinType aJoinType(SvtGraphicStroke::joinMiter); switch(rLineInfo.GetLineJoin()) diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 8d57d56a3667..f38b9852e57e 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -54,6 +54,7 @@ #include "basegfx/polygon/b2dpolygon.hxx" #include "basegfx/polygon/b2dpolygontools.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include using namespace vcl; diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 6626a12d29a2..4e2ed20a7966 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -785,7 +785,7 @@ sal_uInt8 BitmapEx::GetTransparency(sal_Int32 nX, sal_Int32 nY) const if(pRead) { - const Color aColor(Color(pRead->GetColor(nY, nX))); + const Color aColor = pRead->GetColor(nY, nX); // if color is not equal to TransparentColor, we are not transparent if(aColor != aTransparentColor) diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx index 820f3f0d74a9..c782366928db 100644 --- a/vcl/source/glyphs/gcach_ftyp.cxx +++ b/vcl/source/glyphs/gcach_ftyp.cxx @@ -43,6 +43,7 @@ #include "tools/poly.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "basegfx/polygon/b2dpolypolygon.hxx" #include "osl/file.hxx" diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index bfc5aa9d66f4..5bf8b63dc6e2 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -50,6 +50,7 @@ #include "basegfx/polygon/b2dpolygonclipper.hxx" #include "basegfx/polygon/b2dlinegeometry.hxx" #include "basegfx/matrix/b2dhommatrix.hxx" +#include #include "basegfx/polygon/b2dpolypolygoncutter.hxx" #include From 6320fb69ac76730cc148af0cc907036889c925eb Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 14:54:20 +0100 Subject: [PATCH 243/283] printerpullpages: #i94718# fix brochure printing, better paper match --- vcl/aqua/source/gdi/salprn.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vcl/aqua/source/gdi/salprn.cxx b/vcl/aqua/source/gdi/salprn.cxx index 3bf229d1927f..47c027a033aa 100644 --- a/vcl/aqua/source/gdi/salprn.cxx +++ b/vcl/aqua/source/gdi/salprn.cxx @@ -594,7 +594,14 @@ BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName, // now for the current run mnStartPageOffsetX = mnStartPageOffsetY = 0; // setup the paper size and orientation - setPaperSize( aCurSize.Width(), aCurSize.Height(), ORIENTATION_PORTRAIT ); + // do this on our associated Printer object, since that is + // out interface to the applications which occasionally rely on the paper + // information (e.g. brochure printing scales to the found paper size) + // also SetPaperSizeUser has the advantage that we can share a + // platform independent paper matching algorithm + boost::shared_ptr pPrinter( i_rController.getPrinter() ); + pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) ); + pPrinter->SetPaperSizeUser( aCurSize, true ); // create view NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this]; From ced811f0109198d81bbc09e610dd82fb716307b4 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 15:11:29 +0100 Subject: [PATCH 244/283] printerpullpages: #i106762# hide properties button instead of disabling it when no printer setup dialog is available --- svtools/source/dialogs/prnsetup.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx index dedb5b2d7143..74cfe7b1286a 100644 --- a/svtools/source/dialogs/prnsetup.cxx +++ b/svtools/source/dialogs/prnsetup.cxx @@ -59,7 +59,7 @@ void ImplFillPrnDlgListBox( const Printer* pPrinter, } pBox->Enable( nCount != 0 ); - pPropBtn->Enable( pPrinter->HasSupport( SUPPORT_SETUPDIALOG ) ); + pPropBtn->Show( pPrinter->HasSupport( SUPPORT_SETUPDIALOG ) ); } // ----------------------------------------------------------------------- From 5e9fc7a71efaf83fde0766a78c72ee6b7b781ea8 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 15:39:55 +0100 Subject: [PATCH 245/283] printerpullpages: #i106555# layout preview control row if pages text changes to accomodat new text length --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/source/window/printdlg.cxx | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 162061984707..deebb1f11254 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -249,6 +249,7 @@ namespace vcl rtl::OUString maDefPrtText; vcl::RowOrColumn maLayout; + boost::shared_ptr mxPreviewCtrls; Size maDetailsCollapsedSize; Size maDetailsExpandedSize; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 801d7999f692..a3badf32887f 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -915,18 +915,18 @@ void PrintDialog::setupLayout() xPreviewAndTab->addChild( xPreview, 5 ); xPreview->addWindow( &maPreviewWindow, 5 ); // get a row for the preview controls - boost::shared_ptr< vcl::RowOrColumn > xPreviewCtrls( new vcl::RowOrColumn( xPreview.get(), false ) ); - nIndex = xPreview->addChild( xPreviewCtrls ); - boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); - xPreviewCtrls->addChild( xSpacer ); - xPreviewCtrls->addWindow( &maPageEdit ); - xPreviewCtrls->addWindow( &maNumPagesText ); - xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); - xPreviewCtrls->addChild( xSpacer ); - xPreviewCtrls->addWindow( &maBackwardBtn ); - xPreviewCtrls->addWindow( &maForwardBtn ); - xSpacer.reset( new vcl::Spacer( xPreviewCtrls.get(), 2 ) ); - xPreviewCtrls->addChild( xSpacer ); + mxPreviewCtrls.reset( new vcl::RowOrColumn( xPreview.get(), false ) ); + nIndex = xPreview->addChild( mxPreviewCtrls ); + boost::shared_ptr< vcl::Spacer > xSpacer( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); + mxPreviewCtrls->addChild( xSpacer ); + mxPreviewCtrls->addWindow( &maPageEdit ); + mxPreviewCtrls->addWindow( &maNumPagesText ); + xSpacer.reset( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); + mxPreviewCtrls->addChild( xSpacer ); + mxPreviewCtrls->addWindow( &maBackwardBtn ); + mxPreviewCtrls->addWindow( &maForwardBtn ); + xSpacer.reset( new vcl::Spacer( mxPreviewCtrls.get(), 2 ) ); + mxPreviewCtrls->addChild( xSpacer ); // continue with the tab ctrl xPreviewAndTab->addWindow( &maTabCtrl ); @@ -1718,6 +1718,11 @@ void PrintDialog::setPreviewText( sal_Int32 ) { rtl::OUString aNewText( searchAndReplace( maPageStr, "%n", 2, rtl::OUString::valueOf( mnCachedPages ) ) ); maNumPagesText.SetText( aNewText ); + + // if layout is already established the refresh layout of + // preview controls since text length may have changes + if( mxPreviewCtrls.get() ) + mxPreviewCtrls->setManagedArea( mxPreviewCtrls->getManagedArea() ); } void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache ) From c0879d0fd9c440e690ca24b4b4085b2863b46694 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 17:23:09 +0100 Subject: [PATCH 246/283] printerpullpages: #i106559# warn about missing default printer --- vcl/inc/vcl/svids.hrc | 1 + vcl/source/gdi/print.cxx | 13 ++++++++++--- vcl/source/gdi/print3.cxx | 19 ++++++++++++++++++- vcl/source/src/print.src | 6 ++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index c54dfb70c3ed..b3fcf9c70dd3 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -163,6 +163,7 @@ #define SV_PRINT_PROGRESS_TEXT 2 #define SV_PRINT_NATIVE_STRINGS 2050 +#define SV_PRINT_NOPRINTERWARNING 2051 #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index c70835de47e7..16f6b53af7a8 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -277,7 +277,9 @@ static void ImplInitPrnQueueList() pSVData->maGDIData.mpPrinterQueueList = new ImplPrnQueueList; - pSVData->mpDefInst->GetPrinterQueueInfo( pSVData->maGDIData.mpPrinterQueueList ); + static const char* pEnv = getenv( "SAL_DISABLE_PRINTERLIST" ); + if( !pEnv || !*pEnv ) + pSVData->mpDefInst->GetPrinterQueueInfo( pSVData->maGDIData.mpPrinterQueueList ); } // ----------------------------------------------------------------------- @@ -336,9 +338,14 @@ const QueueInfo* Printer::GetQueueInfo( const String& rPrinterName, bool bStatus XubString Printer::GetDefaultPrinterName() { - ImplSVData* pSVData = ImplGetSVData(); + static const char* pEnv = getenv( "SAL_DISABLE_DEFAULTPRINTER" ); + if( !pEnv || !*pEnv ) + { + ImplSVData* pSVData = ImplGetSVData(); - return pSVData->mpDefInst->GetDefaultPrinter(); + return pSVData->mpDefInst->GetDefaultPrinter(); + } + return XubString(); } // ======================================================================= diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 609fe5ad339b..e958994c0c6a 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -38,6 +38,7 @@ #include "vcl/salprn.hxx" #include "vcl/svids.hrc" #include "vcl/metaact.hxx" +#include "vcl/msgbox.hxx" #include "tools/urlobj.hxx" @@ -310,8 +311,24 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr const JobSetup& i_rInitSetup ) { - // setup printer boost::shared_ptr pController( i_pController ); + + // check if there is a default printer; if not, show an error box (if appropriate) + if( GetDefaultPrinterName().Len() == 0 ) + { + if( pController->isShowDialogs() + // && ! pController->isDirectPrint() + ) + { + ErrorBox aBox( NULL, VclResId( SV_PRINT_NOPRINTERWARNING ) ); + aBox.Execute(); + } + pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDirect" ) ), + makeAny( sal_False ) ); + } + + // setup printer + // if no specific printer is already set, create one if( ! pController->getPrinter() ) { diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 856ba88525fa..83ea13e8478a 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -465,6 +465,12 @@ ModelessDialog SV_DLG_PRINT_PROGRESS }; }; +ErrorBox SV_PRINT_NOPRINTERWARNING +{ + Title = "%PRODUCTNAME"; + Message [en-US] = "No default printer found.\nPlease choose a printer and try again."; +}; + StringArray SV_PRINT_NATIVE_STRINGS { ItemList [en-US] = From 7a172afb40d89766934075116f7b3a695f09b8b5 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 18:22:58 +0100 Subject: [PATCH 247/283] printerpullpages: #i106506# disable Pages radio button where unused --- vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/window/printdlg.cxx | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index deebb1f11254..e19b95023c75 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -101,6 +101,7 @@ namespace vcl FixedLine maNupLine; RadioButton maPagesBtn; RadioButton maBrochureBtn; + FixedText maPagesBoxTitleTxt; ListBox maNupPagesBox; // controls for "Custom" page mode @@ -126,6 +127,7 @@ namespace vcl vcl::RowOrColumn maLayout; boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; + boost::shared_ptr< vcl::LabeledElement >mxPagesBtnLabel; void setupLayout(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a3badf32887f..1091c4c5b479 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -285,6 +285,7 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) , maNupLine( this, VclResId( SV_PRINT_PRT_NUP_LAYOUT_FL ) ) , maPagesBtn( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BTN ) ) , maBrochureBtn( this, VclResId( SV_PRINT_PRT_NUP_BROCHURE_BTN ) ) + , maPagesBoxTitleTxt( this, 0 ) , maNupPagesBox( this, VclResId( SV_PRINT_PRT_NUP_PAGES_BOX ) ) , maNupNumPagesTxt( this, VclResId( SV_PRINT_PRT_NUP_NUM_PAGES_TXT ) ) , maNupColEdt( this, VclResId( SV_PRINT_PRT_NUP_COLS_EDT ) ) @@ -330,6 +331,7 @@ PrintDialog::NUpTabPage::NUpTabPage( Window* i_pParent, const ResId& rResId ) maNupLine.SMHID2("NUpPage", "Layout"); maBrochureBtn.SMHID2("NUpPage", "Brochure" ); maPagesBtn.SMHID2( "NUpPage", "PagesPerSheet" ); + maPagesBoxTitleTxt.SMHID2( "NUpPage", "PagesPerSheetLabel" ); maNupPagesBox.SMHID2( "NUpPage", "PagesPerSheetBox" ); maNupNumPagesTxt.SMHID2( "NUpPage", "Columns" ); maNupColEdt.SMHID2( "NUpPage", "ColumnsBox" ); @@ -415,7 +417,8 @@ void PrintDialog::NUpTabPage::setupLayout() boost::shared_ptr< vcl::LabelColumn > xMainCol( new vcl::LabelColumn( xIndent.get() ) ); xIndent->setChild( xMainCol ); - xMainCol->addRow( &maPagesBtn, &maNupPagesBox ); + size_t nPagesIndex = xMainCol->addRow( &maPagesBtn, &maNupPagesBox ); + mxPagesBtnLabel = boost::dynamic_pointer_cast( xMainCol->getChild( nPagesIndex ) ); xRow.reset( new vcl::RowOrColumn( xMainCol.get(), false ) ); xMainCol->addRow( &maNupNumPagesTxt, xRow, nIndent ); @@ -1510,6 +1513,19 @@ void PrintDialog::setupOptionalUI() } } + // #i106506# if no brochure button, then the singular Pages radio button + // makes no sense, so replace it by a FixedText label + if( ! maNUpPage.maBrochureBtn.IsVisible() ) + { + if( maNUpPage.mxPagesBtnLabel.get() ) + { + maNUpPage.maPagesBoxTitleTxt.SetText( maNUpPage.maPagesBtn.GetText() ); + maNUpPage.maPagesBoxTitleTxt.Show( TRUE ); + maNUpPage.mxPagesBtnLabel->setLabel( &maNUpPage.maPagesBoxTitleTxt ); + maNUpPage.maPagesBtn.Show( FALSE ); + } + } + // update enable states checkOptionalControlDependencies(); From 969bf03a947d80eacf0deb3c7a3fdfb86b2f5aba Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 19:19:29 +0100 Subject: [PATCH 248/283] printerpullpages: #i106507# remove layout page for math --- vcl/inc/vcl/print.hxx | 4 ++++ vcl/inc/vcl/prndlg.hxx | 2 ++ vcl/source/gdi/print3.cxx | 19 +++++++++++-------- vcl/source/window/printdlg.cxx | 14 ++++++++++++-- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index 25ace16aea52..e91e3db0c9d7 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -460,6 +460,10 @@ public: const com::sun::star::beans::PropertyValue* getValue( const rtl::OUString& i_rPropertyName ) const; // get a sequence of properties com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getValues( const com::sun::star::uno::Sequence< rtl::OUString >& ) const; + /* get a bool property + in case the property is unknown or not convertible to bool, i_bFallback is returned + */ + sal_Bool getBoolProperty( const rtl::OUString& i_rPropertyName, sal_Bool i_bFallback ) const; /* set a property value - can also be used to add another UI property */ diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index e19b95023c75..57a1e32df6d3 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -256,6 +256,8 @@ namespace vcl Size maDetailsCollapsedSize; Size maDetailsExpandedSize; + sal_Bool mbShowLayoutPage; + Size getJobPageSize(); void updateNup(); void updateNupFromPages(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e958994c0c6a..287969a146f3 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1413,22 +1413,25 @@ void PrinterController::pushPropertiesToPrinter() bool PrinterController::isShowDialogs() const { - sal_Bool bApi = sal_False; - const com::sun::star::beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsApi" ) ) ); - if( pVal ) - pVal->Value >>= bApi; + sal_Bool bApi = getBoolProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsApi" ) ), sal_False ); return ! bApi && ! Application::IsHeadlessModeEnabled(); } bool PrinterController::isDirectPrint() const { - sal_Bool bDirect = sal_False; - const com::sun::star::beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDirect" ) ) ); - if( pVal ) - pVal->Value >>= bDirect; + sal_Bool bDirect = getBoolProperty( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDirect" ) ), sal_False ); return bDirect == sal_True; } +sal_Bool PrinterController::getBoolProperty( const rtl::OUString& i_rProperty, sal_Bool i_bFallback ) const +{ + sal_Bool bRet = i_bFallback; + const com::sun::star::beans::PropertyValue* pVal = getValue( i_rProperty ); + if( pVal ) + pVal->Value >>= bRet; + return bRet; +} + /* * PrinterOptionsHelper **/ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1091c4c5b479..971c629058c5 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -725,6 +725,7 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr>= bNoLayoutPage; + mbShowLayoutPage = ! bNoLayoutPage; + } } // bUseDependencyRow should only be true if a dependency exists From 7e6ad41f327ffc8b3c783d0311f7ba5f1210fe1c Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 20:35:31 +0100 Subject: [PATCH 249/283] printerpullpages: #i106423# show a warning in case of empty direct print job --- vcl/inc/vcl/svids.hrc | 1 + vcl/source/gdi/print3.cxx | 12 ++++++++++++ vcl/source/src/print.src | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index b3fcf9c70dd3..07923e33a4b0 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -164,6 +164,7 @@ #define SV_PRINT_NATIVE_STRINGS 2050 #define SV_PRINT_NOPRINTERWARNING 2051 +#define SV_PRINT_NOCONTENT 2052 #define SV_HELPTEXT_CLOSE 10000 #define SV_HELPTEXT_MINIMIZE 10001 diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 287969a146f3..1617e76cb9b2 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -403,6 +403,18 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr pController->setReversePrint( bReverse ); } + // in direct print case check whether there is anything to print. + // if not, show an errorbox (if appropriate) + if( pController->isShowDialogs() && pController->isDirectPrint() ) + { + if( pController->getFilteredPageCount() == 0 ) + { + ErrorBox aBox( NULL, VclResId( SV_PRINT_NOCONTENT ) ); + aBox.Execute(); + return; + } + } + // check if the printer brings up its own dialog // in that case leave the work to that dialog if( ! pController->getPrinter()->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) && diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index 83ea13e8478a..c1857544c708 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -471,6 +471,12 @@ ErrorBox SV_PRINT_NOPRINTERWARNING Message [en-US] = "No default printer found.\nPlease choose a printer and try again."; }; +ErrorBox SV_PRINT_NOCONTENT +{ + Title = "%PRODUCTNAME"; + Message [en-US] = "There are no pages to be printed. Please check your document for ranges relevant to printing."; +}; + StringArray SV_PRINT_NATIVE_STRINGS { ItemList [en-US] = From 3c50f92e70664eaabc4bbb0e79440ad3a5a7f2ce Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Wed, 18 Nov 2009 20:51:54 +0100 Subject: [PATCH 250/283] printerpullpages: #i107010# fix persistency issue --- vcl/source/window/printdlg.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 971c629058c5..c53d19d6d2dc 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -870,12 +870,6 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr Date: Thu, 19 Nov 2009 12:57:05 +0100 Subject: [PATCH 251/283] aw078: changes after resync --- basegfx/test/basegfx2d.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index eadd99d31a42..639933ace1e6 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -484,10 +484,13 @@ public: } while ( nIndex >= 0 ); - // Adapted number of spaces from 50 to 67 because of the new circle construction - // methods which produce more points and thus more spaces, too. + // Adapted number of spaces to 50 and 67 because of the new circle construction + // methods which produce more points and thus more spaces, too. Use both since + // depending on float precision and the getContinuity() implemetation using + // fTools::equal, linux and mac produce more 'C' than 'S' statements, while WIN32 + // uses more 'S' statements (as it should be for circles) CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", - nCount==67); + nCount==67 || nCount==50); const B2DPolygon aRect( tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) )); From 05d581ee63794413288114325b6fba762be24206 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 19 Nov 2009 18:50:20 +0100 Subject: [PATCH 252/283] printerpullpages: #i106560# fix theming / HC --- vcl/source/window/printdlg.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index c53d19d6d2dc..e0c8bdc71caf 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -68,7 +68,10 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const Re { SetPaintTransparent( TRUE ); SetBackground(); - maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); + if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); + else + maPageVDev.SetBackground( Color( COL_WHITE ) ); } PrintDialog::PrintPreviewWindow::~PrintPreviewWindow() @@ -80,7 +83,10 @@ void PrintDialog::PrintPreviewWindow::DataChanged( const DataChangedEvent& i_rDC // react on settings changed if( i_rDCEvt.GetType() == DATACHANGED_SETTINGS ) { - maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); + if( GetSettings().GetStyleSettings().GetHighContrastMode() ) + maPageVDev.SetBackground( GetSettings().GetStyleSettings().GetWindowColor() ); + else + maPageVDev.SetBackground( Color( COL_WHITE ) ); } Window::DataChanged( i_rDCEvt ); } @@ -206,6 +212,13 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi SetQuickHelpText( aBuf.makeStringAndClear() ); #endif maMtf = i_rNewPreview; + if( GetSettings().GetStyleSettings().GetHighContrastMode() && + GetSettings().GetStyleSettings().GetWindowColor().IsDark() + ) + { + maMtf.ReplaceColors( Color( COL_BLACK ), Color( COL_WHITE ), 30 ); + } + maOrigSize = i_rOrigSize; maReplacementString = i_rReplacement; maPageVDev.SetReferenceDevice( i_nDPIX, i_nDPIY ); From 3b6800d565cadc9e0e20da2d9725a87bcb114153 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 19 Nov 2009 18:55:41 +0100 Subject: [PATCH 253/283] printerpullpages: #i106192# evaluate error state after failed StartJob --- vcl/source/gdi/print3.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 1617e76cb9b2..d5d8392b2f45 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -588,11 +588,12 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptrsetJobState( view::PrintableState_JOB_FAILED ); - mnError = ImplSalPrinterErrorCodeToVCL( mpPrinter->GetErrorCode() ); if ( !mnError ) mnError = PRINTER_GENERALERROR; + i_pController->setJobState( mnError == PRINTER_ABORT + ? view::PrintableState_JOB_ABORTED + : view::PrintableState_JOB_FAILED ); pSVData->mpDefInst->DestroyPrinter( mpPrinter ); mnCurPage = 0; mnCurPrintPage = 0; From 4e0900fa9fae5db6d77fa759bf49164af21b83b9 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 20 Nov 2009 15:27:46 +0100 Subject: [PATCH 254/283] printerpullpages: #i91478# improvements for mac native print dialog --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 138 ++++++------------ 1 file changed, 47 insertions(+), 91 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 52f6c8c5b575..bde2a595bce1 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -567,7 +567,7 @@ static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) // resize the view itself aUnion.size.height += 10; - aUnion.size.width += 10; + aUnion.size.width += 20; [pView setFrameSize: aUnion.size]; if( aUnion.size.width > rMaxSize.width ) @@ -601,12 +601,34 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) NSView* pCurSubView = [pSubViews objectAtIndex: n]; NSRect aFrame = [pCurSubView frame]; aFrame.origin.y += nDiff; + // give separators the correct width + // separators are currently the only NSBoxes we use + if( [pCurSubView isMemberOfClass: [NSBox class]] ) + { + aFrame.size.width = aTabSize.width - aFrame.origin.x - 10; + } [pCurSubView setFrame: aFrame]; } } } } +static NSControl* createLabel( const rtl::OUString& i_rText ) +{ + NSString* pText = CreateNSString( i_rText ); + NSRect aTextRect = { { 0, 0 }, {20, 15} }; + NSTextField* pTextView = [[NSTextField alloc] initWithFrame: aTextRect]; + [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; + [pTextView setEditable: NO]; + [pTextView setSelectable: NO]; + [pTextView setDrawsBackground: NO]; + [pTextView setBordered: NO]; + [pTextView setStringValue: pText]; + [pTextView sizeToFit]; + [pText release]; + return pTextView; +} + @implementation AquaPrintAccessoryView +(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withController: (vcl::PrinterController*)pController withState: (PrintAccessoryViewState*)pState; @@ -703,7 +725,7 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) // so we have a single accessory view that is tabbed for grouping if( aCtrlType.equalsAscii( "Group" ) || ! pCurParent - || ( aCtrlType.equalsAscii( "Subgroup" ) && nCurY < -200 && ! bIgnore ) + || ( aCtrlType.equalsAscii( "Subgroup" ) && nCurY < -250 && ! bIgnore ) ) { rtl::OUString aGroupTitle( aText ); @@ -736,40 +758,20 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) if( bIgnore ) continue; - // if this is not the first view on the page - // insert a separator - NSArray* pArray = [pCurParent subviews]; - if( pArray && [pArray count] > 0 ) - { - NSRect aSepRect = { { 0, nCurY - 15 }, { 300, 15 } }; - NSBox* pBox = [[NSBox alloc] initWithFrame: aSepRect]; - [pBox setBoxType: NSBoxSeparator]; - [pCurParent addSubview: pBox]; - - nCurY -= 15; - } - - NSString* pText = CreateNSString( aText ); - NSRect aTextRect = { { 0, 0 }, { 300, 15 } }; - NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; - [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; - [pTextView setEditable: NO]; - [pTextView setSelectable: NO]; - [pTextView setDrawsBackground: NO]; - [pTextView setString: pText]; - [pTextView sizeToFit]; // FIXME: this does nothing - [pCurParent addSubview: [pTextView autorelease]]; - - aTextRect = [pTextView frame]; + NSControl* pTextView = createLabel( aText ); + [pCurParent addSubview: [pTextView autorelease]]; + NSRect aTextRect = [pTextView frame]; // move to nCurY aTextRect.origin.y = nCurY - aTextRect.size.height; [pTextView setFrame: aTextRect]; + + NSRect aSepRect = { { aTextRect.size.width + 1, aTextRect.origin.y }, { 100, 6 } }; + NSBox* pBox = [[NSBox alloc] initWithFrame: aSepRect]; + [pBox setBoxType: NSBoxSeparator]; + [pCurParent addSubview: [pBox autorelease]]; // update nCurY nCurY = aTextRect.origin.y - 5; - - // cleanup - [pText release]; } else if( bIgnoreSubgroup || bIgnore ) continue; @@ -813,15 +815,9 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) if( aText.getLength() ) { // add a label - NSString* pText = CreateNSString( aText ); - NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, { 300, 15 } }; - NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; - [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; - [pTextView setEditable: NO]; - [pTextView setSelectable: NO]; - [pTextView setDrawsBackground: NO]; - [pTextView setString: pText]; - [pTextView sizeToFit]; // FIXME: this does nothing + NSControl* pTextView = createLabel( aText ); + NSRect aTextRect = [pTextView frame]; + aTextRect.origin.x = nCurX + nAttachOffset; [pCurParent addSubview: [pTextView autorelease]]; // move to nCurY @@ -833,9 +829,6 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) // indent the radio group relative to the text // nOff = 20; - - // cleanup - [pText release]; } // setup radio matrix @@ -888,32 +881,11 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) } else if( aCtrlType.equalsAscii( "List" ) && pCurParent ) { - NSString* pText = CreateNSString( aText ); - - // measure the text - NSFont* pFont = [NSFont controlContentFontOfSize: 0]; - NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont - forKey: NSFontAttributeName]; - - NSSize aTextSize = [pText sizeWithAttributes: pDict]; - // leave a little space - aTextSize.width += 10; - aTextSize.height += 3; - // don't indent attached lists, looks bad in the existing cases - NSRect aTextRect = { { nCurX /* + nAttachOffset*/, 0 }, aTextSize }; - NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; - [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; - [pTextView setEditable: NO]; - [pTextView setSelectable: NO]; - [pTextView setDrawsBackground: NO]; - [pTextView setString: pText]; - [pTextView setVerticallyResizable: NO]; - [pTextView setHorizontallyResizable: YES]; - [pTextView sizeToFit]; // FIXME: this actually does nothing + NSControl* pTextView = createLabel( aText ); [pCurParent addSubview: [pTextView autorelease]]; - aTextRect = [pTextView frame]; - + NSRect aTextRect = [pTextView frame]; + aTextRect.origin.x = nCurX /* + nAttachOffset*/; // don't indent attached lists, looks bad in the existing cases NSRect aBtnRect = { { nCurX /*+ nAttachOffset*/ + aTextRect.size.width, 0 }, { 0, 15 } }; @@ -959,9 +931,6 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) // update nCurY nCurY = aBtnRect.origin.y - 5; - - // cleanup - [pText release]; } else if( (aCtrlType.equalsAscii( "Edit" ) || aCtrlType.equalsAscii( "Range" )) && pCurParent ) { @@ -969,27 +938,12 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) if( aText.getLength() ) { // add a label - NSString* pText = CreateNSString( aText ); - NSFont* pFont = [NSFont controlContentFontOfSize: 0]; - NSDictionary* pDict = [NSDictionary dictionaryWithObject: pFont - forKey: NSFontAttributeName]; - - NSSize aTextSize = [pText sizeWithAttributes: pDict]; - // leave a little space - aTextSize.width += 10; - aTextSize.height += 3; - - NSRect aTextRect = { { nCurX + nAttachOffset, 0 }, aTextSize }; - NSTextView* pTextView = [[NSTextView alloc] initWithFrame: aTextRect]; - [pTextView setFont: [NSFont controlContentFontOfSize: 0]]; - [pTextView setEditable: NO]; - [pTextView setSelectable: NO]; - [pTextView setDrawsBackground: NO]; - [pTextView setString: pText]; - [pTextView sizeToFit]; // FIXME: this does nothing + NSControl* pTextView = createLabel( aText ); [pCurParent addSubview: [pTextView autorelease]]; // move to nCurY + NSRect aTextRect = [pTextView frame]; + aTextRect.origin.x = nCurX + nAttachOffset; aTextRect.origin.y = nCurY - aTextRect.size.height; [pTextView setFrame: aTextRect]; @@ -997,10 +951,7 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) nCurY = aTextRect.origin.y - 5; // and set the offset for the real edit field - nOff = aTextSize.width + 5; - - // cleanup - [pText release]; + nOff = aTextRect.size.width + 5; } NSRect aFieldRect = { { nCurX + nOff + nAttachOffset, 0 }, { 100, 25 } }; @@ -1097,9 +1048,14 @@ static void adjustTabViews( NSTabView* pTabView, NSSize aTabSize ) DBG_ERROR( "Unsupported UI option" ); } } + pControllerProperties->updateEnableState(); adjustViewAndChildren( pCurParent, aMaxTabSize ); + // leave some space for the preview + if( aMaxTabSize.height < 200 ) + aMaxTabSize.height = 200; + // now reposition everything again so it is upper bound adjustTabViews( pTabView, aMaxTabSize ); From a3235d7e7a5b59fc8af646867766ad807da0c78e Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 23 Nov 2009 12:30:29 +0100 Subject: [PATCH 255/283] aw078: #i106541# MetaTextRectAction implementation added, corrected/changed FontHandling when no FontSize is given --- vcl/inc/vcl/outdev.hxx | 7 ++++++- vcl/source/gdi/outdev6.cxx | 14 +++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx index f824151737d2..464b129fdb64 100644 --- a/vcl/inc/vcl/outdev.hxx +++ b/vcl/inc/vcl/outdev.hxx @@ -1104,7 +1104,12 @@ public: */ BOOL HasAlpha(); - void DrawEPS( const Point& rPt, const Size& rSz, + /** Added return value to see if EPS could be painted directly. + Theoreticaly, handing over a matrix would be needed to handle + painting rotated EPS files (e.g. contained mín Metafiles). This + would then need to be supported for Mac and PS printers, but + that's too much for now, wrote #i107046# for this */ + bool DrawEPS( const Point& rPt, const Size& rSz, const GfxLink& rGfxLink, GDIMetaFile* pSubst = NULL ); /// request XCanvas render interface for this OutputDevice diff --git a/vcl/source/gdi/outdev6.cxx b/vcl/source/gdi/outdev6.cxx index 79986988afd7..2d436ea43659 100644 --- a/vcl/source/gdi/outdev6.cxx +++ b/vcl/source/gdi/outdev6.cxx @@ -1158,9 +1158,11 @@ void OutputDevice::ImplDraw2ColorFrame( const Rectangle& rRect, // ----------------------------------------------------------------------- -void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, +bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, const GfxLink& rGfxLink, GDIMetaFile* pSubst ) { + bool bDrawn(true); + if ( mpMetaFile ) { GDIMetaFile aSubst; @@ -1172,20 +1174,20 @@ void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, } if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) - return; + return bDrawn; if( mbOutputClipped ) - return; + return bDrawn; Rectangle aRect( ImplLogicToDevicePixel( Rectangle( rPoint, rSize ) ) ); + if( !aRect.IsEmpty() ) { // draw the real EPS graphics - bool bDrawn = FALSE; if( rGfxLink.GetData() && rGfxLink.GetDataSize() ) { if( !mpGraphics && !ImplGetGraphics() ) - return; + return bDrawn; if( mbInitClipRegion ) ImplInitClipRegion(); @@ -1208,4 +1210,6 @@ void OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, if( mpAlphaVDev ) mpAlphaVDev->DrawEPS( rPoint, rSize, rGfxLink, pSubst ); + + return bDrawn; } From 9bf73f92e0645538720958375b2930bead4d8dc7 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 23 Nov 2009 12:38:01 +0100 Subject: [PATCH 256/283] printerpullpages: #i91478# base dialog layout on HIG --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 159 ++++++++++++++++-- 1 file changed, 146 insertions(+), 13 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index bde2a595bce1..60fac0dfae29 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -543,8 +543,97 @@ static void filterAccelerator( rtl::OUString& io_rText ) } @end -static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize ) +struct ColumnItem { + NSControl* pControl; + long nOffset; + NSControl* pSubControl; + + ColumnItem( NSControl* i_pControl = nil, long i_nOffset = 0, NSControl* i_pSub = nil ) + : pControl( i_pControl ) + , nOffset( i_nOffset ) + , pSubControl( i_pSub ) + {} + + long getWidth() const + { + long nWidth = 0; + if( pControl ) + { + NSRect aCtrlRect = [pControl frame]; + nWidth = aCtrlRect.size.width; + nWidth += nOffset; + if( pSubControl ) + { + NSRect aSubRect = [pSubControl frame]; + nWidth += aSubRect.size.width; + nWidth += aSubRect.origin.x - (aCtrlRect.origin.x + aCtrlRect.size.width); + } + } + return nWidth; + } +}; + +static void adjustViewAndChildren( NSView* pView, NSSize& rMaxSize, + std::vector< ColumnItem >& rLeftColumn, + std::vector< ColumnItem >& rRightColumn + ) +{ + // balance columns + + // first get overall column widths + long nLeftWidth = 0; + long nRightWidth = 0; + for( size_t i = 0; i < rLeftColumn.size(); i++ ) + { + long nW = rLeftColumn[i].getWidth(); + if( nW > nLeftWidth ) + nLeftWidth = nW; + } + for( size_t i = 0; i < rRightColumn.size(); i++ ) + { + long nW = rRightColumn[i].getWidth(); + if( nW > nRightWidth ) + nRightWidth = nW; + } + + // right align left column + for( size_t i = 0; i < rLeftColumn.size(); i++ ) + { + if( rLeftColumn[i].pControl ) + { + NSRect aCtrlRect = [rLeftColumn[i].pControl frame]; + long nX = nLeftWidth - aCtrlRect.size.width; + if( rLeftColumn[i].pSubControl ) + { + NSRect aSubRect = [rLeftColumn[i].pSubControl frame]; + nX -= aSubRect.size.width + (aSubRect.origin.x - (aCtrlRect.origin.x + aCtrlRect.size.width)); + aSubRect.origin.x = nLeftWidth - aSubRect.size.width; + [rLeftColumn[i].pSubControl setFrame: aSubRect]; + } + aCtrlRect.origin.x = nX; + [rLeftColumn[i].pControl setFrame: aCtrlRect]; + } + } + + // left align right column + for( size_t i = 0; i < rRightColumn.size(); i++ ) + { + if( rRightColumn[i].pControl ) + { + NSRect aCtrlRect = [rRightColumn[i].pControl frame]; + long nX = nLeftWidth + 3; + if( rRightColumn[i].pSubControl ) + { + NSRect aSubRect = [rRightColumn[i].pSubControl frame]; + aSubRect.origin.x = nX + aSubRect.origin.x - aCtrlRect.origin.x; + [rRightColumn[i].pSubControl setFrame: aSubRect]; + } + aCtrlRect.origin.x = nX; + [rRightColumn[i].pControl setFrame: aCtrlRect]; + } + } + NSArray* pSubViews = [pView subviews]; unsigned int nViews = [pSubViews count]; NSRect aUnion = { { 0, 0 }, { 0, 0 } }; @@ -629,6 +718,32 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) return pTextView; } +static void linebreakCell( NSCell* pBtn, const rtl::OUString& i_rText ) +{ + NSString* pText = CreateNSString( i_rText ); + [pBtn setTitle: pText]; + [pText release]; + NSSize aSize = [pBtn cellSize]; + if( aSize.width > 280 ) + { + // need two lines + // FIXME: dummy code, should really use linebreaking service instead + const sal_Unicode* pStr = i_rText.getStr(); + sal_Int32 nLen = i_rText.getLength(); + sal_Int32 nIndex = nLen / 2; + while( nIndex < nLen && pStr[nIndex] != ' ' ) + nIndex++; + if( nIndex < nLen ) + { + rtl::OUStringBuffer aBuf( i_rText ); + aBuf.setCharAt( nIndex, '\n' ); + pText = CreateNSString( aBuf.makeStringAndClear() ); + [pBtn setTitle: pText]; + [pText release]; + } + } +} + @implementation AquaPrintAccessoryView +(NSObject*)setupPrinterPanel: (NSPrintOperation*)pOp withController: (vcl::PrinterController*)pController withState: (PrintAccessoryViewState*)pState; @@ -641,7 +756,7 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) long nCurY = 0; long nCurX = 0; NSRect aViewFrame = { { 0, 0 }, {600, 400 } }; - NSRect aTabViewFrame = { { 200, 0 }, {400, 400 } }; + NSRect aTabViewFrame = { { 190, 0 }, {410, 400 } }; NSSize aMaxTabSize = { 0, 0 }; NSView* pAccessoryView = [[NSView alloc] initWithFrame: aViewFrame]; NSTabView* pTabView = [[NSTabView alloc] initWithFrame: aTabViewFrame]; @@ -651,6 +766,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) ControllerProperties* pControllerProperties = new ControllerProperties( pController, pOp, pAccessoryView, pTabView, pState ); ControlTarget* pCtrlTarget = [[ControlTarget alloc] initWithControllerMap: pControllerProperties]; + + std::vector< ColumnItem > aLeftColumn, aRightColumn; for( int i = 0; i < rOptions.getLength(); i++ ) { @@ -733,7 +850,7 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) aGroupTitle = pControllerProperties->getMoreString(); // set size of current parent if( pCurParent ) - adjustViewAndChildren( pCurParent, aMaxTabSize ); + adjustViewAndChildren( pCurParent, aMaxTabSize, aLeftColumn, aRightColumn ); // new tab item if( ! aText.getLength() ) @@ -750,6 +867,9 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) nCurX = 20; // reset Y nCurY = 0; + // clear columns + aLeftColumn.clear(); + aRightColumn.clear(); } if( aCtrlType.equalsAscii( "Subgroup" ) && pCurParent ) @@ -777,19 +897,20 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) continue; else if( aCtrlType.equalsAscii( "Bool" ) && pCurParent ) { - NSString* pText = CreateNSString( aText ); NSRect aCheckRect = { { nCurX + nAttachOffset, 0 }, { 0, 15 } }; NSButton* pBtn = [[NSButton alloc] initWithFrame: aCheckRect]; - [pBtn setButtonType: NSSwitchButton]; - [pBtn setTitle: pText]; + [pBtn setButtonType: NSSwitchButton]; sal_Bool bVal = sal_False; PropertyValue* pVal = pController->getValue( aPropertyName ); if( pVal ) pVal->Value >>= bVal; [pBtn setState: bVal ? NSOnState : NSOffState]; + linebreakCell( [pBtn cell], aText ); [pBtn sizeToFit]; [pCurParent addSubview: [pBtn autorelease]]; + aRightColumn.push_back( ColumnItem( pBtn ) ); + // connect target [pBtn setTarget: pCtrlTarget]; [pBtn setAction: @selector(triggered:)]; @@ -805,9 +926,6 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) // update nCurY nCurY = aCheckRect.origin.y - 5; - - // cleanup - [pText release]; } else if( aCtrlType.equalsAscii( "Radio" ) && pCurParent ) { @@ -819,6 +937,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) NSRect aTextRect = [pTextView frame]; aTextRect.origin.x = nCurX + nAttachOffset; [pCurParent addSubview: [pTextView autorelease]]; + + aLeftColumn.push_back( ColumnItem( pTextView ) ); // move to nCurY aTextRect.origin.y = nCurY - aTextRect.size.height; @@ -853,15 +973,16 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) { NSCell* pCell = [pCells objectAtIndex: m]; filterAccelerator( aChoices[m] ); - NSString* pTitle = CreateNSString( aChoices[m] ); - [pCell setTitle: pTitle]; + linebreakCell( pCell, aChoices[m] ); + //NSString* pTitle = CreateNSString( aChoices[m] ); + //[pCell setTitle: pTitle]; // connect target and action [pCell setTarget: pCtrlTarget]; [pCell setAction: @selector(triggered:)]; int nTag = pControllerProperties->addNameAndValueTag( aPropertyName, m ); pControllerProperties->addObservedControl( pCell ); [pCell setTag: nTag]; - [pTitle release]; + //[pTitle release]; // set current selection if( nSelectVal == m ) [pMatrix selectCellAtRow: m column: 0]; @@ -874,6 +995,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) [pMatrix setFrame: aRadioRect]; [pCurParent addSubview: [pMatrix autorelease]]; + aRightColumn.push_back( ColumnItem( pMatrix ) ); + // update nCurY nCurY = aRadioRect.origin.y - 5; @@ -884,6 +1007,7 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) // don't indent attached lists, looks bad in the existing cases NSControl* pTextView = createLabel( aText ); [pCurParent addSubview: [pTextView autorelease]]; + aLeftColumn.push_back( ColumnItem( pTextView ) ); NSRect aTextRect = [pTextView frame]; aTextRect.origin.x = nCurX /* + nAttachOffset*/; @@ -915,6 +1039,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) [pBtn sizeToFit]; [pCurParent addSubview: [pBtn autorelease]]; + + aRightColumn.push_back( ColumnItem( pBtn ) ); // connect target and action [pBtn setTarget: pCtrlTarget]; @@ -941,6 +1067,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) NSControl* pTextView = createLabel( aText ); [pCurParent addSubview: [pTextView autorelease]]; + aLeftColumn.push_back( ColumnItem( pTextView ) ); + // move to nCurY NSRect aTextRect = [pTextView frame]; aTextRect.origin.x = nCurX + nAttachOffset; @@ -962,6 +1090,8 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) [pFieldView sizeToFit]; // FIXME: this does nothing [pCurParent addSubview: [pFieldView autorelease]]; + aRightColumn.push_back( ColumnItem( pFieldView ) ); + // add the field to observed controls for enabled state changes // also add a tag just for this purpose pControllerProperties->addObservedControl( pFieldView ); @@ -986,6 +1116,9 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) [pStep setValueWraps: NO]; [pStep setTag: nTag]; [pCurParent addSubview: [pStep autorelease]]; + + aRightColumn.back().pSubControl = pStep; + pControllerProperties->addObservedControl( pStep ); [pStep setTarget: pCtrlTarget]; [pStep setAction: @selector(triggered:)]; @@ -1050,7 +1183,7 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) } pControllerProperties->updateEnableState(); - adjustViewAndChildren( pCurParent, aMaxTabSize ); + adjustViewAndChildren( pCurParent, aMaxTabSize, aLeftColumn, aRightColumn ); // leave some space for the preview if( aMaxTabSize.height < 200 ) From b0fe07fec29262fdc5e1aaf97812caadbb9d5c15 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 23 Nov 2009 13:30:17 +0100 Subject: [PATCH 257/283] printerpullpages: #i106836# allow less strict parsing of passed ranges string --- tools/inc/tools/multisel.hxx | 4 ++-- tools/source/memtools/multisel.cxx | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx index bd2f7023bf8d..9de3cc172e70 100644 --- a/tools/inc/tools/multisel.hxx +++ b/tools/inc/tools/multisel.hxx @@ -131,7 +131,7 @@ class TOOLS_DLLPUBLIC StringRangeEnumerator sal_Int32 mnMax; sal_Int32 mnOffset; - bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence ); + bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence, bool bMayAdjust ); bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; public: class TOOLS_DLLPUBLIC Iterator @@ -177,7 +177,7 @@ public: sal_Int32 getLogicalOffset() const { return mnOffset; } void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } - bool setRange( const rtl::OUString& i_rNewRange ); + bool setRange( const rtl::OUString& i_rNewRange, bool i_bStrict = false ); bool hasValue( sal_Int32 nValue, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx index 4f5ccbbabeae..5fe920b6998a 100644 --- a/tools/source/memtools/multisel.cxx +++ b/tools/source/memtools/multisel.cxx @@ -901,7 +901,7 @@ bool StringRangeEnumerator::checkValue( sal_Int32 i_nValue, const std::set< sal_ return true; } -bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence ) +bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, bool bSequence, bool bMayAdjust ) { bool bSuccess = true; if( bSequence ) @@ -910,6 +910,17 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, i_nFirst = mnMin; if( i_nLast == -1 ) i_nLast = mnMax; + if( bMayAdjust ) + { + if( i_nFirst < mnMin ) + i_nFirst = mnMin; + if( i_nFirst > mnMax ) + i_nFirst = mnMax; + if( i_nLast < mnMin ) + i_nLast = mnMin; + if( i_nLast > mnMax ) + i_nLast = mnMax; + } if( checkValue( i_nFirst ) && checkValue( i_nLast ) ) { maSequence.push_back( Range( i_nFirst, i_nLast ) ); @@ -947,7 +958,7 @@ bool StringRangeEnumerator::insertRange( sal_Int32 i_nFirst, sal_Int32 i_nLast, return bSuccess; } -bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) +bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange, bool i_bStrict ) { mnCount = 0; maSequence.clear(); @@ -957,7 +968,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { if( mnMin >= 0 && mnMax >= 0 ) { - insertRange( mnMin, mnMax, mnMin != mnMax ); + insertRange( mnMin, mnMax, mnMin != mnMax, ! i_bStrict ); } return true; } @@ -977,7 +988,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) { if( bSequence ) { - if( ! insertRange( nLastNumber, nNumber, true ) ) + if( ! insertRange( nLastNumber, nNumber, true, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -986,7 +997,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) } else { - if( ! insertRange( nNumber, nNumber, false ) ) + if( ! insertRange( nNumber, nNumber, false, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -1017,7 +1028,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) if( bInsertRange ) { - if( ! insertRange( nLastNumber, nNumber, bSequence ) ) + if( ! insertRange( nLastNumber, nNumber, bSequence, ! i_bStrict ) && i_bStrict ) { bSuccess = false; break; @@ -1029,7 +1040,7 @@ bool StringRangeEnumerator::setRange( const rtl::OUString& i_rNewRange ) pInput++; } // insert last entries - insertRange( nLastNumber, nNumber, bSequence ); + insertRange( nLastNumber, nNumber, bSequence, ! i_bStrict ); return bSuccess; } From 5d7cea9f0f556b7e88921b206683f9c968261a50 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 23 Nov 2009 15:45:18 +0100 Subject: [PATCH 258/283] printerpullpages: #i91478# proper word breaking --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 60fac0dfae29..9e37c0632f4e 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -37,11 +37,16 @@ #include "vcl/image.hxx" #include "vcl/virdev.hxx" #include "vcl/svdata.hxx" +#include "vcl/svapp.hxx" +#include "vcl/unohelp.hxx" #include "vcl/svids.hrc" #include "tools/resary.hxx" +#include "com/sun/star/i18n/XBreakIterator.hpp" +#include "com/sun/star/i18n/WordType.hpp" + #include using namespace vcl; @@ -718,6 +723,21 @@ static NSControl* createLabel( const rtl::OUString& i_rText ) return pTextView; } +static sal_Int32 findBreak( const rtl::OUString& i_rText, sal_Int32 i_nPos ) +{ + sal_Int32 nRet = i_rText.getLength(); + Reference< i18n::XBreakIterator > xBI( vcl::unohelper::CreateBreakIterator() ); + if( xBI.is() ) + { + i18n::Boundary aBoundary = xBI->getWordBoundary( i_rText, i_nPos, + Application::GetSettings().GetLocale(), + i18n::WordType::ANYWORD_IGNOREWHITESPACES, + sal_True ); + nRet = aBoundary.endPos; + } + return nRet; +} + static void linebreakCell( NSCell* pBtn, const rtl::OUString& i_rText ) { NSString* pText = CreateNSString( i_rText ); @@ -727,12 +747,9 @@ static void linebreakCell( NSCell* pBtn, const rtl::OUString& i_rText ) if( aSize.width > 280 ) { // need two lines - // FIXME: dummy code, should really use linebreaking service instead - const sal_Unicode* pStr = i_rText.getStr(); sal_Int32 nLen = i_rText.getLength(); sal_Int32 nIndex = nLen / 2; - while( nIndex < nLen && pStr[nIndex] != ' ' ) - nIndex++; + nIndex = findBreak( i_rText, nIndex ); if( nIndex < nLen ) { rtl::OUStringBuffer aBuf( i_rText ); From aed7c63fea58badc64a0b6be2122b97de4520e95 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Tue, 24 Nov 2009 12:13:33 +0100 Subject: [PATCH 259/283] #i103340# added MaskPrimitive2D::getB2DRange implementation --- tools/source/generic/poly.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 5cca29b3066e..eb8442f7cd93 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -1668,7 +1668,16 @@ void Polygon::Clip( const Rectangle& rRect, BOOL bPolygon ) Rectangle Polygon::GetBoundRect() const { DBG_CHKTHIS( Polygon, NULL ); - DBG_ASSERT( !mpImplPolygon->mpFlagAry, "GetBoundRect could fail with beziers!" ); + // Removing the assert. Bezier curves have the attribute that each single + // curve segment defined by four points can not exit the four-point polygon + // defined by that points. This allows to say that the curve segment can also + // never leave the Range of it's defining points. + // The result is that Polygon::GetBoundRect() may not create the minimal + // BoundRect of the Polygon (to get that, use basegfx::B2DPolygon classes), + // but will always create a valid BoundRect, at least as long as this method + // 'blindly' travels over all points, including control points. + // + // DBG_ASSERT( !mpImplPolygon->mpFlagAry, "GetBoundRect could fail with beziers!" ); USHORT nCount = mpImplPolygon->mnPoints; if( ! nCount ) From 739473cd061d8fbf91ae232d0e3a4ec68a10f174 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Tue, 24 Nov 2009 17:40:41 +0100 Subject: [PATCH 260/283] printerpullpages: #i107065# ensure correct mapmode for borders on subpages --- vcl/source/gdi/print3.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index d5d8392b2f45..2b16d2c611fd 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -776,7 +776,7 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD io_rSubPage.Clip( i_rClipRect ); // save gstate - o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION | PUSH_MAPMODE ) ); + o_rMtf.AddAction( new MetaPushAction( PUSH_ALL ) ); // clip to page rect o_rMtf.AddAction( new MetaClipRegionAction( Region( i_rClipRect ), TRUE ) ); @@ -785,17 +785,24 @@ static void appendSubPage( GDIMetaFile& o_rMtf, const Rectangle& i_rClipRect, GD io_rSubPage.WindStart(); io_rSubPage.Play( o_rMtf ); + // restore gstate + o_rMtf.AddAction( new MetaPopAction() ); + // draw a border if( i_bDrawBorder ) { + // save gstate + o_rMtf.AddAction( new MetaPushAction( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_CLIPREGION | PUSH_MAPMODE ) ); + o_rMtf.AddAction( new MetaMapModeAction( MapMode( MAP_100TH_MM ) ) ); + Rectangle aBorderRect( i_rClipRect ); o_rMtf.AddAction( new MetaLineColorAction( Color( COL_BLACK ), TRUE ) ); o_rMtf.AddAction( new MetaFillColorAction( Color( COL_TRANSPARENT ), FALSE ) ); o_rMtf.AddAction( new MetaRectAction( aBorderRect ) ); - } - // restore gstate - o_rMtf.AddAction( new MetaPopAction() ); + // restore gstate + o_rMtf.AddAction( new MetaPopAction() ); + } } PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, bool i_bMayUseCache ) From 1c46a6da7e010243817963156cb45b8f20ebc8fa Mon Sep 17 00:00:00 2001 From: "Ocke Janssen [oj]" Date: Thu, 26 Nov 2009 08:42:51 +0100 Subject: [PATCH 261/283] dba33b: defines for debug was missing --- comphelper/source/property/property.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx index 14b3b8f9169d..17949b9889dd 100644 --- a/comphelper/source/property/property.cxx +++ b/comphelper/source/property/property.cxx @@ -67,7 +67,9 @@ namespace comphelper using ::com::sun::star::uno::cpp_queryInterface; using ::com::sun::star::uno::cpp_acquire; using ::com::sun::star::uno::cpp_release; +#if OSL_DEBUG_LEVEL > 0 using ::com::sun::star::lang::XServiceInfo; +#endif using ::com::sun::star::uno::UNO_QUERY; /** === end UNO using === **/ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; From 8b2c1496752e50702b5e7d015cbf55594f220b21 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 27 Nov 2009 12:55:08 +0100 Subject: [PATCH 262/283] printerpullpages: #i107119# add a tooltip to the preview window --- vcl/inc/vcl/prndlg.hxx | 1 + vcl/inc/vcl/svids.hrc | 1 + vcl/source/src/print.src | 6 ++++++ vcl/source/window/printdlg.cxx | 8 +++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx index 57a1e32df6d3..f1b69e1ca3aa 100644 --- a/vcl/inc/vcl/prndlg.hxx +++ b/vcl/inc/vcl/prndlg.hxx @@ -60,6 +60,7 @@ namespace vcl Size maOrigSize; VirtualDevice maPageVDev; rtl::OUString maReplacementString; + rtl::OUString maToolTipString; public: PrintPreviewWindow( Window* pParent, const ResId& ); virtual ~PrintPreviewWindow(); diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 07923e33a4b0..695fa6f849e8 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -97,6 +97,7 @@ #define SV_PRINT_PRT_COMMENT 13 #define SV_PRINT_TOFILE_TXT 14 #define SV_PRINT_DEFPRT_TXT 15 +#define SV_PRINT_PRINTPREVIEW_TXT 16 #define SV_PRINT_TAB_NUP 1 #define SV_PRINT_PRT_NUP_LAYOUT_FL 1 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index c1857544c708..0125c0dfbeb3 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -118,6 +118,12 @@ ModalDialog SV_DLG_PRINT Text [en-US] = "Default printer"; }; + + String SV_PRINT_PRINTPREVIEW_TXT + { + Text [en-US] = "Print preview"; + }; + TabPage SV_PRINT_TAB_NUP { Text [en-US] = "Page Layout"; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index e0c8bdc71caf..daf25324e263 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -65,6 +65,7 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( Window* i_pParent, const Re : Window( i_pParent, i_rId ) , maOrigSize( 10, 10 ) , maPageVDev( *this ) + , maToolTipString( String( VclResId( SV_PRINT_PRINTPREVIEW_TXT ) ) ) { SetPaintTransparent( TRUE ); SetBackground(); @@ -202,15 +203,16 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi sal_Int32 i_nDPIY ) { - #if OSL_DEBUG_LEVEL > 0 rtl::OUStringBuffer aBuf( 256 ); - aBuf.appendAscii( "PageSize: " ); + aBuf.append( maToolTipString ); + #if OSL_DEBUG_LEVEL > 0 + aBuf.appendAscii( "\n---\nPageSize: " ); aBuf.append( sal_Int32( i_rOrigSize.Width()/100) ); aBuf.appendAscii( "mm x " ); aBuf.append( sal_Int32( i_rOrigSize.Height()/100) ); aBuf.appendAscii( "mm" ); - SetQuickHelpText( aBuf.makeStringAndClear() ); #endif + SetQuickHelpText( aBuf.makeStringAndClear() ); maMtf = i_rNewPreview; if( GetSettings().GetStyleSettings().GetHighContrastMode() && GetSettings().GetStyleSettings().GetWindowColor().IsDark() From 3b790d2e0926c75a8a919e02bfad05d1b1aff800 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 3 Dec 2009 12:33:17 +0100 Subject: [PATCH 263/283] aw078: corrected small VCL Linux error for non-AA cases --- vcl/source/gdi/outdev.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vcl/source/gdi/outdev.cxx b/vcl/source/gdi/outdev.cxx index 7352f5ed45d9..8b20c8e384f7 100644 --- a/vcl/source/gdi/outdev.cxx +++ b/vcl/source/gdi/outdev.cxx @@ -2653,7 +2653,7 @@ void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo) { - const USHORT nPoints(rPoly.GetSize()); + USHORT nPoints(rPoly.GetSize()); if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() ) return; @@ -2698,6 +2698,15 @@ void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineI } else { + // #100127# the subdivision HAS to be done here since only a pointer + // to an array of points is given to the DrawPolyLine method, there is + // NO way to find out there that it's a curve. + if( aPoly.HasFlags() ) + { + aPoly = ImplSubdivideBezier( aPoly ); + nPoints = aPoly.GetSize(); + } + mpGraphics->DrawPolyLine(nPoints, (const SalPoint*)aPoly.GetConstPointAry(), this); } From 655b08e832103e37a5fc59cd1d9bc50d7a2ad4c0 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 4 Dec 2009 11:35:30 +0100 Subject: [PATCH 264/283] printerpullpages: #i92516# print to file option not persistent anymore --- vcl/source/window/printdlg.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index daf25324e263..649ca21a32b8 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -697,12 +697,14 @@ void PrintDialog::OutputOptPage::setupLayout() void PrintDialog::OutputOptPage::readFromSettings() { + #if 0 SettingsConfigItem* pItem = SettingsConfigItem::get(); rtl::OUString aValue; aValue = pItem->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintDialog" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToFile" ) ) ); maToFileBox.Check( aValue.equalsIgnoreAsciiCaseAscii( "true" ) ); + #endif } void PrintDialog::OutputOptPage::storeToSettings() From 022cb8bfea71cdf4e2b0ea2c91ff9807961a543a Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 4 Dec 2009 14:04:26 +0100 Subject: [PATCH 265/283] d2v02: #161005# do not crash on a badly linked libXrandr --- vcl/unx/source/app/randrwrapper.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vcl/unx/source/app/randrwrapper.cxx b/vcl/unx/source/app/randrwrapper.cxx index 8d01b64d4680..4fbe5db97ab9 100644 --- a/vcl/unx/source/app/randrwrapper.cxx +++ b/vcl/unx/source/app/randrwrapper.cxx @@ -161,7 +161,13 @@ RandRWrapper::RandRWrapper( Display* pDisplay ) : if( ! m_bValid ) { rtl::OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( "libXrandr.so.2" ) ); - m_pRandRLib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_DEFAULT ); + // load and resolve dependencies immediately + // rationale: there are older distributions where libXrandr.so.2 is not linked + // with libXext.so, resulting in a missing symbol and terminating the office + // obviously they expected libXext to be linked in global symbolspace (that is + // linked by the application), which is not the case with us (because we want + // to be able to run in headless mode even without an installed X11 library) + m_pRandRLib = osl_loadModule( aLibName.pData, SAL_LOADMODULE_DEFAULT | SAL_LOADMODULE_NOW ); initFromModule(); } if( m_bValid ) From 021d695170ab31cd91163fbbf58d30f8643a6a6f Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 7 Dec 2009 18:18:45 +0100 Subject: [PATCH 266/283] printerpullpages: #i91478# fix a scaling issue in native mac dialog --- vcl/aqua/source/gdi/aquaprintaccessoryview.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm index 9e37c0632f4e..798fefef1b25 100644 --- a/vcl/aqua/source/gdi/aquaprintaccessoryview.mm +++ b/vcl/aqua/source/gdi/aquaprintaccessoryview.mm @@ -102,7 +102,7 @@ class ControllerProperties PrintAccessoryViewState* i_pState ) : mpController( i_pController ), mnNextTag( 0 ), - mnLastPageCount( i_pController->getPageCountProtected() ), + mnLastPageCount( i_pController->getFilteredPageCount() ), mpState( i_pState ), mpOp( i_pOp ), mpAccessoryView( i_pAccessoryView ), @@ -130,7 +130,7 @@ class ControllerProperties // TODO: refresh page count etc from mpController // page range may have changed depending on options - sal_Int32 nPages = mpController->getPageCountProtected(); + sal_Int32 nPages = mpController->getFilteredPageCount(); #if OSL_DEBUG_LEVEL > 1 if( nPages != mnLastPageCount ) fprintf( stderr, "trouble: number of pages changed from %ld to %ld !\n", mnLastPageCount, nPages ); @@ -314,6 +314,9 @@ class ControllerProperties GDIMetaFile aMtf; PrinterController::PageSize aPageSize( mpController->getFilteredPageFile( i_nPage, aMtf, false ) ); VirtualDevice aDev; + // see salprn.cxx, currently we pretend to be a 720dpi device on printers + aDev.SetReferenceDevice( 720, 720 ); + aDev.EnableOutput( TRUE ); Size aLogicSize( aDev.PixelToLogic( aPixelSize, MapMode( MAP_100TH_MM ) ) ); double fScaleX = double(aLogicSize.Width())/double(aPageSize.aSize.Width()); double fScaleY = double(aLogicSize.Height())/double(aPageSize.aSize.Height()); From 96be2a9615b9243e59cc103d60c8cb5c9340df52 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Tue, 8 Dec 2009 13:00:42 +0100 Subject: [PATCH 267/283] #i105728#, #i105730#, #i105727# intelli UI thingies --- vcl/inc/vcl/print.hxx | 7 +++++-- vcl/source/gdi/print3.cxx | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx index e91e3db0c9d7..daea0c941dd0 100644 --- a/vcl/inc/vcl/print.hxx +++ b/vcl/inc/vcl/print.hxx @@ -600,19 +600,22 @@ class VCL_DLLPUBLIC PrinterOptionsHelper sal_Bool mbAttachToDependency; rtl::OUString maGroupHint; sal_Bool mbInternalOnly; + sal_Bool mbEnabled; com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps; UIControlOptions( const rtl::OUString& i_rDependsOnName = rtl::OUString(), sal_Int32 i_nDependsOnEntry = -1, sal_Bool i_bAttachToDependency = sal_False, const rtl::OUString& i_rGroupHint = rtl::OUString(), - sal_Bool i_bInternalOnly = sal_False + sal_Bool i_bInternalOnly = sal_False, + sal_Bool i_bEnabled = sal_True ) : maDependsOnName( i_rDependsOnName ) , mnDependsOnEntry( i_nDependsOnEntry ) , mbAttachToDependency( i_bAttachToDependency ) , maGroupHint( i_rGroupHint ) - , mbInternalOnly( i_bInternalOnly ) {} + , mbInternalOnly( i_bInternalOnly ) + , mbEnabled( i_bEnabled ) {} }; // general control diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index 2b16d2c611fd..e687fce01d1f 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1562,6 +1562,7 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, + i_rControlOptions.maAddProps.getLength() // additional props + (i_rControlOptions.maGroupHint.getLength() ? 1 : 0) // grouping + (i_rControlOptions.mbInternalOnly ? 1 : 0) // internal hint + + (i_rControlOptions.mbEnabled ? 0 : 1) // enabled ; if( i_rControlOptions.maDependsOnName.getLength() ) { @@ -1616,6 +1617,11 @@ Any PrinterOptionsHelper::getUIControlOpt( const rtl::OUString& i_rTitle, aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InternalUIOnly" ) ); aCtrl[nUsed++].Value <<= sal_True; } + if( ! i_rControlOptions.mbEnabled ) + { + aCtrl[nUsed ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) ); + aCtrl[nUsed++].Value <<= sal_False; + } sal_Int32 nAddProps = i_rControlOptions.maAddProps.getLength(); for( sal_Int32 i = 0; i < nAddProps; i++ ) From 64e8661d76db6b02396d82b7d1f28dd3088a334f Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Fri, 11 Dec 2009 11:34:10 +0100 Subject: [PATCH 268/283] #i106926# fixed hidden text in view when cancelling print to file --- vcl/source/gdi/print3.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index e687fce01d1f..6778cfbc867e 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -436,7 +436,12 @@ void Printer::ImplPrintJob( const boost::shared_ptr& i_pContr { rtl::OUString aFile = queryFile( pController->getPrinter().get() ); if( ! aFile.getLength() ) + { + GDIMetaFile aPageFile; + i_pController->setLastPage( sal_True ); + i_pController->getFilteredPageFile( 0, aPageFile ); return; + } pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ), makeAny( aFile ) ); } From bffdf143d5924fd277000fad4a7e7108d6d8f041 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Mon, 28 Dec 2009 15:02:47 +0000 Subject: [PATCH 269/283] #i107965# report rectangles with 0 or negative width or height as empty --- vcl/source/gdi/outdev3.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 51aad0790a26..e39ca248567f 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -7479,7 +7479,7 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, { bRet = pSalLayout->GetBoundRect( *mpGraphics, aPixelRect ); - if( bRet ) + if( bRet && (aPixelRect.GetWidth() > 0) || (aPixelRect.GetHeight() > 0) ) { int nWidthFactor = pSalLayout->GetUnitsPerPixel(); @@ -7601,6 +7601,12 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, aBmp.ReleaseAccess( pAcc ); + if( (nRight <= nLeft) || (nBottom <= nTop) ) + { + rRect.SetEmpty(); + return TRUE; + } + if( nTop <= nBottom ) { Size aSize( nRight - nLeft + 1, nBottom - nTop + 1 ); From 9afae518759e5d6ecb32dacd76a1aa746ae2cef6 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 28 Dec 2009 20:17:11 +0100 Subject: [PATCH 270/283] aw078: changes after resync --- svtools/source/filter.vcl/wmf/emfwr.cxx | 1 + vcl/source/gdi/makefile.mk | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/svtools/source/filter.vcl/wmf/emfwr.cxx b/svtools/source/filter.vcl/wmf/emfwr.cxx index f516c2eefbd0..e011dde1a0e8 100644 --- a/svtools/source/filter.vcl/wmf/emfwr.cxx +++ b/svtools/source/filter.vcl/wmf/emfwr.cxx @@ -35,6 +35,7 @@ #include #include #include +#include // ----------- // - Defines - diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index ae90d5bd1461..e253f83b25ab 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -100,7 +100,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/impbmp.obj \ $(SLO)$/imagerepository.obj \ $(SLO)$/impvect.obj \ - $(SLO)$/jobset.obj \ $(SLO)$/lineinfo.obj \ $(SLO)$/mapmod.obj \ $(SLO)$/metaact.obj \ From 6a556771abe12e1ac41fd1d39583ee62d46fa082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 4 Jan 2010 12:55:58 +0000 Subject: [PATCH 271/283] exchgcmtdoc2: #i72096#: fix imagemagick convert usage under windows --- goodies/source/filter.vcl/ieps/ieps.cxx | 68 ++++++++++++++++++++----- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/goodies/source/filter.vcl/ieps/ieps.cxx b/goodies/source/filter.vcl/ieps/ieps.cxx index f315ee864310..742985904ce8 100644 --- a/goodies/source/filter.vcl/ieps/ieps.cxx +++ b/goodies/source/filter.vcl/ieps/ieps.cxx @@ -164,12 +164,54 @@ static void MakeAsMeta(Graphic &rGraphic) rGraphic = aMtf; } +static oslProcessError runProcessWithPathSearch(const rtl::OUString &rProgName, + rtl_uString* pArgs[], sal_uInt32 nArgs, oslProcess *pProcess, + oslFileHandle *pIn, oslFileHandle *pOut, oslFileHandle *pErr) +{ +#ifdef WNT + /* + * ooo#72096 + * On Window the underlying SearchPath searches in order of... + * The directory from which the application loaded. + * The current directory. + * The Windows system directory. + * The Windows directory. + * The directories that are listed in the PATH environment variable. + * + * Because one of our programs is called "convert" and there is a convert + * in the windows system directory, we want to explicitly search the PATH + * to avoid picking up on that one if ImageMagick's convert preceeds it in + * PATH. + * + */ + rtl::OUString url; + rtl::OUString path(_wgetenv(L"PATH")); + + oslFileError err = osl_searchFileURL(rProgName.pData, path.pData, &url.pData); + if (err != osl_File_E_None) + return osl_Process_E_NotFound; + return osl_executeProcess_WithRedirectedIO(url.pData, + pArgs, nArgs, osl_Process_HIDDEN, + osl_getCurrentSecurity(), 0, 0, 0, pProcess, pIn, pOut, pErr); +#else + return osl_executeProcess_WithRedirectedIO(rProgName.pData, + pArgs, nArgs, osl_Process_SEARCHPATH | osl_Process_HIDDEN, + osl_getCurrentSecurity(), 0, 0, 0, pProcess, pIn, pOut, pErr); +#endif +} + +#if defined(WNT) || defined(OS2) +# define EXESUFFIX ".exe" +#else +# define EXESUFFIX "" +#endif + static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &rGraphic) { TempFile aTemp; aTemp.EnableKillingFile(); rtl::OUString fileName = - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pstoedit")); + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pstoedit"EXESUFFIX)); rtl::OUString arg1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-f")); rtl::OUString arg2 = @@ -186,10 +228,10 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r oslFileHandle pIn = NULL; oslFileHandle pOut = NULL; oslFileHandle pErr = NULL; - oslProcessError eErr = osl_executeProcess_WithRedirectedIO(fileName.pData, - args, sizeof(args)/sizeof(rtl_uString *), - osl_Process_SEARCHPATH | osl_Process_HIDDEN, - osl_getCurrentSecurity(), 0, 0, 0, &aProcess, &pIn, &pOut, &pErr); + oslProcessError eErr = runProcessWithPathSearch(fileName, + args, sizeof(args)/sizeof(rtl_uString *), + &aProcess, &pIn, &pOut, &pErr); + if (eErr!=osl_Process_E_None) return false; @@ -222,15 +264,15 @@ static bool RenderAsEMF(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, Graphic &r } static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, - Graphic &rGraphic, rtl::OUString &rProgName, rtl_uString **pArgs, size_t nArgs) + Graphic &rGraphic, rtl::OUString &rProgName, rtl_uString *pArgs[], size_t nArgs) { oslProcess aProcess; oslFileHandle pIn = NULL; oslFileHandle pOut = NULL; oslFileHandle pErr = NULL; - oslProcessError eErr = osl_executeProcess_WithRedirectedIO(rProgName.pData, - pArgs, nArgs, osl_Process_SEARCHPATH | osl_Process_HIDDEN, - osl_getCurrentSecurity(), 0, 0, 0, &aProcess, &pIn, &pOut, &pErr); + oslProcessError eErr = runProcessWithPathSearch(rProgName, + pArgs, nArgs, + &aProcess, &pIn, &pOut, &pErr); if (eErr!=osl_Process_E_None) return false; @@ -251,7 +293,7 @@ static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRea aMemStm.Seek(0); if ( - eFileErr == osl_File_E_None && + aMemStm.GetSize() && GraphicConverter::Import(aMemStm, rGraphic, CVT_PNG) == ERRCODE_NONE ) { @@ -270,7 +312,7 @@ static bool RenderAsPNGThroughConvert(const sal_uInt8* pBuf, sal_uInt32 nBytesRe Graphic &rGraphic) { rtl::OUString fileName = - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("convert")); + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("convert"EXESUFFIX)); // density in pixel/inch rtl::OUString arg1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-density")); // since the preview is also used for PDF-Export & printing on non-PS-printers, @@ -293,10 +335,10 @@ static bool RenderAsPNGThroughGS(const sal_uInt8* pBuf, sal_uInt32 nBytesRead, { #ifdef WNT rtl::OUString fileName = - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gswin32c")); + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gswin32c"EXESUFFIX)); #else rtl::OUString fileName = - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gs")); + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gs"EXESUFFIX)); #endif rtl::OUString arg1 = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-q")); From f8a276a66211d0fe08e1c9ad5204d5fe0a0fc038 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Tue, 5 Jan 2010 17:11:23 +0000 Subject: [PATCH 272/283] #i108068# always release solar mutex before calling into UNO --- vcl/source/helper/xconnection.cxx | 36 ++++++++++++++++++++++++---- vcl/unx/source/app/saldisp.cxx | 6 +---- vcl/unx/source/plugadapt/salplug.cxx | 4 +++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/vcl/source/helper/xconnection.cxx b/vcl/source/helper/xconnection.cxx index 477ff5fb9902..489e3cf9340e 100644 --- a/vcl/source/helper/xconnection.cxx +++ b/vcl/source/helper/xconnection.cxx @@ -30,10 +30,31 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include -#include -#include -#include + +#include "svsys.h" +#include "vcl/xconnection.hxx" +#include "vcl/svdata.hxx" +#include "vcl/salinst.hxx" +#include "vcl/svapp.hxx" + +namespace vcl +{ + class SolarMutexReleaser + { + ULONG mnReleased; + public: + SolarMutexReleaser() + { + mnReleased = Application::ReleaseSolarMutex(); + } + + ~SolarMutexReleaser() + { + if( mnReleased ) + Application::AcquireSolarMutex( mnReleased ); + } + }; +} using namespace rtl; using namespace osl; @@ -41,6 +62,7 @@ using namespace vcl; using namespace com::sun::star::uno; using namespace com::sun::star::awt; + DisplayConnection::DisplayConnection() { ImplSVData* pSVData = ImplGetSVData(); @@ -108,6 +130,8 @@ Any SAL_CALL DisplayConnection::getIdentifier() throw() void DisplayConnection::dispatchDowningEvent() { + SolarMutexReleaser aRel; + MutexGuard aGuard( m_aMutex ); Any aEvent; std::list< Reference< XEventHandler > > aLocalList( m_aHandlers ); @@ -117,6 +141,8 @@ void DisplayConnection::dispatchDowningEvent() bool DisplayConnection::dispatchEvent( void* pThis, void* pData, int nBytes ) { + SolarMutexReleaser aRel; + DisplayConnection* This = (DisplayConnection*)pThis; MutexGuard aGuard( This->m_aMutex ); @@ -131,6 +157,8 @@ bool DisplayConnection::dispatchEvent( void* pThis, void* pData, int nBytes ) bool DisplayConnection::dispatchErrorEvent( void* pThis, void* pData, int nBytes ) { + SolarMutexReleaser aRel; + DisplayConnection* This = (DisplayConnection*)pThis; MutexGuard aGuard( This->m_aMutex ); diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx index cfd568ac9b6c..558ae3714358 100644 --- a/vcl/unx/source/app/saldisp.cxx +++ b/vcl/unx/source/app/saldisp.cxx @@ -2304,11 +2304,7 @@ long SalX11Display::Dispatch( XEvent *pEvent ) return 0; SalInstance* pInstance = GetSalData()->m_pInstance; - if( pInstance->GetEventCallback() ) - { - YieldMutexReleaser aReleaser; - pInstance->CallEventCallback( pEvent, sizeof( XEvent ) ); - } + pInstance->CallEventCallback( pEvent, sizeof( XEvent ) ); switch( pEvent->type ) { diff --git a/vcl/unx/source/plugadapt/salplug.cxx b/vcl/unx/source/plugadapt/salplug.cxx index f1c63b8abee7..08820b2cb7f9 100644 --- a/vcl/unx/source/plugadapt/salplug.cxx +++ b/vcl/unx/source/plugadapt/salplug.cxx @@ -219,8 +219,10 @@ SalInstance *CreateSalInstance() if( !(pUsePlugin && *pUsePlugin) ) pInst = check_headless_plugin(); + else + pInst = tryInstance( OUString::createFromAscii( pUsePlugin ) ); - if( ! pInst && !(pUsePlugin && *pUsePlugin) ) + if( ! pInst ) pInst = autodetect_plugin(); // fallback to gen From 73f1c832825e5083987f87d7cda71b594bffb2c4 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Tue, 5 Jan 2010 19:53:12 +0100 Subject: [PATCH 273/283] DEV300 masterfix: #i10000#: lineinfo.cxx: enable exceptions --- vcl/source/gdi/makefile.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index e253f83b25ab..0ec8ca1f280c 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -57,7 +57,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/gfxlink.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ - $(SLO)$/configsettings.obj \ + $(SLO)$/configsettings.obj \ $(SLO)$/sallayout.obj \ $(SLO)$/image.obj \ $(SLO)$/impimage.obj \ @@ -75,7 +75,8 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/impprn.obj \ $(SLO)$/gdimtf.obj \ $(SLO)$/graphictools.obj \ - $(SLO)$/textlayout.obj + $(SLO)$/textlayout.obj \ + $(SLO)$/lineinfo.obj SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/animate.obj \ From a7d20f1e3f23a94ff2e389b815ff35b72843ab9d Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 6 Jan 2010 08:23:28 +0100 Subject: [PATCH 274/283] use proper delete operator --- transex3/source/inireader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transex3/source/inireader.cxx b/transex3/source/inireader.cxx index 0985e788452d..1ff34fad8e95 100644 --- a/transex3/source/inireader.cxx +++ b/transex3/source/inireader.cxx @@ -120,7 +120,7 @@ void INIreader::toStlString( const UnicodeString& str , string& stl_str) char* buffer = new char[ str.length()*3 ]; str.extract( 0 , str.length() , buffer ); stl_str = string( buffer ); - delete buffer; + delete[] buffer; } void INIreader::trim( string& str ) From 8765a3bf9f2926a50d0f644e4263782269abe023 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Wed, 6 Jan 2010 13:54:46 +0100 Subject: [PATCH 275/283] DEV300 masterfix: #i10000#: lineinfo.cxx: enable exceptions (corrected) --- vcl/source/gdi/makefile.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 0ec8ca1f280c..eda537bf629a 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -101,7 +101,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/impbmp.obj \ $(SLO)$/imagerepository.obj \ $(SLO)$/impvect.obj \ - $(SLO)$/lineinfo.obj \ $(SLO)$/mapmod.obj \ $(SLO)$/metaact.obj \ $(SLO)$/octree.obj \ From 0b2cc3465d5a793c36b6ba2752d4b332a6d61e05 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Thu, 7 Jan 2010 11:53:09 +0000 Subject: [PATCH 276/283] reverted previous patch --- vcl/source/gdi/outdev3.cxx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index e39ca248567f..51aad0790a26 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -7479,7 +7479,7 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, { bRet = pSalLayout->GetBoundRect( *mpGraphics, aPixelRect ); - if( bRet && (aPixelRect.GetWidth() > 0) || (aPixelRect.GetHeight() > 0) ) + if( bRet ) { int nWidthFactor = pSalLayout->GetUnitsPerPixel(); @@ -7601,12 +7601,6 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, aBmp.ReleaseAccess( pAcc ); - if( (nRight <= nLeft) || (nBottom <= nTop) ) - { - rRect.SetEmpty(); - return TRUE; - } - if( nTop <= nBottom ) { Size aSize( nRight - nLeft + 1, nBottom - nTop + 1 ); From 86f7dae1d7a3f95a68cf5132cef03073787d3810 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 7 Jan 2010 16:18:32 +0000 Subject: [PATCH 277/283] #i53184# further fix in INetURLObject::setAbsURIRef for UNC server names containing underscores --- tools/source/fsys/urlobj.cxx | 18 ++++++++---------- tools/workben/urltest.cxx | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index f7ffed5e4dd1..e0f711bd2883 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -1022,16 +1022,14 @@ bool INetURLObject::setAbsURIRef(rtl::OUString const & rTheAbsURIRef, if (pEnd - pPos >= 2 && pPos[0] == '/' && pPos[1] == '/') { sal_Unicode const * p1 = pPos + 2; - if ( - p1 == pEnd || *p1 == nFragmentDelimiter || *p1 == '/' || - ( - ( - scanDomain(p1, pEnd) > 0 || - scanIPv6reference(p1, pEnd) - ) && - (p1 == pEnd || *p1 == nFragmentDelimiter || *p1 == '/') - ) - ) + while (p1 != pEnd && *p1 != '/' && + *p1 != nFragmentDelimiter) + { + ++p1; + } + if (parseHostOrNetBiosName( + pPos + 2, p1, bOctets, ENCODE_ALL, + RTL_TEXTENCODING_DONTKNOW, true, NULL)) { aSynAbsURIRef. appendAscii(RTL_CONSTASCII_STRINGPARAM("//")); diff --git a/tools/workben/urltest.cxx b/tools/workben/urltest.cxx index a232f8ebdd93..0e9d22081cb4 100644 --- a/tools/workben/urltest.cxx +++ b/tools/workben/urltest.cxx @@ -1629,6 +1629,20 @@ main() rtl::OUString(urlobj.GetMainURL(INetURLObject::NO_DECODE))); } + if (true) { // #i53184# + rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM("file://comp_name/path")); + bSuccess &= assertEqual( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("#i53184# smart INET_PROT_FILE")), + INetURLObject(url, INET_PROT_FILE).GetMainURL( + INetURLObject::NO_DECODE), + url); + bSuccess &= assertEqual( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("#i53184# strict")), + INetURLObject(url).GetMainURL(INetURLObject::NO_DECODE), url); + } + if (true) { rtl::OUString path; path = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/a/b/c")); From dcbaee1e7d51a7645ce5236b9c8d78736a51c326 Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Thu, 14 Jan 2010 17:37:57 +0100 Subject: [PATCH 278/283] masterfix: #i108160# build error fixed --- canvas/source/cairo/cairo_canvashelper.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx index 5469010f2745..7a5e81a5512a 100644 --- a/canvas/source/cairo/cairo_canvashelper.cxx +++ b/canvas/source/cairo/cairo_canvashelper.cxx @@ -990,7 +990,8 @@ namespace cairocanvas aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a)); aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex)); - doPolyPolygonImplementation( aEdge, aOperation, + doPolyPolygonImplementation( basegfx::B2DPolyPolygon(aEdge), + aOperation, pCairo, pTextures, mpSurfaceProvider, xPolyPolygon->getFillRule() ); @@ -1187,7 +1188,7 @@ namespace cairocanvas cairo_save( mpCairo.get() ); useStates( viewState, renderState, true ); - doPolyPolygonPath( xPolyPolygon, Fill, &textures ); + doPolyPolygonPath( xPolyPolygon, Fill, false, &textures ); cairo_restore( mpCairo.get() ); } From b2fa4ba9756e52f4ddbadb112673c7ed445ade00 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 14 Jan 2010 19:12:18 +0100 Subject: [PATCH 279/283] solar.hrc moved to vcl --- svl/inc/svl/solar.hrc | 305 ------------------------------------------ 1 file changed, 305 deletions(-) delete mode 100644 svl/inc/svl/solar.hrc diff --git a/svl/inc/svl/solar.hrc b/svl/inc/svl/solar.hrc deleted file mode 100644 index 96149b89131c..000000000000 --- a/svl/inc/svl/solar.hrc +++ /dev/null @@ -1,305 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: solar.hrc,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SOLAR_HRC -#define _SOLAR_HRC - -// defines ------------------------------------------------------------------ - -#define CREATERESMGR_NAME( Name ) #Name -#define CREATERESMGR( Name ) ResMgr::CreateResMgr( CREATERESMGR_NAME( Name ) ) - -#define RID_SFX_START 260 -#define RID_SFX_END 9999 - -#define RID_LIB_START 10000 -#define RID_LIB_END 19999 - -#define RID_SVX_START (RID_LIB_START) -#define RID_SVX_END (RID_LIB_START+499) - -#define RID_SBASIC_START (RID_LIB_START+500) -#define RID_SBASIC_END (RID_LIB_START+2999) - -#define RID_BASIC_START (RID_LIB_START+3000) -#define RID_BASIC_END (RID_LIB_START+4499) - -#define RID_UUI_START (RID_LIB_START+4500) -#define RID_UUI_END (RID_LIB_START+4599) - -#define RID_HELP_START (RID_LIB_START+4600) -#define RID_HELP_END (RID_LIB_START+4799) - -#define RID_MAIL_START (RID_LIB_START+4800) -#define RID_MAIL_END (RID_LIB_START+4849) - -#define RID_BASICIDE_START (RID_LIB_START+4850) -#define RID_BASICIDE_END (RID_LIB_START+4949) - -#define RID_SVXITEMS_START (RID_LIB_START+4950) -#define RID_SVXITEMS_END (RID_LIB_START+5599) - -#define RID_SBA_START (RID_LIB_START+5600) -#define RID_SBA_END (RID_LIB_START+5649) - -#define RID_ISETBRW_START (RID_LIB_START+5650) -#define RID_ISETBRW_END (RID_LIB_START+5699) - -#define RID_EXTENSIONS_START (RID_LIB_START+5700) -#define RID_EXTENSIONS_END (RID_LIB_START+5799) - -#define RID_EDIT_START (RID_LIB_START+5800) -#define RID_EDIT_END (RID_LIB_START+5899) - -#define RID_EDIT_START (RID_LIB_START+5800) -#define RID_EDIT_END (RID_LIB_START+5899) - -#define RID_OUTL_START (RID_LIB_START+5900) -#define RID_OUTL_END (RID_LIB_START+5919) - -#define RID_SVTOOLS_START (RID_LIB_START+5920) -#define RID_SVTOOLS_END (RID_LIB_START+5999) - -#define RID_INET_START (RID_LIB_START+6000) -#define RID_INET_END (RID_LIB_START+6059) - -#define RID_SO2_START (RID_LIB_START+6060) -#define RID_SO2_END (RID_LIB_START+6099) - -#define RID_GOODIES_START (RID_LIB_START+6100) -#define RID_GOODIES_END (RID_LIB_START+6149) - -#define RID_SJ_START (RID_LIB_START+6150) -#define RID_SJ_END (RID_LIB_START+6199) - -#define RID_SI_START (RID_LIB_START+6200) -#define RID_SI_END (RID_LIB_START+6399) - -#define RID_DLG_START (RID_LIB_START+6400) -#define RID_DLG_END (RID_LIB_START+6499) - -#define RID_OFA_START (RID_LIB_START+6500) -#define RID_OFA_END (RID_LIB_START+6999) - -#define RID_CHANNEL_START (RID_LIB_START+7000) -#define RID_CHANNEL_END (RID_LIB_START+7499) - -#define RID_CHAOS_START (RID_LIB_START+7500) -#define RID_CHAOS_END (RID_LIB_START+7999) - -#define RID_FORMS_START (RID_LIB_START+8000) -#define RID_FORMS_END (RID_LIB_START+8999) - -#define RID_FORMLAYER_START (RID_LIB_START+9000) -#define RID_FORMLAYER_END (RID_LIB_START+9199) - -#define RID_DBACCESS_START (RID_LIB_START+9200) -#define RID_DBACCESS_END (RID_LIB_START+9699) - -#define RID_MORE_EXTENSIONS_START (RID_LIB_START+9700) -#define RID_MORE_EXTENSIONS_END (RID_LIB_START+9999) - -#define RID_DB_EXTENSIONS_START (RID_LIB_START+10000) -#define RID_DB_EXTENSIONS_END (RID_LIB_START+10199) - -#define RID_FILTER_START (RID_LIB_START+10200) -#define RID_FILTER_END (RID_LIB_START+10299) - -// do *NOT* add more ranges here, RID_LIB_END is (RID_LIB_START + 10000) - -#define RID_APP_START 20000 -#define RID_APP_END 31999 - -#define RID_SW_START (20000) -#define RID_SW_END (25999) - -#define RID_SC_START (26000) -#define RID_SC_END (26999) - -#define RID_SD_START (27000) -#define RID_SD_END (27999) - -#define RID_OBJ_START (30000) -#define RID_OBJ_END (32767) - -#define RID_SIM_START (RID_OBJ_START+ 0) -#define RID_SIM_END (RID_OBJ_START+ 255) - -#define RID_SMA_START (RID_OBJ_START+ 256) -#define RID_SMA_END (RID_OBJ_START+ 511) - -#define RID_SCH_START (RID_OBJ_START+ 512) -#define RID_SCH_END (RID_OBJ_START+ 767) - -#define RID_RPT_START (RID_OBJ_START+768) -#define RID_RPT_END (RID_OBJ_START+1000) - -#define RID_FORMULA_START (RID_OBJ_START+1001) -#define RID_FORMULA_END (RID_OBJ_START+1200) -// Help-Ids -------------------------------------------------------------- - -#define HID_OK_BUTTON 0 -#define HID_CANCEL_BUTTON 0 -#define HID_HELP_BUTTON 0 - -#define HID_START 32768 - -#define HID_SVTOOLS_START (HID_START+200) -#define HID_SVTOOLS_END (HID_START+299) - -#define HID_SFX_START (HID_START+300) -#define HID_SFX_END (HID_START+999) - -#define HID_LIB_START (HID_START+1000) -#define HID_LIB_END (HID_START+19999) - -#define HID_SVX_START (HID_LIB_START) -#define HID_SVX_END (HID_LIB_START+431) - -#define HID_WIZARD_START (HID_LIB_START+432) -#define HID_WIZARD_END (HID_LIB_START+999) -//please note: There is also HID_WIZARD2 below - -// FREE - -#define HID_CUI_START (HID_LIB_START+1100) -#define HID_CUI_END (HID_LIB_START+1699) - -#define HID_OFA_START (HID_LIB_START+1760) -#define HID_OFA_END (HID_LIB_START+1999) - -#define HID_HELP_START (HID_LIB_START+2000) -#define HID_HELP_END (HID_LIB_START+2050) - -#define HID_CHAOS_START (HID_LIB_START+2051) -#define HID_CHAOS_END (HID_LIB_START+2069) - -#define HID_UUI_START (HID_LIB_START+2070) -#define HID_UUI_END (HID_LIB_START+2099) - -#define HID_GOODIES_START (HID_LIB_START+2100) -#define HID_GOODIES_END (HID_LIB_START+2199) - -#define HID_SCHEDULE_START (HID_LIB_START+2200) -#define HID_SCHEDULE_END (HID_LIB_START+3399) - -#define HID_CHANNEL_START (HID_LIB_START+3400) -#define HID_CHANNEL_END (HID_LIB_START+3499) - -#define HID_SBA_START (HID_LIB_START+ 3500) -#define HID_SBA_END (HID_LIB_START+ 3999) - -#define HID_FORMS_START (HID_LIB_START+4000) -#define HID_FORMS_END (HID_LIB_START+4999) - -#define HID_DBACCESS_START (HID_LIB_START+5000) -#define HID_DBACCESS_END (HID_LIB_START+5299) - -#define HID_PORTAL_START (HID_LIB_START+5300) -#define HID_PORTAL_END (HID_LIB_START+5599) - -#define HID_PORTAL_ADMIN_START (HID_LIB_START+5600) -#define HID_PORTAL_ADMIN_END (HID_LIB_START+5999) - -#define HID_SYNCACCESS_START (HID_LIB_START+6000) -#define HID_SYNCACCESS_END (HID_LIB_START+6099) - -#define HID_SVX_EXT0_START (HID_LIB_START+6100) -#define HID_SVX_EXT0_END (HID_LIB_START+6599) - -#define HID_FRAMEWORK_START (HID_LIB_START+6600) -#define HID_FRAMEWORK_END (HID_LIB_START+6999) - -#define HID_WIZARD2_START (HID_LIB_START+7000) -#define HID_WIZARD2_END (HID_LIB_START+8999) - -#define HID_DESKTOP_START (HID_LIB_START+9000) -#define HID_DESKTOP_END (HID_LIB_START+9299) - -#define HID_XMLSECURITY_START (HID_LIB_START+9300) -#define HID_XMLSECURITY_END (HID_LIB_START+9999) - -#define HID_APP_START (HID_START+20000) -#define HID_APP_END (HID_START+29999) - -#define HID_SW_START (HID_START+20000) -#define HID_SW_END (HID_START+24999) - -#define HID_SC_START (HID_START+25000) -#define HID_SC_END (HID_START+26999) - -#define HID_SD_START (HID_START+27000) -#define HID_SD_END (HID_START+27999) - -#define HID_Sa_START (HID_START+28000) -#define HID_Sa_END (HID_START+28999) - -#define HID_Sb_START (HID_START+29000) -#define HID_Sb_END (HID_START+29999) - -#define HID_OBJ_START (HID_START+30000) -#define HID_OBJ_END (HID_START+32767) - -#define HID_CUI3_START (HID_OBJ_START+ 0) -#define HID_CUI3_END (HID_OBJ_START+ 239) - -#define HID_AVMEDIA_START (HID_OBJ_START+ 240) -#define HID_AVMEDIA_END (HID_OBJ_START+ 255) - -#define HID_SMA_START (HID_OBJ_START+ 256) -#define HID_SMA_END (HID_OBJ_START+ 511) - -#define HID_SCH_START (HID_OBJ_START+ 512) -#define HID_SCH_END (HID_OBJ_START+ 767) - -#define HID_BASICIDE_START (HID_OBJ_START+ 768) -#define HID_BASICIDE_END (HID_OBJ_START+1023) - -#define HID_SMA2_START (HID_OBJ_START+1024) -#define HID_SMA2_END (HID_OBJ_START+1280) - -#define HID_FILTER_START (HID_OBJ_START+1281) -#define HID_FILTER_END (HID_OBJ_START+1580) - -#define HID_LICENSING_START (HID_OBJ_START+1581) -#define HID_LICENSING_END (HID_OBJ_START+1680) - -#define HID_RPT_START (HID_OBJ_START+1681) -#define HID_RPT_END (HID_OBJ_START+2080) - -#define HID_FORMULA_START (HID_OBJ_START+2081) -#define HID_FORMULA_END (HID_OBJ_START+2280) - -#define HID_EXTENSIONS_START (HID_OBJ_START+2281) -#define HID_EXTENSIONS_END (HID_OBJ_START+2800) - - -#endif - From 6ac5d627b946828fdf791cca381e9c526c755582 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Thu, 14 Jan 2010 22:27:44 +0100 Subject: [PATCH 280/283] undo previous erroneous change, solar.hrc belongs to svl instead vcl now --- goodies/inc/goodies.hrc | 2 +- goodies/inc/pch/precompiled_goodies.hxx | 2 +- goodies/source/filter.vcl/egif/egif.cxx | 2 +- goodies/source/filter.vcl/eos2met/eos2met.cxx | 2 +- goodies/source/filter.vcl/epbm/epbm.cxx | 2 +- goodies/source/filter.vcl/epgm/epgm.cxx | 2 +- goodies/source/filter.vcl/epict/epict.cxx | 2 +- goodies/source/filter.vcl/eppm/eppm.cxx | 2 +- goodies/source/filter.vcl/eps/eps.cxx | 2 +- goodies/source/filter.vcl/etiff/etiff.cxx | 2 +- goodies/source/filter.vcl/ipcd/ipcd.cxx | 2 +- goodies/source/inv/invader.cxx | 2 +- goodies/source/unographic/provider.cxx | 2 +- goodies/source/unographic/transformer.cxx | 2 +- {vcl/inc/vcl => svl/inc/svl}/solar.hrc | 0 svl/inc/svl/svtools.hrc | 2 +- svtools/bmpmaker/bmp.cxx | 2 +- svtools/bmpmaker/bmpsum.cxx | 2 +- svtools/inc/svtools/helpid.hrc | 2 +- svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx | 2 +- svtools/source/filter.vcl/filter/filter.cxx | 2 +- svtools/source/plugapp/testtool.src | 2 +- svtools/source/uno/unoifac2.hrc | 2 +- svtools/workben/unodialog/udlg_global.hrc | 2 +- vcl/inc/vcl/svids.hrc | 2 +- vcl/prj/build.lst | 2 +- vcl/prj/d.lst | 1 - 27 files changed, 25 insertions(+), 26 deletions(-) rename {vcl/inc/vcl => svl/inc/svl}/solar.hrc (100%) diff --git a/goodies/inc/goodies.hrc b/goodies/inc/goodies.hrc index 0cad63e4efdd..139987c4f6ee 100644 --- a/goodies/inc/goodies.hrc +++ b/goodies/inc/goodies.hrc @@ -31,7 +31,7 @@ #define _GOODIES_HRC #ifndef _SOLAR_HRC -#include +#include #endif // Dialoge --------------------------------------------------------------- diff --git a/goodies/inc/pch/precompiled_goodies.hxx b/goodies/inc/pch/precompiled_goodies.hxx index 754e737467b4..fe6f2ec433e5 100644 --- a/goodies/inc/pch/precompiled_goodies.hxx +++ b/goodies/inc/pch/precompiled_goodies.hxx @@ -100,7 +100,7 @@ #include "svtools/fltcall.hxx" #include "svl/itemprop.hxx" #include "svl/lstner.hxx" -#include "vcl/solar.hrc" +#include "svl/solar.hrc" #include "svtools/stdctrl.hxx" #include "svl/svarray.hxx" diff --git a/goodies/source/filter.vcl/egif/egif.cxx b/goodies/source/filter.vcl/egif/egif.cxx index 6cef33de0187..9f2aeaddd686 100644 --- a/goodies/source/filter.vcl/egif/egif.cxx +++ b/goodies/source/filter.vcl/egif/egif.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "giflzwc.hxx" diff --git a/goodies/source/filter.vcl/eos2met/eos2met.cxx b/goodies/source/filter.vcl/eos2met/eos2met.cxx index 74db6f344492..b818e9cd26ba 100644 --- a/goodies/source/filter.vcl/eos2met/eos2met.cxx +++ b/goodies/source/filter.vcl/eos2met/eos2met.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include "strings.hrc" #include "dlgeos2.hxx" diff --git a/goodies/source/filter.vcl/epbm/epbm.cxx b/goodies/source/filter.vcl/epbm/epbm.cxx index 2913452df4a9..a624e7f45cfb 100644 --- a/goodies/source/filter.vcl/epbm/epbm.cxx +++ b/goodies/source/filter.vcl/epbm/epbm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/epgm/epgm.cxx b/goodies/source/filter.vcl/epgm/epgm.cxx index 435a53da6b9f..32d6e74a5cfe 100644 --- a/goodies/source/filter.vcl/epgm/epgm.cxx +++ b/goodies/source/filter.vcl/epgm/epgm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/epict/epict.cxx b/goodies/source/filter.vcl/epict/epict.cxx index 4f20619eb185..cd9e33edd5d9 100644 --- a/goodies/source/filter.vcl/epict/epict.cxx +++ b/goodies/source/filter.vcl/epict/epict.cxx @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/goodies/source/filter.vcl/eppm/eppm.cxx b/goodies/source/filter.vcl/eppm/eppm.cxx index 5d682a215f6a..d17b4f7777ae 100644 --- a/goodies/source/filter.vcl/eppm/eppm.cxx +++ b/goodies/source/filter.vcl/eppm/eppm.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include "strings.hrc" diff --git a/goodies/source/filter.vcl/eps/eps.cxx b/goodies/source/filter.vcl/eps/eps.cxx index d3580bf4ebc6..83b5a94f97f2 100644 --- a/goodies/source/filter.vcl/eps/eps.cxx +++ b/goodies/source/filter.vcl/eps/eps.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/goodies/source/filter.vcl/etiff/etiff.cxx b/goodies/source/filter.vcl/etiff/etiff.cxx index c4bd6524627b..3cdec42d0978 100644 --- a/goodies/source/filter.vcl/etiff/etiff.cxx +++ b/goodies/source/filter.vcl/etiff/etiff.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/goodies/source/filter.vcl/ipcd/ipcd.cxx b/goodies/source/filter.vcl/ipcd/ipcd.cxx index b0d7cbc1eabb..f7a5f3652cbf 100644 --- a/goodies/source/filter.vcl/ipcd/ipcd.cxx +++ b/goodies/source/filter.vcl/ipcd/ipcd.cxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include //============================ PCDReader ================================== diff --git a/goodies/source/inv/invader.cxx b/goodies/source/inv/invader.cxx index 4e91536e577b..0aed6e76848f 100644 --- a/goodies/source/inv/invader.cxx +++ b/goodies/source/inv/invader.cxx @@ -37,7 +37,7 @@ #include "invader.hrc" #include "strings.hrc" #include "score.hxx" -#include +#include #include #include #include diff --git a/goodies/source/unographic/provider.cxx b/goodies/source/unographic/provider.cxx index b332dd4233e2..1f7de99d4473 100644 --- a/goodies/source/unographic/provider.cxx +++ b/goodies/source/unographic/provider.cxx @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/goodies/source/unographic/transformer.cxx b/goodies/source/unographic/transformer.cxx index ee4371172514..7e18c10cdd41 100644 --- a/goodies/source/unographic/transformer.cxx +++ b/goodies/source/unographic/transformer.cxx @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/vcl/inc/vcl/solar.hrc b/svl/inc/svl/solar.hrc similarity index 100% rename from vcl/inc/vcl/solar.hrc rename to svl/inc/svl/solar.hrc diff --git a/svl/inc/svl/svtools.hrc b/svl/inc/svl/svtools.hrc index ec3bf093d753..e4cc91cfcb49 100644 --- a/svl/inc/svl/svtools.hrc +++ b/svl/inc/svl/svtools.hrc @@ -30,7 +30,7 @@ #ifndef _SVTOOLS_HRC #define _SVTOOLS_HRC "$Revision: 1.0" -#include +#include #define RID_SVTOOLS_BITMAP_START (RID_SVTOOLS_START + 0) #define RID_SVTOOLS_IMAGELIST_START (RID_SVTOOLS_START + 0) diff --git a/svtools/bmpmaker/bmp.cxx b/svtools/bmpmaker/bmp.cxx index 52e2cb5fa7b0..b91dae79bbad 100644 --- a/svtools/bmpmaker/bmp.cxx +++ b/svtools/bmpmaker/bmp.cxx @@ -43,7 +43,7 @@ using namespace std; #include -#include "vcl/solar.hrc" +#include "svl/solar.hrc" #include "filedlg.hxx" #include "bmpcore.hxx" #include "bmp.hrc" diff --git a/svtools/bmpmaker/bmpsum.cxx b/svtools/bmpmaker/bmpsum.cxx index 6ba0ac3cfc78..3eee49ef695d 100644 --- a/svtools/bmpmaker/bmpsum.cxx +++ b/svtools/bmpmaker/bmpsum.cxx @@ -45,7 +45,7 @@ #include #include -#include "vcl/solar.hrc" +#include "svl/solar.hrc" #define EXIT_NOERROR 0x00000000 #define EXIT_INVALIDFILE 0x00000001 diff --git a/svtools/inc/svtools/helpid.hrc b/svtools/inc/svtools/helpid.hrc index d18120b8c0d4..937898f37af1 100644 --- a/svtools/inc/svtools/helpid.hrc +++ b/svtools/inc/svtools/helpid.hrc @@ -33,7 +33,7 @@ // include --------------------------------------------------------------- -#include +#include // Help-Ids -------------------------------------------------------------- diff --git a/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx index d07251079919..584814dd9e92 100644 --- a/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx @@ -37,7 +37,7 @@ #include "FilterConfigCache.hxx" #include #include -#include +#include #include #include "dlgexpor.hxx" #include "dlgejpg.hxx" diff --git a/svtools/source/filter.vcl/filter/filter.cxx b/svtools/source/filter.vcl/filter/filter.cxx index 372b7496920b..306307a0bf91 100644 --- a/svtools/source/filter.vcl/filter/filter.cxx +++ b/svtools/source/filter.vcl/filter/filter.cxx @@ -54,7 +54,7 @@ #include "jpeg.hxx" #include "xbmread.hxx" #include "xpmread.hxx" -#include +#include #include "strings.hrc" #include "sgffilt.hxx" #include "osl/module.hxx" diff --git a/svtools/source/plugapp/testtool.src b/svtools/source/plugapp/testtool.src index 4333dedd4255..78b63c2fb819 100644 --- a/svtools/source/plugapp/testtool.src +++ b/svtools/source/plugapp/testtool.src @@ -28,7 +28,7 @@ * ************************************************************************/ #include "testtool.hrc" -#include +#include #define Control_Control 5 diff --git a/svtools/source/uno/unoifac2.hrc b/svtools/source/uno/unoifac2.hrc index 64941b1c3013..4f46edffdc51 100644 --- a/svtools/source/uno/unoifac2.hrc +++ b/svtools/source/uno/unoifac2.hrc @@ -33,7 +33,7 @@ #ifndef _SOLAR_HRC -#include +#include #endif //! Um den Überblick über alle benutzten HelpID's zu behalten sind diese diff --git a/svtools/workben/unodialog/udlg_global.hrc b/svtools/workben/unodialog/udlg_global.hrc index 6fa2679e3386..bde0e5e86ce2 100644 --- a/svtools/workben/unodialog/udlg_global.hrc +++ b/svtools/workben/unodialog/udlg_global.hrc @@ -31,7 +31,7 @@ #ifndef SVTOOLS_UDLG_GLOBAL_HRC #define SVTOOLS_UDLG_GLOBAL_HRC -#include +#include //===================================================================== //= bases diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc index 695fa6f849e8..e2a8226ac878 100644 --- a/vcl/inc/vcl/svids.hrc +++ b/vcl/inc/vcl/svids.hrc @@ -31,7 +31,7 @@ #ifndef _SV_SVIDS_HRC #define _SV_SVIDS_HRC -#include "vcl/solar.hrc" +#include "svl/solar.hrc" #define SV_RESID_STDOFFSET 0 #define SV_RESID_WINOFFSET 1 diff --git a/vcl/prj/build.lst b/vcl/prj/build.lst index 5d2aaf90c6f7..cf2824f72942 100644 --- a/vcl/prj/build.lst +++ b/vcl/prj/build.lst @@ -1,4 +1,4 @@ -vc vcl : l10n apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu GRAPHITE:graphite i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools transex3 icc SO:print_header cpputools shell NULL +vc vcl : l10n apple_remote BOOST:boost rsc sot ucbhelper unotools ICU:icu GRAPHITE:graphite i18npool i18nutil unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools transex3 icc SO:print_header cpputools shell svl NULL vc vcl usr1 - all vc_mkout NULL vc vcl\inc nmake - all vc_inc NULL vc vcl\source\glyphs nmake - all vc_glyphs vc_inc NULL diff --git a/vcl/prj/d.lst b/vcl/prj/d.lst index afe8a5808be7..b106ff73729e 100644 --- a/vcl/prj/d.lst +++ b/vcl/prj/d.lst @@ -13,7 +13,6 @@ mkdir: %_DEST%\inc%_EXT%\vcl ..\%__SRC%\obj\salmain.obj %_DEST%\lib%_EXT%\salmain.obj ..\%__SRC%\obj\salmain.o %_DEST%\lib%_EXT%\salmain.o -..\inc\vcl\solar.hrc %_DEST%\inc%_EXT%\vcl\solar.hrc ..\inc\vcl\accel.hxx %_DEST%\inc%_EXT%\vcl\accel.hxx ..\inc\vcl\alpha.hxx %_DEST%\inc%_EXT%\vcl\alpha.hxx ..\inc\vcl\animate.hxx %_DEST%\inc%_EXT%\vcl\animate.hxx From a2637545e1419956096899a82a9c79511d83fbc5 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Fri, 15 Jan 2010 00:20:57 +0100 Subject: [PATCH 281/283] solve some merge problems --- vcl/source/gdi/makefile.mk | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/vcl/source/gdi/makefile.mk b/vcl/source/gdi/makefile.mk index 9e4047d63e82..ed2a9b2ba1e1 100755 --- a/vcl/source/gdi/makefile.mk +++ b/vcl/source/gdi/makefile.mk @@ -58,6 +58,7 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/print.obj \ $(SLO)$/print2.obj \ $(SLO)$/print3.obj \ + $(SLO)$/oldprintadaptor.obj \ $(SLO)$/configsettings.obj \ $(SLO)$/sallayout.obj \ $(SLO)$/image.obj \ @@ -73,7 +74,6 @@ EXCEPTIONSFILES= $(SLO)$/salmisc.obj \ $(SLO)$/pngread.obj \ $(SLO)$/pngwrite.obj \ $(SLO)$/virdev.obj \ - $(SLO)$/impprn.obj \ $(SLO)$/gdimtf.obj \ $(SLO)$/graphictools.obj \ $(SLO)$/textlayout.obj \ @@ -105,7 +105,6 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/mapmod.obj \ $(SLO)$/metaact.obj \ $(SLO)$/octree.obj \ - $(SLO)$/oldprintadaptor.obj \ $(SLO)$/outmap.obj \ $(SLO)$/outdev2.obj \ $(SLO)$/outdev4.obj \ @@ -118,11 +117,7 @@ SLOFILES= $(EXCEPTIONSFILES) \ $(SLO)$/pdfwriter.obj \ $(SLO)$/salgdilayout.obj \ $(SLO)$/extoutdevdata.obj \ - $(SLO)$/salnativewidgets-none.obj \ - $(SLO)$/bmpconv.obj \ - $(SLO)$/pngread.obj \ - $(SLO)$/pngwrite.obj \ - $(SLO)$/graphictools.obj + $(SLO)$/salnativewidgets-none.obj # --- Targets ------------------------------------------------------ From c979003e3c9601f525011341c322ba2c27e2a0da Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Mon, 18 Jan 2010 15:07:17 +0100 Subject: [PATCH 282/283] masterfix: #i10000# use typeinfo instead of typeinfo.h which cause an error on mac --- comphelper/source/property/property.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comphelper/source/property/property.cxx b/comphelper/source/property/property.cxx index 17949b9889dd..0ccc28d4238b 100644 --- a/comphelper/source/property/property.cxx +++ b/comphelper/source/property/property.cxx @@ -42,7 +42,7 @@ #include #include #include - #include + #include #endif #include #include From 7f5f6c30e89c27422a1576ccceb9b0d79c8e3f0d Mon Sep 17 00:00:00 2001 From: Kurt Zenker Date: Mon, 18 Jan 2010 15:24:16 +0100 Subject: [PATCH 283/283] masterfix: #i10000# use SvMemoryStream::GetEndOfData() instead of SvMemoryStream::GetSize() --- goodies/source/filter.vcl/ieps/ieps.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/goodies/source/filter.vcl/ieps/ieps.cxx b/goodies/source/filter.vcl/ieps/ieps.cxx index 742985904ce8..7f1ecfc65bd0 100644 --- a/goodies/source/filter.vcl/ieps/ieps.cxx +++ b/goodies/source/filter.vcl/ieps/ieps.cxx @@ -293,7 +293,7 @@ static bool RenderAsPNGThroughHelper(const sal_uInt8* pBuf, sal_uInt32 nBytesRea aMemStm.Seek(0); if ( - aMemStm.GetSize() && + aMemStm.GetEndOfData() && GraphicConverter::Import(aMemStm, rGraphic, CVT_PNG) == ERRCODE_NONE ) {