From 8730974f3da0ce385cac84b81b8ae3169001399c Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Sun, 28 Sep 2014 22:33:50 +1000 Subject: vcl: cleanup headers - remove comments, tabify Change-Id: I718832960abe07450bc9fdda15297cb5e56f84e4 Reviewed-on: https://gerrit.libreoffice.org/11674 Reviewed-by: Chris Sherlock Tested-by: Chris Sherlock --- include/vcl/abstdlg.hxx | 32 ++-- include/vcl/accel.hxx | 94 ++++++----- include/vcl/alpha.hxx | 128 +++++--------- include/vcl/animate.hxx | 285 +++++++++++++++---------------- include/vcl/apptypes.hxx | 14 +- include/vcl/bitmap.hxx | 355 ++++++++++++++++++++++----------------- include/vcl/bitmapex.hxx | 151 +++++++++-------- include/vcl/bitmapfilter.hxx | 5 +- include/vcl/bitmapscalesuper.hxx | 15 +- include/vcl/bmpacc.hxx | 105 ++++++------ include/vcl/btndlg.hxx | 56 +++--- include/vcl/builder.hxx | 332 ++++++++++++++++++++---------------- include/vcl/button.hxx | 4 - 13 files changed, 817 insertions(+), 759 deletions(-) (limited to 'include') diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx index d877e6d3dc46..2b31b1b1d348 100644 --- a/include/vcl/abstdlg.hxx +++ b/include/vcl/abstdlg.hxx @@ -29,50 +29,52 @@ class Link; class VCL_DLLPUBLIC VclAbstractDialog { public: - virtual short Execute() = 0; - virtual ~VclAbstractDialog(); + virtual ~VclAbstractDialog(); + + virtual short Execute() = 0; }; class VCL_DLLPUBLIC VclAbstractDialog2 { public: - virtual void StartExecuteModal( const Link& rEndDialogHdl ) = 0; - virtual long GetResult() = 0; - virtual ~VclAbstractDialog2(); + virtual ~VclAbstractDialog2(); + + virtual void StartExecuteModal( const Link& rEndDialogHdl ) = 0; + virtual long GetResult() = 0; }; class VCL_DLLPUBLIC VclAbstractTerminatedDialog : public VclAbstractDialog { public: - virtual void EndDialog(long nResult =0) = 0; + virtual void EndDialog(long nResult =0) = 0; }; class VCL_DLLPUBLIC VclAbstractRefreshableDialog : public VclAbstractDialog { public: - virtual void Update() = 0; - virtual void Sync() = 0; + virtual void Update() = 0; + virtual void Sync() = 0; }; class VCL_DLLPUBLIC AbstractPasswordToOpenModifyDialog : public VclAbstractDialog { public: - virtual OUString GetPasswordToOpen() const = 0; - virtual OUString GetPasswordToModify() const = 0; - virtual bool IsRecommendToOpenReadonly() const = 0; + virtual OUString GetPasswordToOpen() const = 0; + virtual OUString GetPasswordToModify() const = 0; + virtual bool IsRecommendToOpenReadonly() const = 0; }; class VCL_DLLPUBLIC VclAbstractDialogFactory { public: - virtual ~VclAbstractDialogFactory(); // needed for export of vtable - static VclAbstractDialogFactory* Create(); + virtual ~VclAbstractDialogFactory(); // needed for export of vtable + static VclAbstractDialogFactory* Create(); // nDialogId was previously a ResId without ResMgr; the ResourceId is now // an implementation detail of the factory - virtual VclAbstractDialog* CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) = 0; + virtual VclAbstractDialog* CreateVclDialog( vcl::Window* pParent, sal_uInt32 nResId ) = 0; // creates instance of PasswordToOpenModifyDialog from cui - virtual AbstractPasswordToOpenModifyDialog * CreatePasswordToOpenModifyDialog( vcl::Window * pParent, sal_uInt16 nMinPasswdLen, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0; + virtual AbstractPasswordToOpenModifyDialog* CreatePasswordToOpenModifyDialog( vcl::Window * pParent, sal_uInt16 nMinPasswdLen, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0; }; #endif diff --git a/include/vcl/accel.hxx b/include/vcl/accel.hxx index 2e6e26d3e9d1..5088dc57ff21 100644 --- a/include/vcl/accel.hxx +++ b/include/vcl/accel.hxx @@ -34,65 +34,69 @@ class VCL_DLLPUBLIC Accelerator : public Resource friend class ImplAccelManager; private: - ImplAccelData* mpData; - OUString maHelpStr; - Link maActivateHdl; - Link maDeactivateHdl; - Link maSelectHdl; + ImplAccelData* mpData; + OUString maHelpStr; + Link maActivateHdl; + Link maDeactivateHdl; + Link maSelectHdl; // Will be set by AcceleratorManager - vcl::KeyCode maCurKeyCode; - sal_uInt16 mnCurId; - sal_uInt16 mnCurRepeat; - bool mbIsCancel; - bool* mpDel; - - SAL_DLLPRIVATE void ImplInit(); - SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData ); - SAL_DLLPRIVATE void ImplDeleteData(); - SAL_DLLPRIVATE void ImplInsertAccel( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode, - bool bEnable, Accelerator* pAutoAccel ); - - SAL_DLLPRIVATE ImplAccelEntry* ImplGetAccelData( const vcl::KeyCode& rKeyCode ) const; + vcl::KeyCode maCurKeyCode; + sal_uInt16 mnCurId; + sal_uInt16 mnCurRepeat; + bool mbIsCancel; + bool* mpDel; + + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData ); + SAL_DLLPRIVATE void ImplDeleteData(); + SAL_DLLPRIVATE void ImplInsertAccel( + sal_uInt16 nItemId, + const vcl::KeyCode& rKeyCode, + bool bEnable, + Accelerator* pAutoAccel ); + + SAL_DLLPRIVATE ImplAccelEntry* + ImplGetAccelData( const vcl::KeyCode& rKeyCode ) const; protected: - SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); public: - Accelerator(); - Accelerator( const Accelerator& rAccel ); - Accelerator( const ResId& rResId ); - virtual ~Accelerator(); + Accelerator(); + Accelerator( const Accelerator& rAccel ); + Accelerator( const ResId& rResId ); + virtual ~Accelerator(); - virtual void Activate(); - virtual void Deactivate(); - virtual void Select(); + virtual void Activate(); + virtual void Deactivate(); + virtual void Select(); - void InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); - void InsertItem( const ResId& rResId ); + void InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); + void InsertItem( const ResId& rResId ); - sal_uInt16 GetCurItemId() const { return mnCurId; } - const vcl::KeyCode& GetCurKeyCode() const { return maCurKeyCode; } - sal_uInt16 GetCurRepeat() const { return mnCurRepeat; } - bool IsCancel() const { return mbIsCancel; } + sal_uInt16 GetCurItemId() const { return mnCurId; } + const vcl::KeyCode& GetCurKeyCode() const { return maCurKeyCode; } + sal_uInt16 GetCurRepeat() const { return mnCurRepeat; } + bool IsCancel() const { return mbIsCancel; } - sal_uInt16 GetItemCount() const; - sal_uInt16 GetItemId( sal_uInt16 nPos ) const; - vcl::KeyCode GetKeyCode( sal_uInt16 nItemId ) const; + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + vcl::KeyCode GetKeyCode( sal_uInt16 nItemId ) const; - Accelerator* GetAccel( sal_uInt16 nItemId ) const; + Accelerator* GetAccel( sal_uInt16 nItemId ) const; - void SetHelpText( const OUString& rHelpText ) { maHelpStr = rHelpText; } - const OUString& GetHelpText() const { return maHelpStr; } + void SetHelpText( const OUString& rHelpText ) { maHelpStr = rHelpText; } + const OUString& GetHelpText() const { return maHelpStr; } - void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; } - const Link& GetActivateHdl() const { return maActivateHdl; } - void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; } - const Link& GetDeactivateHdl() const { return maDeactivateHdl; } - void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } - const Link& GetSelectHdl() const { return maSelectHdl; } + void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; } + const Link& GetActivateHdl() const { return maActivateHdl; } + void SetDeactivateHdl( const Link& rLink ) { maDeactivateHdl = rLink; } + const Link& GetDeactivateHdl() const { return maDeactivateHdl; } + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } - Accelerator& operator=( const Accelerator& rAccel ); + Accelerator& operator=( const Accelerator& rAccel ); }; #endif // INCLUDED_VCL_ACCEL_HXX diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx index bd8ce8a10b9c..fd8476537f6b 100644 --- a/include/vcl/alpha.hxx +++ b/include/vcl/alpha.hxx @@ -24,108 +24,60 @@ #include -// - AlphaMask - - - class ImageList; class BitmapEx; class VCL_DLLPUBLIC AlphaMask : private Bitmap { -private: - friend class BitmapEx; - friend class OutputDevice; - friend bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx& rTarget, SvStream& rIStm); - - SAL_DLLPRIVATE const Bitmap& ImplGetBitmap() const; - SAL_DLLPRIVATE void ImplSetBitmap( const Bitmap& rBitmap ); - public: - AlphaMask(); - AlphaMask( const Bitmap& rBitmap ); - AlphaMask( const AlphaMask& rAlphaMask ); - AlphaMask( const Size& rSizePixel, sal_uInt8* pEraseTransparency = NULL ); - virtual ~AlphaMask(); + AlphaMask(); + AlphaMask( const Bitmap& rBitmap ); + AlphaMask( const AlphaMask& rAlphaMask ); + AlphaMask( const Size& rSizePixel, sal_uInt8* pEraseTransparency = NULL ); + virtual ~AlphaMask(); AlphaMask& operator=( const Bitmap& rBitmap ); - AlphaMask& operator=( const AlphaMask& rAlphaMask ) - { - return static_cast( Bitmap::operator=( rAlphaMask ) ); - } - - bool operator!() const - { - return Bitmap::operator!(); - } - - bool operator==( const AlphaMask& rAlphaMask ) const - { - return Bitmap::operator==( rAlphaMask ); - } - - bool operator!=( const AlphaMask& rAlphaMask ) const - { - return Bitmap::operator!=( rAlphaMask ); - } - - const MapMode& GetPrefMapMode() const - { - return Bitmap::GetPrefMapMode(); - } - - void SetPrefMapMode( const MapMode& rMapMode ) - { - Bitmap::SetPrefMapMode( rMapMode ); - } - - const Size& GetPrefSize() const - { - return Bitmap::GetPrefSize(); - } - - void SetPrefSize( const Size& rSize ) - { - Bitmap::SetPrefSize( rSize ); - } - - Size GetSizePixel() const - { - return Bitmap::GetSizePixel(); - } - - sal_uLong GetSizeBytes() const - { - return Bitmap::GetSizeBytes(); - } - sal_uLong GetChecksum() const - { - return Bitmap::GetChecksum(); - } - - Bitmap GetBitmap() const; - - bool Erase( sal_uInt8 cTransparency ); - bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); - bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, - sal_uLong nTol = 0UL ); - - BitmapReadAccess* AcquireReadAccess() - { - return Bitmap::AcquireReadAccess(); - } - - BitmapWriteAccess* AcquireWriteAccess() - { - return Bitmap::AcquireWriteAccess(); - } - - void ReleaseAccess( BitmapReadAccess* pAccess ); + AlphaMask& operator=( const AlphaMask& rAlphaMask ) { return static_cast( Bitmap::operator=( rAlphaMask ) ); } + bool operator!() const { return Bitmap::operator!(); } + bool operator==( const AlphaMask& rAlphaMask ) const { return Bitmap::operator==( rAlphaMask ); } + bool operator!=( const AlphaMask& rAlphaMask ) const { return Bitmap::operator!=( rAlphaMask ); } + + const MapMode& GetPrefMapMode() const { return Bitmap::GetPrefMapMode(); } + void SetPrefMapMode( const MapMode& rMapMode ) { Bitmap::SetPrefMapMode( rMapMode ); } + + const Size& GetPrefSize() const { return Bitmap::GetPrefSize(); } + void SetPrefSize( const Size& rSize ) { Bitmap::SetPrefSize( rSize ); } + + Size GetSizePixel() const { return Bitmap::GetSizePixel(); } + sal_uLong GetSizeBytes() const { return Bitmap::GetSizeBytes(); } + + sal_uLong GetChecksum() const { return Bitmap::GetChecksum(); } + + Bitmap GetBitmap() const; + + bool Erase( sal_uInt8 cTransparency ); + bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); + bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, sal_uLong nTol = 0UL ); + + BitmapReadAccess* AcquireReadAccess() { return Bitmap::AcquireReadAccess(); } + BitmapWriteAccess* AcquireWriteAccess() { return Bitmap::AcquireWriteAccess(); } + + void ReleaseAccess( BitmapReadAccess* pAccess ); typedef vcl::ScopedBitmapAccess< BitmapReadAccess, AlphaMask, &AlphaMask::AcquireReadAccess > ScopedReadAccess; typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireWriteAccess > ScopedWriteAccess; + +private: + friend class BitmapEx; + friend class OutputDevice; + friend bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx& rTarget, SvStream& rIStm); + + SAL_DLLPRIVATE const Bitmap& ImplGetBitmap() const; + SAL_DLLPRIVATE void ImplSetBitmap( const Bitmap& rBitmap ); + }; #endif // INCLUDED_VCL_ALPHA_HXX diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx index f75caf6f5cca..25f10f0c3ce7 100644 --- a/include/vcl/animate.hxx +++ b/include/vcl/animate.hxx @@ -45,59 +45,58 @@ enum CycleMode struct VCL_DLLPUBLIC AnimationBitmap { - BitmapEx aBmpEx; - Point aPosPix; - Size aSizePix; - long nWait; - Disposal eDisposal; - bool bUserInput; - - AnimationBitmap() - : nWait(0) - , eDisposal(DISPOSE_NOT) - , bUserInput(false) - { - } - - AnimationBitmap( - const BitmapEx& rBmpEx, - const Point& rPosPix, - const Size& rSizePix, - long _nWait = 0L, - Disposal _eDisposal = DISPOSE_NOT - ) : - aBmpEx ( rBmpEx ), - aPosPix ( rPosPix ), - aSizePix ( rSizePix ), - nWait ( _nWait ), - eDisposal ( _eDisposal ), - bUserInput ( false ) - {} - - bool operator==( const AnimationBitmap& rAnimBmp ) const - { - return( rAnimBmp.aBmpEx == aBmpEx && - rAnimBmp.aPosPix == aPosPix && - rAnimBmp.aSizePix == aSizePix && - rAnimBmp.nWait == nWait && - rAnimBmp.eDisposal == eDisposal && - rAnimBmp.bUserInput == bUserInput ); - } - - bool operator!=( const AnimationBitmap& rAnimBmp ) const - { return !( *this == rAnimBmp ); } - - bool IsEqual( const AnimationBitmap& rAnimBmp ) const - { - return( rAnimBmp.aPosPix == aPosPix && - rAnimBmp.aSizePix == aSizePix && - rAnimBmp.nWait == nWait && - rAnimBmp.eDisposal == eDisposal && - rAnimBmp.bUserInput == bUserInput && - rAnimBmp.aBmpEx.IsEqual( aBmpEx ) ); - } - - sal_uLong GetChecksum() const; + BitmapEx aBmpEx; + Point aPosPix; + Size aSizePix; + long nWait; + Disposal eDisposal; + bool bUserInput; + + AnimationBitmap() + : nWait(0) + , eDisposal(DISPOSE_NOT) + , bUserInput(false) + {} + + AnimationBitmap( + const BitmapEx& rBmpEx, + const Point& rPosPix, + const Size& rSizePix, + long _nWait = 0L, + Disposal _eDisposal = DISPOSE_NOT + ) : + aBmpEx ( rBmpEx ), + aPosPix ( rPosPix ), + aSizePix ( rSizePix ), + nWait ( _nWait ), + eDisposal ( _eDisposal ), + bUserInput ( false ) + {} + + bool operator==( const AnimationBitmap& rAnimBmp ) const + { + return( rAnimBmp.aBmpEx == aBmpEx && + rAnimBmp.aPosPix == aPosPix && + rAnimBmp.aSizePix == aSizePix && + rAnimBmp.nWait == nWait && + rAnimBmp.eDisposal == eDisposal && + rAnimBmp.bUserInput == bUserInput ); + } + + bool operator!=( const AnimationBitmap& rAnimBmp ) const + { return !( *this == rAnimBmp ); } + + bool IsEqual( const AnimationBitmap& rAnimBmp ) const + { + return( rAnimBmp.aPosPix == aPosPix && + rAnimBmp.aSizePix == aSizePix && + rAnimBmp.nWait == nWait && + rAnimBmp.eDisposal == eDisposal && + rAnimBmp.bUserInput == bUserInput && + rAnimBmp.aBmpEx.IsEqual( aBmpEx ) ); + } + + sal_uLong GetChecksum() const; }; struct AInfo @@ -112,8 +111,8 @@ struct AInfo OutputDevice* pOutDev; void* pViewData; long nExtraData; - bool bWithSize; - bool bPause; + bool bWithSize; + bool bPause; AInfo() : pOutDev( NULL ), pViewData( NULL ), @@ -128,111 +127,115 @@ typedef ::std::vector< ImplAnimView* > AnimViewList_impl; class VCL_DLLPUBLIC Animation { - SAL_DLLPRIVATE static sal_uLong mnAnimCount; - - AnimationBitmapList_impl maList; - AnimViewList_impl maViewList; - Link maNotifyLink; - BitmapEx maBitmapEx; - Timer maTimer; - Size maGlobalSize; - long mnLoopCount; - long mnLoops; - size_t mnPos; - CycleMode meCycleMode; - bool mbIsInAnimation; - bool mbLoopTerminated; - bool mbIsWaiting; - - - SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); - DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, void* ); - public: + Animation(); + Animation( const Animation& rAnimation ); + ~Animation(); - SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; } - SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; } - SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnPos; } + Animation& operator=( const Animation& rAnimation ); + bool operator==( const Animation& rAnimation ) const; + bool operator!=( const Animation& rAnimation ) const + { return !(*this==rAnimation); } + void Clear(); -public: - Animation(); - Animation( const Animation& rAnimation ); - ~Animation(); + bool Start( + OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSz, + long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = NULL); - Animation& operator=( const Animation& rAnimation ); - bool operator==( const Animation& rAnimation ) const; - bool operator!=( const Animation& rAnimation ) const - { return !(*this==rAnimation); } + void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 ); - void Clear(); + void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; - bool Start( - OutputDevice* pOutDev, - const Point& rDestPt, - const Size& rDestSz, - long nExtraData = 0, - OutputDevice* pFirstFrameOutDev = NULL - ); - void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 ); + bool IsInAnimation() const { return mbIsInAnimation; } + bool IsTransparent() const; + bool IsTerminated() const { return mbLoopTerminated; } - void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; - void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; + const Size& GetDisplaySizePixel() const { return maGlobalSize; } + void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } - bool IsInAnimation() const { return mbIsInAnimation; } - bool IsTransparent() const; - bool IsTerminated() const { return mbLoopTerminated; } + const BitmapEx& GetBitmapEx() const { return maBitmapEx; } + void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } - const Size& GetDisplaySizePixel() const { return maGlobalSize; } - void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } + sal_uLong GetLoopCount() const { return mnLoopCount; } + void SetLoopCount( const sal_uLong nLoopCount ); + void ResetLoopCount(); - const BitmapEx& GetBitmapEx() const { return maBitmapEx; } - void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } + void SetCycleMode( CycleMode eMode ); + CycleMode GetCycleMode() const { return meCycleMode; } - sal_uLong GetLoopCount() const { return mnLoopCount; } - void SetLoopCount( const sal_uLong nLoopCount ); - void ResetLoopCount(); + void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } + const Link& GetNotifyHdl() const { return maNotifyLink; } - void SetCycleMode( CycleMode eMode ); - CycleMode GetCycleMode() const { return meCycleMode; } + size_t Count() const { return maList.size(); } + bool Insert( const AnimationBitmap& rAnimationBitmap ); + const AnimationBitmap& + Get( sal_uInt16 nAnimation ) const; + void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); - void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } - const Link& GetNotifyHdl() const { return maNotifyLink; } + sal_uLong GetSizeBytes() const; + sal_uLong GetChecksum() const; - size_t Count() const { return maList.size(); } - bool Insert( const AnimationBitmap& rAnimationBitmap ); - const AnimationBitmap& Get( sal_uInt16 nAnimation ) const; - void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); +public: - sal_uLong GetSizeBytes() const; - sal_uLong GetChecksum() const; + bool Convert( BmpConversion eConversion ); + bool ReduceColors( + sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + + bool Invert(); + bool Mirror( sal_uLong nMirrorFlags ); + bool Adjust( + short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + bool bInvert = false ); + + bool Filter( + BmpFilter eFilter, + const BmpFilterParam* pFilterParam = NULL, + const Link* pProgress = NULL ); + + friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation ); + friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation ); public: - bool Convert( BmpConversion eConversion ); - bool ReduceColors( - sal_uInt16 nNewColorCount, - BmpReduce eReduce = BMP_REDUCE_SIMPLE - ); - bool Invert(); - bool Mirror( sal_uLong nMirrorFlags ); - bool Adjust( - short nLuminancePercent = 0, - short nContrastPercent = 0, - short nChannelRPercent = 0, - short nChannelGPercent = 0, - short nChannelBPercent = 0, - double fGamma = 1.0, - bool bInvert = false - ); - bool Filter( - BmpFilter eFilter, - const BmpFilterParam* pFilterParam = NULL, - const Link* pProgress = NULL - ); - - friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation ); - friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation ); + SAL_DLLPRIVATE static void + ImplIncAnimCount() { mnAnimCount++; } + SAL_DLLPRIVATE static void + ImplDecAnimCount() { mnAnimCount--; } + SAL_DLLPRIVATE sal_uLong + ImplGetCurPos() const { return mnPos; } + +private: + SAL_DLLPRIVATE static sal_uLong mnAnimCount; + + AnimationBitmapList_impl maList; + AnimViewList_impl maViewList; + + Link maNotifyLink; + BitmapEx maBitmapEx; + Timer maTimer; + Size maGlobalSize; + long mnLoopCount; + long mnLoops; + size_t mnPos; + CycleMode meCycleMode; + bool mbIsInAnimation; + bool mbLoopTerminated; + bool mbIsWaiting; + + SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); + DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, void* ); + }; #endif // INCLUDED_VCL_ANIMATE_HXX diff --git a/include/vcl/apptypes.hxx b/include/vcl/apptypes.hxx index 60ead542cb10..bc0307cf8d86 100644 --- a/include/vcl/apptypes.hxx +++ b/include/vcl/apptypes.hxx @@ -23,13 +23,13 @@ #include #include -#define EXC_RSCNOTLOADED ((sal_uInt16)0x0100) -#define EXC_SYSTEM ((sal_uInt16)0x0300) -#define EXC_DISPLAY ((sal_uInt16)0x0400) -#define EXC_REMOTE ((sal_uInt16)0x0500) -#define EXC_USER ((sal_uInt16)0x1000) -#define EXC_MAJORTYPE ((sal_uInt16)0xFF00) -#define EXC_MINORTYPE ((sal_uInt16)0x00FF) +#define EXC_RSCNOTLOADED ((sal_uInt16)0x0100) +#define EXC_SYSTEM ((sal_uInt16)0x0300) +#define EXC_DISPLAY ((sal_uInt16)0x0400) +#define EXC_REMOTE ((sal_uInt16)0x0500) +#define EXC_USER ((sal_uInt16)0x1000) +#define EXC_MAJORTYPE ((sal_uInt16)0xFF00) +#define EXC_MINORTYPE ((sal_uInt16)0x00FF) #define VCL_INPUT_MOUSE 0x0001 #define VCL_INPUT_KEYBOARD 0x0002 diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index d2f0cac3bcde..6f66f9ce8c24 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -60,7 +60,7 @@ #define BMP_VECTORIZE_BOUND_ONLY 0x00000004UL #define BMP_VECTORIZE_REDUCE_EDGES 0x00000008UL -#define BMP_COL_TRANS Color( 252, 3, 251 ) +#define BMP_COL_TRANS Color( 252, 3, 251 ) enum BmpConversion { @@ -127,39 +127,6 @@ enum BmpFilter class VCL_DLLPUBLIC BmpFilterParam { - friend class Bitmap; - friend class BitmapEx; - friend class Animation; - -private: - BmpFilter meFilter; - sal_uLong mnProgressStart; - sal_uLong mnProgressEnd; - -public: - struct MosaicTileSize - { - sal_uLong mnTileWidth; - sal_uLong mnTileHeight; - }; - - struct EmbossAngles - { - sal_uInt16 mnAzimuthAngle100; - sal_uInt16 mnElevationAngle100; - }; - -private: - union - { - sal_uInt16 mnSepiaPercent; - sal_uInt8 mcSolarGreyThreshold; - double mnRadius; - - MosaicTileSize maMosaicTileSize; - EmbossAngles maEmbossAngles; - }; - public: BmpFilterParam( sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : @@ -190,36 +157,68 @@ public: maEmbossAngles.mnAzimuthAngle100 = nEmbossAzimuthAngle100; maEmbossAngles.mnElevationAngle100 = nEmbossElevationAngle100; } -}; +private: + friend class Bitmap; + friend class BitmapEx; + friend class Animation; -// Resample kernels +private: + BmpFilter meFilter; + sal_uLong mnProgressStart; + sal_uLong mnProgressEnd; + +public: + struct MosaicTileSize + { + sal_uLong mnTileWidth; + sal_uLong mnTileHeight; + }; + + struct EmbossAngles + { + sal_uInt16 mnAzimuthAngle100; + sal_uInt16 mnElevationAngle100; + }; + +private: + union + { + sal_uInt16 mnSepiaPercent; + sal_uInt8 mcSolarGreyThreshold; + double mnRadius; + + MosaicTileSize maMosaicTileSize; + EmbossAngles maEmbossAngles; + }; +}; + +// Resample kernels class Kernel { public: - Kernel () {} - virtual ~Kernel() {} + Kernel () {} + virtual ~Kernel() {} - virtual double GetWidth() const = 0; - virtual double Calculate( double x ) const = 0; + virtual double GetWidth() const = 0; + virtual double Calculate( double x ) const = 0; }; class Lanczos3Kernel : public Kernel { - typedef boost::math::policies::policy< - boost::math::policies::promote_double > SincPolicy; public: - Lanczos3Kernel() : Kernel () {} - virtual double GetWidth() const SAL_OVERRIDE { return 3.0; } - virtual double Calculate (double x) const SAL_OVERRIDE + Lanczos3Kernel() : Kernel () {} + + virtual double GetWidth() const SAL_OVERRIDE { return 3.0; } + virtual double Calculate (double x) const SAL_OVERRIDE { return (-3.0 <= x && x < 3.0) ? SincFilter(x) * SincFilter( x / 3.0 ) : 0.0; } - inline double SincFilter(double x) const + inline double SincFilter(double x) const { if (x == 0.0) { @@ -228,14 +227,20 @@ public: x = x * M_PI; return boost::math::sinc_pi(x, SincPolicy()); } + +private: + typedef boost::math::policies::policy< + boost::math::policies::promote_double > SincPolicy; }; -class BicubicKernel : public Kernel { +class BicubicKernel : public Kernel +{ public: - BicubicKernel() : Kernel () {} + BicubicKernel() : Kernel () {} + private: - virtual double GetWidth() const SAL_OVERRIDE { return 2.0; } - virtual double Calculate (double x) const SAL_OVERRIDE + virtual double GetWidth() const SAL_OVERRIDE { return 2.0; } + virtual double Calculate (double x) const SAL_OVERRIDE { if (x < 0.0) { @@ -254,12 +259,13 @@ private: } }; -class BilinearKernel : public Kernel { +class BilinearKernel : public Kernel +{ public: - BilinearKernel() : Kernel () {} + BilinearKernel() : Kernel () {} private: - virtual double GetWidth() const SAL_OVERRIDE { return 1.0; } - virtual double Calculate (double x) const SAL_OVERRIDE + virtual double GetWidth() const SAL_OVERRIDE { return 1.0; } + virtual double Calculate (double x) const SAL_OVERRIDE { if (x < 0.0) { @@ -273,12 +279,14 @@ private: } }; -class BoxKernel : public Kernel { +class BoxKernel : public Kernel +{ public: - BoxKernel() : Kernel () {} + BoxKernel() : Kernel () {} + private: - virtual double GetWidth() const SAL_OVERRIDE { return 0.5; } - virtual double Calculate (double x) const SAL_OVERRIDE + virtual double GetWidth() const SAL_OVERRIDE { return 0.5; } + virtual double Calculate (double x) const SAL_OVERRIDE { if (-0.5 <= x && x < 0.5) return 1.0; @@ -313,67 +321,14 @@ struct BitmapSystemData class VCL_DLLPUBLIC Bitmap { -private: - - ImpBitmap* mpImpBmp; - MapMode maPrefMapMode; - Size maPrefSize; - -public: - - SAL_DLLPRIVATE void ImplReleaseRef(); - SAL_DLLPRIVATE void ImplMakeUnique(); - ImpBitmap* ImplGetImpBitmap() const { return mpImpBmp;} - SAL_DLLPRIVATE void ImplSetImpBitmap( ImpBitmap* pImpBmp ); - SAL_DLLPRIVATE void ImplAssignWithSize( const Bitmap& rBitmap ); - - SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew) const; - SAL_DLLPRIVATE bool ImplScaleFast( const double& rScaleX, const double& rScaleY ); - SAL_DLLPRIVATE bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ); - SAL_DLLPRIVATE bool ImplScaleSuper( const double& rScaleX, const double& rScaleY ); - SAL_DLLPRIVATE bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel); - - SAL_DLLPRIVATE bool ImplConvolutionPass( Bitmap& aNewBitmap, const int nNewSize, BitmapReadAccess* pReadAcc, - int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount ); - - SAL_DLLPRIVATE bool ImplMakeMono( sal_uInt8 cThreshold ); - SAL_DLLPRIVATE bool ImplMakeMonoDither(); - SAL_DLLPRIVATE bool ImplMakeGreyscales( sal_uInt16 nGreyscales ); - SAL_DLLPRIVATE bool ImplConvertUp( sal_uInt16 nBitCount, Color* pExtColor = NULL ); - SAL_DLLPRIVATE bool ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor = NULL ); - SAL_DLLPRIVATE bool ImplConvertGhosted(); - SAL_DLLPRIVATE bool ImplDitherMatrix(); - SAL_DLLPRIVATE bool ImplDitherFloyd(); - SAL_DLLPRIVATE bool ImplDitherFloyd16(); - SAL_DLLPRIVATE bool ImplReduceSimple( sal_uInt16 nColorCount ); - SAL_DLLPRIVATE bool ImplReducePopular( sal_uInt16 nColorCount ); - SAL_DLLPRIVATE bool ImplReduceMedian( sal_uInt16 nColorCount ); - SAL_DLLPRIVATE void ImplMedianCut( sal_uLong* pColBuf, BitmapPalette& rPal, - long nR1, long nR2, long nG1, long nG2, long nB1, long nB2, - long nColors, long nPixels, long& rIndex ); - SAL_DLLPRIVATE bool ImplConvolute3( const long* pMatrix, long nDivisor, - const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplMedianFilter( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplSobelGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplEmbossGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplSolarize( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplSepia( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplMosaic( const BmpFilterParam* pFilterParam, const Link* pProgress ); - SAL_DLLPRIVATE bool ImplPopArt( const BmpFilterParam* pFilterParam, const Link* pProgress ); - - SAL_DLLPRIVATE bool ImplSeparableBlurFilter( const double aRadius = 0.7 ); - SAL_DLLPRIVATE bool ImplSeparableUnsharpenFilter( const double aRadius = 0.7 ); - SAL_DLLPRIVATE bool ImplDuotoneFilter( const sal_uLong nColorOne, sal_uLong nColorTwo ); - SAL_DLLPRIVATE void ImplBlurContributions( const int aSize, const int aNumberOfContributions, - double* pBlurVector, double*& pWeights, int*& pPixels, int*& pCount ); public: - Bitmap(); - Bitmap( const Bitmap& rBitmap ); - Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = NULL ); - Bitmap( const ResId& rResId ); - Bitmap( SalBitmap* pSalBitmap ); - virtual ~Bitmap(); + Bitmap(); + Bitmap( const Bitmap& rBitmap ); + Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = NULL ); + Bitmap( const ResId& rResId ); + Bitmap( SalBitmap* pSalBitmap ); + virtual ~Bitmap(); Bitmap& operator=( const Bitmap& rBitmap ); inline bool operator!() const; @@ -394,9 +349,9 @@ public: Size GetSizePixel() const; - sal_uInt16 GetBitCount() const; - inline sal_uLong GetColorCount() const; - inline sal_uLong GetSizeBytes() const; + sal_uInt16 GetBitCount() const; + inline sal_uLong GetColorCount() const; + inline sal_uLong GetSizeBytes() const; bool HasGreyPalette() const; /** get system dependent bitmap data @@ -407,16 +362,17 @@ public: */ bool GetSystemData( BitmapSystemData& rData ) const; - sal_uLong GetChecksum() const; + sal_uLong GetChecksum() const; Bitmap CreateDisplayBitmap( OutputDevice* pDisplay ); Bitmap GetColorTransformedBitmap() const; - static const BitmapPalette& GetGreyPalette( int nEntries ); + static const BitmapPalette& + GetGreyPalette( int nEntries ); public: - bool MakeMono( sal_uInt8 cThreshold ); + bool MakeMono( sal_uInt8 cThreshold ); /** Convert bitmap format @@ -438,8 +394,9 @@ public: @return true, if the color reduction operation was completed successfully. */ - bool ReduceColors( sal_uInt16 nNewColorCount, - BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + bool ReduceColors( + sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); /** Apply a dither algorithm to the bitmap @@ -483,8 +440,9 @@ public: not only returned when the operation failed, but also if nothing had to be done, e.g. because nDX and nDY were zero. */ - bool Expand( sal_uLong nDX, sal_uLong nDY, - const Color* pInitColor = NULL ); + bool Expand( + sal_uLong nDX, sal_uLong nDY, + const Color* pInitColor = NULL ); /** Copy a rectangular area from another bitmap @@ -508,12 +466,15 @@ public: nothing had to be done, e.g. because one of the rectangles are empty. */ - bool CopyPixel( const Rectangle& rRectDst, - const Rectangle& rRectSrc, - const Bitmap* pBmpSrc = NULL ); + bool CopyPixel( + const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const Bitmap* pBmpSrc = NULL ); - bool CopyPixel_AlphaOptimized( const Rectangle& rRectDst, const Rectangle& rRectSrc, - const Bitmap* pBmpSrc = NULL); + bool CopyPixel_AlphaOptimized( + const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const Bitmap* pBmpSrc = NULL ); /** Perform boolean operations with another bitmap @@ -525,8 +486,9 @@ public: @return true, if the operation was completed successfully. */ - bool CombineSimple( const Bitmap& rMask, - BmpCombine eCombine ); + bool CombineSimple( + const Bitmap& rMask, + BmpCombine eCombine ); /** Alpha-blend the given bitmap against a specified uniform background color. @@ -544,8 +506,9 @@ public: @return true, if blending was successful, false otherwise */ - bool Blend( const AlphaMask& rAlpha, - const Color& rBackgroundColor ); + bool Blend( + const AlphaMask& rAlpha, + const Color& rBackgroundColor ); /** Fill the entire bitmap with the given color @@ -600,7 +563,7 @@ public: // Adapt the BitCount of rNew to BitCount of lolal, including grey or color paltette // Can be used to create alpha/mask bitmaps after their processing in 24bit - void AdaptBitCount(Bitmap& rNew) const; + void AdaptBitCount(Bitmap& rNew) const; /** Rotate bitmap by the specified angle @@ -707,8 +670,11 @@ public: @return true, if the operation was completed successfully. */ - bool Replace( const Color* pSearchColors, const Color* rReplaceColors, - sal_uLong nColorCount, sal_uLong* pTols = NULL ); + bool Replace( + const Color* pSearchColors, + const Color* rReplaceColors, + sal_uLong nColorCount, + sal_uLong* pTols = NULL ); /** Convert the bitmap to a PolyPolygon @@ -727,9 +693,10 @@ public: @return true, if the operation was completed successfully. */ - bool Vectorize( PolyPolygon& rPolyPoly, - sal_uLong nFlags = BMP_VECTORIZE_OUTER, - const Link* pProgress = NULL ); + bool Vectorize( + PolyPolygon& rPolyPoly, + sal_uLong nFlags = BMP_VECTORIZE_OUTER, + const Link* pProgress = NULL ); /** Convert the bitmap to a meta file @@ -752,9 +719,11 @@ public: @return true, if the operation was completed successfully. */ - bool Vectorize( GDIMetaFile& rMtf, sal_uInt8 cReduce = 0, - sal_uLong nFlags = BMP_VECTORIZE_INNER, - const Link* pProgress = NULL ); + bool Vectorize( + GDIMetaFile& rMtf, + sal_uInt8 cReduce = 0, + sal_uLong nFlags = BMP_VECTORIZE_INNER, + const Link* pProgress = NULL ); /** Change various global color characteristics @@ -786,14 +755,15 @@ public: @return true, if the operation was completed successfully. */ - bool Adjust( short nLuminancePercent = 0, - short nContrastPercent = 0, - short nChannelRPercent = 0, - short nChannelGPercent = 0, - short nChannelBPercent = 0, - double fGamma = 1.0, - bool bInvert = false, - bool msoBrightness = false ); + bool Adjust( + short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + bool bInvert = false, + bool msoBrightness = false ); /** Apply specified filter to the bitmap @@ -808,9 +778,75 @@ public: @return true, if the operation was completed successfully. */ - bool Filter( BmpFilter eFilter, - const BmpFilterParam* pFilterParam = NULL, - const Link* pProgress = NULL ); + bool Filter( + BmpFilter eFilter, + const BmpFilterParam* pFilterParam = NULL, + const Link* pProgress = NULL ); + +public: + + SAL_DLLPRIVATE void ImplReleaseRef(); + SAL_DLLPRIVATE void ImplMakeUnique(); + ImpBitmap* ImplGetImpBitmap() const { return mpImpBmp;} + SAL_DLLPRIVATE void ImplSetImpBitmap( ImpBitmap* pImpBmp ); + SAL_DLLPRIVATE void ImplAssignWithSize( const Bitmap& rBitmap ); + + SAL_DLLPRIVATE void ImplAdaptBitCount(Bitmap& rNew) const; + SAL_DLLPRIVATE bool ImplScaleFast( const double& rScaleX, const double& rScaleY ); + SAL_DLLPRIVATE bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ); + SAL_DLLPRIVATE bool ImplScaleSuper( const double& rScaleX, const double& rScaleY ); + SAL_DLLPRIVATE bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, const Kernel& aKernel); + + SAL_DLLPRIVATE bool ImplConvolutionPass( + Bitmap& aNewBitmap, + const int nNewSize, + BitmapReadAccess* pReadAcc, + int aNumberOfContributions, + double* pWeights, + int* pPixels, + int* pCount ); + + SAL_DLLPRIVATE bool ImplMakeMono( sal_uInt8 cThreshold ); + SAL_DLLPRIVATE bool ImplMakeMonoDither(); + SAL_DLLPRIVATE bool ImplMakeGreyscales( sal_uInt16 nGreyscales ); + SAL_DLLPRIVATE bool ImplConvertUp( sal_uInt16 nBitCount, Color* pExtColor = NULL ); + SAL_DLLPRIVATE bool ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor = NULL ); + SAL_DLLPRIVATE bool ImplConvertGhosted(); + SAL_DLLPRIVATE bool ImplDitherMatrix(); + SAL_DLLPRIVATE bool ImplDitherFloyd(); + SAL_DLLPRIVATE bool ImplDitherFloyd16(); + SAL_DLLPRIVATE bool ImplReduceSimple( sal_uInt16 nColorCount ); + SAL_DLLPRIVATE bool ImplReducePopular( sal_uInt16 nColorCount ); + SAL_DLLPRIVATE bool ImplReduceMedian( sal_uInt16 nColorCount ); + SAL_DLLPRIVATE void ImplMedianCut( + sal_uLong* pColBuf, + BitmapPalette& rPal, + long nR1, long nR2, long nG1, long nG2, long nB1, long nB2, + long nColors, long nPixels, long& rIndex ); + + SAL_DLLPRIVATE bool ImplConvolute3( + const long* pMatrix, long nDivisor, + const BmpFilterParam* pFilterParam, + const Link* pProgress ); + + SAL_DLLPRIVATE bool ImplMedianFilter( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplSobelGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplEmbossGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplSolarize( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplSepia( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplMosaic( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE bool ImplPopArt( const BmpFilterParam* pFilterParam, const Link* pProgress ); + + SAL_DLLPRIVATE bool ImplSeparableBlurFilter( const double aRadius = 0.7 ); + SAL_DLLPRIVATE bool ImplSeparableUnsharpenFilter( const double aRadius = 0.7 ); + SAL_DLLPRIVATE bool ImplDuotoneFilter( const sal_uLong nColorOne, sal_uLong nColorTwo ); + SAL_DLLPRIVATE void ImplBlurContributions( + const int aSize, + const int aNumberOfContributions, + double* pBlurVector, + double*& pWeights, + int*& pPixels, + int*& pCount ); public: @@ -822,6 +858,13 @@ public: ScopedReadAccess; typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess > ScopedWriteAccess; + +private: + + ImpBitmap* mpImpBmp; + MapMode maPrefMapMode; + Size maPrefSize; + }; inline bool Bitmap::operator!() const diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index 5571ee41ca5f..dc875ff02c59 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -27,15 +27,12 @@ #include #include +#include namespace com { namespace sun { namespace star { namespace rendering { class XBitmapCanvas; } } } } - -// - TransparentType - - - enum TransparentType { TRANSPARENT_NONE, @@ -43,29 +40,10 @@ enum TransparentType TRANSPARENT_BITMAP }; - -// - BitmapEx - - - class VCL_DLLPUBLIC BitmapEx { -private: - friend class ImpGraphic; - friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm); - - Bitmap aBitmap; - Bitmap aMask; - Size aBitmapSize; - Color aTransparentColor; - TransparentType eTransparent; - bool bAlpha; - public: - - SAL_DLLPRIVATE ImpBitmap* ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); } - SAL_DLLPRIVATE ImpBitmap* ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); } - BitmapEx(); BitmapEx( const ResId& rResId ); BitmapEx( const BitmapEx& rBitmapEx ); @@ -115,9 +93,9 @@ public: const Color& GetTransparentColor() const { return aTransparentColor; } void SetTransparentColor( const Color& rColor ) { aTransparentColor = rColor; } - sal_uInt16 GetBitCount() const { return aBitmap.GetBitCount(); } - sal_uLong GetSizeBytes() const; - sal_uLong GetChecksum() const; + sal_uInt16 GetBitCount() const { return aBitmap.GetBitCount(); } + sal_uLong GetSizeBytes() const; + sal_uLong GetChecksum() const; public: @@ -140,8 +118,9 @@ public: @return true, if the color reduction operation was completed successfully. */ - bool ReduceColors( sal_uInt16 nNewColorCount, - BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + bool ReduceColors( + sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); /** Apply a dither algorithm to the bitmap @@ -188,9 +167,10 @@ public: not only returned when the operation failed, but also if nothing had to be done, e.g. because nDX and nDY were zero. */ - bool Expand( sal_uLong nDX, sal_uLong nDY, - const Color* pInitColor = NULL, - bool bExpandTransparent = false ); + bool Expand( + sal_uLong nDX, sal_uLong nDY, + const Color* pInitColor = NULL, + bool bExpandTransparent = false ); /** Copy a rectangular area from another bitmap @@ -214,9 +194,10 @@ public: nothing had to be done, e.g. because one of the rectangles are empty. */ - bool CopyPixel( const Rectangle& rRectDst, - const Rectangle& rRectSrc, - const BitmapEx* pBmpExSrc = NULL ); + bool CopyPixel( + const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const BitmapEx* pBmpExSrc = NULL ); /** Fill the entire bitmap with the given color @@ -253,7 +234,9 @@ public: @return true, if the operation was completed successfully. */ - bool Scale( const Size& rNewSize, sal_uInt32 nScaleFlag = BMP_SCALE_DEFAULT ); + bool Scale( + const Size& rNewSize, + sal_uInt32 nScaleFlag = BMP_SCALE_DEFAULT ); /** Scale the bitmap @@ -268,7 +251,10 @@ public: @return true, if the operation was completed successfully. */ - bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag = BMP_SCALE_DEFAULT ); + bool Scale( + const double& rScaleX, + const double& rScaleY, + sal_uInt32 nScaleFlag = BMP_SCALE_DEFAULT ); /** Rotate bitmap by the specified angle @@ -283,7 +269,9 @@ public: @return true, if the operation was completed successfully. */ - bool Rotate( long nAngle10, const Color& rFillColor ); + bool Rotate( + long nAngle10, + const Color& rFillColor ); /** Replace all pixel having the search color with the specified color @@ -300,7 +288,10 @@ public: @return true, if the operation was completed successfully. */ - bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol = 0 ); + bool Replace( + const Color& rSearchColor, + const Color& rReplaceColor, + sal_uLong nTol = 0 ); /** Replace all pixel having one the search colors with the corresponding replace color @@ -320,8 +311,11 @@ public: @return true, if the operation was completed successfully. */ - bool Replace( const Color* pSearchColors, const Color* pReplaceColors, - sal_uLong nColorCount, const sal_uLong* pTols = NULL ); + bool Replace( + const Color* pSearchColors, + const Color* pReplaceColors, + sal_uLong nColorCount, + const sal_uLong* pTols = NULL ); /** Change various global color characteristics @@ -353,14 +347,15 @@ public: @return true, if the operation was completed successfully. */ - bool Adjust( short nLuminancePercent = 0, - short nContrastPercent = 0, - short nChannelRPercent = 0, - short nChannelGPercent = 0, - short nChannelBPercent = 0, - double fGamma = 1.0, - bool bInvert = false, - bool msoBrightness = false ); + bool Adjust( + short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + bool bInvert = false, + bool msoBrightness = false ); /** Apply specified filter to the bitmap @@ -375,9 +370,10 @@ public: @return true, if the operation was completed successfully. */ - bool Filter( BmpFilter eFilter, - const BmpFilterParam* pFilterParam = NULL, - const Link* pProgress = NULL ); + bool Filter( + BmpFilter eFilter, + const BmpFilterParam* pFilterParam = NULL, + const Link* pProgress = NULL ); /** Get transparency at given position @@ -390,7 +386,9 @@ public: @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; + sal_uInt8 GetTransparency( + sal_Int32 nX, + sal_Int32 nY) const; /** Create transformed Bitmap @@ -407,11 +405,11 @@ public: @param bSmooth Defines if pixel interpolation is to be used to create the result */ - BitmapEx TransformBitmapEx( - double fWidth, - double fHeight, - const basegfx::B2DHomMatrix& rTransformation, - bool bSmooth = true) const; + BitmapEx TransformBitmapEx( + double fWidth, + double fHeight, + const basegfx::B2DHomMatrix& rTransformation, + bool bSmooth = true) const; /** Create transformed Bitmap @@ -434,27 +432,42 @@ public: @return The transformed bitmap */ - BitmapEx getTransformed( - const basegfx::B2DHomMatrix& rTransformation, - const basegfx::B2DRange& rVisibleRange, - double fMaximumArea = 500000.0, - bool bSmooth = true) const; + BitmapEx getTransformed( + const basegfx::B2DHomMatrix& rTransformation, + const basegfx::B2DRange& rVisibleRange, + double fMaximumArea = 500000.0, + bool bSmooth = true) const; /** Create ColorStack-modified version of this BitmapEx @param rBColorModifierStack A ColrModifierStack which defines how each pixel has to be modified */ - BitmapEx ModifyBitmapEx(const basegfx::BColorModifierStack& rBColorModifierStack) const; + BitmapEx ModifyBitmapEx( const basegfx::BColorModifierStack& rBColorModifierStack) const; + + static BitmapEx AutoScaleBitmap( BitmapEx & aBitmap, const long aStandardSize ); + /// populate from a canvas implementation + bool Create( + const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas, + const Size &rSize ); public: - static BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize); + SAL_DLLPRIVATE ImpBitmap* ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); } + SAL_DLLPRIVATE ImpBitmap* ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); } + + +private: + friend class ImpGraphic; + friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm); + + Bitmap aBitmap; + Bitmap aMask; + Size aBitmapSize; + Color aTransparentColor; + TransparentType eTransparent; + bool bAlpha; - /// populate from a canvas implementation - bool Create( const ::com::sun::star::uno::Reference< - ::com::sun::star::rendering::XBitmapCanvas > &xBitmapCanvas, - const Size &rSize ); }; @@ -498,8 +511,6 @@ BitmapEx VCL_DLLPUBLIC createBlendFrame( Color aColorBottomRight, Color aColorBottomLeft); - - #endif // INCLUDED_VCL_BITMAPEX_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmapfilter.hxx b/include/vcl/bitmapfilter.hxx index 37cdac1638d7..c23bd7feaa82 100644 --- a/include/vcl/bitmapfilter.hxx +++ b/include/vcl/bitmapfilter.hxx @@ -16,8 +16,9 @@ class VCL_DLLPUBLIC BitmapFilter { public: - BitmapFilter(); - virtual ~BitmapFilter(); + BitmapFilter(); + virtual ~BitmapFilter(); + virtual bool filter(Bitmap& rBitmap) = 0; }; diff --git a/include/vcl/bitmapscalesuper.hxx b/include/vcl/bitmapscalesuper.hxx index 3b59b9910ee1..e7fffead8469 100644 --- a/include/vcl/bitmapscalesuper.hxx +++ b/include/vcl/bitmapscalesuper.hxx @@ -24,13 +24,16 @@ class VCL_DLLPUBLIC BitmapScaleSuper : public BitmapFilter { - double mrScaleX; - double mrScaleY; - public: - BitmapScaleSuper(const double& rScaleX, const double& rScaleY); - virtual ~BitmapScaleSuper(); - virtual bool filter(Bitmap& rBitmap) SAL_OVERRIDE; + BitmapScaleSuper(const double& rScaleX, const double& rScaleY); + virtual ~BitmapScaleSuper(); + + virtual bool filter(Bitmap& rBitmap) SAL_OVERRIDE; + +private: + double mrScaleX; + double mrScaleY; + }; #endif // INCLUDED_VCL_BITMAPSCALESUPER_HXX diff --git a/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx index 359c16829031..252599b5f76c 100644 --- a/include/vcl/bmpacc.hxx +++ b/include/vcl/bmpacc.hxx @@ -67,50 +67,6 @@ class VCL_DLLPUBLIC BitmapReadAccess { friend class BitmapWriteAccess; -private: - - BitmapReadAccess() {} - BitmapReadAccess( const BitmapReadAccess& ) {} - BitmapReadAccess& operator=( const BitmapReadAccess& ) { return *this; } - -protected: - Bitmap maBitmap; - BitmapBuffer* mpBuffer; - Scanline* mpScanBuf; - ColorMask maColorMask; - FncGetPixel mFncGetPixel; - FncSetPixel mFncSetPixel; - bool mbModify; - - -SAL_DLLPRIVATE void ImplCreate( Bitmap& rBitmap ); -SAL_DLLPRIVATE void ImplDestroy(); -SAL_DLLPRIVATE bool ImplSetAccessPointers( sal_uLong nFormat ); - -public: - -SAL_DLLPRIVATE void ImplZeroInitUnusedBits(); -SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const { return mpBuffer; } - - DECL_FORMAT( _1BIT_MSB_PAL ) - DECL_FORMAT( _1BIT_LSB_PAL ) - DECL_FORMAT( _4BIT_MSN_PAL ) - DECL_FORMAT( _4BIT_LSN_PAL ) - DECL_FORMAT( _8BIT_PAL ) - DECL_FORMAT( _8BIT_TC_MASK ) - DECL_FORMAT( _16BIT_TC_MSB_MASK ) - DECL_FORMAT( _16BIT_TC_LSB_MASK ) - DECL_FORMAT( _24BIT_TC_BGR ) - DECL_FORMAT( _24BIT_TC_RGB ) - DECL_FORMAT( _24BIT_TC_MASK ) - DECL_FORMAT( _32BIT_TC_ABGR ) - DECL_FORMAT( _32BIT_TC_ARGB ) - DECL_FORMAT( _32BIT_TC_BGRA ) - DECL_FORMAT( _32BIT_TC_RGBA ) - DECL_FORMAT( _32BIT_TC_MASK ) -protected: - BitmapReadAccess( Bitmap& rBitmap, bool bModify ); - public: BitmapReadAccess( Bitmap& rBitmap ); virtual ~BitmapReadAccess(); @@ -125,10 +81,10 @@ public: inline bool IsTopDown() const; inline bool IsBottomUp() const; - inline sal_uLong GetScanlineFormat() const; - inline sal_uLong GetScanlineSize() const; + inline sal_uLong GetScanlineFormat() const; + inline sal_uLong GetScanlineSize() const; - inline sal_uInt16 GetBitCount() const; + inline sal_uInt16 GetBitCount() const; inline BitmapColor GetBestMatchingColor( const BitmapColor& rBitmapColor ); inline Scanline GetBuffer() const; @@ -136,10 +92,10 @@ public: inline bool HasPalette() const; inline const BitmapPalette& GetPalette() const; - inline sal_uInt16 GetPaletteEntryCount() const; + inline sal_uInt16 GetPaletteEntryCount() const; inline const BitmapColor& GetPaletteColor( sal_uInt16 nColor ) const; inline const BitmapColor& GetBestPaletteColor( const BitmapColor& rBitmapColor ) const; - sal_uInt16 GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const; + sal_uInt16 GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const; inline bool HasColorMask() const; inline ColorMask& GetColorMask() const; @@ -152,11 +108,58 @@ public: inline sal_uInt8 GetLuminance( long nY, long nX ) const; /** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */ - BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; + BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; /** Get the color at coordinates fY, fX; if outside, return rFallback. Automatically does the correct inside/outside checks, e.g. static_cast< sal_uInt32 >(-0.25) *is* 0, not -1 and has to be outside */ - BitmapColor GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; + BitmapColor GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; + +private: + + BitmapReadAccess() {} + BitmapReadAccess( const BitmapReadAccess& ) {} + BitmapReadAccess& operator=( const BitmapReadAccess& ) { return *this; } + +protected: + Bitmap maBitmap; + BitmapBuffer* mpBuffer; + Scanline* mpScanBuf; + ColorMask maColorMask; + FncGetPixel mFncGetPixel; + FncSetPixel mFncSetPixel; + bool mbModify; + + + SAL_DLLPRIVATE void ImplCreate( Bitmap& rBitmap ); + SAL_DLLPRIVATE void ImplDestroy(); + SAL_DLLPRIVATE bool ImplSetAccessPointers( sal_uLong nFormat ); + +public: + + SAL_DLLPRIVATE void ImplZeroInitUnusedBits(); + SAL_DLLPRIVATE BitmapBuffer* + ImplGetBitmapBuffer() const { return mpBuffer; } + + DECL_FORMAT( _1BIT_MSB_PAL ) + DECL_FORMAT( _1BIT_LSB_PAL ) + DECL_FORMAT( _4BIT_MSN_PAL ) + DECL_FORMAT( _4BIT_LSN_PAL ) + DECL_FORMAT( _8BIT_PAL ) + DECL_FORMAT( _8BIT_TC_MASK ) + DECL_FORMAT( _16BIT_TC_MSB_MASK ) + DECL_FORMAT( _16BIT_TC_LSB_MASK ) + DECL_FORMAT( _24BIT_TC_BGR ) + DECL_FORMAT( _24BIT_TC_RGB ) + DECL_FORMAT( _24BIT_TC_MASK ) + DECL_FORMAT( _32BIT_TC_ABGR ) + DECL_FORMAT( _32BIT_TC_ARGB ) + DECL_FORMAT( _32BIT_TC_BGRA ) + DECL_FORMAT( _32BIT_TC_RGBA ) + DECL_FORMAT( _32BIT_TC_MASK ) + +protected: + BitmapReadAccess( Bitmap& rBitmap, bool bModify ); + }; // - BitmapWriteAccess - diff --git a/include/vcl/btndlg.hxx b/include/vcl/btndlg.hxx index 958b0f394be9..81df3d1e9090 100644 --- a/include/vcl/btndlg.hxx +++ b/include/vcl/btndlg.hxx @@ -37,32 +37,9 @@ class PushButton; class VCL_DLLPUBLIC ButtonDialog : public Dialog { -private: - boost::ptr_vector maItemList; - Size maPageSize; - Size maCtrlSize; - long mnButtonSize; - sal_uInt16 mnCurButtonId; - sal_uInt16 mnFocusButtonId; - bool mbFormat; - Link maClickHdl; - - SAL_DLLPRIVATE void ImplInitButtonDialogData(); - SAL_DLLPRIVATE PushButton* ImplCreatePushButton( sal_uInt16 nBtnFlags ); - SAL_DLLPRIVATE ImplBtnDlgItem* ImplGetItem( sal_uInt16 nId ) const; - DECL_DLLPRIVATE_LINK( ImplClickHdl, PushButton* pBtn ); - SAL_DLLPRIVATE void ImplPosControls(); - - // Copy assignment is forbidden and not implemented. - SAL_DLLPRIVATE ButtonDialog( const ButtonDialog & ); - SAL_DLLPRIVATE ButtonDialog& operator=( const ButtonDialog& ); -protected: - ButtonDialog( WindowType nType ); - SAL_DLLPRIVATE long ImplGetButtonSize(); - public: ButtonDialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG ); - virtual ~ButtonDialog(); + virtual ~ButtonDialog(); virtual void Resize() SAL_OVERRIDE; virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; @@ -72,11 +49,12 @@ public: void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; } const Size& GetPageSizePixel() const { return maPageSize; } - sal_uInt16 GetCurButtonId() const { return mnCurButtonId; } + sal_uInt16 GetCurButtonId() const { return mnCurButtonId; } void AddButton( const OUString& rText, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 ); void AddButton( StandardButtonType eType, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 ); void RemoveButton( sal_uInt16 nId ); + void Clear(); sal_uInt16 GetButtonId( sal_uInt16 nButton ) const; PushButton* GetPushButton( sal_uInt16 nId ) const; @@ -84,10 +62,36 @@ public: void SetButtonHelpText( sal_uInt16 nId, const OUString& rText ); void SetFocusButton( sal_uInt16 nId = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; } - sal_uInt16 GetFocusButton() const { return mnFocusButtonId; } + sal_uInt16 GetFocusButton() const { return mnFocusButtonId; } void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } const Link& GetClickHdl() const { return maClickHdl; } + +protected: + ButtonDialog( WindowType nType ); + SAL_DLLPRIVATE long ImplGetButtonSize(); + +private: + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ButtonDialog( const ButtonDialog & ); + SAL_DLLPRIVATE ButtonDialog& operator=( const ButtonDialog& ); + +private: + boost::ptr_vector maItemList; + Size maPageSize; + Size maCtrlSize; + long mnButtonSize; + sal_uInt16 mnCurButtonId; + sal_uInt16 mnFocusButtonId; + bool mbFormat; + Link maClickHdl; + + SAL_DLLPRIVATE void ImplInitButtonDialogData(); + SAL_DLLPRIVATE PushButton* ImplCreatePushButton( sal_uInt16 nBtnFlags ); + SAL_DLLPRIVATE ImplBtnDlgItem* ImplGetItem( sal_uInt16 nId ) const; + DECL_DLLPRIVATE_LINK( ImplClickHdl, PushButton* pBtn ); + SAL_DLLPRIVATE void ImplPosControls(); + }; #endif // INCLUDED_VCL_BTNDLG_HXX diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx index 4e62f41f95fc..c314134ea787 100644 --- a/include/vcl/builder.hxx +++ b/include/vcl/builder.hxx @@ -45,19 +45,89 @@ class VCL_DLLPUBLIC VclBuilder: private boost::noncopyable public: typedef std::map stringmap; typedef vcl::Window* (*customMakeWidget)(vcl::Window *pParent, stringmap &rVec); + +public: + VclBuilder( + vcl::Window *pParent, + const OUString& sUIRootDir, + const OUString& sUIFile, + const OString& sID = OString(), + const css::uno::Reference &rFrame = css::uno::Reference()); + ~VclBuilder(); + + //sID must exist and be of type T + template T* get(T*& ret, const OString& sID); + + //sID may not exist, but must be of type T if it does + template T* get(const OString& sID); + + vcl::Window* get_widget_root(); + + PopupMenu* get_menu(PopupMenu*& ret, const OString& sID); + + //sID may not exist + PopupMenu* get_menu(const OString& sID); + + //given an sID return the response value for that widget + short get_response(const vcl::Window *pWindow) const; + + OString get_by_window(const vcl::Window *pWindow) const; + void delete_by_window(const vcl::Window *pWindow); + + //release ownership of pWindow, i.e. don't delete it + void drop_ownership(const vcl::Window *pWindow); + + //apply the properties of rProps to pWindow + static void set_properties(vcl::Window *pWindow, const stringmap &rProps); + + //Convert _ gtk markup to ~ vcl markup + static OString convertMnemonicMarkup(const OString &rIn); + + static OString extractCustomProperty(stringmap &rMap); + static FieldUnit detectUnit(OString const&); + + static bool extractDropdown(stringmap &rMap); + + //add a default value of 25 width-chars to a map if width-chars not set + static void ensureDefaultWidthChars(VclBuilder::stringmap &rMap); + + //see m_aDeferredProperties, you need this for toplevel dialogs + //which build themselves from their ctor. The properties on + //the top level are stored in m_aDeferredProperties and need + //to be applied post ctor + void setDeferredProperties(); + + //Helpers to retrofit all the existing code to the builder + static void reorderWithinParent(std::vector< vcl::Window*>& rChilds, bool bIsButtonBox); + static void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition); + + /// Get label of the command (like of .uno:Save) from the description service + static OUString getCommandLabel(const OUString& rCommand, const css::uno::Reference& rContext, const OUString& rModuleId); + + /// Get image of the command (like of .uno:Save) from the description service + static Image getCommandImage( + const OUString& rCommand, + bool bLarge, + const css::uno::Reference& rContext, + const css::uno::Reference& rFrame, + const OUString& rModuleId ); + + css::uno::Reference getFrame() { return m_xFrame; } + private: typedef boost::ptr_map ModuleMap; + //We store these until the builder is deleted, that way we can use the //ui-previewer on custom widgets and guarantee the modules they are from //exist for the duration of the dialog - ModuleMap m_aModuleMap; + ModuleMap m_aModuleMap; //If the toplevel window has any properties which need to be set on it, //but the toplevel is the owner of the builder, then its ctor //has not been completed during the building, so properties for it //are collected here and need to be set afterwards, e.g. during //Show or Execute - stringmap m_aDeferredProperties; + stringmap m_aDeferredProperties; struct PackingData { @@ -147,19 +217,23 @@ private: typedef std::vector row; std::vector m_aEntries; }; + const ListStore* get_model_by_name(const OString& sID) const; - static void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); + static void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); typedef stringmap TextBuffer; - const TextBuffer* get_buffer_by_name(const OString& sID) const; - static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer); + const TextBuffer* + get_buffer_by_name(const OString& sID) const; + + static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer); typedef stringmap Adjustment; - const Adjustment *get_adjustment_by_name(const OString& sID) const; - static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment); - static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment); - static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment); - static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment); + const Adjustment* get_adjustment_by_name(const OString& sID) const; + + static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment); typedef std::map WidgetTranslations; typedef std::map Translations; @@ -226,175 +300,133 @@ private: {} }; - void loadTranslations(const LanguageTag &rLanguageTag, const OUString &rUri); - OString getTranslation(const OString &rId, const OString &rProperty) const; + void loadTranslations(const LanguageTag &rLanguageTag, const OUString &rUri); + OString getTranslation(const OString &rId, const OString &rProperty) const; - OString m_sID; - OString m_sHelpRoot; + OString m_sID; + OString m_sHelpRoot; ResHookProc m_pStringReplace; vcl::Window *m_pParent; - bool m_bToplevelHasDeferredInit; - bool m_bToplevelHasDeferredProperties; - bool m_bToplevelParentFound; + bool m_bToplevelHasDeferredInit; + bool m_bToplevelHasDeferredProperties; + bool m_bToplevelParentFound; ParserState *m_pParserState; vcl::Window *get_by_name(const OString& sID); - void delete_by_name(const OString& sID); + void delete_by_name(const OString& sID); class sortIntoBestTabTraversalOrder : public std::binary_function { - VclBuilder *m_pBuilder; public: - sortIntoBestTabTraversalOrder(VclBuilder *pBuilder) - : m_pBuilder(pBuilder) - { - } - bool operator()(const vcl::Window *pA, const vcl::Window *pB) const; + sortIntoBestTabTraversalOrder(VclBuilder *pBuilder) + : m_pBuilder(pBuilder) {} + + bool operator()(const vcl::Window *pA, const vcl::Window *pB) const; + + private: + VclBuilder *m_pBuilder; }; /// XFrame to be able to extract labels and other properties of the UNO commands (like of .uno:Bold). css::uno::Reference m_xFrame; -public: - VclBuilder(vcl::Window *pParent, const OUString& sUIRootDir, const OUString& sUIFile, - const OString& sID = OString(), - const css::uno::Reference &rFrame = css::uno::Reference()); - ~VclBuilder(); - vcl::Window *get_widget_root(); - //sID must exist and be of type T - template T* get(T*& ret, const OString& sID) - { - vcl::Window *w = get_by_name(sID); - SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID.getStr() << "\" not found in .ui"); - SAL_WARN_IF(!dynamic_cast(w), - "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); - assert(w && dynamic_cast(w)); - ret = static_cast(w); - return ret; - } - PopupMenu* get_menu(PopupMenu*& ret, const OString& sID) - { - ret = get_menu(sID); - SAL_WARN_IF(!ret, "vcl.layout", "menu \"" << sID.getStr() << "\" not found in .ui"); - assert(ret); - return ret; - } - //sID may not exist, but must be of type T if it does - template T* get(const OString& sID) - { - vcl::Window *w = get_by_name(sID); - SAL_WARN_IF(w && !dynamic_cast(w), - "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); - assert(!w || dynamic_cast(w)); - return static_cast(w); - } - //sID may not exist - PopupMenu* get_menu(const OString& sID); - - //given an sID return the response value for that widget - short get_response(const vcl::Window *pWindow) const; - - OString get_by_window(const vcl::Window *pWindow) const; - void delete_by_window(const vcl::Window *pWindow); - - //release ownership of pWindow, i.e. don't delete it - void drop_ownership(const vcl::Window *pWindow); - - //apply the properties of rProps to pWindow - static void set_properties(vcl::Window *pWindow, const stringmap &rProps); - - //Convert _ gtk markup to ~ vcl markup - static OString convertMnemonicMarkup(const OString &rIn); - - static OString extractCustomProperty(stringmap &rMap); - static FieldUnit detectUnit(OString const&); - - static bool extractDropdown(stringmap &rMap); - - //add a default value of 25 width-chars to a map if width-chars not set - static void ensureDefaultWidthChars(VclBuilder::stringmap &rMap); - - //see m_aDeferredProperties, you need this for toplevel dialogs - //which build themselves from their ctor. The properties on - //the top level are stored in m_aDeferredProperties and need - //to be applied post ctor - void setDeferredProperties(); - - //Helpers to retrofit all the existing code to the builder - static void reorderWithinParent(std::vector< vcl::Window*>& rChilds, bool bIsButtonBox); - static void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition); - - /// Get label of the command (like of .uno:Save) from the description service - static OUString getCommandLabel(const OUString& rCommand, const css::uno::Reference& rContext, const OUString& rModuleId); - - /// Get image of the command (like of .uno:Save) from the description service - static Image getCommandImage(const OUString& rCommand, bool bLarge, - const css::uno::Reference& rContext, const css::uno::Reference& rFrame, - const OUString& rModuleId); - - css::uno::Reference getFrame() { return m_xFrame; } private: vcl::Window *insertObject(vcl::Window *pParent, - const OString &rClass, const OString &rID, - stringmap &rProps, stringmap &rPangoAttributes, - stringmap &rAtkProps, std::vector &rItems); + const OString &rClass, const OString &rID, + stringmap &rProps, stringmap &rPangoAttributes, + stringmap &rAtkProps, std::vector &rItems); vcl::Window *makeObject(vcl::Window *pParent, - const OString &rClass, const OString &rID, - stringmap &rVec, const std::vector &rItems); + const OString &rClass, const OString &rID, + stringmap &rVec, const std::vector &rItems); - void connectNumericFormatterAdjustment(const OString &id, const OString &rAdjustment); - void connectTimeFormatterAdjustment(const OString &id, const OString &rAdjustment); - void connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment); + void connectNumericFormatterAdjustment(const OString &id, const OString &rAdjustment); + void connectTimeFormatterAdjustment(const OString &id, const OString &rAdjustment); + void connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment); - bool extractGroup(const OString &id, stringmap &rVec); - bool extractModel(const OString &id, stringmap &rVec); - bool extractBuffer(const OString &id, stringmap &rVec); - bool extractScrollAdjustment(const OString &id, stringmap &rVec); - bool extractButtonImage(const OString &id, stringmap &rMap, bool bRadio); - bool extractStock(const OString &id, stringmap &rMap); - void extractMnemonicWidget(const OString &id, stringmap &rMap); + bool extractGroup(const OString &id, stringmap &rVec); + bool extractModel(const OString &id, stringmap &rVec); + bool extractBuffer(const OString &id, stringmap &rVec); + bool extractScrollAdjustment(const OString &id, stringmap &rVec); + bool extractButtonImage(const OString &id, stringmap &rMap, bool bRadio); + bool extractStock(const OString &id, stringmap &rMap); + void extractMnemonicWidget(const OString &id, stringmap &rMap); - void handleTranslations(xmlreader::XmlReader &reader); + void handleTranslations(xmlreader::XmlReader &reader); - void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader); + void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader); vcl::Window* handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader); - void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); - void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); - void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec); - void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap); - void collectAtkAttribute(xmlreader::XmlReader &reader, stringmap &rMap); - void collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMap); - - void insertMenuObject(PopupMenu *pParent, const OString &rClass, const OString &rID, - stringmap &rProps, stringmap &rAccels); - void handleMenuChild(PopupMenu *pParent, xmlreader::XmlReader &reader); - void handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &reader); - - void handleListStore(xmlreader::XmlReader &reader, const OString &rID); - void handleRow(xmlreader::XmlReader &reader, const OString &rID, sal_Int32 nRowIndex); - void handleAdjustment(const OString &rID, stringmap &rProperties); - void handleTextBuffer(const OString &rID, stringmap &rProperties); - void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); - void handleMenu(xmlreader::XmlReader &reader, const OString &rID); + void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); + void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); + void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec); + void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + void collectAtkAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + void collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMap); + + void insertMenuObject( + PopupMenu *pParent, + const OString &rClass, + const OString &rID, + stringmap &rProps, + stringmap &rAccels); + + void handleMenuChild(PopupMenu *pParent, xmlreader::XmlReader &reader); + void handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &reader); + + void handleListStore(xmlreader::XmlReader &reader, const OString &rID); + void handleRow(xmlreader::XmlReader &reader, const OString &rID, sal_Int32 nRowIndex); + void handleAdjustment(const OString &rID, stringmap &rProperties); + void handleTextBuffer(const OString &rID, stringmap &rProperties); + void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); + void handleMenu(xmlreader::XmlReader &reader, const OString &rID); std::vector handleItems(xmlreader::XmlReader &reader, const OString &rID); - void handleSizeGroup(xmlreader::XmlReader &reader, const OString &rID); + void handleSizeGroup(xmlreader::XmlReader &reader, const OString &rID); - void handleAtkObject(xmlreader::XmlReader &reader, const OString &rID, vcl::Window *pWindow); + void handleAtkObject(xmlreader::XmlReader &reader, const OString &rID, vcl::Window *pWindow); - void handleActionWidget(xmlreader::XmlReader &reader); + void handleActionWidget(xmlreader::XmlReader &reader); PackingData get_window_packing_data(const vcl::Window *pWindow) const; - void set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition); + void set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition); vcl::Window* prepareWidgetOwnScrolling(vcl::Window *pParent, WinBits &rWinStyle); - void cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap); + void cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap); - void set_response(const OString& sID, short nResponse); + void set_response(const OString& sID, short nResponse); }; +template +inline T* VclBuilder::get(T*& ret, const OString& sID) +{ + vcl::Window *w = get_by_name(sID); + SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID.getStr() << "\" not found in .ui"); + SAL_WARN_IF(!dynamic_cast(w), + "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(w && dynamic_cast(w)); + ret = static_cast(w); + return ret; +} + +//sID may not exist, but must be of type T if it does +template +inline T* VclBuilder::get(const OString& sID) +{ + vcl::Window *w = get_by_name(sID); + SAL_WARN_IF(w && !dynamic_cast(w), + "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(!w || dynamic_cast(w)); + return static_cast(w); +} + +inline PopupMenu* VclBuilder::get_menu(PopupMenu*& ret, const OString& sID) +{ + ret = get_menu(sID); + SAL_WARN_IF(!ret, "vcl.layout", "menu \"" << sID.getStr() << "\" not found in .ui"); + assert(ret); + return ret; +} //helper baseclass to ease retro fitting dialogs/tabpages that load a resource //to load a .ui file instead @@ -409,14 +441,15 @@ private: class VCL_DLLPUBLIC VclBuilderContainer { -protected: - VclBuilder *m_pUIBuilder; public: - VclBuilderContainer(); - virtual ~VclBuilderContainer(); + VclBuilderContainer(); + virtual ~VclBuilderContainer(); + static OUString getUIRootDir(); - bool hasBuilder() const { return m_pUIBuilder != NULL; } + bool hasBuilder() const { return m_pUIBuilder != NULL; } + css::uno::Reference getFrame() { return m_pUIBuilder->getFrame(); } + template T* get(T*& ret, const OString& sID) { return m_pUIBuilder->get(ret, sID); @@ -439,6 +472,9 @@ public: return; m_pUIBuilder->setDeferredProperties(); } + +protected: + VclBuilder *m_pUIBuilder; }; /* diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx index 13fd5066e7a1..614312e805a9 100644 --- a/include/vcl/button.hxx +++ b/include/vcl/button.hxx @@ -34,10 +34,6 @@ class UserDrawEvent; class ImplCommonButtonData; - -// - Button - - - class VCL_DLLPUBLIC Button : public Control { private: -- cgit