diff options
Diffstat (limited to 'vcl/inc/vcl')
200 files changed, 42969 insertions, 0 deletions
diff --git a/vcl/inc/vcl/ImageListProvider.hxx b/vcl/inc/vcl/ImageListProvider.hxx new file mode 100644 index 000000000000..7fc678b485fd --- /dev/null +++ b/vcl/inc/vcl/ImageListProvider.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMAGELISTPROVIDER_HXX +#define _SV_IMAGELISTPROVIDER_HXX + +#include <sal/types.h> + +namespace com { namespace sun { namespace star { namespace lang { class IllegalArgumentException; }}}} + +class ImageList; + + +namespace vcl +{ + enum ImageListType + { + IMAGELISTTYPE_UNKNOWN = 0, + HIGHCONTRAST_NO = 1, + HIGHCONTRAST_YES = 2 + }; + + /* abstract */ class IImageListProvider + { + public: + virtual ImageList getImageList(ImageListType) SAL_THROW (( com::sun::star::lang::IllegalArgumentException )) = 0; + }; +} /* vcl */ + +#endif /* _SV_IMAGELISTPROVIDER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/abstdlg.hxx b/vcl/inc/vcl/abstdlg.hxx new file mode 100644 index 000000000000..012981fba7cf --- /dev/null +++ b/vcl/inc/vcl/abstdlg.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _VCL_ABSTDLG_HXX +#define _VCL_ABSTDLG_HXX + +// include --------------------------------------------------------------- + +#include <tools/solar.h> +#include <tools/string.hxx> +#include <vcl/dllapi.h> + +class Window; +class ResId; +class Link; + +class VCL_DLLPUBLIC VclAbstractDialog +{ +public: + virtual short Execute() = 0; + //virtual void Show( sal_Bool bVisible = sal_True, sal_uInt16 nFlags = 0 ) = 0; + virtual ~VclAbstractDialog(); +}; + +class VCL_DLLPUBLIC VclAbstractDialog2 +{ +public: + virtual void StartExecuteModal( const Link& rEndDialogHdl ) = 0; + virtual long GetResult() = 0; + virtual ~VclAbstractDialog2(); +}; + +class VCL_DLLPUBLIC VclAbstractTerminatedDialog : public VclAbstractDialog +{ +public: + virtual void EndDialog(long nResult =0) = 0; +}; + +class VCL_DLLPUBLIC VclAbstractRefreshableDialog : public VclAbstractDialog +{ +public: + virtual void Update() = 0; + virtual void Sync() = 0; +}; + +class VCL_DLLPUBLIC AbstractPasswordToOpenModifyDialog : public VclAbstractDialog +{ +public: + virtual String GetPasswordToOpen() const = 0; + virtual String GetPasswordToModify() const = 0; + virtual bool IsRecommendToOpenReadonly() const = 0; +}; + +//------------------------------------------------------------- + +class VCL_DLLPUBLIC VclAbstractDialogFactory +{ +public: + 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( Window* pParent, sal_uInt32 nResId ) = 0; + + // creates instance of PasswordToOpenModifyDialog from cui + virtual AbstractPasswordToOpenModifyDialog * CreatePasswordToOpenModifyDialog( Window * pParent, sal_uInt16 nMinPasswdLen, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify ) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/accel.h b/vcl/inc/vcl/accel.h new file mode 100644 index 000000000000..bf3006c9ca7b --- /dev/null +++ b/vcl/inc/vcl/accel.h @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ACCEL_H +#define _SV_ACCEL_H + +#include <vcl/sv.h> +#ifndef _SV_KEYCOD_HXX +#include <vcl/keycod.hxx> +#endif + +class Accelerator; + +// ------------------ +// - ImplAccelEntry - +// ------------------ + +class ImplAccelEntry +{ +public: + sal_uInt16 mnId; + KeyCode maKeyCode; + Accelerator* mpAccel; + Accelerator* mpAutoAccel; + sal_Bool mbEnabled; +}; + +// ----------------- +// - Hilfemethoden - +// ----------------- + +// in KEYCOD.CXX +void ImplGetKeyCode( KeyFuncType eFunc, sal_uInt16& rCode1, sal_uInt16& rCode2, sal_uInt16& rCode3, sal_uInt16& rCode4 ); + +#endif // _SV_ACCEL_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/accel.hxx b/vcl/inc/vcl/accel.hxx new file mode 100644 index 000000000000..a7bf623cb20a --- /dev/null +++ b/vcl/inc/vcl/accel.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ACCEL_HXX +#define _SV_ACCEL_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/resid.hxx> +#include <tools/rc.hxx> +#include <vcl/keycod.hxx> + +class ImplAccelData; +class ImplAccelEntry; + +// --------------- +// - Accelerator - +// --------------- + +class VCL_DLLPUBLIC Accelerator : public Resource +{ + friend class ImplAccelManager; + +private: + ImplAccelData* mpData; + XubString maHelpStr; + Link maActivateHdl; + Link maDeactivateHdl; + Link maSelectHdl; + + // Werden vom AcceleratorManager gesetzt + KeyCode maCurKeyCode; + sal_uInt16 mnCurId; + sal_uInt16 mnCurRepeat; + sal_Bool mbIsCancel; + sal_Bool* mpDel; + + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData ); + SAL_DLLPRIVATE void ImplDeleteData(); + SAL_DLLPRIVATE void ImplInsertAccel( sal_uInt16 nItemId, const KeyCode& rKeyCode, + sal_Bool bEnable, Accelerator* pAutoAccel ); + + SAL_DLLPRIVATE ImplAccelEntry* ImplGetAccelData( const KeyCode& rKeyCode ) const; + +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + Accelerator(); + Accelerator( const Accelerator& rAccel ); + Accelerator( const ResId& rResId ); + virtual ~Accelerator(); + + virtual void Activate(); + virtual void Deactivate(); + virtual void Select(); + + void InsertItem( sal_uInt16 nItemId, const KeyCode& rKeyCode ); + void InsertItem( const ResId& rResId ); + void RemoveItem( sal_uInt16 nItemId ); + void RemoveItem( const KeyCode rKeyCode ); + void Clear(); + + sal_uInt16 GetCurItemId() const { return mnCurId; } + const KeyCode& GetCurKeyCode() const { return maCurKeyCode; } + sal_uInt16 GetCurRepeat() const { return mnCurRepeat; } + sal_Bool IsCancel() const { return mbIsCancel; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + KeyCode GetItemKeyCode( sal_uInt16 nPos ) const; + sal_uInt16 GetItemId( const KeyCode& rKeyCode ) const; + KeyCode GetKeyCode( sal_uInt16 nItemId ) const; + sal_Bool IsIdValid( sal_uInt16 nItemId ) const; + sal_Bool IsKeyCodeValid( const KeyCode rKeyCode ) const; + sal_Bool Call( const KeyCode& rKeyCode, sal_uInt16 nRepeat = 0 ); + + void SetAccel( sal_uInt16 nItemId, Accelerator* pAccel ); + Accelerator* GetAccel( sal_uInt16 nItemId ) const; + void SetAccel( const KeyCode rKeyCode, Accelerator* pAccel ); + Accelerator* GetAccel( const KeyCode rKeyCode ) const; + + void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True ); + sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const; + void EnableItem( const KeyCode rKeyCode, sal_Bool bEnable = sal_True ); + sal_Bool IsItemEnabled( const KeyCode rKeyCode ) const; + + void SetHelpText( const XubString& rHelpText ) { maHelpStr = rHelpText; } + const XubString& 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; } + + Accelerator& operator=( const Accelerator& rAccel ); +}; + +#endif // _SV_ACCEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/accmgr.hxx b/vcl/inc/vcl/accmgr.hxx new file mode 100644 index 000000000000..2ffa2b366920 --- /dev/null +++ b/vcl/inc/vcl/accmgr.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ACCMGR_HXX +#define _SV_ACCMGR_HXX + +#include <vcl/sv.h> +#include <vector> + +class Accelerator; +class KeyCode; + +typedef ::std::vector< Accelerator* > ImplAccelList; + +// -------------------- +// - ImplAccelManager - +// -------------------- + +class ImplAccelManager +{ +private: + ImplAccelList* mpAccelList; + ImplAccelList* mpSequenceList; + +public: + ImplAccelManager() + { + mpAccelList = NULL; + mpSequenceList = NULL; + } + ~ImplAccelManager(); + + sal_Bool InsertAccel( Accelerator* pAccel ); + void RemoveAccel( Accelerator* pAccel ); + + void EndSequence( sal_Bool bCancel = sal_False ); + void FlushAccel() { EndSequence( sal_True ); } + + sal_Bool IsAccelKey( const KeyCode& rKeyCode, sal_uInt16 nRepeat ); +}; + +#endif // _SV_ACCMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/alpha.hxx b/vcl/inc/vcl/alpha.hxx new file mode 100644 index 000000000000..8bcaf3789528 --- /dev/null +++ b/vcl/inc/vcl/alpha.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ALPHA_HXX +#define _SV_ALPHA_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> + +// ------------- +// - AlphaMask - +// ------------- + +class ImageList; +class BitmapEx; + +class VCL_DLLPUBLIC AlphaMask : private Bitmap +{ + friend class BitmapEx; + friend class OutputDevice; + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream&, const ImageList& ); + +private: + + 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 ); + ~AlphaMask(); + + AlphaMask& operator=( const Bitmap& rBitmap ); + AlphaMask& operator=( const AlphaMask& rAlphaMask ) { return (AlphaMask&) Bitmap::operator=( rAlphaMask ); } + sal_Bool operator!() const { return Bitmap::operator!(); } + sal_Bool operator==( const AlphaMask& rAlphaMask ) const { return Bitmap::operator==( rAlphaMask ); } + sal_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(); } + void SetSizePixel( const Size& rNewSize ) { Bitmap::SetSizePixel( rNewSize ); } + + sal_uLong GetSizeBytes() const { return Bitmap::GetSizeBytes(); } + sal_uLong GetChecksum() const { return Bitmap::GetChecksum(); } + + Bitmap GetBitmap() const; + +public: + + sal_Bool Crop( const Rectangle& rRectPixel ); + sal_Bool Expand( sal_uLong nDX, sal_uLong nDY, sal_uInt8* pInitTransparency = NULL ); + sal_Bool CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, const AlphaMask* pAlphaSrc = NULL ); + sal_Bool Erase( sal_uInt8 cTransparency ); + sal_Bool Invert(); + sal_Bool Mirror( sal_uLong nMirrorFlags ); + sal_Bool Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_FAST ); + sal_Bool Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_FAST ); + sal_Bool Rotate( long nAngle10, sal_uInt8 cFillTransparency ); + sal_Bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); + sal_Bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, sal_uLong nTol = 0UL ); + sal_Bool Replace( sal_uInt8* pSearchTransparencies, sal_uInt8* pReplaceTransparencies, + sal_uLong nColorCount, sal_uLong* pTols = NULL ); + +public: + + BitmapReadAccess* AcquireReadAccess() { return Bitmap::AcquireReadAccess(); } + BitmapWriteAccess* AcquireWriteAccess() { return Bitmap::AcquireWriteAccess(); } + void ReleaseAccess( BitmapReadAccess* pAccess ); + +public: + + sal_Bool Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True ) { return Bitmap::Read( rIStm, bFileHeader ); } + sal_Bool Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const { return Bitmap::Write( rOStm, bCompressed, bFileHeader ); } + + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx ); + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx ); +}; + +#endif // _SV_ALPHA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/animate.hxx b/vcl/inc/vcl/animate.hxx new file mode 100644 index 000000000000..e53a51e0e932 --- /dev/null +++ b/vcl/inc/vcl/animate.hxx @@ -0,0 +1,255 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ANIMATE_HXX +#define _SV_ANIMATE_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/bitmapex.hxx> + +// ----------- +// - Defines - +// ----------- + +#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L + +// --------- +// - Enums - +// --------- + +enum Disposal +{ + DISPOSE_NOT, + DISPOSE_BACK, + DISPOSE_FULL, + DISPOSE_PREVIOUS +}; + +enum CycleMode +{ + CYCLE_NOT, + CYCLE_NORMAL, + CYCLE_FALLBACK, + CYCLE_REVERS, + CYCLE_REVERS_FALLBACK +}; + +// ------------------- +// - AnimationBitmap - +// ------------------- + +struct VCL_DLLPUBLIC AnimationBitmap +{ + BitmapEx aBmpEx; + Point aPosPix; + Size aSizePix; + long nWait; + Disposal eDisposal; + sal_Bool bUserInput; + + AnimationBitmap() {} + 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 ( sal_False ) {} + + sal_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 ); + } + + sal_Bool operator!=( const AnimationBitmap& rAnimBmp ) const { return !( *this == rAnimBmp ); } + + sal_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; +}; + +// ------------------- +// - AnimationBitmap - +// ------------------- + +struct AInfo +{ + Bitmap aLastSaveBitmap; + Bitmap aBackBitmap; + Rectangle aClipRect; + Size aLastSaveSize; + Point aLastSavePoint; + Point aStartOrg; + Size aStartSize; + OutputDevice* pOutDev; + void* pViewData; + long nExtraData; + sal_Bool bWithSize; + sal_Bool bPause; + + AInfo() : pOutDev( NULL ), + pViewData( NULL ), + nExtraData( 0L ), + bWithSize( sal_False ), + bPause( sal_False ) {} +}; + +// ------------------- +// - AnimationBitmap - +// ------------------- + +class VCL_DLLPUBLIC Animation +{ + SAL_DLLPRIVATE static sal_uLong mnAnimCount; + + List maList; + List maAInfoList; + Link maNotifyLink; + BitmapEx maBitmapEx; + Timer maTimer; + Size maGlobalSize; + List* mpViewList; + void* mpExtraData; + long mnLoopCount; + long mnLoops; + long mnPos; + Disposal meLastDisposal; + CycleMode meCycleMode; + sal_Bool mbFirst; + sal_Bool mbIsInAnimation; + sal_Bool mbWithSize; + sal_Bool mbLoopTerminated; + sal_Bool mbIsWaiting; + + + SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); + DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer* ); + +public: + + SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; } + SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; } + SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnPos; } + + +public: + Animation(); + Animation( const Animation& rAnimation ); + ~Animation(); + + Animation& operator=( const Animation& rAnimation ); + sal_Bool operator==( const Animation& rAnimation ) const; + sal_Bool operator!=( const Animation& rAnimation ) const { return !(*this==rAnimation); } + + sal_Bool IsEqual( const Animation& rAnimation ) const; + + sal_Bool IsEmpty() const; + void SetEmpty(); + + void Clear(); + + sal_Bool Start( OutputDevice* pOutDev, const Point& rDestPt, long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = NULL ); + sal_Bool Start( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz, long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = NULL ); + void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 ); + + void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; + + sal_Bool IsInAnimation() const { return mbIsInAnimation; } + sal_Bool IsTransparent() const; + sal_Bool IsTerminated() const { return mbLoopTerminated; } + + const Size& GetDisplaySizePixel() const { return maGlobalSize; } + void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } + + const BitmapEx& GetBitmapEx() const { return maBitmapEx; } + void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } + + sal_uLong GetLoopCount() const { return mnLoopCount; } + void SetLoopCount( const sal_uLong nLoopCount ); + void ResetLoopCount(); + + void SetCycleMode( CycleMode eMode ); + CycleMode GetCycleMode() const { return meCycleMode; } + + void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } + const Link& GetNotifyHdl() const { return maNotifyLink; } + + sal_uInt16 Count() const { return (sal_uInt16) maList.Count(); } + sal_Bool Insert( const AnimationBitmap& rAnimationBitmap ); + const AnimationBitmap& Get( sal_uInt16 nAnimation ) const; + void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); + + List* GetAInfoList() { return &maAInfoList; } + sal_uLong GetSizeBytes() const; + sal_uLong GetChecksum() const; + +public: + + sal_Bool Convert( BmpConversion eConversion ); + sal_Bool ReduceColors( sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + sal_Bool Invert(); + sal_Bool Mirror( sal_uLong nMirrorFlags ); + sal_Bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); + sal_Bool Adjust( short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + sal_Bool bInvert = sal_False ); + sal_Bool Filter( BmpFilter eFilter, + const BmpFilterParam* pFilterParam = NULL, + const Link* pProgress = NULL ); + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Animation& rAnimation ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Animation& rAnimation ); +}; + +#endif // _SV_ANIMATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/apptypes.hxx b/vcl/inc/vcl/apptypes.hxx new file mode 100644 index 000000000000..42273f6a292c --- /dev/null +++ b/vcl/inc/vcl/apptypes.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_APPTYPES_HXX +#define _VCL_APPTYPES_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/rtti.hxx> + +// --------------------- +// - Application-Types - +// --------------------- + +#define EXC_RSCNOTLOADED ((sal_uInt16)0x0100) +#define EXC_SYSOBJNOTCREATED ((sal_uInt16)0x0200) +#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 UNIQUEID_SV_BEGIN 64000 + +class VCL_DLLPUBLIC ApplicationProperty +{ +public: + + TYPEINFO(); +}; + +#define INPUT_MOUSE 0x0001 +#define INPUT_KEYBOARD 0x0002 +#define INPUT_PAINT 0x0004 +#define INPUT_TIMER 0x0008 +#define INPUT_OTHER 0x0010 +#define INPUT_APPEVENT 0x0020 +#define INPUT_MOUSEANDKEYBOARD (INPUT_MOUSE | INPUT_KEYBOARD) +#define INPUT_ANY (INPUT_MOUSEANDKEYBOARD | INPUT_PAINT | INPUT_TIMER | INPUT_OTHER | INPUT_APPEVENT) + +#define DISPATCH_OPEN 0x0001 +#define DISPATCH_PRINT 0x0002 +#define DISPATCH_SERVER 0x0004 + +// -------------- +// - UserActive - +// -------------- + +#define USERACTIVE_MOUSEDRAG ((sal_uInt16)0x0001) +#define USERACTIVE_INPUT ((sal_uInt16)0x0002) +#define USERACTIVE_MODALDIALOG ((sal_uInt16)0x0004) +#define USERACTIVE_ALL ((sal_uInt16)0xFFFF) + +#endif // _VCL_APPTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/arrange.hxx b/vcl/inc/vcl/arrange.hxx new file mode 100644 index 000000000000..5568cc3b05d8 --- /dev/null +++ b/vcl/inc/vcl/arrange.hxx @@ -0,0 +1,461 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_ARRANGE_HXX +#define _VCL_ARRANGE_HXX + +#include "vcl/window.hxx" + +#include <vector> +#include <map> +#include <boost/shared_ptr.hpp> + +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 VCL_DLLPUBLIC WindowArranger + { + protected: + struct Element + { + Window* m_pElement; + boost::shared_ptr<WindowArranger> m_pChild; + 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, + boost::shared_ptr<WindowArranger> const & i_pChild = boost::shared_ptr<WindowArranger>(), + sal_Int32 i_nExpandPriority = 0, + const Size& i_rMinSize = Size() + ) + : m_pElement( i_pWin ) + , m_pChild( i_pChild ) + , m_nExpandPriority( i_nExpandPriority ) + , m_aMinSize( i_rMinSize ) + , m_bHidden( false ) + , m_nLeftBorder( 0 ) + , m_nTopBorder( 0 ) + , m_nRightBorder( 0 ) + , m_nBottomBorder( 0 ) + {} + + void deleteChild() { m_pChild.reset(); } + + sal_Int32 getExpandPriority() const; + Size getOptimalSize( WindowSizeType ) const; + bool isVisible() const; + void setPosSize( const Point&, const Size& ); + }; + + Window* m_pParentWindow; + WindowArranger* m_pParentArranger; + Rectangle m_aManagedArea; + long m_nOuterBorder; + + rtl::OUString m_aIdentifier; + + virtual Element* getElement( size_t i_nIndex ) = 0; + const Element* getConstElement( size_t i_nIndex ) const + { return const_cast<WindowArranger*>(this)->getElement( i_nIndex ); } + + + public: + static long getDefaultBorder(); + + static long getBorderValue( long nBorder ) + { return nBorder >= 0 ? nBorder : -nBorder * getDefaultBorder(); } + + 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* ); + + virtual void setParent( WindowArranger* ); + + virtual size_t countElements() const = 0; + boost::shared_ptr<WindowArranger> getChild( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->m_pChild : boost::shared_ptr<WindowArranger>(); + } + Window* getWindow( size_t i_nIndex ) const + { + const Element* pEle = getConstElement( i_nIndex ); + return pEle ? pEle->m_pElement : NULL; + } + + virtual bool isVisible() const; // true if any element is visible + + virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getProperties() const; + virtual void setProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& ); + + 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; + 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 getBorders( size_t i_nIndex, long* i_pLeft = NULL, long* i_pTop = NULL, long* i_pRight = NULL, long* i_pBottom = NULL ) const + { + const Element* pEle = getConstElement( i_nIndex ); + if( pEle ) + { + if( i_pLeft ) *i_pLeft = pEle->m_nLeftBorder; + if( i_pTop ) *i_pTop = pEle->m_nTopBorder; + if( i_pRight ) *i_pRight = pEle->m_nRightBorder; + if( i_pBottom ) *i_pBottom = pEle->m_nBottomBorder; + } + } + + + void show( bool i_bShow = true, bool i_bImmediateUpdate = true ); + + void setManagedArea( const Rectangle& i_rArea ) + { + m_aManagedArea = i_rArea; + resize(); + } + const Rectangle& getManagedArea() const { return m_aManagedArea; } + + void setOuterBorder( long i_nBorder ) + { + m_nOuterBorder = i_nBorder; + resize(); + } + + const rtl::OUString getIdentifier() const + { return m_aIdentifier; } + + void setIdentifier( const rtl::OUString& i_rId ) + { m_aIdentifier = i_rId; } + }; + + class VCL_DLLPUBLIC 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 ); + 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 = -1 ) + : WindowArranger( i_pParent ) + , m_nBorderWidth( i_nBorderWidth ) + , m_bColumn( bColumn ) + {} + + virtual ~RowOrColumn(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual size_t countElements() const { return m_aElements.size(); } + + // add a managed window at the given index + // an index smaller than zero means add the window at the end + size_t addWindow( Window*, sal_Int32 i_nExpandPrio = 0, const Size& i_rMinSize = Size(), size_t i_nIndex = ~0 ); + void remove( Window* ); + + size_t addChild( boost::shared_ptr<WindowArranger> const &, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ); + // convenience: use for addChild( new WindowArranger( ... ) ) constructs + size_t addChild( WindowArranger* i_pNewChild, sal_Int32 i_nExpandPrio = 0, size_t i_nIndex = ~0 ) + { return addChild( boost::shared_ptr<WindowArranger>( i_pNewChild ), i_nExpandPrio, i_nIndex ); } + void remove( boost::shared_ptr<WindowArranger> const & ); + + long getBorderWidth() const { return m_nBorderWidth; } + }; + + class VCL_DLLPUBLIC LabeledElement : public WindowArranger + { + 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 ) + { + if( i_nIndex == 0 ) + return &m_aLabel; + else if( i_nIndex == 1 ) + return &m_aElement; + return 0; + } + + public: + LabeledElement( WindowArranger* i_pParent = NULL, int i_nLabelStyle = 0, long i_nDistance = -1 ) + : WindowArranger( i_pParent ) + , m_nDistance( i_nDistance ) + , m_nLabelColumnWidth( 0 ) + , m_nLabelStyle( i_nLabelStyle ) + {} + + 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<WindowArranger> const & ); + void setElement( Window* ); + void setElement( boost::shared_ptr<WindowArranger> 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 VCL_DLLPUBLIC LabelColumn : public RowOrColumn + { + long getLabelWidth() const; + public: + LabelColumn( WindowArranger* i_pParent = NULL, long i_nBorderWidth = -1 ) + : 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<WindowArranger> const& i_rElement, long i_nIndent = 0 ); + size_t addRow( Window* i_pLabel, Window* i_pElement, long i_nIndent = 0, const Size& i_rElementMinSize = Size() ); + }; + + class VCL_DLLPUBLIC Indenter : public WindowArranger + { + long m_nIndent; + WindowArranger::Element m_aElement; + + protected: + virtual Element* getElement( size_t i_nIndex ) + { return i_nIndex == 0 ? &m_aElement : NULL; } + + public: + Indenter( WindowArranger* i_pParent = NULL, long i_nIndent = 3*getDefaultBorder() ) + : WindowArranger( i_pParent ) + , m_nIndent( i_nIndent ) + {} + + virtual ~Indenter(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual size_t countElements() const { return (m_aElement.m_pElement != 0 || m_aElement.m_pChild != 0) ? 1 : 0; } + + void setIndent( long i_nIndent ) + { + m_nIndent = i_nIndent; + resize(); + } + + void setWindow( Window*, sal_Int32 i_nExpandPrio = 0 ); + void setChild( boost::shared_ptr<WindowArranger> const &, sal_Int32 i_nExpandPrio = 0 ); + // convenience: use for setChild( new WindowArranger( ... ) ) constructs + void setChild( WindowArranger* i_pChild, sal_Int32 i_nExpandPrio = 0 ) + { setChild( boost::shared_ptr<WindowArranger>( i_pChild ), i_nExpandPrio ); } + }; + + class VCL_DLLPUBLIC Spacer : public WindowArranger + { + WindowArranger::Element m_aElement; + Size m_aSize; + + 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<WindowArranger>(), i_nPrio ) + , m_aSize( i_rSize ) + {} + + virtual ~Spacer() {} + + virtual Size getOptimalSize( WindowSizeType ) const + { return m_aSize; } + virtual void resize() {} + virtual void setParentWindow( Window* ) {} + virtual size_t countElements() const { return 1; } + virtual bool isVisible() const { return true; } + }; + + class VCL_DLLPUBLIC 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<WindowArranger> const & i_pChild = boost::shared_ptr<WindowArranger>(), + sal_Int32 i_nExpandPriority = 0, + const Size& i_rMinSize = Size() + ) + : WindowArranger::Element( i_pWin, i_pChild, i_nExpandPriority, i_rMinSize ) + , 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 ); } + + static void distributeExtraSize( std::vector<long>& io_rSizes, const std::vector<sal_Int32>& i_rPrios, long i_nExtraWidth ); + + Size getOptimalSize( WindowSizeType, + std::vector<long>& o_rColumnWidths, std::vector<long>& o_rRowHeights, + std::vector<sal_Int32>& o_rColumnPrio, std::vector<sal_Int32>& o_rRowPrio + ) const; + 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 = -1, + long i_nBorderY = -1 ) + : WindowArranger( i_pParent ) + , m_nBorderX( i_nBorderX ) + , m_nBorderY( i_nBorderY ) + {} + + virtual ~MatrixArranger(); + + virtual Size getOptimalSize( WindowSizeType ) const; + virtual void resize(); + virtual size_t countElements() const { return m_aElements.size(); } + + // add a managed window at the given matrix position + size_t addWindow( Window*, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0, const Size& i_rMinSize = Size() ); + void remove( Window* ); + + size_t addChild( boost::shared_ptr<WindowArranger> const &, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ); + // convenience: use for addChild( new WindowArranger( ... ) ) constructs + size_t addChild( WindowArranger* i_pNewChild, sal_uInt32 i_nX, sal_uInt32 i_nY, sal_Int32 i_nExpandPrio = 0 ) + { return addChild( boost::shared_ptr<WindowArranger>( i_pNewChild ), i_nX, i_nY, i_nExpandPrio ); } + void remove( boost::shared_ptr<WindowArranger> const & ); + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/bitmap.hxx b/vcl/inc/vcl/bitmap.hxx new file mode 100644 index 000000000000..d514977fda38 --- /dev/null +++ b/vcl/inc/vcl/bitmap.hxx @@ -0,0 +1,846 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BITMAP_HXX +#define _SV_BITMAP_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/mapmod.hxx> +#include <tools/rc.hxx> +#include <vcl/region.hxx> + +// ----------- +// - Defines - +// ----------- + +#define BMP_MIRROR_NONE 0x00000000UL +#define BMP_MIRROR_HORZ 0x00000001UL +#define BMP_MIRROR_VERT 0x00000002UL + +// ----------------------------------------------------------------------------- + +#define BMP_SCALE_NONE 0x00000000UL +#define BMP_SCALE_FAST 0x00000001UL +#define BMP_SCALE_INTERPOLATE 0x00000002UL + +// ----------------------------------------------------------------------------- + +#define BMP_DITHER_NONE 0x00000000UL +#define BMP_DITHER_MATRIX 0x00000001UL +#define BMP_DITHER_FLOYD 0x00000002UL +#define BMP_DITHER_FLOYD_16 0x00000004UL + +// ----------------------------------------------------------------------------- + +#define BMP_VECTORIZE_NONE BMP_VECTORIZE_OUTER +#define BMP_VECTORIZE_INNER 0x00000001UL +#define BMP_VECTORIZE_OUTER 0x00000002UL +#define BMP_VECTORIZE_BOUND_ONLY 0x00000004UL +#define BMP_VECTORIZE_REDUCE_EDGES 0x00000008UL + +// ----------------------------------------------------------------------------- + +#define BMP_COL_TRANS Color( 252, 3, 251 ) +#define BMP_COLOR_MONOCHROME_THRESHOLD 128 + +// --------- +// - Enums - +// --------- + +enum BmpConversion +{ + BMP_CONVERSION_NONE = 0, + BMP_CONVERSION_1BIT_THRESHOLD = 1, + BMP_CONVERSION_1BIT_MATRIX = 2, + BMP_CONVERSION_4BIT_GREYS = 3, + BMP_CONVERSION_4BIT_COLORS = 4, + BMP_CONVERSION_8BIT_GREYS = 5, + BMP_CONVERSION_8BIT_COLORS = 6, + BMP_CONVERSION_24BIT = 7, + BMP_CONVERSION_4BIT_TRANS = 8, + BMP_CONVERSION_8BIT_TRANS = 9, + BMP_CONVERSION_GHOSTED = 10 +}; + +// ------------------------------------------------------------------------ + +enum BmpCombine +{ + BMP_COMBINE_COPY = 0, + BMP_COMBINE_INVERT = 1, + BMP_COMBINE_AND = 2, + BMP_COMBINE_NAND = 3, + BMP_COMBINE_OR = 4, + BMP_COMBINE_NOR = 5, + BMP_COMBINE_XOR = 6, + BMP_COMBINE_NXOR = 7 +}; + +// ------------------------------------------------------------------------ + +enum BmpReduce +{ + BMP_REDUCE_SIMPLE = 0, + BMP_REDUCE_POPULAR = 1, + BMP_REDUCE_MEDIAN = 2 +}; + +// ------------------------------------------------------------------------ + +enum BmpEmboss +{ + BMP_EMBOSS_TOPLEFT = 0, + BMP_EMBOSS_TOP = 1, + BMP_EMBOSS_TOPRIGHT = 2, + BMP_EMBOSS_LEFT = 3, + BMP_EMBOSS_MIDDLE = 4, + BMP_EMBOSS_RIGHT = 5, + BMP_EMBOSS_BOTTOMLEFT = 6, + BMP_EMBOSS_BOTTOM = 7, + BMP_EMBOSS_BOTTOMRIGHT = 8 +}; + +// ------------------------------------------------------------------------ + +enum BmpFilter +{ + BMP_FILTER_SMOOTH = 0, + BMP_FILTER_SHARPEN = 1, + BMP_FILTER_REMOVENOISE = 2, + BMP_FILTER_SOBEL_GREY = 3, + BMP_FILTER_EMBOSS_GREY = 4, + BMP_FILTER_SOLARIZE = 5, + BMP_FILTER_SEPIA = 6, + BMP_FILTER_MOSAIC = 7, + BMP_FILTER_POPART = 8, + + BMP_FILTER_UNKNOWN = 65535 +}; + +// ------------------------------------------------------------------------ + +// -------------------- +// - FilterParameters - +// -------------------- + +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; + + MosaicTileSize maMosaicTileSize; + EmbossAngles maEmbossAngles; + }; + +public: + + BmpFilterParam( sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_UNKNOWN ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) {} + + BmpFilterParam( sal_uInt8 cSolarGreyThreshold, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_SOLARIZE ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), + mcSolarGreyThreshold( cSolarGreyThreshold ) {} + + BmpFilterParam( sal_uInt16 nSepiaPercent, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_SEPIA ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), + mnSepiaPercent( nSepiaPercent ) {} + + BmpFilterParam( const Size& rMosaicTileSize, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_MOSAIC ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) + { + maMosaicTileSize.mnTileWidth = rMosaicTileSize.Width(); + maMosaicTileSize.mnTileHeight= rMosaicTileSize.Height(); + } + BmpFilterParam( sal_uInt16 nEmbossAzimuthAngle100, sal_uInt16 nEmbossElevationAngle100, + sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_EMBOSS_GREY ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) + { + maEmbossAngles.mnAzimuthAngle100 = nEmbossAzimuthAngle100; + maEmbossAngles.mnElevationAngle100 = nEmbossElevationAngle100; + } +}; + +// ---------- +// - Bitmap - +// ---------- + +class BitmapReadAccess; +class BitmapWriteAccess; +class BitmapPalette; +class ImpBitmap; +class Color; +class SvStream; +struct DIBInfoHeader; +class ResId; +class GDIMetaFile; +class AlphaMask; +class OutputDevice; +class SalBitmap; + +struct BitmapSystemData +{ + #if defined( WNT ) || defined( OS2 ) + void* pDIB; // device independent byte buffer + void* pDDB; // if not NULL then this is actually an HBITMAP + #elif defined( QUARTZ ) + void* rImageContext; //Image context (CGContextRef) + #else + void* aPixmap; + #endif + int mnWidth; + int mnHeight; +}; + +class VCL_DLLPUBLIC Bitmap +{ +private: + + ImpBitmap* mpImpBmp; + MapMode maPrefMapMode; + Size maPrefSize; + + +public: + + SAL_DLLPRIVATE void ImplReleaseRef(); + SAL_DLLPRIVATE void ImplMakeUnique(); + ImpBitmap* ImplGetImpBitmap() const; + SAL_DLLPRIVATE void ImplSetImpBitmap( ImpBitmap* pImpBmp ); + SAL_DLLPRIVATE void ImplAssignWithSize( const Bitmap& rBitmap ); + + SAL_DLLPRIVATE static sal_Bool ImplReadDIB( SvStream& rIStm, Bitmap& rBmp, sal_uLong nOffset, sal_Bool bMSOFormat = sal_False ); + SAL_DLLPRIVATE static sal_Bool ImplReadDIBFileHeader( SvStream& rIStm, sal_uLong& rOffset ); + SAL_DLLPRIVATE static sal_Bool ImplReadDIBInfoHeader( SvStream& rIStm, DIBInfoHeader& rHeader, sal_Bool& bTopDown, sal_Bool bMSOFormat = sal_False ); + SAL_DLLPRIVATE static sal_Bool ImplReadDIBPalette( SvStream& rIStm, BitmapWriteAccess& rAcc, sal_Bool bQuad ); + SAL_DLLPRIVATE static sal_Bool ImplReadDIBBits( SvStream& rIStm, DIBInfoHeader& rHeader, BitmapWriteAccess& rAcc, sal_Bool bTopDown ); + SAL_DLLPRIVATE sal_Bool ImplWriteDIB( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bCompressed ) const; + SAL_DLLPRIVATE static sal_Bool ImplWriteDIBFileHeader( SvStream& rOStm, BitmapReadAccess& rAcc ); + SAL_DLLPRIVATE static sal_Bool ImplWriteDIBPalette( SvStream& rOStm, BitmapReadAccess& rAcc ); + SAL_DLLPRIVATE static sal_Bool ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc, + sal_uLong nCompression, sal_uInt32& rImageSize ); + SAL_DLLPRIVATE static void ImplDecodeRLE( sal_uInt8* pBuffer, DIBInfoHeader& rHeader, + BitmapWriteAccess& rAcc, sal_Bool bRLE4 ); + SAL_DLLPRIVATE static sal_Bool ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bRLE4 ); + + SAL_DLLPRIVATE sal_Bool ImplScaleFast( const double& rScaleX, const double& rScaleY ); + SAL_DLLPRIVATE sal_Bool ImplScaleInterpolate( const double& rScaleX, const double& rScaleY ); + SAL_DLLPRIVATE sal_Bool ImplMakeMono( sal_uInt8 cThreshold ); + SAL_DLLPRIVATE sal_Bool ImplMakeMonoDither(); + SAL_DLLPRIVATE sal_Bool ImplMakeGreyscales( sal_uInt16 nGreyscales ); + SAL_DLLPRIVATE sal_Bool ImplConvertUp( sal_uInt16 nBitCount, Color* pExtColor = NULL ); + SAL_DLLPRIVATE sal_Bool ImplConvertDown( sal_uInt16 nBitCount, Color* pExtColor = NULL ); + SAL_DLLPRIVATE sal_Bool ImplConvertGhosted(); + SAL_DLLPRIVATE sal_Bool ImplDitherMatrix(); + SAL_DLLPRIVATE sal_Bool ImplDitherFloyd(); + SAL_DLLPRIVATE sal_Bool ImplDitherFloyd16(); + SAL_DLLPRIVATE sal_Bool ImplReduceSimple( sal_uInt16 nColorCount ); + SAL_DLLPRIVATE sal_Bool ImplReducePopular( sal_uInt16 nColorCount ); + SAL_DLLPRIVATE sal_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 sal_Bool ImplConvolute3( const long* pMatrix, long nDivisor, + const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplMedianFilter( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplSobelGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplEmbossGrey( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplSolarize( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplSepia( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplMosaic( const BmpFilterParam* pFilterParam, const Link* pProgress ); + SAL_DLLPRIVATE sal_Bool ImplPopArt( const BmpFilterParam* pFilterParam, const Link* pProgress ); + +public: + + Bitmap(); + Bitmap( const Bitmap& rBitmap ); + Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = NULL ); + Bitmap( const ResId& rResId ); + Bitmap( SalBitmap* pSalBitmap ); + ~Bitmap(); + + Bitmap& operator=( const Bitmap& rBitmap ); + inline sal_Bool operator!() const; + inline sal_Bool operator==( const Bitmap& rBitmap ) const; + inline sal_Bool operator!=( const Bitmap& rBitmap ) const; + + inline sal_Bool IsSameInstance( const Bitmap& rBmp ) const; + sal_Bool IsEqual( const Bitmap& rBmp ) const; + + inline sal_Bool IsEmpty() const; + void SetEmpty(); + + inline const MapMode& GetPrefMapMode() const; + inline void SetPrefMapMode( const MapMode& rMapMode ); + + inline const Size& GetPrefSize() const; + inline void SetPrefSize( const Size& rSize ); + + Size GetSizePixel() const; + void SetSizePixel( const Size& rNewSize ); + + /** + * The pixel size of a bitmap's source (e.g. an image file) + * and the pixel size of its resulting bitmap can differ, + * e.g. when the image reader has its preview mode enabled. + */ + Size GetSourceSizePixel() const; + void SetSourceSizePixel( const Size& ); + + + sal_uInt16 GetBitCount() const; + inline sal_uLong GetColorCount() const; + inline sal_uLong GetSizeBytes() const; + sal_Bool HasGreyPalette() const; + /** get system dependent bitmap data + + @param rData + The system dependent BitmapSystemData structure to be filled + + @return sal_True if the bitmap has a valid system object (e.g. not empty) + */ + bool GetSystemData( BitmapSystemData& rData ) const; + + sal_uLong GetChecksum() const; + + Bitmap CreateDisplayBitmap( OutputDevice* pDisplay ); + Bitmap GetColorTransformedBitmap() const; + + static const BitmapPalette& GetGreyPalette( int nEntries ); + +public: + + sal_Bool MakeMono( sal_uInt8 cThreshold ); + + + /** Convert bitmap format + + @param eConversion + The format this bitmap should be converted to. + + @return sal_True, if the conversion was completed successfully. + */ + sal_Bool Convert( BmpConversion eConversion ); + + /** Reduce number of colors for the bitmap + + @param nNewColorCount + Maximal number of bitmap colors after the reduce operation + + @param eReduce + Algorithm to use for color reduction + + @return sal_True, if the color reduction operation was completed successfully. + */ + sal_Bool ReduceColors( sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + + /** Apply a dither algorithm to the bitmap + + This method dithers the bitmap inplace, i.e. a true color + bitmap is converted to a paletted bitmap, reducing the color + deviation by error diffusion. + + @param nDitherFlags + The algorithm to be used for dithering + + @param pDitherPal + A custom palette to be used when dithering (not yet implemented, leave NULL) + */ + sal_Bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); + + /** Crop the bitmap + + @param rRectPixel + A rectangle specifying the crop amounts on all four sides of + the bitmap. If the upper left corner of the bitmap is assigned + (0,0), then this method cuts out the given rectangle from the + bitmap. Note that the rectangle is clipped to the bitmap's + dimension, i.e. negative left,top rectangle coordinates or + exceeding width or height is ignored. + + @return sal_True, if cropping was performed successfully. If + nothing had to be cropped, because e.g. the crop rectangle + included the bitmap, sal_False is returned, too! + */ + sal_Bool Crop( const Rectangle& rRectPixel ); + + /** Expand the bitmap by pixel padding + + @param nDX + Number of pixel to pad at the right border of the bitmap + + @param nDY + Number of scanlines to pad at the bottom border of the bitmap + + @param pInitColor + Color to use for padded pixel + + @return sal_True, if padding was performed successfully. sal_False is + not only returned when the operation failed, but also if + nothing had to be done, e.g. because nDX and nDY were zero. + */ + sal_Bool Expand( sal_uLong nDX, sal_uLong nDY, + const Color* pInitColor = NULL ); + + /** Copy a rectangular area from another bitmap + + @param rRectDst + Destination rectangle in this bitmap. This is clipped to the + bitmap dimensions. + + @param rRectSrc + Source rectangle in pBmpSrc. This is clipped to the source + bitmap dimensions. Note further that no scaling takes place + during this copy operation, i.e. only the minimum of source + and destination rectangle's width and height are used. + + @param pBmpSrc + The source bitmap to copy from. If this argument is NULL, or + equal to the object this method is called on, copying takes + place within the same bitmap. + + @return sal_True, if the operation completed successfully. sal_False + is not only returned when the operation failed, but also if + nothing had to be done, e.g. because one of the rectangles are + empty. + */ + sal_Bool CopyPixel( const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const Bitmap* pBmpSrc = NULL ); + + /** Perform boolean operations with another bitmap + + @param rMask + The mask bitmap in the selected combine operation + + @param eCombine + The combine operation to perform on the bitmap + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool CombineSimple( const Bitmap& rMask, + BmpCombine eCombine ); + + /** Alpha-blend the given bitmap against a specified uniform + background color. + + @attention This method might convert paletted bitmaps to + truecolor, to be able to represent every necessary color. Note + that during alpha blending, lots of colors not originally + included in the bitmap can be generated. + + @param rAlpha + Alpha mask to blend with + + @param rBackgroundColor + Background color to use for every pixel during alpha blending + + @return sal_True, if blending was successful, sal_False otherwise + */ + sal_Bool Blend( const AlphaMask& rAlpha, + const Color& rBackgroundColor ); + + /** Fill the entire bitmap with the given color + + @param rFillColor + Color value to use for filling + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Erase( const Color& rFillColor ); + + /** Perform the Invert operation on every pixel + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Invert(); + + /** Mirror the bitmap + + @param nMirrorFlags + About which axis (horizontal, vertical, or both) to mirror + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Mirror( sal_uLong nMirrorFlags ); + + /** Scale the bitmap + + @param rNewSize + The resulting size of the scaled bitmap + + @param nScaleFlag + The algorithm to be used for scaling + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Scale( const Size& rNewSize, + sal_uLong nScaleFlag = BMP_SCALE_FAST ); + + /** Scale the bitmap + + @param rScaleX + The scale factor in x direction. + + @param rScaleY + The scale factor in y direction. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Scale( const double& rScaleX, const double& rScaleY, + sal_uLong nScaleFlag = BMP_SCALE_FAST ); + + /** Rotate bitmap by the specified angle + + @param nAngle10 + The rotation angle in tenth of a degree. The bitmap is always rotated around its center. + + @param rFillColor + The color to use for filling blank areas. During rotation, the + bitmap is enlarged such that the whole rotation result fits + in. The empty spaces around that rotated original bitmap are + then filled with this color. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Rotate( long nAngle10, const Color& rFillColor ); + + /** Create on-off mask from bitmap + + This method creates a bitmask from the bitmap, where every + pixel that equals rTransColor is set transparent, the rest + opaque. + + @param rTransColor + Color value where the bitmask should be transparent + + @param nTol + Tolerance value. Specifies the maximal difference between + rTransColor and the individual pixel values, such that the + corresponding pixel is still regarded transparent. + + @return the resulting bitmask. + */ + Bitmap CreateMask( const Color& rTransColor, sal_uLong nTol = 0UL ) const; + + /** Create region of similar colors in a given rectangle + + @param rColor + All pixel which have this color are included in the calculated region + + @param rRect + The rectangle within which matching pixel are looked for. This + rectangle is always clipped to the bitmap dimensions. + + @return the generated region. + */ + Region CreateRegion( const Color& rColor, const Rectangle& rRect ) const; + + /** Replace all pixel where the given mask is on with the specified color + + @param rMask + Mask specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Replace( const Bitmap& rMask, const Color& rReplaceColor ); + + /** Merge bitmap with given background color according to specified alpha mask + + @param rAlpha + Alpha mask specifying the amount of background color to merge in + + @param rMergeColor + Background color to be used for merging + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Replace( const AlphaMask& rAlpha, const Color& rMergeColor ); + + /** Replace all pixel having the search color with the specified color + + @param rSearchColor + Color specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @param nTol + Tolerance value. Specifies the maximal difference between + rSearchColor and the individual pixel values, such that the + corresponding pixel is still regarded a match. + + @return sal_True, if the operation was completed successfully. + */ + sal_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 + + @param pSearchColor + Array of colors specifying which pixel should be replaced + + @param pReplaceColor + Array of colors to be placed in all changed pixel + + @param nColorCount + Size of the aforementioned color arrays + + @param nTol + Tolerance value. Specifies the maximal difference between + pSearchColor colors and the individual pixel values, such that + the corresponding pixel is still regarded a match. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Replace( const Color* pSearchColors, const Color* rReplaceColors, + sal_uLong nColorCount, sal_uLong* pTols = NULL ); + + /** Convert the bitmap to a PolyPolygon + + This works by putting continuous areas of the same color into + a polygon, by tracing its bounding line. + + @param rPolyPoly + The resulting PolyPolygon + + @param nFlags + Whether the inline or the outline of the color areas should be + represented by the polygon + + @param pProgress + A callback for showing the progress of the vectorization + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Vectorize( PolyPolygon& rPolyPoly, + sal_uLong nFlags = BMP_VECTORIZE_OUTER, + const Link* pProgress = NULL ); + + /** Convert the bitmap to a meta file + + This works by putting continuous areas of the same color into + polygons painted in this color, by tracing the area's bounding + line. + + @param rMtf + The resulting meta file + + @param cReduce + If non-null, minimal size of bound rects for individual polygons. Smaller ones are ignored. + + @param nFlags + Whether the inline or the outline of the color areas should be + represented by the polygon + + @param pProgress + A callback for showing the progress of the vectorization + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Vectorize( GDIMetaFile& rMtf, sal_uInt8 cReduce = 0, + sal_uLong nFlags = BMP_VECTORIZE_INNER, + const Link* pProgress = NULL ); + + /** Change various global color characteristics + + @param nLuminancePercent + Percent of luminance change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nContrastPercent + Percent of contrast change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelRPercent + Percent of red channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelGPercent + Percent of green channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelBPercent + Percent of blue channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param fGamma + Exponent of the gamma function applied to the bitmap. The + value 1.0 results in no change, the valid range is + (0.0,10.0]. Values outside this range are regarded as 1.0. + + @param bInvert + If sal_True, invert the channel values with the logical 'not' operator + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Adjust( short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + sal_Bool bInvert = sal_False ); + + /** Apply specified filter to the bitmap + + @param eFilter + The filter algorithm to apply + + @param pFilterParam + Various parameter for the different bitmap filter algorithms + + @param pProgress + A callback for showing the progress of the vectorization + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Filter( BmpFilter eFilter, + const BmpFilterParam* pFilterParam = NULL, + const Link* pProgress = NULL ); + +public: + BitmapReadAccess* AcquireReadAccess(); + BitmapWriteAccess* AcquireWriteAccess(); + void ReleaseAccess( BitmapReadAccess* pAccess ); + +public: + + sal_Bool Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True, sal_Bool bMSOFormat = sal_False ); + sal_Bool Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const; + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Bitmap& rBitmap ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Bitmap& rBitmap ); +}; + +// ----------- +// - Inlines - +// ----------- + +inline sal_Bool Bitmap::operator!() const +{ + return( mpImpBmp == NULL ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool Bitmap::operator==( const Bitmap& rBitmap ) const +{ + return( rBitmap.mpImpBmp == mpImpBmp ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool Bitmap::operator!=( const Bitmap& rBitmap ) const +{ + return( rBitmap.mpImpBmp != mpImpBmp ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool Bitmap::IsSameInstance( const Bitmap& rBitmap ) const +{ + return( rBitmap.mpImpBmp == mpImpBmp ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool Bitmap::IsEmpty() const +{ + return( mpImpBmp == NULL ); +} + +// ------------------------------------------------------------------ + +inline const MapMode& Bitmap::GetPrefMapMode() const +{ + return maPrefMapMode; +} + +// ------------------------------------------------------------------ + +inline void Bitmap::SetPrefMapMode( const MapMode& rMapMode ) +{ + maPrefMapMode = rMapMode; +} + +// ------------------------------------------------------------------ + +inline const Size& Bitmap::GetPrefSize() const +{ + return maPrefSize; +} + +// ------------------------------------------------------------------ + +inline void Bitmap::SetPrefSize( const Size& rSize ) +{ + maPrefSize = rSize; +} + +// ------------------------------------------------------------------ + +inline sal_uLong Bitmap::GetColorCount() const +{ + return( 1UL << (sal_uLong) GetBitCount() ); +} + +// ------------------------------------------------------------------ + +inline sal_uLong Bitmap::GetSizeBytes() const +{ + const Size aSizePix( GetSizePixel() ); + return( ( (sal_uLong) aSizePix.Width() * aSizePix.Height() * GetBitCount() ) >> 3UL ); +} + +#endif // _SV_BITMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/bitmapex.hxx b/vcl/inc/vcl/bitmapex.hxx new file mode 100644 index 000000000000..9a6259fa61eb --- /dev/null +++ b/vcl/inc/vcl/bitmapex.hxx @@ -0,0 +1,401 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BITMAPEX_HXX +#define _SV_BITMAPEX_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> +#include <vcl/alpha.hxx> +#include <tools/color.hxx> + +// ------------------- +// - TransparentType - +// ------------------- + +enum TransparentType +{ + TRANSPARENT_NONE, + TRANSPARENT_COLOR, + TRANSPARENT_BITMAP +}; + +// ------------ +// - BitmapEx - +// ------------ + +class VCL_DLLPUBLIC BitmapEx +{ + friend class ImpGraphic; + +private: + + Bitmap aBitmap; + Bitmap aMask; + Size aBitmapSize; + Color aTransparentColor; + TransparentType eTransparent; + sal_Bool bAlpha; + +public: + + + SAL_DLLPRIVATE ImpBitmap* ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); } + SAL_DLLPRIVATE ImpBitmap* ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); } + +public: + + BitmapEx(); + BitmapEx( const ResId& rResId ); + BitmapEx( const BitmapEx& rBitmapEx ); + BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize ); + BitmapEx( const Bitmap& rBmp ); + BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ); + BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask ); + BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor ); + ~BitmapEx(); + + BitmapEx& operator=( const BitmapEx& rBitmapEx ); + sal_Bool operator==( const BitmapEx& rBitmapEx ) const; + sal_Bool operator!=( const BitmapEx& rBitmapEx ) const { return !(*this==rBitmapEx); } + sal_Bool operator!() const { return !aBitmap; } + + sal_Bool IsEqual( const BitmapEx& rBmpEx ) const; + + sal_Bool IsEmpty() const; + void SetEmpty(); + void Clear(); + + void Draw( OutputDevice* pOutDev, + const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, + const Point& rDestPt, const Size& rDestSize ) const; + void Draw( OutputDevice* pOutDev, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ) const; + + sal_Bool IsTransparent() const; + TransparentType GetTransparentType() const { return eTransparent; } + + Bitmap GetBitmap( const Color* pTransReplaceColor = NULL ) const; + Bitmap GetMask() const; + + BitmapEx GetColorTransformedBitmapEx() const; + + sal_Bool IsAlpha() const; + AlphaMask GetAlpha() const; + + const Size& GetSizePixel() const { return aBitmapSize; } + void SetSizePixel( const Size& rNewSize ); + + const Size& GetPrefSize() const { return aBitmap.GetPrefSize(); } + void SetPrefSize( const Size& rPrefSize ) { aBitmap.SetPrefSize( rPrefSize ); } + + const MapMode& GetPrefMapMode() const { return aBitmap.GetPrefMapMode(); } + void SetPrefMapMode( const MapMode& rPrefMapMode ) { aBitmap.SetPrefMapMode( rPrefMapMode ); } + + 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; + +public: + + /** Convert bitmap format + + @param eConversion + The format this bitmap should be converted to. + + @return sal_True, if the conversion was completed successfully. + */ + sal_Bool Convert( BmpConversion eConversion ); + + /** Reduce number of colors for the bitmap + + @param nNewColorCount + Maximal number of bitmap colors after the reduce operation + + @param eReduce + Algorithm to use for color reduction + + @return sal_True, if the color reduction operation was completed successfully. + */ + sal_Bool ReduceColors( sal_uInt16 nNewColorCount, + BmpReduce eReduce = BMP_REDUCE_SIMPLE ); + + /** Apply a dither algorithm to the bitmap + + This method dithers the bitmap inplace, i.e. a true color + bitmap is converted to a paletted bitmap, reducing the color + deviation by error diffusion. + + @param nDitherFlags + The algorithm to be used for dithering + */ + sal_Bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); + + /** Crop the bitmap + + @param rRectPixel + A rectangle specifying the crop amounts on all four sides of + the bitmap. If the upper left corner of the bitmap is assigned + (0,0), then this method cuts out the given rectangle from the + bitmap. Note that the rectangle is clipped to the bitmap's + dimension, i.e. negative left,top rectangle coordinates or + exceeding width or height is ignored. + + @return sal_True, if cropping was performed successfully. If + nothing had to be cropped, because e.g. the crop rectangle + included the bitmap, sal_False is returned, too! + */ + sal_Bool Crop( const Rectangle& rRectPixel ); + + /** Expand the bitmap by pixel padding + + @param nDX + Number of pixel to pad at the right border of the bitmap + + @param nDY + Number of scanlines to pad at the bottom border of the bitmap + + @param pInitColor + Color to use for padded pixel + + @return sal_True, if padding was performed successfully. sal_False is + not only returned when the operation failed, but also if + nothing had to be done, e.g. because nDX and nDY were zero. + */ + sal_Bool Expand( sal_uLong nDX, sal_uLong nDY, + const Color* pInitColor = NULL, + sal_Bool bExpandTransparent = sal_False ); + + /** Copy a rectangular area from another bitmap + + @param rRectDst + Destination rectangle in this bitmap. This is clipped to the + bitmap dimensions. + + @param rRectSrc + Source rectangle in pBmpSrc. This is clipped to the source + bitmap dimensions. Note further that no scaling takes place + during this copy operation, i.e. only the minimum of source + and destination rectangle's width and height are used. + + @param pBmpSrc + The source bitmap to copy from. If this argument is NULL, or + equal to the object this method is called on, copying takes + place within the same bitmap. + + @return sal_True, if the operation completed successfully. sal_False + is not only returned when the operation failed, but also if + nothing had to be done, e.g. because one of the rectangles are + empty. + */ + sal_Bool CopyPixel( const Rectangle& rRectDst, + const Rectangle& rRectSrc, + const BitmapEx* pBmpExSrc = NULL ); + + /** Fill the entire bitmap with the given color + + @param rFillColor + Color value to use for filling. Set the transparency part of + the color to fill the mask. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Erase( const Color& rFillColor ); + + /** Perform the Invert operation on every pixel + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Invert(); + + /** Mirror the bitmap + + @param nMirrorFlags + About which axis (horizontal, vertical, or both) to mirror + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Mirror( sal_uLong nMirrorFlags ); + + /** Scale the bitmap + + @param rNewSize + The resulting size of the scaled bitmap + + @param nScaleFlag + The algorithm to be used for scaling + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Scale( const Size& rNewSize, sal_uLong nScaleFlag = BMP_SCALE_FAST ); + + /** Scale the bitmap + + @param rScaleX + The scale factor in x direction. + + @param rScaleY + The scale factor in y direction. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Scale( const double& rScaleX, const double& rScaleY, sal_uLong nScaleFlag = BMP_SCALE_FAST ); + + /** Rotate bitmap by the specified angle + + @param nAngle10 + The rotation angle in tenth of a degree. The bitmap is always rotated around its center. + + @param rFillColor + The color to use for filling blank areas. During rotation, the + bitmap is enlarged such that the whole rotation result fits + in. The empty spaces around that rotated original bitmap are + then filled with this color. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Rotate( long nAngle10, const Color& rFillColor ); + + /** Replace all pixel having the search color with the specified color + + @param rSearchColor + Color specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @param nTol + Tolerance value. Specifies the maximal difference between + rSearchColor and the individual pixel values, such that the + corresponding pixel is still regarded a match. + + @return sal_True, if the operation was completed successfully. + */ + sal_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 + + @param pSearchColor + Array of colors specifying which pixel should be replaced + + @param pReplaceColor + Array of colors to be placed in all changed pixel + + @param nColorCount + Size of the aforementioned color arrays + + @param nTol + Tolerance value. Specifies the maximal difference between + pSearchColor colors and the individual pixel values, such that + the corresponding pixel is still regarded a match. + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Replace( const Color* pSearchColors, const Color* pReplaceColors, + sal_uLong nColorCount, const sal_uLong* pTols = NULL ); + + /** Change various global color characteristics + + @param nLuminancePercent + Percent of luminance change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nContrastPercent + Percent of contrast change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelRPercent + Percent of red channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelGPercent + Percent of green channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelBPercent + Percent of blue channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param fGamma + Exponent of the gamma function applied to the bitmap. The + value 1.0 results in no change, the valid range is + (0.0,10.0]. Values outside this range are regarded as 1.0. + + @param bInvert + If sal_True, invert the channel values with the logical 'not' operator + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Adjust( short nLuminancePercent = 0, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + sal_Bool bInvert = sal_False ); + + /** Apply specified filter to the bitmap + + @param eFilter + The filter algorithm to apply + + @param pFilterParam + Various parameter for the different bitmap filter algorithms + + @param pProgress + A callback for showing the progress of the vectorization + + @return sal_True, if the operation was completed successfully. + */ + sal_Bool Filter( BmpFilter eFilter, + 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 ); + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx ); + static BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize); +}; + +#endif // _SV_BITMAPEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/bmpacc.hxx b/vcl/inc/vcl/bmpacc.hxx new file mode 100644 index 000000000000..650a60a69077 --- /dev/null +++ b/vcl/inc/vcl/bmpacc.hxx @@ -0,0 +1,543 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BMPACC_HXX +#define _SV_BMPACC_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/salbtype.hxx> +#include <vcl/bitmap.hxx> + + +// -------------------- +// - Access defines - +// -------------------- + +#define DECL_FORMAT_GETPIXEL( Format ) \ +static BitmapColor GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& rMask ); + +#define DECL_FORMAT_SETPIXEL( Format ) \ +static void SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask ); + +#define DECL_FORMAT( Format ) \ +DECL_FORMAT_GETPIXEL( Format ) \ +DECL_FORMAT_SETPIXEL( Format ) + +#define IMPL_FORMAT_GETPIXEL( Format ) \ +BitmapColor BitmapReadAccess::GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& rMask ) + +#define IMPL_FORMAT_GETPIXEL_NOMASK( Format ) \ +BitmapColor BitmapReadAccess::GetPixelFor##Format( ConstScanline pScanline, long nX, const ColorMask& ) + +#define IMPL_FORMAT_SETPIXEL( Format ) \ +void BitmapReadAccess::SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask ) + +#define IMPL_FORMAT_SETPIXEL_NOMASK( Format ) \ +void BitmapReadAccess::SetPixelFor##Format( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& ) + +#define CASE_FORMAT( Format ) \ +case( BMP_FORMAT##Format ): \ +{ \ + mFncGetPixel = GetPixelFor##Format;\ + mFncSetPixel = SetPixelFor##Format;\ +} \ +break; + + +// -------------------- +// - Access functions - +// -------------------- + +typedef BitmapColor (*FncGetPixel)( ConstScanline pScanline, long nX, const ColorMask& rMask ); +typedef void (*FncSetPixel)( Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask ); + +// -------------------- +// - BitmapReadAccess - +// -------------------- + +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; + sal_Bool mbModify; + + +SAL_DLLPRIVATE void ImplCreate( Bitmap& rBitmap ); +SAL_DLLPRIVATE void ImplDestroy(); +SAL_DLLPRIVATE sal_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, sal_Bool bModify ); + + void Flush(); + void ReAccess( sal_Bool bModify ); + +public: + BitmapReadAccess( Bitmap& rBitmap ); + virtual ~BitmapReadAccess(); + + inline sal_Bool operator!() const; + + inline long Width() const; + inline long Height() const; + inline Point TopLeft() const; + inline Point BottomRight() const; + + inline sal_Bool IsTopDown() const; + inline sal_Bool IsBottomUp() const; + + inline sal_uLong GetScanlineFormat() const; + inline sal_uLong GetScanlineSize() const; + + inline sal_uInt16 GetBitCount() const; + inline BitmapColor GetBestMatchingColor( const BitmapColor& rBitmapColor ); + + inline Scanline GetBuffer() const; + inline Scanline GetScanline( long nY ) const; + + inline sal_Bool HasPalette() const; + inline const BitmapPalette& GetPalette() 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; + + inline sal_Bool HasColorMask() const; + inline ColorMask& GetColorMask() const; + + inline BitmapColor GetPixelFromData( const sal_uInt8* pData, long nX ) const; + inline void SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor ); + inline BitmapColor GetPixel( long nY, long nX ) const; + inline BitmapColor GetColor( long nY, long nX ) const; + inline sal_uInt8 GetLuminance( long nY, long nX ) const; +}; + +// --------------------- +// - BitmapWriteAccess - +// --------------------- + +class VCL_DLLPUBLIC BitmapWriteAccess : public BitmapReadAccess +{ +public: + + BitmapWriteAccess( Bitmap& rBitmap ); + virtual ~BitmapWriteAccess(); + + void CopyScanline( long nY, const BitmapReadAccess& rReadAcc ); + void CopyScanline( long nY, ConstScanline aSrcScanline, + sal_uLong nSrcScanlineFormat, sal_uLong nSrcScanlineSize ); + + void CopyBuffer( const BitmapReadAccess& rReadAcc ); + + inline void SetPalette( const BitmapPalette& rPalette ); + inline void SetPaletteEntryCount( sal_uInt16 nCount ); + inline void SetPaletteColor( sal_uInt16 nColor, const BitmapColor& rBitmapColor ); + + inline void SetPixel( long nY, long nX, const BitmapColor& rBitmapColor ); + + void SetLineColor(); + void SetLineColor( const Color& rColor ); + Color GetLineColor() const; + + void SetFillColor(); + void SetFillColor( const Color& rColor ); + Color GetFillColor() const; + + void Erase( const Color& rColor ); + + void DrawLine( const Point& rStart, const Point& rEnd ); + + void FillRect( const Rectangle& rRect ); + void DrawRect( const Rectangle& rRect ); + + void FillPolygon( const Polygon& rPoly ); + void DrawPolygon( const Polygon& rPoly ); + + void FillPolyPolygon( const PolyPolygon& rPoly ); + void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); + +private: + + BitmapColor* mpLineColor; + BitmapColor* mpFillColor; + + BitmapWriteAccess() {} + BitmapWriteAccess( const BitmapWriteAccess& ) : BitmapReadAccess() {} + BitmapWriteAccess& operator=( const BitmapWriteAccess& ) { return *this; } +}; + +// ------------------- +// - Accessor Helper - +// ------------------- + +/** This template handles BitmapAccess the RAII way. + + Please don't use directly, but the ready-made typedefs for + BitmapReadAccess and BitmapWriteAccess below. + */ +template < class Access > class ScopedBitmapAccess +{ +public: + ScopedBitmapAccess( Access* pAccess, + Bitmap& rBitmap ) : + mpAccess( pAccess ), + mrBitmap( rBitmap ) + { + } + + ~ScopedBitmapAccess() + { + mrBitmap.ReleaseAccess( mpAccess ); + } + + Access* get() { return mpAccess; } + const Access* get() const { return mpAccess; } + + Access* operator->() { return mpAccess; } + const Access* operator->() const { return mpAccess; } + + Access& operator*() { return *mpAccess; } + const Access& operator*() const { return *mpAccess; } + +private: + Access* mpAccess; + Bitmap& mrBitmap; +}; + +/** This wrapper handles BitmapReadAccess the RAII way. + + Use as follows: + Bitmap aBitmap + ScopedBitmapReadAccess pReadAccess( aBitmap.AcquireReadAccess(), aBitmap ); + pReadAccess->SetPixel()... + + @attention for practical reasons, ScopedBitmapReadAccess stores a + reference to the provided bitmap, thus, make sure that the bitmap + specified at construction time lives at least as long as the + ScopedBitmapReadAccess. +*/ +typedef ScopedBitmapAccess< BitmapReadAccess > ScopedBitmapReadAccess; + +/** This wrapper handles BitmapWriteAccess the RAII way. + + Use as follows: + Bitmap aBitmap + ScopedBitmapWriteAccess pWriteAccess( aBitmap.AcquireWriteAccess(), aBitmap ); + pWriteAccess->SetPixel()... + + @attention for practical reasons, ScopedBitmapWriteAccess stores a + reference to the provided bitmap, thus, make sure that the bitmap + specified at construction time lives at least as long as the + ScopedBitmapWriteAccess. +*/ +typedef ScopedBitmapAccess< BitmapWriteAccess > ScopedBitmapWriteAccess; + +// ----------- +// - Inlines - +// ----------- + +inline sal_Bool BitmapReadAccess::operator!() const +{ + return( mpBuffer == NULL ); +} + +// ------------------------------------------------------------------ + +inline long BitmapReadAccess::Width() const +{ + return( mpBuffer ? mpBuffer->mnWidth : 0L ); +} + +// ------------------------------------------------------------------ + +inline long BitmapReadAccess::Height() const +{ + return( mpBuffer ? mpBuffer->mnHeight : 0L ); +} + +// ------------------------------------------------------------------ + +inline Point BitmapReadAccess::TopLeft() const +{ + return Point(); +} + +// ------------------------------------------------------------------ + +inline Point BitmapReadAccess::BottomRight() const +{ + return Point( Width() - 1L, Height() - 1L ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapReadAccess::IsTopDown() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer ? sal::static_int_cast<sal_Bool>( BMP_SCANLINE_ADJUSTMENT( mpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN ) : sal_False ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapReadAccess::IsBottomUp() const +{ + return !IsTopDown(); +} + +// ------------------------------------------------------------------ + +inline sal_uLong BitmapReadAccess::GetScanlineFormat() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer ? BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ) : 0UL ); +} + +// ------------------------------------------------------------------ + +inline sal_uLong BitmapReadAccess::GetScanlineSize() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer ? mpBuffer->mnScanlineSize : 0UL ); +} + +// ------------------------------------------------------------------ + +inline sal_uInt16 BitmapReadAccess::GetBitCount() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer ? mpBuffer->mnBitCount : 0 ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor BitmapReadAccess::GetBestMatchingColor( const BitmapColor& rBitmapColor ) +{ + if( HasPalette() ) + return BitmapColor( (sal_uInt8) GetBestPaletteIndex( rBitmapColor ) ); + else + return rBitmapColor; +} + +// ------------------------------------------------------------------ + +inline Scanline BitmapReadAccess::GetBuffer() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer ? mpBuffer->mpBits : NULL ); +} + +// ------------------------------------------------------------------ + +inline Scanline BitmapReadAccess::GetScanline( long nY ) const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + DBG_ASSERT( nY < mpBuffer->mnHeight, "y-coordinate out of range!" ); + return( mpBuffer ? mpScanBuf[ nY ] : NULL ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapReadAccess::HasPalette() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return( mpBuffer && !!mpBuffer->maPalette ); +} + +// ------------------------------------------------------------------ + +inline const BitmapPalette& BitmapReadAccess::GetPalette() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return mpBuffer->maPalette; +} + +// ------------------------------------------------------------------ + +inline sal_uInt16 BitmapReadAccess::GetPaletteEntryCount() const +{ + DBG_ASSERT( HasPalette(), "Bitmap has no palette!" ); + return( HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0 ); +} + +// ------------------------------------------------------------------ + +inline const BitmapColor& BitmapReadAccess::GetPaletteColor( sal_uInt16 nColor ) const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + DBG_ASSERT( HasPalette(), "Bitmap has no palette!" ); + return mpBuffer->maPalette[ nColor ]; +} + +// ------------------------------------------------------------------ + +inline const BitmapColor& BitmapReadAccess::GetBestPaletteColor( const BitmapColor& rBitmapColor ) const +{ + return GetPaletteColor( GetBestPaletteIndex( rBitmapColor ) ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapReadAccess::HasColorMask() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + const sal_uLong nFormat = BMP_SCANLINE_FORMAT( mpBuffer->mnFormat ); + + return( nFormat == BMP_FORMAT_8BIT_TC_MASK || + nFormat == BMP_FORMAT_16BIT_TC_MSB_MASK || + nFormat == BMP_FORMAT_16BIT_TC_LSB_MASK || + nFormat == BMP_FORMAT_24BIT_TC_MASK || + nFormat == BMP_FORMAT_32BIT_TC_MASK ); +} + +// ------------------------------------------------------------------ + +inline ColorMask& BitmapReadAccess::GetColorMask() const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return mpBuffer->maColorMask; +} + +// ------------------------------------------------------------------ + +inline BitmapColor BitmapReadAccess::GetPixel( long nY, long nX ) const +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + DBG_ASSERT( nX < mpBuffer->mnWidth, "x-coordinate out of range!" ); + DBG_ASSERT( nY < mpBuffer->mnHeight, "y-coordinate out of range!" ); + return mFncGetPixel( mpScanBuf[ nY ], nX, maColorMask ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor BitmapReadAccess::GetPixelFromData( const sal_uInt8* pData, long nX ) const +{ + DBG_ASSERT( pData, "Access is not valid!" ); + return mFncGetPixel( pData, nX, maColorMask ); +} + +// ------------------------------------------------------------------ + +inline void BitmapReadAccess::SetPixelOnData( sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor ) +{ + DBG_ASSERT( pData, "Access is not valid!" ); + mFncSetPixel( pData, nX, rBitmapColor, maColorMask ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor BitmapReadAccess::GetColor( long nY, long nX ) const +{ + if( !!mpBuffer->maPalette ) + { + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + return mpBuffer->maPalette[ GetPixel( nY, nX ).GetIndex() ]; + } + else + return GetPixel( nY, nX ); +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapReadAccess::GetLuminance( long nY, long nX ) const +{ + return GetColor( nY, nX ).GetLuminance(); +} + +// ------------------------------------------------------------------ + +inline void BitmapWriteAccess::SetPalette( const BitmapPalette& rPalette ) +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + mpBuffer->maPalette = rPalette; +} + +// ------------------------------------------------------------------ + +inline void BitmapWriteAccess::SetPaletteEntryCount( sal_uInt16 nCount ) +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + mpBuffer->maPalette.SetEntryCount( nCount ); +} + +// ------------------------------------------------------------------ + +inline void BitmapWriteAccess::SetPaletteColor( sal_uInt16 nColor, const BitmapColor& rBitmapColor ) +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + DBG_ASSERT( HasPalette(), "Bitmap has no palette!" ); + mpBuffer->maPalette[ nColor ] = rBitmapColor; +} + +// ------------------------------------------------------------------ + +inline void BitmapWriteAccess::SetPixel( long nY, long nX, const BitmapColor& rBitmapColor ) +{ + DBG_ASSERT( mpBuffer, "Access is not valid!" ); + DBG_ASSERT( nX < mpBuffer->mnWidth, "x-coordinate out of range!" ); + DBG_ASSERT( nY < mpBuffer->mnHeight, "y-coordinate out of range!" ); + mFncSetPixel( mpScanBuf[ nY ], nX, rBitmapColor, maColorMask ); +} + +#endif // _SV_BMPACC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/bmpfast.hxx b/vcl/inc/vcl/bmpfast.hxx new file mode 100644 index 000000000000..b43df0e115b2 --- /dev/null +++ b/vcl/inc/vcl/bmpfast.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BMPFAST_HXX +#define _SV_BMPFAST_HXX + +class BitmapWriteAccess; +class BitmapReadAccess; +struct BitmapBuffer; +class BitmapColor; +class Size; +class Point; +struct SalTwoRect; + +// the bmpfast functions have signatures with good compatibility to +// their canonic counterparts, which employ the GetPixel/SetPixel methods + +bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc, + const SalTwoRect& rTwoRect ); + +bool ImplFastBitmapBlending( BitmapWriteAccess& rDst, + const BitmapReadAccess& rSrc, const BitmapReadAccess& rMask, + const SalTwoRect& rTwoRect ); + +bool ImplFastEraseBitmap( BitmapBuffer&, const BitmapColor& ); + +#endif // _SV_BMPFAST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/brdwin.hxx b/vcl/inc/vcl/brdwin.hxx new file mode 100644 index 000000000000..e6374ea032f5 --- /dev/null +++ b/vcl/inc/vcl/brdwin.hxx @@ -0,0 +1,356 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BRDWIN_HXX +#define _SV_BRDWIN_HXX + +#include <vcl/sv.h> +#include <vcl/window.hxx> + +class ImplBorderWindowView; + +// -------------------------- +// - ImplBorderWindow-Types - +// -------------------------- + +#define BORDERWINDOW_STYLE_OVERLAP ((sal_uInt16)0x0001) +#define BORDERWINDOW_STYLE_BORDER ((sal_uInt16)0x0002) +#define BORDERWINDOW_STYLE_FLOAT ((sal_uInt16)0x0004) +#define BORDERWINDOW_STYLE_FRAME ((sal_uInt16)0x0008) +#define BORDERWINDOW_STYLE_APP ((sal_uInt16)0x0010) + +#define BORDERWINDOW_HITTEST_TITLE ((sal_uInt16)0x0001) +#define BORDERWINDOW_HITTEST_LEFT ((sal_uInt16)0x0002) +#define BORDERWINDOW_HITTEST_MENU ((sal_uInt16)0x0004) +#define BORDERWINDOW_HITTEST_TOP ((sal_uInt16)0x0008) +#define BORDERWINDOW_HITTEST_RIGHT ((sal_uInt16)0x0010) +#define BORDERWINDOW_HITTEST_BOTTOM ((sal_uInt16)0x0020) +#define BORDERWINDOW_HITTEST_TOPLEFT ((sal_uInt16)0x0040) +#define BORDERWINDOW_HITTEST_TOPRIGHT ((sal_uInt16)0x0080) +#define BORDERWINDOW_HITTEST_BOTTOMLEFT ((sal_uInt16)0x0100) +#define BORDERWINDOW_HITTEST_BOTTOMRIGHT ((sal_uInt16)0x0200) +#define BORDERWINDOW_HITTEST_CLOSE ((sal_uInt16)0x0400) +#define BORDERWINDOW_HITTEST_ROLL ((sal_uInt16)0x0800) +#define BORDERWINDOW_HITTEST_DOCK ((sal_uInt16)0x1000) +#define BORDERWINDOW_HITTEST_HIDE ((sal_uInt16)0x2000) +#define BORDERWINDOW_HITTEST_HELP ((sal_uInt16)0x4000) +#define BORDERWINDOW_HITTEST_PIN ((sal_uInt16)0x8000) + +#define BORDERWINDOW_DRAW_TITLE ((sal_uInt16)0x0001) +#define BORDERWINDOW_DRAW_BORDER ((sal_uInt16)0x0002) +#define BORDERWINDOW_DRAW_FRAME ((sal_uInt16)0x0004) +#define BORDERWINDOW_DRAW_CLOSE ((sal_uInt16)0x0008) +#define BORDERWINDOW_DRAW_ROLL ((sal_uInt16)0x0010) +#define BORDERWINDOW_DRAW_DOCK ((sal_uInt16)0x0020) +#define BORDERWINDOW_DRAW_HIDE ((sal_uInt16)0x0040) +#define BORDERWINDOW_DRAW_HELP ((sal_uInt16)0x0080) +#define BORDERWINDOW_DRAW_PIN ((sal_uInt16)0x0100) +#define BORDERWINDOW_DRAW_MENU ((sal_uInt16)0x0200) +#define BORDERWINDOW_DRAW_ALL (BORDERWINDOW_DRAW_TITLE | \ + BORDERWINDOW_DRAW_BORDER | \ + BORDERWINDOW_DRAW_FRAME | \ + BORDERWINDOW_DRAW_CLOSE | \ + BORDERWINDOW_DRAW_ROLL | \ + BORDERWINDOW_DRAW_DOCK | \ + BORDERWINDOW_DRAW_HIDE | \ + BORDERWINDOW_DRAW_HELP | \ + BORDERWINDOW_DRAW_PIN | \ + BORDERWINDOW_DRAW_MENU) + +#define BORDERWINDOW_TITLE_NORMAL ((sal_uInt16)0x0001) +#define BORDERWINDOW_TITLE_SMALL ((sal_uInt16)0x0002) +#define BORDERWINDOW_TITLE_TEAROFF ((sal_uInt16)0x0004) +#define BORDERWINDOW_TITLE_POPUP ((sal_uInt16)0x0008) +#define BORDERWINDOW_TITLE_NONE ((sal_uInt16)0x0010) + +// -------------------- +// - ImplBorderWindow - +// -------------------- + +class ImplBorderWindow : public Window +{ + friend class Window; + friend class ImplBorderWindowView; + friend class ImplSmallBorderWindowView; + friend class ImplStdBorderWindowView; + +private: + ImplBorderWindowView* mpBorderView; + Window* mpMenuBarWindow; + long mnMinWidth; + long mnMinHeight; + long mnMaxWidth; + long mnMaxHeight; + long mnRollHeight; + long mnOrgMenuHeight; + sal_uInt16 mnTitleType; + sal_uInt16 mnBorderStyle; + sal_Bool mbFloatWindow; + sal_Bool mbSmallOutBorder; + sal_Bool mbFrameBorder; + sal_Bool mbPined; + sal_Bool mbRollUp; + sal_Bool mbMenuHide; + sal_Bool mbDockBtn; + sal_Bool mbHideBtn; + sal_Bool mbHelpBtn; + sal_Bool mbMenuBtn; + sal_Bool mbDisplayActive; + + using Window::ImplInit; + void ImplInit( Window* pParent, + WinBits nStyle, sal_uInt16 nTypeStyle, + SystemParentData* pParentData ); + void ImplInit( Window* pParent, + WinBits nStyle, sal_uInt16 nTypeStyle, + const ::com::sun::star::uno::Any& ); + + // Copy assignment is forbidden and not implemented. + ImplBorderWindow (const ImplBorderWindow &); + ImplBorderWindow& operator= (const ImplBorderWindow &); + +public: + ImplBorderWindow( Window* pParent, + SystemParentData* pParentData, + WinBits nStyle = 0, + sal_uInt16 nTypeStyle = 0 ); + ImplBorderWindow( Window* pParent, WinBits nStyle = 0, + sal_uInt16 nTypeStyle = 0 ); + ImplBorderWindow( Window* pParent, + WinBits nStyle, sal_uInt16 nTypeStyle, + const ::com::sun::star::uno::Any& ); + ~ImplBorderWindow(); + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Activate(); + virtual void Deactivate(); + virtual void Resize(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void InitView(); + void UpdateView( sal_Bool bNewView, const Size& rNewOutSize ); + void InvalidateBorder(); + + using Window::Draw; + void Draw( const Rectangle& rRect, OutputDevice* pDev, const Point& rPos ); + + void SetDisplayActive( sal_Bool bActive ); + sal_Bool IsDisplayActive() const { return mbDisplayActive; } + void SetTitleType( sal_uInt16 nTitleType, const Size& rSize ); + void SetBorderStyle( sal_uInt16 nStyle ); + sal_uInt16 GetBorderStyle() const { return mnBorderStyle; } + void SetPin( sal_Bool bPin ); + void SetRollUp( sal_Bool bRollUp, const Size& rSize ); + void SetCloser(); + void SetDockButton( sal_Bool bDockButton ); + void SetHideButton( sal_Bool bHideButton ); + void SetHelpButton( sal_Bool bHelpButton ); + void SetMenuButton( sal_Bool bMenuButton ); + + void UpdateMenuHeight(); + void SetMenuBarWindow( Window* pWindow ); + void SetMenuBarMode( sal_Bool bHide ); + + void SetMinOutputSize( long nWidth, long nHeight ) + { mnMinWidth = nWidth; mnMinHeight = nHeight; } + void SetMaxOutputSize( long nWidth, long nHeight ) + { mnMaxWidth = nWidth; mnMaxHeight = nHeight; } + + void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + long CalcTitleWidth() const; + + Rectangle GetMenuRect() const; +}; + +// ======================================================================= + +// ----------------------- +// - ImplBorderFrameData - +// ----------------------- + +struct ImplBorderFrameData +{ + ImplBorderWindow* mpBorderWindow; + OutputDevice* mpOutDev; + Rectangle maTitleRect; + Rectangle maPinRect; + Rectangle maCloseRect; + Rectangle maRollRect; + Rectangle maDockRect; + Rectangle maMenuRect; + Rectangle maHideRect; + Rectangle maHelpRect; + Point maMouseOff; + long mnWidth; + long mnHeight; + long mnTrackX; + long mnTrackY; + long mnTrackWidth; + long mnTrackHeight; + sal_Int32 mnLeftBorder; + sal_Int32 mnTopBorder; + sal_Int32 mnRightBorder; + sal_Int32 mnBottomBorder; + long mnNoTitleTop; + long mnBorderSize; + long mnTitleHeight; + long mnTitleOff; + sal_uInt16 mnHitTest; + sal_uInt16 mnPinState; + sal_uInt16 mnCloseState; + sal_uInt16 mnRollState; + sal_uInt16 mnDockState; + sal_uInt16 mnMenuState; + sal_uInt16 mnHideState; + sal_uInt16 mnHelpState; + sal_uInt16 mnTitleType; + sal_Bool mbFloatWindow; + sal_Bool mbDragFull; + sal_Bool mbTitleClipped; +}; + +// ======================================================================= + +// ------------------------ +// - ImplBorderWindowView - +// ------------------------ + +class ImplBorderWindowView +{ +public: + virtual ~ImplBorderWindowView(); + + virtual sal_Bool MouseMove( const MouseEvent& rMEvt ); + virtual sal_Bool MouseButtonDown( const MouseEvent& rMEvt ); + virtual sal_Bool Tracking( const TrackingEvent& rTEvt ); + virtual String RequestHelp( const Point& rPos, Rectangle& rHelpRect ); + + virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) = 0; + virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0; + virtual long CalcTitleWidth() const = 0; + virtual void DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev = NULL, const Point* pOffset = NULL ) = 0; + virtual Rectangle GetMenuRect() const; + + void ImplInitTitle( ImplBorderFrameData* pData ); + sal_uInt16 ImplHitTest( ImplBorderFrameData* pData, const Point& rPos ); + sal_Bool ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt ); + sal_Bool ImplMouseButtonDown( ImplBorderFrameData* pData, const MouseEvent& rMEvt ); + sal_Bool ImplTracking( ImplBorderFrameData* pData, const TrackingEvent& rTEvt ); + String ImplRequestHelp( ImplBorderFrameData* pData, const Point& rPos, Rectangle& rHelpRect ); + long ImplCalcTitleWidth( const ImplBorderFrameData* pData ) const; +}; + +// ======================================================================= + +// -------------------------- +// - ImplNoBorderWindowView - +// -------------------------- + +class ImplNoBorderWindowView : public ImplBorderWindowView +{ +public: + ImplNoBorderWindowView( ImplBorderWindow* pBorderWindow ); + + virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ); + virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + virtual long CalcTitleWidth() const; + virtual void DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset ); +}; + + +// ======================================================================= + +// ----------------------------- +// - ImplSmallBorderWindowView - +// ----------------------------- + +class ImplSmallBorderWindowView : public ImplBorderWindowView +{ + ImplBorderWindow* mpBorderWindow; + OutputDevice* mpOutDev; + long mnWidth; + long mnHeight; + sal_Int32 mnLeftBorder; + sal_Int32 mnTopBorder; + sal_Int32 mnRightBorder; + sal_Int32 mnBottomBorder; + bool mbNWFBorder; + +public: + ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow ); + + virtual void Init( OutputDevice* pOutDev, long nWidth, long nHeight ); + virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + virtual long CalcTitleWidth() const; + virtual void DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset ); +}; + + +// ======================================================================= + +// --------------------------- +// - ImplStdBorderWindowView - +// --------------------------- + + +class ImplStdBorderWindowView : public ImplBorderWindowView +{ + ImplBorderFrameData maFrameData; + VirtualDevice* mpATitleVirDev; + VirtualDevice* mpDTitleVirDev; + +public: + ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow ); + ~ImplStdBorderWindowView(); + + virtual sal_Bool MouseMove( const MouseEvent& rMEvt ); + virtual sal_Bool MouseButtonDown( const MouseEvent& rMEvt ); + virtual sal_Bool Tracking( const TrackingEvent& rTEvt ); + virtual String RequestHelp( const Point& rPos, Rectangle& rHelpRect ); + virtual Rectangle GetMenuRect() const; + + virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ); + virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + virtual long CalcTitleWidth() const; + virtual void DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset ); +}; + + +#endif // _SV_BRDWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/btndlg.hxx b/vcl/inc/vcl/btndlg.hxx new file mode 100644 index 000000000000..ec537f517374 --- /dev/null +++ b/vcl/inc/vcl/btndlg.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BTNDLG_HXX +#define _SV_BTNDLG_HXX + +#include <boost/ptr_container/ptr_vector.hpp> + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/dialog.hxx> + +struct ImplBtnDlgItem; +class PushButton; + +// ---------------------- +// - ButtonDialog-Types - +// ---------------------- + +#define BUTTONDIALOG_BUTTON_NOTFOUND ((sal_uInt16)0xFFFF) + +#define BUTTONDIALOG_DEFBUTTON ((sal_uInt16)0x0001) +#define BUTTONDIALOG_OKBUTTON ((sal_uInt16)0x0002) +#define BUTTONDIALOG_CANCELBUTTON ((sal_uInt16)0x0004) +#define BUTTONDIALOG_HELPBUTTON ((sal_uInt16)0x0008) +#define BUTTONDIALOG_FOCUSBUTTON ((sal_uInt16)0x0010) + +// ---------------- +// - ButtonDialog - +// ---------------- + +class VCL_DLLPUBLIC ButtonDialog : public Dialog +{ +private: + boost::ptr_vector<ImplBtnDlgItem> maItemList; + Size maPageSize; + Size maCtrlSize; + long mnButtonSize; + sal_uInt16 mnCurButtonId; + sal_uInt16 mnFocusButtonId; + sal_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( Window* pParent, WinBits nStyle = WB_STDDIALOG ); + ButtonDialog( Window* pParent, const ResId& rResId ); + ~ButtonDialog(); + + virtual void Resize(); + virtual void StateChanged( StateChangedType nStateChange ); + + virtual void Click(); + + void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; } + const Size& GetPageSizePixel() const { return maPageSize; } + + sal_uInt16 GetCurButtonId() const { return mnCurButtonId; } + + void AddButton( const XubString& rText, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 ); + void AddButton( StandardButtonType eType, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 ); + void AddButton( PushButton* pBtn, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 ); + void RemoveButton( sal_uInt16 nId ); + void Clear(); + sal_uInt16 GetButtonCount() const; + sal_uInt16 GetButtonId( sal_uInt16 nButton ) const; + PushButton* GetPushButton( sal_uInt16 nId ) const; + void SetButtonText( sal_uInt16 nId, const XubString& rText ); + XubString GetButtonText( sal_uInt16 nId ) const; + void SetButtonHelpText( sal_uInt16 nId, const XubString& rText ); + XubString GetButtonHelpText( sal_uInt16 nId ) const; + void SetButtonHelpId( sal_uInt16 nId, const rtl::OString& rHelpId ); + rtl::OString GetButtonHelpId( sal_uInt16 nId ) const; + + void SetFocusButton( sal_uInt16 nId = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; } + sal_uInt16 GetFocusButton() const { return mnFocusButtonId; } + + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } +}; + +#endif // _SV_BTNDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx new file mode 100644 index 000000000000..9205f9df7661 --- /dev/null +++ b/vcl/inc/vcl/button.hxx @@ -0,0 +1,567 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_BUTTON_HXX +#define _SV_BUTTON_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/image.hxx> +#include <vcl/symbol.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/salnativewidgets.hxx> + +#include <vector> + +class UserDrawEvent; +class ImplCommonButtonData; + +// ---------- +// - Button - +// ---------- + +class VCL_DLLPUBLIC Button : public Control +{ +private: + ImplCommonButtonData *mpButtonData; + Link maClickHdl; + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE Button (const Button &); + SAL_DLLPRIVATE Button & operator= (const Button &); +public: + SAL_DLLPRIVATE sal_uInt16 ImplGetButtonState() const; + SAL_DLLPRIVATE sal_uInt16& ImplGetButtonState(); + SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( XubString& rText, WinBits nWinStyle, sal_uLong nDrawFlags ); + SAL_DLLPRIVATE void ImplDrawAlignedImage( OutputDevice* pDev, Point& rPos, Size& rSize, + sal_Bool bLayout, sal_uLong nImageSep, sal_uLong nDrawFlags, + sal_uInt16 nTextStyle, Rectangle *pSymbolRect=NULL, bool bAddImageSep = false ); + SAL_DLLPRIVATE void ImplSetFocusRect( const Rectangle &rFocusRect ); + SAL_DLLPRIVATE const Rectangle& ImplGetFocusRect() const; + SAL_DLLPRIVATE void ImplSetSymbolAlign( SymbolAlign eAlign ); + SAL_DLLPRIVATE SymbolAlign ImplGetSymbolAlign() const; + SAL_DLLPRIVATE void ImplSetSmallSymbol( sal_Bool bSmall = sal_True ); + SAL_DLLPRIVATE const Rectangle& ImplGetSymbolRect() const; + SAL_DLLPRIVATE void ImplSetSymbolRect(const Rectangle&); + +protected: + Button( WindowType nType ); + +public: + Button( Window* pParent, WinBits nStyle = 0 ); + Button( Window* pParent, const ResId& rResId ); + ~Button(); + + virtual void Click(); + + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } + + static XubString GetStandardText( StandardButtonType eButton ); + static XubString GetStandardHelpText( StandardButtonType eButton ); + + sal_Bool SetModeImage( const Image& rImage ); + const Image GetModeImage( ) const; + sal_Bool HasImage() const; + void SetImageAlign( ImageAlign eAlign ); + ImageAlign GetImageAlign() const; + + sal_Bool SetModeBitmap( const BitmapEx& rBitmap ); + BitmapEx GetModeBitmap( ) const; + + void EnableImageDisplay( sal_Bool bEnable ); + sal_Bool IsImageDisplayEnabled(); + void EnableTextDisplay( sal_Bool bEnable ); + sal_Bool IsTextDisplayEnabled(); + + void SetFocusRect( const Rectangle& rFocusRect ); + const Rectangle& GetFocusRect() const; + void SetSmallSymbol (bool bSmall=true); + bool IsSmallSymbol () const; +}; + +// -------------------- +// - PushButton-Types - +// -------------------- + +#define PUSHBUTTON_DROPDOWN_TOOLBOX ((sal_uInt16)0x0001) +#define PUSHBUTTON_DROPDOWN_MENUBUTTON ((sal_uInt16)0x0002) + +// -------------- +// - PushButton - +// -------------- + +class VCL_DLLPUBLIC PushButton : public Button +{ +protected: + SymbolType meSymbol; + TriState meState; + TriState meSaveValue; + sal_uInt16 mnDDStyle; + sal_Bool mbPressed; + sal_Bool mbInUserDraw; + Link maToggleHdl; + + SAL_DLLPRIVATE void ImplInitPushButtonData(); + SAL_DLLPRIVATE WinBits ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawFlags, + const Rectangle& rRect, bool bLayout, bool bMenuBtnSep ); + SAL_DLLPRIVATE void ImplDrawPushButton( bool bLayout = false ); + using Button::ImplGetTextStyle; + SAL_DLLPRIVATE sal_uInt16 ImplGetTextStyle( sal_uLong nDrawFlags ) const; + SAL_DLLPRIVATE sal_Bool IsSymbol() const { return ( (meSymbol != SYMBOL_NOSYMBOL) && (meSymbol != SYMBOL_IMAGE) ); } + SAL_DLLPRIVATE sal_Bool IsImage() const { return Button::HasImage(); } + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE PushButton( const PushButton & ); + SAL_DLLPRIVATE PushButton& operator=( const PushButton & ); + + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + + using Control::ImplInitSettings; + using Window::ImplInit; +public: + SAL_DLLPRIVATE void ImplSetDefButton( sal_Bool bSet ); + SAL_DLLPRIVATE static void ImplDrawPushButtonFrame( Window* pDev, Rectangle& rRect, sal_uInt16 nStyle ); + SAL_DLLPRIVATE static sal_Bool ImplHitTestPushButton( Window* pDev, const Point& rPos ); + SAL_DLLPRIVATE sal_Bool ImplIsDefButton() const; + +protected: + PushButton( WindowType nType ); + + virtual void FillLayoutData() const; + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; +public: + PushButton( Window* pParent, WinBits nStyle = 0 ); + PushButton( Window* pParent, const ResId& rResId ); + ~PushButton(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + + virtual void Toggle(); + + void SetSymbol( SymbolType eSymbol ); + SymbolType GetSymbol() const { return meSymbol; } + void SetSymbolAlign( SymbolAlign eAlign ); + SymbolAlign GetSymbolAlign() const; + + void SetDropDown( sal_uInt16 nStyle ); + sal_uInt16 GetDropDown() const { return mnDDStyle; } + + void SetState( TriState eState ); + TriState GetState() const { return meState; } + + void Check( sal_Bool bCheck = sal_True ); + sal_Bool IsChecked() const; + + void SetPressed( sal_Bool bPressed ); + sal_Bool IsPressed() const { return mbPressed; } + + void EndSelection(); + + void SaveValue() { meSaveValue = GetState(); } + TriState GetSavedValue() const { return meSaveValue; } + + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + + void SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; } + const Link& GetToggleHdl() const { return maToggleHdl; } +}; + +inline void PushButton::Check( sal_Bool bCheck ) +{ + SetState( (bCheck) ? STATE_CHECK : STATE_NOCHECK ); +} + +inline sal_Bool PushButton::IsChecked() const +{ + return (GetState() == STATE_CHECK); +} + +// ------------ +// - OKButton - +// ------------ + +class VCL_DLLPUBLIC OKButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE OKButton (const OKButton &); + SAL_DLLPRIVATE OKButton & operator= (const OKButton &); + +public: + OKButton( Window* pParent, WinBits nStyle = WB_DEFBUTTON ); + OKButton( Window* pParent, const ResId& rResId ); + + virtual void Click(); +}; + +// ---------------- +// - CancelButton - +// ---------------- + +class VCL_DLLPUBLIC CancelButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE CancelButton (const CancelButton &); + SAL_DLLPRIVATE CancelButton & operator= (const CancelButton &); + +public: + CancelButton( Window* pParent, WinBits nStyle = 0 ); + CancelButton( Window* pParent, const ResId& rResId ); + + virtual void Click(); +}; + +// -------------- +// - HelpButton - +// -------------- + +class VCL_DLLPUBLIC HelpButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE HelpButton( const HelpButton & ); + SAL_DLLPRIVATE HelpButton & operator= ( const HelpButton & ); + +public: + HelpButton( Window* pParent, WinBits nStyle = 0 ); + HelpButton( Window* pParent, const ResId& rResId ); + + virtual void Click(); +}; + +// --------------- +// - RadioButton - +// --------------- + +class VCL_DLLPUBLIC RadioButton : public Button +{ +private: + Rectangle maStateRect; + Rectangle maMouseRect; + Image maImage; + sal_Bool mbChecked; + sal_Bool mbSaveValue; + sal_Bool mbRadioCheck; + sal_Bool mbStateChanged; + Link maToggleHdl; + + SAL_DLLPRIVATE void ImplInitRadioButtonData(); + SAL_DLLPRIVATE WinBits ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDrawRadioButtonState(); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize, + const Size& rImageSize, Rectangle& rStateRect, + Rectangle& rMouseRect, bool bLayout = false ); + SAL_DLLPRIVATE void ImplDrawRadioButton( bool bLayout = false ); + SAL_DLLPRIVATE void ImplInvalidateOrDrawRadioButtonState(); + SAL_DLLPRIVATE void ImplUncheckAllOther(); + SAL_DLLPRIVATE Size ImplGetRadioImageSize() const; + SAL_DLLPRIVATE long ImplGetImageToTextDistance() const; + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE RadioButton(const RadioButton &); + SAL_DLLPRIVATE RadioButton& operator= (const RadioButton &); + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + SAL_DLLPRIVATE void ImplCallClick( sal_Bool bGrabFocus = sal_False, sal_uInt16 nFocusFlags = 0 ); + SAL_DLLPRIVATE void ImplSetMinimumNWFSize(); + +protected: + virtual void FillLayoutData() const; + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + + inline void SetMouseRect( const Rectangle& _rMouseRect ) { maMouseRect = _rMouseRect; } + inline const Rectangle& GetMouseRect( ) const { return maMouseRect; } + inline void SetStateRect( const Rectangle& _rStateRect ) { maStateRect = _rStateRect; } + inline const Rectangle& GetStateRect( ) const { return maStateRect; } + + // draws the radio button (the knob image), in it's current state (pressed/checked) + // at the usual location, which can be overridden with SetStateRect + void DrawRadioButtonState( ); + +public: + RadioButton( Window* pParent, WinBits nWinStyle = 0 ); + RadioButton( Window* pParent, const ResId& rResId ); + ~RadioButton(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + virtual void Toggle(); + + sal_Bool IsStateChanged() const { return mbStateChanged; } + + void EnableRadioCheck( sal_Bool bRadioCheck = sal_True ) { mbRadioCheck = bRadioCheck; } + sal_Bool IsRadioCheckEnabled() const { return mbRadioCheck; } + + sal_Bool SetModeRadioImage( const Image& rImage ); + const Image& GetModeRadioImage( ) const; + + void SetState( sal_Bool bCheck ); + void Check( sal_Bool bCheck = sal_True ); + sal_Bool IsChecked() const { return mbChecked; } + + void SaveValue() { mbSaveValue = IsChecked(); } + sal_Bool GetSavedValue() const { return mbSaveValue; } + + static Image GetRadioImage( const AllSettings& rSettings, sal_uInt16 nFlags ); + + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + + void SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; } + const Link& GetToggleHdl() const { return maToggleHdl; } + + /** GetRadioButtonGroup returns a list of pointers to <code>RadioButton</code>s in the same group. + + The pointers in the returned list are valid at the time call returns. However rescheduling + or giving up the SolarMutex may mean events get executed that lead to the pointers getting + invalid. + + @param io_rGroup + gets cleared on entering the function. on return contains the <code>RadioButton</code>s + in the same group as this <code>RadioButton</code>. + + @param bIncludeThis + defines whether <code>this</code> is contained in the returned list + */ + void GetRadioButtonGroup( std::vector<RadioButton*>& io_rGroup, bool bIncludeThis ) const; +}; + +// ------------ +// - CheckBox - +// ------------ + +class VCL_DLLPUBLIC CheckBox : public Button +{ +private: + Rectangle maStateRect; + Rectangle maMouseRect; + TriState meState; + TriState meSaveValue; + sal_Bool mbTriState; + Link maToggleHdl; + + SAL_DLLPRIVATE void ImplInitCheckBoxData(); + SAL_DLLPRIVATE WinBits ImplInitStyle( const Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplInvalidateOrDrawCheckBoxState(); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize, + const Size& rImageSize, Rectangle& rStateRect, + Rectangle& rMouseRect, bool bLayout ); + SAL_DLLPRIVATE void ImplDrawCheckBox( bool bLayout = false ); + SAL_DLLPRIVATE long ImplGetImageToTextDistance() const; + SAL_DLLPRIVATE Size ImplGetCheckImageSize() const; + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE CheckBox(const CheckBox &); + SAL_DLLPRIVATE CheckBox& operator= (const CheckBox &); + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE virtual void FillLayoutData() const; + SAL_DLLPRIVATE virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + SAL_DLLPRIVATE virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + + 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(); +public: + CheckBox( Window* pParent, WinBits nStyle = 0 ); + CheckBox( Window* pParent, const ResId& rResId ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + virtual void Toggle(); + + void SetState( TriState eState ); + TriState GetState() const { return meState; } + + void Check( sal_Bool bCheck = sal_True ); + sal_Bool IsChecked() const; + + void EnableTriState( sal_Bool bTriState = sal_True ); + sal_Bool IsTriStateEnabled() const { return mbTriState; } + + void SaveValue() { meSaveValue = GetState(); } + TriState GetSavedValue() const { return meSaveValue; } + + static Image GetCheckImage( const AllSettings& rSettings, sal_uInt16 nFlags ); + + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + + void SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; } + const Link& GetToggleHdl() const { return maToggleHdl; } +}; + +inline void CheckBox::Check( sal_Bool bCheck ) +{ + SetState( (bCheck) ? STATE_CHECK : STATE_NOCHECK ); +} + +inline sal_Bool CheckBox::IsChecked() const +{ + return (GetState() == STATE_CHECK); +} + +// --------------------------------- +// - Control-Layer fuer alten Code - +// --------------------------------- + +class VCL_DLLPUBLIC ImageButton : public PushButton +{ +protected: + using PushButton::ImplInitStyle; +private: + SAL_DLLPRIVATE void ImplInitStyle(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ImageButton( const ImageButton & ); + SAL_DLLPRIVATE ImageButton & operator= ( const ImageButton & ); + +protected: + ImageButton( WindowType nType ); + +public: + ImageButton( Window* pParent, WinBits nStyle = 0 ); + ImageButton( Window* pParent, const ResId& rResId ); + ~ImageButton(); +}; + +class VCL_DLLPUBLIC ImageRadioButton : public RadioButton +{ + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ImageRadioButton( const ImageRadioButton & ); + SAL_DLLPRIVATE ImageRadioButton & operator= ( const ImageRadioButton & ); + +public: + ImageRadioButton( Window* pParent, WinBits nStyle = 0 ); + ImageRadioButton( Window* pParent, const ResId& rResId ); + ~ImageRadioButton(); +}; + +class VCL_DLLPUBLIC TriStateBox : public CheckBox +{ + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE TriStateBox( const TriStateBox & ); + SAL_DLLPRIVATE TriStateBox & operator= ( const TriStateBox & ); + +public: + TriStateBox( Window* pParent, WinBits nStyle = 0 ); + TriStateBox( Window* pParent, const ResId& rResId ); + ~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 ); + + virtual void KeyInput( const KeyEvent& rKEvt ); +}; + +#endif // _SV_BUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/canvasbitmap.hxx b/vcl/inc/vcl/canvasbitmap.hxx new file mode 100644 index 000000000000..e0773257b029 --- /dev/null +++ b/vcl/inc/vcl/canvasbitmap.hxx @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_CANVASBITMAP_HXX +#define _VCL_CANVASBITMAP_HXX + +#include <cppuhelper/compbase3.hxx> +#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp> +#include <com/sun/star/rendering/XIntegerBitmapColorSpace.hpp> +#include <com/sun/star/rendering/XIntegerBitmap.hpp> +#include <com/sun/star/rendering/XBitmapPalette.hpp> + +#include <vcl/bitmapex.hxx> +#include <vcl/bmpacc.hxx> + +namespace vcl +{ +namespace unotools +{ + class VCL_DLLPUBLIC VclCanvasBitmap : + public cppu::WeakImplHelper3< com::sun::star::rendering::XIntegerReadOnlyBitmap, + com::sun::star::rendering::XBitmapPalette, + com::sun::star::rendering::XIntegerBitmapColorSpace > + { + private: + BitmapEx m_aBmpEx; + Bitmap m_aBitmap; + Bitmap m_aAlpha; + BitmapReadAccess* m_pBmpAcc; + BitmapReadAccess* m_pAlphaAcc; + com::sun::star::uno::Sequence<sal_Int8> m_aComponentTags; + com::sun::star::uno::Sequence<sal_Int32> m_aComponentBitCounts; + com::sun::star::rendering::IntegerBitmapLayout m_aLayout; + sal_Int32 m_nBitsPerInputPixel; + sal_Int32 m_nBitsPerOutputPixel; + sal_Int32 m_nRedIndex; + sal_Int32 m_nGreenIndex; + sal_Int32 m_nBlueIndex; + sal_Int32 m_nAlphaIndex; + sal_Int32 m_nIndexIndex; + sal_Int8 m_nEndianness; + bool m_bSwap; + bool m_bPalette; + + SAL_DLLPRIVATE void setComponentInfo( sal_uLong redShift, sal_uLong greenShift, sal_uLong blueShift ); + + virtual ~VclCanvasBitmap(); + + public: + // XBitmap + virtual com::sun::star::geometry::IntegerSize2D SAL_CALL getSize() throw (com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL hasAlpha( ) throw (::com::sun::star::uno::RuntimeException); + virtual com::sun::star::uno::Reference< com::sun::star::rendering::XBitmap > SAL_CALL getScaledBitmap( const com::sun::star::geometry::RealSize2D& newSize, sal_Bool beFast ) throw (com::sun::star::uno::RuntimeException); + + // XIntegerReadOnlyBitmap + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > SAL_CALL getPalette( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException); + + // XBitmapPalette + virtual sal_Int32 SAL_CALL getNumberOfEntries() throw (com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getIndex( ::com::sun::star::uno::Sequence< double >& entry, ::sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL setIndex( const ::com::sun::star::uno::Sequence< double >& color, ::sal_Bool transparency, ::sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace > SAL_CALL getColorSpace( ) throw (::com::sun::star::uno::RuntimeException); + + // XIntegerBitmapColorSpace + virtual ::sal_Int8 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getComponentTags( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int8 SAL_CALL getRenderingIntent( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getProperties( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertColorSpace( const ::com::sun::star::uno::Sequence< double >& deviceColor, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace >& targetColorSpace ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor > SAL_CALL convertToRGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertToARGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertToPARGB( const ::com::sun::star::uno::Sequence< double >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromRGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL convertFromPARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getBitsPerPixel( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getComponentBitCounts( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int8 SAL_CALL getEndianness( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence<double> SAL_CALL convertFromIntegerColorSpace( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace >& targetColorSpace ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertToIntegerColorSpace( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor, const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XIntegerBitmapColorSpace >& targetColorSpace ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor > SAL_CALL convertIntegerToRGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertIntegerToARGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor > SAL_CALL convertIntegerToPARGB( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& deviceColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromRGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::RGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertIntegerFromPARGB( const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::ARGBColor >& rgbColor ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + /** Create API wrapper for given BitmapEx + + @param rBitmap + Bitmap to wrap. As usual, changes to the original bitmap + are not reflected in this object (copy on write). + */ + explicit VclCanvasBitmap( const BitmapEx& rBitmap ); + + /// Retrieve contained bitmap. Call me with locked Solar mutex! + BitmapEx getBitmapEx() const; + }; +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/canvastools.hxx b/vcl/inc/vcl/canvastools.hxx new file mode 100644 index 000000000000..e82d397a92f0 --- /dev/null +++ b/vcl/inc/vcl/canvastools.hxx @@ -0,0 +1,256 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_CANVASTOOLS_HXX +#define _VCL_CANVASTOOLS_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/rendering/XColorSpace.hpp> +#include <basegfx/numeric/ftools.hxx> + +#include <vcl/dllapi.h> + +class Point; +class Size; +class Rectangle; +class Polygon; +class PolyPolygon; +class Bitmap; +class BitmapEx; +class Color; + +namespace basegfx +{ + class B2DVector; + class B2DPoint; + class B2DRange; + class B2IVector; + class B2IPoint; + class B2IRange; + class B2DPolygon; + class B2DPolyPolygon; +} + +namespace com { namespace sun { namespace star { namespace geometry +{ + struct RealPoint2D; + struct RealSize2D; + struct RealRectangle2D; + struct IntegerPoint2D; + struct IntegerSize2D; + struct IntegerRectangle2D; + struct RealBezierSegment2D; +} } } } + +namespace com { namespace sun { namespace star { namespace rendering +{ + class XGraphicDevice; + class XBitmap; + class XIntegerBitmap; + class XIntegerReadOnlyBitmap; + class XPolyPolygon2D; +} } } } + +namespace vcl +{ + namespace unotools + { + // Polygon conversions + // =================================================================== + + /** Create an XPolyPolygon from VCL/Tools polygon + */ + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > + VCL_DLLPUBLIC xPolyPolygonFromPolygon( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice, + const ::Polygon& inputPolygon ); + + /** Create an XPolyPolygon from VCL/Tools polyPolygon + */ + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > + VCL_DLLPUBLIC xPolyPolygonFromPolyPolygon( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice, + const ::PolyPolygon& inputPolyPolygon ); + + /** Create an VCL/Tools polygon from a point sequence + */ + ::Polygon VCL_DLLPUBLIC polygonFromPoint2DSequence( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::geometry::RealPoint2D >& rPoints ); + + /** Create an VCL/Tools polyPolygon from a point sequence sequence + */ + ::PolyPolygon VCL_DLLPUBLIC polyPolygonFromPoint2DSequenceSequence( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& rPoints ); + + /** Create an VCL/Tools polygon from a bezier segment sequence + */ + ::Polygon VCL_DLLPUBLIC polygonFromBezier2DSequence( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::geometry::RealBezierSegment2D >& rPoints ); + + /** Create an VCL/Tools polyPolygon from a bezier segment sequence sequence + */ + ::PolyPolygon VCL_DLLPUBLIC polyPolygonFromBezier2DSequenceSequence( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& rPoints ); + + // Bitmap conversions + // =================================================================== + + /** Create an XBitmap from VCL Bitmap + */ + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > + VCL_DLLPUBLIC xBitmapFromBitmap( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice, + const ::Bitmap& inputBitmap ); + + /** Create an XBitmap from VCL BitmapEx + */ + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > + VCL_DLLPUBLIC xBitmapFromBitmapEx( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XGraphicDevice >& xGraphicDevice, + const ::BitmapEx& inputBitmap ); + + /** Create a BitmapEx from an XBitmap + */ + ::BitmapEx VCL_DLLPUBLIC bitmapExFromXBitmap( const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XIntegerReadOnlyBitmap >& xInputBitmap ); + + /** get a unique identifier for identification in XUnoTunnel interface + */ + enum TunnelIdentifierType { Id_BitmapEx = 0 }; + const com::sun::star::uno::Sequence< sal_Int8 > VCL_DLLPUBLIC getTunnelIdentifier( TunnelIdentifierType eType ); + + // Color conversions (vcl/tools Color <-> canvas standard color space) + // =================================================================== + + /** Create a device-specific color sequence from VCL/Tools color + + Note that this method assumes a color space equivalent to + the one returned from createStandardColorSpace() + */ + ::com::sun::star::uno::Sequence< double > + VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor ); + + /** Convert color to device color sequence + + @param rColor + Color to convert + + @param xColorSpace + Color space to convert into + */ + ::com::sun::star::uno::Sequence< double > + VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XColorSpace >& xColorSpace ); + + /** Convert from standard device color space to VCL/Tools color + + Note that this method assumes a color space equivalent to + the one returned from createStandardColorSpace() + */ + Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor( + const ::com::sun::star::uno::Sequence< double >& rColor ); + + /** Convert color to device color sequence + + @param rColor + Color sequence to convert from + + @param xColorSpace + Color space to convert from + */ + Color VCL_DLLPUBLIC doubleSequenceToColor( const ::com::sun::star::uno::Sequence< double > rColor, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XColorSpace >& xColorSpace ); + + /// Convert [0,1] double value to [0,255] int + inline sal_Int8 toByteColor( double val ) + { + return sal::static_int_cast<sal_Int8>( + basegfx::fround(val*255.0)); + } + + /// Convert [0,255] int value to [0,1] double value + inline double toDoubleColor( sal_uInt8 val ) + { + return val / 255.0; + } + + /// Create a standard color space suitable for VCL RGB color + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace(); + + // Geometry conversions (vcl/tools <-> x) + // =================================================================== + + // geometry::Real + ::com::sun::star::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& ); + ::com::sun::star::geometry::RealPoint2D VCL_DLLPUBLIC point2DFromPoint( const Point& ); + ::com::sun::star::geometry::RealRectangle2D VCL_DLLPUBLIC rectangle2DFromRectangle( const Rectangle& ); + + Size VCL_DLLPUBLIC sizeFromRealSize2D( const ::com::sun::star::geometry::RealSize2D& ); + Point VCL_DLLPUBLIC pointFromRealPoint2D( const ::com::sun::star::geometry::RealPoint2D& ); + Rectangle VCL_DLLPUBLIC rectangleFromRealRectangle2D( const ::com::sun::star::geometry::RealRectangle2D& ); + + // geometry::Integer + ::com::sun::star::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& ); + ::com::sun::star::geometry::IntegerPoint2D VCL_DLLPUBLIC integerPoint2DFromPoint( const Point& ); + ::com::sun::star::geometry::IntegerRectangle2D VCL_DLLPUBLIC integerRectangle2DFromRectangle( const Rectangle& ); + + Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const ::com::sun::star::geometry::IntegerSize2D& ); + Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const ::com::sun::star::geometry::IntegerPoint2D& ); + Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const ::com::sun::star::geometry::IntegerRectangle2D& ); + + // basegfx::B2D + Size VCL_DLLPUBLIC sizeFromB2DSize( const ::basegfx::B2DVector& ); + Point VCL_DLLPUBLIC pointFromB2DPoint( const ::basegfx::B2DPoint& ); + Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const ::basegfx::B2DRange& ); + + basegfx::B2DVector VCL_DLLPUBLIC b2DSizeFromSize( const Size& ); + basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& ); + basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const Rectangle& ); + + // basegfx::B2I + Size VCL_DLLPUBLIC sizeFromB2ISize( const ::basegfx::B2IVector& ); + Point VCL_DLLPUBLIC pointFromB2IPoint( const ::basegfx::B2IPoint& ); + Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const ::basegfx::B2IRange& ); + + basegfx::B2IVector VCL_DLLPUBLIC b2ISizeFromSize( const Size& ); + basegfx::B2IPoint VCL_DLLPUBLIC b2IPointFromPoint( const Point& ); + basegfx::B2IRange VCL_DLLPUBLIC b2IRectangleFromRectangle( const Rectangle& ); + } +} + +#endif /* _VCL_CANVASTOOLS_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/cmdevt.h b/vcl/inc/vcl/cmdevt.h new file mode 100644 index 000000000000..0ecf03ca22bb --- /dev/null +++ b/vcl/inc/vcl/cmdevt.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_CMDEVT_H +#define _VCL_CMDEVT_H + +// -------------------- +// - CommandVoiceData - +// -------------------- + +#define DICTATIONCOMMAND_SYSTEM 0x1000 +#define DICTATIONCOMMAND_USER 0x2000 + +#define DICTATIONCOMMAND_UNKNOWN 0x0001 +#define DICTATIONCOMMAND_NEWPARAGRAPH 0x0002 +#define DICTATIONCOMMAND_NEWLINE 0x0003 +#define DICTATIONCOMMAND_BOLD_ON 0x0004 +#define DICTATIONCOMMAND_BOLD_OFF 0x0005 +#define DICTATIONCOMMAND_ITALIC_ON 0x0006 +#define DICTATIONCOMMAND_ITALIC_OFF 0x0007 +#define DICTATIONCOMMAND_UNDERLINE_ON 0x0008 +#define DICTATIONCOMMAND_UNDERLINE_OFF 0x0009 +#define DICTATIONCOMMAND_NUMBERING_ON 0x0010 +#define DICTATIONCOMMAND_NUMBERING_OFF 0x0011 +#define DICTATIONCOMMAND_TAB 0x0012 +#define DICTATIONCOMMAND_LEFT 0x0013 +#define DICTATIONCOMMAND_RIGHT 0x0014 +#define DICTATIONCOMMAND_UP 0x0015 +#define DICTATIONCOMMAND_DOWN 0x0016 +#define DICTATIONCOMMAND_UNDO 0x0017 +#define DICTATIONCOMMAND_REPEAT 0x0018 +#define DICTATIONCOMMAND_DEL 0x0019 + +#define DICTATIONCOMMAND_COMMANDMODE (DICTATIONCOMMAND_SYSTEM + 1) +#define DICTATIONCOMMAND_DICTATIONMODE (DICTATIONCOMMAND_SYSTEM + 2) + +#endif // _VCL_CMDEVT_H + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/cmdevt.hxx b/vcl/inc/vcl/cmdevt.hxx new file mode 100644 index 000000000000..c71160b3fce1 --- /dev/null +++ b/vcl/inc/vcl/cmdevt.hxx @@ -0,0 +1,529 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_CMDEVT_HXX +#define _VCL_CMDEVT_HXX + +#include <tools/gen.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/keycod.hxx> +#include <vcl/font.hxx> + +// --------------------------- +// - CommandExtTextInputData - +// --------------------------- + +#define EXTTEXTINPUT_ATTR_GRAYWAVELINE ((sal_uInt16)0x0100) +#define EXTTEXTINPUT_ATTR_UNDERLINE ((sal_uInt16)0x0200) +#define EXTTEXTINPUT_ATTR_BOLDUNDERLINE ((sal_uInt16)0x0400) +#define EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE ((sal_uInt16)0x0800) +#define EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE ((sal_uInt16)0x1000) +#define EXTTEXTINPUT_ATTR_HIGHLIGHT ((sal_uInt16)0x2000) +#define EXTTEXTINPUT_ATTR_REDTEXT ((sal_uInt16)0x4000) +#define EXTTEXTINPUT_ATTR_HALFTONETEXT ((sal_uInt16)0x8000) + +#define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001) +#define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002) + +class VCL_DLLPUBLIC CommandExtTextInputData +{ +private: + XubString maText; + sal_uInt16* mpTextAttr; + xub_StrLen mnCursorPos; + xub_StrLen mnDeltaStart; + xub_StrLen mnOldTextLen; + sal_uInt16 mnCursorFlags; + sal_Bool mbOnlyCursor; + +public: + CommandExtTextInputData(); + CommandExtTextInputData( const XubString& rText, + const sal_uInt16* pTextAttr, + xub_StrLen nCursorPos, + sal_uInt16 nCursorFlags, + xub_StrLen nDeltaStart, + xub_StrLen nOldTextLen, + sal_Bool bOnlyCursor ); + CommandExtTextInputData( const CommandExtTextInputData& rData ); + ~CommandExtTextInputData(); + + const XubString& GetText() const { return maText; } + const sal_uInt16* GetTextAttr() const { return mpTextAttr; } + sal_uInt16 GetCharTextAttr( sal_uInt16 nIndex ) const; + xub_StrLen GetCursorPos() const { return mnCursorPos; } + sal_Bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; } + sal_Bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; } + sal_uInt16 GetCursorFlags() const { return mnCursorFlags; } + xub_StrLen GetDeltaStart() const { return mnDeltaStart; } + xub_StrLen GetOldTextLen() const { return mnOldTextLen; } + sal_Bool IsOnlyCursorChanged() const { return mbOnlyCursor; } +}; + +inline sal_uInt16 CommandExtTextInputData::GetCharTextAttr( sal_uInt16 nIndex ) const +{ + if ( mpTextAttr && (nIndex < maText.Len()) ) + return mpTextAttr[nIndex]; + else + return 0; +} + +// --------------------------- +// - CommandInputContextData - +// --------------------------- + +class VCL_DLLPUBLIC CommandInputContextData +{ +private: + LanguageType meLanguage; + +public: + CommandInputContextData(); + CommandInputContextData( LanguageType eLang ); + + LanguageType GetLanguage() const { return meLanguage; } +}; + +inline CommandInputContextData::CommandInputContextData() +{ + meLanguage = LANGUAGE_DONTKNOW; +} + +inline CommandInputContextData::CommandInputContextData( LanguageType eLang ) +{ + meLanguage = eLang; +} + +// -------------------- +// - CommandWheelData - +// -------------------- + +#define COMMAND_WHEEL_SCROLL ((sal_uInt16)0x0001) +#define COMMAND_WHEEL_ZOOM ((sal_uInt16)0x0002) +#define COMMAND_WHEEL_DATAZOOM ((sal_uInt16)0x0004) + +#define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF) + +class VCL_DLLPUBLIC CommandWheelData +{ +private: + long mnDelta; + long mnNotchDelta; + sal_uLong mnLines; + sal_uInt16 mnMode; + sal_uInt16 mnCode; + sal_Bool mbHorz; + sal_Bool mbDeltaIsPixel; + +public: + CommandWheelData(); + CommandWheelData( long nWheelDelta, long nWheelNotchDelta, + sal_uLong nScrollLines, + sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier, + sal_Bool bHorz = sal_False, sal_Bool bDeltaIsPixel = sal_False ); + + long GetDelta() const { return mnDelta; } + long GetNotchDelta() const { return mnNotchDelta; } + sal_uLong GetScrollLines() const { return mnLines; } + sal_Bool IsHorz() const { return mbHorz; } + sal_Bool IsDeltaPixel() const { return mbDeltaIsPixel; } + + sal_uInt16 GetMode() const { return mnMode; } + + sal_uInt16 GetModifier() const + { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); } + bool IsShift() const + { return ((mnCode & KEY_SHIFT) != 0); } + sal_Bool IsMod1() const + { return ((mnCode & KEY_MOD1) != 0); } + sal_Bool IsMod2() const + { return ((mnCode & KEY_MOD2) != 0); } + sal_Bool IsMod3() const + { return ((mnCode & KEY_MOD3) != 0); } +}; + +inline CommandWheelData::CommandWheelData() +{ + mnDelta = 0; + mnNotchDelta = 0; + mnLines = 0; + mnMode = 0; + mnCode = 0; + mbHorz = sal_False; + mbDeltaIsPixel = sal_False; +} + +inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta, + sal_uLong nScrollLines, + sal_uInt16 nWheelMode, sal_uInt16 nKeyModifier, + sal_Bool bHorz, sal_Bool bDeltaIsPixel ) +{ + mnDelta = nWheelDelta; + mnNotchDelta = nWheelNotchDelta; + mnLines = nScrollLines; + mnMode = nWheelMode; + mnCode = nKeyModifier; + mbHorz = bHorz; + mbDeltaIsPixel = bDeltaIsPixel; +} + +// --------------------- +// - CommandScrollData - +// --------------------- + +class VCL_DLLPUBLIC CommandScrollData +{ +private: + long mnDeltaX; + long mnDeltaY; + +public: + CommandScrollData(); + CommandScrollData( long nDeltaX, long nDeltaY ); + + long GetDeltaX() const { return mnDeltaX; } + long GetDeltaY() const { return mnDeltaY; } +}; + +inline CommandScrollData::CommandScrollData() +{ + mnDeltaX = 0; + mnDeltaY = 0; +} + +inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY ) +{ + mnDeltaX = nDeltaX; + mnDeltaY = nDeltaY; +} + +// -------------------- +// - CommandVoiceData - +// -------------------- + +enum DictationCommandType +{ + VOICECOMMANDTYPE_DICTATION, + VOICECOMMANDTYPE_CONTROL +}; + +class VCL_DLLPUBLIC CommandVoiceData +{ +private: + XubString maText; + sal_uInt16 mnCommand; + DictationCommandType meType; + +public: + CommandVoiceData(); + CommandVoiceData( const XubString& rStr, + DictationCommandType eType, + sal_uInt16 nCommand ); + + const XubString& GetText() const { return maText; } + sal_uInt16 GetCommand() const { return mnCommand; } + DictationCommandType GetType() const { return meType; } +}; + +inline CommandVoiceData::CommandVoiceData() +{ + meType = VOICECOMMANDTYPE_DICTATION; + mnCommand = 0; +} + +inline CommandVoiceData::CommandVoiceData( const XubString& rStr, + DictationCommandType eType, + sal_uInt16 nCommand ) : + maText( rStr ), + mnCommand( nCommand ), + meType( eType ) +{ +} + +// --------------------- +// - CommandModKeyData - +// --------------------- + +class VCL_DLLPUBLIC CommandModKeyData +{ +private: + sal_uInt16 mnCode; + +public: + CommandModKeyData(); + CommandModKeyData( sal_uInt16 nCode ); + + bool IsShift() const { return (mnCode & MODKEY_SHIFT) ? true : false; } + sal_Bool IsMod1() const { return (mnCode & MODKEY_MOD1) ? sal_True : sal_False; } + sal_Bool IsMod2() const { return (mnCode & MODKEY_MOD2) ? sal_True : sal_False; } + sal_Bool IsMod3() const { return (mnCode & MODKEY_MOD3) ? sal_True : sal_False; } + + sal_Bool IsLeftShift() const { return (mnCode & MODKEY_LSHIFT) ? sal_True : sal_False; } + sal_Bool IsLeftMod1() const { return (mnCode & MODKEY_LMOD1) ? sal_True : sal_False; } + sal_Bool IsLeftMod2() const { return (mnCode & MODKEY_LMOD2) ? sal_True : sal_False; } + sal_Bool IsLeftMod3() const { return (mnCode & MODKEY_LMOD3) ? sal_True : sal_False; } + + sal_Bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) ? sal_True : sal_False; } + sal_Bool IsRightMod1() const { return (mnCode & MODKEY_RMOD1) ? sal_True : sal_False; } + sal_Bool IsRightMod2() const { return (mnCode & MODKEY_RMOD2) ? sal_True : sal_False; } + sal_Bool IsRightMod3() const { return (mnCode & MODKEY_RMOD3) ? sal_True : sal_False; } +}; + +inline CommandModKeyData::CommandModKeyData() +{ + mnCode = 0L; +} + +inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode ) +{ + mnCode = nCode; +} + +// -------------------- +// - CommanDialogData - +// -------------------- + +#define SHOWDIALOG_ID_PREFERENCES 1 +#define SHOWDIALOG_ID_ABOUT 2 + +class VCL_DLLPUBLIC CommandDialogData +{ + int m_nDialogId; + public: + CommandDialogData( int nDialogId = SHOWDIALOG_ID_PREFERENCES ) + : m_nDialogId( nDialogId ) + {} + + int GetDialogId() const { return m_nDialogId; } +}; + +// -------------- +// Media Commands +// -------------- + +#define MEDIA_COMMAND_CHANNEL_DOWN ((sal_Int16)1) // Decrement the channel value, for example, for a TV or radio tuner. +#define MEDIA_COMMAND_CHANNEL_UP ((sal_Int16)2) // Increment the channel value, for example, for a TV or radio tuner. +#define MEDIA_COMMAND_NEXTTRACK ((sal_Int16)3) // Go to next media track/slide. +#define MEDIA_COMMAND_PAUSE ((sal_Int16)4) // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state. +#define MEDIA_COMMAND_PLAY ((sal_Int16)5) // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state. +#define MEDIA_COMMAND_PLAY_PAUSE ((sal_Int16)6) // Play or pause playback. +#define MEDIA_COMMAND_PREVIOUSTRACK ((sal_Int16)7) // Go to previous media track/slide. +#define MEDIA_COMMAND_RECORD ((sal_Int16)8) // Begin recording the current stream. +#define MEDIA_COMMAND_REWIND ((sal_Int16)9)// Go backward in a stream at a higher rate of speed. +#define MEDIA_COMMAND_STOP ((sal_Int16)10)// Stop playback. +#define MEDIA_COMMAND_MIC_ON_OFF_TOGGLE ((sal_Int16)11)// Toggle the microphone. +#define MEDIA_COMMAND_MICROPHONE_VOLUME_DOWN ((sal_Int16)12)// Increase microphone volume. +#define MEDIA_COMMAND_MICROPHONE_VOLUME_MUTE ((sal_Int16)13)// Mute the microphone. +#define MEDIA_COMMAND_MICROPHONE_VOLUME_UP ((sal_Int16)14)// Decrease microphone volume. +#define MEDIA_COMMAND_VOLUME_DOWN ((sal_Int16)15)// Lower the volume. +#define MEDIA_COMMAND_VOLUME_MUTE ((sal_Int16)16)// Mute the volume. +#define MEDIA_COMMAND_VOLUME_UP ((sal_Int16)17)// Raise the volume. +#define MEDIA_COMMAND_MENU ((sal_Int16)18)// Button Menu pressed. +#define MEDIA_COMMAND_MENU_HOLD ((sal_Int16)19)// Button Menu (long) pressed. +#define MEDIA_COMMAND_PLAY_HOLD ((sal_Int16)20)// Button Play (long) pressed. +#define MEDIA_COMMAND_NEXTTRACK_HOLD ((sal_Int16)21)// Button Right holding pressed. +#define MEDIA_COMMAND_PREVIOUSTRACK_HOLD ((sal_Int16)22)// Button Left holding pressed. + + +// ------------------------------ +// - CommandSelectionChangeData - +// ------------------------------ + +class VCL_DLLPUBLIC CommandSelectionChangeData +{ +private: + sal_uLong mnStart; + sal_uLong mnEnd; + +public: + CommandSelectionChangeData(); + CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd ); + + sal_uLong GetStart() const { return mnStart; } + sal_uLong GetEnd() const { return mnEnd; } +}; + +inline CommandSelectionChangeData::CommandSelectionChangeData() +{ + mnStart = mnEnd = 0; +} + +inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, + sal_uLong nEnd ) +{ + mnStart = nStart; + mnEnd = nEnd; +} + +// ---------------- +// - CommandEvent - +// ---------------- + +#define COMMAND_CONTEXTMENU ((sal_uInt16)1) +#define COMMAND_STARTDRAG ((sal_uInt16)2) +#define COMMAND_WHEEL ((sal_uInt16)3) +#define COMMAND_STARTAUTOSCROLL ((sal_uInt16)4) +#define COMMAND_AUTOSCROLL ((sal_uInt16)5) +#define COMMAND_VOICE ((sal_uInt16)6) +#define COMMAND_STARTEXTTEXTINPUT ((sal_uInt16)7) +#define COMMAND_EXTTEXTINPUT ((sal_uInt16)8) +#define COMMAND_ENDEXTTEXTINPUT ((sal_uInt16)9) +#define COMMAND_INPUTCONTEXTCHANGE ((sal_uInt16)10) +#define COMMAND_CURSORPOS ((sal_uInt16)11) +#define COMMAND_PASTESELECTION ((sal_uInt16)12) +#define COMMAND_MODKEYCHANGE ((sal_uInt16)13) +#define COMMAND_HANGUL_HANJA_CONVERSION ((sal_uInt16)14) +#define COMMAND_INPUTLANGUAGECHANGE ((sal_uInt16)15) +#define COMMAND_SHOWDIALOG ((sal_uInt16)16) +#define COMMAND_MEDIA ((sal_uInt16)17) +#define COMMAND_SELECTIONCHANGE ((sal_uInt16)18) +#define COMMAND_PREPARERECONVERSION ((sal_uInt16)19) +#define COMMAND_USER ((sal_uInt16)4096) + +class VCL_DLLPUBLIC CommandEvent +{ +private: + Point maPos; + void* mpData; + sal_uInt16 mnCommand; + sal_Bool mbMouseEvent; + +public: + CommandEvent(); + CommandEvent( const Point& rMousePos, sal_uInt16 nCmd, + sal_Bool bMEvt = sal_False, const void* pCmdData = NULL ); + + sal_uInt16 GetCommand() const { return mnCommand; } + const Point& GetMousePosPixel() const { return maPos; } + sal_Bool IsMouseEvent() const { return mbMouseEvent; } + void* GetData() const { return mpData; } + + const CommandExtTextInputData* GetExtTextInputData() const; + const CommandInputContextData* GetInputContextChangeData() const; + const CommandWheelData* GetWheelData() const; + const CommandScrollData* GetAutoScrollData() const; + const CommandVoiceData* GetVoiceData() const; + const CommandModKeyData* GetModKeyData() const; + const CommandDialogData* GetDialogData() const; + sal_Int16 GetMediaCommand() const; + const CommandSelectionChangeData* GetSelectionChangeData() const; +}; + +inline CommandEvent::CommandEvent() +{ + mpData = NULL; + mnCommand = 0; + mbMouseEvent = sal_False; +} + +inline CommandEvent::CommandEvent( const Point& rMousePos, + sal_uInt16 nCmd, sal_Bool bMEvt, const void* pCmdData ) : + maPos( rMousePos ) +{ + mpData = (void*)pCmdData; + mnCommand = nCmd; + mbMouseEvent = bMEvt; +} + +inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const +{ + if ( mnCommand == COMMAND_EXTTEXTINPUT ) + return (const CommandExtTextInputData*)mpData; + else + return NULL; +} + +inline const CommandInputContextData* CommandEvent::GetInputContextChangeData() const +{ + if ( mnCommand == COMMAND_INPUTCONTEXTCHANGE ) + return (const CommandInputContextData*)mpData; + else + return NULL; +} + +inline const CommandWheelData* CommandEvent::GetWheelData() const +{ + if ( mnCommand == COMMAND_WHEEL ) + return (const CommandWheelData*)mpData; + else + return NULL; +} + +inline const CommandScrollData* CommandEvent::GetAutoScrollData() const +{ + if ( mnCommand == COMMAND_AUTOSCROLL ) + return (const CommandScrollData*)mpData; + else + return NULL; +} + +inline const CommandVoiceData* CommandEvent::GetVoiceData() const +{ + if ( mnCommand == COMMAND_VOICE ) + return (const CommandVoiceData*)mpData; + else + return NULL; +} + +inline const CommandModKeyData* CommandEvent::GetModKeyData() const +{ + if( mnCommand == COMMAND_MODKEYCHANGE ) + return (const CommandModKeyData*)mpData; + else + return NULL; +} + +inline const CommandDialogData* CommandEvent::GetDialogData() const +{ + if( mnCommand == COMMAND_SHOWDIALOG ) + return (const CommandDialogData*)mpData; + else + return NULL; +} + +inline sal_Int16 CommandEvent::GetMediaCommand() const +{ + if( mnCommand == COMMAND_MEDIA ) + return *(const sal_Int16*)(mpData); + else + return 0; +} + +inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const +{ + if( mnCommand == COMMAND_SELECTIONCHANGE ) + return (const CommandSelectionChangeData*)mpData; + else + return NULL; +} + + +#endif // _VCL_CMDEVT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/combobox.h b/vcl/inc/vcl/combobox.h new file mode 100644 index 000000000000..387c20d544be --- /dev/null +++ b/vcl/inc/vcl/combobox.h @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_COMBOBOX_H +#define _SV_COMBOBOX_H + +#define COMBOBOX_APPEND ((sal_uInt16)0xFFFF) +#define COMBOBOX_ENTRY_NOTFOUND ((sal_uInt16)0xFFFF) +#define COMBOBOX_ERROR ((sal_uInt16)0xFFFF) + +#define COMBOBOX_USERDRAW_SELECTED ((sal_uInt16)0x0001) + +#endif // _SV_COMBOBOX_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx new file mode 100644 index 000000000000..12385c9bd9e2 --- /dev/null +++ b/vcl/inc/vcl/combobox.hxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_COMBOBOX_HXX +#define _SV_COMBOBOX_HXX + +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/combobox.h> +#include <vcl/edit.hxx> + +class UserDrawEvent; + +class ImplListBoxFloatingWindow; +class ImplListBox; +class ImplBtn; + +// ------------ +// - ComboBox - +// ------------ + +class VCL_DLLPUBLIC ComboBox : public Edit +{ +private: + Edit* mpSubEdit; + ImplListBox* mpImplLB; + ImplBtn* mpBtn; + ImplListBoxFloatingWindow* mpFloatWin; + sal_uInt16 mnDDHeight; + xub_Unicode mcMultiSep; + sal_Bool mbDDAutoSize : 1; + sal_Bool mbSyntheticModify : 1; + sal_Bool mbMatchCase : 1; + Link maSelectHdl; + Link maDoubleClickHdl; + +private: + SAL_DLLPRIVATE void ImplInitComboBoxData(); + SAL_DLLPRIVATE void ImplUpdateFloatSelection(); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* ); + DECL_DLLPRIVATE_LINK( ImplAutocompleteHdl, Edit* ); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplCalcEditHeight(); + +protected: + ComboBox( WindowType nType ); + sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; } + + virtual void FillLayoutData() const; +public: + ComboBox( Window* pParent, WinBits nStyle = 0 ); + ComboBox( Window* pParent, const ResId& rResId ); + ~ComboBox(); + + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + virtual void Select(); + virtual void DoubleClick(); + + virtual void Modify(); + + virtual const Wallpaper& GetDisplayBackground() const; + + virtual void SetPosSizePixel( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) + { Edit::SetPosSizePixel( rNewPos, rNewSize ); } + void SetDropDownSizePixel( const Size& rNewSize ) + { if( IsDropDownBox() ) SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); } + + Rectangle GetDropDownPosSizePixel() const; + Rectangle GetListPosSizePixel() const; + // returns empty rectangle in DropDown mode, + // else it returns the PosSize of the ListBox + + void SetDropDownLineCount( sal_uInt16 nLines ); + sal_uInt16 GetDropDownLineCount() const; + + void EnableAutoSize( sal_Bool bAuto ); + sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; } + + void EnableDDAutoWidth( sal_Bool b ); + sal_Bool IsDDAutoWidthEnabled() const; + + void SetText( const XubString& rStr ); + void SetText( const XubString& rStr, const Selection& rNewSelection ); + + sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND ); + sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND ); + + void RemoveEntry( const XubString& rStr ); + void RemoveEntry( sal_uInt16 nPos ); + + void Clear(); + + sal_uInt16 GetEntryPos( const XubString& rStr ) const; + sal_uInt16 GetEntryPos( const void* pData ) const; + Image GetEntryImage( sal_uInt16 nPos ) const; + XubString GetEntry( sal_uInt16 nPos ) const; + sal_uInt16 GetEntryCount() const; + + sal_Bool IsTravelSelect() const; + sal_Bool IsInDropDown() const; + void ToggleDropDown(); + + long CalcWindowSizePixel( sal_uInt16 nLines ) const; + + void SetUserItemSize( const Size& rSz ); + const Size& GetUserItemSize() const; + + void EnableUserDraw( sal_Bool bUserDraw ); + sal_Bool IsUserDrawEnabled() const; + + void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False ); + void SetBorderStyle( sal_uInt16 nBorderStyle ); + + void SetSeparatorPos( sal_uInt16 n ); + void SetSeparatorPos(); + sal_uInt16 GetSeparatorPos() const; + + void EnableAutocomplete( sal_Bool bEnable, sal_Bool bMatchCase = sal_False ); + sal_Bool IsAutocompleteEnabled() const; + + void EnableMultiSelection( sal_Bool bMulti ); + sal_Bool IsMultiSelectionEnabled() const; + void SetMultiSelectionSeparator( xub_Unicode cSep ) { mcMultiSep = cSep; } + xub_Unicode GetMultiSelectionSeparator() const { return mcMultiSep; } + + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } + void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } + const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } + + Size CalcMinimumSize() const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + using Edit::CalcSize; + Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep = ';' ); + XubString GetMRUEntries( xub_Unicode cSep = ';' ) const; + void SetMaxMRUCount( sal_uInt16 n ); + sal_uInt16 GetMaxMRUCount() const; + + void SetEntryData( sal_uInt16 nPos, void* pNewData ); + void* GetEntryData( sal_uInt16 nPos ) const; + + void SetTopEntry( sal_uInt16 nPos ); + void ShowProminentEntry( sal_uInt16 nPos ); + sal_uInt16 GetTopEntry() const; + + void SetProminentEntryType( ProminentEntry eType ); + ProminentEntry GetProminentEntryType() const; + + sal_uInt16 GetDisplayLineCount() const; + + sal_uInt16 GetSelectEntryCount() const; + sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const; + sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const; + void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True ); + void SetNoSelection(); + Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; + + /** checks whether a certain point lies within the bounds of + a list item and returns the item as well as the character position + the point is at. + + <p>If the point is inside an item the item pos is put into <code>rPos</code> and + the item-relative character index is returned. If the point is not inside + an item -1 is returned and rPos is unchanged.</p> + + @param rPoint + tells the point for which an item is requested. + + @param rPos + gets the item at the specified point <code>rPoint</code> + + @returns + the item-relative character index at point <code>rPos</code> or -1 + if no item is at that point. + */ + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const; +}; + +#endif // _COMBOBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/configsettings.hxx b/vcl/inc/vcl/configsettings.hxx new file mode 100644 index 000000000000..e9b85d30728e --- /dev/null +++ b/vcl/inc/vcl/configsettings.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef VCL_INC_CONFIGSETTINGS_HXX +#define VCL_INC_CONFIGSETTINGS_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <unotools/configitem.hxx> +#include <vcl/dllapi.h> + +#include <boost/unordered_map.hpp> + +//........................................................................ +namespace vcl +{ +//........................................................................ + + typedef boost::unordered_map< rtl::OUString, rtl::OUString, rtl::OUStringHash > OUStrMap; + class SmallOUStrMap : public OUStrMap { public: SmallOUStrMap() : OUStrMap(1) {} }; + + //==================================================================== + //= SettingsConfigItem + //==================================================================== + class VCL_DLLPUBLIC SettingsConfigItem : public ::utl::ConfigItem + { + + boost::unordered_map< rtl::OUString, SmallOUStrMap, rtl::OUStringHash > m_aSettings; + + virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& rPropertyNames ); + + void getValues(); + SettingsConfigItem(); + public: + virtual ~SettingsConfigItem(); + + static SettingsConfigItem* get(); + + 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(); + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_INC_CONFIGSETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/controldata.hxx b/vcl/inc/vcl/controldata.hxx new file mode 100644 index 000000000000..b30184be2481 --- /dev/null +++ b/vcl/inc/vcl/controldata.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ***********************************************************************/ + +#ifndef VCL_CONTROLDATA_HXX +#define VCL_CONTROLDATA_HXX + +#include <vcl/controllayout.hxx> + +//........................................................................ +namespace vcl +{ +//........................................................................ + + //==================================================================== + //= ImplControlData + //==================================================================== + struct ImplControlData + { + mutable ControlLayoutData* mpLayoutData; + OutputDevice* mpReferenceDevice; + + ImplControlData() + :mpLayoutData( NULL ) + ,mpReferenceDevice( NULL ) + { + } + + ~ImplControlData() + { + delete mpLayoutData; + } + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_CONTROLDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/controllayout.hxx b/vcl/inc/vcl/controllayout.hxx new file mode 100644 index 000000000000..0cad923c6b33 --- /dev/null +++ b/vcl/inc/vcl/controllayout.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_CONTROLLAYOUT_HXX +#define _VCL_CONTROLLAYOUT_HXX + +#include <vector> +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <vcl/dllapi.h> + +class Control; + +namespace vcl +{ + +struct VCL_DLLPUBLIC ControlLayoutData +{ + // contains the string really displayed + // there must be exactly one bounding rectangle in m_aUnicodeBoundRects + // for every character in m_aDisplayText + String m_aDisplayText; + // the bounding rectangle of every character + // where one character may consist of many glyphs + std::vector< Rectangle > m_aUnicodeBoundRects; + // start indices of lines + std::vector< long > m_aLineIndices; + // notify parent control on destruction + const Control* m_pParent; + + ControlLayoutData() : m_pParent( NULL ) {} + ~ControlLayoutData(); + + Rectangle GetCharacterBounds( long nIndex ) const; + // returns the character index for corresponding to rPoint (in control coordinates) + // -1 is returned if no character is at that point + long GetIndexForPoint( const Point& rPoint ) const; + // returns the number of lines in the result of GetDisplayText() + long GetLineCount() const; + // returns the interval [start,end] of line nLine + // returns [-1,-1] for an invalid line + Pair GetLineStartEnd( long nLine ) const; + /** ToRelativeLineIndex changes a layout data index to a count relative to its line. + + <p>This is equivalent to getting the line start/end pairs with + <member>GetLineStartEnd</member> until the index lies within [start,end] of a line + </p> + + @param nIndex + the absolute index inside the display text to be changed to a relative index + + @returns + the relative index inside the displayed line or -1 if the absolute index does + not match any line + */ + long ToRelativeLineIndex( long nIndex ) const; +}; + +} // namespace vcl + +#endif // _VCL_CONTROLLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/ctrl.hxx b/vcl/inc/vcl/ctrl.hxx new file mode 100644 index 000000000000..71d7d88d6003 --- /dev/null +++ b/vcl/inc/vcl/ctrl.hxx @@ -0,0 +1,202 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_CTRL_HXX +#define _SV_CTRL_HXX + +#include <tools/link.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <vcl/salnativewidgets.hxx> + +// forward +namespace vcl { struct ImplControlData; struct ControlLayoutData; } + +// ----------- +// - Control - +// ----------- + +class VCL_DLLPUBLIC Control : public Window +{ +protected: + ::vcl::ImplControlData* mpControlData; + +private: + sal_Bool mbHasFocus; + Link maGetFocusHdl; + Link maLoseFocusHdl; + + SAL_DLLPRIVATE void ImplInitControlData(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE Control (const Control &); + SAL_DLLPRIVATE Control & operator= (const Control &); + +protected: + Control( WindowType nType ); + virtual void FillLayoutData() const; + + // helper method for composite controls + void AppendLayoutData( const Control& rSubControl ) const; + + /// creates the mpData->mpLayoutData structure + void CreateLayoutData() const; + /// determines whether we currently have layout data + bool HasLayoutData() const; + /// returns the current layout data + ::vcl::ControlLayoutData* + GetLayoutData() const; + + /** this calls both our event listeners, and a specified handler + + If the Control instance is destroyed during any of those calls, the + method properly handles this (in particular, it doesn't crash :) + + @param nEvent + the event to notify to our event listeners + @param rHandler + the handler to call + @param pCaller + the parameter to pass to the handler call + @return + if the Control instance has been destroyed in any of the call + */ + sal_Bool ImplCallEventListenersAndHandler( + sal_uLong nEvent, const Link& rHandler, void* pCaller + ); + + /** draws the given text onto the given device + + If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise, + the text will be rendered according to the metrics at the reference device. + + Note that the given rectangle might be modified, it will contain the result of a GetTextRect call (either + directly at the target device, or taking the reference device into account) when returning. + */ + void DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRect, + const XubString& _rStr, sal_uInt16 _nStyle, + MetricVector* _pVector, String* _pDisplayText ) const; + + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + + void ImplInitSettings( const sal_Bool _bFont, const sal_Bool _bForeground ); + +public: + SAL_DLLPRIVATE void ImplClearLayoutData() const; + /** draws a frame around the give rectangle, onto the given device + + only to be used from within the <member>Window::Draw</member> method of your sub class. + + The frame is always drawn with a single line (without 3D effects). In addition, any mono + color set at the control's settings is respected. Yet more additionally, if we're living + in a themed desktop, this theming is ignored. + + Note that this makes sense, since the *only known* clients of <member>Window::Draw</member> + are form controls, when printed or print-previewed. For form controls embedded in office documents, + you don't want to have the theme look. + + @param pDev + the device to draw onto + @param rRect + the rect for drawing the frame. Upon returning from the call, the rect will be inflated + by the space occupied by the drawn pixels. + */ + SAL_DLLPRIVATE void ImplDrawFrame( OutputDevice* pDev, Rectangle& rRect ); + +public: + Control( Window* pParent, WinBits nWinStyle = 0 ); + Control( Window* pParent, const ResId& rResId ); + ~Control(); + + virtual void GetFocus(); + virtual void LoseFocus(); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void Resize(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + // invalidates layout data + virtual void SetText( const String& rStr ); + // gets the displayed text + virtual String GetDisplayText() const; + // returns the bounding box for the character at index nIndex (in control coordinates) + Rectangle GetCharacterBounds( long nIndex ) const; + // returns the character index for corresponding to rPoint (in control coordinates) + // -1 is returned if no character is at that point + long GetIndexForPoint( const Point& rPoint ) const; + // returns the number of lines in the result of GetDisplayText() + long GetLineCount() const; + // returns the interval [start,end] of line nLine + // returns [-1,-1] for an invalid line + Pair GetLineStartEnd( long nLine ) const; + /** ToRelativeLineIndex changes a layout data index to a count relative to its line. + + <p>This is equivalent to getting the line start/end pairs with + <member>GetLineStartEnd</member> until the index lies within [start,end] of a line + </p> + + @param nIndex + the absolute index inside the display text to be changed to a relative index + + @returns + the relative index inside the displayed line or -1 if the absolute index does + not match any line + */ + long ToRelativeLineIndex( long nIndex ) const; + + void SetGetFocusHdl( const Link& rLink ) { maGetFocusHdl = rLink; } + const Link& GetGetFocusHdl() const { return maGetFocusHdl; } + void SetLoseFocusHdl( const Link& rLink ) { maLoseFocusHdl = rLink; } + const Link& GetLoseFocusHdl() const { return maLoseFocusHdl; } + + void SetLayoutDataParent( const Control* pParent ) const; + + virtual Size GetOptimalSize(WindowSizeType eType) const; + + /** sets a reference device used for rendering control text + @seealso DrawControlText + */ + void SetReferenceDevice( OutputDevice* _referenceDevice ); + OutputDevice* GetReferenceDevice() const; + + Font GetUnzoomedControlPointFont() const + { + Font aFont( GetCanonicalFont( GetSettings().GetStyleSettings() ) ); + if ( IsControlFont() ) + aFont.Merge( GetControlFont() ); + return aFont; + } +}; + +#endif // _SV_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/cursor.hxx b/vcl/inc/vcl/cursor.hxx new file mode 100644 index 000000000000..d87d2201bfd4 --- /dev/null +++ b/vcl/inc/vcl/cursor.hxx @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_CURSOR_HXX +#define _SV_CURSOR_HXX + +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +class AutoTimer; +struct ImplCursorData; +class Window; + +// ----------------- +// - Cursor-Styles - +// ----------------- + +#define CURSOR_SHADOW ((sal_uInt16)0x0001) +#define CURSOR_DIRECTION_NONE ((unsigned char)0x00) +#define CURSOR_DIRECTION_LTR ((unsigned char)0x01) +#define CURSOR_DIRECTION_RTL ((unsigned char)0x02) + +// ---------- +// - Cursor - +// ---------- + +class VCL_DLLPUBLIC Cursor +{ +private: + ImplCursorData* mpData; // Interne Daten + Window* mpWindow; // Window (only for shadow cursor) + long mnSlant; // Schraegstellung + long mnOffsetY; // Offset fuer Rotation + Size maSize; // Groesse + Point maPos; // Position + short mnOrientation; // Rotation + sal_uInt16 mnStyle; // Style + sal_Bool mbVisible; // Ist Cursor sichtbar + unsigned char mnDirection; // indicates direction + +public: + SAL_DLLPRIVATE void ImplDraw(); + SAL_DLLPRIVATE void ImplRestore(); + DECL_DLLPRIVATE_LINK( ImplTimerHdl, AutoTimer* ); + SAL_DLLPRIVATE void ImplShow( bool bDrawDirect = true ); + SAL_DLLPRIVATE void ImplHide(); + SAL_DLLPRIVATE void ImplResume( bool bRestore = false ); + SAL_DLLPRIVATE bool ImplSuspend(); + SAL_DLLPRIVATE void ImplNew(); + +public: + Cursor(); + Cursor( const Cursor& rCursor ); + ~Cursor(); + + void SetStyle( sal_uInt16 nStyle ); + sal_uInt16 GetStyle() const { return mnStyle; } + + void Show(); + void Hide(); + sal_Bool IsVisible() const { return mbVisible; } + + void SetWindow( Window* pWindow ); + Window* GetWindow() const { return mpWindow; } + + void SetPos( const Point& rNewPos ); + const Point& GetPos() const { return maPos; } + void SetOffsetY( long mnOffsetY = 0 ); + long GetOffsetY() const { return mnOffsetY; } + + void SetSize( const Size& rNewSize ); + const Size& GetSize() const { return maSize; } + void SetWidth( long nNewWidth ); + long GetWidth() const { return maSize.Width(); } + void SetHeight( long nNewHeight ); + long GetHeight() const { return maSize.Height(); } + + void SetSlant( long nSlant = 0 ); + long GetSlant() const { return mnSlant; } + + void SetOrientation( short nOrientation = 0 ); + short GetOrientation() const { return mnOrientation; } + + void SetDirection( unsigned char nDirection = 0 ); + unsigned char GetDirection() const { return mnDirection; } + + Cursor& operator=( const Cursor& rCursor ); + sal_Bool operator==( const Cursor& rCursor ) const; + sal_Bool operator!=( const Cursor& rCursor ) const + { return !(Cursor::operator==( rCursor )); } + +private: + void ImplDoShow( bool bDrawDirect, bool bRestore ); + bool ImplDoHide( bool bStop ); +}; + +#endif // _SV_CURSOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/cvtgrf.hxx b/vcl/inc/vcl/cvtgrf.hxx new file mode 100644 index 000000000000..50d766f5565c --- /dev/null +++ b/vcl/inc/vcl/cvtgrf.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_CVTGRF_HXX +#define _SV_CVTGRF_HXX + +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <vcl/salctype.hxx> + +// -------------------- +// - GraphicConverter - +// -------------------- + +struct ConvertData; +class Graphic; + +class VCL_DLLPUBLIC GraphicConverter +{ +private: + + Link maFilterHdl; + ConvertData* mpConvertData; + +public: + SAL_DLLPRIVATE sal_uLong ImplConvert( sal_uLong nInFormat, void* pInBuffer, sal_uLong nInBufSize, + void** ppOutBuffer, sal_uLong nOutFormat ); + +public: + + GraphicConverter(); + ~GraphicConverter(); + + static sal_uLong Import( SvStream& rIStm, Graphic& rGraphic, sal_uLong nFormat = CVT_UNKNOWN ); + static sal_uLong Export( SvStream& rOStm, const Graphic& rGraphic, sal_uLong nFormat ); + + ConvertData* GetConvertData() { return mpConvertData; } + + void SetFilterHdl( const Link& rLink ) { maFilterHdl = rLink; } + const Link& GetFilterHdl() const { return maFilterHdl; } +}; + +#endif // _SV_CVTGRF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/cvtsvm.hxx b/vcl/inc/vcl/cvtsvm.hxx new file mode 100644 index 000000000000..de4158e08efc --- /dev/null +++ b/vcl/inc/vcl/cvtsvm.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_CVTMTF_HXX +#define _SV_CVTMTF_HXX + +#include <vcl/dllapi.h> +#include <vcl/metaact.hxx> +#include <vcl/gdimtf.hxx> + +// ----------- +// - Defines - +// ----------- + +#define CONVERT_TO_SVM1 0x00000001UL +#define CONVERT_FROM_SVM1 0x00000002UL + +#define GDI_PIXEL_ACTION 1 +#define GDI_POINT_ACTION 2 +#define GDI_LINE_ACTION 3 +#define GDI_RECT_ACTION 4 +#define GDI_ELLIPSE_ACTION 5 +#define GDI_ARC_ACTION 6 +#define GDI_PIE_ACTION 7 +#define GDI_INVERTRECT_ACTION 8 +#define GDI_HIGHLIGHTRECT_ACTION 9 +#define GDI_POLYLINE_ACTION 10 +#define GDI_POLYGON_ACTION 11 +#define GDI_POLYPOLYGON_ACTION 12 +#define GDI_TEXT_ACTION 13 +#define GDI_TEXTARRAY_ACTION 14 +#define GDI_STRETCHTEXT_ACTION 15 +#define GDI_ICON_ACTION 16 +#define GDI_BITMAP_ACTION 17 +#define GDI_BITMAPSCALE_ACTION 18 +#define GDI_PEN_ACTION 19 +#define GDI_FONT_ACTION 20 +#define GDI_BACKBRUSH_ACTION 21 +#define GDI_FILLBRUSH_ACTION 22 +#define GDI_MAPMODE_ACTION 23 +#define GDI_CLIPREGION_ACTION 24 +#define GDI_RASTEROP_ACTION 25 +#define GDI_PUSH_ACTION 26 +#define GDI_POP_ACTION 27 +#define GDI_MOVECLIPREGION_ACTION 28 +#define GDI_ISECTCLIPREGION_ACTION 29 +#define GDI_MTF_ACTION 30 +#define GDI_BITMAPSCALEPART_ACTION 32 +#define GDI_GRADIENT_ACTION 33 + +#define GDI_TRANSPARENT_COMMENT 1024 +#define GDI_HATCH_COMMENT 1025 +#define GDI_REFPOINT_COMMENT 1026 +#define GDI_TEXTLINECOLOR_COMMENT 1027 +#define GDI_TEXTLINE_COMMENT 1028 +#define GDI_FLOATTRANSPARENT_COMMENT 1029 +#define GDI_GRADIENTEX_COMMENT 1030 +#define GDI_COMMENT_COMMENT 1031 +#define GDI_UNICODE_COMMENT 1032 + +#define GDI_LINEJOIN_ACTION 1033 +#define GDI_EXTENDEDPOLYGON_ACTION 1034 +#define GDI_LINEDASHDOT_ACTION 1035 + +// ---------------- +// - SVMConverter - +// ---------------- + +class Stack; + +class VCL_PLUGIN_PUBLIC SVMConverter +{ +private: + SAL_DLLPRIVATE void ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ); + SAL_DLLPRIVATE void ImplConvertToSVM1( SvStream& rOStm, GDIMetaFile& rMtf ); + SAL_DLLPRIVATE sal_uLong ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, + VirtualDevice& rSaveVDev, sal_Bool& rRop_0_1, + Color& rLineCol, Stack& rLineColStack, + rtl_TextEncoding& rActualCharSet ); + +public: + SVMConverter( SvStream& rIStm, GDIMetaFile& rMtf, sal_uLong nConvertMode ); + ~SVMConverter() {} + +private: + // Not implemented + SVMConverter( const SVMConverter& ); + SVMConverter& operator=( const SVMConverter& ); +}; + +#endif // _SV_CVTMTF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dbggui.hxx b/vcl/inc/vcl/dbggui.hxx new file mode 100644 index 000000000000..61d878de3451 --- /dev/null +++ b/vcl/inc/vcl/dbggui.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_DBGGUI_HXX +#define _SV_DBGGUI_HXX + +#include <vcl/sv.h> + +// ------------ +// - DBG_UITL - +// ------------ + +#ifdef DBG_UTIL + +class Window; +class XubString; + +void DbgGUIInit(); +void DbgGUIDeInit(); +void DbgGUIStart(); +void DbgDialogTest( Window* pWindow ); + +/** registers a named user-defined channel for emitting the diagnostic messages + @return + a unique number for this channel, which can be used for ->DbgData::nErrorOut, + ->DbgData::nWarningOut and ->DbgData::nTraceOut + @see DBG_OUT_USER_CHANNEL_0 +*/ +sal_uInt16 DbgRegisterNamedUserChannel( const XubString& _rChannelUIName, DbgPrintLine pProc ); + +#define DBGGUI_INIT() DbgGUIInit() +#define DBGGUI_DEINIT() DbgGUIDeInit() +#define DBGGUI_START() DbgGUIStart() + +#define DBG_DIALOGTEST( pWindow ) \ + if ( DbgIsDialog() ) \ + DbgDialogTest( pWindow ); + +#else + + +#define DBGGUI_INIT() +#define DBGGUI_DEINIT() +#define DBGGUI_START() + +#define DBG_DIALOGTEST( pWindow ) + +#endif + +#endif // _SV_DBGGUI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/decoview.hxx b/vcl/inc/vcl/decoview.hxx new file mode 100644 index 000000000000..63434bea2830 --- /dev/null +++ b/vcl/inc/vcl/decoview.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_DECOVIEW_HXX +#define _SV_DECOVIEW_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/symbol.hxx> + +class Rectangle; +class Point; +class Color; +class OutputDevice; + +// ------------------------ +// - DecorationView-Types - +// ------------------------ + +// Flags for DrawSymbol() +#define SYMBOL_DRAW_MONO ((sal_uInt16)0x0001) +#define SYMBOL_DRAW_DISABLE ((sal_uInt16)0x0002) + +// Flags for DrawFrame() +#define FRAME_DRAW_IN ((sal_uInt16)0x0001) +#define FRAME_DRAW_OUT ((sal_uInt16)0x0002) +#define FRAME_DRAW_GROUP ((sal_uInt16)0x0003) +#define FRAME_DRAW_DOUBLEIN ((sal_uInt16)0x0004) +#define FRAME_DRAW_DOUBLEOUT ((sal_uInt16)0x0005) +#define FRAME_DRAW_MENU ((sal_uInt16)0x0010) +#define FRAME_DRAW_WINDOWBORDER ((sal_uInt16)0x0020) +#define FRAME_DRAW_BORDERWINDOWBORDER ((sal_uInt16)0x0040) +#define FRAME_DRAW_MONO ((sal_uInt16)0x1000) +#define FRAME_DRAW_NODRAW ((sal_uInt16)0x8000) +#define FRAME_DRAW_STYLE ((sal_uInt16)0x000F) + +// Flags for DrawHighlightFrame() +#define FRAME_HIGHLIGHT_IN ((sal_uInt16)0x0001) +#define FRAME_HIGHLIGHT_OUT ((sal_uInt16)0x0002) +#define FRAME_HIGHLIGHT_TESTBACKGROUND ((sal_uInt16)0x4000) +#define FRAME_HIGHLIGHT_STYLE ((sal_uInt16)0x000F) + +// Flags for DrawButton() +#define BUTTON_DRAW_DEFAULT ((sal_uInt16)0x0001) +#define BUTTON_DRAW_NOLIGHTBORDER ((sal_uInt16)0x0002) +#define BUTTON_DRAW_PRESSED ((sal_uInt16)0x0004) +#define BUTTON_DRAW_CHECKED ((sal_uInt16)0x0008) +#define BUTTON_DRAW_DONTKNOW ((sal_uInt16)0x0010) +#define BUTTON_DRAW_MONO ((sal_uInt16)0x0020) +#define BUTTON_DRAW_NOFILL ((sal_uInt16)0x0040) +#define BUTTON_DRAW_DISABLED ((sal_uInt16)0x0080) +#define BUTTON_DRAW_HIGHLIGHT ((sal_uInt16)0x0100) +#define BUTTON_DRAW_FLAT ((sal_uInt16)0x0200) +#define BUTTON_DRAW_NOTOPLIGHTBORDER ((sal_uInt16)0x0400) +#define BUTTON_DRAW_NOBOTTOMSHADOWBORDER ((sal_uInt16)0x0800) +#define BUTTON_DRAW_NOLEFTLIGHTBORDER ((sal_uInt16)0x1000) +#define BUTTON_DRAW_NOTEXT ((sal_uInt16)0x2000) +#define BUTTON_DRAW_NOIMAGE ((sal_uInt16)0x4000) +#define BUTTON_DRAW_NODRAW ((sal_uInt16)0x8000) + +// ------------------ +// - DecorationView - +// ------------------ + +class VCL_DLLPUBLIC DecorationView +{ +private: + OutputDevice* mpOutDev; + +public: + DecorationView( OutputDevice* pOutDev ) + { mpOutDev = pOutDev; } + + void DrawSymbol( const Rectangle& rRect, SymbolType eType, + const Color& rColor, sal_uInt16 nStyle = 0 ); + void DrawFrame( const Rectangle& rRect, + const Color& rLeftTopColor, + const Color& rRightBottomColor ); + void DrawHighlightFrame( const Rectangle& rRect, + sal_uInt16 nStyle = FRAME_HIGHLIGHT_OUT ); + Rectangle DrawFrame( const Rectangle& rRect, sal_uInt16 nStyle = FRAME_DRAW_OUT ); + Rectangle DrawButton( const Rectangle& rRect, sal_uInt16 nStyle ); + void DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical = true ); +}; + +#endif // _SV_DECOVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx new file mode 100644 index 000000000000..7b8c3ac032f2 --- /dev/null +++ b/vcl/inc/vcl/dialog.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_DIALOG_HXX +#define _SV_DIALOG_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> + +// parameter to pass to the dialogue constructor if really no parent is wanted +// whereas NULL chooses the deafult dialogue parent +#define DIALOG_NO_PARENT ((Window*)0xffffffff) + +// ---------- +// - Dialog - +// ---------- + +struct DialogImpl; + +class VCL_DLLPUBLIC Dialog : public SystemWindow +{ +private: + Window* mpDialogParent; + Dialog* mpPrevExecuteDlg; + DialogImpl* mpDialogImpl; + long mnMousePositioned; + sal_Bool mbInExecute; + sal_Bool mbOldSaveBack; + sal_Bool mbInClose; + sal_Bool mbModalMode; + sal_Int8 mnCancelClose; //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event + + SAL_DLLPRIVATE void ImplInitDialogData(); + SAL_DLLPRIVATE void ImplInitSettings(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE Dialog (const Dialog &); + SAL_DLLPRIVATE Dialog & operator= (const Dialog &); + + DECL_DLLPRIVATE_LINK( ImplAsyncCloseHdl, void* ); +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplCenterDialog(); + +public: + SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } + +protected: + Dialog( WindowType nType ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + +public: + Dialog( Window* pParent, WinBits nStyle = WB_STDDIALOG ); + Dialog( Window* pParent, const ResId& rResId ); + virtual ~Dialog(); + + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual sal_Bool Close(); + + virtual short Execute(); + sal_Bool IsInExecute() const { return mbInExecute; } + + sal_Int8 GetCloseFlag() const { return mnCancelClose; } //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event + void SetCloseFlag( sal_Int8 nCancel ) { mnCancelClose = nCancel; } //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event + + //////////////////////////////////////// + // Dialog::Execute replacement API +public: + // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended + virtual void StartExecuteModal( const Link& rEndDialogHdl ); + sal_Bool IsStartedModal() const; + long GetResult() const; +private: + sal_Bool ImplStartExecuteModal(); + void ImplEndExecuteModal(); +public: + + // Dialog::Execute replacement API + //////////////////////////////////////// + + void EndDialog( long nResult = 0 ); + static void EndAllDialogs( Window* pParent=NULL ); + + void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + + void SetModalInputMode( sal_Bool bModal ); + void SetModalInputMode( sal_Bool bModal, sal_Bool bSubModalDialogs ); + sal_Bool IsModalInputMode() const { return mbModalMode; } + + void GrabFocusToFirstControl(); +}; + +// ------------------ +// - ModelessDialog - +// ------------------ + +class VCL_DLLPUBLIC ModelessDialog : public Dialog +{ + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ModelessDialog (const ModelessDialog &); + SAL_DLLPRIVATE ModelessDialog & operator= (const ModelessDialog &); + +public: + ModelessDialog( Window* pParent, WinBits nStyle = WB_STDMODELESS ); + ModelessDialog( Window* pParent, const ResId& rResId ); +}; + +// --------------- +// - ModalDialog - +// --------------- + +class VCL_DLLPUBLIC ModalDialog : public Dialog +{ +public: + ModalDialog( Window* pParent, WinBits nStyle = WB_STDMODAL ); + ModalDialog( Window* pParent, const ResId& rResId ); + +private: + using Window::Show; + void Show( sal_Bool bVisible = sal_True ); + using Window::Hide; + void Hide(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ModalDialog (const ModalDialog &); + SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &); +}; + +#endif // _SV_DIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/displayconnectiondispatch.hxx b/vcl/inc/vcl/displayconnectiondispatch.hxx new file mode 100644 index 000000000000..fea1d0b7cba9 --- /dev/null +++ b/vcl/inc/vcl/displayconnectiondispatch.hxx @@ -0,0 +1,52 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* 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 +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_VCL_DISPLAYCONNECTIONDISPATCH_HXX +#define INCLUDED_VCL_DISPLAYCONNECTIONDISPATCH_HXX + +#include "sal/config.h" + +#include "com/sun/star/awt/XDisplayConnection.hpp" +#include "cppuhelper/implbase1.hxx" + +namespace vcl { + +class DisplayConnectionDispatch: + public cppu::WeakImplHelper1< com::sun::star::awt::XDisplayConnection > +{ +public: + virtual bool dispatchEvent(void * pData, int nBytes) = 0; + + virtual bool dispatchErrorEvent(void * pData, int nBytes) = 0; + +protected: + virtual ~DisplayConnectionDispatch() {} +}; + +} + +#endif diff --git a/vcl/inc/vcl/dllapi.h b/vcl/inc/vcl/dllapi.h new file mode 100644 index 000000000000..3ec80dd0ec7d --- /dev/null +++ b/vcl/inc/vcl/dllapi.h @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_DLLAPI_H +#define _VCL_DLLAPI_H + +#include "sal/config.h" +#include "sal/types.h" + +#if defined VCL_DLLIMPLEMENTATION +#define VCL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define VCL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#if defined UNX && ! defined MACOS +#define VCL_PLUGIN_PUBLIC VCL_DLLPUBLIC +#else +#define VCL_PLUGIN_PUBLIC SAL_DLLPRIVATE +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dndevdis.hxx b/vcl/inc/vcl/dndevdis.hxx new file mode 100644 index 000000000000..41be5ba3fc38 --- /dev/null +++ b/vcl/inc/vcl/dndevdis.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DNDEVDIS_HXX_ +#define _DNDEVDIS_HXX_ + +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> + +#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> +#include <cppuhelper/implbase3.hxx> +#include <vcl/window.hxx> + +class DNDEventDispatcher: public ::cppu::WeakImplHelper3< + ::com::sun::star::datatransfer::dnd::XDropTargetListener, + ::com::sun::star::datatransfer::dnd::XDropTargetDragContext, + ::com::sun::star::datatransfer::dnd::XDragGestureListener > +{ + Window * m_pTopWindow; + Window * m_pCurrentWindow; + + ::osl::Mutex m_aMutex; + ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > m_aDataFlavorList; + + Window* findTopLevelWindow(Point location); + /* + * fire the events on the dnd listener container of the specified window + */ + + sal_Int32 fireDragEnterEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, + const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction, + const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& aFlavorList ) throw(::com::sun::star::uno::RuntimeException); + + sal_Int32 fireDragOverEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, + const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction ) throw(::com::sun::star::uno::RuntimeException); + + sal_Int32 fireDragExitEvent( Window *pWindow ) throw(::com::sun::star::uno::RuntimeException); + + sal_Int32 fireDropActionChangedEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& xContext, + const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction ) throw(::com::sun::star::uno::RuntimeException); + + sal_Int32 fireDropEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext >& xContext, + const sal_Int8 nDropAction, const Point& rLocation, const sal_Int8 nSourceAction, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable ) throw(::com::sun::star::uno::RuntimeException); + + sal_Int32 fireDragGestureEvent( Window *pWindow, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >& xSource, + const ::com::sun::star::uno::Any event, const Point& rOrigin, const sal_Int8 nDragAction )throw(::com::sun::star::uno::RuntimeException); + +public: + + DNDEventDispatcher( Window * pTopWindow ); + virtual ~DNDEventDispatcher(); + + /* + * XDropTargetDragContext + */ + + virtual void SAL_CALL acceptDrag( sal_Int8 dropAction ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rejectDrag() throw(::com::sun::star::uno::RuntimeException); + + /* + * XDropTargetListener + */ + + virtual void SAL_CALL drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(::com::sun::star::uno::RuntimeException); + + /* + * XDragGestureListener + */ + + virtual void SAL_CALL dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw(::com::sun::star::uno::RuntimeException); + + + /* + * XEventListener + */ + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& eo ) throw(::com::sun::star::uno::RuntimeException); +}; + +//================================================================================================== +// +//================================================================================================== + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dndhelp.hxx b/vcl/inc/vcl/dndhelp.hxx new file mode 100644 index 000000000000..73adc8a4508a --- /dev/null +++ b/vcl/inc/vcl/dndhelp.hxx @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_DNDHELP_HXX +#define _VCL_DNDHELP_HXX + +#include <vcl/dllapi.h> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> + +namespace com { +namespace sun { +namespace star { + +namespace datatransfer { +namespace dnd { + struct DragGestureEvent; + struct DragSourceDragEvent; + struct DragSourceDropEvent; + struct DragSourceEvent; + struct DropTargetDragEvent; + struct DropTargetDragEnterEvent; + struct DropTargetDropEvent; + struct DropTargetEvent; +}} + +}}} + +namespace vcl +{ + +namespace unohelper +{ + +class VCL_DLLPUBLIC DragAndDropClient +{ +public: + virtual ~DragAndDropClient(); + + // ::com::sun::star::datatransfer::dnd::XDragGestureListener + virtual void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::datatransfer::dnd::XDragSourceListener + virtual void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragEnter( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragExit( const ::com::sun::star::datatransfer::dnd::DragSourceEvent& dse ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragOver( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dropActionChanged( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::datatransfer::dnd::XDropTargetListener + virtual void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); +}; + +class VCL_DLLPUBLIC DragAndDropWrapper : + public ::com::sun::star::datatransfer::dnd::XDragGestureListener, + public ::com::sun::star::datatransfer::dnd::XDragSourceListener, + public ::com::sun::star::datatransfer::dnd::XDropTargetListener, + public ::cppu::OWeakObject +{ +private: + DragAndDropClient* mpClient; + +public: + DragAndDropWrapper( DragAndDropClient* pClient ); + ~DragAndDropWrapper(); + + // ::com::sun::star::uno::XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + void SAL_CALL release() throw() { OWeakObject::release(); } + + // ::com::sun::star::lang::XEventListener + void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::datatransfer::dnd::XDragGestureListener + void SAL_CALL dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::datatransfer::dnd::XDragSourceListener + void SAL_CALL dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DragSourceEvent& dse ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DragSourceDragEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::datatransfer::dnd::XDropTargetListener + void SAL_CALL drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL dropActionChanged( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); +}; + +}} // namespace vcl::unohelper + +#endif // _VCL_DNDHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dndlcon.hxx b/vcl/inc/vcl/dndlcon.hxx new file mode 100644 index 000000000000..1c3654c1a9ea --- /dev/null +++ b/vcl/inc/vcl/dndlcon.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DNDLCON_HXX_ +#define _DNDLCON_HXX_ + +#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetDropContext.hpp> +#include <cppuhelper/compbase4.hxx> + +#include <vcl/unohelp2.hxx> + +class DNDListenerContainer : public ::vcl::unohelper::MutexHelper, + public ::cppu::WeakComponentImplHelper4< + ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer, \ + ::com::sun::star::datatransfer::dnd::XDropTargetDragContext, + ::com::sun::star::datatransfer::dnd::XDropTargetDropContext, + ::com::sun::star::datatransfer::dnd::XDropTarget > +{ + sal_Bool m_bActive; + sal_Int8 m_nDefaultActions; + + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext > m_xDropTargetDragContext; + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext > m_xDropTargetDropContext; + +public: + + DNDListenerContainer( sal_Int8 nDefaultActions ); + virtual ~DNDListenerContainer(); + + sal_uInt32 fireDropEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDropContext >& context, + sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& transferable ); + + sal_uInt32 fireDragExitEvent(); + + sal_uInt32 fireDragOverEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, + sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions ); + + sal_uInt32 fireDragEnterEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, + sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions, + const ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor >& dataFlavor ); + + sal_uInt32 fireDropActionChangedEvent( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetDragContext >& context, + sal_Int8 dropAction, sal_Int32 locationX, sal_Int32 locationY, sal_Int8 sourceActions ); + + sal_uInt32 fireDragGestureEvent( + sal_Int8 dragAction, sal_Int32 dragOriginX, sal_Int32 dragOriginY, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >& dragSource, + const ::com::sun::star::uno::Any& triggerEvent ); + + /* + * XDragGestureRecognizer + */ + + virtual void SAL_CALL addDragGestureListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureListener >& dgl ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDragGestureListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureListener >& dgl ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL resetRecognizer( ) throw(::com::sun::star::uno::RuntimeException); + + /* + * XDropTargetDragContext + */ + + virtual void SAL_CALL acceptDrag( sal_Int8 dragOperation ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rejectDrag( ) throw (::com::sun::star::uno::RuntimeException); + + + /* + * XDropTargetDropContext + */ + + virtual void SAL_CALL acceptDrop( sal_Int8 dropOperation ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rejectDrop( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dropComplete( sal_Bool success ) throw (::com::sun::star::uno::RuntimeException); + + /* + * XDropTarget + */ + + virtual void SAL_CALL addDropTargetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDropTargetListener( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& dtl ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isActive( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActive( sal_Bool active ) throw(::com::sun::star::uno::RuntimeException); + virtual sal_Int8 SAL_CALL getDefaultActions( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(::com::sun::star::uno::RuntimeException); +}; + + +//================================================================================================== +// +//================================================================================================== + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dockingarea.hxx b/vcl/inc/vcl/dockingarea.hxx new file mode 100644 index 000000000000..7ba82d380f58 --- /dev/null +++ b/vcl/inc/vcl/dockingarea.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_DOCKINGAREA_HXX +#define _SV_DOCKINGAREA_HXX + +#include <vcl/sv.h> +#include <vcl/window.hxx> + +// ------------------------------------------ +// A simple container for docked toolbars +// - its main purpose is theming support +// ------------------------------------------ + +class VCL_DLLPUBLIC DockingAreaWindow : public Window +{ + class ImplData; + +private: + ImplData* mpImplData; + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE DockingAreaWindow (const DockingAreaWindow &); + SAL_DLLPRIVATE DockingAreaWindow & operator= (const DockingAreaWindow &); + +public: + DockingAreaWindow( Window *pParent ); + ~DockingAreaWindow(); + + void SetAlign( WindowAlign eNewAlign ); + WindowAlign GetAlign() const; + sal_Bool IsHorizontal() const; + + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void StateChanged( StateChangedType nType ); + +}; + +#endif // _SV_SYSWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/dockwin.hxx b/vcl/inc/vcl/dockwin.hxx new file mode 100644 index 000000000000..5721d979b188 --- /dev/null +++ b/vcl/inc/vcl/dockwin.hxx @@ -0,0 +1,453 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_DOCKWIN_HXX +#define _SV_DOCKWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/floatwin.hxx> +#include <vector> + +// data to be sent with docking events +struct DockingData +{ + Point maMousePos; // in + Rectangle maTrackRect; // in/out + sal_Bool mbFloating; // out + sal_Bool mbLivemode; // in + sal_Bool mbInteractive; // in + + DockingData() {}; + DockingData( const Point& rPt, const Rectangle& rRect, sal_Bool b) : + maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ), mbLivemode( sal_False ), mbInteractive( sal_True ) + {}; +}; + +struct EndDockingData +{ + Rectangle maWindowRect; // in + sal_Bool mbFloating; // in + sal_Bool mbCancelled; // in + + EndDockingData() {}; + EndDockingData( const Rectangle& rRect, sal_Bool b, sal_Bool bCancelled ) : + maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled ) + {}; +}; + +struct EndPopupModeData +{ + Point maFloatingPos; // in + sal_Bool mbTearoff; // in + + EndPopupModeData() {}; + EndPopupModeData( const Point& rPos, sal_Bool bTearoff ) : + maFloatingPos( rPos ), mbTearoff( bTearoff ) + {}; +}; + +/** ImplDockingWindowWrapper + * + * ImplDockingWindowWrapper obsoletes the DockingWindow class. + * It is better because it can make a "normal window" dockable. + * All DockingWindows should be converted the new class. + */ + +class ImplDockingWindowWrapper +{ + friend class Window; + friend class DockingManager; + friend class DockingWindow; + +private: + + // the original 'Docking'window + Window *mpDockingWindow; + + // the original DockingWindow members + FloatingWindow* mpFloatWin; + Window* mpOldBorderWin; + Window* mpParent; + Point maFloatPos; + Point maDockPos; + Point maMouseOff; + Point maMouseStart; + Size maRollUpOutSize; + Size maMinOutSize; + Size maMaxOutSize; + Rectangle maDragArea; + long mnTrackX; + long mnTrackY; + long mnTrackWidth; + long mnTrackHeight; + sal_Int32 mnDockLeft; + sal_Int32 mnDockTop; + sal_Int32 mnDockRight; + sal_Int32 mnDockBottom; + WinBits mnFloatBits; + sal_Bool mbDockCanceled:1, + mbFloatPrevented:1, + mbDockable:1, + mbDocking:1, + mbDragFull:1, + mbLastFloatMode:1, + mbStartFloat:1, + mbTrackDock:1, + mbPined:1, + mbRollUp:1, + mbDockBtn:1, + mbHideBtn:1, + mbStartDockingEnabled:1, + mbLocked:1; + + void ImplInitData(); + + DECL_LINK( PopupModeEnd, void* ); + void ImplEnableStartDocking( sal_Bool bEnable = sal_True ) { mbStartDockingEnabled = bEnable; } + sal_Bool ImplStartDockingEnabled() { return mbStartDockingEnabled; } + +public: + ImplDockingWindowWrapper( const Window *pWindow ); + virtual ~ImplDockingWindowWrapper(); + + Window* GetWindow() { return mpDockingWindow; } + sal_Bool ImplStartDocking( const Point& rPos ); + + // those methods actually call the corresponding handlers + void StartDocking( const Point& rPos, Rectangle& rRect ); + sal_Bool Docking( const Point& rPos, Rectangle& rRect ); + void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ); + sal_Bool PrepareToggleFloatingMode(); + void ToggleFloatingMode(); + + void SetDragArea( const Rectangle& rRect ); + Rectangle GetDragArea() const; + + void Lock(); + void Unlock(); + sal_Bool IsLocked() const; + + void StartPopupMode( ToolBox* pParentToolBox, sal_uLong nPopupModeFlags ); + sal_Bool IsInPopupMode() const; + + void TitleButtonClick( sal_uInt16 nButton ); + void Pin(); + void Roll(); + void PopupModeEnd(); + void Resizing( Size& rSize ); + sal_Bool Close(); + void Tracking( const TrackingEvent& rTEvt ); + long Notify( NotifyEvent& rNEvt ); + + void ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible = sal_True ); + sal_Bool IsTitleButtonVisible( sal_uInt16 nButton ) const; + + void SetPin( sal_Bool bPin ); + sal_Bool IsPined() const; + + void RollUp(); + void RollDown(); + sal_Bool IsRollUp() const; + + void SetRollUpOutputSizePixel( const Size& rSize ); + Size GetRollUpOutputSizePixel() const; + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const; + + void SetMaxOutputSizePixel( const Size& rSize ); + const Size& GetMaxOutputSizePixel() const; + + sal_Bool IsDocking() const { return mbDocking; } + sal_Bool IsDockable() const { return mbDockable; } + sal_Bool IsDockingCanceled() const { return mbDockCanceled; } + sal_Bool IsFloatingPrevented() const { return mbFloatPrevented; } + + void SetFloatingMode( sal_Bool bFloatMode = sal_False ); + sal_Bool IsFloatingMode() const; + FloatingWindow* GetFloatingWindow() const { return mpFloatWin; } + + void SetFloatingPos( const Point& rNewPos ); + Point GetFloatingPos() const; + + void SetFloatStyle( WinBits nWinStyle ); + WinBits GetFloatStyle() const; + void SetTabStop(); + + virtual void SetPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + void SetPosSizePixel( const Point& rNewPos, + const Size& rNewSize ) + { mpDockingWindow->SetPosSizePixel( rNewPos, rNewSize ); } + Point GetPosPixel() const; + Size GetSizePixel() const; + void SetOutputSizePixel( const Size& rNewSize ); + Size GetOutputSizePixel() const; +}; + +class VCL_DLLPUBLIC DockingManager +{ +protected: + ::std::vector<ImplDockingWindowWrapper *> mDockingWindows; + +public: + DockingManager(); + ~DockingManager(); + + void AddWindow( const Window *pWin ); + void RemoveWindow( const Window *pWin ); + + ImplDockingWindowWrapper* GetDockingWindowWrapper( const Window *pWin ); + sal_Bool IsDockable( const Window *pWin ); + + sal_Bool IsFloating( const Window *pWin ); + void SetFloatingMode( const Window *pWin, sal_Bool bFloating ); + + void Lock( const Window *pWin ); + void Unlock( const Window *pWin ); + sal_Bool IsLocked( const Window *pWin ); + + void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin ); + void StartPopupMode( ToolBox *pParentToolBox, const Window *pWin, sal_uLong nPopupModeFlags ); + + sal_Bool IsInPopupMode( const Window *pWin ); + void EndPopupMode( const Window *pWin ); + + // required because those methods are not virtual in Window (!!!) and must + // be availbale from the toolkit + void SetPosSizePixel( Window *pWin, long nX, long nY, + long nWidth, long nHeight, + sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + Rectangle GetPosSizePixel( const Window *pWin ); +}; + +// ----------------- +// - DockingWindow - +// ----------------- + +class VCL_DLLPUBLIC DockingWindow : public Window +{ + class ImplData; +private: + FloatingWindow* mpFloatWin; + Window* mpOldBorderWin; + ImplData* mpImplData; + Point maFloatPos; + Point maDockPos; + Point maMouseOff; + Point maMouseStart; + Size maRollUpOutSize; + Size maMinOutSize; + long mnTrackX; + long mnTrackY; + long mnTrackWidth; + long mnTrackHeight; + sal_Int32 mnDockLeft; + sal_Int32 mnDockTop; + sal_Int32 mnDockRight; + sal_Int32 mnDockBottom; + WinBits mnFloatBits; + sal_Bool mbDockCanceled:1, + mbDockPrevented:1, + mbFloatPrevented:1, + mbDockable:1, + mbDocking:1, + mbDragFull:1, + mbLastFloatMode:1, + mbStartFloat:1, + mbTrackDock:1, + mbPined:1, + mbRollUp:1, + mbDockBtn:1, + mbHideBtn:1; + + SAL_DLLPRIVATE void ImplInitDockingWindowData(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE DockingWindow (const DockingWindow &); + SAL_DLLPRIVATE DockingWindow & operator= (const DockingWindow &); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + SAL_DLLPRIVATE sal_Bool ImplStartDocking( const Point& rPos ); + +protected: + DockingWindow( WindowType nType ); + +public: + DockingWindow( Window* pParent, WinBits nStyle = WB_STDDOCKWIN ); + DockingWindow( Window* pParent, const ResId& rResId ); + ~DockingWindow(); + + virtual void StartDocking(); + virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect ); + virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ); + virtual sal_Bool PrepareToggleFloatingMode(); + virtual void ToggleFloatingMode(); + + virtual void TitleButtonClick( sal_uInt16 nButton ); + virtual void Pin(); + virtual void Roll(); + virtual void PopupModeEnd(); + virtual void Resizing( Size& rSize ); + virtual sal_Bool Close(); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible = sal_True ); + sal_Bool IsTitleButtonVisible( sal_uInt16 nButton ) const; + + void SetPin( sal_Bool bPin ); + sal_Bool IsPined() const; + + void RollUp(); + void RollDown(); + sal_Bool IsRollUp() const; + + void SetRollUpOutputSizePixel( const Size& rSize ); + Size GetRollUpOutputSizePixel() const; + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const; + + void SetMaxOutputSizePixel( const Size& rSize ); + const Size& GetMaxOutputSizePixel() const; + + sal_Bool IsDocking() const { return mbDocking; } + sal_Bool IsDockable() const { return mbDockable; } + sal_Bool IsDockingCanceled() const { return mbDockCanceled; } + sal_Bool IsDockingPrevented() const { return mbDockPrevented; } + sal_Bool IsFloatingPrevented() const { return mbFloatPrevented; } + + void SetFloatingMode( sal_Bool bFloatMode = sal_False ); + sal_Bool IsFloatingMode() const; + FloatingWindow* GetFloatingWindow() const { return mpFloatWin; } + + void SetFloatingPos( const Point& rNewPos ); + Point GetFloatingPos() const; + + void SetFloatStyle( WinBits nWinStyle ); + WinBits GetFloatStyle() const; + void SetTabStop(); + + virtual void SetPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + void SetPosSizePixel( const Point& rNewPos, + const Size& rNewSize ) + { Window::SetPosSizePixel( rNewPos, rNewSize ); } + Point GetPosPixel() const; + Size GetSizePixel() const; + void SetOutputSizePixel( const Size& rNewSize ); + Size GetOutputSizePixel() const; +}; + +inline void DockingWindow::SetPin( sal_Bool bPin ) +{ + if ( mpFloatWin ) + mpFloatWin->SetPin( bPin ); + mbPined = bPin; +} + +inline sal_Bool DockingWindow::IsPined() const +{ + if ( mpFloatWin ) + return mpFloatWin->IsPined(); + return mbPined; +} + +inline void DockingWindow::RollUp() +{ + if ( mpFloatWin ) + mpFloatWin->RollUp(); + mbRollUp = sal_True; +} + +inline void DockingWindow::RollDown() +{ + if ( mpFloatWin ) + mpFloatWin->RollDown(); + mbRollUp = sal_False; +} + +inline sal_Bool DockingWindow::IsRollUp() const +{ + if ( mpFloatWin ) + return mpFloatWin->IsRollUp(); + return mbRollUp; +} + +inline void DockingWindow::SetRollUpOutputSizePixel( const Size& rSize ) +{ + if ( mpFloatWin ) + mpFloatWin->SetRollUpOutputSizePixel( rSize ); + maRollUpOutSize = rSize; +} + +inline Size DockingWindow::GetRollUpOutputSizePixel() const +{ + if ( mpFloatWin ) + return mpFloatWin->GetRollUpOutputSizePixel(); + return maRollUpOutSize; +} + +inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize ) +{ + if ( mpFloatWin ) + mpFloatWin->SetMinOutputSizePixel( rSize ); + maMinOutSize = rSize; +} + +inline const Size& DockingWindow::GetMinOutputSizePixel() const +{ + if ( mpFloatWin ) + return mpFloatWin->GetMinOutputSizePixel(); + return maMinOutSize; +} + +inline void DockingWindow::SetFloatingPos( const Point& rNewPos ) +{ + if ( mpFloatWin ) + mpFloatWin->SetPosPixel( rNewPos ); + else + maFloatPos = rNewPos; +} + + +#endif // _SV_DOCKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/edit.hxx b/vcl/inc/vcl/edit.hxx new file mode 100644 index 000000000000..0263daa5a427 --- /dev/null +++ b/vcl/inc/vcl/edit.hxx @@ -0,0 +1,267 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_EDIT_HXX +#define _SV_EDIT_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/menu.hxx> +#include <vcl/dndhelp.hxx> +#include <com/sun/star/uno/Reference.h> + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XExtendedInputSequenceChecker; +}}}} + +class ImplSubEdit; +struct DDInfo; +struct Impl_IMEInfos; + +// -------------- +// - Edit-Types - +// -------------- + +#define EDIT_NOLIMIT STRING_LEN +#define EDIT_UPDATEDATA_TIMEOUT 350 + +typedef XubString (*FncGetSpecialChars)( Window* pWin, const Font& rFont ); + +// -------- +// - Edit - +// -------- + +enum AutocompleteAction{ AUTOCOMPLETE_KEYINPUT, AUTOCOMPLETE_TABFORWARD, AUTOCOMPLETE_TABBACKWARD }; + +class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient +{ +private: + Edit* mpSubEdit; + Timer* mpUpdateDataTimer; + DDInfo* mpDDInfo; + Impl_IMEInfos* mpIMEInfos; + XubString maText; + XubString maSaveValue; + XubString maUndoText; + XubString maRedoText; + long mnXOffset; + Selection maSelection; + sal_uInt16 mnAlign; + xub_StrLen mnMaxTextLen; + AutocompleteAction meAutocompleteAction; + xub_Unicode mcEchoChar; + sal_Bool mbModified:1, + mbInternModified:1, + mbReadOnly:1, + mbInsertMode:1, + mbClickedInSelection:1, + mbIsSubEdit:1, + mbInMBDown:1, + mbActivePopup:1; + Link maModifyHdl; + Link maUpdateDataHdl; + Link maAutocompleteHdl; + + DECL_DLLPRIVATE_LINK( ImplUpdateDataHdl, Timer* ); + + SAL_DLLPRIVATE bool ImplTruncateToMaxLen( rtl::OUString&, sal_uInt32 nSelectionLen ) const; + SAL_DLLPRIVATE void ImplInitEditData(); + SAL_DLLPRIVATE void ImplModified(); + SAL_DLLPRIVATE XubString ImplGetText() const; + SAL_DLLPRIVATE void ImplRepaint( xub_StrLen nStart = 0, xub_StrLen nEnd = STRING_LEN, bool bLayout = false ); + SAL_DLLPRIVATE void ImplInvalidateOrRepaint( xub_StrLen nStart = 0, xub_StrLen nEnd = STRING_LEN ); + SAL_DLLPRIVATE void ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode ); + SAL_DLLPRIVATE void ImplSetText( const XubString& rStr, const Selection* pNewSelection = 0 ); + SAL_DLLPRIVATE void ImplInsertText( const XubString& rStr, const Selection* pNewSelection = 0, sal_Bool bIsUserInput = sal_False ); + SAL_DLLPRIVATE String ImplGetValidString( const String& rString ) const; + SAL_DLLPRIVATE void ImplClearBackground( long nXStart, long nXEnd ); + SAL_DLLPRIVATE void ImplShowCursor( sal_Bool bOnlyIfVisible = sal_True ); + SAL_DLLPRIVATE void ImplAlign(); + SAL_DLLPRIVATE void ImplAlignAndPaint(); + SAL_DLLPRIVATE xub_StrLen ImplGetCharPos( const Point& rWindowPos ) const; + SAL_DLLPRIVATE void ImplSetCursorPos( xub_StrLen nChar, sal_Bool bSelect ); + SAL_DLLPRIVATE void ImplShowDDCursor(); + SAL_DLLPRIVATE void ImplHideDDCursor(); + SAL_DLLPRIVATE sal_Bool ImplHandleKeyEvent( const KeyEvent& rKEvt ); + SAL_DLLPRIVATE void ImplCopyToSelectionClipboard(); + 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; + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplSetSelection( const Selection& rSelection, sal_Bool bPaint = sal_True ); + SAL_DLLPRIVATE int ImplGetNativeControlType(); + static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder( Window* pWin ); + + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener > mxDnDListener; + + // DragAndDropClient + using vcl::unohelper::DragAndDropClient::dragEnter; + using vcl::unohelper::DragAndDropClient::dragExit; + using vcl::unohelper::DragAndDropClient::dragOver; + virtual void dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException); + virtual void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException); + virtual void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException); + + protected: + virtual void FillLayoutData() const; + + Edit( WindowType nType ); + +public: + // public because needed in button.cxx + SAL_DLLPRIVATE bool ImplUseNativeBorder( WinBits nStyle ); + + Edit( Window* pParent, WinBits nStyle = WB_BORDER ); + Edit( Window* pParent, const ResId& rResId ); + Edit( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabeledByRelation ); + virtual ~Edit(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual Window* GetPreferredKeyInputWindow(); + + virtual void Modify(); + virtual void UpdateData(); + + static sal_Bool IsCharInput( const KeyEvent& rKEvt ); + + virtual void SetModifyFlag(); + virtual void ClearModifyFlag(); + virtual sal_Bool IsModified() const { return mpSubEdit ? mpSubEdit->mbModified : mbModified; } + + virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ); + virtual void DisableUpdateData() { delete mpUpdateDataTimer; mpUpdateDataTimer = NULL; } + virtual sal_uLong IsUpdateDataEnabled() const; + + void SetEchoChar( xub_Unicode c ); + xub_Unicode GetEchoChar() const { return mcEchoChar; } + + virtual void SetReadOnly( sal_Bool bReadOnly = sal_True ); + virtual sal_Bool IsReadOnly() const { return mbReadOnly; } + + void SetInsertMode( sal_Bool bInsert ); + sal_Bool IsInsertMode() const; + + virtual void SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT ); + virtual xub_StrLen GetMaxTextLen() const { return mnMaxTextLen; } + + virtual void SetSelection( const Selection& rSelection ); + virtual const Selection& GetSelection() const; + + virtual void ReplaceSelected( const XubString& rStr ); + virtual void DeleteSelected(); + virtual XubString GetSelected() const; + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + void Undo(); + + virtual void SetText( const XubString& rStr ); + virtual void SetText( const XubString& rStr, const Selection& rNewSelection ); + virtual XubString GetText() const; + + void SaveValue() { maSaveValue = GetText(); } + const XubString& GetSavedValue() const { return maSaveValue; } + + virtual void SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; } + virtual const Link& GetModifyHdl() const { return maModifyHdl; } + virtual void SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; } + virtual const Link& GetUpdateDataHdl() const { return maUpdateDataHdl; } + + void SetSubEdit( Edit* pEdit ); + Edit* GetSubEdit() const { return mpSubEdit; } + + void SetAutocompleteHdl( const Link& rHdl ); + const Link& GetAutocompleteHdl() const { return maAutocompleteHdl; } + AutocompleteAction GetAutocompleteAction() const { return meAutocompleteAction; } + + virtual Size CalcMinimumSize() const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + virtual Size CalcSize( sal_uInt16 nChars ) const; + virtual xub_StrLen GetMaxVisChars() const; + + xub_StrLen GetCharPos( const Point& rWindowPos ) const; + + // shows a warning box saying "text too long, truncated" + static void ShowTruncationWarning( Window* pParent ); + + static void SetGetSpecialCharsFunction( FncGetSpecialChars fn ); + static FncGetSpecialChars GetGetSpecialCharsFunction(); + + static PopupMenu* CreatePopupMenu(); + static void DeletePopupMenu( PopupMenu* pMenu ); + + virtual XubString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + + // returns the minimum size a bordered Edit should have given the current + // global style settings (needed by sc's inputwin.cxx) + static Size GetMinimumEditSize(); +}; + +inline sal_uLong Edit::IsUpdateDataEnabled() const +{ + if ( mpUpdateDataTimer ) + return mpUpdateDataTimer->GetTimeout(); + else + return sal_False; +} + +#endif // _SV_EDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/event.hxx b/vcl/inc/vcl/event.hxx new file mode 100644 index 000000000000..9e8666ea7c78 --- /dev/null +++ b/vcl/inc/vcl/event.hxx @@ -0,0 +1,481 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_EVENT_HXX +#define _SV_EVENT_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/keycod.hxx> +#include <vcl/cmdevt.hxx> + +class AllSettings; +class OutputDevice; +class Window; +struct IDataObject; + +namespace com { namespace sun { namespace star { namespace awt { + struct KeyEvent; + struct MouseEvent; +} } } } + +enum TextDirectionality { + TextDirectionality_LeftToRight_TopToBottom, + TextDirectionality_RightToLeft_TopToBottom, + TextDirectionality_TopToBottom_RightToLeft +}; + +// ------------ +// - KeyEvent - +// ------------ +class VCL_DLLPUBLIC KeyEvent +{ +private: + KeyCode maKeyCode; + sal_uInt16 mnRepeat; + xub_Unicode mnCharCode; + +public: + KeyEvent(); + KeyEvent( xub_Unicode nChar, const KeyCode& rKeyCode, + sal_uInt16 nRepeat = 0 ); + + /** inits this vcl KeyEvent with all settings from the given awt event **/ + KeyEvent( const ::com::sun::star::awt::KeyEvent& rEvent ); + + /** fills out the given awt KeyEvent with all settings from this vcl event **/ + void InitKeyEvent( ::com::sun::star::awt::KeyEvent& rEvent ) const; + + xub_Unicode GetCharCode() const { return mnCharCode; } + const KeyCode& GetKeyCode() const { return maKeyCode; } + sal_uInt16 GetRepeat() const { return mnRepeat; } + + KeyEvent LogicalTextDirectionality (TextDirectionality eMode) const; + KeyEvent (const KeyEvent& rKeyEvent); + +}; + +inline KeyEvent::KeyEvent() +{ + mnCharCode = 0; + mnRepeat = 0; +} + +inline KeyEvent::KeyEvent( xub_Unicode nChar, const KeyCode& rKeyCode, + sal_uInt16 nRepeat ) : + maKeyCode( rKeyCode ) + +{ + mnCharCode = nChar; + mnRepeat = nRepeat; +} + +// -------------------- +// - MouseEvent-Types - +// -------------------- + +// Maus-Move-Modi +#define MOUSE_SIMPLEMOVE ((sal_uInt16)0x0001) +#define MOUSE_DRAGMOVE ((sal_uInt16)0x0002) +#define MOUSE_DRAGCOPY ((sal_uInt16)0x0004) +#define MOUSE_ENTERWINDOW ((sal_uInt16)0x0010) +#define MOUSE_LEAVEWINDOW ((sal_uInt16)0x0020) +#define MOUSE_SYNTHETIC ((sal_uInt16)0x0040) +#define MOUSE_MODIFIERCHANGED ((sal_uInt16)0x0080) + +// Maus-Button-Down/Up-Modi +#define MOUSE_SIMPLECLICK ((sal_uInt16)0x0001) +#define MOUSE_SELECT ((sal_uInt16)0x0002) +#define MOUSE_MULTISELECT ((sal_uInt16)0x0004) +#define MOUSE_RANGESELECT ((sal_uInt16)0x0008) + +// Maus-Buttons +#define MOUSE_LEFT ((sal_uInt16)0x0001) +#define MOUSE_MIDDLE ((sal_uInt16)0x0002) +#define MOUSE_RIGHT ((sal_uInt16)0x0004) + +// -------------- +// - MouseEvent - +// -------------- + +class VCL_DLLPUBLIC MouseEvent +{ +private: + Point maPos; + sal_uInt16 mnMode; + sal_uInt16 mnClicks; + sal_uInt16 mnCode; + +public: + MouseEvent(); + MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1, + sal_uInt16 nMode = 0, sal_uInt16 nButtons = 0, + sal_uInt16 nModifier = 0 ); + + const Point& GetPosPixel() const { return maPos; } + sal_uInt16 GetMode() const { return mnMode; } + /** inits this vcl KeyEvent with all settings from the given awt event **/ + MouseEvent( const ::com::sun::star::awt::MouseEvent& rEvent ); + + /** fills out the given awt KeyEvent with all settings from this vcl event **/ + void InitMouseEvent( ::com::sun::star::awt::MouseEvent& rEvent ) const; + + sal_uInt16 GetClicks() const { return mnClicks; } + + sal_Bool IsEnterWindow() const + { return ((mnMode & MOUSE_ENTERWINDOW) != 0); } + sal_Bool IsLeaveWindow() const + { return ((mnMode & MOUSE_LEAVEWINDOW) != 0); } + sal_Bool IsSynthetic() const + { return ((mnMode & MOUSE_SYNTHETIC) != 0); } + sal_Bool IsModifierChanged() const + { return ((mnMode & MOUSE_MODIFIERCHANGED) != 0); } + + sal_uInt16 GetButtons() const + { return (mnCode & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)); } + sal_Bool IsLeft() const + { return ((mnCode & MOUSE_LEFT) != 0); } + sal_Bool IsMiddle() const + { return ((mnCode & MOUSE_MIDDLE) != 0); } + sal_Bool IsRight() const + { return ((mnCode & MOUSE_RIGHT) != 0); } + + sal_uInt16 GetModifier() const + { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); } + bool IsShift() const + { return ((mnCode & KEY_SHIFT) != 0); } + sal_Bool IsMod1() const + { return ((mnCode & KEY_MOD1) != 0); } + sal_Bool IsMod2() const + { return ((mnCode & KEY_MOD2) != 0); } + sal_Bool IsMod3() const + { return ((mnCode & KEY_MOD3) != 0); } +}; + +inline MouseEvent::MouseEvent() +{ + mnMode = 0; + mnClicks = 0; + mnCode = 0; +} + +inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks, + sal_uInt16 nMode, + sal_uInt16 nButtons, sal_uInt16 nModifier ) : + maPos( rPos ) +{ + mnClicks = nClicks; + mnMode = nMode; + mnCode = nButtons | nModifier; +} + +// ------------- +// - HelpEvent - +// ------------- + +#define HELPMODE_CONTEXT ((sal_uInt16)0x0001) +#define HELPMODE_EXTENDED ((sal_uInt16)0x0002) +#define HELPMODE_BALLOON ((sal_uInt16)0x0004) +#define HELPMODE_QUICK ((sal_uInt16)0x0008) + +class VCL_DLLPUBLIC HelpEvent +{ +private: + Point maPos; + sal_uInt16 mnMode; + sal_Bool mbKeyboardActivated; + +public: + HelpEvent(); + HelpEvent( sal_uInt16 nHelpMode ); + HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode ); + + const Point& GetMousePosPixel() const; + sal_uInt16 GetMode() const { return mnMode; } + sal_Bool KeyboardActivated() const { return mbKeyboardActivated; } + void SetKeyboardActivated( sal_Bool bKeyboard ) { mbKeyboardActivated = bKeyboard; } +}; + +inline HelpEvent::HelpEvent() +{ + mnMode = HELPMODE_CONTEXT; + mbKeyboardActivated = sal_True; +} + +inline HelpEvent::HelpEvent( const Point& rMousePos, sal_uInt16 nHelpMode ) : + maPos( rMousePos ) +{ + mnMode = nHelpMode; + mbKeyboardActivated = sal_False; +} + +inline HelpEvent::HelpEvent( sal_uInt16 nHelpMode ) +{ + mnMode = nHelpMode; + mbKeyboardActivated = sal_True; +} + +// ----------------- +// - UserDrawEvent - +// ----------------- + +class VCL_DLLPUBLIC UserDrawEvent +{ +private: + OutputDevice* mpOutDev; + Rectangle maOutRect; + sal_uInt16 mnItemId; + sal_uInt16 mnStyle; + +public: + UserDrawEvent(); + UserDrawEvent( OutputDevice* pOut, + const Rectangle& rOutRect, + sal_uInt16 nId, sal_uInt16 nStyle = 0 ); + + OutputDevice* GetDevice() const { return mpOutDev; } + const Rectangle& GetRect() const { return maOutRect; } + sal_uInt16 GetItemId() const { return mnItemId; } + sal_uInt16 GetStyle() const { return mnStyle; } +}; + +inline UserDrawEvent::UserDrawEvent() +{ + mpOutDev = NULL; + mnItemId = 0; + mnStyle = 0; +} + +inline UserDrawEvent::UserDrawEvent( OutputDevice* pOut, + const Rectangle& rOutRect, + sal_uInt16 nId, sal_uInt16 nStyle ) : + maOutRect( rOutRect ) +{ + mpOutDev = pOut; + mnItemId = nId; + mnStyle = nStyle; +} + +// ------------------ +// - Tracking-Types - +// ------------------ + +#define ENDTRACK_CANCEL ((sal_uInt16)0x0001) +#define ENDTRACK_KEY ((sal_uInt16)0x0002) +#define ENDTRACK_FOCUS ((sal_uInt16)0x0004) +#define ENDTRACK_END ((sal_uInt16)0x1000) +#define ENDTRACK_DONTCALLHDL ((sal_uInt16)0x8000) + +#define TRACKING_REPEAT ((sal_uInt16)0x0100) + +// ----------------- +// - TrackingEvent - +// ----------------- + +class VCL_DLLPUBLIC TrackingEvent +{ +private: + MouseEvent maMEvt; + sal_uInt16 mnFlags; + +public: + TrackingEvent(); + TrackingEvent( const MouseEvent& rMEvt, + sal_uInt16 nTrackFlags = 0 ); + + const MouseEvent& GetMouseEvent() const { return maMEvt; } + + sal_Bool IsTrackingRepeat() const + { return ((mnFlags & TRACKING_REPEAT) != 0); } + + sal_Bool IsTrackingEnded() const + { return ((mnFlags & ENDTRACK_END) != 0); } + sal_Bool IsTrackingCanceled() const + { return ((mnFlags & ENDTRACK_CANCEL) != 0); } + sal_uInt16 GetTrackingFlags() const { return mnFlags; } +}; + +inline TrackingEvent::TrackingEvent() +{ + mnFlags = 0; +} + +inline TrackingEvent::TrackingEvent( const MouseEvent& rMEvt, + sal_uInt16 nTrackFlags ) : + maMEvt( rMEvt ) +{ + mnFlags = nTrackFlags; +} + +// --------------- +// - NotifyEvent - +// --------------- + +#define EVENT_MOUSEBUTTONDOWN 1 +#define EVENT_MOUSEBUTTONUP 2 +#define EVENT_MOUSEMOVE 3 +#define EVENT_KEYINPUT 4 +#define EVENT_KEYUP 5 +#define EVENT_GETFOCUS 6 +#define EVENT_LOSEFOCUS 7 +#define EVENT_COMMAND 8 +#define EVENT_DESTROY 9 +#define EVENT_INPUTENABLE 10 +#define EVENT_INPUTDISABLE 11 +#define EVENT_EXECUTEDIALOG 100 +#define EVENT_ENDEXECUTEDIALOG 101 +#define EVENT_USER 10000 + +class VCL_DLLPUBLIC NotifyEvent +{ +private: + Window* mpWindow; + void* mpData; + sal_uInt16 mnType; + long mnRetValue; + +public: + NotifyEvent(); + NotifyEvent( sal_uInt16 nType, + Window* pWindow, + const void* pEvent = NULL, + long nRet = 0 ); + + sal_uInt16 GetType() const { return mnType; } + Window* GetWindow() const { return mpWindow; } + void* GetData() const { return mpData; } + + void SetReturnValue( long nRet ) { mnRetValue = nRet; } + long GetReturnValue() const { return mnRetValue; } + + const KeyEvent* GetKeyEvent() const; + const MouseEvent* GetMouseEvent() const; + const CommandEvent* GetCommandEvent() const; +}; + +inline NotifyEvent::NotifyEvent() +{ + mpWindow = NULL; + mpData = NULL; + mnType = 0; + mnRetValue = 0; +} + +inline NotifyEvent::NotifyEvent( sal_uInt16 nType, Window* pWindow, + const void* pEvent, long nRet ) +{ + mpWindow = pWindow; + mpData = (void*)pEvent; + mnType = nType; + mnRetValue = nRet; +} + +inline const KeyEvent* NotifyEvent::GetKeyEvent() const +{ + if ( (mnType == EVENT_KEYINPUT) || (mnType == EVENT_KEYUP) ) + return (const KeyEvent*)mpData; + else + return NULL; +} + +inline const MouseEvent* NotifyEvent::GetMouseEvent() const +{ + if ( (mnType >= EVENT_MOUSEBUTTONDOWN) && (mnType <= EVENT_MOUSEMOVE) ) + return (const MouseEvent*)mpData; + else + return NULL; +} + +inline const CommandEvent* NotifyEvent::GetCommandEvent() const +{ + if ( mnType == EVENT_COMMAND ) + return (const CommandEvent*)mpData; + else + return NULL; +} + +// -------------------- +// - DataChangedEvent - +// -------------------- + +#define DATACHANGED_SETTINGS ((sal_uInt16)1) +#define DATACHANGED_DISPLAY ((sal_uInt16)2) +#define DATACHANGED_DATETIME ((sal_uInt16)3) +#define DATACHANGED_FONTS ((sal_uInt16)4) +#define DATACHANGED_PRINTER ((sal_uInt16)5) +#define DATACHANGED_FONTSUBSTITUTION ((sal_uInt16)6) +#define DATACHANGED_USER ((sal_uInt16)10000) + +class VCL_DLLPUBLIC DataChangedEvent +{ +private: + void* mpData; + sal_uLong mnFlags; + sal_uInt16 mnType; + +public: + DataChangedEvent(); + DataChangedEvent( sal_uInt16 nType, + const void* pData = NULL, + sal_uLong nFlags = 0 ); + + sal_uInt16 GetType() const { return mnType; } + void* GetData() const { return mpData; } + sal_uLong GetFlags() const { return mnFlags; } + + const AllSettings* GetOldSettings() const; +}; + +inline DataChangedEvent::DataChangedEvent() +{ + mpData = NULL; + mnFlags = 0; + mnType = 0; +} + +inline DataChangedEvent::DataChangedEvent( sal_uInt16 nType, + const void* pData, + sal_uLong nChangeFlags ) +{ + mpData = (void*)pData; + mnFlags = nChangeFlags; + mnType = nType; +} + +inline const AllSettings* DataChangedEvent::GetOldSettings() const +{ + if ( mnType == DATACHANGED_SETTINGS ) + return (const AllSettings*)mpData; + else + return NULL; +} + +#endif // _SV_EVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/evntpost.hxx b/vcl/inc/vcl/evntpost.hxx new file mode 100644 index 000000000000..90a165506c65 --- /dev/null +++ b/vcl/inc/vcl/evntpost.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _VCL_EVNTPOST_HXX +#define _VCL_EVNTPOST_HXX + +#include <tools/link.hxx> +#include <vcl/dllapi.h> + +//=================================================================== + +namespace vcl +{ + struct UserEvent + { + sal_uLong m_nWhich; + void* m_pData; + }; + + class VCL_DLLPUBLIC EventPoster + { + sal_uLong m_nId; + Link m_aLink; + + DECL_DLLPRIVATE_LINK( DoEvent_Impl, UserEvent* ); + + public: + EventPoster( const Link& rLink ); + ~EventPoster(); + void Post( UserEvent* pEvent ); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/extoutdevdata.hxx b/vcl/inc/vcl/extoutdevdata.hxx new file mode 100644 index 000000000000..28f9a05c5b9f --- /dev/null +++ b/vcl/inc/vcl/extoutdevdata.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_EXTOUTDEVDATA_HXX +#define _VCL_EXTOUTDEVDATA_HXX + +#include <tools/rtti.hxx> +#include <vcl/dllapi.h> + +namespace vcl +{ + +class VCL_DLLPUBLIC ExtOutDevData +{ +public: + + TYPEINFO(); + virtual ~ExtOutDevData(); +}; + +} + +#endif // _VCL_PDFWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/field.hxx b/vcl/inc/vcl/field.hxx new file mode 100644 index 000000000000..fd0ce90cb0d7 --- /dev/null +++ b/vcl/inc/vcl/field.hxx @@ -0,0 +1,889 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FIELD_HXX +#define _SV_FIELD_HXX + +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <tools/date.hxx> +#include <tools/time.hxx> +#include <vcl/spinfld.hxx> +#include <vcl/combobox.hxx> +#include <tools/fldunit.hxx> + +namespace com { namespace sun { namespace star { namespace lang { struct Locale; } } } } + +class CalendarWrapper; +class LocaleDataWrapper; + +// ----------------- +// - FormatterBase - +// ----------------- + +class VCL_DLLPUBLIC FormatterBase +{ +private: + Edit* mpField; + LocaleDataWrapper* mpLocaleDataWrapper; + Link maErrorLink; + sal_Bool mbReformat; + sal_Bool mbStrictFormat; + sal_Bool mbEmptyFieldValue; + sal_Bool mbEmptyFieldValueEnabled; + sal_Bool mbDefaultLocale; + +protected: + SAL_DLLPRIVATE void ImplSetText( const XubString& rText, Selection* pNewSel = NULL ); + SAL_DLLPRIVATE sal_Bool ImplGetEmptyFieldValue() const { return mbEmptyFieldValue; } + + void SetFieldText( const XubString& rText, sal_Bool bKeepSelection ); + void SetEmptyFieldValueData( sal_Bool bValue ) { mbEmptyFieldValue = bValue; } + + SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const; + sal_Bool IsDefaultLocale() const { return mbDefaultLocale; } + +public: + FormatterBase( Edit* pField = NULL ); + virtual ~FormatterBase(); + + const LocaleDataWrapper& GetLocaleDataWrapper() const; + + void SetField( Edit* pField ) { mpField = pField; } + Edit* GetField() const { return mpField; } + + sal_Bool MustBeReformatted() const { return mbReformat; } + void MarkToBeReformatted( sal_Bool b ) { mbReformat = b; } + + void SetStrictFormat( sal_Bool bStrict ); + sal_Bool IsStrictFormat() const { return mbStrictFormat; } + + virtual void Reformat(); + virtual void ReformatAll(); + + virtual void SetLocale( const ::com::sun::star::lang::Locale& rLocale ); + const ::com::sun::star::lang::Locale& GetLocale() const; + + const AllSettings& GetFieldSettings() const; + + void SetErrorHdl( const Link& rLink ) { maErrorLink = rLink; } + const Link& GetErrorHdl() const { return maErrorLink; } + + void SetEmptyFieldValue(); + sal_Bool IsEmptyFieldValue() const; + + void EnableEmptyFieldValue( sal_Bool bEnable ) { mbEmptyFieldValueEnabled = bEnable; } + sal_Bool IsEmptyFieldValueEnabled() const { return mbEmptyFieldValueEnabled; } +}; + + +// -------------------- +// - PatternFormatter - +// -------------------- + +#define PATTERN_FORMAT_EMPTYLITERALS ((sal_uInt16)0x0001) + +class VCL_DLLPUBLIC PatternFormatter : public FormatterBase +{ +private: + ByteString maEditMask; + XubString maFieldString; + XubString maLiteralMask; + sal_uInt16 mnFormatFlags; + sal_Bool mbSameMask; + sal_Bool mbInPattKeyInput; + +protected: + PatternFormatter(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplSetMask( const ByteString& rEditMask, const XubString& rLiteralMask ); + SAL_DLLPRIVATE sal_Bool ImplIsSameMask() const { return mbSameMask; } + SAL_DLLPRIVATE sal_Bool& ImplGetInPattKeyInput() { return mbInPattKeyInput; } + +public: + ~PatternFormatter(); + + virtual void Reformat(); + + void SetMask( const ByteString& rEditMask, + const XubString& rLiteralMask ); + const ByteString& GetEditMask() const { return maEditMask; } + const XubString& GetLiteralMask() const { return maLiteralMask; } + + void SetFormatFlags( sal_uInt16 nFlags ) { mnFormatFlags = nFlags; } + sal_uInt16 GetFormatFlags() const { return mnFormatFlags; } + + void SetString( const XubString& rStr ); + XubString GetString() const; + sal_Bool IsStringModified() const { return !(GetString().Equals( maFieldString )); } + + void SelectFixedFont(); +}; + +// -------------------- +// - NumericFormatter - +// -------------------- + +class VCL_DLLPUBLIC NumericFormatter : public FormatterBase +{ +private: + SAL_DLLPRIVATE void ImplInit(); + +protected: + sal_Int64 mnFieldValue; + sal_Int64 mnLastValue; + sal_Int64 mnMin; + sal_Int64 mnMax; + sal_Int64 mnCorrectedValue; + sal_uInt16 mnType; + sal_uInt16 mnDecimalDigits; + sal_Bool mbThousandSep; + sal_Bool mbShowTrailingZeros; + + // the members below are used in all derivatives of NumericFormatter + // not in NumericFormatter itself. + sal_Int64 mnSpinSize; + sal_Int64 mnFirst; + sal_Int64 mnLast; + +protected: + NumericFormatter(); + + virtual XubString CreateFieldText( sal_Int64 nValue ) const; + + void FieldUp(); + void FieldDown(); + void FieldFirst(); + void FieldLast(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplNumericReformat( const XubString& rStr, double& rValue, XubString& rOutStr ); + SAL_DLLPRIVATE void ImplNewFieldValue( sal_Int64 nNewValue ); + SAL_DLLPRIVATE void ImplSetUserValue( sal_Int64 nNewValue, Selection* pNewSelection = NULL ); + +public: + ~NumericFormatter(); + + virtual void Reformat(); + + void SetMin( sal_Int64 nNewMin ); + sal_Int64 GetMin() const { return mnMin; } + void SetMax( sal_Int64 nNewMax ); + sal_Int64 GetMax() const { return mnMax; } + + void SetFirst( sal_Int64 nNewFirst ) { mnFirst = nNewFirst; } + sal_Int64 GetFirst() const { return mnFirst; } + void SetLast( sal_Int64 nNewLast ) { mnLast = nNewLast; } + sal_Int64 GetLast() const { return mnLast; } + void SetSpinSize( sal_Int64 nNewSize ) { mnSpinSize = nNewSize; } + sal_Int64 GetSpinSize() const { return mnSpinSize; } + + void SetDecimalDigits( sal_uInt16 nDigits ); + sal_uInt16 GetDecimalDigits() const; + + void SetUseThousandSep( sal_Bool b ); + sal_Bool IsUseThousandSep() const { return mbThousandSep; } + + void SetShowTrailingZeros( sal_Bool bShowTrailingZeros ); + sal_Bool IsShowTrailingZeros() const { return mbShowTrailingZeros; } + + + void SetUserValue( sal_Int64 nNewValue ); + virtual void SetValue( sal_Int64 nNewValue ); + virtual sal_Int64 GetValue() const; + sal_Bool IsValueModified() const; + sal_Int64 GetCorrectedValue() const { return mnCorrectedValue; } + + Fraction ConvertToFraction( sal_Int64 nValue ); + sal_Int64 ConvertToLong( const Fraction& rValue ); + sal_Int64 Normalize( sal_Int64 nValue ) const; + sal_Int64 Denormalize( sal_Int64 nValue ) const; +}; + +// ------------------- +// - MetricFormatter - +// ------------------- + +class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter +{ +private: + SAL_DLLPRIVATE void ImplInit(); + +protected: + XubString maCustomUnitText; + XubString maCurUnitText; + sal_Int64 mnBaseValue; + FieldUnit meUnit; + Link maCustomConvertLink; + +protected: + MetricFormatter(); + + virtual XubString CreateFieldText( sal_Int64 nValue ) const; + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplMetricReformat( const XubString& rStr, double& rValue, XubString& rOutStr ); + +public: + ~MetricFormatter(); + + virtual void CustomConvert() = 0; + virtual void Reformat(); + + virtual void SetUnit( FieldUnit meUnit ); + FieldUnit GetUnit() const { return meUnit; } + void SetCustomUnitText( const XubString& rStr ); + const XubString& GetCustomUnitText() const { return maCustomUnitText; } + const XubString& GetCurUnitText() const { return maCurUnitText; } + + using NumericFormatter::SetMax; + void SetMax( sal_Int64 nNewMax, FieldUnit eInUnit ); + using NumericFormatter::GetMax; + sal_Int64 GetMax( FieldUnit eOutUnit ) const; + using NumericFormatter::SetMin; + void SetMin( sal_Int64 nNewMin, FieldUnit eInUnit ); + using NumericFormatter::GetMin; + sal_Int64 GetMin( FieldUnit eOutUnit ) const; + void SetBaseValue( sal_Int64 nNewBase, FieldUnit eInUnit = FUNIT_NONE ); + sal_Int64 GetBaseValue( FieldUnit eOutUnit = FUNIT_NONE ) const; + + virtual void SetValue( sal_Int64 nNewValue, FieldUnit eInUnit ); + virtual void SetValue( sal_Int64 nValue ); + using NumericFormatter::SetUserValue; + void SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit ); + virtual sal_Int64 GetValue( FieldUnit eOutUnit ) const; + virtual sal_Int64 GetValue() const; + using NumericFormatter::GetCorrectedValue; + sal_Int64 GetCorrectedValue( FieldUnit eOutUnit ) const; + + void SetCustomConvertHdl( const Link& rLink ) { maCustomConvertLink = rLink; } + const Link& GetCustomConvertHdl() const { return maCustomConvertLink; } +}; + + +// --------------------- +// - CurrencyFormatter - +// --------------------- + +class VCL_DLLPUBLIC CurrencyFormatter : public NumericFormatter +{ +private: + String maCurrencySymbol; + + SAL_DLLPRIVATE void ImplInit(); + +protected: + CurrencyFormatter(); + virtual XubString CreateFieldText( sal_Int64 nValue ) const; + SAL_DLLPRIVATE sal_Bool ImplCurrencyReformat( const XubString& rStr, XubString& rOutStr ); + +public: + ~CurrencyFormatter(); + + virtual void Reformat(); + + void SetCurrencySymbol( const String& rStr ); + String GetCurrencySymbol() const; + + virtual void SetValue( sal_Int64 nNewValue ); + virtual sal_Int64 GetValue() const; +}; + + +// ----------------- +// - DateFormatter - +// ----------------- + +class VCL_DLLPUBLIC DateFormatter : public FormatterBase +{ +private: + CalendarWrapper* mpCalendarWrapper; + Date maFieldDate; + Date maLastDate; + Date maMin; + Date maMax; + Date maCorrectedDate; + sal_Bool mbLongFormat; + sal_Bool mbEmptyDate; + sal_Bool mbShowDateCentury; + sal_uInt16 mnDateFormat; + sal_uLong mnExtDateFormat; + sal_Bool mbEnforceValidValue; + + SAL_DLLPRIVATE void ImplInit(); + +protected: + DateFormatter(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE const Date& ImplGetFieldDate() const { return maFieldDate; } + SAL_DLLPRIVATE sal_Bool ImplDateReformat( const XubString& rStr, XubString& rOutStr, + const AllSettings& rSettings ); + SAL_DLLPRIVATE void ImplSetUserDate( const Date& rNewDate, + Selection* pNewSelection = NULL ); + SAL_DLLPRIVATE XubString ImplGetDateAsText( const Date& rDate, + const AllSettings& rSettings ) const; + SAL_DLLPRIVATE void ImplNewFieldValue( const Date& rDate ); + CalendarWrapper& GetCalendarWrapper() const; + + SAL_DLLPRIVATE sal_Bool ImplAllowMalformedInput() const; + +public: + ~DateFormatter(); + + virtual void Reformat(); + virtual void ReformatAll(); + + virtual void SetLocale( const ::com::sun::star::lang::Locale& rLocale ); + + + void SetExtDateFormat( ExtDateFieldFormat eFormat ); + ExtDateFieldFormat GetExtDateFormat( sal_Bool bResolveSystemFormat = sal_False ) const; + + void SetMin( const Date& rNewMin ); + const Date& GetMin() const { return maMin; } + + void SetMax( const Date& rNewMax ); + const Date& GetMax() const { return maMax; } + + + // -------------------------------------------------------------- + // MT: Remove these methods too, ExtDateFormat should be enough! + // What should happen if using DDMMYYYY, but ShowCentury=sal_False? + // -------------------------------------------------------------- + void SetLongFormat( sal_Bool bLong ); + sal_Bool IsLongFormat() const { return mbLongFormat; } + void SetShowDateCentury( sal_Bool bShowCentury ); + sal_Bool IsShowDateCentury() const { return mbShowDateCentury; } + // -------------------------------------------------------------- + + void SetDate( const Date& rNewDate ); + void SetUserDate( const Date& rNewDate ); + Date GetDate() const; + Date GetRealDate() const; + sal_Bool IsDateModified() const; + void SetEmptyDate(); + sal_Bool IsEmptyDate() const; + Date GetCorrectedDate() const { return maCorrectedDate; } + + void ResetLastDate() { maLastDate = Date( 0, 0, 0 ); } + + static void ExpandCentury( Date& rDate ); + static void ExpandCentury( Date& rDate, sal_uInt16 nTwoDigitYearStart ); + + static Date GetInvalidDate() { return Date( 0, 0, 0 ); } + + /** enables or disables the enforcement of valid values + + If this is set to <TRUE/> (which is the default), then GetDate will always return a valid + date, no matter whether the current text can really be interpreted as date. (Note: this + is the compatible bahavior). + + If this is set to <FALSE/>, the GetDate will return GetInvalidDate, in case the current text + cannot be interpreted as date. + + In addition, if this is set to <FALSE/>, the text in the field will <em>not</em> be corrected + when the control loses the focus - instead, the invalid input will be preserved. + */ + void EnforceValidValue( sal_Bool _bEnforce ) { mbEnforceValidValue = _bEnforce; } + inline sal_Bool IsEnforceValidValue( ) const { return mbEnforceValidValue; } +}; + + +// ----------------- +// - TimeFormatter - +// ----------------- + +class VCL_DLLPUBLIC TimeFormatter : public FormatterBase +{ +private: + Time maLastTime; + Time maMin; + Time maMax; + Time maCorrectedTime; + TimeFieldFormat meFormat; + sal_uInt16 mnTimeFormat; + sal_Bool mbDuration; + sal_Bool mbEmptyTime; + sal_Bool mbEnforceValidValue; + + SAL_DLLPRIVATE void ImplInit(); + +protected: + Time maFieldTime; + + TimeFormatter(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplTimeReformat( const XubString& rStr, XubString& rOutStr ); + SAL_DLLPRIVATE void ImplNewFieldValue( const Time& rTime ); + SAL_DLLPRIVATE void ImplSetUserTime( const Time& rNewTime, Selection* pNewSelection = NULL ); + SAL_DLLPRIVATE sal_Bool ImplAllowMalformedInput() const; + +public: + + enum TimeFormat { + HOUR_12, + HOUR_24 + }; + + ~TimeFormatter(); + + virtual void Reformat(); + virtual void ReformatAll(); + + void SetMin( const Time& rNewMin ); + const Time& GetMin() const { return maMin; } + void SetMax( const Time& rNewMax ); + const Time& GetMax() const { return maMax; } + + void SetTimeFormat( TimeFormat eNewFormat ); + TimeFormat GetTimeFormat() const; + + void SetFormat( TimeFieldFormat eNewFormat ); + TimeFieldFormat GetFormat() const { return meFormat; } + + void SetDuration( sal_Bool mbDuration ); + sal_Bool IsDuration() const { return mbDuration; } + + void SetTime( const Time& rNewTime ); + void SetUserTime( const Time& rNewTime ); + Time GetTime() const; + Time GetRealTime() const; + sal_Bool IsTimeModified() const; + void SetEmptyTime() { FormatterBase::SetEmptyFieldValue(); } + sal_Bool IsEmptyTime() const { return FormatterBase::IsEmptyFieldValue(); } + Time GetCorrectedTime() const { return maCorrectedTime; } + + static Time GetInvalidTime() { return Time( 99, 99, 99 ); } + + /** enables or disables the enforcement of valid values + + If this is set to <TRUE/> (which is the default), then GetTime will always return a valid + time, no matter whether the current text can really be interpreted as time. (Note: this + is the compatible bahavior). + + If this is set to <FALSE/>, the GetTime will return GetInvalidTime, in case the current text + cannot be interpreted as time. + + In addition, if this is set to <FALSE/>, the text in the field will <em>not</em> be corrected + when the control loses the focus - instead, the invalid input will be preserved. + */ + void EnforceValidValue( sal_Bool _bEnforce ) { mbEnforceValidValue = _bEnforce; } + inline sal_Bool IsEnforceValidValue( ) const { return mbEnforceValidValue; } +}; + + +// ---------------- +// - PatternField - +// ---------------- + +class VCL_DLLPUBLIC PatternField : public SpinField, public PatternFormatter +{ +public: + PatternField( Window* pParent, WinBits nWinStyle ); + PatternField( Window* pParent, const ResId& rResId ); + ~PatternField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void Modify(); +}; + + +// ---------------- +// - NumericField - +// ---------------- + +class VCL_DLLPUBLIC NumericField : public SpinField, public NumericFormatter +{ +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + NumericField( Window* pParent, WinBits nWinStyle ); + NumericField( Window* pParent, const ResId& rResId ); + ~NumericField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); +}; + + +// ---------------- +// - MetricField - +// ---------------- + +class VCL_DLLPUBLIC MetricField : public SpinField, public MetricFormatter +{ +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + MetricField( Window* pParent, WinBits nWinStyle ); + MetricField( Window* pParent, const ResId& rResId ); + ~MetricField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + virtual void CustomConvert(); + + virtual void SetUnit( FieldUnit meUnit ); + + void SetFirst( sal_Int64 nNewFirst, FieldUnit eInUnit ); + inline void SetFirst(sal_Int64 first) { SetFirst(first, FUNIT_NONE); } + sal_Int64 GetFirst( FieldUnit eOutUnit ) const; + inline sal_Int64 GetFirst() const { return GetFirst(FUNIT_NONE); } + void SetLast( sal_Int64 nNewLast, FieldUnit eInUnit ); + inline void SetLast(sal_Int64 last) { SetLast(last, FUNIT_NONE); } + sal_Int64 GetLast( FieldUnit eOutUnit ) const; + inline sal_Int64 GetLast() const { return GetLast(FUNIT_NONE); } + + static void SetDefaultUnit( FieldUnit eDefaultUnit ); + static FieldUnit GetDefaultUnit(); + static sal_Int64 ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit ); + static sal_Int64 ConvertValue( sal_Int64 nValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, MapUnit eOutUnit ); + static sal_Int64 ConvertValue( sal_Int64 nValue, sal_uInt16 nDecDigits, + MapUnit eInUnit, FieldUnit eOutUnit ); + + // for backwards compatibility + // caution: conversion to double loses precision + static double ConvertDoubleValue( double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit ); + static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, MapUnit eOutUnit ); + static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits, + MapUnit eInUnit, FieldUnit eOutUnit ); + + // for backwards compatibility + // caution: conversion to double loses precision + static double ConvertDoubleValue( sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit ) + { return ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, eOutUnit ); } + static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, MapUnit eOutUnit ) + { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); } + static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits, + MapUnit eInUnit, FieldUnit eOutUnit ) + { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); } +}; + + +// ----------------- +// - CurrencyField - +// ----------------- + +class VCL_DLLPUBLIC CurrencyField : public SpinField, public CurrencyFormatter +{ +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + CurrencyField( Window* pParent, WinBits nWinStyle ); + CurrencyField( Window* pParent, const ResId& rResId ); + ~CurrencyField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); +}; + + +// ------------- +// - DateField - +// ------------- + +class VCL_DLLPUBLIC DateField : public SpinField, public DateFormatter +{ +private: + Date maFirst; + Date maLast; + +protected: + SAL_DLLPRIVATE void ImplDateSpinArea( sal_Bool bUp ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + DateField( Window* pParent, WinBits nWinStyle ); + DateField( Window* pParent, const ResId& rResId ); + ~DateField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + + void SetFirst( const Date& rNewFirst ) { maFirst = rNewFirst; } + Date GetFirst() const { return maFirst; } + void SetLast( const Date& rNewLast ) { maLast = rNewLast; } + Date GetLast() const { return maLast; } +}; + +// ------------- +// - TimeField - +// ------------- + +class VCL_DLLPUBLIC TimeField : public SpinField, public TimeFormatter +{ +private: + Time maFirst; + Time maLast; + +protected: + SAL_DLLPRIVATE void ImplTimeSpinArea( sal_Bool bUp ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + TimeField( Window* pParent, WinBits nWinStyle ); + TimeField( Window* pParent, const ResId& rResId ); + ~TimeField(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + + void SetFirst( const Time& rNewFirst ) { maFirst = rNewFirst; } + Time GetFirst() const { return maFirst; } + void SetLast( const Time& rNewLast ) { maLast = rNewLast; } + Time GetLast() const { return maLast; } + + void SetExtFormat( ExtTimeFieldFormat eFormat ); +}; + + +// -------------- +// - PatternBox - +// -------------- + +class VCL_DLLPUBLIC PatternBox : public ComboBox, public PatternFormatter +{ +public: + PatternBox( Window* pParent, WinBits nWinStyle ); + PatternBox( Window* pParent, const ResId& rResId ); + ~PatternBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); + + void InsertString( const XubString& rStr, + sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveString( const XubString& rStr ); + using PatternFormatter::GetString; + XubString GetString( sal_uInt16 nPos ) const; + sal_uInt16 GetStringPos( const XubString& rStr ) const; +}; + + +// -------------- +// - NumericBox - +// -------------- + +class VCL_DLLPUBLIC NumericBox : public ComboBox, public NumericFormatter +{ +public: + NumericBox( Window* pParent, WinBits nWinStyle ); + NumericBox( Window* pParent, const ResId& rResId ); + ~NumericBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); + + void InsertValue( sal_Int64 nValue, sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveValue( sal_Int64 nValue ); + using NumericFormatter::GetValue; + sal_Int64 GetValue( sal_uInt16 nPos ) const; + sal_uInt16 GetValuePos( sal_Int64 nPos ) const; +}; + + +// ------------- +// - MetricBox - +// ------------- + +class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter +{ +public: + MetricBox( Window* pParent, WinBits nWinStyle ); + MetricBox( Window* pParent, const ResId& rResId ); + ~MetricBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void CustomConvert(); + virtual void ReformatAll(); + + void InsertValue( sal_Int64 nValue, FieldUnit eInUnit = FUNIT_NONE, + sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveValue( sal_Int64 nValue, FieldUnit eInUnit = FUNIT_NONE ); + sal_Int64 GetValue( sal_uInt16 nPos, FieldUnit eOutUnit = FUNIT_NONE ) const; + sal_uInt16 GetValuePos( sal_Int64 nValue, + FieldUnit eInUnit = FUNIT_NONE ) const; + + // Needed, because GetValue() with nPos hide these functions + virtual sal_Int64 GetValue( FieldUnit eOutUnit ) const; + virtual sal_Int64 GetValue() const; +}; + + +// --------------- +// - CurrencyBox - +// --------------- + +class VCL_DLLPUBLIC CurrencyBox : public ComboBox, public CurrencyFormatter +{ +public: + CurrencyBox( Window* pParent, WinBits nWinStyle ); + CurrencyBox( Window* pParent, const ResId& rResId ); + ~CurrencyBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); + + void InsertValue( sal_Int64 nValue, sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveValue( sal_Int64 nValue ); + sal_Int64 GetValue( sal_uInt16 nPos ) const; + sal_uInt16 GetValuePos( sal_Int64 nValue ) const; + + // Needed, because GetValue() with nPos hide this function + virtual sal_Int64 GetValue() const; +}; + + +// ----------- +// - DateBox - +// ----------- + +class VCL_DLLPUBLIC DateBox : public ComboBox, public DateFormatter +{ +public: + DateBox( Window* pParent, WinBits nWinStyle ); + DateBox( Window* pParent, const ResId& rResId ); + ~DateBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); + + void InsertDate( const Date& rDate, sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveDate( const Date& rDate ); + using DateFormatter::GetDate; + Date GetDate( sal_uInt16 nPos ) const; + sal_uInt16 GetDatePos( const Date& rDate ) const; +}; + + +// ----------- +// - TimeBox - +// ----------- + +class VCL_DLLPUBLIC TimeBox : public ComboBox, public TimeFormatter +{ +public: + TimeBox( Window* pParent, WinBits nWinStyle ); + TimeBox( Window* pParent, const ResId& rResId ); + ~TimeBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); + + void InsertTime( const Time& rTime, sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveTime( const Time& rTime ); + using TimeFormatter::GetTime; + Time GetTime( sal_uInt16 nPos ) const; + sal_uInt16 GetTimePos( const Time& rTime ) const; +}; + +#endif // _SV_FIELD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fixbrd.hxx b/vcl/inc/vcl/fixbrd.hxx new file mode 100644 index 000000000000..e091f68d4fad --- /dev/null +++ b/vcl/inc/vcl/fixbrd.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FIXBRD_HXX +#define _SV_FIXBRD_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/decoview.hxx> +#include <vcl/ctrl.hxx> + +// --------------------- +// - FixedBorder-Types - +// --------------------- + +#define FIXEDBORDER_TYPE_IN (FRAME_DRAW_IN) +#define FIXEDBORDER_TYPE_OUT (FRAME_DRAW_OUT) +#define FIXEDBORDER_TYPE_GROUP (FRAME_DRAW_GROUP) +#define FIXEDBORDER_TYPE_DOUBLEIN (FRAME_DRAW_DOUBLEIN) +#define FIXEDBORDER_TYPE_DOUBLEOUT (FRAME_DRAW_DOUBLEOUT) + +// --------------- +// - FixedBorder - +// --------------- + +class VCL_DLLPUBLIC FixedBorder : public Control +{ +private: + sal_uInt16 mnType; + sal_Bool mbTransparent; + +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize ); + +public: + FixedBorder( Window* pParent, WinBits nStyle = 0 ); + FixedBorder( Window* pParent, const ResId& rResId ); + ~FixedBorder(); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void SetTransparent( sal_Bool bTransparent ); + sal_Bool IsTransparent() const { return mbTransparent; } + void SetBorderType( sal_uInt16 nType ); + sal_uInt16 GetBorderType() const { return mnType; } +}; + +#endif // _SV_FIXBRD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fixed.hxx b/vcl/inc/vcl/fixed.hxx new file mode 100644 index 000000000000..3912f19e778a --- /dev/null +++ b/vcl/inc/vcl/fixed.hxx @@ -0,0 +1,198 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FIXED_HXX +#define _SV_FIXED_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> +#include <vcl/image.hxx> +#include <vcl/ctrl.hxx> + +class UserDrawEvent; + +// ------------- +// - FixedText - +// ------------- + +class VCL_DLLPUBLIC FixedText : public Control +{ +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize, bool bFillLayout = false ) const; +public: + SAL_DLLPRIVATE static sal_uInt16 ImplGetTextStyle( WinBits nWinBits ); +protected: + virtual void FillLayoutData() const; + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + +public: + FixedText( Window* pParent, WinBits nStyle = 0 ); + FixedText( Window* pParent, const ResId& rResId ); + FixedText( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabelForRelation ); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + static Size CalcMinimumTextSize( Control const* pControl, long nMaxWidth = 0 ); + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize(WindowSizeType eType) const; +}; + +// ------------- +// - FixedLine - +// ------------- + +class VCL_DLLPUBLIC FixedLine : public Control +{ +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDraw( bool bLayout = false ); + +protected: + virtual void FillLayoutData() const; + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + +public: + FixedLine( Window* pParent, WinBits nStyle = WB_HORZ ); + FixedLine( Window* pParent, const ResId& rResId ); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual Size GetOptimalSize(WindowSizeType eType) const; +}; + +// --------------- +// - FixedBitmap - +// --------------- + +class VCL_DLLPUBLIC FixedBitmap : public Control +{ +private: + Bitmap maBitmap; + + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize ); + +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + FixedBitmap( Window* pParent, WinBits nStyle = 0 ); + FixedBitmap( Window* pParent, const ResId& rResId ); + ~FixedBitmap(); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void SetBitmap( const Bitmap& rBitmap ); + using OutputDevice::GetBitmap; + const Bitmap& GetBitmap() const { return maBitmap; } + sal_Bool SetModeBitmap( const Bitmap& rBitmap ); + const Bitmap& GetModeBitmap( ) const; +}; + +// -------------- +// - FixedImage - +// -------------- + +class VCL_DLLPUBLIC FixedImage : public Control +{ +private: + Image maImage; + sal_Bool mbInUserDraw; + +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + +protected: + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + FixedImage( Window* pParent, WinBits nStyle = 0 ); + FixedImage( Window* pParent, const ResId& rResId ); + ~FixedImage(); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + 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; } + + sal_Bool SetModeImage( const Image& rImage ); + const Image& GetModeImage( ) const; + + Point CalcImagePos( const Point& rPos, + const Size& rObjSize, const Size& rWinSize ); +}; + +#endif // _SV_FIXED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/floatwin.hxx b/vcl/inc/vcl/floatwin.hxx new file mode 100644 index 000000000000..e6a5b58eea32 --- /dev/null +++ b/vcl/inc/vcl/floatwin.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FLOATWIN_HXX +#define _SV_FLOATWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> + +class ToolBox; +class PopupModeEvent; + +// ------------------------ +// - FloatingWindow-Types - +// ------------------------ + +#define FLOATWIN_POPUPMODE_ALLOWTEAROFF ((sal_uLong)0x00000001) +#define FLOATWIN_POPUPMODE_ANIMATIONSLIDE ((sal_uLong)0x00000002) +#define FLOATWIN_POPUPMODE_NOAUTOARRANGE ((sal_uLong)0x00000004) +#define FLOATWIN_POPUPMODE_NOANIMATION ((sal_uLong)0x00000008) +#define FLOATWIN_POPUPMODE_DOWN ((sal_uLong)0x00000010) +#define FLOATWIN_POPUPMODE_UP ((sal_uLong)0x00000020) +#define FLOATWIN_POPUPMODE_LEFT ((sal_uLong)0x00000040) +#define FLOATWIN_POPUPMODE_RIGHT ((sal_uLong)0x00000080) +#define FLOATWIN_POPUPMODE_NOFOCUSCLOSE ((sal_uLong)0x00000100) +#define FLOATWIN_POPUPMODE_NOKEYCLOSE ((sal_uLong)0x00000200) +#define FLOATWIN_POPUPMODE_NOMOUSECLOSE ((sal_uLong)0x00000400) +#define FLOATWIN_POPUPMODE_NOMOUSERECTCLOSE ((sal_uLong)0x00000800) +#define FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE ((sal_uLong)0x00001000) +#define FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE ((sal_uLong)0x00002000) +#define FLOATWIN_POPUPMODE_PATHMOUSECANCELCLICK ((sal_uLong)0x00004000) +#define FLOATWIN_POPUPMODE_NEWLEVEL ((sal_uLong)0x00008000) +#define FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE ((sal_uLong)0x00010000) +#define FLOATWIN_POPUPMODE_GRABFOCUS ((sal_uLong)0x00020000) + +#define FLOATWIN_POPUPMODEEND_CANCEL ((sal_uInt16)0x0001) +#define FLOATWIN_POPUPMODEEND_TEAROFF ((sal_uInt16)0x0002) +#define FLOATWIN_POPUPMODEEND_DONTCALLHDL ((sal_uInt16)0x0004) +#define FLOATWIN_POPUPMODEEND_CLOSEALL ((sal_uInt16)0x0008) + +#define FLOATWIN_TITLE_NORMAL ((sal_uInt16)0x0001) +#define FLOATWIN_TITLE_TEAROFF ((sal_uInt16)0x0002) +#define FLOATWIN_TITLE_POPUP ((sal_uInt16)0x0004) +#define FLOATWIN_TITLE_NONE ((sal_uInt16)0x0008) + +// ------------------ +// - FloatingWindow - +// ------------------ + +class VCL_DLLPUBLIC FloatingWindow : public SystemWindow +{ + class ImplData; +private: + FloatingWindow* mpNextFloat; + Window* mpFirstPopupModeWin; + ImplData* mpImplData; + Rectangle maFloatRect; + sal_uLong mnPostId; + sal_uLong mnPopupModeFlags; + sal_uInt16 mnTitle; + sal_uInt16 mnOldTitle; + sal_Bool mbInPopupMode; + sal_Bool mbPopupMode; + sal_Bool mbPopupModeCanceled; + sal_Bool mbPopupModeTearOff; + sal_Bool mbMouseDown; + sal_Bool mbOldSaveBackMode; + sal_Bool mbGrabFocus; // act as key input window, although focus is not set + sal_Bool mbInCleanUp; + Link maPopupModeEndHdl; + + SAL_DLLPRIVATE void ImplCallPopupModeEnd(); + DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void* ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE FloatingWindow (const FloatingWindow &); + SAL_DLLPRIVATE FloatingWindow & operator= (const FloatingWindow &); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: +#define IMPL_FLOATWIN_HITTEST_OUTSIDE ((sal_uInt16)0x0001) +#define IMPL_FLOATWIN_HITTEST_WINDOW ((sal_uInt16)0x0002) +#define IMPL_FLOATWIN_HITTEST_RECT ((sal_uInt16)0x0004) + SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( Window* pReference, const Point& rPos, sal_uInt16& rHitTest ); + SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat(); + SAL_DLLPRIVATE sal_Bool ImplIsFloatPopupModeWindow( const Window* pWindow ); + SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = sal_True; } + SAL_DLLPRIVATE sal_Bool ImplIsMouseDown() const { return mbMouseDown; } + SAL_DLLPRIVATE static Point ImplCalcPos( Window* pWindow, + const Rectangle& rRect, sal_uLong nFlags, + sal_uInt16& rArrangeIndex ); + SAL_DLLPRIVATE void ImplEndPopupMode( sal_uInt16 nFlags = 0, sal_uLong nFocusId = 0 ); + SAL_DLLPRIVATE Rectangle& ImplGetItemEdgeClipRect(); + SAL_DLLPRIVATE sal_Bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; } + +public: + FloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN ); + FloatingWindow( Window* pParent, const ResId& rResId ); + ~FloatingWindow(); + + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void PopupModeEnd(); + + void SetTitleType( sal_uInt16 nTitle ); + sal_uInt16 GetTitleType() const { return mnTitle; } + + void StartPopupMode( const Rectangle& rRect, sal_uLong nFlags = 0 ); + void StartPopupMode( ToolBox* pBox, sal_uLong nFlags = 0 ); + void EndPopupMode( sal_uInt16 nFlags = 0 ); + void AddPopupModeWindow( Window* pWindow ); + void RemovePopupModeWindow( Window* pWindow ); + sal_uLong GetPopupModeFlags() const { return mnPopupModeFlags; } + void SetPopupModeFlags( sal_uLong nFlags ) { mnPopupModeFlags = nFlags; } + sal_Bool IsInPopupMode() const { return mbPopupMode; } + sal_Bool IsInCleanUp() const { return mbInCleanUp; } + sal_Bool IsPopupModeCanceled() const { return mbPopupModeCanceled; } + sal_Bool IsPopupModeTearOff() const { return mbPopupModeTearOff; } + + void SetPopupModeEndHdl( const Link& rLink ) { maPopupModeEndHdl = rLink; } + const Link& GetPopupModeEndHdl() const { return maPopupModeEndHdl; } + + sal_Bool GrabsFocus() const { return mbGrabFocus; } + + static Point CalcFloatingPosition( Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex ); +}; + +#endif // _SV_FLOATWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fntstyle.hxx b/vcl/inc/vcl/fntstyle.hxx new file mode 100644 index 000000000000..82c8c8ad5932 --- /dev/null +++ b/vcl/inc/vcl/fntstyle.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_FNTSTYLE_HXX +#define _VCL_FNTSTYLE_HXX + +#include <tools/solar.h> +#include <sal/types.h> + +// -------------- +// - Font enums - +// -------------- + +#ifndef ENUM_FONTRELIEF_DECLARED +#define ENUM_FONTRELIEF_DECLARED + +enum FontRelief { RELIEF_NONE, RELIEF_EMBOSSED, RELIEF_ENGRAVED, FontRelief_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// -------------- +// - Font types - +// -------------- + +typedef sal_uInt8 FontKerning; +#define KERNING_FONTSPECIFIC ((FontKerning)0x01) +#define KERNING_ASIAN ((FontKerning)0x02) + +#endif // _VCL_FNTSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/font.hxx b/vcl/inc/vcl/font.hxx new file mode 100644 index 000000000000..8ca4ba5bbb87 --- /dev/null +++ b/vcl/inc/vcl/font.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FONT_HXX +#define _SV_FONT_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <i18npool/lang.h> +#include <tools/color.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/fntstyle.hxx> + +class SvStream; +#define FontAlign TextAlign + +class Impl_Font; +class ImplFontAttributes; + +// -------- +// - Font - +// -------- + +class VCL_DLLPUBLIC Font +{ +private: + Impl_Font* mpImplFont; + void MakeUnique(); + +public: + Font(); + Font( const Font& ); + Font( const String& rFamilyName, const Size& ); + Font( const String& rFamilyName, const String& rStyleName, const Size& ); + Font( FontFamily eFamily, const Size& ); + ~Font(); + + void SetColor( const Color& ); + const Color& GetColor() const; + void SetFillColor( const Color& ); + const Color& GetFillColor() const; + void SetTransparent( sal_Bool bTransparent ); + sal_Bool IsTransparent() const; + void SetAlign( FontAlign ); + FontAlign GetAlign() const; + + void SetName( const String& rFamilyName ); + const String& GetName() const; + void SetStyleName( const String& rStyleName ); + const String& GetStyleName() const; + void SetSize( const Size& ); + const Size& GetSize() const; + void SetHeight( long nHeight ); + long GetHeight() const; + void SetWidth( long nWidth ); + long GetWidth() const; + + void SetFamily( FontFamily ); + FontFamily GetFamily() const; + void SetCharSet( rtl_TextEncoding ); + rtl_TextEncoding GetCharSet() const; + void SetLanguage( LanguageType ); + LanguageType GetLanguage() const; + void SetCJKContextLanguage( LanguageType ); + LanguageType GetCJKContextLanguage() const; + void SetPitch( FontPitch ePitch ); + FontPitch GetPitch() const; + + void SetOrientation( short nLineOrientation ); + short GetOrientation() const; + void SetVertical( sal_Bool bVertical ); + sal_Bool IsVertical() const; + void SetKerning( FontKerning nKerning ); + FontKerning GetKerning() const; + sal_Bool IsKerning() const; + + void SetWeight( FontWeight ); + FontWeight GetWeight() const; + void SetWidthType( FontWidth ); + FontWidth GetWidthType() const; + void SetItalic( FontItalic ); + FontItalic GetItalic() const; + void SetOutline( sal_Bool bOutline ); + sal_Bool IsOutline() const; + void SetShadow( sal_Bool bShadow ); + sal_Bool IsShadow() const; + void SetRelief( FontRelief ); + FontRelief GetRelief() const; + void SetUnderline( FontUnderline ); + FontUnderline GetUnderline() const; + void SetOverline( FontUnderline ); + FontUnderline GetOverline() const; + void SetStrikeout( FontStrikeout ); + FontStrikeout GetStrikeout() const; + void SetEmphasisMark( FontEmphasisMark ); + FontEmphasisMark GetEmphasisMark() const; + void SetWordLineMode( sal_Bool bWordLine ); + sal_Bool IsWordLineMode() const; + + void Merge( const Font& rFont ); + void GetFontAttributes( ImplFontAttributes& rAttrs ) const; + + Font& operator=( const Font& ); + sal_Bool operator==( const Font& ) const; + sal_Bool operator!=( const Font& rFont ) const + { return !(Font::operator==( rFont )); } + sal_Bool IsSameInstance( const Font& ) const; + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Font& ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Font& ); + + static Font identifyFont( const void* pBuffer, sal_uInt32 nLen ); +}; + +#endif // _VCL_FONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fontcache.hxx b/vcl/inc/vcl/fontcache.hxx new file mode 100644 index 000000000000..ad261e8d8e6d --- /dev/null +++ b/vcl/inc/vcl/fontcache.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_FONTCACHE_HXX +#define _PSPRINT_FONTCACHE_HXX + +#include "vcl/dllapi.h" +#include "vcl/fontmanager.hxx" + +#include "tools/string.hxx" + +#include <boost/unordered_map.hpp> + +namespace psp +{ + +class VCL_PLUGIN_PUBLIC FontCache +{ + struct FontDir; + friend class FontDir; + struct FontFile; + friend class FontFile; + + typedef std::list< PrintFontManager::PrintFont* > FontCacheEntry; + struct FontFile + { + FontCacheEntry m_aEntry; + }; + + typedef boost::unordered_map< ::rtl::OString, FontFile, ::rtl::OStringHash > FontDirMap; + struct FontDir + { + sal_Int64 m_nTimestamp; + bool m_bNoFiles; + bool m_bUserOverrideOnly; + FontDirMap m_aEntries; + + FontDir() : m_nTimestamp(0), m_bNoFiles(false), m_bUserOverrideOnly( false ) {} + }; + + typedef boost::unordered_map< int, FontDir > FontCacheData; + FontCacheData m_aCache; + String m_aCacheFile; + bool m_bDoFlush; + + void read(); + void clearCache(); + + void copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFontManager::PrintFont* pTo ) const; + bool equalsPrintFont( const PrintFontManager::PrintFont* pLeft, PrintFontManager::PrintFont* pRight ) const; + PrintFontManager::PrintFont* clonePrintFont( const PrintFontManager::PrintFont* pFont ) const; + + void createCacheDir( int nDirID ); +public: + FontCache(); + ~FontCache(); + + bool getFontCacheFile( int nDirID, const rtl::OString& rFile, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const; + void updateFontCacheEntry( const PrintFontManager::PrintFont*, bool bFlush ); + void markEmptyDir( int nDirID, bool bNoFiles = true ); + + // returns false for non cached directory + // a cached but empty directory will return true but not append anything + bool listDirectory( const rtl::OString& rDir, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const; + // returns true for directoris that contain only user overridden fonts + bool scanAdditionalFiles( const rtl::OString& rDir ); + + void flush(); + + void updateDirTimestamp( int nDirID ); +}; + +} // namespace psp + +#endif // _PSPRINT_FONTCACHE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fontcapabilities.hxx b/vcl/inc/vcl/fontcapabilities.hxx new file mode 100644 index 000000000000..09eddf4e3a5b --- /dev/null +++ b/vcl/inc/vcl/fontcapabilities.hxx @@ -0,0 +1,221 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) + * Portions created by the Initial Developer are Copyright (C) 2011 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Caolán McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ +#ifndef _VCLFONTCAPABILITIES_HXX +#define _VCLFONTCAPABILITIES_HXX + +#include <boost/dynamic_bitset.hpp> +#include <vector> + +namespace vcl +{ + struct UnicodeCoverage + { + enum + { + BASIC_LATIN = 0, + LATIN_1_SUPPLEMENT = 1, + LATIN_EXTENDED_A = 2, + LATIN_EXTENDED_B = 3, + IPA_EXTENSIONS = 4, + SPACING_MODIFIER_LETTERS = 5, + COMBINING_DIACRITICAL_MARKS = 6, + GREEK_AND_COPTIC = 7, + COPTIC = 8, + CYRILLIC = 9, + ARMENIAN = 10, + HEBREW = 11, + VAI = 12, + ARABIC = 13, + NKO = 14, + DEVANAGARI = 15, + BENGALI = 16, + GURMUKHI = 17, + GUJARATI = 18, + ORIYA = 19, + TAMIL = 20, + TELUGU = 21, + KANNADA = 22, + MALAYALAM = 23, + THAI = 24, + LAO = 25, + GEORGIAN = 26, + BALINESE = 27, + HANGUL_JAMO = 28, + LATIN_EXTENDED_ADDITIONAL = 29, + GREEK_EXTENDED = 30, + GENERAL_PUNCTUATION = 31, + SUPERSCRIPTS_AND_SUBSCRIPTS = 32, + CURRENCY_SYMBOLS = 33, + COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS = 34, + LETTERLIKE_SYMBOLS = 35, + NUMBER_FORMS = 36, + ARROWS = 37, + MATHEMATICAL_OPERATORS = 38, + MISCELLANEOUS_TECHNICAL = 39, + CONTROL_PICTURES = 40, + OPTICAL_CHARACTER_RECOGNITION = 41, + ENCLOSED_ALPHANUMERICS = 42, + BOX_DRAWING = 43, + BLOCK_ELEMENTS = 44, + GEOMETRIC_SHAPES = 45, + MISCELLANEOUS_SYMBOLS = 46, + DINGBATS = 47, + CJK_SYMBOLS_AND_PUNCTUATION = 48, + HIRAGANA = 49, + KATAKANA = 50, + BOPOMOFO = 51, + HANGUL_COMPATIBILITY_JAMO = 52, + PHAGS_PA = 53, + ENCLOSED_CJK_LETTERS_AND_MONTHS = 54, + CJK_COMPATIBILITY = 55, + HANGUL_SYLLABLES = 56, + NONPLANE_0 = 57, + PHOENICIAN = 58, + CJK_UNIFIED_IDEOGRAPHS = 59, + PRIVATE_USE_AREA_PLANE_0 = 60, + CJK_STROKES = 61, + ALPHABETIC_PRESENTATION_FORMS = 62, + ARABIC_PRESENTATION_FORMS_A = 63, + COMBINING_HALF_MARKS = 64, + VERTICAL_FORMS = 65, + SMALL_FORM_VARIANTS = 66, + ARABIC_PRESENTATION_FORMS_B = 67, + HALFWIDTH_AND_FULLWIDTH_FORMS = 68, + SPECIALS = 69, + TIBETAN = 70, + SYRIAC = 71, + THAANA = 72, + SINHALA = 73, + MYANMAR = 74, + ETHIOPIC = 75, + CHEROKEE = 76, + UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS = 77, + OGHAM = 78, + RUNIC = 79, + KHMER = 80, + MONGOLIAN = 81, + BRAILLE_PATTERNS = 82, + YI_SYLLABLES = 83, + TAGALOG = 84, + OLD_ITALIC = 85, + GOTHIC = 86, + DESERET = 87, + BYZANTINE_MUSICAL_SYMBOLS = 88, + MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 89, + PRIVATE_USE_PLANE_15 = 90, + VARIATION_SELECTORS = 91, + TAGS = 92, + LIMBU = 93, + TAI_LE = 94, + NEW_TAI_LUE = 95, + BUGINESE = 96, + GLAGOLITIC = 97, + TIFINAGH = 98, + YIJING_HEXAGRAM_SYMBOLS = 99, + SYLOTI_NAGRI = 100, + LINEAR_B_SYLLABARY = 101, + ANCIENT_GREEK_NUMBERS = 102, + UGARITIC = 103, + OLD_PERSIAN = 104, + SHAVIAN = 105, + OSMANYA = 106, + CYPRIOT_SYLLABARY = 107, + KHAROSHTHI = 108, + TAI_XUAN_JING_SYMBOLS = 109, + CUNEIFORM = 110, + COUNTING_ROD_NUMERALS = 111, + SUNDANESE = 112, + LEPCHA = 113, + OL_CHIKI = 114, + SAURASHTRA = 115, + KAYAH_LI = 116, + REJANG = 117, + CHAM = 118, + ANCIENT_SYMBOLS = 119, + PHAISTOS_DISC = 120, + CARIAN = 121, + DOMINO_TILES = 122, + RESERVED1 = 123, + RESERVED2 = 124, + RESERVED3 = 125, + RESERVED4 = 126, + RESERVED5 = 127, + MAX_UC_ENUM = 128 + }; + }; + + struct CodePageCoverage + { + enum + { + CP1252 = 0, + CP1250 = 1, + CP1251 = 2, + CP1253 = 3, + CP1254 = 4, + CP1255 = 5, + CP1256 = 6, + CP1257 = 7, + CP1258 = 8, + CP874 = 16, + CP932 = 17, + CP936 = 18, + CP949 = 19, + CP950 = 20, + CP1361 = 21, + CP869 = 48, + CP866 = 49, + CP865 = 50, + CP864 = 51, + CP863 = 52, + CP862 = 53, + CP861 = 54, + CP860 = 55, + CP857 = 56, + CP855 = 57, + CP852 = 58, + CP775 = 59, + CP737 = 60, + CP780 = 61, + CP850 = 62, + CP437 = 63, + MAX_CP_ENUM = 64 + }; + }; + + struct FontCapabilities + { + boost::dynamic_bitset<sal_uInt32> maUnicodeRange; + boost::dynamic_bitset<sal_uInt32> maCodePageRange; + std::vector< sal_uInt32 > maGSUBScriptTags; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx new file mode 100644 index 000000000000..25674b76ae8a --- /dev/null +++ b/vcl/inc/vcl/fontmanager.hxx @@ -0,0 +1,750 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_FONTMANAGER_HXX_ +#define _PSPRINT_FONTMANAGER_HXX_ + +#include <boost/unordered_map.hpp> +#include <map> +#include <list> +#include <set> + +#include "vcl/dllapi.h" +#include "vcl/helper.hxx" + +#include "com/sun/star/lang/Locale.hpp" + +#include <vector> + +#define ATOM_FAMILYNAME 2 +#define ATOM_PSNAME 3 + +/* + * some words on metrics: every length returned by PrintFontManager and + * friends are PostScript afm style, that is they are 1/1000 font height + */ + +// forward declarations +namespace utl { class MultiAtomProvider; } // see unotools/atom.hxx +class FontSubsetInfo; +class ImplFontOptions; + +namespace psp { +class PPDParser; // see ppdparser.hxx + +namespace italic +{ +enum type { + Upright = 0, + Oblique = 1, + Italic = 2, + Unknown = 3 +}; +} + +namespace width +{ +enum type { + Unknown = 0, + UltraCondensed = 1, + ExtraCondensed = 2, + Condensed = 3, + SemiCondensed = 4, + Normal = 5, + SemiExpanded = 6, + Expanded = 7, + ExtraExpanded = 8, + UltraExpanded = 9 +}; +} + +namespace pitch +{ +enum type { + Unknown = 0, + Fixed = 1, + Variable = 2 +}; +} + +namespace weight +{ +enum type { + Unknown = 0, + Thin = 1, + UltraLight = 2, + Light = 3, + SemiLight = 4, + Normal = 5, + Medium = 6, + SemiBold = 7, + Bold = 8, + UltraBold = 9, + Black = 10 +}; +} + +namespace family +{ +enum type { + Unknown = 0, + Decorative = 1, + Modern = 2, + Roman = 3, + Script = 4, + Swiss = 5, + System = 6 +}; +} + +namespace fonttype +{ +enum type { + Unknown = 0, + Type1 = 1, + TrueType = 2, + Builtin = 3 +}; +} + +namespace fcstatus +{ +enum type { + istrue, + isunset, + isfalse +}; +} + +/* + * the difference between FastPrintFontInfo and PrintFontInfo + * is that the information in FastPrintFontInfo can usually + * be gathered without openening either the font file or + * an afm metric file. they are gathered from fonts.dir alone. + * if only FastPrintFontInfo is gathered and PrintFontInfo + * on demand and for less fonts, then performance in startup + * increases considerably + */ + +struct FastPrintFontInfo +{ + fontID m_nID; // FontID + fonttype::type m_eType; + + // font attributes + rtl::OUString m_aFamilyName; + rtl::OUString m_aStyleName; + std::list< rtl::OUString > m_aAliases; + family::type m_eFamilyStyle; + italic::type m_eItalic; + width::type m_eWidth; + weight::type m_eWeight; + pitch::type m_ePitch; + rtl_TextEncoding m_aEncoding; + bool m_bSubsettable; + bool m_bEmbeddable; + + FastPrintFontInfo() : + m_nID( 0 ), + m_eType( fonttype::Unknown ), + m_eFamilyStyle( family::Unknown ), + m_eItalic( italic::Unknown ), + m_eWidth( width::Unknown ), + m_eWeight( weight::Unknown ), + m_ePitch( pitch::Unknown ), + m_aEncoding( RTL_TEXTENCODING_DONTKNOW ) + {} +}; + +struct PrintFontInfo : public FastPrintFontInfo +{ + int m_nAscend; + int m_nDescend; + int m_nLeading; + int m_nWidth; + + PrintFontInfo() : + FastPrintFontInfo(), + m_nAscend( 0 ), + m_nDescend( 0 ), + m_nLeading( 0 ), + m_nWidth( 0 ) + {} +}; + +// the values are per thousand of the font size +// note: width, height contain advances, not bounding box +struct CharacterMetric +{ + short int width, height; + + CharacterMetric() : width( 0 ), height( 0 ) {} + bool operator==( const CharacterMetric& rOther ) const + { return rOther.width == width && rOther.height == height; } + bool operator!=( const CharacterMetric& rOther ) const + { return rOther.width != width || rOther.height != height; } +}; + +struct KernPair +{ + sal_Unicode first, second; + short int kern_x, kern_y; + + KernPair() : first( 0 ), second( 0 ), kern_x( 0 ), kern_y( 0 ) {} +}; + +class FontCache; + +// a class to manage printable fonts +// aims are type1 and truetype fonts + +class FontCache; + +class VCL_PLUGIN_PUBLIC PrintFontManager +{ + struct PrintFont; + struct TrueTypeFontFile; + struct Type1FontFile; + struct BuiltinFont; + friend struct PrintFont; + friend struct TrueTypeFontFile; + friend struct Type1FontFile; + friend struct BuiltinFont; + friend class FontCache; + + struct PrintFontMetrics + { + // character metrics are stored by the following keys: + // lower two bytes contain a sal_Unicode (a UCS2 character) + // upper byte contains: 0 for horizontal metric + // 1 for vertical metric + // highest byte: 0 for now + boost::unordered_map< int, CharacterMetric > m_aMetrics; + // contains the unicode blocks for which metrics were queried + // this implies that metrics should be queried in terms of + // unicode blocks. here a unicode block is identified + // by the upper byte of the UCS2 encoding. + // note that the corresponding bit should be set even + // if the font does not support a single character of that page + // this map shows, which pages were queried already + // if (like in AFM metrics) all metrics are queried in + // a single pass, then all bits should be set + char m_aPages[32]; + + bool m_bKernPairsQueried; + std::list< KernPair > m_aXKernPairs; + std::list< KernPair > m_aYKernPairs; + boost::unordered_map< sal_Unicode, bool > m_bVerticalSubstitutions; + + PrintFontMetrics() : m_bKernPairsQueried( false ) {} + + bool isEmpty() const { return m_aMetrics.empty(); } + }; + + struct PrintFont + { + fonttype::type m_eType; + + // font attributes + int m_nFamilyName; // atom + std::list< int > m_aAliases; + int m_nPSName; // atom + rtl::OUString m_aStyleName; + italic::type m_eItalic; + width::type m_eWidth; + weight::type m_eWeight; + pitch::type m_ePitch; + rtl_TextEncoding m_aEncoding; + bool m_bFontEncodingOnly; // set if font should be only accessed by builtin encoding + CharacterMetric m_aGlobalMetricX; + CharacterMetric m_aGlobalMetricY; + PrintFontMetrics* m_pMetrics; + int m_nAscend; + int m_nDescend; + int m_nLeading; + int m_nXMin; // font bounding box + int m_nYMin; + int m_nXMax; + int m_nYMax; + bool m_bHaveVerticalSubstitutedGlyphs; + bool m_bUserOverride; + + std::map< sal_Unicode, sal_Int32 > m_aEncodingVector; + std::map< sal_Unicode, rtl::OString > m_aNonEncoded; + + PrintFont( fonttype::type eType ); + virtual ~PrintFont(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) = 0; + + bool readAfmMetrics( const rtl::OString& rFileName, utl::MultiAtomProvider* pProvider, bool bFillEncodingvector, bool bOnlyGlobalAttributes ); + }; + + struct Type1FontFile : public PrintFont + { + int m_nDirectory; // atom containing system dependent path + rtl::OString m_aFontFile; // relative to directory + rtl::OString m_aMetricFile; // dito + rtl::OString m_aXLFD; // mainly for administration, contains the XLFD from fonts.dir + + /* note: m_aFontFile and Metric file are not atoms + because they should be fairly unique */ + + Type1FontFile() : PrintFont( fonttype::Type1 ), m_nDirectory( 0 ) {} + virtual ~Type1FontFile(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ); + }; + + struct TrueTypeFontFile : public PrintFont + { + int m_nDirectory; // atom containing system dependent path + rtl::OString m_aFontFile; // relative to directory + rtl::OString m_aXLFD; // mainly for administration, contains the XLFD from fonts.dir + int m_nCollectionEntry; // -1 for regular fonts, 0 to ... for fonts stemming from collections + unsigned int m_nTypeFlags; // copyright bits and PS-OpenType flag + + TrueTypeFontFile(); + virtual ~TrueTypeFontFile(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ); + }; + + struct BuiltinFont : public PrintFont + { + int m_nDirectory; // atom containing system dependent path + rtl::OString m_aMetricFile; + + BuiltinFont() : PrintFont( fonttype::Builtin ) {} + virtual ~BuiltinFont(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ); + }; + + struct XLFDEntry + { + static const int MaskFoundry = 1; + static const int MaskFamily = 2; + static const int MaskAddStyle = 4; + static const int MaskItalic = 8; + static const int MaskWeight = 16; + static const int MaskWidth = 32; + static const int MaskPitch = 64; + static const int MaskEncoding = 128; + + int nMask; // contains a bit set for every valid member + + rtl::OString aFoundry; + rtl::OString aFamily; + rtl::OString aAddStyle; + italic::type eItalic; + weight::type eWeight; + width::type eWidth; + pitch::type ePitch; + rtl_TextEncoding aEncoding; + + XLFDEntry() { nMask = 0; } + + bool operator<(const XLFDEntry& rRight) const; + bool operator==(const XLFDEntry& rRight) const; + }; + + static rtl::OString s_aEmptyOString; + + fontID m_nNextFontID; + boost::unordered_map< fontID, PrintFont* > m_aFonts; + boost::unordered_map< int, family::type > m_aFamilyTypes; + std::list< rtl::OUString > m_aPrinterDrivers; + std::list< rtl::OString > m_aFontDirectories; + std::list< int > m_aPrivateFontDirectories; + std::map< struct XLFDEntry, std::list< struct XLFDEntry > > + m_aXLFD_Aliases; + utl::MultiAtomProvider* m_pAtoms; + // for speeding up findFontFileID + boost::unordered_map< rtl::OString, std::set< fontID >, rtl::OStringHash > + m_aFontFileToFontID; + + boost::unordered_map< rtl::OString, int, rtl::OStringHash > + m_aDirToAtom; + boost::unordered_map< int, rtl::OString > m_aAtomToDir; + int m_nNextDirAtom; + + boost::unordered_multimap< rtl::OString, sal_Unicode, rtl::OStringHash > + m_aAdobenameToUnicode; + boost::unordered_multimap< sal_Unicode, rtl::OString > + m_aUnicodeToAdobename; + boost::unordered_multimap< sal_Unicode, sal_uInt8 > m_aUnicodeToAdobecode; + boost::unordered_multimap< sal_uInt8, sal_Unicode > m_aAdobecodeToUnicode; + + mutable FontCache* m_pFontCache; + bool m_bFontconfigSuccess; + + mutable std::vector< fontID > m_aOverrideFonts; + + rtl::OString getAfmFile( PrintFont* pFont ) const; + rtl::OString getFontFile( PrintFont* pFont ) const; + + void getFontAttributesFromXLFD( PrintFont* pFont, const std::list< rtl::OString >& rXLFDs ) const; + + bool analyzeFontFile( int nDirID, const rtl::OString& rFileName, const std::list< rtl::OString >& rXLFDs, std::list< PrintFont* >& rNewFonts ) const; + rtl::OUString convertTrueTypeName( void* pNameRecord ) const; // actually a NameRecord* formt font subsetting code + void analyzeTrueTypeFamilyName( void* pTTFont, std::list< rtl::OUString >& rnames ) const; // actually a TrueTypeFont* from font subsetting code + bool analyzeTrueTypeFile( PrintFont* pFont ) const; + // finds the FIRST id for this font file; there may be more + // for TrueType collections + fontID findFontFileID( int nDirID, const rtl::OString& rFile ) const; + fontID findFontBuiltinID( int nPSNameAtom ) const; + + family::type matchFamilyName( const rtl::OUString& rFamily ) const; + + PrintFont* getFont( fontID nID ) const + { + boost::unordered_map< fontID, PrintFont* >::const_iterator it; + it = m_aFonts.find( nID ); + return it == m_aFonts.end() ? NULL : it->second; + } + rtl::OString getXLFD( PrintFont* pFont ) const; + void fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& rInfo ) const; + void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const; + + const rtl::OString& getDirectory( int nAtom ) const; + int getDirectoryAtom( const rtl::OString& rDirectory, bool bCreate = false ); + + /* try to initialize fonts from libfontconfig + + called from <code>initialize()</code> + + @returns + true if at least one font was added by libfontconfig + false else (e.g. no libfontconfig found) + */ + bool initFontconfig(); + int countFontconfigFonts( boost::unordered_map<rtl::OString, int, rtl::OStringHash>& o_rVisitedPaths ); + /* deinitialize fontconfig + */ + void deinitFontconfig(); + + /* register an application specific font directory for libfontconfig + + since fontconfig is asked for font substitutes before OOo will check for font availability + and fontconfig will happily substitute fonts it doesn't know (e.g. "Arial Narrow" -> "DejaVu Sans Book"!) + it becomes necessary to tell the library about all the hidden font treasures + + @returns + true if libfontconfig accepted the directory + false else (e.g. no libfontconfig found) + */ + bool addFontconfigDir(const rtl::OString& rDirectory); + + static bool parseXLFD( const rtl::OString& rXLFD, XLFDEntry& rEntry ); + void parseXLFD_appendAliases( const std::list< rtl::OString >& rXLFDs, std::list< XLFDEntry >& rEntries ) const; + void initFontsAlias(); + + bool readOverrideMetrics(); + + PrintFontManager(); + ~PrintFontManager(); +public: + static PrintFontManager& get(); // one instance only + + int addFontFile( const rtl::OString& rFileName, int nFaceNum ); + + void initialize(); + + // returns the number of managed fonts + int getFontCount() const { return m_aFonts.size(); } + + // caution: the getFontList* methods can change the font list on demand + // depending on the pParser argument. That is getFontCount() may + // return a larger value after getFontList() + + // returns the ids of all managed fonts. on pParser != NULL + // all fonttype::Builtin type fonts are not listed + // which do not occur in the PPD of pParser + void getFontList( std::list< fontID >& rFontIDs, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false ); + // get the font list and detailed font info. see getFontList for pParser + void getFontListWithInfo( std::list< PrintFontInfo >& rFonts, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false ); + // get the font list and fast font info. see getFontList for pParser + void getFontListWithFastInfo( std::list< FastPrintFontInfo >& rFonts, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false ); + + // get font info for a specific font + bool getFontInfo( fontID nFontID, PrintFontInfo& rInfo ) const; + // get fast font info for a specific font + bool getFontFastInfo( fontID nFontID, FastPrintFontInfo& rInfo ) const; + + // routines to get font info in small pieces + + // get a specific fonts family name + const rtl::OUString& getFontFamily( fontID nFontID ) const; + // get a specific fonts PSName name + const rtl::OUString& getPSName( fontID nFontID ) const; + + // get a specific fonts style family + family::type getFontFamilyType( fontID nFontID ) const; + + // get a specific fonts family name aliases + void getFontFamilyAliases( fontID nFontID ) const; + + // get a specific fonts type + fonttype::type getFontType( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eType : fonttype::Unknown; + } + + // get a specific fonts italic type + italic::type getFontItalic( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eItalic : italic::Unknown; + } + + // get a specific fonts width type + width::type getFontWidth( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eWidth : width::Unknown; + } + + // get a specific fonts weight type + weight::type getFontWeight( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eWeight : weight::Unknown; + } + + // get a specific fonts pitch type + pitch::type getFontPitch( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_ePitch : pitch::Unknown; + } + + // get a specific fonts encoding + rtl_TextEncoding getFontEncoding( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_aEncoding : RTL_TEXTENCODING_DONTKNOW; + } + + // should i only use font's builtin encoding ? + bool getUseOnlyFontEncoding( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_bFontEncodingOnly : false; + } + + // get a specific fonts system dependent filename + rtl::OString getFontFileSysPath( fontID nFontID ) const + { + return getFontFile( getFont( nFontID ) ); + } + + // get the ttc face number + int getFontFaceNumber( fontID nFontID ) const; + + // get a specific fonts global metrics + const CharacterMetric& getGlobalFontMetric( fontID nFontID, bool bHorizontal ) const; + + // get a specific fonts ascend + int getFontAscend( fontID nFontID ) const; + + // get a specific fonts descent + int getFontDescend( fontID nFontID ) const; + + // get a specific fonts leading + int getFontLeading( fontID nFontID ) const; + + // get a fonts glyph bounding box + bool getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax ); + + // info whether there are vertical substitutions + bool hasVerticalSubstitutions( fontID nFontID ) const; + + // info whether an array of glyphs has vertical substitutions + void hasVerticalSubstitutions( fontID nFontID, const sal_Unicode* pCharacters, + int nCharacters, bool* pHasSubst ) const; + + // get the XLFD for a font that originated from the X fontpath + // note: this may not be the original line that was in the fonts.dir + // returns a string for every font, but only TrueType and Type1 + // fonts originated from the X font path, so check for the font type + rtl::OUString getFontXLFD( fontID nFontID ) const; + + // get a specific fonts metrics + + // get metrics for a sal_Unicode range + // the user is responsible to allocate pArray large enough + bool getMetrics( fontID nFontID, sal_Unicode minCharacter, sal_Unicode maxCharacter, CharacterMetric* pArray, bool bVertical = false ) const; + // get metrics for an array of sal_Unicode characters + // the user is responsible to allocate pArray large enough + bool getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray, bool bVertical = false ) const; + + // get encoding vector of font, currently only for Type1 and Builtin fonts + // returns NULL if encoding vector is empty or font is neither type1 or + // builtin; if ppNonEncoded is set and non encoded type1 glyphs exist + // then *ppNonEncoded is set to the mapping for nonencoded glyphs. + // the encoding vector contains -1 for non encoded glyphs + const std::map< sal_Unicode, sal_Int32 >* getEncodingMap( fontID nFontID, const std::map< sal_Unicode, rtl::OString >** ppNonEncoded ) const; + + // to get font substitution transparently use the + // getKernPairs method of PrinterGfx + const std::list< KernPair >& getKernPairs( fontID nFontID, bool bVertical = false ) const; + + // evaluates copyright flags for TrueType fonts + // type1 fonts do not have such a feature, so return for them is true + // returns true for builtin fonts (surprise!) + bool isFontDownloadingAllowed( fontID nFont ) const; + + // helper for type 1 fonts + std::list< rtl::OString > getAdobeNameFromUnicode( sal_Unicode aChar ) const; + + std::pair< boost::unordered_multimap< sal_Unicode, sal_uInt8 >::const_iterator, + boost::unordered_multimap< sal_Unicode, sal_uInt8 >::const_iterator > + getAdobeCodeFromUnicode( sal_Unicode aChar ) const + { + return m_aUnicodeToAdobecode.equal_range( aChar ); + } + std::list< sal_Unicode > getUnicodeFromAdobeName( const rtl::OString& rName ) const; + std::pair< boost::unordered_multimap< sal_uInt8, sal_Unicode >::const_iterator, + boost::unordered_multimap< sal_uInt8, sal_Unicode >::const_iterator > + getUnicodeFromAdobeCode( sal_uInt8 aChar ) const + { + return m_aAdobecodeToUnicode.equal_range( aChar ); + } + + // creates a new font subset of an existing TrueType font + // returns true in case of success, else false + // nFont: the font to be subsetted + // rOutFile: the file to put the new subset into; + // must be a valid osl file URL + // pGlyphIDs: input array of glyph ids for new font + // pNewEncoding: the corresponding encoding in the new font + // pWidths: output array of widths of requested glyphs + // nGlyphs: number of glyphs in arrays + // pCapHeight:: capital height of the produced font + // pXMin, pYMin, pXMax, pYMax: outgoing font bounding box + // TODO: callers of this method should use its FontSubsetInfo counterpart directly + bool createFontSubset( FontSubsetInfo&, + fontID nFont, + const rtl::OUString& rOutFile, + sal_Int32* pGlyphIDs, + sal_uInt8* pNewEncoding, + sal_Int32* pWidths, + int nGlyphs, + bool bVertical = false + ); + void getGlyphWidths( fontID nFont, + bool bVertical, + std::vector< sal_Int32 >& rWidths, + std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc ); + + + // font administration functions + + // for importFonts to provide the user feedback + class ImportFontCallback + { + public: + enum FailCondition { NoWritableDirectory, NoAfmMetric, AfmCopyFailed, FontCopyFailed }; + virtual void importFontsFailed( FailCondition eReason ) = 0; + virtual void progress( const rtl::OUString& rFile ) = 0; + virtual bool queryOverwriteFile( const rtl::OUString& rFile ) = 0; + virtual void importFontFailed( const rtl::OUString& rFile, FailCondition ) = 0; + virtual bool isCanceled() = 0; + }; + + // checks wether font import would fail due to no writeable directory + bool checkImportPossible() const; + // expects system paths not UNC paths + // returns the number of fonts successfully imported + int importFonts( const std::list< rtl::OString >& rFiles, bool bLinkOnly = false, ImportFontCallback* pCallback = NULL ); + + // check wether changeFontProperties would fail due to not writable fonts.dir + bool checkChangeFontPropertiesPossible( fontID nFont ) const; + // change fonts.dir entry for font + bool changeFontProperties( fontID nFont, const rtl::OUString& rXLFD ); + + // get properties of a not imported font file + bool getImportableFontProperties( const rtl::OString& rFile, std::list< FastPrintFontInfo >& rFontProps ); + + // get fonts that come from the same font file + bool getFileDuplicates( fontID nFont, std::list< fontID >& rFonts ) const; + // remove font files + bool removeFonts( const std::list< fontID >& rFonts ); + + bool isPrivateFontFile( fontID ) const; + + // returns false if there were not any + bool getAlternativeFamilyNames( fontID nFont, std::list< rtl::OUString >& rNames ) const; + + /* system dependendent font matching + + <p> + <code>matchFont</code> matches a pattern of font characteristics + and returns the closest match if possibe. If a match was found + the <code>FastPrintFontInfo</code> passed in as parameter + will be update to the found matching font. + </p> + <p> + implementation note: currently the function is only implemented + for fontconfig. + </p> + + @param rInfo + out of the FastPrintFontInfo structure the following + fields will be used for the match: + <ul> + <li>family name</li> + <li>italic</li> + <li>width</li> + <li>weight</li> + <li>pitch</li> + </ul> + + @param rLocale + if <code>rLocal</code> contains non empty strings the corresponding + locale will be used for font matching also; e.g. "Sans" can result + in different fonts in e.g. english and japanese + + @returns + true if a match was found + false else + */ + bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale ); + ImplFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*)) const; + + rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes, + const rtl::OString& rLangAttrib, italic::type& rItalic, weight::type& rWeight, + width::type& rWidth, pitch::type& rPitch) const; + bool hasFontconfig() const { return m_bFontconfigSuccess; } + + int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar ); +}; + +} // namespace + +#endif // _PSPRINT_FONTMANAGER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/fontsubset.hxx b/vcl/inc/vcl/fontsubset.hxx new file mode 100644 index 000000000000..f710434698de --- /dev/null +++ b/vcl/inc/vcl/fontsubset.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_FONTSUBSET_HXX +#define _SV_FONTSUBSET_HXX + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <cstdio> + +namespace vcl { struct _TrueTypeFont; } // SFT's idea of a TTF font + +class FontSubsetInfo +{ +public: + explicit FontSubsetInfo( void ); + virtual ~FontSubsetInfo( void ); + + enum FontType { + NO_FONT = 0, + SFNT_TTF = 1<<1, // SFNT container with TrueType glyphs + SFNT_CFF = 1<<2, // SFNT container with CFF-container + TYPE1_PFA = 1<<3, // PSType1 Postscript Font Ascii + TYPE1_PFB = 1<<4, // PSType1 Postscript Font Binary + CFF_FONT = 1<<5, // CFF-container with PSType2 glyphs + TYPE3_FONT = 1<<6, // PSType3 Postscript font + TYPE42_FONT = 1<<7, // PSType42 wrapper for an SFNT_TTF + ANY_SFNT = SFNT_TTF | SFNT_CFF, + ANY_TYPE1 = TYPE1_PFA | TYPE1_PFB, + ANY_FONT = 0xFF + }; + + bool LoadFont( FontType eInFontType, + const unsigned char* pFontBytes, int nByteLength ); + bool LoadFont( vcl::_TrueTypeFont* pSftTrueTypeFont ); + + bool CreateFontSubset( int nOutFontTypeMask, + FILE* pOutFile, const char* pOutFontName, + const long* pReqGlyphIds, const sal_uInt8* pEncodedIds, + int nReqGlyphCount, sal_Int32* pOutGlyphWidths = NULL ); + +public: // TODO: make subsetter results private and provide accessor methods instead + // subsetter-provided subset details needed by e.g. Postscript or PDF + String m_aPSName; + int m_nAscent; // all metrics in PS font units + int m_nDescent; + int m_nCapHeight; + Rectangle m_aFontBBox; + FontType m_nFontType; // font-type of subset result + +private: + // input-font-specific details + unsigned const char* mpInFontBytes; + int mnInByteLength; + FontType meInFontType; // allowed mask of input font-types + vcl::_TrueTypeFont* mpSftTTFont; + + // subset-request details + int mnReqFontTypeMask; // allowed subset-target font types + FILE* mpOutFile; + const char* mpReqFontName; + const long* mpReqGlyphIds; + const sal_uInt8* mpReqEncodedIds; + int mnReqGlyphCount; + +protected: + bool CreateFontSubsetFromCff( sal_Int32* pOutGlyphWidths = NULL ); + bool CreateFontSubsetFromSfnt( sal_Int32* pOutGlyphWidths = NULL ); + bool CreateFontSubsetFromType1( sal_Int32* pOutGlyphWidths = NULL ); +}; + +#endif // _SV_FONTSUBSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx new file mode 100644 index 000000000000..ffbd4867ecb8 --- /dev/null +++ b/vcl/inc/vcl/gdimtf.hxx @@ -0,0 +1,279 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GDIMTF_HXX +#define _SV_GDIMTF_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/list.hxx> +#include <tools/string.hxx> +#include <vcl/mapmod.hxx> + +class OutputDevice; +class ImpLabelList; +class MetaAction; +class MetaCommentAction; +class SvStream; +class Color; +class BitmapEx; +class Polygon; +class PolyPolygon; +class Gradient; + +// --------------------- +// - GDIMetaFile-Types - +// --------------------- + +#define GDI_METAFILE_END ((sal_uLong)0xFFFFFFFF) +#define GDI_METAFILE_LABEL_NOTFOUND ((sal_uLong)0xFFFFFFFF) + +#ifndef METAFILE_END +#define METAFILE_END GDI_METAFILE_END +#endif + +#ifndef METAFILE_LABEL_NOTFOUND +#define METAFILE_LABEL_NOTFOUND GDI_METAFILE_LABEL_NOTFOUND +#endif + +// ----------- +// - Defines - +// ----------- + +#define MTF_MIRROR_NONE 0x00000000UL +#define MTF_MIRROR_HORZ 0x00000001UL +#define MTF_MIRROR_VERT 0x00000002UL + +// --------- +// - Enums - +// --------- + +enum MtfConversion +{ + MTF_CONVERSION_NONE = 0, + MTF_CONVERSION_1BIT_THRESHOLD = 1, + MTF_CONVERSION_8BIT_GREYS = 2 +}; + +// ----------------------------- +// - Color conversion routines - +// ----------------------------- + +typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam ); +typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam ); + + +// --------------- +// - GDIMetaFile - +// --------------- + +class VCL_DLLPUBLIC GDIMetaFile : protected List +{ +private: + + MapMode aPrefMapMode; + Size aPrefSize; + Link aHookHdlLink; + GDIMetaFile* pPrev; + GDIMetaFile* pNext; + OutputDevice* pOutDev; + ImpLabelList* pLabelList; + sal_Bool bPause; + sal_Bool bRecord; + sal_Bool bUseCanvas; + + + SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam, + BmpExchangeFnc pFncBmp, const void* pBmpParam ); + + SAL_DLLPRIVATE Point ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE Polygon ImplGetRotatedPolygon( const Polygon& rPoly, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE PolyPolygon ImplGetRotatedPolyPolygon( const PolyPolygon& rPoly, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE void ImplAddGradientEx( GDIMetaFile& rMtf, + const OutputDevice& rMapDev, + const PolyPolygon& rPolyPoly, + const Gradient& rGrad ); + SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rDestSize ); + SAL_DLLPRIVATE void ImplDelegate2PluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut ); + + +protected: + + virtual void Linker( OutputDevice* pOut, sal_Bool bLink ); + virtual long Hook(); + +public: + GDIMetaFile(); + GDIMetaFile( const GDIMetaFile& rMtf ); + virtual ~GDIMetaFile(); + + using List::operator==; + using List::operator!=; + GDIMetaFile& operator=( const GDIMetaFile& rMtf ); + sal_Bool operator==( const GDIMetaFile& rMtf ) const; + sal_Bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); } + + void Clear(); + sal_Bool IsEqual( const GDIMetaFile& rMtf ) const; + sal_Bool Mirror( sal_uLong nMirrorFlags ); + void Move( long nX, long nY ); + // additional Move method getting specifics how to handle MapMode( MAP_PIXEL ) + void Move( long nX, long nY, long nDPIX, long nDPIY ); + void Scale( double fScaleX, double fScaleY ); + 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, + short nChannelBPercent = 0, double fGamma = 1.0, sal_Bool bInvert = sal_False ); + void Convert( MtfConversion eConversion ); + void ReplaceColors( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol = 0 ); + void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors, + sal_uLong nColorCount, sal_uLong* pTols = NULL ); + + GDIMetaFile GetMonochromeMtf( const Color& rCol ) const; + + void Record( OutputDevice* pOutDev ); + sal_Bool IsRecord() const { return bRecord; } + + void Play( GDIMetaFile& rMtf, sal_uLong nPos = GDI_METAFILE_END ); + void Play( OutputDevice* pOutDev, sal_uLong nPos = GDI_METAFILE_END ); + void Play( OutputDevice* pOutDev, const Point& rPos, + const Size& rSize, sal_uLong nPos = GDI_METAFILE_END ); + + void Pause( sal_Bool bPause ); + sal_Bool IsPause() const { return bPause; } + + void Stop(); + + void WindStart(); + void WindEnd(); + void Wind( sal_uLong nAction ); + void WindPrev(); + void WindNext(); + + sal_uLong GetActionCount() const { return Count(); } + void AddAction( MetaAction* pAction ); + void AddAction( MetaAction* pAction, sal_uLong nPos ); + void RemoveAction( sal_uLong nPos ); + MetaAction* CopyAction( sal_uLong nPos ) const; + MetaAction* GetCurAction() const { return (MetaAction*) GetCurObject(); } + MetaAction* GetAction( sal_uLong nAction ) const { return (MetaAction*) GetObject( nAction ); } + MetaAction* FirstAction() { return (MetaAction*) First(); } + MetaAction* NextAction() { return (MetaAction*) Next(); } + MetaAction* ReplaceAction( MetaAction* pAction, sal_uLong nAction ) { return (MetaAction*) Replace( pAction, nAction ); } + + sal_uLong GetActionPos( const String& rLabel ); + sal_Bool InsertLabel( const String& rLabel, sal_uLong nActionPos ); + void RemoveLabel( const String& rLabel ); + void RenameLabel( const String& rLabel, const String& rNewLabel ); + sal_uLong GetLabelCount() const; + String GetLabel( sal_uLong nLabel ); + + sal_Bool SaveStatus(); + + const Size& GetPrefSize() const { return aPrefSize; } + void SetPrefSize( const Size& rSize ) { aPrefSize = rSize; } + + const MapMode& GetPrefMapMode() const { return aPrefMapMode; } + void SetPrefMapMode( const MapMode& rMapMode ) { aPrefMapMode = rMapMode; } + + void SetHookHdl( const Link& rLink ) { aHookHdlLink = rLink; } + const Link& GetHookHdl() const { return aHookHdlLink; } + + sal_uLong GetChecksum() const; + sal_uLong GetSizeBytes() const; + + // Methoden zum Lesen und Schreiben des neuen Formats; + // die Read-Methode kann auch das alte Format lesen + SvStream& Read( SvStream& rIStm ); + SvStream& Write( SvStream& rOStm ); + + // Stream-Operatoren schreiben das alte Format (noch) + // und lesen sowohl das alte wie auch das neue Format + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, GDIMetaFile& rGDIMetaFile ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile ); + + sal_Bool CreateThumbnail( sal_uInt32 nMaximumExtent, BitmapEx& rBmpEx, const BitmapEx* pOverlay = NULL, const Rectangle* pOverlayRect = NULL ) const; + + void UseCanvas( sal_Bool _bUseCanvas ); + sal_Bool GetUseCanvas() const { return bUseCanvas; } +}; + +/** Create a special metaaction that delegates rendering to specified + service. + + This factory function creates a MetaCommentAction that delegates + rendering to the specified services, once played back in the + metafile. + + @param rRendererServiceName + Renderer service. Gets an awt::XGraphic on instantiation + + @param rGraphicServiceName + Graphic service. Gets the raw data on instantiation + + @param pData + Raw data. Gets copied + + @param nDataSize + Length, in byte, of raw data + */ +MetaCommentAction* makePluggableRendererAction( const rtl::OUString& rRendererServiceName, + const rtl::OUString& rGraphicServiceName, + const void* pData, + sal_uInt32 nDataSize ); + +#endif // _SV_GDIMTF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/gfxlink.hxx b/vcl/inc/vcl/gfxlink.hxx new file mode 100644 index 000000000000..1d4362f00dc1 --- /dev/null +++ b/vcl/inc/vcl/gfxlink.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GFXLINK_HXX +#define _SV_GFXLINK_HXX + +#include <vcl/dllapi.h> +#include <vcl/sv.h> +#include <vcl/mapmod.hxx> +#include <tools/stream.hxx> + +// ------------- +// - ImpBuffer - +// ------------- + +struct ImpBuffer +{ + sal_uLong mnRefCount; + sal_uInt8* mpBuffer; + + ImpBuffer( sal_uLong nSize ) + { + mnRefCount = 1UL; + mpBuffer = nSize ? new sal_uInt8[ nSize ] : NULL; + } + + ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; } + + ~ImpBuffer() { delete[] mpBuffer; } +}; + +// ----------- +// - ImpSwap - +// ----------- + +struct ImpSwap +{ + rtl::OUString maURL; + sal_uLong mnDataSize; + sal_uLong mnRefCount; + + ImpSwap( sal_uInt8* pData, sal_uLong nDataSize ); + ~ImpSwap(); + + sal_uInt8* GetData() const; + + sal_Bool IsSwapped() const { return maURL.getLength() > 0; } + + void WriteTo( SvStream& rOStm ) const; +}; + +// -------------- +// - ImpGfxLink - +// -------------- + +struct ImpGfxLink +{ + MapMode maPrefMapMode; + Size maPrefSize; + bool mbPrefMapModeValid; + bool mbPrefSizeValid; + + ImpGfxLink() : + maPrefMapMode(), + maPrefSize(), + mbPrefMapModeValid( false ), + mbPrefSizeValid( false ) + {} +}; + +//#endif // __PRIVATE + +// --------------- +// - GfxLinkType - +// --------------- + +enum GfxLinkType +{ + GFX_LINK_TYPE_NONE = 0, + GFX_LINK_TYPE_EPS_BUFFER = 1, + GFX_LINK_TYPE_NATIVE_GIF = 2, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_JPG = 3, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_PNG = 4, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_TIF = 5, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_WMF = 6, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_MET = 7, // Don't forget to update the following defines + GFX_LINK_TYPE_NATIVE_PCT = 8, // Don't forget to update the following defines + GFX_LINK_TYPE_USER = 0xffff +}; + +#define GFX_LINK_FIRST_NATIVE_ID GFX_LINK_TYPE_NATIVE_GIF +#define GFX_LINK_LAST_NATIVE_ID GFX_LINK_TYPE_NATIVE_PCT + +// ----------- +// - GfxLink - +// ----------- + +struct ImpBuffer; +struct ImpSwap; +struct ImpGfxLink; +class Graphic; + +class VCL_DLLPUBLIC GfxLink +{ +private: + + GfxLinkType meType; + ImpBuffer* mpBuf; + ImpSwap* mpSwap; + sal_uInt32 mnBufSize; + sal_uInt32 mnUserId; + ImpGfxLink* mpImpData; + sal_uLong mnExtra2; + + SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink ); + +public: + GfxLink(); + GfxLink( const GfxLink& ); + GfxLink( const String& rPath, GfxLinkType nType ); + GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType, sal_Bool bOwns ); + ~GfxLink(); + + GfxLink& operator=( const GfxLink& ); + sal_Bool IsEqual( const GfxLink& ) const; + + GfxLinkType GetType() const; + + void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } + sal_uInt32 GetUserId() const { return mnUserId; } + + sal_uInt32 GetDataSize() const; + void SetData( sal_uInt8* pBuf, sal_uInt32 nSize, GfxLinkType nType, sal_Bool bOwns ); + const sal_uInt8* GetData() const; + + const Size& GetPrefSize() const; + void SetPrefSize( const Size& rPrefSize ); + bool IsPrefSizeValid(); + + const MapMode& GetPrefMapMode() const; + void SetPrefMapMode( const MapMode& rPrefMapMode ); + bool IsPrefMapModeValid(); + + sal_Bool IsNative() const; + sal_Bool IsUser() const { return( GFX_LINK_TYPE_USER == meType ); } + + sal_Bool LoadNative( Graphic& rGraphic ); + + sal_Bool ExportNative( SvStream& rOStream ) const; + + void SwapOut(); + void SwapIn(); + sal_Bool IsSwappedOut() const { return( mpSwap != NULL ); } + +public: + + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const GfxLink& rGfxLink ); + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, GfxLink& rGfxLink ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx new file mode 100644 index 000000000000..dc11ba1637d8 --- /dev/null +++ b/vcl/inc/vcl/glyphcache.hxx @@ -0,0 +1,391 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GLYPHCACHE_HXX +#define _SV_GLYPHCACHE_HXX + +#include <vcl/dllapi.h> + +class GlyphCache; +class GlyphMetric; +class GlyphData; +class ServerFont; +class GlyphCachePeer; +class ServerFontLayoutEngine; +class ServerFontLayout; +class ExtraKernInfo; +struct ImplKernPairData; +class ImplFontOptions; + +#include <tools/gen.hxx> +#include <boost/unordered_map.hpp> +#include <boost/unordered_set.hpp> +#include <boost/shared_ptr.hpp> + +namespace basegfx { class B2DPolyPolygon; } + +class RawBitmap; + +#include <vcl/outfont.hxx> +#include <vcl/impfont.hxx> + +class ServerFontLayout; +#include <vcl/sallayout.hxx> + +namespace vcl +{ + struct FontCapabilities; +} + +// ======================================================================= + +class VCL_PLUGIN_PUBLIC GlyphCache +{ +public: + explicit GlyphCache( GlyphCachePeer& ); + /*virtual*/ ~GlyphCache(); + + static GlyphCache& GetInstance(); + void LoadFonts(); + + void ClearFontPath(); + void AddFontPath( const String& rFontPath ); + void AddFontFile( const rtl::OString& rNormalizedName, + int nFaceNum, sal_IntPtr nFontId, const ImplDevFontAttributes&, + const ExtraKernInfo* = NULL ); + void AnnounceFonts( ImplDevFontList* ) const; + + ServerFont* CacheFont( const ImplFontSelectData& ); + void UncacheFont( ServerFont& ); + void InvalidateAllGlyphs(); + +protected: + GlyphCachePeer& mrPeer; + +private: + friend class ServerFont; + // used by ServerFont class only + void AddedGlyph( ServerFont&, GlyphData& ); + void RemovingGlyph( ServerFont&, GlyphData&, int nGlyphIndex ); + void UsingGlyph( ServerFont&, GlyphData& ); + void GrowNotify(); + +private: + sal_uLong CalcByteCount() const; + void GarbageCollect(); + + // the GlyphCache's FontList matches a font request to a serverfont instance + // the FontList key's mpFontData member is reinterpreted as integer font id + struct IFSD_Equal{ bool operator()( const ImplFontSelectData&, const ImplFontSelectData& ) const; }; + struct IFSD_Hash{ size_t operator()( const ImplFontSelectData& ) const; }; + typedef ::boost::unordered_map<ImplFontSelectData,ServerFont*,IFSD_Hash,IFSD_Equal > FontList; + FontList maFontList; + sal_uLong mnMaxSize; // max overall cache size in bytes + mutable sal_uLong mnBytesUsed; + mutable long mnLruIndex; + mutable int mnGlyphCount; + ServerFont* mpCurrentGCFont; + + class FreetypeManager* mpFtManager; +}; + +// ======================================================================= + +class GlyphMetric +{ +public: + Point GetOffset() const { return maOffset; } + Point GetDelta() const { return maDelta; } + Size GetSize() const { return maSize; } + long GetCharWidth() const { return mnAdvanceWidth; } + +protected: + friend class GlyphData; + void SetOffset( int nX, int nY ) { maOffset = Point( nX, nY); } + void SetDelta( int nX, int nY ) { maDelta = Point( nX, nY); } + void SetSize( const Size& s ) { maSize = s; } + void SetCharWidth( long nW ) { mnAdvanceWidth = nW; } + +private: + long mnAdvanceWidth; + Point maDelta; + Point maOffset; + Size maSize; +}; + +// ----------------------------------------------------------------------- + +// the glyph specific data needed by a GlyphCachePeer is usually trivial, +// not attaching it to the corresponding GlyphData would be overkill +struct ExtGlyphData +{ + int meInfo; + void* mpData; + + ExtGlyphData() : meInfo(0), mpData(NULL) {} +}; + +// ----------------------------------------------------------------------- + +class GlyphData +{ +public: + const GlyphMetric& GetMetric() const { return maMetric; } + Size GetSize() const { return maMetric.GetSize(); } + + void SetSize( const Size& s) { maMetric.SetSize( s ); } + void SetOffset( int nX, int nY ) { maMetric.SetOffset( nX, nY ); } + void SetDelta( int nX, int nY ) { maMetric.SetDelta( nX, nY ); } + void SetCharWidth( long nW ) { maMetric.SetCharWidth( nW ); } + + void SetLruValue( int n ) const { mnLruValue = n; } + long GetLruValue() const { return mnLruValue;} + + ExtGlyphData& ExtDataRef() { return maExtData; } + const ExtGlyphData& ExtDataRef() const { return maExtData; } + +private: + GlyphMetric maMetric; + ExtGlyphData maExtData; + + // used by GlyphCache for cache LRU algorithm + mutable long mnLruValue; +}; + +// ======================================================================= + +class VCL_PLUGIN_PUBLIC ServerFont +{ +public: + virtual const ::rtl::OString* GetFontFileName() const { return NULL; } + virtual int GetFontFaceNumber() const { return 0; } + virtual bool TestFont() const { return true; } + virtual void* GetFtFace() const { return 0; } + virtual int GetLoadFlags() const { return 0; } + virtual void SetFontOptions( boost::shared_ptr<ImplFontOptions> ) {} + virtual boost::shared_ptr<ImplFontOptions> GetFontOptions() const + { return boost::shared_ptr<ImplFontOptions>(); } + virtual bool NeedsArtificialBold() const { return false; } + virtual bool NeedsArtificialItalic() const { return false; } + + const ImplFontSelectData& GetFontSelData() const { return maFontSelData; } + + virtual void FetchFontMetric( ImplFontMetricData&, long& rFactor ) const = 0; + virtual sal_uLong GetKernPairs( ImplKernPairData** ) const { return 0; } + virtual int GetGlyphKernValue( int, int ) const { return 0; } + virtual const ImplFontCharMap* GetImplFontCharMap() const = 0; + virtual bool GetFontCapabilities(vcl::FontCapabilities &) const { return false; } + Point TransformPoint( const Point& ) const; + + GlyphData& GetGlyphData( int nGlyphIndex ); + const GlyphMetric& GetGlyphMetric( int nGlyphIndex ) + { return GetGlyphData( nGlyphIndex ).GetMetric(); } + + virtual int GetGlyphIndex( sal_UCS4 ) const = 0; + virtual bool GetGlyphOutline( int nGlyphIndex, ::basegfx::B2DPolyPolygon& ) const = 0; + virtual bool GetAntialiasAdvice( void ) const = 0; + bool IsGlyphInvisible( int nGlyphIndex ); + virtual bool GetGlyphBitmap1( int nGlyphIndex, RawBitmap& ) const = 0; + virtual bool GetGlyphBitmap8( int nGlyphIndex, RawBitmap& ) const = 0; + + void SetExtended( int nInfo, void* ppVoid ); + int GetExtInfo() { return mnExtInfo; } + void* GetExtPointer() { return mpExtData; } + +protected: + friend class GlyphCache; + friend class ServerFontLayout; + explicit ServerFont( const ImplFontSelectData& ); + virtual ~ServerFont(); + + void AddRef() const { ++mnRefCount; } + long GetRefCount() const { return mnRefCount; } + long Release() const; + sal_uLong GetByteCount() const { return mnBytesUsed; } + + virtual void InitGlyphData( int nGlyphIndex, GlyphData& ) const = 0; + virtual void GarbageCollect( long ); + void ReleaseFromGarbageCollect(); + + virtual ServerFontLayoutEngine* GetLayoutEngine() { return NULL; } + +private: + typedef ::boost::unordered_map<int,GlyphData> GlyphList; + mutable GlyphList maGlyphList; + + const ImplFontSelectData maFontSelData; + + // info for GlyphcachePeer + int mnExtInfo; + void* mpExtData; + + // used by GlyphCache for cache LRU algorithm + mutable long mnRefCount; + mutable sal_uLong mnBytesUsed; + + ServerFont* mpPrevGCFont; + ServerFont* mpNextGCFont; + +protected: + // 16.16 fixed point values used for a rotated font + long mnCos; + long mnSin; +private: + int mnZWJ; + int mnZWNJ; + bool mbCollectedZW; +}; + +// ======================================================================= + +// a class for cache entries for physical font instances that are based on serverfonts +class VCL_PLUGIN_PUBLIC ImplServerFontEntry : public ImplFontEntry +{ +private: + ServerFont* mpServerFont; + boost::shared_ptr<ImplFontOptions> mpFontOptions; + bool mbGotFontOptions; + +public: + ImplServerFontEntry( ImplFontSelectData& ); + virtual ~ImplServerFontEntry(); + void SetServerFont( ServerFont* p) { mpServerFont = p; } + void HandleFontOptions(); +}; + +// ======================================================================= + +class VCL_PLUGIN_PUBLIC ServerFontLayout : public GenericSalLayout +{ +private: + ServerFont& mrServerFont; + + // enforce proper copy semantic + SAL_DLLPRIVATE ServerFontLayout( const ServerFontLayout& ); + SAL_DLLPRIVATE ServerFontLayout& operator=( const ServerFontLayout& ); + +public: + ServerFontLayout( ServerFont& ); + virtual bool LayoutText( ImplLayoutArgs& ); + virtual void AdjustLayout( ImplLayoutArgs& ); + virtual void DrawText( SalGraphics& ) const; + ServerFont& GetServerFont() const { return mrServerFont; } +}; + +// ======================================================================= + +class ServerFontLayoutEngine +{ +public: + virtual ~ServerFontLayoutEngine() {} + virtual bool operator()( ServerFontLayout&, ImplLayoutArgs& ); +}; + +// ======================================================================= + +class GlyphCachePeer +{ +protected: + GlyphCachePeer() : mnBytesUsed(0) {} + virtual ~GlyphCachePeer() {} + +public: + sal_Int32 GetByteCount() const { return mnBytesUsed; } + virtual void RemovingFont( ServerFont& ) {} + virtual void RemovingGlyph( ServerFont&, GlyphData&, int ) {} + +protected: + sal_Int32 mnBytesUsed; +}; + +// ======================================================================= + +class VCL_PLUGIN_PUBLIC RawBitmap +{ +public: + RawBitmap(); + ~RawBitmap(); + bool Rotate( int nAngle ); + +public: + unsigned char* mpBits; + sal_uLong mnAllocated; + + sal_uLong mnWidth; + sal_uLong mnHeight; + + sal_uLong mnScanlineSize; + sal_uLong mnBitCount; + + int mnXOffset; + int mnYOffset; +}; + +// ======================================================================= + +inline void ServerFont::SetExtended( int nInfo, void* pVoid ) +{ + mnExtInfo = nInfo; + mpExtData = pVoid; +} + +// ======================================================================= + +// ExtraKernInfo allows an on-demand query of extra kerning info #i29881# +// The kerning values have to be scaled to match the font size before use +class VCL_PLUGIN_PUBLIC ExtraKernInfo +{ +public: + ExtraKernInfo( sal_IntPtr nFontId ); + virtual ~ExtraKernInfo() {} + + bool HasKernPairs() const; + int GetUnscaledKernPairs( ImplKernPairData** ) const; + int GetUnscaledKernValue( sal_Unicode cLeft, sal_Unicode cRight ) const; + +protected: + mutable bool mbInitialized; + virtual void Initialize() const = 0; + +protected: + sal_IntPtr mnFontId; + + // container to map a unicode pair to an unscaled kerning value + struct PairEqual{ int operator()(const ImplKernPairData& rA, const ImplKernPairData& rB) const + { return (rA.mnChar1 == rB.mnChar1) && (rA.mnChar2 == rB.mnChar2); } }; + struct PairHash{ int operator()(const ImplKernPairData& rA) const + { return (rA.mnChar1) * 256 ^ rA.mnChar2; } }; + typedef boost::unordered_set< ImplKernPairData, PairHash, PairEqual > UnicodeKernPairs; + mutable UnicodeKernPairs maUnicodeKernPairs; +}; + +// ======================================================================= + +#endif // _SV_GLYPHCACHE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/gradient.hxx b/vcl/inc/vcl/gradient.hxx new file mode 100644 index 000000000000..1ed0c12ce98f --- /dev/null +++ b/vcl/inc/vcl/gradient.hxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GRADIENT_HXX +#define _SV_GRADIENT_HXX + +#include <vcl/dllapi.h> +#include <tools/color.hxx> +#include <tools/gen.hxx> + +#include <vcl/vclenum.hxx> + +// ------------------ +// - Gradient-Types - +// ------------------ + +/* +#ifndef ENUM_GRADIENTSTYLE_DECLARED +#define ENUM_GRADIENTSTYLE_DECLARED +enum GradientStyle { GRADIENT_LINEAR, GRADIENT_AXIAL, GRADIENT_RADIAL, + GRADIENT_ELLIPTICAL, GRADIENT_SQUARE, GRADIENT_RECT }; +#endif +*/ + +// ---------------- +// - Impl_Gradient - +// ---------------- + +class SvStream; + +class Impl_Gradient +{ +public: + sal_uLong mnRefCount; + GradientStyle meStyle; + Color maStartColor; + Color maEndColor; + sal_uInt16 mnAngle; + sal_uInt16 mnBorder; + sal_uInt16 mnOfsX; + sal_uInt16 mnOfsY; + sal_uInt16 mnIntensityStart; + sal_uInt16 mnIntensityEnd; + sal_uInt16 mnStepCount; + + friend SvStream& operator>>( SvStream& rIStm, Impl_Gradient& rImplGradient ); + friend SvStream& operator<<( SvStream& rOStm, const Impl_Gradient& rImplGradient ); + + Impl_Gradient(); + Impl_Gradient( const Impl_Gradient& rImplGradient ); +}; + +// ------------ +// - Gradient - +// ------------ + +class VCL_DLLPUBLIC Gradient +{ +private: + Impl_Gradient* mpImplGradient; + void MakeUnique(); + +public: + Gradient(); + Gradient( const Gradient& rGradient ); + Gradient( GradientStyle eStyle ); + Gradient( GradientStyle eStyle, + const Color& rStartColor, + const Color& rEndColor ); + ~Gradient(); + + void SetStyle( GradientStyle eStyle ); + GradientStyle GetStyle() const { return mpImplGradient->meStyle; } + + void SetStartColor( const Color& rColor ); + const Color& GetStartColor() const { return mpImplGradient->maStartColor; } + void SetEndColor( const Color& rColor ); + const Color& GetEndColor() const { return mpImplGradient->maEndColor; } + + void SetAngle( sal_uInt16 nAngle ); + sal_uInt16 GetAngle() const { return mpImplGradient->mnAngle; } + + void SetBorder( sal_uInt16 nBorder ); + sal_uInt16 GetBorder() const { return mpImplGradient->mnBorder; } + void SetOfsX( sal_uInt16 nOfsX ); + sal_uInt16 GetOfsX() const { return mpImplGradient->mnOfsX; } + void SetOfsY( sal_uInt16 nOfsY ); + sal_uInt16 GetOfsY() const { return mpImplGradient->mnOfsY; } + + void SetStartIntensity( sal_uInt16 nIntens ); + sal_uInt16 GetStartIntensity() const { return mpImplGradient->mnIntensityStart; } + void SetEndIntensity( sal_uInt16 nIntens ); + sal_uInt16 GetEndIntensity() const { return mpImplGradient->mnIntensityEnd; } + + void SetSteps( sal_uInt16 nSteps ); + sal_uInt16 GetSteps() const { return mpImplGradient->mnStepCount; } + + void GetBoundRect( const Rectangle& rRect, Rectangle &rBoundRect, Point& rCenter ) const; + + Gradient& operator=( const Gradient& rGradient ); + sal_Bool operator==( const Gradient& rGradient ) const; + sal_Bool operator!=( const Gradient& rGradient ) const + { return !(Gradient::operator==( rGradient )); } + sal_Bool IsSameInstance( const Gradient& rGradient ) const + { return (mpImplGradient == rGradient.mpImplGradient); } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Gradient& rGradient ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Gradient& rGradient ); +}; + +#endif // _SV_GRADIENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graph.h b/vcl/inc/vcl/graph.h new file mode 100644 index 000000000000..1df2ee7a3df3 --- /dev/null +++ b/vcl/inc/vcl/graph.h @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GRAPH_H +#define _SV_GRAPH_H + +#include <vcl/dllapi.h> +#include <tools/string.hxx> +#include <vcl/sv.h> + +// --------------- +// - GraphicType - +// --------------- + +enum GraphicType +{ + GRAPHIC_NONE, + GRAPHIC_BITMAP, + GRAPHIC_GDIMETAFILE, + GRAPHIC_DEFAULT +}; + +// ----------------- +// - GraphicReader - +// ----------------- + +class ReaderData; + +class VCL_DLLPUBLIC GraphicReader +{ +protected: + + String maUpperName; + ReaderData* mpReaderData; + sal_Bool mbIsReading; + + GraphicReader() : + mpReaderData( NULL ), + mbIsReading( sal_False ) {} + +public: + + virtual ~GraphicReader(); + + const String& GetUpperFilterName() const { return maUpperName; } + ReaderData* GetReaderData() const { return mpReaderData; } + sal_Bool IsReading() const { return mbIsReading; } + + // TODO: when incompatible changes are possible again + // the preview size hint should be redone + sal_Bool IsPreviewModeEnabled() const; + void DisablePreviewMode(); + void SetPreviewSize( const Size& ); + Size GetPreviewSize() const; +}; + +#endif // _SV_GRAPH_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graph.hxx b/vcl/inc/vcl/graph.hxx new file mode 100644 index 000000000000..3dfbb8d261d8 --- /dev/null +++ b/vcl/inc/vcl/graph.hxx @@ -0,0 +1,220 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GRAPH_HXX +#define _SV_GRAPH_HXX + +#include <tools/stream.hxx> +#include <vcl/dllapi.h> +#include <vcl/sv.h> +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/animate.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/graph.h> +#include <vcl/gfxlink.hxx> +#include <com/sun/star/uno/Reference.hxx> + +namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } } + +// ----------- +// - Graphic - +// ----------- + +class ImpGraphic; +class OutputDevice; +class Font; +class GfxLink; + +class VCL_DLLPUBLIC GraphicConversionParameters +{ +private: + Size maSizePixel; // default is (0,0) + + // bitfield + unsigned mbUnlimitedSize : 1; // default is false + unsigned mbAntiAliase : 1; // default is false + unsigned mbSnapHorVerLines : 1; // default is false + +public: + GraphicConversionParameters( + const Size& rSizePixel = Size(), + bool bUnlimitedSize = false, + bool bAntiAliase = false, + bool bSnapHorVerLines = false) + : maSizePixel(rSizePixel), + mbUnlimitedSize(bUnlimitedSize), + mbAntiAliase(bAntiAliase), + mbSnapHorVerLines(bSnapHorVerLines) + { + } + + // data read access + const Size getSizePixel() const { return maSizePixel; } + bool getUnlimitedSize() const { return mbUnlimitedSize; } + bool getAntiAliase() const { return mbAntiAliase; } + bool getSnapHorVerLines() const { return mbSnapHorVerLines; } +}; + +class VCL_DLLPUBLIC Graphic : public SvDataCopyStream +{ +private: + + ImpGraphic* mpImpGraphic; + +public: + + SAL_DLLPRIVATE void ImplTestRefCount(); + SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; } + +public: + + TYPEINFO(); + + Graphic(); + Graphic( const Graphic& rGraphic ); + Graphic( const Bitmap& rBmp ); + Graphic( const BitmapEx& rBmpEx ); + Graphic( const Animation& rAnimation ); + Graphic( const GDIMetaFile& rMtf ); + Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); + virtual ~Graphic(); + + Graphic& operator=( const Graphic& rGraphic ); + sal_Bool operator==( const Graphic& rGraphic ) const; + sal_Bool operator!=( const Graphic& rGraphic ) const; + sal_Bool operator!() const; + + void Clear(); + + GraphicType GetType() const; + void SetDefaultType(); + sal_Bool IsSupportedGraphic() const; + + sal_Bool IsTransparent() const; + sal_Bool IsAlpha() const; + sal_Bool IsAnimated() const; + + // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic + // if it is a MetaFile. To be able to control this conversion it is necessary to + // allow giving parameters which control AntiAliasing and LineSnapping of the + // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as + // before. + Bitmap GetBitmap(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const; + BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const; + + Animation GetAnimation() const; + const GDIMetaFile& GetGDIMetaFile() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const; + + Size GetPrefSize() const; + void SetPrefSize( const Size& rPrefSize ); + + MapMode GetPrefMapMode() const; + void SetPrefMapMode( const MapMode& rPrefMapMode ); + + Size GetSizePixel( const OutputDevice* pRefDevice = NULL ) const; + + sal_uLong GetSizeBytes() const; + + void Draw( OutputDevice* pOutDev, + const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize ) const; + static void Draw( OutputDevice* pOutDev, const String& rText, + Font& rFont, const Bitmap& rBitmap, + const Point& rDestPt, const Size& rDestSize ); + static void DrawEx( OutputDevice* pOutDev, const String& rText, + Font& rFont, const BitmapEx& rBitmap, + const Point& rDestPt, const Size& rDestSize ); + + void StartAnimation( OutputDevice* pOutDev, + const Point& rDestPt, + long nExtraData = 0L, + OutputDevice* pFirstFrameOutDev = NULL ); + void StartAnimation( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize, + long nExtraData = 0L, + OutputDevice* pFirstFrameOutDev = NULL ); + void StopAnimation( OutputDevice* pOutputDevice = NULL, + long nExtraData = 0L ); + + void SetAnimationNotifyHdl( const Link& rLink ); + Link GetAnimationNotifyHdl() const; + + sal_uLong GetAnimationLoopCount() const; + void ResetAnimationLoopCount(); + + List* GetAnimationInfoList() const; + + sal_uLong GetChecksum() const; + +public: + + GraphicReader* GetContext(); + void SetContext( GraphicReader* pReader ); + +public: + + static sal_uInt16 GetGraphicsCompressMode( SvStream& rIStm ); + + void SetDocFileName( const String& rName, sal_uLong nFilePos ); + const String& GetDocFileName() const; + sal_uLong GetDocFilePos() const; + + sal_Bool ReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False ); + sal_Bool WriteEmbedded( SvStream& rOStream ); + + sal_Bool SwapOut(); + sal_Bool SwapOut( SvStream* pOStm ); + sal_Bool SwapIn(); + sal_Bool SwapIn( SvStream* pIStm ); + sal_Bool IsSwapOut() const; + + void SetLink( const GfxLink& ); + GfxLink GetLink() const; + sal_Bool IsLink() const; + + sal_Bool ExportNative( SvStream& rOStream ) const; + + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Graphic& rGraphic ); + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Graphic& rGraphic ); + +public: + + virtual void Load( SvStream& ); + virtual void Save( SvStream& ); + virtual void Assign( const SvDataCopyStream& ); +}; + +#endif // _SV_GRAPH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graphictools.hxx b/vcl/inc/vcl/graphictools.hxx new file mode 100644 index 000000000000..edd29ab9db01 --- /dev/null +++ b/vcl/inc/vcl/graphictools.hxx @@ -0,0 +1,465 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_GRAPHICTOOLS_HXX_ +#define _VCL_GRAPHICTOOLS_HXX_ + +#include <vcl/dllapi.h> +#include <sal/types.h> +#include <rtl/string.hxx> +#include <tools/color.hxx> +#include <tools/poly.hxx> +#include <tools/stream.hxx> +#include <vcl/graph.hxx> + +#ifndef INCLUDED_MEMORY +#include <memory> +#define INCLUDED_MEMORY +#endif + +#ifndef INCLUDED_VECTOR +#include <vector> +#define INCLUDED_VECTOR +#endif + +/** Encapsulates geometry and associated attributes of a graphical 'pen stroke' + + @attention Widespread use is deprecated. See declarations above + for the way to go. Especially the copied enums from svx/xenum.hxx + are troublesome. + + Use this class to store geometry and attributes of a graphical + 'pen stroke', such as pen width, dashing etc. The geometry is the + so-called 'path' along which the stroke is traced, with the given + pen width. The cap type determines how the open ends of the path + should be drawn. If the geometry consists of more than one + segment, the join type determines in which way the segments are + joined. + */ +class VCL_DLLPUBLIC SvtGraphicStroke +{ +public: + /// Style for open stroke ends + enum CapType + { + /// No additional cap + capButt=0, + /// Half-round cap at the line end, the center lying at the end point + capRound, + /// Half-square cap at the line end, the center lying at the end point + capSquare + }; + /// Style for joins of individual stroke segments + enum JoinType + { + /// Extend segment edges, until they cross + joinMiter=0, + /// Connect segments by a filled round arc + joinRound, + /// Connect segments by a direct straight line + joinBevel, + /// Perform no join, leads to visible gaps between thick line segments + joinNone + }; + enum + { + /// Width of stroke start/end arrow to exactly fit the joining stroke + normalizedArrowWidth=65536 + }; + typedef ::std::vector< double > DashArray; + + SvtGraphicStroke(); + /** All in one constructor + + See accessor method descriptions for argument description + */ + SvtGraphicStroke( const Polygon& rPath, + const PolyPolygon& rStartArrow, + const PolyPolygon& rEndArrow, + double fTransparency, + double fStrokeWidth, + CapType aCap, + JoinType aJoin, + double fMiterLimit, + const DashArray& rDashArray ); // TODO: Dash array offset (position where to start, see PS) + + // accessors + /// Query path to stroke + void getPath ( Polygon& ) const; + /** Get the polygon that is put at the start of the line + + The polygon is in a special normalized position: the center of + the stroked path will meet the given polygon at (0,0) from + negative y values. Thus, an arrow would have its baseline on + the x axis, going upwards to positive y values. Furthermore, + the polygon is also scaled in a special way: the width of the + joining stroke is defined to be + SvtGraphicStroke::normalizedArrowWidth (0x10000), i.e. ranging + from x=-0x8000 to x=0x8000. So, if the arrow does have this + width, it has to fit every stroke with every stroke width + exactly. + */ + void getStartArrow ( PolyPolygon& ) const; + /** Get the polygon that is put at the end of the line + + The polygon is in a special normalized position, and already + scaled to the desired size: the center of the stroked path + will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + is also scaled in a special way: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. So, if the + arrow does have this width, it has to fit every stroke with + every stroke width exactly. + */ + void getEndArrow ( PolyPolygon& ) const; + /** Get stroke transparency + + @return the transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + double getTransparency () const; + /// Get width of the stroke + double getStrokeWidth () const; + /// Get the style in which open stroke ends are drawn + CapType getCapType () const; + /// Get the style in which the stroke segments are joined + JoinType getJoinType () const; + /// Get the maximum length of mitered joins + double getMiterLimit () const; + /// Get an array of "on" and "off" lengths for stroke dashing + void getDashArray ( DashArray& ) const; + /// Query a textual representation of the object's content + ::rtl::OString toString () const; + + // mutators + /// Set path to stroke + void setPath ( const Polygon& ); + /** Set the polygon that is put at the start of the line + + The polygon has to be in a special normalized position, and + already scaled to the desired size: the center of the stroked + path will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + also has to be scaled appropriately: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. If your + arrow does have this width, it will fit every stroke with + every stroke width exactly. + */ + void setStartArrow ( const PolyPolygon& ); + /** Set the polygon that is put at the end of the line + + The polygon has to be in a special normalized position, and + already scaled to the desired size: the center of the stroked + path will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + also has to be scaled appropriately: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. If your + arrow does have this width, it will fit every stroke with + every stroke width exactly. + */ + void setEndArrow ( const PolyPolygon& ); + /** Set stroke transparency + + @param fTrans + The transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + void setTransparency ( double fTrans ); + /// Set width of the stroke + void setStrokeWidth ( double ); + /// Set the style in which open stroke ends are drawn + void setCapType ( CapType ); + /// Set the style in which the stroke segments are joined + void setJoinType ( JoinType ); + /// Set the maximum length of mitered joins + void setMiterLimit ( double ); + /// Set the array of "on" and "off" lengths for stroke dashing + void setDashArray ( const DashArray& ); + +private: + // friends + VCL_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStm, const SvtGraphicStroke& rClass ); + VCL_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStm, SvtGraphicStroke& rClass ); + + Polygon maPath; + PolyPolygon maStartArrow; + PolyPolygon maEndArrow; + double mfTransparency; + double mfStrokeWidth; + CapType maCapType; + JoinType maJoinType; + double mfMiterLimit; + DashArray maDashArray; +}; + +/** Encapsulates geometry and associated attributes of a filled area + + @attention Widespread use is deprecated. See declarations above + for the way to go. Especially the copied enums from svx/xenum.hxx + is troublesome. + + Use this class to store geometry and attributes of a filled area, + such as fill color, transparency, texture or hatch. The geometry + is the so-called 'path', whose inner area will get filled + according to the attributes set. If the path is intersecting, or + one part of the path is lying fully within another part, then the + fill rule determines which parts are filled and which are not. + */ +class VCL_DLLPUBLIC SvtGraphicFill +{ +public: + /// Type of fill algorithm used + enum FillRule + { + /** Non-zero winding rule + + Fill shape scanline-wise. Starting at the left, determine + the winding number as follows: every segment crossed that + runs counter-clockwise adds one to the winding number, + every segment crossed that runs clockwise subtracts + one. The part of the scanline where the winding number is + non-zero gets filled. + */ + fillNonZero=0, + /** Even-odd fill rule + + Fill shape scanline-wise. Starting at the left, count the + number of segments crossed. If this number is odd, the + part of the scanline is filled, otherwise not. + */ + fillEvenOdd + }; + /// Type of filling used + enum FillType + { + /// Fill with a specified solid color + fillSolid=0, + /// Fill with the specified gradient + fillGradient, + /// Fill with the specified hatch + fillHatch, + /// Fill with the specified texture (a Graphic object) + fillTexture + }; + /// Type of hatching used + enum HatchType + { + /// horizontal parallel lines, one unit apart + hatchSingle=0, + /// horizontal and verticall orthogonally crossing lines, one unit apart + hatchDouble, + /// three crossing lines, like HatchType::hatchDouble, but + /// with an additional diagonal line, rising to the upper + /// right corner. The first diagonal line goes through the + /// upper left corner, the other are each spaced a unit apart. + hatchTriple + }; + /// Type of gradient used + enum GradientType {gradientLinear=0, gradientRadial, gradientRectangular}; + /// Special values for gradient step count + enum { gradientStepsInfinite=0 }; + /** Homogeneous 2D transformation matrix + + This is a 2x3 matrix representing an affine transformation on + the R^2, in the usual C/C++ row major form. It is structured as follows: + <pre> + a b t_x + c d t_y + 0 0 1 + </pre> + where the lowest line is not stored in the matrix, since it is + constant. Variables t_x and t_y contain translational + components, a to d rotation, scale and shear (for details, + look up your favorite linear algebra/computer graphics book). + */ + struct VCL_DLLPUBLIC Transform + { + enum { MatrixSize=6 }; + Transform(); + double matrix[MatrixSize]; + }; + + SvtGraphicFill(); + /** All in one constructor + + See accessor method descriptions for argument description + */ + SvtGraphicFill( const PolyPolygon& rPath, + Color aFillColor, + double fTransparency, + FillRule aFillRule, + FillType aFillType, // TODO: Multitexturing + const Transform& aFillTransform, + bool bTiling, + HatchType aHatchType, // TODO: vector of directions and start points + Color aHatchColor, + GradientType aGradientType, // TODO: Transparent gradients (orthogonal to normal ones) + Color aGradient1stColor, // TODO: vector of colors and offsets + Color aGradient2ndColor, + int aGradientStepCount, // numbers of steps to render the gradient. gradientStepsInfinite means infinitely many. + const Graphic& aFillGraphic ); + + // accessors + /// Query path to fill + void getPath ( PolyPolygon& ) const; + /// Get color used for solid fills + Color getFillColor () const; + /** Get stroke transparency + + @return the transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + double getTransparency () const; + /// Get fill rule used + FillRule getFillRule () const; + /** Get fill type used + + Currently, only one of the fill types can be used + simultaneously. If you specify e.g. FillRule::fillGradient, + hatching, texture and solid fill color are ignored. + */ + FillType getFillType () const; + /** Get transformation applied to hatch, gradient or texture during fill + + A fill operation generally starts at the top left position of + the object's bounding box. At that position (if tiling is on, + also all successive positions), the specified fill graphic is + rendered, after applying the fill transformation to it. For + example, if the fill transformation contains a translation, + the fill graphic is rendered at the object's bounding box's + top left corner plus the translation components. + + */ + void getTransform ( Transform& ) const; + /// deprecated + bool IsTiling () const; + /** Query state of texture tiling + + @return true, if texture is tiled, false, if output only once. + */ + bool isTiling () const; + /// Get type of hatch used + HatchType getHatchType () const; + /// Get color used for drawing the hatch + Color getHatchColor () const; + /// Get type of gradient used + GradientType getGradientType () const; + /// Get start color of the gradient + Color getGradient1stColor () const; + /// Get end color of the gradient + Color getGradient2ndColor () const; + /** Get the numbers of steps to render the gradient. + + @return the step count. gradientStepsInfinite means infinitely many. + */ + int getGradientStepCount() const; + /** Get the texture graphic used + + The Graphic object returned is used to fill the geometry, if + the FillType is fillTexture. The Graphic object is always + assumed to be of size 1x1, the transformation is used to scale + it to the appropriate size. + */ + void getGraphic ( Graphic& ) const; + /// Query a textual representation of the object's content + ::rtl::OString toString () const; + + // mutators + /// Set path to fill + void setPath ( const PolyPolygon& rPath ); + /// Set color used for solid fills + void setFillColor ( Color aFillColor ); + /** Set stroke transparency + + @param fTransparency + The transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + void setTransparency ( double fTransparency ); + /// Set fill rule used + void setFillRule ( FillRule aFillRule ); + /** Set fill type used + + Currently, only one of the fill types can be used + simultaneously. If you specify e.g. FillRule::fillGradient, + hatching, texture and solid fill color are ignored. + */ + void setFillType ( FillType aFillType ); + /// Set transformation applied to hatch, gradient or texture during fill + void setTransform ( const Transform& pTransform ); + /** Set state of texture tiling + + @param bTiling + If set to true, texture is tiled, if set to false, texture is output only once. + */ + void setTiling ( bool bTiling = true ); + /// Set type of hatch used + void setHatchType ( HatchType aHatchType ); + /// Set color used for drawing the hatch + void setHatchColor ( Color aHatchColor ); + /// Set type of gradient used + void setGradientType ( GradientType aGradType ); + /// Set start color of the gradient + void setGradient1stColor ( Color aColor ); + /// Set end color of the gradient + void setGradient2ndColor ( Color aColor ); + /** Set the numbers of steps to render the gradient. + + @param aCount + The step count. gradientStepsInfinite means use infinitely many. + */ + void setGradientStepCount( int aCount ); + /// Set the texture graphic used + void setGraphic ( const Graphic& rGraphic ); + +private: + // friends + VCL_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStm, const SvtGraphicFill& rClass ); + VCL_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStm, SvtGraphicFill& rClass ); + + PolyPolygon maPath; + Color maFillColor; + double mfTransparency; + FillRule maFillRule; + FillType maFillType; + Transform maFillTransform; + bool mbTiling; + HatchType maHatchType; + Color maHatchColor; + GradientType maGradientType; + Color maGradient1stColor; + Color maGradient2ndColor; + int maGradientStepCount; + Graphic maFillGraphic; +}; + +#endif /* _VCL_GRAPHICTOOLS_HXX_ */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graphite_features.hxx b/vcl/inc/vcl/graphite_features.hxx new file mode 100644 index 000000000000..742ad2c3f5f5 --- /dev/null +++ b/vcl/inc/vcl/graphite_features.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// Description: +// Parse a string of features specified as ; separated pairs. +// e.g. +// 1001=1&2002=2&fav1=0 +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <graphite2/Font.h> + +namespace grutils +{ + union FeatId + { + gr_uint32 num; + unsigned char label[5]; + }; + + class GrFeatureParser + { + public: + enum { MAX_FEATURES = 64 }; + static const char FEAT_PREFIX; + static const char FEAT_SEPARATOR; + static const char FEAT_ID_VALUE_SEPARATOR; + GrFeatureParser(const gr_face * face, const ::rtl::OString features, const ::rtl::OString lang); + GrFeatureParser(const gr_face * face, const ::rtl::OString lang); + ~GrFeatureParser(); + //size_t getFontFeatures(gr::FeatureSetting settings[MAX_FEATURES]) const; + bool parseErrors() { return mbErrors; }; + //static bool isValid(gr::Font & font, gr::FeatureSetting & setting); + gr_uint32 getLanguage() const { return maLang.num; }; + bool hasLanguage() const { return (maLang.label[0] != '\0'); } + sal_Int32 hashCode() const { return mnHash; } + size_t numFeatures() const { return mnNumSettings; } + gr_feature_val * values() const { return mpSettings; }; + private: + GrFeatureParser(const GrFeatureParser & copy); + void setLang(const gr_face * face, const ::rtl::OString & lang); + bool isCharId(const ::rtl::OString & id, size_t offset, size_t length); + gr_uint32 getCharId(const ::rtl::OString & id, size_t offset, size_t length); + short getIntValue(const ::rtl::OString & id, size_t offset, size_t length); + size_t mnNumSettings; + FeatId maLang; + bool mbErrors; + sal_uInt32 mnHash; + gr_feature_val * mpSettings; + }; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graphite_layout.hxx b/vcl/inc/vcl/graphite_layout.hxx new file mode 100644 index 000000000000..f605f190f669 --- /dev/null +++ b/vcl/inc/vcl/graphite_layout.hxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GRAPHITELAYOUT_HXX +#define _SV_GRAPHITELAYOUT_HXX +// Description: An implementation of the SalLayout interface that uses the +// Graphite engine. + +// We need this to enable namespace support in libgrengine headers. +#define GR_NAMESPACE + +// Standard Library +#include <memory> +#include <vector> +#include <map> +#include <utility> +// Libraries +#include <graphite2/Font.h> +#include <graphite2/Segment.h> +// Platform +#include <vcl/sallayout.hxx> +#include <vcl/dllapi.h> +// Module + +// Module type definitions and forward declarations. +// +class TextSourceAdaptor; +class GraphiteFontAdaptor; +class GrSegRecord; +// SAL/VCL types +class ServerFont; + +// Graphite types +namespace grutils { class GrFeatureParser; } + +class GraphiteFaceWrapper +{ +public: + typedef std::map<int, gr_font*> GrFontMap; + GraphiteFaceWrapper(gr_face * pFace) : m_pFace(pFace) {} + ~GraphiteFaceWrapper() + { + GrFontMap::iterator i = m_fonts.begin(); + while (i != m_fonts.end()) + gr_font_destroy((*i++).second); + m_fonts.clear(); + gr_face_destroy(m_pFace); + } + const gr_face * face() const { return m_pFace; } + gr_font * font(int ppm) const + { + GrFontMap::const_iterator i = m_fonts.find(ppm); + if (i != m_fonts.end()) + return i->second; + return NULL; + }; + void addFont(int ppm, gr_font * pFont) + { + if (m_fonts[ppm]) + gr_font_destroy(m_fonts[ppm]); + m_fonts[ppm] = pFont; + } +private: + gr_face * m_pFace; + GrFontMap m_fonts; +}; + +// This class uses the SIL Graphite engine to provide complex text layout services to the VCL +// @author tse +// +class VCL_PLUGIN_PUBLIC GraphiteLayout : public SalLayout +{ +public: + + class Glyphs : public std::vector<GlyphItem> + { + public: + typedef std::pair<Glyphs::const_iterator, Glyphs::const_iterator> iterator_pair_t; + + }; + + mutable Glyphs mvGlyphs; + void clear(); + +private: + const gr_face * mpFace; // not owned by layout + gr_font * mpFont; // not owned by layout + int mnSegCharOffset; // relative to ImplLayoutArgs::mpStr + long mnWidth; + std::vector<int> mvChar2BaseGlyph; + std::vector<int> mvGlyph2Char; + std::vector<int> mvCharDxs; + std::vector<int> mvCharBreaks; + float mfScaling; + const grutils::GrFeatureParser * mpFeatures; + +public: + GraphiteLayout(const gr_face * pFace, gr_font * pFont = NULL, + const grutils::GrFeatureParser * features = NULL) throw(); + + // used by upper layers + virtual bool LayoutText( ImplLayoutArgs& ); // first step of layout + // split into two stages to allow dc to be restored on the segment + gr_segment * CreateSegment(ImplLayoutArgs& rArgs); + bool LayoutGlyphs(ImplLayoutArgs& rArgs, gr_segment * pSegment); + + virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting positions + + // methods using string indexing + virtual int GetTextBreak( long nMaxWidth, long nCharExtra=0, int nFactor=1 ) const; + virtual long FillDXArray( sal_Int32* pDXArray ) const; + virtual void ApplyDXArray(ImplLayoutArgs &rArgs, std::vector<int> & rDeltaWidth); + + virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const; + + // methods using glyph indexing + virtual int GetNextGlyphs(int nLen, sal_GlyphId* pGlyphIdxAry, ::Point & rPos, int&, + sal_Int32* pGlyphAdvAry = 0, int* pCharPosAry = 0 ) const; + + // used by glyph+font+script fallback + virtual void MoveGlyph( int nStart, long nNewXPos ); + virtual void DropGlyph( int nStart ); + virtual void Simplify( bool bIsBase ); + + // Dummy implementation so layout can be shared between Linux/Windows + virtual void DrawText(SalGraphics&) const {}; + + virtual ~GraphiteLayout() throw(); + void SetFont(gr_font * pFont) { mpFont = pFont; } + gr_font * GetFont() { return mpFont; } + void SetFeatures(grutils::GrFeatureParser * aFeature) { mpFeatures = aFeature; } + void SetFontScale(float s) { mfScaling = s; }; + virtual sal_GlyphId getKashidaGlyph(int & width) = 0; + void kashidaJustify(std::vector<int> & rDeltaWidth, sal_GlyphId, int width); + + static const int EXTRA_CONTEXT_LENGTH; +private: + void expandOrCondense(ImplLayoutArgs &rArgs); + void fillFrom(gr_segment * rSeg, ImplLayoutArgs & rArgs, float fScaling); + + void append(gr_segment * pSeg, + ImplLayoutArgs & rArgs, + const gr_slot * pSlot, + float nextGlyphOrigin, float fScaling, + long & rDXOffset, bool bIsBase, int baseChar); +}; + +#endif // _SV_GRAPHITELAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/graphite_serverfont.hxx b/vcl/inc/vcl/graphite_serverfont.hxx new file mode 100644 index 000000000000..b4a6e10be925 --- /dev/null +++ b/vcl/inc/vcl/graphite_serverfont.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GRAPHITESERVERFONT_HXX +#define _SV_GRAPHITESERVERFONT_HXX + +// We need this to enable namespace support in libgrengine headers. +#define GR_NAMESPACE + +#ifndef MSC +#include "vcl/graphite_layout.hxx" + +// Modules + +class VCL_PLUGIN_PUBLIC GraphiteLayoutImpl : public GraphiteLayout +{ +public: + GraphiteLayoutImpl(const gr_face * pFace, + ServerFont & rServerFont) throw() + : GraphiteLayout(pFace), mrServerFont(rServerFont) {}; + virtual ~GraphiteLayoutImpl() throw() {}; + virtual sal_GlyphId getKashidaGlyph(int & width); +private: + ServerFont & mrServerFont; +}; + +// This class implments the server font specific parts. +// @author tse +// +class VCL_PLUGIN_PUBLIC GraphiteServerFontLayout : public ServerFontLayout +{ +private: + // mutable so that the DrawOffset/DrawBase can be set + mutable GraphiteLayoutImpl maImpl; + grutils::GrFeatureParser * mpFeatures; + const sal_Unicode * mpStr; +public: + GraphiteServerFontLayout(ServerFont& pServerFont) throw(); + + virtual bool LayoutText( ImplLayoutArgs& rArgs) + { + mpStr = rArgs.mpStr; + SalLayout::AdjustLayout(rArgs); + return maImpl.LayoutText(rArgs); + }; // first step of layout + virtual void AdjustLayout( ImplLayoutArgs& rArgs) + { + SalLayout::AdjustLayout(rArgs); + maImpl.DrawBase() = maDrawBase; + maImpl.DrawOffset() = maDrawOffset; + maImpl.AdjustLayout(rArgs); + }; + virtual long GetTextWidth() const { return maImpl.GetTextWidth(); } + virtual long FillDXArray( sal_Int32* dxa ) const { return maImpl.FillDXArray(dxa); } + virtual int GetTextBreak( long mw, long ce, int f ) const { return maImpl.GetTextBreak(mw, ce, f); } + virtual void GetCaretPositions( int as, sal_Int32* cxa ) const { maImpl.GetCaretPositions(as, cxa); } + + // used by display layers + virtual int GetNextGlyphs( int l, sal_GlyphId* gia, Point& p, int& s, + sal_Int32* gaa = NULL, int* cpa = NULL ) const + { + maImpl.DrawBase() = maDrawBase; + maImpl.DrawOffset() = maDrawOffset; + return maImpl.GetNextGlyphs(l, gia, p, s, gaa, cpa); + } + + virtual void MoveGlyph( int nStart, long nNewXPos ) { maImpl.MoveGlyph(nStart, nNewXPos); }; + virtual void DropGlyph( int nStart ) { maImpl.DropGlyph(nStart); }; + virtual void Simplify( bool bIsBase ) { maImpl.Simplify(bIsBase); }; + + virtual ~GraphiteServerFontLayout() throw(); + + static bool IsGraphiteEnabledFont(ServerFont * pServerFont); +// For use with PspGraphics + const sal_Unicode* getTextPtr() const { return mpStr; }; + int getMinCharPos() const { return mnMinCharPos; } + int getMaxCharPos() const { return mnEndCharPos; } +}; + +#endif +#endif //_SV_GRAPHITESERVERFONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/group.hxx b/vcl/inc/vcl/group.hxx new file mode 100644 index 000000000000..3334988c7877 --- /dev/null +++ b/vcl/inc/vcl/group.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_GROUP_HXX +#define _SV_GROUP_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> + +// ------------ +// - GroupBox - +// ------------ + +class VCL_DLLPUBLIC GroupBox : public Control +{ +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags, + const Point& rPos, const Size& rSize, bool bLayout = false ); + + virtual void FillLayoutData() const; + virtual const Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + +public: + GroupBox( Window* pParent, WinBits nStyle = 0 ); + GroupBox( Window* pParent, const ResId& rResId ); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); +}; + +#endif // _SV_GROUP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/hatch.hxx b/vcl/inc/vcl/hatch.hxx new file mode 100644 index 000000000000..947740229f7f --- /dev/null +++ b/vcl/inc/vcl/hatch.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_HATCH_HXX +#define _SV_HATCH_HXX + +#include <tools/color.hxx> +#include <vcl/dllapi.h> + +#include <vcl/vclenum.hxx> + +// -------------- +// - Impl_Hatch - +// -------------- + +class SvStream; + +struct ImplHatch +{ + sal_uLong mnRefCount; + Color maColor; + HatchStyle meStyle; + long mnDistance; + sal_uInt16 mnAngle; + + ImplHatch(); + ImplHatch( const ImplHatch& rImplHatch ); + + friend SvStream& operator>>( SvStream& rIStm, ImplHatch& rImplHatch ); + friend SvStream& operator<<( SvStream& rOStm, const ImplHatch& rImplHatch ); +}; + +// --------- +// - Hatch - +// --------- + +class VCL_DLLPUBLIC Hatch +{ +private: + + ImplHatch* mpImplHatch; + SAL_DLLPRIVATE void ImplMakeUnique(); + +public: + + Hatch(); + Hatch( const Hatch& rHatch ); + Hatch( HatchStyle eStyle, const Color& rHatchColor, long nDistance, sal_uInt16 nAngle10 = 0 ); + ~Hatch(); + + Hatch& operator=( const Hatch& rHatch ); + sal_Bool operator==( const Hatch& rHatch ) const; + sal_Bool operator!=( const Hatch& rHatch ) const { return !(Hatch::operator==( rHatch ) ); } + sal_Bool IsSameInstance( const Hatch& rHatch ) const { return( mpImplHatch == rHatch.mpImplHatch ); } + + void SetStyle( HatchStyle eStyle ); + HatchStyle GetStyle() const { return mpImplHatch->meStyle; } + + void SetColor( const Color& rColor ); + const Color& GetColor() const { return mpImplHatch->maColor; } + + void SetDistance( long nDistance ); + long GetDistance() const { return mpImplHatch->mnDistance; } + + void SetAngle( sal_uInt16 nAngle10 ); + sal_uInt16 GetAngle() const { return mpImplHatch->mnAngle; } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Hatch& rHatch ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Hatch& rHatch ); +}; + +#endif // _SV_HATCH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/help.hxx b/vcl/inc/vcl/help.hxx new file mode 100644 index 000000000000..ce7d1baf4fd6 --- /dev/null +++ b/vcl/inc/vcl/help.hxx @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_HELP_HXX +#define _SV_HELP_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +class Point; +class Rectangle; +class Window; + +// -------------- +// - Help-Types - +// -------------- + +#define QUICKHELP_LEFT ((sal_uInt16)0x0001) +#define QUICKHELP_CENTER ((sal_uInt16)0x0002) +#define QUICKHELP_RIGHT ((sal_uInt16)0x0004) +#define QUICKHELP_TOP ((sal_uInt16)0x0008) +#define QUICKHELP_VCENTER ((sal_uInt16)0x0010) +#define QUICKHELP_BOTTOM ((sal_uInt16)0x0020) +#define QUICKHELP_NOAUTOPOS (QUICKHELP_LEFT | QUICKHELP_CENTER | QUICKHELP_RIGHT | QUICKHELP_TOP | QUICKHELP_VCENTER | QUICKHELP_BOTTOM) +#define QUICKHELP_CTRLTEXT ((sal_uInt16)0x0040) +/// force the existent tip window to be re-positioned, even if the previous incarnation has the same text. Applies to ShowBallon and ShowQuickHelp. +#define QUICKHELP_FORCE_REPOSITION ((sal_uInt16)0x0080) +/// no delay when opening the quick help. Applies to ShowBallon and ShowQuickHelp +#define QUICKHELP_NO_DELAY ((sal_uInt16)0x0100) +/// force balloon-style in ShowTip +#define QUICKHELP_TIP_STYLE_BALLOON ((sal_uInt16)0x0200) +#define QUICKHELP_NOEVADEPOINTER ((sal_uInt16)0x4000) +#define QUICKHELP_BIDI_RTL ((sal_uInt16)0x8000) + +// By changes you must also change: rsc/vclrsc.hxx +#define OOO_HELP_INDEX ".help:index" +#define OOO_HELP_HELPONHELP ".help:helponhelp" + +// -------- +// - Help - +// -------- + +class VCL_DLLPUBLIC Help +{ +private: + String maHelpFile; + +public: + Help(); + virtual ~Help(); + + void SetHelpFile( const String& rFileName ) { maHelpFile = rFileName; } + const String& GetHelpFile() const { return maHelpFile; } + + virtual sal_Bool Start( const XubString& rHelpId, const Window* pWindow ); + virtual sal_Bool SearchKeyword( const XubString& rKeyWord ); + virtual void OpenHelpAgent( const rtl::OString& rHelpId ); + virtual XubString GetHelpText( const String& aHelpURL, const Window* pWindow ); + + static void EnableContextHelp(); + static void DisableContextHelp(); + static sal_Bool IsContextHelpEnabled(); + static sal_Bool StartContextHelp(); + + static void EnableExtHelp(); + static void DisableExtHelp(); + static sal_Bool IsExtHelpEnabled(); + static sal_Bool StartExtHelp(); + static sal_Bool EndExtHelp(); + static sal_Bool IsExtHelpActive(); + + static void EnableBalloonHelp(); + static void DisableBalloonHelp(); + static sal_Bool IsBalloonHelpEnabled(); + static sal_Bool ShowBalloon( Window* pParent, + const Point& rScreenPos, + const XubString& rHelpText ); + static sal_Bool ShowBalloon( Window* pParent, + const Point& rScreenPos, + const Rectangle&, + const XubString& rHelpText ); + + static void EnableQuickHelp(); + static void DisableQuickHelp(); + static sal_Bool IsQuickHelpEnabled(); + static sal_Bool ShowQuickHelp( Window* pParent, + const Rectangle& rScreenRect, + const XubString& rHelpText, + const XubString& rLongHelpText, + sal_uInt16 nStyle = 0 ); + static sal_Bool ShowQuickHelp( Window* pParent, + const Rectangle& rScreenRect, + const XubString& rHelpText, + sal_uInt16 nStyle = 0 ) + { return Help::ShowQuickHelp( pParent, rScreenRect, rHelpText, XubString(), nStyle ); } + + static sal_uLong ShowTip( Window* pParent, + const Rectangle& rScreenRect, + const XubString& rText, sal_uInt16 nStyle = 0 ); + static void UpdateTip( sal_uLong nId, + Window* pParent, + const Rectangle& rScreenRect, + const XubString& rText ); + static void HideTip( sal_uLong nId ); +}; + +#endif // _SV_HELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/helper.hxx b/vcl/inc/vcl/helper.hxx new file mode 100644 index 000000000000..732e98080c62 --- /dev/null +++ b/vcl/inc/vcl/helper.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_HELPER_HXX_ +#define _PSPRINT_HELPER_HXX_ + +#include <list> + +#include "vcl/dllapi.h" + +#include "rtl/ustring.hxx" + + +// forwards +namespace osl { class File; } + +namespace psp { +typedef int fontID; + +void VCL_DLLPUBLIC getPrinterPathList( std::list< rtl::OUString >& rPathList, const char* pSubDir ); + +// note: gcc 3.4.1 warns about visibility if we retunr a const rtl::OUString& here +// seems to be a bug in gcc, now we return an object instead of a reference +rtl::OUString VCL_DLLPUBLIC getFontPath(); + +bool VCL_DLLPUBLIC convertPfbToPfa( osl::File& rInFile, osl::File& rOutFile ); + +// normalized path (equivalent to realpath) +void VCL_DLLPUBLIC normPath( rtl::OString& rPath ); + +// splits rOrgPath into dirname and basename +// rOrgPath will be subject to normPath +void VCL_DLLPUBLIC splitPath( rtl::OString& rOrgPath, rtl::OString& rDir, rtl::OString& rBase ); + +enum whichOfficePath { NetPath, UserPath, ConfigPath }; +// note: gcc 3.4.1 warns about visibility if we retunr a const rtl::OUString& here +// seems to be a bug in gcc, now we return an object instead of a reference +rtl::OUString VCL_DLLPUBLIC getOfficePath( enum whichOfficePath ePath ); +} // namespace + +#endif // _PSPRINT_HELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/helpwin.hxx b/vcl/inc/vcl/helpwin.hxx new file mode 100644 index 000000000000..7862a4961bbd --- /dev/null +++ b/vcl/inc/vcl/helpwin.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_HELPWIN_HXX +#define _SV_HELPWIN_HXX + +#include <vcl/floatwin.hxx> +#include <vcl/timer.hxx> + +// ------------------ +// - HelpTextWindow - +// ------------------ + +class HelpTextWindow : public FloatingWindow +{ +private: + Point maPos; + Rectangle maHelpArea; // Wenn naechste Hilfe fuers gleiche Rectangle, gleicher Text, dann Fenster stehen lassen + + Rectangle maTextRect; // Bei umgebrochenen Text in QuickHelp + + String maHelpText; + String maStatusText; + + Timer maShowTimer; + Timer maHideTimer; + + sal_uInt16 mnHelpWinStyle; + sal_uInt16 mnStyle; + +protected: + DECL_LINK( TimerHdl, Timer* ); + virtual void Paint( const Rectangle& ); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual String GetText() const; + void ImplShow(); + +public: + HelpTextWindow( Window* pParent, const String& rText, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle ); + ~HelpTextWindow(); + + const String& GetHelpText() const { return maHelpText; } + void SetHelpText( const String& rHelpText ); + sal_uInt16 GetWinStyle() const { return mnHelpWinStyle; } + sal_uInt16 GetStyle() const { return mnStyle; } + + // Nur merken: + void SetStatusText( const String& rStatusText ) { maStatusText = rStatusText; } + void SetHelpArea( const Rectangle& rRect ) { maHelpArea = rRect; } + + void ShowHelp( sal_uInt16 nDelayMode ); + + Size CalcOutSize() const; + const Rectangle& GetHelpArea() const { return maHelpArea; } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + + sal_Bool RegisterAccessibleParent(); + void RevokeAccessibleParent(); +}; + +void ImplShowHelpWindow( Window* pParent, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle, + const String& rHelpText, const String& rStatusText, + const Point& rScreenPos, const Rectangle* pHelpArea = NULL ); +void ImplDestroyHelpWindow( bool bUpdateHideTime ); +void ImplSetHelpWindowPos( Window* pHelpWindow, sal_uInt16 nHelpWinStyle, sal_uInt16 nStyle, + const Point& rPos, const Rectangle* pHelpArea ); + +#endif // _SV_HELPWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/i18nhelp.hxx b/vcl/inc/vcl/i18nhelp.hxx new file mode 100644 index 000000000000..a83afa4510ab --- /dev/null +++ b/vcl/inc/vcl/i18nhelp.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_I18NHELP_HXX +#define _VCL_I18NHELP_HXX + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/Locale.hpp> +#include <osl/mutex.hxx> +#include <tools/string.hxx> +#include <vcl/dllapi.h> + +namespace com { +namespace sun { +namespace star { +namespace lang { + class XMultiServiceFactory; +} +}}} + +namespace utl { + class TransliterationWrapper; +} + +class LocaleDataWrapper; + +class Date; + +namespace vcl +{ + +class VCL_DLLPUBLIC I18nHelper +{ +private: + ::osl::Mutex maMutex; + ::com::sun::star::lang::Locale maLocale; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + + LocaleDataWrapper* mpLocaleDataWrapper; + utl::TransliterationWrapper* mpTransliterationWrapper; + + sal_Bool mbTransliterateIgnoreCase; + + SAL_DLLPRIVATE void ImplDestroyWrappers(); + +protected: + ::osl::Mutex& GetMutex() { return maMutex; } + + SAL_DLLPRIVATE utl::TransliterationWrapper& ImplGetTransliterationWrapper() const; + SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const; + +public: + + I18nHelper( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxMSF, const ::com::sun::star::lang::Locale& rLocale ); + ~I18nHelper(); + + const ::com::sun::star::lang::Locale& getLocale() const; + + sal_Int32 CompareString( const String& rStr1, const String& rStr2 ) const; + + sal_Bool MatchString( const String& rStr1, const String& rStr2 ) const; + sal_Bool MatchMnemonic( const String& rString, sal_Unicode cMnemonicChar ) const; + + String GetDate( const Date& rDate ) const; + String GetNum( long nNumber, sal_uInt16 nDecimals, sal_Bool bUseThousandSep = sal_True, sal_Bool bTrailingZeros = sal_True ) const; + + static String filterFormattingChars( const String& ); +}; + +} // namespace vcl + +#endif // _VCL_I18NHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/idlemgr.hxx b/vcl/inc/vcl/idlemgr.hxx new file mode 100644 index 000000000000..674bdf070c3a --- /dev/null +++ b/vcl/inc/vcl/idlemgr.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IDLEMGR_HXX +#define _SV_IDLEMGR_HXX + +#include <vcl/sv.h> +#include <vcl/timer.hxx> +#include <vector> + +struct ImplIdleData; +typedef ::std::vector< ImplIdleData* > ImplIdleList; + +// --------------- +// - ImplIdleMgr - +// --------------- + +class ImplIdleMgr +{ +private: + ImplIdleList* mpIdleList; + AutoTimer maTimer; + +public: + ImplIdleMgr(); + ~ImplIdleMgr(); + + sal_Bool InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority ); + void RemoveIdleHdl( const Link& rLink ); + + void RestartIdler() + { if ( maTimer.IsActive() ) maTimer.Start(); } + + // Timer* kann auch NULL sein + DECL_LINK( TimeoutHdl, Timer* ); +}; + +#endif // _SV_IDLEMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/ilstbox.hxx b/vcl/inc/vcl/ilstbox.hxx new file mode 100644 index 000000000000..850531c64d9d --- /dev/null +++ b/vcl/inc/vcl/ilstbox.hxx @@ -0,0 +1,651 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_ILSTBOX_HXX +#define _SV_ILSTBOX_HXX + +#include <vcl/sv.h> +#include <vcl/image.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/button.hxx> +#include <vcl/floatwin.hxx> +#include <vcl/lstbox.h> +#include <vcl/timer.hxx> + +#include "vcl/quickselectionengine.hxx" + +class ScrollBar; +class ScrollBarBox; + +// ----------------- +// - ListBox-Types - +// ----------------- + +#define HORZ_SCROLL 4 +#define IMG_TXT_DISTANCE 6 + +enum LB_EVENT_TYPE +{ + LET_MBDOWN, + LET_TRACKING, + LET_TRACKING_END, + LET_KEYMOVE, + LET_KEYSPACE +}; + +// ----------------- +// - ImplEntryType - +// ----------------- + +struct ImplEntryType +{ + XubString maStr; + Image maImage; + void* mpUserData; + sal_Bool mbIsSelected; + long mnFlags; + long mnHeight; + + ImplEntryType( const XubString& rStr, const Image& rImage ) : + maStr( rStr ), + maImage( rImage ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } + + ImplEntryType( const XubString& rStr ) : + maStr( rStr ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } + + ImplEntryType( const Image& rImage ) : + maImage( rImage ), + mnFlags( 0 ), + mnHeight( 0 ) + { + mbIsSelected = sal_False; + mpUserData = NULL; + } +}; + +// ----------------- +// - ImplEntryList - +// ----------------- + +class ImplEntryList : private List +{ +private: + Window* mpWindow; // For getting the current locale when matching strings + sal_uInt16 mnLastSelected; + sal_uInt16 mnSelectionAnchor; + sal_uInt16 mnImages; + + sal_uInt16 mnMRUCount; + sal_uInt16 mnMaxMRUCount; + + Link maSelectionChangedHdl; + sal_Bool mbCallSelectionChangedHdl; + + ImplEntryType* GetEntry( sal_uInt16 nPos ) const { return (ImplEntryType*)List::GetObject( nPos ); } + +public: + ImplEntryList( Window* pWindow ); + ~ImplEntryList(); + + sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry, sal_Bool bSort ); + void RemoveEntry( sal_uInt16 nPos ); + const ImplEntryType* GetEntryPtr( sal_uInt16 nPos ) const { return (const ImplEntryType*) GetObject( nPos ); } + ImplEntryType* GetMutableEntryPtr( sal_uInt16 nPos ) const { return (ImplEntryType*) GetObject( nPos ); } + void Clear(); + + sal_uInt16 FindMatchingEntry( const XubString& rStr, sal_uInt16 nStart = 0, sal_Bool bForward = sal_True, sal_Bool bLazy = sal_True ) const; + sal_uInt16 FindEntry( const XubString& rStr, sal_Bool bSearchMRUArea = sal_False ) const; + sal_uInt16 FindEntry( const void* pData ) const; + + // helper: add up heights up to index nEndIndex. + // GetAddedHeight( 0 ) returns 0 + // GetAddedHeight( LISTBOX_ENTRY_NOTFOUND ) returns 0 + // GetAddedHeight( i, k ) with k > i is equivalent -GetAddedHeight( k, i ) + long GetAddedHeight( sal_uInt16 nEndIndex, sal_uInt16 nBeginIndex = 0, long nBeginHeight = 0 ) const; + long GetEntryHeight( sal_uInt16 nPos ) const; + + sal_uInt16 GetEntryCount() const { return (sal_uInt16)List::Count(); } + sal_Bool HasImages() const { return mnImages ? sal_True : sal_False; } + + XubString GetEntryText( sal_uInt16 nPos ) const; + + sal_Bool HasEntryImage( sal_uInt16 nPos ) const; + Image GetEntryImage( sal_uInt16 nPos ) const; + + void SetEntryData( sal_uInt16 nPos, void* pNewData ); + void* GetEntryData( sal_uInt16 nPos ) const; + + void SetEntryFlags( sal_uInt16 nPos, long nFlags ); + long GetEntryFlags( sal_uInt16 nPos ) const; + + void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); + + sal_uInt16 GetSelectEntryCount() const; + XubString GetSelectEntry( sal_uInt16 nIndex ) const; + sal_uInt16 GetSelectEntryPos( sal_uInt16 nIndex ) const; + sal_Bool IsEntrySelected( const XubString& rStr ) const; + sal_Bool IsEntryPosSelected( sal_uInt16 nIndex ) const; + + void SetLastSelected( sal_uInt16 nPos ) { mnLastSelected = nPos; } + sal_uInt16 GetLastSelected() const { return mnLastSelected; } + + void SetSelectionAnchor( sal_uInt16 nPos ) { mnSelectionAnchor = nPos; } + sal_uInt16 GetSelectionAnchor() const { return mnSelectionAnchor; } + + + void SetSelectionChangedHdl( const Link& rLnk ) { maSelectionChangedHdl = rLnk; } + void SetCallSelectionChangedHdl( sal_Bool bCall ) { mbCallSelectionChangedHdl = bCall; } + + void SetMRUCount( sal_uInt16 n ) { mnMRUCount = n; } + sal_uInt16 GetMRUCount() const { return mnMRUCount; } + + void SetMaxMRUCount( sal_uInt16 n ) { mnMaxMRUCount = n; } + sal_uInt16 GetMaxMRUCount() const { return mnMaxMRUCount; } + + /** An Entry is selectable if its mnFlags does not have the + LISTBOX_ENTRY_FLAG_DISABLE_SELECTION flag set. */ + bool IsEntrySelectable( sal_uInt16 nPos ) const; + + /** returns the first entry found from the given position nPos that is selectable + or LISTBOX_ENTRY_NOTFOUND if non is found. If the entry at nPos is not selectable, + it returns the first selectable entry after nPos if bForward is true and the + first selectable entry after nPos is bForward is false. + */ + sal_uInt16 FindFirstSelectable( sal_uInt16 nPos, bool bForward = true ); +}; + +// --------------------- +// - ImplListBoxWindow - +// --------------------- + +class ImplListBoxWindow : public Control, public ::vcl::ISearchableStringList +{ +private: + ImplEntryList* mpEntryList; // EntryListe + Rectangle maFocusRect; + + Size maUserItemSize; + + long mnMaxTxtHeight; // Maximale Hoehe eines Text-Items + long mnMaxTxtWidth; // Maximale Breite eines Text-Items + // Entry ohne Image + long mnMaxImgTxtWidth;// Maximale Breite eines Text-Items + // Entry UND Image + long mnMaxImgWidth; // Maximale Breite eines Image-Items + long mnMaxImgHeight; // Maximale Hoehe eines Image-Items + long mnMaxWidth; // Maximale Breite eines Eintrags + long mnMaxHeight; // Maximale Hoehe eines Eintrags + + sal_uInt16 mnCurrentPos; // Position (Focus) + sal_uInt16 mnTrackingSaveSelection; // Selektion vor Tracking(); + + sal_uInt16 mnSeparatorPos; // Separator + + sal_uInt16 mnUserDrawEntry; + + sal_uInt16 mnTop; // Ausgabe ab Zeile + long mnLeft; // Ausgabe ab Spalte + long mnBorder; // Abstand Rahmen - Text + long mnTextHeight; // Texthoehe + ProminentEntry meProminentType; // where is the "prominent" entry + + sal_uInt16 mnSelectModifier; // Modifiers + + sal_Bool mbHasFocusRect: 1, + mbSort: 1, // ListBox sortiert + mbTrack: 1, // Tracking + mbMulti: 1, // MultiListBox + mbStackMode: 1, // StackSelection + mbSimpleMode: 1, // SimpleMode fuer MultiListBox + mbImgsDiffSz: 1, // Images haben verschiedene Groessen + mbTravelSelect: 1, // TravelSelect + mbTrackingSelect: 1, // Selektiert bei MouseMove + mbSelectionChanged: 1, // Select() nicht zu oft rufen... + mbMouseMoveSelect: 1, // Selektieren bei MouseMove + mbGrabFocus: 1, // Focus bei MBDown grabben + mbUserDrawEnabled: 1, // UserDraw possible + mbInUserDraw: 1, // In UserDraw + mbReadOnly: 1, // ReadOnly + mbMirroring: 1, // pb: #106948# explicit mirroring for calc + mbRight: 1, // right align Text output + mbCenter: 1; // center Text output + + Link maScrollHdl; + Link maSelectHdl; + Link maCancelHdl; + Link maDoubleClickHdl; + Link maUserDrawHdl; + Link maMRUChangedHdl; + + ::vcl::QuickSelectionEngine + maQuickSelectionEngine; + +protected: + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + + sal_Bool SelectEntries( sal_uInt16 nSelect, LB_EVENT_TYPE eLET, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False ); + void ImplPaint( sal_uInt16 nPos, sal_Bool bErase = sal_False, bool bLayout = false ); + void ImplDoPaint( const Rectangle& rRect, bool bLayout = false ); + void ImplCalcMetrics(); + void ImplUpdateEntryMetrics( ImplEntryType& rEntry ); + void ImplCallSelect(); + + void ImplShowFocusRect(); + void ImplHideFocusRect(); + + + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +public: + virtual void FillLayoutData() const; + + ImplListBoxWindow( Window* pParent, WinBits nWinStyle ); + ~ImplListBoxWindow(); + + ImplEntryList* GetEntryList() const { return mpEntryList; } + + sal_uInt16 InsertEntry( sal_uInt16 nPos, ImplEntryType* pNewEntry ); + void RemoveEntry( sal_uInt16 nPos ); + void Clear(); + void ResetCurrentPos() { mnCurrentPos = LISTBOX_ENTRY_NOTFOUND; } + sal_uInt16 GetCurrentPos() const { return mnCurrentPos; } + sal_uInt16 GetDisplayLineCount() const; + void SetEntryFlags( sal_uInt16 nPos, long nFlags ); + + void DrawEntry( sal_uInt16 nPos, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); + + void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); + void DeselectAll(); + sal_uInt16 GetEntryPosForPoint( const Point& rPoint ) const; + sal_uInt16 GetLastVisibleEntry() const; + + sal_Bool ProcessKeyInput( const KeyEvent& rKEvt ); + + void SetTopEntry( sal_uInt16 nTop ); + sal_uInt16 GetTopEntry() const { return mnTop; } + // ShowProminentEntry will set the entry correspoding to nEntryPos + // either at top or in the middle depending on the chosen style + void ShowProminentEntry( sal_uInt16 nEntryPos ); + void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; } + ProminentEntry GetProminentEntryType() const { return meProminentType; } + using Window::IsVisible; + sal_Bool IsVisible( sal_uInt16 nEntry ) const; + + long GetLeftIndent() const { return mnLeft; } + void SetLeftIndent( long n ); + void ScrollHorz( long nDiff ); + + void AllowGrabFocus( sal_Bool b ) { mbGrabFocus = b; } + sal_Bool IsGrabFocusAllowed() const { return mbGrabFocus; } + + void SetSeparatorPos( sal_uInt16 n ) { mnSeparatorPos = n; } + sal_uInt16 GetSeparatorPos() const { return mnSeparatorPos; } + + void SetTravelSelect( sal_Bool bTravelSelect ) { mbTravelSelect = bTravelSelect; } + sal_Bool IsTravelSelect() const { return mbTravelSelect; } + sal_Bool IsTrackingSelect() const { return mbTrackingSelect; } + + void SetUserItemSize( const Size& rSz ); + const Size& GetUserItemSize() const { return maUserItemSize; } + + void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } + sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } + + void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { mbMulti = bMulti; mbStackMode = bStackMode; } + sal_Bool IsMultiSelectionEnabled() const { return mbMulti; } + + void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { mbSimpleMode = bSimple; } + sal_Bool IsMultiSelectionSimpleMode() const { return mbSimpleMode; } + + void EnableMouseMoveSelect( sal_Bool bMouseMoveSelect ) { mbMouseMoveSelect = bMouseMoveSelect; } + sal_Bool IsMouseMoveSelectEnabled() const { return mbMouseMoveSelect; } + sal_Bool IsMouseMoveSelect() const { return mbMouseMoveSelect||mbStackMode; } + + Size CalcSize( sal_uInt16 nMaxLines ) const; + Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; + + long GetEntryHeight() const { return mnMaxHeight; } + long GetMaxEntryWidth() const { return mnMaxWidth; } + + void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } + const Link& GetScrollHdl() const { return maScrollHdl; } + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } + void SetCancelHdl( const Link& rLink ) { maCancelHdl = rLink; } + const Link& GetCancelHdl() const { return maCancelHdl; } + void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } + const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } + void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } + const Link& GetUserDrawHdl() const { return maUserDrawHdl; } + void SetMRUChangedHdl( const Link& rLink ) { maMRUChangedHdl = rLink; } + const Link& GetMRUChangedHdl() const { return maMRUChangedHdl; } + + sal_Bool IsSelectionChanged() const { return mbSelectionChanged; } + sal_uInt16 GetSelectModifier() const { return mnSelectModifier; } + + void EnableSort( sal_Bool b ) { mbSort = b; } + + void SetReadOnly( sal_Bool bReadOnly ) { mbReadOnly = bReadOnly; } + sal_Bool IsReadOnly() const { return mbReadOnly; } + + using Control::ImplInitSettings; + void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + sal_uInt16 ImplGetTextStyle() const; + + // pb: #106948# explicit mirroring for calc + inline void EnableMirroring() { mbMirroring = sal_True; } + inline sal_Bool IsMirroring() const { return mbMirroring; } + +protected: + // ISearchableStringList + virtual ::vcl::StringEntryIdentifier CurrentEntry( String& _out_entryText ) const; + virtual ::vcl::StringEntryIdentifier NextEntry( ::vcl::StringEntryIdentifier _currentEntry, String& _out_entryText ) const; + virtual void SelectEntry( ::vcl::StringEntryIdentifier _entry ); +}; + +// --------------- +// - ImplListBox - +// --------------- + +class ImplListBox : public Control +{ +private: + ImplListBoxWindow maLBWindow; + ScrollBar* mpHScrollBar; + ScrollBar* mpVScrollBar; + ScrollBarBox* mpScrollBarBox; + sal_Bool mbVScroll : 1, // VScroll an oder aus + mbHScroll : 1, // HScroll an oder aus + mbAutoHScroll : 1; // AutoHScroll an oder aus + Link maScrollHdl; // Weil der vom ImplListBoxWindow selbst benoetigt wird. + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; + +protected: + virtual void GetFocus(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + long Notify( NotifyEvent& rNEvt ); + + void ImplResizeControls(); + void ImplCheckScrollBars(); + void ImplInitScrollBars(); + + DECL_LINK( ScrollBarHdl, ScrollBar* ); + DECL_LINK( LBWindowScrolled, void* ); + DECL_LINK( MRUChanged, void* ); + +public: + ImplListBox( Window* pParent, WinBits nWinStyle ); + ~ImplListBox(); + + const ImplEntryList* GetEntryList() const { return maLBWindow.GetEntryList(); } + ImplListBoxWindow* GetMainWindow() { return &maLBWindow; } + + virtual void Resize(); + virtual const Wallpaper& GetDisplayBackground() const; + virtual Window* GetPreferredKeyInputWindow(); + + sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr ); + sal_uInt16 InsertEntry( sal_uInt16 nPos, const Image& rImage ); + sal_uInt16 InsertEntry( sal_uInt16 nPos, const XubString& rStr, const Image& rImage ); + void RemoveEntry( sal_uInt16 nPos ); + void SetEntryData( sal_uInt16 nPos, void* pNewData ) { maLBWindow.GetEntryList()->SetEntryData( nPos, pNewData ); } + void Clear(); + + void SetEntryFlags( sal_uInt16 nPos, long nFlags ); + long GetEntryFlags( sal_uInt16 nPos ) const; + + void SelectEntry( sal_uInt16 nPos, sal_Bool bSelect ); + void SetNoSelection(); + void ResetCurrentPos() { maLBWindow.ResetCurrentPos(); } + sal_uInt16 GetCurrentPos() const { return maLBWindow.GetCurrentPos(); } + + sal_Bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow.ProcessKeyInput( rKEvt ); } + sal_Bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt ); + + void SetSeparatorPos( sal_uInt16 n ) { maLBWindow.SetSeparatorPos( n ); } + sal_uInt16 GetSeparatorPos() const { return maLBWindow.GetSeparatorPos(); } + + void SetTopEntry( sal_uInt16 nTop ) { maLBWindow.SetTopEntry( nTop ); } + sal_uInt16 GetTopEntry() const { return maLBWindow.GetTopEntry(); } + void ShowProminentEntry( sal_uInt16 nPos ) { maLBWindow.ShowProminentEntry( nPos ); } + using Window::IsVisible; + sal_Bool IsVisible( sal_uInt16 nEntry ) const { return maLBWindow.IsVisible( nEntry ); } + + void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); } + ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); } + + long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); } + void SetLeftIndent( sal_uInt16 n ) { maLBWindow.SetLeftIndent( n ); } + void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); } + + void SetTravelSelect( sal_Bool bTravelSelect ) { maLBWindow.SetTravelSelect( bTravelSelect ); } + sal_Bool IsTravelSelect() const { return maLBWindow.IsTravelSelect(); } + sal_Bool IsTrackingSelect() const { return maLBWindow.IsTrackingSelect(); } + + void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackMode ) { maLBWindow.EnableMultiSelection( bMulti, bStackMode ); } + sal_Bool IsMultiSelectionEnabled() const { return maLBWindow.IsMultiSelectionEnabled(); } + + void SetMultiSelectionSimpleMode( sal_Bool bSimple ) { maLBWindow.SetMultiSelectionSimpleMode( bSimple ); } + sal_Bool IsMultiSelectionSimpleMode() const { return maLBWindow.IsMultiSelectionSimpleMode(); } + + void SetReadOnly( sal_Bool b ) { maLBWindow.SetReadOnly( b ); } + sal_Bool IsReadOnly() const { return maLBWindow.IsReadOnly(); } + + + Size CalcSize( sal_uInt16 nMaxLines ) const { return maLBWindow.CalcSize( nMaxLines ); } + long GetEntryHeight() const { return maLBWindow.GetEntryHeight(); } + long GetMaxEntryWidth() const { return maLBWindow.GetMaxEntryWidth(); } + + void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } + const Link& GetScrollHdl() const { return maScrollHdl; } + void SetSelectHdl( const Link& rLink ) { maLBWindow.SetSelectHdl( rLink ); } + const Link& GetSelectHdl() const { return maLBWindow.GetSelectHdl(); } + void SetCancelHdl( const Link& rLink ) { maLBWindow.SetCancelHdl( rLink ); } + const Link& GetCancelHdl() const { return maLBWindow.GetCancelHdl(); } + void SetDoubleClickHdl( const Link& rLink ) { maLBWindow.SetDoubleClickHdl( rLink ); } + const Link& GetDoubleClickHdl() const { return maLBWindow.GetDoubleClickHdl(); } + void SetUserDrawHdl( const Link& rLink ) { maLBWindow.SetUserDrawHdl( rLink ); } + const Link& GetUserDrawHdl() const { return maLBWindow.GetUserDrawHdl(); } + + void SetSelectionChangedHdl( const Link& rLnk ) { maLBWindow.GetEntryList()->SetSelectionChangedHdl( rLnk ); } + void SetCallSelectionChangedHdl( sal_Bool bCall ) { maLBWindow.GetEntryList()->SetCallSelectionChangedHdl( bCall ); } + sal_Bool IsSelectionChanged() const { return maLBWindow.IsSelectionChanged(); } + sal_uInt16 GetSelectModifier() const { return maLBWindow.GetSelectModifier(); } + + void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep ); + XubString GetMRUEntries( xub_Unicode cSep ) const; + void SetMaxMRUCount( sal_uInt16 n ) { maLBWindow.GetEntryList()->SetMaxMRUCount( n ); } + sal_uInt16 GetMaxMRUCount() const { return maLBWindow.GetEntryList()->GetMaxMRUCount(); } + sal_uInt16 GetDisplayLineCount() const + { return maLBWindow.GetDisplayLineCount(); } + + // pb: #106948# explicit mirroring for calc + inline void EnableMirroring() { maLBWindow.EnableMirroring(); } + inline void SetDropTraget(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_xDNDListenerContainer){ mxDNDListenerContainer= i_xDNDListenerContainer; } +}; + +// ----------------------------- +// - ImplListBoxFloatingWindow - +// ----------------------------- + +class ImplListBoxFloatingWindow : public FloatingWindow +{ +private: + ImplListBox* mpImplLB; + Size maPrefSz; + sal_uInt16 mnDDLineCount; + sal_uInt16 mnPopupModeStartSaveSelection; + sal_Bool mbAutoWidth; + +protected: + long PreNotify( NotifyEvent& rNEvt ); + +public: + ImplListBoxFloatingWindow( Window* pParent ); + + void SetImplListBox( ImplListBox* pLB ) { mpImplLB = pLB; } + + void SetPrefSize( const Size& rSz ) { maPrefSz = rSz; } + const Size& GetPrefSize() const { return maPrefSz; } + + void SetAutoWidth( sal_Bool b ) { mbAutoWidth = b; } + sal_Bool IsAutoWidth() const { return mbAutoWidth; } + + Size CalcFloatSize(); + void StartFloat( sal_Bool bStartTracking ); + + virtual void SetPosSizePixel( long nX, long nY, + long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) + { FloatingWindow::SetPosSizePixel( rNewPos, rNewSize ); } + + void SetDropDownLineCount( sal_uInt16 n ) { mnDDLineCount = n; } + sal_uInt16 GetDropDownLineCount() const { return mnDDLineCount; } + + sal_uInt16 GetPopupModeStartSaveSelection() const { return mnPopupModeStartSaveSelection; } + + virtual void Resize(); +}; + +// ----------- +// - ImplWin - +// ----------- + +class ImplWin : public Control +{ +private: + + sal_uInt16 mnItemPos; // wegen UserDraw muss ich wissen, welches Item ich darstelle. + XubString maString; + Image maImage; + + Rectangle maFocusRect; + Size maUserItemSize; + + Link maMBDownHdl; + Link maUserDrawHdl; + + sal_Bool mbUserDrawEnabled : 1, + mbInUserDraw : 1; + + + void ImplDraw( bool bLayout = false ); +protected: + virtual void FillLayoutData() const; +public: + + ImplWin( Window* pParent, WinBits nWinStyle = 0 ); + ~ImplWin() {}; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual long PreNotify( NotifyEvent& rNEvt ); + + sal_uInt16 GetItemPos() const { return mnItemPos; } + void SetItemPos( sal_uInt16 n ) { mnItemPos = n; } + + const XubString& GetString() const { return maString; } + void SetString( const XubString& rStr ) { maString = rStr; } + + const Image& GetImage() const { return maImage; } + void SetImage( const Image& rImg ) { maImage = rImg; } + + sal_Bool SetModeImage( const Image& rImage ); + const Image& GetModeImage( ) const; + + + virtual void MBDown(); + void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } + const Link& GetMBDownHdl() const { return maMBDownHdl; } + + void SetUserDrawHdl( const Link& rLink ) { maUserDrawHdl = rLink; } + const Link& GetUserDrawHdl() const { return maUserDrawHdl; } + + void SetUserItemSize( const Size& rSz ) { maUserItemSize = rSz; } + const Size& GetUserItemSize() const { return maUserItemSize; } + + void EnableUserDraw( sal_Bool bUserDraw ) { mbUserDrawEnabled = bUserDraw; } + sal_Bool IsUserDrawEnabled() const { return mbUserDrawEnabled; } + + void DrawEntry( sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False, bool bLayout = false ); +}; + +// ----------- +// - ImplBtn - +// ----------- + +class ImplBtn : public PushButton +{ +private: + sal_Bool mbDown; + + Link maMBDownHdl; + +public: + ImplBtn( Window* pParent, WinBits nWinStyle = 0 ); + ~ImplBtn() {}; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + + virtual void MBDown(); + void SetMBDownHdl( const Link& rLink ) { maMBDownHdl = rLink; } + const Link& GetMBDownHdl() const { return maMBDownHdl; } +}; + + +void ImplInitFieldSettings( Window* pWin, sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); +void ImplInitDropDownButton( PushButton* pButton ); + +#endif // _SV_ILSTBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/image.h b/vcl/inc/vcl/image.h new file mode 100644 index 000000000000..86f924993ed3 --- /dev/null +++ b/vcl/inc/vcl/image.h @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMAGE_H +#define _SV_IMAGE_H + +#include <vcl/bitmapex.hxx> + +#include <boost/unordered_map.hpp> + +// ---------------- +// - ImplImageBmp - +// ---------------- + +class ImplImageBmp +{ +public: + + ImplImageBmp(); + ~ImplImageBmp(); + + void Create( long nItemWidth, long nItemHeight, sal_uInt16 nInitSize ); + void Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight,sal_uInt16 nInitSize ); + + void Expand( sal_uInt16 nGrowSize ); + + void Replace( sal_uInt16 nPos, sal_uInt16 nSrcPos ); + void Replace( sal_uInt16 nPos, const ImplImageBmp& rImageBmp, sal_uInt16 nSrcPos ); + void Replace( sal_uInt16 nPos, const BitmapEx& rBmpEx ); + + void ReplaceColors( const Color* pSrcColors, const Color* pDstColors, sal_uIntPtr nColorCount ); + void ColorTransform(); + void Invert(); + + BitmapEx GetBitmapEx( sal_uInt16 nPosCount, sal_uInt16* pPosAry ) const; + + void Draw( sal_uInt16 nPos, OutputDevice* pDev, const Point& rPos, sal_uInt16 nStyle, const Size* pSize = NULL ); + +private: + + BitmapEx maBmpEx; + BitmapEx maDisabledBmpEx; + BitmapEx* mpDisplayBmp; + Size maSize; + sal_uInt8* mpInfoAry; + sal_uInt16 mnSize; + + void ImplUpdateDisplayBmp( OutputDevice* pOutDev ); + void ImplUpdateDisabledBmpEx( int nPos ); + +private: // prevent assignment and copy construction + ImplImageBmp( const ImplImageBmp& ); + void operator=( const ImplImageBmp& ); +}; + +// -------------- +// - ImageTypes - +// -------------- + +enum ImageType { IMAGETYPE_BITMAP, IMAGETYPE_IMAGE }; + +// ----------------- +// - ImplImageList - +// ----------------- + +struct ImageAryData +{ + ::rtl::OUString maName; + // Images identified by either name, or by id + sal_uInt16 mnId; + BitmapEx maBitmapEx; + + ImageAryData(); + ImageAryData( const rtl::OUString &aName, + sal_uInt16 nId, const BitmapEx &aBitmap ); + ImageAryData( const ImageAryData& rData ); + ~ImageAryData(); + + bool IsLoadable() { return maBitmapEx.IsEmpty() && maName.getLength(); } + void Load(const rtl::OUString &rPrefix); + + ImageAryData& operator=( const ImageAryData& rData ); +}; + +// ------------------------------------------------------------------------------ + +struct ImplImageList +{ + typedef std::vector<ImageAryData *> ImageAryDataVec; + typedef boost::unordered_map< rtl::OUString, ImageAryData *, rtl::OUStringHash > + ImageAryDataNameHash; + + ImageAryDataVec maImages; + ImageAryDataNameHash maNameHash; + rtl::OUString maPrefix; + Size maImageSize; + sal_uIntPtr mnRefCount; + + ImplImageList(); + ImplImageList( const ImplImageList &aSrc ); + ~ImplImageList(); + + void AddImage( const ::rtl::OUString &aName, + sal_uInt16 nId, const BitmapEx &aBitmapEx ); + void RemoveImage( sal_uInt16 nPos ); + sal_uInt16 GetImageCount() const; +}; + +// -------------------- +// - ImplImageRefData - +// -------------------- + +struct ImplImageRefData +{ + ImplImageList* mpImplData; + sal_uInt16 mnIndex; + + ImplImageRefData() {} // Um Warning zu umgehen + ~ImplImageRefData(); + + sal_Bool IsEqual( const ImplImageRefData& rData ); +}; + +// ---------------- +// - ImpImageData - +// ---------------- + +struct ImplImageData +{ + ImplImageBmp* mpImageBitmap; + BitmapEx maBmpEx; + + ImplImageData( const BitmapEx& rBmpEx ); + ~ImplImageData(); + + sal_Bool IsEqual( const ImplImageData& rData ); +}; + +// ------------- +// - ImplImage - +// ------------- + +struct ImplImage +{ + sal_uIntPtr mnRefCount; + // TODO: use inheritance to get rid of meType+mpData + void* mpData; + ImageType meType; + + ImplImage(); + ~ImplImage(); + +private: // prevent assignment and copy construction + ImplImage( const ImplImage&); + void operator=( const ImplImage&); +}; + +#endif // _SV_IMAGE_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/image.hxx b/vcl/inc/vcl/image.hxx new file mode 100644 index 000000000000..d536d6bd03d7 --- /dev/null +++ b/vcl/inc/vcl/image.hxx @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMAGE_HXX +#define _SV_IMAGE_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/resid.hxx> +#include <vcl/sv.h> +#include <vcl/bitmapex.hxx> +#include <com/sun/star/uno/Reference.hxx> + +#include <vector> + +struct ImplImage; +struct ImplImageList; +namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } } + +// ----------- +// - Defines - +// ----------- + +#define IMAGE_STDBTN_COLOR Color( 0xC0, 0xC0, 0xC0 ) +#define IMAGELIST_IMAGE_NOTFOUND ((sal_uInt16)0xFFFF) + +// ----------------------- +// - ImageColorTransform - +// ----------------------- + +enum ImageColorTransform +{ + IMAGECOLORTRANSFORM_NONE = 0, + IMAGECOLORTRANSFORM_HIGHCONTRAST = 1, + IMAGECOLORTRANSFORM_MONOCHROME_BLACK = 2, + IMAGECOLORTRANSFORM_MONOCHROME_WHITE = 3 +}; + +// --------- +// - Image - +// --------- + +class VCL_DLLPUBLIC Image +{ + friend class ImageList; + friend class OutputDevice; + +public: + Image(); + Image( const ResId& rResId ); + Image( const Image& rImage ); + Image( const BitmapEx& rBitmapEx ); + Image( const Bitmap& rBitmap ); + Image( const Bitmap& rBitmap, const Bitmap& rMaskBitmap ); + Image( const Bitmap& rBitmap, const Color& rColor ); + Image( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); + ~Image(); + + Size GetSizePixel() const; + + BitmapEx GetBitmapEx() const; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const; + + Image GetColorTransformedImage( ImageColorTransform eColorTransform ) const; + static void GetColorTransformArrays( ImageColorTransform eColorTransform, Color*& rpSrcColor, Color*& rpDstColor, sal_uLong& rColorCount ); + + void Invert(); + + sal_Bool operator!() const { return( !mpImplData ? true : false ); } + Image& operator=( const Image& rImage ); + sal_Bool operator==( const Image& rImage ) const; + sal_Bool operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); } + +private: + + ImplImage* mpImplData; + + SAL_DLLPRIVATE void ImplInit( const BitmapEx& rBmpEx ); +}; + +// ------------- +// - ImageList - +// ------------- + +class VCL_DLLPUBLIC ImageList +{ +public: + ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 ); + ImageList( const ResId& rResId ); + ImageList( const ::std::vector< ::rtl::OUString >& rNameVector, + const ::rtl::OUString& rPrefix, + const Color* pMaskColor = NULL ); + ImageList( const ImageList& rImageList ); + ~ImageList(); + + void Clear(); + void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx, + const std::vector< rtl::OUString > &rNameVector ); + void InsertFromHorizontalBitmap( const ResId& rResId, + sal_uInt16 nCount, + const Color *pNonAlphaMaskColor, + const Color *pSearchColors = NULL, + const Color *pReplaceColors = NULL, + sal_uLong nColorCount = 0); + BitmapEx GetAsHorizontalStrip() const; + sal_uInt16 GetImageCount() const; + Size GetImageSize() const; + + void AddImage( sal_uInt16 nNewId, const Image& rImage ); + void AddImage( const ::rtl::OUString& rImageName, const Image& rImage ); + + void ReplaceImage( sal_uInt16 nId, const Image& rImage ); + void ReplaceImage( const ::rtl::OUString& rImageName, const Image& rImage ); + + void ReplaceImage( sal_uInt16 nId, sal_uInt16 nReplaceId ); + void ReplaceImage( const ::rtl::OUString& rImageName, const ::rtl::OUString& rReplaceName ); + + void RemoveImage( sal_uInt16 nId ); + void RemoveImage( const ::rtl::OUString& rImageName ); + + Image GetImage( sal_uInt16 nId ) const; + Image GetImage( const ::rtl::OUString& rImageName ) const; + + sal_uInt16 GetImagePos( sal_uInt16 nId ) const; + bool HasImageAtPos( sal_uInt16 nId ) const; + sal_uInt16 GetImagePos( const ::rtl::OUString& rImageName ) const; + + sal_uInt16 GetImageId( sal_uInt16 nPos ) const; + void GetImageIds( ::std::vector< sal_uInt16 >& rIds ) const; + + ::rtl::OUString GetImageName( sal_uInt16 nPos ) const; + void GetImageNames( ::std::vector< ::rtl::OUString >& rNames ) const; + + ImageList& operator=( const ImageList& rImageList ); + sal_Bool operator==( const ImageList& rImageList ) const; + sal_Bool operator!=( const ImageList& rImageList ) const { return !(ImageList::operator==( rImageList )); } + +private: + + ImplImageList* mpImplData; + sal_uInt16 mnInitSize; + sal_uInt16 mnGrowSize; + + SAL_DLLPRIVATE void ImplInitBitmapEx( const ::rtl::OUString& rUserImageName, + const ::std::vector< ::rtl::OUString >& rImageNames, + const ::rtl::OUString& rSymbolsStyle, + BitmapEx& rBmpEx, + const Color* pMaskColor ) const; + SAL_DLLPRIVATE void ImplInit( sal_uInt16 nItems, const Size &rSize ); + SAL_DLLPRIVATE sal_uInt16 ImplGetImageId( const ::rtl::OUString& rImageName ) const; + SAL_DLLPRIVATE void ImplMakeUnique(); +}; + +#endif // _SV_IMAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/imagerepository.hxx b/vcl/inc/vcl/imagerepository.hxx new file mode 100644 index 000000000000..8f963fb51edc --- /dev/null +++ b/vcl/inc/vcl/imagerepository.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VCL_IMAGEREPOSITORY_HXX +#define VCL_IMAGEREPOSITORY_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> + +class BitmapEx; + +//........................................................................ +namespace vcl +{ +//........................................................................ + + //==================================================================== + //= ImageRepository + //==================================================================== + // provides access to the application's image repository (image.zip) + class VCL_DLLPUBLIC ImageRepository + { + public: + /** loads an image from the application's image repository + @param _rName + the name of the image to load. + @param _out_rImage + will take the image upon successful return. + @param bSearchLanguageDependent + determines whether a language-dependent image is to be searched. + @return + whether or not the image could be loaded successfully. + */ + static bool loadImage( + const ::rtl::OUString& _rName, + BitmapEx& _out_rImage, + bool bSearchLanguageDependent, + bool loadMissing = false + ); + + static bool loadDefaultImage( + BitmapEx& _out_rImage + ); + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_IMAGEREPOSITORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/imgctrl.hxx b/vcl/inc/vcl/imgctrl.hxx new file mode 100644 index 000000000000..ec8ed99c93bb --- /dev/null +++ b/vcl/inc/vcl/imgctrl.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMGCTRL_HXX +#define _SV_IMGCTRL_HXX + +#include <vcl/dllapi.h> + +#include <vcl/fixed.hxx> +#include <vcl/bitmapex.hxx> + +// ---------------- +// - ImageControl - +// ---------------- + +class VCL_DLLPUBLIC ImageControl : public FixedImage +{ +private: + ::sal_Int16 mnScaleMode; + +public: + ImageControl( Window* pParent, WinBits nStyle = 0 ); + ImageControl( Window* pParent, const ResId& rResId ); + + // set/get the scale mode. This is one of the css.awt.ImageScaleMode constants + void SetScaleMode( const ::sal_Int16 _nMode ); + ::sal_Int16 GetScaleMode() const { return mnScaleMode; } + + virtual void Resize(); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Paint( const Rectangle& rRect ); + virtual void GetFocus(); + virtual void LoseFocus(); + +protected: + void ImplDraw( OutputDevice& rDev, sal_uLong nDrawFlags, const Point& rPos, const Size& rSize ) const; +private: + sal_Bool SetModeBitmap( const BitmapEx& rBitmap ); + const BitmapEx& GetModeBitmap( ) const; +}; + +#endif // _SV_IMGCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impbmp.hxx b/vcl/inc/vcl/impbmp.hxx new file mode 100644 index 000000000000..c77e906bd8ae --- /dev/null +++ b/vcl/inc/vcl/impbmp.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMPBMP_HXX +#define _SV_IMPBMP_HXX + +#include <tools/gen.hxx> +#include <vcl/sv.h> + +// --------------- +// - ImpBitmap - +// --------------- + +struct BitmapBuffer; +class SalBitmap; +class BitmapPalette; +class SalGraphics; +class ImplServerBitmap; +class Bitmap; +class OutputDevice; +class Color; +class AlphaMask; + +class ImpBitmap +{ +private: + + sal_uLong mnRefCount; + sal_uLong mnChecksum; + SalBitmap* mpSalBitmap; + Size maSourceSize; + +public: + + ImpBitmap(); + ~ImpBitmap(); + +#if _SOLAR__PRIVATE + +public: + + void ImplSetSalBitmap( SalBitmap* pSalBitmap ); + SalBitmap* ImplGetSalBitmap() const { return mpSalBitmap; } + +public: + + sal_Bool ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal ); + sal_Bool ImplCreate( const ImpBitmap& rImpBitmap ); + sal_Bool ImplCreate( const ImpBitmap& rImpBitmap, SalGraphics* pGraphics ); + sal_Bool ImplCreate( const ImpBitmap& rImpBitmap, sal_uInt16 nNewBitCount ); + + void ImplDestroy(); + + Size ImplGetSize() const; + Size ImplGetSourceSize() const; + void ImplSetSourceSize( const Size&); + sal_uInt16 ImplGetBitCount() const; + + BitmapBuffer* ImplAcquireBuffer( sal_Bool bReadOnly ); + void ImplReleaseBuffer( BitmapBuffer* pBuffer, sal_Bool bReadOnly ); + +public: + + sal_uLong ImplGetRefCount() const { return mnRefCount; } + void ImplIncRefCount() { mnRefCount++; } + void ImplDecRefCount() { mnRefCount--; } + + inline void ImplSetChecksum( sal_uLong nChecksum ) { mnChecksum = nChecksum; } + inline sal_uLong ImplGetChecksum() const { return mnChecksum; } + +#endif // PRIVATE +}; + +inline Size ImpBitmap::ImplGetSourceSize() const +{ + return maSourceSize; +} + +inline void ImpBitmap::ImplSetSourceSize( const Size& rSize) +{ + maSourceSize = rSize; +} + +#endif // _SV_IMPBMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impdel.hxx b/vcl/inc/vcl/impdel.hxx new file mode 100644 index 000000000000..90ab82bd1878 --- /dev/null +++ b/vcl/inc/vcl/impdel.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + #ifndef _VCL_IMPDEL_HXX + #define _VCL_IMPDEL_HXX + + #include <list> + + namespace vcl + { + + class DeletionListener; + + class DeletionNotifier + { + std::list< DeletionListener* > m_aListeners; + protected: + DeletionNotifier() {} + + ~DeletionNotifier() + { notifyDelete(); } + + inline void notifyDelete(); + + public: + void addDel( DeletionListener* pListener ) + { m_aListeners.push_back( pListener ); } + + void removeDel( DeletionListener* pListener ) + { m_aListeners.remove( pListener ); } + }; + + class DeletionListener + { + DeletionNotifier* m_pNotifier; + public: + DeletionListener( DeletionNotifier* pNotifier ) + : m_pNotifier( pNotifier ) + { + if( m_pNotifier ) + m_pNotifier->addDel( this ); + } + ~DeletionListener() + { + if( m_pNotifier ) + m_pNotifier->removeDel( this ); + } + void deleted() { m_pNotifier = NULL; } + bool isDeleted() const { return (m_pNotifier == NULL); } + }; + + inline void DeletionNotifier::notifyDelete() + { + for( std::list< DeletionListener* >::const_iterator it = + m_aListeners.begin(); it != m_aListeners.end(); ++it ) + (*it)->deleted(); + + m_aListeners.clear(); + } + + } // namespace vcl + + #endif // _VCL_IMPDEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impfont.hxx b/vcl/inc/vcl/impfont.hxx new file mode 100644 index 000000000000..40355af21518 --- /dev/null +++ b/vcl/inc/vcl/impfont.hxx @@ -0,0 +1,242 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMPFONT_HXX +#define _SV_IMPFONT_HXX + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <i18npool/lang.h> +#include <tools/color.hxx> +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> +#include <vcl/fntstyle.hxx> + +// ------------ +// - Impl_Font - +// ------------ + +class Impl_Font +{ +public: + Impl_Font(); + Impl_Font( const Impl_Font& ); + + bool operator==( const Impl_Font& ) const; + + FontPitch GetPitch() { if(mePitch==PITCH_DONTKNOW) AskConfig(); return mePitch; } + FontFamily GetFamily() { if(meFamily==FAMILY_DONTKNOW) AskConfig(); return meFamily; } + FontItalic GetItalic() { if(meItalic==ITALIC_DONTKNOW) AskConfig(); return meItalic; } + FontWeight GetWeight() { if(meWeight==WEIGHT_DONTKNOW) AskConfig(); return meWeight; } + FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW)AskConfig(); return meWidthType; } + +private: + friend class Font; + void AskConfig(); + + int mnRefCount; + String maFamilyName; + String maStyleName; + Size maSize; + Color maColor; // compatibility, now on output device + Color maFillColor; // compatibility, now on output device + rtl_TextEncoding meCharSet; + LanguageType meLanguage; + LanguageType meCJKLanguage; + FontFamily meFamily; + FontPitch mePitch; + TextAlign meAlign; + FontWeight meWeight; + FontWidth meWidthType; + FontItalic meItalic; + FontUnderline meUnderline; + FontUnderline meOverline; + FontStrikeout meStrikeout; + FontRelief meRelief; + FontEmphasisMark meEmphasisMark; + FontType meType; // used by metrics only + short mnOrientation; + FontKerning mnKerning; + sal_Bool mbWordLine:1, + mbOutline:1, + mbConfigLookup:1, // there was a config lookup + mbShadow:1, + mbVertical:1, + mbTransparent:1; // compatibility, now on output device + + friend SvStream& operator>>( SvStream& rIStm, Impl_Font& ); + friend SvStream& operator<<( SvStream& rOStm, const Impl_Font& ); +}; + +// ------------------ +// - ImplFontMetric - +// ------------------ + +class ImplFontMetric +{ + friend class OutputDevice; + +private: + long mnAscent; // Ascent + long mnDescent; // Descent + long mnIntLeading; // Internal Leading + long mnExtLeading; // External Leading + long mnLineHeight; // Ascent+Descent+EmphasisMark + long mnSlant; // Slant + sal_uInt16 mnMiscFlags; // Misc Flags + sal_uInt32 mnRefCount; // Reference Counter + + enum { DEVICE_FLAG=1, SCALABLE_FLAG=2, LATIN_FLAG=4, CJK_FLAG=8, CTL_FLAG=16 }; + +public: + ImplFontMetric(); + void AddReference(); + void DeReference(); + + long GetAscent() const { return mnAscent; } + long GetDescent() const { return mnDescent; } + long GetIntLeading() const { return mnIntLeading; } + long GetExtLeading() const { return mnExtLeading; } + long GetLineHeight() const { return mnLineHeight; } + long GetSlant() const { return mnSlant; } + + bool IsDeviceFont() const { return ((mnMiscFlags & DEVICE_FLAG) != 0); } + bool IsScalable() const { return ((mnMiscFlags & SCALABLE_FLAG) != 0); } + bool SupportsLatin() const { return ((mnMiscFlags & LATIN_FLAG) != 0); } + bool SupportsCJK() const { return ((mnMiscFlags & CJK_FLAG) != 0); } + bool SupportsCTL() const { return ((mnMiscFlags & CTL_FLAG) != 0); } + + bool operator==( const ImplFontMetric& ) const; +}; + +// ------------------ +// - ImplFontOptions - +// ------------------ + +class ImplFontOptions +{ +public: + FontEmbeddedBitmap meEmbeddedBitmap; // whether the embedded bitmaps should be used + FontAntiAlias meAntiAlias; // whether the font should be antialiased + FontAutoHint meAutoHint; // whether the font should be autohinted + FontHinting meHinting; // whether the font should be hinted + FontHintStyle meHintStyle; // type of font hinting to be used +public: + ImplFontOptions() : + meEmbeddedBitmap(EMBEDDEDBITMAP_DONTKNOW), + meAntiAlias(ANTIALIAS_DONTKNOW), + meAutoHint(AUTOHINT_DONTKNOW), + meHinting(HINTING_DONTKNOW), + meHintStyle(HINT_SLIGHT) + {} + virtual ~ImplFontOptions() + {} + FontAutoHint GetUseAutoHint() const + { return meAutoHint; } + FontHintStyle GetHintStyle() const + { return meHintStyle; } + bool DontUseEmbeddedBitmaps() const + { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; } + bool DontUseAntiAlias() const + { return meAntiAlias == ANTIALIAS_FALSE; } + bool DontUseHinting() const + { return (meHinting == HINTING_FALSE) || (GetHintStyle() == HINT_NONE); } + virtual void *GetPattern(void * /*pFace*/, bool /*bEmbolden*/) const + { return NULL; } +}; + +// ------------------- +// - ImplFontCharMap - +// ------------------- + +class CmapResult; + +class VCL_PLUGIN_PUBLIC ImplFontCharMap +{ +public: + explicit ImplFontCharMap( const CmapResult& ); + virtual ~ImplFontCharMap(); + + static ImplFontCharMap* GetDefaultMap( bool bSymbols=false); + + bool IsDefaultMap() const; + bool HasChar( sal_uInt32 ) const; + int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const; + int GetCharCount() const; + + sal_uInt32 GetFirstChar() const; + sal_uInt32 GetLastChar() const; + + sal_uInt32 GetNextChar( sal_uInt32 ) const; + sal_uInt32 GetPrevChar( sal_uInt32 ) const; + + int GetIndexFromChar( sal_uInt32 ) const; + sal_uInt32 GetCharFromIndex( int ) const; + + void AddReference() const; + void DeReference() const; + + int GetGlyphIndex( sal_uInt32 ) const; + +private: + int ImplFindRangeIndex( sal_uInt32 ) const; + + // prevent assignment and copy construction + explicit ImplFontCharMap( const ImplFontCharMap& ); + void operator=( const ImplFontCharMap& ); + +private: + const sal_uInt32* mpRangeCodes; // pairs of StartCode/(EndCode+1) + const int* mpStartGlyphs; // range-specific mapper to glyphs + const sal_uInt16* mpGlyphIds; // individual glyphid mappings + int mnRangeCount; + int mnCharCount; // covered codepoints + mutable int mnRefCount; +}; + +// CmapResult is a normalized version of the many CMAP formats +class VCL_PLUGIN_PUBLIC CmapResult +{ +public: + explicit CmapResult( bool bSymbolic = false, + const sal_uInt32* pRangeCodes = NULL, int nRangeCount = 0, + const int* pStartGlyphs = 0, const sal_uInt16* pGlyphIds = NULL ); + + const sal_uInt32* mpRangeCodes; + const int* mpStartGlyphs; + const sal_uInt16* mpGlyphIds; + int mnRangeCount; + bool mbSymbolic; + bool mbRecoded; +}; + +bool ParseCMAP( const unsigned char* pRawData, int nRawLength, CmapResult& ); + +#endif // _SV_IMPFONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impgraph.hxx b/vcl/inc/vcl/impgraph.hxx new file mode 100644 index 000000000000..22c409fb476a --- /dev/null +++ b/vcl/inc/vcl/impgraph.hxx @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMPGRAPH_HXX +#define _SV_IMPGRAPH_HXX + +#include <tools/urlobj.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/animate.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/graph.h> + +// --------------- +// - ImpSwapInfo - +// --------------- + +struct ImpSwapInfo +{ + MapMode maPrefMapMode; + Size maPrefSize; +}; + +// -------------- +// - ImpGraphic - +// -------------- + +class OutputDevice; +class GfxLink; +struct ImpSwapFile; +class GraphicConversionParameters; + +class ImpGraphic +{ + friend class Graphic; + +private: + + GDIMetaFile maMetaFile; + BitmapEx maEx; + ImpSwapInfo maSwapInfo; + Animation* mpAnimation; + GraphicReader* mpContext; + ImpSwapFile* mpSwapFile; + GfxLink* mpGfxLink; + GraphicType meType; + String maDocFileURLStr; + sal_uLong mnDocFilePos; + mutable sal_uLong mnSizeBytes; + sal_uLong mnRefCount; + sal_Bool mbSwapOut; + sal_Bool mbSwapUnderway; + +private: + + ImpGraphic(); + ImpGraphic( const ImpGraphic& rImpGraphic ); + ImpGraphic( const Bitmap& rBmp ); + ImpGraphic( const BitmapEx& rBmpEx ); + ImpGraphic( const Animation& rAnimation ); + ImpGraphic( const GDIMetaFile& rMtf ); + virtual ~ImpGraphic(); + + ImpGraphic& operator=( const ImpGraphic& rImpGraphic ); + sal_Bool operator==( const ImpGraphic& rImpGraphic ) const; + sal_Bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); } + + void ImplClearGraphics( sal_Bool bCreateSwapInfo ); + void ImplClear(); + + GraphicType ImplGetType() const; + void ImplSetDefaultType(); + sal_Bool ImplIsSupportedGraphic() const; + + sal_Bool ImplIsTransparent() const; + sal_Bool ImplIsAlpha() const; + sal_Bool ImplIsAnimated() const; + + Bitmap ImplGetBitmap(const GraphicConversionParameters& rParameters) const; + BitmapEx ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const; + Animation ImplGetAnimation() const; + const GDIMetaFile& ImplGetGDIMetaFile() const; + + Size ImplGetPrefSize() const; + void ImplSetPrefSize( const Size& rPrefSize ); + + MapMode ImplGetPrefMapMode() const; + void ImplSetPrefMapMode( const MapMode& rPrefMapMode ); + + sal_uLong ImplGetSizeBytes() const; + + void ImplDraw( OutputDevice* pOutDev, + const Point& rDestPt ) const; + void ImplDraw( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize ) const; + + void ImplStartAnimation( OutputDevice* pOutDev, + const Point& rDestPt, + long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = NULL ); + void ImplStartAnimation( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize, + long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = NULL ); + void ImplStopAnimation( OutputDevice* pOutputDevice = NULL, + long nExtraData = 0 ); + + void ImplSetAnimationNotifyHdl( const Link& rLink ); + Link ImplGetAnimationNotifyHdl() const; + + sal_uLong ImplGetAnimationLoopCount() const; + void ImplResetAnimationLoopCount(); + + List* ImplGetAnimationInfoList() const; + +private: + + GraphicReader* ImplGetContext(); + void ImplSetContext( GraphicReader* pReader ); + +private: + + void ImplSetDocFileName( const String& rName, sal_uLong nFilePos ); + const String& ImplGetDocFileName() const; + sal_uLong ImplGetDocFilePos() const; + + sal_Bool ImplReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False ); + sal_Bool ImplWriteEmbedded( SvStream& rOStream ); + + sal_Bool ImplSwapIn(); + sal_Bool ImplSwapIn( SvStream* pIStm ); + + sal_Bool ImplSwapOut(); + sal_Bool ImplSwapOut( SvStream* pOStm ); + + sal_Bool ImplIsSwapOut() const; + + void ImplSetLink( const GfxLink& ); + GfxLink ImplGetLink(); + sal_Bool ImplIsLink() const; + + sal_uLong ImplGetChecksum() const; + + sal_Bool ImplExportNative( SvStream& rOStm ) const; + + friend SvStream& operator<<( SvStream& rOStm, const ImpGraphic& rImpGraphic ); + friend SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic ); +}; + +#endif // _SV_IMPGRAPH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impimagetree.hxx b/vcl/inc/vcl/impimagetree.hxx new file mode 100644 index 000000000000..41c4f565ef22 --- /dev/null +++ b/vcl/inc/vcl/impimagetree.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ***********************************************************************/ + +#ifndef INCLUDED_VCL_IMPIMAGETREE_HXX +#define INCLUDED_VCL_IMPIMAGETREE_HXX + +#include "sal/config.h" + +#include <list> +#include <utility> +#include <vector> + +#include <boost/unordered_map.hpp> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "rtl/ustring.hxx" +#include "salhelper/singletonref.hxx" + +namespace com { namespace sun { namespace star { namespace container { + class XNameAccess; +} } } } +class BitmapEx; + +class ImplImageTree: private boost::noncopyable { +public: + ImplImageTree(); + + ~ImplImageTree(); + + // check whether the icon style is installed + bool checkStyle(rtl::OUString const & style); + + bool loadImage( + rtl::OUString const & name, rtl::OUString const & style, + BitmapEx & bitmap, bool localized = false, bool loadMissing = false ); + + bool loadDefaultImage( + rtl::OUString const & style, + BitmapEx& bitmap); + + void shutDown(); + // a crude form of life cycle control (called from DeInitVCL; otherwise, + // if the ImplImageTree singleton were destroyed during exit that would + // be too late for the destructors of the bitmaps in m_iconCache) + +private: + bool doLoadImage( + rtl::OUString const & name, rtl::OUString const & style, + BitmapEx & bitmap, bool localized); + + typedef std::list< + std::pair< + rtl::OUString, + com::sun::star::uno::Reference< + com::sun::star::container::XNameAccess > > > Zips; + + typedef boost::unordered_map< + rtl::OUString, bool, rtl::OUStringHash > CheckStyleCache; + typedef boost::unordered_map< + rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > IconCache; + + rtl::OUString m_style; + Zips m_zips; + CheckStyleCache m_checkStyleCache; + IconCache m_iconCache; + + void setStyle(rtl::OUString const & style ); + + void resetZips(); + + bool checkStyleCacheLookup( rtl::OUString const & style, bool &exists ); + bool iconCacheLookup( rtl::OUString const & name, bool localized, BitmapEx & bitmap ); + + bool find(std::vector< rtl::OUString > const & paths, BitmapEx & bitmap ); +}; + +typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/impoct.hxx b/vcl/inc/vcl/impoct.hxx new file mode 100644 index 000000000000..daf6a275ada1 --- /dev/null +++ b/vcl/inc/vcl/impoct.hxx @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_IMPOCT_HXX +#define _SV_IMPOCT_HXX + +#include <vcl/octree.hxx> + +// ---------------- +// - ImpErrorQuad - +// ---------------- + +class ImpErrorQuad +{ + long nRed; + long nGreen; + long nBlue; + long nReserved; + +public: + + inline ImpErrorQuad() {} + inline ImpErrorQuad( const BitmapColor& rColor ) : + nRed ( (long) rColor.GetRed() << 5L ), + nGreen ( (long) rColor.GetGreen() << 5L ), + nBlue ( (long) rColor.GetBlue() << 5L ) {} + + inline void operator=( const BitmapColor& rColor ); + inline ImpErrorQuad& operator-=( const BitmapColor& rColor ); + + inline void ImplAddColorError1( const ImpErrorQuad& rErrQuad ); + inline void ImplAddColorError3( const ImpErrorQuad& rErrQuad ); + inline void ImplAddColorError5( const ImpErrorQuad& rErrQuad ); + inline void ImplAddColorError7( const ImpErrorQuad& rErrQuad ); + + inline BitmapColor ImplGetColor(); +}; + +// ------------------------------------------------------------------------ + +inline void ImpErrorQuad::operator=( const BitmapColor& rColor ) +{ + nRed = (long) rColor.GetRed() << 5L; + nGreen = (long) rColor.GetGreen() << 5L; + nBlue = (long) rColor.GetBlue() << 5L; +} + +// ------------------------------------------------------------------------ + +inline ImpErrorQuad& ImpErrorQuad::operator-=( const BitmapColor& rColor ) +{ + nRed -= ( (long) rColor.GetRed() << 5L ); + nGreen -= ( (long) rColor.GetGreen() << 5L ); + nBlue -= ( (long) rColor.GetBlue() << 5L ); + + return *this; +} + +// ------------------------------------------------------------------------ + +inline void ImpErrorQuad::ImplAddColorError1( const ImpErrorQuad& rErrQuad ) +{ + nRed += ( rErrQuad.nRed >> 4L ); + nGreen += ( rErrQuad.nGreen >> 4L ); + nBlue += ( rErrQuad.nBlue >> 4L ); +} + +// ------------------------------------------------------------------------ + +inline void ImpErrorQuad::ImplAddColorError3( const ImpErrorQuad& rErrQuad ) +{ + nRed += ( rErrQuad.nRed * 3L >> 4L ); + nGreen += ( rErrQuad.nGreen * 3L >> 4L ); + nBlue += ( rErrQuad.nBlue * 3L >> 4L ); +} + +// ------------------------------------------------------------------------ + +inline void ImpErrorQuad::ImplAddColorError5( const ImpErrorQuad& rErrQuad ) +{ + nRed += ( rErrQuad.nRed * 5L >> 4L ); + nGreen += ( rErrQuad.nGreen * 5L >> 4L ); + nBlue += ( rErrQuad.nBlue * 5L >> 4L ); +} + +// ------------------------------------------------------------------------ + +inline void ImpErrorQuad::ImplAddColorError7( const ImpErrorQuad& rErrQuad ) +{ + nRed += ( rErrQuad.nRed * 7L >> 4L ); + nGreen += ( rErrQuad.nGreen * 7L >> 4L ); + nBlue += ( rErrQuad.nBlue *7L >> 4L ); +} + +// ------------------------------------------------------------------------ + +inline BitmapColor ImpErrorQuad::ImplGetColor() +{ + return BitmapColor( (sal_uInt8) ( ( nRed < 0L ? 0L : nRed > 8160L ? 8160L : nRed ) >> 5L ), + (sal_uInt8) ( ( nGreen < 0L ? 0L : nGreen > 8160L ? 8160L : nGreen ) >> 5L ), + (sal_uInt8) ( ( nBlue < 0L ? 0L : nBlue > 8160L ? 8160L : nBlue ) >> 5L ) ); +} + +// ------------- +// - NodeCache - +// ------------- + +class ImpNodeCache +{ + OctreeNode* pActNode; + sal_uLong nNew; + sal_uLong nDelete; + sal_uLong nGet; + sal_uLong nRelease; + +public: + + ImpNodeCache( const sal_uLong nInitSize ); + ~ImpNodeCache(); + + inline OctreeNode* ImplGetFreeNode(); + inline void ImplReleaseNode( OctreeNode* pNode ); +}; + +// ------------------------------------------------------------------------ + +inline OctreeNode* ImpNodeCache::ImplGetFreeNode() +{ + OctreeNode* pNode; + + if ( !pActNode ) + { + pActNode = new NODE; + pActNode->pNextInCache = NULL; + } + + pNode = pActNode; + pActNode = pNode->pNextInCache; + memset( pNode, 0, sizeof( NODE ) ); + + return pNode; +} + +// ------------------------------------------------------------------------ + +inline void ImpNodeCache::ImplReleaseNode( OctreeNode* pNode ) +{ + pNode->pNextInCache = pActNode; + pActNode = pNode; +} + +#endif // _SV_IMPOCT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/inputctx.hxx b/vcl/inc/vcl/inputctx.hxx new file mode 100644 index 000000000000..eaaec5e7bd1d --- /dev/null +++ b/vcl/inc/vcl/inputctx.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_INPUTCTX_HXX +#define _VCL_INPUTCTX_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/font.hxx> + +// ---------------------- +// - InputContext-Flags - +// ---------------------- + +#define INPUTCONTEXT_TEXT ((sal_uLong)0x00000001) +#define INPUTCONTEXT_EXTTEXTINPUT ((sal_uLong)0x00000002) +#define INPUTCONTEXT_EXTTEXTINPUT_ON ((sal_uLong)0x00000004) +#define INPUTCONTEXT_EXTTEXTINPUT_OFF ((sal_uLong)0x00000008) + +// ---------------- +// - InputContext - +// ---------------- + +class VCL_DLLPUBLIC InputContext +{ +private: + Font maFont; + sal_uLong mnOptions; + +public: + InputContext() { mnOptions = 0; } + InputContext( const InputContext& rInputContext ) : + maFont( rInputContext.maFont ) + { mnOptions = rInputContext.mnOptions; } + InputContext( const Font& rFont, sal_uLong nOptions = 0 ) : + maFont( rFont ) + { mnOptions = nOptions; } + + void SetFont( const Font& rFont ) { maFont = rFont; } + const Font& GetFont() const { return maFont; } + + void SetOptions( sal_uLong nOptions ) { mnOptions = nOptions; } + sal_uLong GetOptions() const { return mnOptions; } + + InputContext& operator=( const InputContext& rInputContext ); + sal_Bool operator==( const InputContext& rInputContext ) const; + sal_Bool operator!=( const InputContext& rInputContext ) const + { return !(InputContext::operator==( rInputContext )); } +}; + +inline InputContext& InputContext::operator=( const InputContext& rInputContext ) +{ + maFont = rInputContext.maFont; + mnOptions = rInputContext.mnOptions; + return *this; +} + +inline sal_Bool InputContext::operator==( const InputContext& rInputContext ) const +{ + return ((mnOptions == rInputContext.mnOptions) && + (maFont == rInputContext.maFont)); +} + +#endif // _VCL_INPUTCTX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/introwin.hxx b/vcl/inc/vcl/introwin.hxx new file mode 100644 index 000000000000..e5503bc5dfd6 --- /dev/null +++ b/vcl/inc/vcl/introwin.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_INTROWIN_HXX +#define _SV_INTROWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/wrkwin.hxx> +#include <vcl/bitmapex.hxx> + +// -------------- +// - IntroWindow - +// -------------- + +class VCL_DLLPUBLIC IntroWindow : public WorkWindow +{ +private: + SAL_DLLPRIVATE void ImplInitIntroWindowData(); + +public: + IntroWindow(); + ~IntroWindow(); + + void SetBackgroundBitmap( const Bitmap& rBitmap ); + void SetBackgroundBitmap( const BitmapEx& rBitmapEx ); +}; + +#endif // _SV_INTROWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/javachild.hxx b/vcl/inc/vcl/javachild.hxx new file mode 100644 index 000000000000..a7b39d0bff8f --- /dev/null +++ b/vcl/inc/vcl/javachild.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_JAVACHILD_HXX +#define _SV_JAVACHILD_HXX + +#include <vcl/dllapi.h> +#include <vcl/syschild.hxx> + +// ------------------- +// - JavaChildWindow - +// ------------------- + +class VCL_DLLPUBLIC JavaChildWindow : public SystemChildWindow +{ +public: + + JavaChildWindow( Window* pParent, WinBits nStyle = 0 ); + JavaChildWindow( Window* pParent, const ResId& rResId ); + ~JavaChildWindow(); + + sal_IntPtr getParentWindowHandleForJava(); + +private: + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE JavaChildWindow (const JavaChildWindow &); + SAL_DLLPRIVATE JavaChildWindow & operator= (const JavaChildWindow &); +}; + +#endif // _SV_JAVACHILD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/jobdata.hxx b/vcl/inc/vcl/jobdata.hxx new file mode 100644 index 000000000000..7517b41ef03c --- /dev/null +++ b/vcl/inc/vcl/jobdata.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_JOBDATA_HXX_ +#define _PSPRINT_JOBDATA_HXX_ + +#include "vcl/ppdparser.hxx" + +namespace psp { + +namespace orientation { +enum type { + Portrait, + Landscape +}; +} + +struct JobData +{ + int m_nCopies; + int m_nLeftMarginAdjust; + int m_nRightMarginAdjust; + int m_nTopMarginAdjust; + int m_nBottomMarginAdjust; + // user overrides for PPD + int m_nColorDepth; + int m_nPSLevel; // 0: no override, else languaglevel to use + int m_nColorDevice; // 0: no override, -1 grey scale, +1 color + int m_nPDFDevice; // 0: PostScript, 1: PDF + orientation::type m_eOrientation; + ::rtl::OUString m_aPrinterName; + const PPDParser* m_pParser; + PPDContext m_aContext; + + JobData() : + m_nCopies( 1 ), + m_nLeftMarginAdjust( 0 ), + m_nRightMarginAdjust( 0 ), + m_nTopMarginAdjust( 0 ), + m_nBottomMarginAdjust( 0 ), + m_nColorDepth( 24 ), + m_nPSLevel( 0 ), + m_nColorDevice( 0 ), + m_nPDFDevice( 0 ), + m_eOrientation( orientation::Portrait ), + m_pParser( NULL ) {} + + JobData& operator=(const psp::JobData& rRight); + + JobData( const JobData& rData ) { *this = rData; } + + void setCollate( bool bCollate ); + bool setPaper( int nWidth, int nHeight ); // dimensions in pt + bool setPaperBin( int nPaperBin ); // dimensions in pt + + // creates a new buffer using new + // it is up to the user to delete it again + bool getStreamBuffer( void*& pData, int& bytes ); + static bool constructFromStreamBuffer( void* pData, int bytes, JobData& rJobData ); +}; + +} // namespace + + +#endif // PSPRINT_JOBDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/jobset.h b/vcl/inc/vcl/jobset.h new file mode 100644 index 000000000000..b1cbdb9853f9 --- /dev/null +++ b/vcl/inc/vcl/jobset.h @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_JOBSET_H +#define _SV_JOBSET_H + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/prntypes.hxx> +#include <boost/unordered_map.hpp> +#include <rtl/ustring.hxx> + +// ------------------ +// - JobSetup-Types - +// ------------------ + +// see com.sun.star.portal.client.JobSetupSystem.idl: +#define JOBSETUP_SYSTEM_DONTKNOW 0 +#define JOBSETUP_SYSTEM_WINDOWS 1 +#define JOBSETUP_SYSTEM_OS2 2 +#define JOBSETUP_SYSTEM_UNIX 3 +#define JOBSETUP_SYSTEM_MAC 4 +#define JOBSETUP_SYSTEM_JAVA 5 + +// ---------------- +// - ImplJobSetup - +// ---------------- + +struct ImplJobSetup +{ + sal_uInt16 mnRefCount; // RefCount (only independ data) + sal_uInt16 mnSystem; // Sytem - JOBSETUP_SYSTEM_xxxx + String maPrinterName; // Printer-Name + String maDriver; // Driver-Name + Orientation meOrientation; // Orientation + DuplexMode meDuplexMode; // Duplex + sal_uInt16 mnPaperBin; // paper bin / in tray + Paper mePaperFormat; // paper format + long mnPaperWidth; // paper width (100th mm) + long mnPaperHeight; // paper height (100th mm) + sal_uIntPtr mnDriverDataLen; // length of system specific data + sal_uInt8* mpDriverData; // system specific data (will be streamed a byte block) + ::boost::unordered_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > maValueMap; + + ImplJobSetup(); + ImplJobSetup( const ImplJobSetup& rJobSetup ); + ~ImplJobSetup(); +}; + +// Papierformat wird wenn PAPER_USER im unabhaengigen Teil automatisch aus +// Papierbreite/hoehe berechnet +// Papierbreite/hoehe wird wenn 0 im unabhaengigen Teil automatisch aus +// Papierformat berechnet, wenn dieses ungleich PAPER_USER ist + +#endif // _SV_JOBSET_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/jobset.hxx b/vcl/inc/vcl/jobset.hxx new file mode 100644 index 000000000000..0340f5dd8587 --- /dev/null +++ b/vcl/inc/vcl/jobset.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_JOBSET_HXX +#define _SV_JOBSET_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/prntypes.hxx> + +class SvStream; +struct ImplJobSetup; + +// ------------ +// - JobSetup - +// ------------ + +class VCL_DLLPUBLIC JobSetup +{ + friend class Printer; + +private: + ImplJobSetup* mpData; + +public: + SAL_DLLPRIVATE ImplJobSetup* ImplGetData(); + SAL_DLLPRIVATE ImplJobSetup* ImplGetConstData(); + SAL_DLLPRIVATE const ImplJobSetup* ImplGetConstData() const; + +public: + JobSetup(); + JobSetup( const JobSetup& rJob ); + ~JobSetup(); + + String GetPrinterName() const; + String GetDriverName() const; + + /* Get/SetValue are used to read/store additional + * Parameters in the job setup that may be used + * by the printer driver. One possible use are phone + * numbers for faxes (which disguise as printers) + */ + String GetValue( const String& rKey ) const; + void SetValue( const String& rKey, const String& rValue ); + + JobSetup& operator=( const JobSetup& rJob ); + + sal_Bool operator==( const JobSetup& rJobSetup ) const; + sal_Bool operator!=( const JobSetup& rJobSetup ) const + { return !(JobSetup::operator==( rJobSetup )); } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const JobSetup& rJobSetup ); +}; + +#endif // _SV_JOBSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/keycod.hxx b/vcl/inc/vcl/keycod.hxx new file mode 100644 index 000000000000..b5be547b1781 --- /dev/null +++ b/vcl/inc/vcl/keycod.hxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_KEYCODE_HXX +#define _SV_KEYCODE_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/resid.hxx> +#include <vcl/keycodes.hxx> + +#include <vcl/vclenum.hxx> + +class Window; + +// ------------- +// - Key-Types - +// ------------- + +// Logische KeyFunktionen +/* +#ifndef ENUM_KEYFUNCTYPE_DECLARED +#define ENUM_KEYFUNCTYPE_DECLARED +enum KeyFuncType { KEYFUNC_DONTKNOW, KEYFUNC_NEW, KEYFUNC_OPEN, + KEYFUNC_SAVE, KEYFUNC_SAVEAS, KEYFUNC_PRINT, + KEYFUNC_CLOSE, KEYFUNC_QUIT, + KEYFUNC_CUT, KEYFUNC_COPY, KEYFUNC_PASTE, KEYFUNC_UNDO, + KEYFUNC_REDO, KEYFUNC_DELETE, KEYFUNC_REPEAT, + KEYFUNC_FIND, KEYFUNC_FINDBACKWARD, KEYFUNC_PROPERTIES, + KEYFUNC_FRONT }; +#endif +*/ +// ----------- +// - KeyCode - +// ----------- + +class VCL_DLLPUBLIC KeyCode +{ +private: + sal_uInt16 nCode; + KeyFuncType eFunc; + +public: + KeyCode() { nCode = 0; eFunc = KEYFUNC_DONTKNOW; } + KeyCode( const ResId& rResId ); + KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 ) + { nCode = nKey | nModifier; eFunc = KEYFUNC_DONTKNOW; } + KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 ); + KeyCode( KeyFuncType eFunction ); + + sal_uInt16 GetFullCode() const { return nCode; } + sal_uInt16 GetFullKeyCode() const { return (nCode) ; } + KeyFuncType GetFullFunction() const { return eFunc; } + sal_Bool IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const; + + sal_uInt16 GetCode() const + { return (nCode & KEY_CODE); } + + sal_uInt16 GetModifier() const + { return (nCode & KEY_MODTYPE); } + sal_uInt16 GetAllModifier() const + { return (nCode & KEY_ALLMODTYPE); } + sal_Bool IsShift() const + { return ((nCode & KEY_SHIFT) != 0); } + sal_Bool IsMod1() const + { return ((nCode & KEY_MOD1) != 0); } + sal_Bool IsMod2() const + { return ((nCode & KEY_MOD2) != 0); } + sal_Bool IsMod3() const + { return ((nCode & KEY_MOD3) != 0); } + sal_uInt16 GetGroup() const + { return (nCode & KEYGROUP_TYPE); } + + XubString GetName( Window* pWindow = NULL ) const; + XubString GetSymbolName( const XubString& rFontName, Window* pWindow = NULL ) const; + + sal_Bool IsFunction() const + { return ((eFunc != KEYFUNC_DONTKNOW) ? sal_True : sal_False); } + + KeyFuncType GetFunction() const; + + KeyCode& operator = ( const KeyCode& rKeyCode ); + sal_Bool operator ==( const KeyCode& rKeyCode ) const; + sal_Bool operator !=( const KeyCode& rKeyCode ) const; +}; + +inline KeyCode::KeyCode( sal_uInt16 nKey, sal_Bool bShift, sal_Bool bMod1, sal_Bool bMod2, sal_Bool bMod3 ) +{ + nCode = nKey; + if( bShift ) + nCode |= KEY_SHIFT; + if( bMod1 ) + nCode |= KEY_MOD1; + if( bMod2 ) + nCode |= KEY_MOD2; + if( bMod3 ) + nCode |= KEY_MOD3; + eFunc = KEYFUNC_DONTKNOW; +} + +inline sal_Bool KeyCode::operator ==( const KeyCode& rKeyCode ) const +{ + if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) ) + return (nCode == rKeyCode.nCode); + else + return (GetFunction() == rKeyCode.GetFunction()); +} + +inline sal_Bool KeyCode::operator !=( const KeyCode& rKeyCode ) const +{ + if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) ) + return (nCode != rKeyCode.nCode); + else + return (GetFunction() != rKeyCode.GetFunction()); +} + +inline sal_Bool KeyCode::IsDefinedKeyCodeEqual( const KeyCode& rKeyCode ) const +{ + if ( (eFunc == KEYFUNC_DONTKNOW) && (rKeyCode.eFunc == KEYFUNC_DONTKNOW) ) + return (GetFullKeyCode() == rKeyCode.GetFullKeyCode()); + return (GetFunction() == rKeyCode.GetFunction()); +} + +inline KeyCode& KeyCode::operator = ( const KeyCode& rKeyCode ) +{ + nCode = rKeyCode.nCode; + eFunc = rKeyCode.eFunc; + + return *this; +} + +#endif // _SV_KEYCODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/keycodes.hxx b/vcl/inc/vcl/keycodes.hxx new file mode 100644 index 000000000000..9b4fc0893b34 --- /dev/null +++ b/vcl/inc/vcl/keycodes.hxx @@ -0,0 +1,209 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_KEYCODES_HXX +#define _SV_KEYCODES_HXX + +#include <vcl/sv.h> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> + +// ----------------- +// - KeyCode-Types - +// ----------------- + +// By changes you must also change: rsc/vclrsc.hxx + +// Key-Gruppen +#define KEYGROUP_NUM ((sal_uInt16)::com::sun::star::awt::KeyGroup::NUM) +#define KEYGROUP_ALPHA ((sal_uInt16)::com::sun::star::awt::KeyGroup::ALPHA) +#define KEYGROUP_FKEYS ((sal_uInt16)::com::sun::star::awt::KeyGroup::FKEYS) +#define KEYGROUP_CURSOR ((sal_uInt16)::com::sun::star::awt::KeyGroup::CURSOR) +#define KEYGROUP_MISC ((sal_uInt16)::com::sun::star::awt::KeyGroup::MISC) +#define KEYGROUP_TYPE ((sal_uInt16)::com::sun::star::awt::KeyGroup::TYPE) + +// Key-Codes +#define KEY_0 ((sal_uInt16)::com::sun::star::awt::Key::NUM0) +#define KEY_1 ((sal_uInt16)::com::sun::star::awt::Key::NUM1) +#define KEY_2 ((sal_uInt16)::com::sun::star::awt::Key::NUM2) +#define KEY_3 ((sal_uInt16)::com::sun::star::awt::Key::NUM3) +#define KEY_4 ((sal_uInt16)::com::sun::star::awt::Key::NUM4) +#define KEY_5 ((sal_uInt16)::com::sun::star::awt::Key::NUM5) +#define KEY_6 ((sal_uInt16)::com::sun::star::awt::Key::NUM6) +#define KEY_7 ((sal_uInt16)::com::sun::star::awt::Key::NUM7) +#define KEY_8 ((sal_uInt16)::com::sun::star::awt::Key::NUM8) +#define KEY_9 ((sal_uInt16)::com::sun::star::awt::Key::NUM9) + +#define KEY_A ((sal_uInt16)::com::sun::star::awt::Key::A) +#define KEY_B ((sal_uInt16)::com::sun::star::awt::Key::B) +#define KEY_C ((sal_uInt16)::com::sun::star::awt::Key::C) +#define KEY_D ((sal_uInt16)::com::sun::star::awt::Key::D) +#define KEY_E ((sal_uInt16)::com::sun::star::awt::Key::E) +#define KEY_F ((sal_uInt16)::com::sun::star::awt::Key::F) +#define KEY_G ((sal_uInt16)::com::sun::star::awt::Key::G) +#define KEY_H ((sal_uInt16)::com::sun::star::awt::Key::H) +#define KEY_I ((sal_uInt16)::com::sun::star::awt::Key::I) +#define KEY_J ((sal_uInt16)::com::sun::star::awt::Key::J) +#define KEY_K ((sal_uInt16)::com::sun::star::awt::Key::K) +#define KEY_L ((sal_uInt16)::com::sun::star::awt::Key::L) +#define KEY_M ((sal_uInt16)::com::sun::star::awt::Key::M) +#define KEY_N ((sal_uInt16)::com::sun::star::awt::Key::N) +#define KEY_O ((sal_uInt16)::com::sun::star::awt::Key::O) +#define KEY_P ((sal_uInt16)::com::sun::star::awt::Key::P) +#define KEY_Q ((sal_uInt16)::com::sun::star::awt::Key::Q) +#define KEY_R ((sal_uInt16)::com::sun::star::awt::Key::R) +#define KEY_S ((sal_uInt16)::com::sun::star::awt::Key::S) +#define KEY_T ((sal_uInt16)::com::sun::star::awt::Key::T) +#define KEY_U ((sal_uInt16)::com::sun::star::awt::Key::U) +#define KEY_V ((sal_uInt16)::com::sun::star::awt::Key::V) +#define KEY_W ((sal_uInt16)::com::sun::star::awt::Key::W) +#define KEY_X ((sal_uInt16)::com::sun::star::awt::Key::X) +#define KEY_Y ((sal_uInt16)::com::sun::star::awt::Key::Y) +#define KEY_Z ((sal_uInt16)::com::sun::star::awt::Key::Z) + +#define KEY_F1 ((sal_uInt16)::com::sun::star::awt::Key::F1) +#define KEY_F2 ((sal_uInt16)::com::sun::star::awt::Key::F2) +#define KEY_F3 ((sal_uInt16)::com::sun::star::awt::Key::F3) +#define KEY_F4 ((sal_uInt16)::com::sun::star::awt::Key::F4) +#define KEY_F5 ((sal_uInt16)::com::sun::star::awt::Key::F5) +#define KEY_F6 ((sal_uInt16)::com::sun::star::awt::Key::F6) +#define KEY_F7 ((sal_uInt16)::com::sun::star::awt::Key::F7) +#define KEY_F8 ((sal_uInt16)::com::sun::star::awt::Key::F8) +#define KEY_F9 ((sal_uInt16)::com::sun::star::awt::Key::F9) +#define KEY_F10 ((sal_uInt16)::com::sun::star::awt::Key::F10) +#define KEY_F11 ((sal_uInt16)::com::sun::star::awt::Key::F11) +#define KEY_F12 ((sal_uInt16)::com::sun::star::awt::Key::F12) +#define KEY_F13 ((sal_uInt16)::com::sun::star::awt::Key::F13) +#define KEY_F14 ((sal_uInt16)::com::sun::star::awt::Key::F14) +#define KEY_F15 ((sal_uInt16)::com::sun::star::awt::Key::F15) +#define KEY_F16 ((sal_uInt16)::com::sun::star::awt::Key::F16) +#define KEY_F17 ((sal_uInt16)::com::sun::star::awt::Key::F17) +#define KEY_F18 ((sal_uInt16)::com::sun::star::awt::Key::F18) +#define KEY_F19 ((sal_uInt16)::com::sun::star::awt::Key::F19) +#define KEY_F20 ((sal_uInt16)::com::sun::star::awt::Key::F20) +#define KEY_F21 ((sal_uInt16)::com::sun::star::awt::Key::F21) +#define KEY_F22 ((sal_uInt16)::com::sun::star::awt::Key::F22) +#define KEY_F23 ((sal_uInt16)::com::sun::star::awt::Key::F23) +#define KEY_F24 ((sal_uInt16)::com::sun::star::awt::Key::F24) +#define KEY_F25 ((sal_uInt16)::com::sun::star::awt::Key::F25) +#define KEY_F26 ((sal_uInt16)::com::sun::star::awt::Key::F26) + +#define KEY_DOWN ((sal_uInt16)::com::sun::star::awt::Key::DOWN) +#define KEY_UP ((sal_uInt16)::com::sun::star::awt::Key::UP) +#define KEY_LEFT ((sal_uInt16)::com::sun::star::awt::Key::LEFT) +#define KEY_RIGHT ((sal_uInt16)::com::sun::star::awt::Key::RIGHT) +#define KEY_HOME ((sal_uInt16)::com::sun::star::awt::Key::HOME) +#define KEY_END ((sal_uInt16)::com::sun::star::awt::Key::END) +#define KEY_PAGEUP ((sal_uInt16)::com::sun::star::awt::Key::PAGEUP) +#define KEY_PAGEDOWN ((sal_uInt16)::com::sun::star::awt::Key::PAGEDOWN) + +#define KEY_RETURN ((sal_uInt16)::com::sun::star::awt::Key::RETURN) +#define KEY_ESCAPE ((sal_uInt16)::com::sun::star::awt::Key::ESCAPE) +#define KEY_TAB ((sal_uInt16)::com::sun::star::awt::Key::TAB) +#define KEY_BACKSPACE ((sal_uInt16)::com::sun::star::awt::Key::BACKSPACE) +#define KEY_SPACE ((sal_uInt16)::com::sun::star::awt::Key::SPACE) +#define KEY_INSERT ((sal_uInt16)::com::sun::star::awt::Key::INSERT) +#define KEY_DELETE ((sal_uInt16)::com::sun::star::awt::Key::DELETE) + +#define KEY_ADD ((sal_uInt16)::com::sun::star::awt::Key::ADD) +#define KEY_SUBTRACT ((sal_uInt16)::com::sun::star::awt::Key::SUBTRACT) +#define KEY_MULTIPLY ((sal_uInt16)::com::sun::star::awt::Key::MULTIPLY) +#define KEY_DIVIDE ((sal_uInt16)::com::sun::star::awt::Key::DIVIDE) +#define KEY_POINT ((sal_uInt16)::com::sun::star::awt::Key::POINT) +#define KEY_COMMA ((sal_uInt16)::com::sun::star::awt::Key::COMMA) +#define KEY_LESS ((sal_uInt16)::com::sun::star::awt::Key::LESS) +#define KEY_GREATER ((sal_uInt16)::com::sun::star::awt::Key::GREATER) +#define KEY_EQUAL ((sal_uInt16)::com::sun::star::awt::Key::EQUAL) + +#define KEY_OPEN ((sal_uInt16)::com::sun::star::awt::Key::OPEN) +#define KEY_CUT ((sal_uInt16)::com::sun::star::awt::Key::CUT) +#define KEY_COPY ((sal_uInt16)::com::sun::star::awt::Key::COPY) +#define KEY_PASTE ((sal_uInt16)::com::sun::star::awt::Key::PASTE) +#define KEY_UNDO ((sal_uInt16)::com::sun::star::awt::Key::UNDO) +#define KEY_REPEAT ((sal_uInt16)::com::sun::star::awt::Key::REPEAT) +#define KEY_FIND ((sal_uInt16)::com::sun::star::awt::Key::FIND) +#define KEY_PROPERTIES ((sal_uInt16)::com::sun::star::awt::Key::PROPERTIES) +#define KEY_FRONT ((sal_uInt16)::com::sun::star::awt::Key::FRONT) +#define KEY_CONTEXTMENU ((sal_uInt16)::com::sun::star::awt::Key::CONTEXTMENU) +#define KEY_MENU ((sal_uInt16)::com::sun::star::awt::Key::MENU) +#define KEY_HELP ((sal_uInt16)::com::sun::star::awt::Key::HELP) +#define KEY_HANGUL_HANJA ((sal_uInt16)::com::sun::star::awt::Key::HANGUL_HANJA) +#define KEY_DECIMAL ((sal_uInt16)::com::sun::star::awt::Key::DECIMAL) +#define KEY_TILDE ((sal_uInt16)::com::sun::star::awt::Key::TILDE) +#define KEY_QUOTELEFT ((sal_uInt16)::com::sun::star::awt::Key::QUOTELEFT) +#define KEY_BRACKETLEFT ((sal_uInt16)::com::sun::star::awt::Key::BRACKETLEFT) +#define KEY_BRACKETRIGHT ((sal_uInt16)::com::sun::star::awt::Key::BRACKETRIGHT) +#define KEY_SEMICOLON ((sal_uInt16)::com::sun::star::awt::Key::SEMICOLON) + +#define KEY_CAPSLOCK ((sal_uInt16)::com::sun::star::awt::Key::CAPSLOCK) +#define KEY_NUMLOCK ((sal_uInt16)::com::sun::star::awt::Key::NUMLOCK) +#define KEY_SCROLLLOCK ((sal_uInt16)::com::sun::star::awt::Key::SCROLLLOCK) + +#define KEY_CODE ((sal_uInt16)0x0FFF) + +// Modifier-Tasten +#define KEY_SHIFT ((sal_uInt16)0x1000) +#define KEY_MOD1 ((sal_uInt16)0x2000) +#define KEY_MOD2 ((sal_uInt16)0x4000) +#define KEY_MOD3 ((sal_uInt16)0x8000) +#define KEY_MODTYPE ((sal_uInt16)0xF000) +#define KEY_ALLMODTYPE ((sal_uInt16)0xF000) + +// extended Modifier-Keys (only used for modkey events) +#define MODKEY_LSHIFT 0x0001 +#define MODKEY_RSHIFT 0x0002 +#define MODKEY_LMOD1 0x0004 +#define MODKEY_RMOD1 0x0008 +#define MODKEY_LMOD2 0x0010 +#define MODKEY_RMOD2 0x0020 +#define MODKEY_LMOD3 0x0040 +#define MODKEY_RMOD3 0x0080 +#define MODKEY_SHIFT (MODKEY_LSHIFT|MODKEY_RSHIFT) +#define MODKEY_MOD1 (MODKEY_LMOD1|MODKEY_RMOD1) +#define MODKEY_MOD2 (MODKEY_LMOD2|MODKEY_RMOD2) +#define MODKEY_MOD3 (MODKEY_LMOD3|MODKEY_RMOD3) + +// --------------- +// - Mouse-Types - +// --------------- + +#define MOUSE_LEFT ((sal_uInt16)0x0001) +#define MOUSE_MIDDLE ((sal_uInt16)0x0002) +#define MOUSE_RIGHT ((sal_uInt16)0x0004) + +// ------------------- +// - Indicator-Types - +// ------------------- + +#define INDICATOR_CAPSLOCK 0x0001 +#define INDICATOR_NUMLOCK 0x0002 +#define INDICATOR_SCROLLLOCK 0x0004 + +#endif // _SV_KEYCODES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/lazydelete.hxx b/vcl/inc/vcl/lazydelete.hxx new file mode 100644 index 000000000000..e7edee035e4d --- /dev/null +++ b/vcl/inc/vcl/lazydelete.hxx @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_LAZYDELETE_HXX +#define _VCL_LAZYDELETE_HXX + +#include "dllapi.h" + +#include <vector> +#include <boost/unordered_map.hpp> +#include <algorithm> + +#if OSL_DEBUG_LEVEL > 2 +#include <typeinfo> +#include <stdio.h> +#endif + +#include <com/sun/star/lang/XComponent.hpp> + +namespace vcl +{ + /* Helpers for lazy object deletion + + With vcl it is often necessary to delete objects (especially Windows) + in the right order as well as in a way ensuring that the deleted objects + are not still on the stack (e.g. deleting a Window in its key handler). To + make this easier a helper class is given here which takes care of both + sorting as well as lazy deletion. + + The grisly details: + LazyDelete is a class that LazyDeletor register to. When vcl's event + loop (that is Application::Yield or Application::Reschedule) comes out + of the last level, the LazyDelete::flush is called. This will cause + LazyDelete to delete all registered LazyDeletor objects. + + LazyDeletor<T> is a one instance object that contains a list of + <T> objects to be deleted in sorted order. It is derived from + LazyDeletorBase as to be able to register itself in LazyDelete. + + The user calls the static method LazyDeletor<T>::Delete( T* ) with the + object to be destroyed lazy. The static method creates the LazyDeletor<T> + (which in turn registers itself in LazyDelete) if this is the first time + a T* is to be destroyed lazy. It then inserts the object. When the LazyDeletor<T> + gets delte it will delete the stored objects in a fashion + that will ensure the correct order of deletion via the specialized is_less method + (e.g. if a Window is a child of another Window and therefore should be destroyed + first it is "less" in this sense) + + LazyDelete::flush will be called when the top of the nested event loop is + reached again and will then destroy each registered LazyDeletor<T> which + in turn destroys the objects needed to be destroyed lazily. After this + the state is as before entering the event loop. + + Preconditions: + - The class <T> of which objects are to be destroyed needs a virtual + destructor or must be final, else the wrong type will be destroyed. + - The destructor of <T> should call LazyDeletor<T>::Undelete( this ). This + prevents duplicate deletionin case someone destroys the object prematurely. + */ + + class LazyDeletorBase; + class VCL_DLLPUBLIC LazyDelete + { + public: + /** flush all registered object lists + */ + static void flush(); + /** register an object list to be destroyed + */ + static void addDeletor( LazyDeletorBase* pDeletor ); + }; + + class VCL_DLLPUBLIC LazyDeletorBase + { + friend void LazyDelete::flush(); + protected: + LazyDeletorBase(); + virtual ~LazyDeletorBase(); + }; + + template < typename T > + class VCL_DLLPUBLIC LazyDeletor : public LazyDeletorBase + { + static LazyDeletor< T >* s_pOneInstance; + + struct DeleteObjectEntry + { + T* m_pObject; + bool m_bDeleted; + + DeleteObjectEntry() : + m_pObject( NULL ), + m_bDeleted( false ) + {} + + DeleteObjectEntry( T* i_pObject ) : + m_pObject( i_pObject ), + m_bDeleted( false ) + {} + }; + + std::vector< DeleteObjectEntry > m_aObjects; + typedef boost::unordered_map< sal_IntPtr, unsigned int > PtrToIndexMap; + PtrToIndexMap m_aPtrToIndex; + + /** strict weak ordering funtion to bring objects to be destroyed lazily + in correct order, e.g. for Window objects children before parents + */ + static bool is_less( T* left, T* right ); + + LazyDeletor() { LazyDelete::addDeletor( this ); } + virtual ~LazyDeletor() + { + #if OSL_DEBUG_LEVEL > 2 + fprintf( stderr, "%s %p deleted\n", + typeid(*this).name(), this ); + #endif + if( s_pOneInstance == this ) // sanity check + s_pOneInstance = NULL; + + // do the actual work + unsigned int nCount = m_aObjects.size(); + std::vector<T*> aRealDelete; + aRealDelete.reserve( nCount ); + for( unsigned int i = 0; i < nCount; i++ ) + { + if( ! m_aObjects[i].m_bDeleted ) + { + aRealDelete.push_back( m_aObjects[i].m_pObject ); + } + } + // sort the vector of objects to be destroyed + std::sort( aRealDelete.begin(), aRealDelete.end(), is_less ); + nCount = aRealDelete.size(); + for( unsigned int n = 0; n < nCount; n++ ) + { + #if OSL_DEBUG_LEVEL > 2 + fprintf( stderr, "%s deletes object %p of type %s\n", + typeid(*this).name(), + aRealDelete[n], + typeid(*aRealDelete[n]).name() ); + #endif + // check if the object to be deleted is not already destroyed + // as a side effect of a previous lazily destroyed object + if( ! m_aObjects[ m_aPtrToIndex[ reinterpret_cast<sal_IntPtr>(aRealDelete[n]) ] ].m_bDeleted ) + delete aRealDelete[n]; + } + } + + public: + /** mark an object for lazy deletion + */ + static void Delete( T* i_pObject ) + { + if( s_pOneInstance == NULL ) + s_pOneInstance = new LazyDeletor<T>(); + + // is this object already in the list ? + // if so mark it as not to be deleted; else insert it + PtrToIndexMap::const_iterator dup = s_pOneInstance->m_aPtrToIndex.find( reinterpret_cast<sal_IntPtr>(i_pObject) ); + if( dup != s_pOneInstance->m_aPtrToIndex.end() ) + { + s_pOneInstance->m_aObjects[ dup->second ].m_bDeleted = false; + } + else + { + s_pOneInstance->m_aPtrToIndex[ reinterpret_cast<sal_IntPtr>(i_pObject) ] = s_pOneInstance->m_aObjects.size(); + s_pOneInstance->m_aObjects.push_back( DeleteObjectEntry( i_pObject ) ); + } + } + /** unmark an object already marked for lazy deletion + */ + static void Undelete( T* i_pObject ) + { + if( s_pOneInstance ) + { + PtrToIndexMap::const_iterator it = s_pOneInstance->m_aPtrToIndex.find( reinterpret_cast<sal_IntPtr>(i_pObject) ); + if( it != s_pOneInstance->m_aPtrToIndex.end() ) + s_pOneInstance->m_aObjects[ it->second ].m_bDeleted = true; + } + } + }; + + /* + class DeleteOnDeinit matches a similar need as LazyDelete for static objects: + you may not access vcl objects after DeInitVCL has been called this includes their destruction + therefore disallowing the existance of static vcl object like e.g. a static BitmapEx + To work around this use DeleteOnDeinit<BitmapEx> which will allow you to have a static object container, + that will have its contents destroyed on DeinitVCL. The single drawback is that you need to check on the + container object whether it still contains content before actually accessing it. + + caveat: when constructing a vcl object, you certainly want to ensure that InitVCL has run already. + However this is not necessarily the case when using a class static member or a file level static variable. + In these cases make judicious use of the set() method of DeleteOnDeinit, but beware of the changing + ownership. + + example use case: use a lazy initialized on call BitmapEx in a paint method. Of course a paint method + would not normally be called after DeInitVCL anyway, so the check might not be necessary in a + Window::Paint implementation, but always checking is a good idea. + + SomeWindow::Paint() + { + static vcl::DeleteOnDeinit< BitmapEx > aBmp( new BitmapEx( ResId( 1000, myResMgr ) ) ); + + if( aBmp.get() ) // check whether DeInitVCL has been called already + DrawBitmapEx( Point( 10, 10 ), *aBmp.get() ); + } + */ + + class VCL_DLLPUBLIC DeleteOnDeinitBase + { + public: + static void SAL_DLLPRIVATE ImplDeleteOnDeInit(); + virtual ~DeleteOnDeinitBase(); + protected: + static void addDeinitContainer( DeleteOnDeinitBase* i_pContainer ); + + virtual void doCleanup() = 0; + }; + + template < typename T > + class DeleteOnDeinit : public DeleteOnDeinitBase + { + T* m_pT; + virtual void doCleanup() { delete m_pT; m_pT = NULL; } + public: + DeleteOnDeinit( T* i_pT ) : m_pT( i_pT ) { addDeinitContainer( this ); } + virtual ~DeleteOnDeinit() {} + + // get contents + T* get() { return m_pT; } + + // set contents, returning old contents + // ownership is transfered ! + T* set( T* i_pNew ) { T* pOld = m_pT; m_pT = i_pNew; return pOld; } + }; + + /** Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit + template class makes sure that a static UNO object is disposed + and released at the right time. + + Use like + static DeleteUnoReferenceOnDeinit<lang::XMultiServiceFactory> + xStaticFactory (<create factory object>); + Reference<lang::XMultiServiceFactory> xFactory (xStaticFactory.get()); + if (xFactory.is()) + <do something with xFactory> + */ + template <typename I> + class DeleteUnoReferenceOnDeinit : public ::vcl::DeleteOnDeinitBase + { + ::com::sun::star::uno::Reference<I> m_xI; + virtual void doCleanup() { set(NULL); } + public: + DeleteUnoReferenceOnDeinit(const ::com::sun::star::uno::Reference<I>& r_xI ) : m_xI( r_xI ) { + addDeinitContainer( this ); } + virtual ~DeleteUnoReferenceOnDeinit() {} + + ::com::sun::star::uno::Reference<I> get (void) { return m_xI; } + + void set (const ::com::sun::star::uno::Reference<I>& r_xNew ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xComponent (m_xI, ::com::sun::star::uno::UNO_QUERY); + m_xI = r_xNew; + if (xComponent.is()) try + { + xComponent->dispose(); + } + catch( ::com::sun::star::uno::Exception& ) + { + } + } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/lineinfo.hxx b/vcl/inc/vcl/lineinfo.hxx new file mode 100644 index 000000000000..046257cbdd9f --- /dev/null +++ b/vcl/inc/vcl/lineinfo.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_LINEINFO_HXX +#define _SV_LINEINFO_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/vclenum.hxx> +#include <basegfx/vector/b2enums.hxx> + +// ---------------- +// - ImplLineInfo - +// ---------------- + +class SvStream; +namespace basegfx { class B2DPolyPolygon; } + +struct ImplLineInfo +{ + sal_uLong mnRefCount; + LineStyle meStyle; + long mnWidth; + sal_uInt16 mnDashCount; + long mnDashLen; + sal_uInt16 mnDotCount; + long mnDotLen; + long mnDistance; + + basegfx::B2DLineJoin meLineJoin; + + ImplLineInfo(); + ImplLineInfo( const ImplLineInfo& rImplLineInfo ); + + bool operator==( const ImplLineInfo& ) const; + + friend SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo ); + friend SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo ); +}; + +// ------------ +// - LineInfo - +// ------------ + +class VCL_DLLPUBLIC LineInfo +{ +private: + + ImplLineInfo* mpImplLineInfo; + long n1; + long n2; + long n3; + + SAL_DLLPRIVATE void ImplMakeUnique(); + +public: + + LineInfo( LineStyle eLineStyle = LINE_SOLID, long nWidth = 0L ); + LineInfo( const LineInfo& rLineInfo ); + ~LineInfo(); + + LineInfo& operator=( const LineInfo& rLineInfo ); + sal_Bool operator==( const LineInfo& rLineInfo ) const; + sal_Bool operator!=( const LineInfo& rLineInfo ) const { return !(LineInfo::operator==( rLineInfo ) ); } + sal_Bool IsSameInstance( const LineInfo& rLineInfo ) const { return( mpImplLineInfo == rLineInfo.mpImplLineInfo ); } + + void SetStyle( LineStyle eStyle ); + LineStyle GetStyle() const { return mpImplLineInfo->meStyle; } + + void SetWidth( long nWidth ); + long GetWidth() const { return mpImplLineInfo->mnWidth; } + + void SetDashCount( sal_uInt16 nDashCount ); + sal_uInt16 GetDashCount() const { return mpImplLineInfo->mnDashCount; } + + void SetDashLen( long nDashLen ); + long GetDashLen() const { return mpImplLineInfo->mnDashLen; } + + void SetDotCount( sal_uInt16 nDotCount ); + sal_uInt16 GetDotCount() const { return mpImplLineInfo->mnDotCount; } + + void SetDotLen( long nDotLen ); + long GetDotLen() const { return mpImplLineInfo->mnDotLen; } + + void SetDistance( long nDistance ); + long GetDistance() const { return mpImplLineInfo->mnDistance; } + + void SetLineJoin(basegfx::B2DLineJoin eLineJoin); + basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; } + + sal_Bool IsDefault() const { return( !mpImplLineInfo->mnWidth && ( LINE_SOLID == mpImplLineInfo->meStyle ) ); } + + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/longcurr.hxx b/vcl/inc/vcl/longcurr.hxx new file mode 100644 index 000000000000..ca4ebcadc77e --- /dev/null +++ b/vcl/inc/vcl/longcurr.hxx @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _LONGCURR_HXX +#define _LONGCURR_HXX + +#include <vcl/dllapi.h> +#include <tools/bigint.hxx> +#include <vcl/field.hxx> + +class LocaleDataWrapper; + +// ------------------------- +// - LongCurrencyFormatter - +// ------------------------- + +class VCL_DLLPUBLIC LongCurrencyFormatter : public FormatterBase +{ +private: + SAL_DLLPRIVATE friend sal_Bool ImplLongCurrencyReformat( const XubString&, BigInt, BigInt, sal_uInt16, const LocaleDataWrapper&, XubString&, LongCurrencyFormatter& ); + SAL_DLLPRIVATE void ImpInit(); + +protected: + BigInt mnFieldValue; + BigInt mnLastValue; + BigInt mnMin; + BigInt mnMax; + BigInt mnCorrectedValue; + String maCurrencySymbol; + sal_uInt16 mnType; + sal_uInt16 mnDecimalDigits; + sal_Bool mbThousandSep; + + LongCurrencyFormatter(); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + ~LongCurrencyFormatter(); + + virtual void Reformat(); + virtual void ReformatAll(); + + void SetUseThousandSep( sal_Bool b ); + sal_Bool IsUseThousandSep() const { return mbThousandSep; } + + void SetCurrencySymbol( const String& rStr ); + String GetCurrencySymbol() const; + + void SetMin( BigInt nNewMin ); + BigInt GetMin() const { return mnMin; } + void SetMax( BigInt nNewMax ); + BigInt GetMax() const { return mnMax; } + + void SetDecimalDigits( sal_uInt16 nDigits ); + sal_uInt16 GetDecimalDigits() const; + void SetValue( BigInt nNewValue ); + void SetUserValue( BigInt nNewValue ); + BigInt GetValue() const; + sal_Bool IsValueModified() const; + + void SetEmptyValue(); + sal_Bool IsEmptyValue() const { return !GetField()->GetText().Len(); } + + BigInt GetCorrectedValue() const { return mnCorrectedValue; } + + BigInt Normalize( BigInt nValue ) const; + BigInt Denormalize( BigInt nValue ) const; +}; + +// --------------------- +// - LongCurrencyField - +// --------------------- + +class VCL_DLLPUBLIC LongCurrencyField : public SpinField, public LongCurrencyFormatter +{ + friend void ImplNewLongCurrencyFieldValue( LongCurrencyField*, BigInt ); + +private: + BigInt mnSpinSize; + BigInt mnFirst; + BigInt mnLast; + +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + LongCurrencyField( Window* pParent, WinBits nWinStyle ); + LongCurrencyField( Window* pParent, const ResId& rResId ); + ~LongCurrencyField(); + + long PreNotify( NotifyEvent& rNEvt ); + long Notify( NotifyEvent& rNEvt ); + + void Modify(); + void Up(); + void Down(); + void First(); + void Last(); + + void SetFirst( BigInt nNewFirst ) { mnFirst = nNewFirst; } + BigInt GetFirst() const { return mnFirst; } + void SetLast( BigInt nNewLast ) { mnLast = nNewLast; } + BigInt GetLast() const { return mnLast; } + void SetSpinSize( BigInt nNewSize ) { mnSpinSize = nNewSize; } + BigInt GetSpinSize() const { return mnSpinSize; } +}; + +// ------------------- +// - LongCurrencyBox - +// ------------------- + +class VCL_DLLPUBLIC LongCurrencyBox : public ComboBox, public LongCurrencyFormatter +{ +public: + LongCurrencyBox( Window* pParent, WinBits nWinStyle ); + LongCurrencyBox( Window* pParent, const ResId& rResId ); + ~LongCurrencyBox(); + + long PreNotify( NotifyEvent& rNEvt ); + long Notify( NotifyEvent& rNEvt ); + + void Modify(); + void ReformatAll(); + + void InsertValue( BigInt nValue, + sal_uInt16 nPos = COMBOBOX_APPEND ); + void RemoveValue( BigInt nValue ); + BigInt GetValue() const + { return LongCurrencyFormatter::GetValue(); } + BigInt GetValue( sal_uInt16 nPos ) const; + sal_uInt16 GetValuePos( BigInt nValue ) const; +}; + +#endif // _LONGCURR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/lstbox.h b/vcl/inc/vcl/lstbox.h new file mode 100644 index 000000000000..f4577dc1e718 --- /dev/null +++ b/vcl/inc/vcl/lstbox.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_LSTBOX_H +#define _SV_LSTBOX_H + +#define LISTBOX_APPEND ((sal_uInt16)0xFFFF) +#define LISTBOX_ENTRY_NOTFOUND ((sal_uInt16)0xFFFF) +#define LISTBOX_ERROR ((sal_uInt16)0xFFFF) + +#define LISTBOX_USERDRAW_SELECTED ((sal_uInt16)0x0001) + +// -------------------------------------------------------------------- + +// the following defines can be used for the SetEntryFlags() +// and GetEntryFlags() methods + +// !! Do not use these flags for user data as they are reserved !! +// !! to change the internal behaviour of the ListBox implementation !! +// !! for specific entries. !! + +/** this flag disables a selection of an entry completly. It is not + possible to select such entries either from the user interface + nor from the ListBox methods. Cursor traveling is handled correctly. + This flag can be used to add titles to a ListBox. +*/ +#define LISTBOX_ENTRY_FLAG_DISABLE_SELECTION 0x0000001 + +/** this flag can be used to make an entry multine capable + A normal entry is single line and will therefore be clipped + at the right listbox border. Setting this flag enables + word breaks for the entry text. +*/ +#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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/lstbox.hxx b/vcl/inc/vcl/lstbox.hxx new file mode 100644 index 000000000000..cc1d0615cb7b --- /dev/null +++ b/vcl/inc/vcl/lstbox.hxx @@ -0,0 +1,267 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_LSTBOX_HXX +#define _SV_LSTBOX_HXX + +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/lstbox.h> + +class Image; +class ImplListBox; +class ImplListBoxFloatingWindow; +class ImplBtn; +class ImplWin; + +// -------------------------------------------------------------------- +// - ListBox - +// -------------------------------------------------------------------- + +class VCL_DLLPUBLIC ListBox : public Control +{ +private: + ImplListBox* mpImplLB; + ImplListBoxFloatingWindow* mpFloatWin; + ImplWin* mpImplWin; + ImplBtn* mpBtn; + sal_uInt16 mnDDHeight; + sal_uInt16 mnSaveValue; + sal_Bool mbDDAutoSize; + Link maSelectHdl; + Link maDoubleClickHdl; + sal_uInt16 mnLineCount; + +private: + SAL_DLLPRIVATE void ImplInitListBoxData(); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplScrollHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplCancelHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplUserDrawHdl, UserDrawEvent* ); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + sal_Bool IsDropDownBox() const { return mpFloatWin ? sal_True : sal_False; } + +protected: + ListBox( WindowType nType ); + + virtual void FillLayoutData() const; + +public: + ListBox( Window* pParent, WinBits nStyle = WB_BORDER ); + ListBox( Window* pParent, const ResId& rResId ); + ~ListBox(); + + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + + virtual void Select(); + virtual void DoubleClick(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual Window* GetPreferredKeyInputWindow(); + + virtual const Wallpaper& GetDisplayBackground() const; + + virtual void SetPosSizePixel( long nX, long nY, + long nWidth, long nHeight, sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + void SetPosSizePixel( const Point& rNewPos, const Size& rNewSize ) + { Control::SetPosSizePixel( rNewPos, rNewSize ); } + void SetDropDownSizePixel( const Size& rNewSize ) + { if( IsDropDownBox() ) SetPosSizePixel( 0, 0, rNewSize.Width(), rNewSize.Height(), WINDOW_POSSIZE_SIZE | WINDOW_POSSIZE_DROPDOWN ); } + + Rectangle GetDropDownPosSizePixel() const; + + void SetDropDownLineCount( sal_uInt16 nLines ); + sal_uInt16 GetDropDownLineCount() const; + + void EnableAutoSize( sal_Bool bAuto ); + sal_Bool IsAutoSizeEnabled() const { return mbDDAutoSize; } + + void EnableDDAutoWidth( sal_Bool b ); + sal_Bool IsDDAutoWidthEnabled() const; + + virtual sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND ); + virtual sal_uInt16 InsertEntry( const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND ); + virtual sal_uInt16 InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos = LISTBOX_APPEND ); + virtual void RemoveEntry( const XubString& rStr ); + virtual void RemoveEntry( sal_uInt16 nPos ); + + virtual void Clear(); + + virtual sal_uInt16 GetEntryPos( const XubString& rStr ) const; + virtual sal_uInt16 GetEntryPos( const void* pData ) const; + Image GetEntryImage( sal_uInt16 nPos ) const; + virtual XubString GetEntry( sal_uInt16 nPos ) const; + virtual sal_uInt16 GetEntryCount() const; + + virtual void SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True ); + virtual void SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect = sal_True ); + + virtual sal_uInt16 GetSelectEntryCount() const; + virtual XubString GetSelectEntry( sal_uInt16 nSelIndex = 0 ) const; + virtual sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex = 0 ) const; + + virtual sal_Bool IsEntrySelected( const XubString& rStr ) const; + virtual sal_Bool IsEntryPosSelected( sal_uInt16 nPos ) const; + virtual void SetNoSelection(); + + void SetEntryData( sal_uInt16 nPos, void* pNewData ); + void* GetEntryData( sal_uInt16 nPos ) const; + + /** this methods stores a combination of flags from the + LISTBOX_ENTRY_FLAG_* defines at the given entry. + See description of the possible LISTBOX_ENTRY_FLAG_* flags + for details. + Do not use these flags for user data as they are reserved + to change the internal behaviour of the ListBox implementation + for specific entries. + */ + void SetEntryFlags( sal_uInt16 nPos, long nFlags ); + + /** this methods gets the current combination of flags from the + LISTBOX_ENTRY_FLAG_* defines from the given entry. + See description of the possible LISTBOX_ENTRY_FLAG_* flags + for details. + */ + long GetEntryFlags( sal_uInt16 nPos ) const; + + void SetTopEntry( sal_uInt16 nPos ); + void ShowProminentEntry( sal_uInt16 nPos ); + void SetTopEntryStr( const XubString& rStr ); + sal_uInt16 GetTopEntry() const; + + void SetProminentEntryType( ProminentEntry eType ); + ProminentEntry GetProminentEntryType() const; + + void SaveValue() { mnSaveValue = GetSelectEntryPos(); } + sal_uInt16 GetSavedValue() const { return mnSaveValue; } + + void SetSeparatorPos( sal_uInt16 n ); + void SetSeparatorPos(); + sal_uInt16 GetSeparatorPos() const; + + sal_Bool IsTravelSelect() const; + sal_Bool IsInDropDown() const; + void ToggleDropDown(); + + void EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackSelection ); + void EnableMultiSelection( sal_Bool bMulti ); + sal_Bool IsMultiSelectionEnabled() const; + + void SetReadOnly( sal_Bool bReadOnly = sal_True ); + sal_Bool IsReadOnly() const; + + long CalcWindowSizePixel( sal_uInt16 nLines ) const; + Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; + + void SetUserItemSize( const Size& rSz ); + const Size& GetUserItemSize() const; + + void EnableUserDraw( sal_Bool bUserDraw ); + sal_Bool IsUserDrawEnabled() const; + + void DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos = sal_False ); + + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } + void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } + const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } + + Size CalcMinimumSize() const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + Size CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void SetMRUEntries( const XubString& rEntries, xub_Unicode cSep = ';' ); + XubString GetMRUEntries( xub_Unicode cSep = ';' ) const; + void SetMaxMRUCount( sal_uInt16 n ); + sal_uInt16 GetMaxMRUCount() const; + + sal_uInt16 GetDisplayLineCount() const; + + void EnableMirroring(); + + /** checks whether a certain point lies within the bounds of + a listbox item and returns the item as well as the character position + the point is at. + + <p>If the point is inside an item the item pos is put into <code>rPos</code> and + the item-relative character index is returned. If the point is not inside + an item -1 is returned and rPos is unchanged.</p> + + @param rPoint + tells the point for which an item is requested. + + @param rPos + gets the item at the specified point <code>rPoint</code> + + @returns + the item-relative character index at point <code>rPos</code> or -1 + if no item is at that point. + */ + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const; +}; + +// ---------------- +// - MultiListBox - +// ---------------- + +class VCL_DLLPUBLIC MultiListBox : public ListBox +{ +public: + using ListBox::SaveValue; + using ListBox::GetSavedValue; +private: + // Bei MultiListBox nicht erlaubt... + void SaveValue(); + sal_uInt16 GetSavedValue(); + +public: + MultiListBox( Window* pParent, WinBits nStyle = 0 ); + MultiListBox( Window* pParent, const ResId& rResId ); +}; + +#endif // _SV_LSTBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/mapmod.hxx b/vcl/inc/vcl/mapmod.hxx new file mode 100644 index 000000000000..bf666bc782cb --- /dev/null +++ b/vcl/inc/vcl/mapmod.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MAPMOD_HXX +#define _SV_MAPMOD_HXX + +#include <tools/gen.hxx> +#include <tools/fract.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/resid.hxx> +#include <tools/mapunit.hxx> + +class SvStream; + +// -------------- +// - ImplMapMode - +// -------------- + +class OutputDevice; + +class ImplMapMode +{ + friend class MapMode; + friend class OutputDevice; + +private: + sal_uLong mnRefCount; + MapUnit meUnit; + Point maOrigin; + Fraction maScaleX; + Fraction maScaleY; + sal_Bool mbSimple; + + friend SvStream& operator>>( SvStream& rIStm, ImplMapMode& rMapMode ); + friend SvStream& operator<<( SvStream& rOStm, const ImplMapMode& rMapMode ); + + static ImplMapMode* ImplGetStaticMapMode( MapUnit eUnit ); +public: + ImplMapMode(); + ImplMapMode( const ImplMapMode& rImpMapMode ); +}; + +// ----------- +// - MapMode - +// ----------- + +class VCL_DLLPUBLIC MapMode +{ + friend class OutputDevice; + +private: + ImplMapMode* mpImplMapMode; + + SAL_DLLPRIVATE void ImplMakeUnique(); + +public: + MapMode(); + MapMode( const MapMode& rMapMode ); + MapMode( MapUnit eUnit ); + MapMode( MapUnit eUnit, const Point& rLogicOrg, + const Fraction& rScaleX, const Fraction& rScaleY ); + ~MapMode(); + + void SetMapUnit( MapUnit eUnit ); + MapUnit GetMapUnit() const + { return mpImplMapMode->meUnit; } + + void SetOrigin( const Point& rOrigin ); + const Point& GetOrigin() const + { return mpImplMapMode->maOrigin; } + + void SetScaleX( const Fraction& rScaleX ); + const Fraction& GetScaleX() const + { return mpImplMapMode->maScaleX; } + void SetScaleY( const Fraction& rScaleY ); + const Fraction& GetScaleY() const + { return mpImplMapMode->maScaleY; } + + MapMode& operator=( const MapMode& rMapMode ); + sal_Bool operator==( const MapMode& rMapMode ) const; + sal_Bool operator!=( const MapMode& rMapMode ) const + { return !(MapMode::operator==( rMapMode )); } + sal_Bool IsDefault() const; + sal_Bool IsSameInstance( const MapMode& rMapMode ) const + { return (mpImplMapMode == rMapMode.mpImplMapMode); } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, MapMode& rMapMode ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const MapMode& rMapMode ); +}; + +#endif // _SV_MAPMOD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/menu.hxx b/vcl/inc/vcl/menu.hxx new file mode 100644 index 000000000000..2712cefbb5d8 --- /dev/null +++ b/vcl/inc/vcl/menu.hxx @@ -0,0 +1,534 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MENU_HXX +#define _SV_MENU_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/rc.hxx> +#include <tools/resid.hxx> +#include <vcl/bitmapex.hxx> +#include <tools/color.hxx> +#include <vcl/vclevent.hxx> +#include <com/sun/star/uno/Reference.hxx> + +struct MenuItemData; +class Point; +class Size; +class Rectangle; +class Menu; +class MenuItemList; +class HelpEvent; +class Image; +class PopupMenu; +class KeyCode; +class KeyEvent; +class AppBarWindow; +class MenuFloatingWindow; +class Window; +class SalMenu; +struct SystemMenuData; + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + class XAccessible; +}}}} + +namespace vcl { struct MenuLayoutData; } + +// -------------- +// - Menu-Types - +// -------------- + +#define MENU_APPEND ((sal_uInt16)0xFFFF) +#define MENU_ITEM_NOTFOUND ((sal_uInt16)0xFFFF) + +#define POPUPMENU_EXECUTE_DOWN ((sal_uInt16)0x0001) +#define POPUPMENU_EXECUTE_UP ((sal_uInt16)0x0002) +#define POPUPMENU_EXECUTE_LEFT ((sal_uInt16)0x0004) +#define POPUPMENU_EXECUTE_RIGHT ((sal_uInt16)0x0008) + +#define POPUPMENU_NOMOUSEUPCLOSE ((sal_uInt16)0x0010) + +// By changes you must also change: rsc/vclrsc.hxx +enum MenuItemType { MENUITEM_DONTKNOW, MENUITEM_STRING, MENUITEM_IMAGE, + MENUITEM_STRINGIMAGE, MENUITEM_SEPARATOR }; + +// By changes you must also change: rsc/vclrsc.hxx +typedef sal_uInt16 MenuItemBits; +#define MIB_CHECKABLE ((MenuItemBits)0x0001) +#define MIB_RADIOCHECK ((MenuItemBits)0x0002) +#define MIB_AUTOCHECK ((MenuItemBits)0x0004) +#define MIB_ABOUT ((MenuItemBits)0x0008) +#define MIB_HELP ((MenuItemBits)0x0010) +#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 + +// overrides default hiding of disabled entries in popup menus +#define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004 + +// forces images & toggle visibility for toolbar config popup +#define MENU_FLAG_SHOWCHECKIMAGES 0x0008 + +struct ImplMenuDelData +{ + ImplMenuDelData* mpNext; + const Menu* mpMenu; + + ImplMenuDelData( const Menu* pMenu ); + ~ImplMenuDelData(); + + bool isDeleted() const { return mpMenu == 0; } +}; + +// -------- +// - Menu - +// -------- + +struct MenuLogo +{ + BitmapEx aBitmap; + Color aStartColor; + Color aEndColor; +}; + +class VCL_DLLPUBLIC Menu : public Resource +{ + friend class MenuBar; + friend class MenuBarWindow; + friend class MenuFloatingWindow; + friend class PopupMenu; + friend class SystemWindow; + friend struct ImplMenuDelData; +private: + ImplMenuDelData* mpFirstDel; + MenuItemList* pItemList; // Liste mit den MenuItems + MenuLogo* pLogo; + Menu* pStartedFrom; + Window* pWindow; + + Link aActivateHdl; // Active-Handler + Link aDeactivateHdl; // Deactivate-Handler + Link aHighlightHdl; // Highlight-Handler + Link aSelectHdl; // Highlight-Handler + + VclEventListeners maEventListeners; + VclEventListeners maChildEventListeners; + + XubString aTitleText; // PopupMenu-Text + + sal_uLong nEventId; + sal_uInt16 mnHighlightedItemPos; // for native menues: keeps track of the highlighted item + sal_uInt16 nMenuFlags; + sal_uInt16 nDefaultItem; // Id vom Default-Item + sal_uInt16 nSelectedId; + + // Fuer Ausgabe: + sal_uInt16 nCheckPos; + sal_uInt16 nImagePos; + sal_uInt16 nTextPos; + + sal_Bool bIsMenuBar : 1, // Handelt es sich um den MenuBar + bCanceled : 1, // Waehrend eines Callbacks abgebrochen + bInCallback : 1, // In Activate/Deactivate + bKilled : 1; // Gekillt... + + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible; + mutable vcl::MenuLayoutData* mpLayoutData; + SalMenu* mpSalMenu; + +protected: + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE Menu* ImplGetStartMenu(); + SAL_DLLPRIVATE Menu* ImplFindSelectMenu(); + SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId ); + SAL_DLLPRIVATE Size ImplCalcSize( Window* pWin ); + SAL_DLLPRIVATE sal_Bool ImplIsVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_Bool ImplIsSelectable( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE void ImplPaint( Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, sal_Bool bHighlighted = sal_False, bool bLayout = false ) const; + SAL_DLLPRIVATE void ImplSelect(); + SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); + SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ); + DECL_DLLPRIVATE_LINK( ImplCallSelect, Menu* ); + + SAL_DLLPRIVATE void ImplFillLayoutData() const; + SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; } + SAL_DLLPRIVATE void ImplSetSalMenu( SalMenu *pMenu ); + SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const; + + // returns native check and option menu symbol height; + // return value is Max( rCheckHeight, rRadioHeight ) + SAL_DLLPRIVATE long ImplGetNativeCheckAndRadioSize( Window*, long& rCheckHeight, long& rRadioHeight, long &rMaxWidth ) const; + + SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); + SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); +public: + SAL_DLLPRIVATE void ImplKillLayoutData() const; + SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const; + + Menu(); + Menu( sal_Bool bMenuBar ); + SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; } + + + SAL_DLLPRIVATE void ImplSelectWithStart( Menu* pStartMenu = NULL ); +public: + virtual ~Menu(); + + virtual void Activate(); + virtual void Deactivate(); + virtual void Highlight(); + virtual void Select(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + + void InsertItem( sal_uInt16 nItemId, const XubString& rStr, + MenuItemBits nItemBits = 0, + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + MenuItemBits nItemBits = 0, + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( sal_uInt16 nItemId, + const XubString& rString, const Image& rImage, + MenuItemBits nItemBits = 0, + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( const ResId& rResId, sal_uInt16 nPos = MENU_APPEND ); + void InsertSeparator( sal_uInt16 nPos = MENU_APPEND ); + void RemoveItem( sal_uInt16 nPos ); + void CopyItem( const Menu& rMenu, sal_uInt16 nPos, + sal_uInt16 nNewPos = MENU_APPEND ); + void Clear(); + + void CreateAutoMnemonics(); + + void SetMenuFlags( sal_uInt16 nFlags ) { nMenuFlags = nFlags; } + sal_uInt16 GetMenuFlags() const { return nMenuFlags; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + MenuItemType GetItemType( sal_uInt16 nPos ) const; + sal_uInt16 GetCurItemId() const; + + void SetDefaultItem( sal_uInt16 nItemId ) { nDefaultItem = nItemId; } + sal_uInt16 GetDefaultItem() const { return nDefaultItem; } + + void SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits ); + MenuItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetUserValue( sal_uInt16 nItemId, sal_uLong nValue ); + sal_uLong GetUserValue( sal_uInt16 nItemId ) const; + + void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ); + PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const; + + void SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode ); + KeyCode GetAccelKey( sal_uInt16 nItemId ) const; + + void CheckItem( sal_uInt16 nItemId, sal_Bool bCheck = sal_True ); + sal_Bool IsItemChecked( sal_uInt16 nItemId ) const; + + void SelectItem( sal_uInt16 nItemId ); + void DeSelect() { SelectItem( 0xFFFF ); } // MENUITEMPOS_INVALID + + void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True ); + sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const; + + void ShowItem( sal_uInt16 nItemId, sal_Bool bVisible = sal_True ); + void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); } + + sal_Bool IsItemVisible( sal_uInt16 nItemId ) const; + sal_Bool IsItemPosVisible( sal_uInt16 nItemPos ) const; + sal_Bool IsMenuVisible() const; + sal_Bool IsMenuBar() const { return bIsMenuBar; } + + void RemoveDisabledEntries( sal_Bool bCheckPopups = sal_True, sal_Bool bRemoveEmptyPopups = sal_False ); + sal_Bool HasValidEntries( sal_Bool bCheckPopups = sal_True ); + + void SetItemText( sal_uInt16 nItemId, const XubString& rStr ); + XubString GetItemText( sal_uInt16 nItemId ) const; + + void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemImage( sal_uInt16 nItemId ) const; + void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); + long GetItemImageAngle( sal_uInt16 nItemId ) const; + void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror ); + sal_Bool GetItemImageMirrorMode( sal_uInt16 ) const; + + void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand ); + const XubString& GetItemCommand( sal_uInt16 nItemId ) const; + + void SetHelpText( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetHelpText( sal_uInt16 nItemId ) const; + + void SetTipHelpText( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetTipHelpText( sal_uInt16 nItemId ) const; + + void SetHelpCommand( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetHelpCommand( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ); + rtl::OString GetHelpId( sal_uInt16 nItemId ) const; + + void SetActivateHdl( const Link& rLink ) { aActivateHdl = rLink; } + const Link& GetActivateHdl() const { return aActivateHdl; } + + void SetDeactivateHdl( const Link& rLink ) { aDeactivateHdl = rLink; } + const Link& GetDeactivateHdl() const { return aDeactivateHdl; } + + void SetHighlightHdl( const Link& rLink ) { aHighlightHdl = rLink; } + const Link& GetHighlightHdl() const { return aHighlightHdl; } + + void SetSelectHdl( const Link& rLink ) { aSelectHdl = rLink; } + const Link& GetSelectHdl() const { return aSelectHdl; } + + void SetLogo( const MenuLogo& rLogo ); + void SetLogo(); + sal_Bool HasLogo() const { return pLogo ? sal_True : sal_False; } + MenuLogo GetLogo() const; + + void AddEventListener( const Link& rEventListener ); + void RemoveEventListener( const Link& rEventListener ); + //void AddChildEventListener( const Link& rEventListener ); + //void RemoveChildEventListener( const Link& rEventListener ); + + Menu& operator =( const Menu& rMenu ); + + // Fuer Menu-'Funktionen' + MenuItemList* GetItemList() const { return pItemList; } + + // returns the system's menu handle if native menues are supported + // pData must point to a SystemMenuData structure + sal_Bool GetSystemMenuData( SystemMenuData* pData ) const; + + // accessibility helpers + + // gets the displayed text + String GetDisplayText() const; + // returns the bounding box for the character at index nIndex + // where nIndex is relative to the starting index of the item + // with id nItemId (in coordinates of the displaying window) + Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const; + // -1 is returned if no character is at that point + // if an index is found the corresponding item id is filled in (else 0) + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const; + // returns the number of lines in the result of GetDisplayText() + long GetLineCount() const; + // returns the interval [start,end] of line nLine + // returns [-1,-1] for an invalid line + Pair GetLineStartEnd( long nLine ) const; + // like GetLineStartEnd but first finds the line number for the item + Pair GetItemStartEnd( sal_uInt16 nItemId ) const; + // returns the item id for line nLine or 0 if nLine is invalid + sal_uInt16 GetDisplayItemId( long nLine ) const; + // returns the bounding rectangle for an item at pos nItemPos + Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) const; + sal_Bool ConvertPoint( Point& rPoint, Window* pReferenceWindow ) const; + + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible(); + void SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible ); + + // gets the activation key of the specified item + KeyEvent GetActivationKey( sal_uInt16 nItemId ) const; + + Window* GetWindow() const { return pWindow; } + + void SetAccessibleName( sal_uInt16 nItemId, const XubString& rStr ); + XubString GetAccessibleName( sal_uInt16 nItemId ) const; + + void SetAccessibleDescription( sal_uInt16 nItemId, const XubString& rStr ); + XubString GetAccessibleDescription( sal_uInt16 nItemId ) const; + + // returns whether the item a position nItemPos is highlighted or not. + bool IsHighlighted( sal_uInt16 nItemPos ) const; + + void HighlightItem( sal_uInt16 nItemPos ); + void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID + + + void doLazyDelete(); +}; + +// ----------- +// - MenuBar - +// ----------- + +class VCL_DLLPUBLIC MenuBar : public Menu +{ + Link maCloserHdl; + Link maFloatHdl; + Link maHideHdl; + sal_Bool mbCloserVisible; + sal_Bool mbFloatBtnVisible; + sal_Bool mbHideBtnVisible; + sal_Bool mbDisplayable; + + friend class Application; + friend class Menu; + friend class MenuBarWindow; + friend class MenuFloatingWindow; + friend class SystemWindow; + + SAL_DLLPRIVATE static Window* ImplCreate( Window* pParent, Window* pWindow, MenuBar* pMenu ); + SAL_DLLPRIVATE static void ImplDestroy( MenuBar* pMenu, sal_Bool bDelete ); + SAL_DLLPRIVATE sal_Bool ImplHandleKeyEvent( const KeyEvent& rKEvent, sal_Bool bFromMenu = sal_True ); + +public: + MenuBar(); + MenuBar( const ResId& rResId ); + MenuBar( const MenuBar& rMenu ); + ~MenuBar(); + + MenuBar& operator =( const MenuBar& rMenu ); + + void ShowCloser( sal_Bool bShow = sal_True ); + sal_Bool HasCloser() const { return mbCloserVisible; } + void ShowFloatButton( sal_Bool bShow = sal_True ); + sal_Bool HasFloatButton() const { return mbFloatBtnVisible; } + void ShowHideButton( sal_Bool bShow = sal_True ); + sal_Bool HasHideButton() const { return mbHideBtnVisible; } + void ShowButtons( sal_Bool bClose, sal_Bool bFloat, sal_Bool bHide ); + + void SelectEntry( sal_uInt16 nId ); + sal_Bool HandleMenuActivateEvent( Menu *pMenu ) const; + sal_Bool HandleMenuDeActivateEvent( Menu *pMenu ) const; + sal_Bool HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nEventId ) const; + sal_Bool HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nEventId ) const; + sal_Bool HandleMenuButtonEvent( Menu *pMenu, sal_uInt16 nEventId ) const; + + void SetCloserHdl( const Link& rLink ) { maCloserHdl = rLink; } + const Link& GetCloserHdl() const { return maCloserHdl; } + void SetFloatButtonClickHdl( const Link& rLink ) { maFloatHdl = rLink; } + const Link& GetFloatButtonClickHdl() const { return maFloatHdl; } + void SetHideButtonClickHdl( const Link& rLink ) { maHideHdl = rLink; } + const Link& GetHideButtonClickHdl() const { return maHideHdl; } + + // - by default a menubar is displayable + // - if a menubar is not displayable, its MenuBarWindow will never be shown + // and it will be hidden if it was visible before + // - note: if a menubar is diplayable, this does not necessarily mean that it is currently visible + void SetDisplayable( sal_Bool bDisplayable ); + sal_Bool IsDisplayable() const { return mbDisplayable; } + + struct MenuBarButtonCallbackArg + { + sal_uInt16 nId; // Id of the button + bool bHighlight; // highlight on/off + MenuBar* pMenuBar; // menubar the button belongs to + }; + // add an arbitrary button to the menubar (will appear next to closer) + // passed link will be call with a MenuBarButtonCallbackArg on press + sal_uInt16 AddMenuBarButton( const Image&, const Link&, sal_uInt16 nPos = 0 ); + // add an arbitrary button to the menubar (will appear next to closer) + // passed link will be call with a MenuBarButtonCallbackArg on press + // passed string will be set as tooltip + sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos = 0 ); + // set the highlight link for additional button with ID nId + // highlight link will be called with a MenuBarButtonHighlightArg + // the bHighlight member of that struct shall contain the new state + void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& ); + // returns the rectangle occupied by the additional button named nId + // coordinates are relative to the systemwindiow the menubar is attached to + // if the menubar is unattached an empty rectangle is returned + Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId ); + void RemoveMenuBarButton( sal_uInt16 nId ); +}; + +inline MenuBar& MenuBar::operator =( const MenuBar& rMenu ) +{ + Menu::operator =( rMenu ); + return *this; +} + + +// ------------- +// - PopupMenu - +// ------------- + +class VCL_DLLPUBLIC PopupMenu : public Menu +{ + friend class Menu; + friend class MenuFloatingWindow; + friend class MenuBarWindow; + friend struct MenuItemData; + +private: + Menu** pRefAutoSubMenu; // keeps track if a pointer to this Menu is stored in the MenuItemData + + SAL_DLLPRIVATE MenuFloatingWindow* ImplGetFloatingWindow() const { return (MenuFloatingWindow*)Menu::ImplGetWindow(); } + +protected: + SAL_DLLPRIVATE sal_uInt16 ImplExecute( Window* pWindow, const Rectangle& rRect, sal_uLong nPopupFlags, Menu* pStaredFrom, sal_Bool bPreSelectFirst ); + SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const; + SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = NULL ) const; + +public: + PopupMenu(); + PopupMenu( const PopupMenu& rMenu ); + PopupMenu( const ResId& rResId ); + ~PopupMenu(); + + void SetText( const XubString& rTitle ) { aTitleText = rTitle; } + const XubString& GetText() const { return aTitleText; } + + sal_uInt16 Execute( Window* pWindow, const Point& rPopupPos ); + sal_uInt16 Execute( Window* pWindow, const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + + // Fuer das TestTool + void EndExecute( sal_uInt16 nSelect = 0 ); + void SelectEntry( sal_uInt16 nId ); + void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only + + static sal_Bool IsInExecute(); + static PopupMenu* GetActivePopupMenu(); + + PopupMenu& operator =( const PopupMenu& rMenu ); +}; + +inline PopupMenu& PopupMenu::operator =( const PopupMenu& rMenu ) +{ + Menu::operator =( rMenu ); + return *this; +} + +#endif // _SV_MENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/menubtn.hxx b/vcl/inc/vcl/menubtn.hxx new file mode 100644 index 000000000000..1e65504b97bc --- /dev/null +++ b/vcl/inc/vcl/menubtn.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MENUBTN_HXX +#define _SV_MENUBTN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/button.hxx> + +class Timer; +class PopupMenu; + +// -------------------- +// - MenuButton-Types - +// -------------------- + +#define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001) + +// -------------- +// - MenuButton - +// -------------- + +class VCL_DLLPUBLIC MenuButton : public PushButton +{ +private: + Rectangle maFocusRect; + Timer* mpMenuTimer; + PopupMenu* mpOwnMenu; + PopupMenu* mpMenu; + sal_uInt16 mnCurItemId; + sal_uInt16 mnMenuMode; + Link maActivateHdl; + Link maSelectHdl; + + SAL_DLLPRIVATE void ImplInitMenuButtonData(); + SAL_DLLPRIVATE void ImplExecuteMenu(); + DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer* ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE MenuButton( const MenuButton & ); + SAL_DLLPRIVATE MenuButton& operator=( const MenuButton & ); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + MenuButton( Window* pParent, WinBits nStyle = 0 ); + MenuButton( Window* pParent, const ResId& rResId ); + ~MenuButton(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + + virtual void Activate(); + virtual void Select(); + + void SetMenuMode( sal_uInt16 nMode ); + sal_uInt16 GetMenuMode() const { return mnMenuMode; } + + void SetPopupMenu( PopupMenu* pNewMenu ); + PopupMenu* GetPopupMenu() const { return mpMenu; } + + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + + void SetActivateHdl( const Link& rLink ) { maActivateHdl = rLink; } + const Link& GetActivateHdl() const { return maActivateHdl; } + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } +}; + +#endif // _SV_MENUBTN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/metaact.hxx b/vcl/inc/vcl/metaact.hxx new file mode 100644 index 000000000000..fd8f3b8e985b --- /dev/null +++ b/vcl/inc/vcl/metaact.hxx @@ -0,0 +1,1549 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_METAACT_HXX +#define _SV_METAACT_HXX + +#include <vcl/dllapi.h> +#include <vcl/gradient.hxx> +#include <vcl/hatch.hxx> +#include <vcl/wall.hxx> +#include <vcl/font.hxx> +#include <tools/poly.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/region.hxx> +#include <vcl/graph.hxx> +#include <vcl/outdev.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/lineinfo.hxx> + +class SvStream; + +// ----------- +// - Defines - +// ----------- + +#define META_NULL_ACTION (0) +#define META_PIXEL_ACTION (100) +#define META_POINT_ACTION (101) +#define META_LINE_ACTION (102) +#define META_RECT_ACTION (103) +#define META_ROUNDRECT_ACTION (104) +#define META_ELLIPSE_ACTION (105) +#define META_ARC_ACTION (106) +#define META_PIE_ACTION (107) +#define META_CHORD_ACTION (108) +#define META_POLYLINE_ACTION (109) +#define META_POLYGON_ACTION (110) +#define META_POLYPOLYGON_ACTION (111) +#define META_TEXT_ACTION (112) +#define META_TEXTARRAY_ACTION (113) +#define META_STRETCHTEXT_ACTION (114) +#define META_TEXTRECT_ACTION (115) +#define META_BMP_ACTION (116) +#define META_BMPSCALE_ACTION (117) +#define META_BMPSCALEPART_ACTION (118) +#define META_BMPEX_ACTION (119) +#define META_BMPEXSCALE_ACTION (120) +#define META_BMPEXSCALEPART_ACTION (121) +#define META_MASK_ACTION (122) +#define META_MASKSCALE_ACTION (123) +#define META_MASKSCALEPART_ACTION (124) +#define META_GRADIENT_ACTION (125) +#define META_HATCH_ACTION (126) +#define META_WALLPAPER_ACTION (127) +#define META_CLIPREGION_ACTION (128) +#define META_ISECTRECTCLIPREGION_ACTION (129) +#define META_ISECTREGIONCLIPREGION_ACTION (130) +#define META_MOVECLIPREGION_ACTION (131) +#define META_LINECOLOR_ACTION (132) +#define META_FILLCOLOR_ACTION (133) +#define META_TEXTCOLOR_ACTION (134) +#define META_TEXTFILLCOLOR_ACTION (135) +#define META_TEXTALIGN_ACTION (136) +#define META_MAPMODE_ACTION (137) +#define META_FONT_ACTION (138) +#define META_PUSH_ACTION (139) +#define META_POP_ACTION (140) +#define META_RASTEROP_ACTION (141) +#define META_TRANSPARENT_ACTION (142) +#define META_EPS_ACTION (143) +#define META_REFPOINT_ACTION (144) +#define META_TEXTLINECOLOR_ACTION (145) +#define META_TEXTLINE_ACTION (146) +#define META_FLOATTRANSPARENT_ACTION (147) +#define META_GRADIENTEX_ACTION (148) +#define META_LAYOUTMODE_ACTION (149) +#define META_TEXTLANGUAGE_ACTION (150) +#define META_OVERLINECOLOR_ACTION (151) + +#define META_COMMENT_ACTION (512) + +// ------------------------------------------------------------------------ + +struct ImplMetaReadData +{ + rtl_TextEncoding meActualCharSet; +}; + +// ------------------------------------------------------------------------ + +struct ImplMetaWriteData +{ + rtl_TextEncoding meActualCharSet; +}; + +// ------------------------------------------------------------------------ + +#define DECL_META_ACTION( Name, nType ) \ + Meta##Name##Action(); \ +protected: \ + virtual ~Meta##Name##Action(); \ +public: \ + virtual void Execute( OutputDevice* pOut ); \ + virtual MetaAction* Clone(); \ + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); \ + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); + +#define IMPL_META_ACTION( Name, nType ) \ +Meta##Name##Action::Meta##Name##Action() : \ + MetaAction( nType ) {} \ +Meta##Name##Action::~Meta##Name##Action() {} + +// -------------- +// - MetaAction - +// -------------- + +class VCL_DLLPUBLIC MetaAction +{ +private: + sal_uLong mnRefCount; + sal_uInt16 mnType; + + virtual sal_Bool Compare( const MetaAction& ) const; + +protected: + virtual ~MetaAction(); + +public: + MetaAction(); + MetaAction( sal_uInt16 nType ); + + virtual void Execute( OutputDevice* pOut ); + + virtual MetaAction* Clone(); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); + + sal_Bool IsEqual( const MetaAction& ) const; + + sal_uInt16 GetType() const { return mnType; } + sal_uLong GetRefCount() const { return mnRefCount; } + void ResetRefCount() { mnRefCount = 1; } + void Duplicate() { mnRefCount++; } + void Delete() { if ( 0 == --mnRefCount ) delete this; } + +public: + static MetaAction* ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData ); +}; + +// ------------------- +// - MetaPixelAction - +// ------------------- + +class VCL_DLLPUBLIC MetaPixelAction : public MetaAction +{ +private: + Point maPt; + Color maColor; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Pixel, META_PIXEL_ACTION ) + + MetaPixelAction( const Point& rPt, const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetPoint() const { return maPt; } + const Color& GetColor() const { return maColor; } +}; + +// ------------------- +// - MetaPointAction - +// ------------------- + +class VCL_DLLPUBLIC MetaPointAction : public MetaAction +{ +private: + Point maPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Point, META_POINT_ACTION ) + + MetaPointAction( const Point& rPt ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetPoint() const { return maPt; } +}; + +// ------------------ +// - MetaLineAction - +// ------------------ + +class VCL_DLLPUBLIC MetaLineAction : public MetaAction +{ +private: + + LineInfo maLineInfo; + Point maStartPt; + Point maEndPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Line, META_LINE_ACTION ) + + MetaLineAction( const Point& rStart, const Point& rEnd ); + MetaLineAction( const Point& rStart, const Point& rEnd, + const LineInfo& rLineInfo ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } + const LineInfo& GetLineInfo() const { return maLineInfo; } +}; + +// ------------------ +// - MetaRectAction - +// ------------------ + +class VCL_DLLPUBLIC MetaRectAction : public MetaAction +{ +private: + + Rectangle maRect; + + virtual sal_Bool Compare( const MetaAction& ) const; +public: + DECL_META_ACTION( Rect, META_RECT_ACTION ) + + MetaRectAction( const Rectangle& rRect ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } +}; + +// ----------------------- +// - MetaRoundRectAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaRoundRectAction : public MetaAction +{ +private: + + Rectangle maRect; + sal_uInt32 mnHorzRound; + sal_uInt32 mnVertRound; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( RoundRect, META_ROUNDRECT_ACTION ) + + MetaRoundRectAction( const Rectangle& rRect, + sal_uInt32 nHorzRound, sal_uInt32 nVertRound ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + sal_uInt32 GetHorzRound() const { return mnHorzRound; } + sal_uInt32 GetVertRound() const { return mnVertRound; } +}; + +// --------------------- +// - MetaEllipseAction - +// --------------------- + +class VCL_DLLPUBLIC MetaEllipseAction : public MetaAction +{ +private: + + Rectangle maRect; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Ellipse, META_ELLIPSE_ACTION ) + + MetaEllipseAction( const Rectangle& rRect ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } +}; + +// ----------------- +// - MetaArcAction - +// ----------------- + +class VCL_DLLPUBLIC MetaArcAction : public MetaAction +{ +private: + + Rectangle maRect; + Point maStartPt; + Point maEndPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Arc, META_ARC_ACTION ) + + MetaArcAction( const Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +// ----------------- +// - MetaPieAction - +// ----------------- + +class VCL_DLLPUBLIC MetaPieAction : public MetaAction +{ +private: + + Rectangle maRect; + Point maStartPt; + Point maEndPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Pie, META_PIE_ACTION ) + + MetaPieAction( const Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +// ------------------- +// - MetaChordAction - +// ------------------- + +class VCL_DLLPUBLIC MetaChordAction : public MetaAction +{ +private: + + Rectangle maRect; + Point maStartPt; + Point maEndPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Chord, META_CHORD_ACTION ) + + MetaChordAction( const Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +// ---------------------- +// - MetaPolyLineAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaPolyLineAction : public MetaAction +{ +private: + + LineInfo maLineInfo; + Polygon maPoly; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( PolyLine, META_POLYLINE_ACTION ) + + MetaPolyLineAction( const Polygon& rPoly ); + MetaPolyLineAction( const Polygon& rPoly, const LineInfo& rLineInfo ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Polygon& GetPolygon() const { return maPoly; } + const LineInfo& GetLineInfo() const { return maLineInfo; } +}; + +// --------------------- +// - MetaPolygonAction - +// --------------------- + +class VCL_DLLPUBLIC MetaPolygonAction : public MetaAction +{ +private: + + Polygon maPoly; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Polygon, META_POLYGON_ACTION ) + + MetaPolygonAction( const Polygon& rPoly ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Polygon& GetPolygon() const { return maPoly; } +}; + +// ------------------------- +// - MetaPolyPolygonAction - +// ------------------------- + +class VCL_DLLPUBLIC MetaPolyPolygonAction : public MetaAction +{ +private: + + PolyPolygon maPolyPoly; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( PolyPolygon, META_POLYPOLYGON_ACTION ) + + MetaPolyPolygonAction( const PolyPolygon& rPolyPoly ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } +}; + +// ------------------ +// - MetaTextAction - +// ------------------ + +class VCL_DLLPUBLIC MetaTextAction : public MetaAction +{ +private: + + Point maPt; + XubString maStr; + sal_uInt16 mnIndex; + sal_uInt16 mnLen; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Text, META_TEXT_ACTION ) + + MetaTextAction( const Point& rPt, const XubString& rStr, + sal_uInt16 nIndex, sal_uInt16 nLen ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetPoint() const { return maPt; } + const XubString& GetText() const { return maStr; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } +}; + +// ----------------------- +// - MetaTextArrayAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaTextArrayAction : public MetaAction +{ +private: + + Point maStartPt; + XubString maStr; + sal_Int32* mpDXAry; + sal_uInt16 mnIndex; + sal_uInt16 mnLen; + + virtual sal_Bool Compare( const MetaAction& ) const; + +protected: + virtual ~MetaTextArrayAction(); + +public: + MetaTextArrayAction(); + MetaTextArrayAction( const MetaTextArrayAction& rAction ); + MetaTextArrayAction( const Point& rStartPt, + const XubString& rStr, + const sal_Int32* pDXAry, + sal_uInt16 nIndex, + sal_uInt16 nLen ); + + virtual void Execute( OutputDevice* pOut ); + + virtual MetaAction* Clone(); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); + + const Point& GetPoint() const { return maStartPt; } + const XubString& GetText() const { return maStr; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } + sal_Int32* GetDXArray() const { return mpDXAry; } +}; + +// ------------------------- +// - MetaStretchTextAction - +// ------------------------- + +class VCL_DLLPUBLIC MetaStretchTextAction : public MetaAction +{ +private: + + Point maPt; + XubString maStr; + sal_uInt32 mnWidth; + sal_uInt16 mnIndex; + sal_uInt16 mnLen; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( StretchText, META_STRETCHTEXT_ACTION ) + + MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidth, + const XubString& rStr, + sal_uInt16 nIndex, sal_uInt16 nLen ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetPoint() const { return maPt; } + const XubString& GetText() const { return maStr; } + sal_uInt32 GetWidth() const { return mnWidth; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } +}; + +// ---------------------- +// - MetaTextRectAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaTextRectAction : public MetaAction +{ +private: + + Rectangle maRect; + XubString maStr; + sal_uInt16 mnStyle; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextRect, META_TEXTRECT_ACTION ) + + MetaTextRectAction( const Rectangle& rRect, + const XubString& rStr, sal_uInt16 nStyle ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const XubString& GetText() const { return maStr; } + sal_uInt16 GetStyle() const { return mnStyle; } +}; + +// ---------------------- +// - MetaTextLineAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaTextLineAction : public MetaAction +{ +private: + + Point maPos; + long mnWidth; + FontStrikeout meStrikeout; + FontUnderline meUnderline; + FontUnderline meOverline; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextLine, META_TEXTLINE_ACTION ) + + MetaTextLineAction( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontUnderline eUnderline, + FontUnderline eOverline ); + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Point& GetStartPoint() const { return maPos; } + long GetWidth() const { return mnWidth; } + FontStrikeout GetStrikeout() const { return meStrikeout; } + FontUnderline GetUnderline() const { return meUnderline; } + FontUnderline GetOverline() const { return meOverline; } +}; + +// ----------------- +// - MetaBmpAction - +// ----------------- + +class VCL_DLLPUBLIC MetaBmpAction : public MetaAction +{ +private: + + Bitmap maBmp; + Point maPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Bmp, META_BMP_ACTION ) + + MetaBmpAction( const Point& rPt, const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetPoint() const { return maPt; } +}; + +// ---------------------- +// - MetaBmpScaleAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaBmpScaleAction : public MetaAction +{ +private: + + Bitmap maBmp; + Point maPt; + Size maSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( BmpScale, META_BMPSCALE_ACTION ) + + MetaBmpScaleAction( const Point& rPt, const Size& rSz, + const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } +}; + +// -------------------------- +// - MetaBmpScalePartAction - +// -------------------------- + +class VCL_DLLPUBLIC MetaBmpScalePartAction : public MetaAction +{ +private: + + Bitmap maBmp; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( BmpScalePart, META_BMPSCALEPART_ACTION ) + + MetaBmpScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } +}; + +// ----------------- +// - MetaBmpExAction - +// ----------------- + +class VCL_DLLPUBLIC MetaBmpExAction : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( BmpEx, META_BMPEX_ACTION ) + + MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetPoint() const { return maPt; } +}; + +// ---------------------- +// - MetaBmpExScaleAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaBmpExScaleAction : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maPt; + Size maSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( BmpExScale, META_BMPEXSCALE_ACTION ) + + MetaBmpExScaleAction( const Point& rPt, const Size& rSz, + const BitmapEx& rBmpEx ) ; + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } +}; + +// ---------------------------- +// - MetaBmpExScalePartAction - +// ---------------------------- + +class VCL_DLLPUBLIC MetaBmpExScalePartAction : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( BmpExScalePart, META_BMPEXSCALEPART_ACTION ) + + MetaBmpExScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const BitmapEx& rBmpEx ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } +}; + +// ------------------ +// - MetaMaskAction - +// ------------------ + +class VCL_DLLPUBLIC MetaMaskAction : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maPt; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Mask, META_MASK_ACTION ) + + MetaMaskAction( const Point& rPt, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetPoint() const { return maPt; } +}; + +// ----------------------- +// - MetaMaskScaleAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaMaskScaleAction : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maPt; + Size maSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( MaskScale, META_MASKSCALE_ACTION ) + + MetaMaskScaleAction( const Point& rPt, const Size& rSz, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } +}; + +// --------------------------- +// - MetaMaskScalePartAction - +// --------------------------- + +class VCL_DLLPUBLIC MetaMaskScalePartAction : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( MaskScalePart, META_MASKSCALEPART_ACTION ) + + MetaMaskScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } +}; + +// ---------------------- +// - MetaGradientAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaGradientAction : public MetaAction +{ +private: + + Rectangle maRect; + Gradient maGradient; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Gradient, META_GRADIENT_ACTION ) + + MetaGradientAction( const Rectangle& rRect, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const Gradient& GetGradient() const { return maGradient; } +}; + +// ------------------------ +// - MetaGradientExAction - +// ------------------------ + +class VCL_DLLPUBLIC MetaGradientExAction : public MetaAction +{ +private: + + PolyPolygon maPolyPoly; + Gradient maGradient; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( GradientEx, META_GRADIENTEX_ACTION ) + + MetaGradientExAction( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + const Gradient& GetGradient() const { return maGradient; } +}; + +// ------------------- +// - MetaHatchAction - +// ------------------- + +class VCL_DLLPUBLIC MetaHatchAction : public MetaAction +{ +private: + + PolyPolygon maPolyPoly; + Hatch maHatch; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Hatch, META_HATCH_ACTION ) + + MetaHatchAction( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + const Hatch& GetHatch() const { return maHatch; } +}; + +// ----------------------- +// - MetaWallpaperAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaWallpaperAction : public MetaAction +{ +private: + + Rectangle maRect; + Wallpaper maWallpaper; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Wallpaper, META_WALLPAPER_ACTION ) + + MetaWallpaperAction( const Rectangle& rRect, + const Wallpaper& rPaper ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } + const Wallpaper& GetWallpaper() const { return maWallpaper; } +}; + +// ------------------------ +// - MetaClipRegionAction - +// ------------------------ + +class VCL_DLLPUBLIC MetaClipRegionAction : public MetaAction +{ +private: + + Region maRegion; + sal_Bool mbClip; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( ClipRegion, META_CLIPREGION_ACTION ) + + MetaClipRegionAction( const Region& rRegion, sal_Bool bClip ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Region& GetRegion() const { return maRegion; } + sal_Bool IsClipping() const { return mbClip; } +}; + +// --------------------------------- +// - MetaISectRectClipRegionAction - +// --------------------------------- + +class VCL_DLLPUBLIC MetaISectRectClipRegionAction : public MetaAction +{ +private: + + Rectangle maRect; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( ISectRectClipRegion, META_ISECTRECTCLIPREGION_ACTION ) + + MetaISectRectClipRegionAction( const Rectangle& rRect ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Rectangle& GetRect() const { return maRect; } +}; + +// ----------------------------------- +// - MetaISectRegionClipRegionAction - +// ----------------------------------- + +class VCL_DLLPUBLIC MetaISectRegionClipRegionAction : public MetaAction +{ +private: + + Region maRegion; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( ISectRegionClipRegion, META_ISECTREGIONCLIPREGION_ACTION ) + + MetaISectRegionClipRegionAction( const Region& rRegion ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const Region& GetRegion() const { return maRegion; } +}; + +// ---------------------------- +// - MetaMoveClipRegionAction - +// ---------------------------- + +class VCL_DLLPUBLIC MetaMoveClipRegionAction : public MetaAction +{ +private: + + long mnHorzMove; + long mnVertMove; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( MoveClipRegion, META_MOVECLIPREGION_ACTION ) + + MetaMoveClipRegionAction( long nHorzMove, long nVertMove ); + + virtual void Scale( double fScaleX, double fScaleY ); + + long GetHorzMove() const { return mnHorzMove; } + long GetVertMove() const { return mnVertMove; } +}; + +// ----------------------- +// - MetaLineColorAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaLineColorAction : public MetaAction +{ +private: + + Color maColor; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( LineColor, META_LINECOLOR_ACTION ) + + MetaLineColorAction( const Color& rColor, sal_Bool bSet ); + + const Color& GetColor() const { return maColor; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// ----------------------- +// - MetaFillColorAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaFillColorAction : public MetaAction +{ +private: + + Color maColor; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( FillColor, META_FILLCOLOR_ACTION ) + + MetaFillColorAction( const Color& rColor, sal_Bool bSet ); + + const Color& GetColor() const { return maColor; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// ----------------------- +// - MetaTextColorAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaTextColorAction : public MetaAction +{ +private: + + Color maColor; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextColor, META_TEXTCOLOR_ACTION ) + + MetaTextColorAction( const Color& rColor ); + + const Color& GetColor() const { return maColor; } +}; + +// --------------------------- +// - MetaTextFillColorAction - +// --------------------------- + +class VCL_DLLPUBLIC MetaTextFillColorAction : public MetaAction +{ +private: + + Color maColor; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextFillColor, META_TEXTFILLCOLOR_ACTION ) + + MetaTextFillColorAction( const Color& rColor, sal_Bool bSet ); + + const Color& GetColor() const { return maColor; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// --------------------------- +// - MetaTextLineColorAction - +// --------------------------- + +class VCL_DLLPUBLIC MetaTextLineColorAction : public MetaAction +{ +private: + + Color maColor; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextLineColor, META_TEXTLINECOLOR_ACTION ) + + MetaTextLineColorAction( const Color& rColor, sal_Bool bSet ); + + const Color& GetColor() const { return maColor; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// --------------------------- +// - MetaOverlineColorAction - +// --------------------------- + +class VCL_DLLPUBLIC MetaOverlineColorAction : public MetaAction +{ +private: + + Color maColor; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( OverlineColor, META_OVERLINECOLOR_ACTION ) + + MetaOverlineColorAction( const Color& rColor, sal_Bool bSet ); + + const Color& GetColor() const { return maColor; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// ----------------------- +// - MetaTextAlignAction - +// ----------------------- + +class VCL_DLLPUBLIC MetaTextAlignAction : public MetaAction +{ +private: + + TextAlign maAlign; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextAlign, META_TEXTALIGN_ACTION ) + + MetaTextAlignAction( TextAlign aAlign ); + + TextAlign GetTextAlign() const { return maAlign; } +}; + +// --------------------- +// - MetaMapModeAction - +// --------------------- + +class VCL_DLLPUBLIC MetaMapModeAction : public MetaAction +{ +private: + + MapMode maMapMode; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( MapMode, META_MAPMODE_ACTION ) + + MetaMapModeAction( const MapMode& rMapMode ); + + virtual void Scale( double fScaleX, double fScaleY ); + + const MapMode& GetMapMode() const { return maMapMode; } +}; + +// --------------------- +// - MetaFontAction - +// --------------------- + +class VCL_DLLPUBLIC MetaFontAction : public MetaAction +{ +private: + + Font maFont; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Font, META_FONT_ACTION ) + + MetaFontAction( const Font& rFont ); + + virtual void Scale( double fScaleX, double fScaleY ); + + const Font& GetFont() const { return maFont; } +}; + +// ------------------ +// - MetaPushAction - +// ------------------ + +class VCL_DLLPUBLIC MetaPushAction : public MetaAction +{ +private: + + sal_uInt16 mnFlags; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Push, META_PUSH_ACTION ) + + MetaPushAction( sal_uInt16 nFlags ); + + sal_uInt16 GetFlags() const { return mnFlags; } +}; + +// ----------------- +// - MetaPopAction - +// ----------------- + +class VCL_DLLPUBLIC MetaPopAction : public MetaAction +{ +public: + + DECL_META_ACTION( Pop, META_POP_ACTION ) +}; + +// ---------------------- +// - MetaRasterOpAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaRasterOpAction : public MetaAction +{ +private: + + RasterOp meRasterOp; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( RasterOp, META_RASTEROP_ACTION ) + + MetaRasterOpAction( RasterOp eRasterOp ); + + RasterOp GetRasterOp() const { return meRasterOp; } +}; + +// ------------------------- +// - MetaTransparentAction - +// ------------------------- + +class VCL_DLLPUBLIC MetaTransparentAction : public MetaAction +{ +private: + + PolyPolygon maPolyPoly; + sal_uInt16 mnTransPercent; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( Transparent, META_TRANSPARENT_ACTION ) + + MetaTransparentAction( const PolyPolygon& rPolyPoly, sal_uInt16 nTransPercent ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + sal_uInt16 GetTransparence() const { return mnTransPercent; } +}; + +// ------------------------------ +// - MetaFloatTransparentAction - +// ------------------------------ + +class VCL_DLLPUBLIC MetaFloatTransparentAction : public MetaAction +{ +private: + + GDIMetaFile maMtf; + Point maPoint; + Size maSize; + Gradient maGradient; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( FloatTransparent, META_FLOATTRANSPARENT_ACTION ) + + MetaFloatTransparentAction( const GDIMetaFile& rMtf, const Point& rPos, + const Size& rSize, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const GDIMetaFile& GetGDIMetaFile() const { return maMtf; } + const Point& GetPoint() const { return maPoint; } + const Size& GetSize() const { return maSize; } + const Gradient& GetGradient() const { return maGradient; } +}; + +// --------------------- +// - MetaDrawEPSAction - +// --------------------- + +class VCL_DLLPUBLIC MetaEPSAction : public MetaAction +{ +private: + + GfxLink maGfxLink; + GDIMetaFile maSubst; + Point maPoint; + Size maSize; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( EPS, META_EPS_ACTION ) + + MetaEPSAction( const Point& rPoint, const Size& rSize, + const GfxLink& rGfxLink, const GDIMetaFile& rSubst ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + const GfxLink& GetLink() const { return maGfxLink; } + const GDIMetaFile& GetSubstitute() const { return maSubst; } + const Point& GetPoint() const { return maPoint; } + const Size& GetSize() const { return maSize; } +}; + +// ---------------------- +// - MetaRefPointAction - +// ---------------------- + +class VCL_DLLPUBLIC MetaRefPointAction : public MetaAction +{ +private: + + Point maRefPoint; + sal_Bool mbSet; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( RefPoint, META_REFPOINT_ACTION ) + + MetaRefPointAction( const Point& rRefPoint, sal_Bool bSet ); + + const Point& GetRefPoint() const { return maRefPoint; } + sal_Bool IsSetting() const { return mbSet; } +}; + +// --------------------- +// - MetaCommentAction - +// --------------------- + +class VCL_DLLPUBLIC MetaCommentAction : public MetaAction +{ +private: + + ByteString maComment; + sal_Int32 mnValue; + sal_uInt32 mnDataSize; + sal_uInt8* mpData; + + SAL_DLLPRIVATE void ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize ); + virtual sal_Bool Compare( const MetaAction& ) const; + +protected: + ~MetaCommentAction(); + +public: + MetaCommentAction( sal_Int32 nValue = 0L ); + MetaCommentAction( const MetaCommentAction& rAct ); + MetaCommentAction( const ByteString& rComment, sal_Int32 nValue = 0L, const sal_uInt8* pData = NULL, sal_uInt32 nDataSize = 0UL ); + MetaCommentAction( const sal_uInt8* pData, sal_uInt32 nDataSize ); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + virtual void Execute( OutputDevice* pOut ); + virtual MetaAction* Clone(); + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); + + const ByteString& GetComment() const { return maComment; } + sal_Int32 GetValue() const { return mnValue; } + sal_uInt32 GetDataSize() const { return mnDataSize; } + const sal_uInt8* GetData() const { return mpData; } +}; + +// ------------------------ +// - MetaLayoutModeAction - +// ------------------------ + +class VCL_DLLPUBLIC MetaLayoutModeAction : public MetaAction +{ +private: + + sal_uInt32 mnLayoutMode; + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( LayoutMode, META_LAYOUTMODE_ACTION ) + + MetaLayoutModeAction( sal_uInt32 nLayoutMode ); + + sal_uInt32 GetLayoutMode() const { return mnLayoutMode; } +}; + +// ------------------------ +// - MetaTextLanguageAction - +// ------------------------ + +class VCL_DLLPUBLIC MetaTextLanguageAction : public MetaAction +{ +private: + + LanguageType meTextLanguage; + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextLanguage, META_TEXTLANGUAGE_ACTION ) + + MetaTextLanguageAction( LanguageType ); + + LanguageType GetTextLanguage() const { return meTextLanguage; } +}; + +#endif // _SV_METAACT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/metric.hxx b/vcl/inc/vcl/metric.hxx new file mode 100644 index 000000000000..677135b99990 --- /dev/null +++ b/vcl/inc/vcl/metric.hxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_METRIC_HXX +#define _SV_METRIC_HXX + +#include <vcl/dllapi.h> +#include <vcl/font.hxx> + +class ImplFontMetric; +class ImplFontCharMap; + +typedef sal_uInt32 sal_UCS4; + +// ------------ +// - FontInfo - +// ------------ + +class VCL_DLLPUBLIC FontInfo : public Font +{ + friend class OutputDevice; + +protected: + ImplFontMetric* mpImplMetric; // Implementation + +public: + FontInfo(); + FontInfo( const FontInfo& ); + ~FontInfo(); + + FontType GetType() const; + sal_Bool IsDeviceFont() const; + sal_Bool SupportsLatin() const; + sal_Bool SupportsCJK() const; + sal_Bool SupportsCTL() const; + + FontInfo& operator=( const FontInfo& ); + sal_Bool operator==( const FontInfo& ) const; + sal_Bool operator!=( const FontInfo& rInfo ) const + { return !operator==( rInfo ); } +}; + +// -------------- +// - FontMetric - +// -------------- + +class VCL_DLLPUBLIC FontMetric : public FontInfo +{ +public: + FontMetric() {} + FontMetric( const FontMetric& ); + ~FontMetric() {} + + long GetAscent() const; + long GetDescent() const; + long GetIntLeading() const; + long GetExtLeading() const; + long GetLineHeight() const; + long GetSlant() const; + + FontMetric& operator=( const FontMetric& rMetric ); + sal_Bool operator==( const FontMetric& rMetric ) const; + sal_Bool operator!=( const FontMetric& rMetric ) const + { return !operator==( rMetric ); } +}; + +// --------------- +// - FontCharMap - +// --------------- + +class VCL_DLLPUBLIC FontCharMap +{ +private: + const ImplFontCharMap* mpImpl; + +public: + FontCharMap(); + ~FontCharMap(); + + sal_Bool IsDefaultMap() const; + sal_Bool HasChar( sal_uInt32 ) const; + int CountCharsInRange( sal_uInt32 cMin, sal_uInt32 cMax ) const; + int GetCharCount() const; + + sal_uInt32 GetFirstChar() const; + sal_uInt32 GetLastChar() const; + + sal_uInt32 GetNextChar( sal_uInt32 ) const; + sal_uInt32 GetPrevChar( sal_uInt32 ) const; + + int GetIndexFromChar( sal_uInt32 ) const; + sal_uInt32 GetCharFromIndex( int ) const; + + +private: + friend class OutputDevice; + void Reset( const ImplFontCharMap* pNewMap = NULL ); + + // prevent assignment and copy construction + FontCharMap( const FontCharMap& ); + void operator=( const FontCharMap& ); +}; + +// ---------------- +// - TextRectInfo - +// ---------------- + +class VCL_DLLPUBLIC TextRectInfo +{ + friend class OutputDevice; + +private: + long mnMaxWidth; + sal_uInt16 mnLineCount; + sal_Bool mbEllipsis; + +public: + TextRectInfo(); + + sal_uInt16 GetLineCount() const { return mnLineCount; } + long GetMaxLineWidth() const { return mnMaxWidth; } + sal_Bool IsEllipses() const { return mbEllipsis; } + + sal_Bool operator ==( const TextRectInfo& rInfo ) const + { return ((mnMaxWidth == rInfo.mnMaxWidth) && + (mnLineCount == rInfo.mnLineCount) && + (mbEllipsis == rInfo.mbEllipsis)); } + sal_Bool operator !=( const TextRectInfo& rInfo ) const + { return !(TextRectInfo::operator==( rInfo )); } +}; + +inline TextRectInfo::TextRectInfo() +{ + mnMaxWidth = 0; + mnLineCount = 0; + mbEllipsis = sal_False; +} + +#endif // _SV_METRIC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/mnemonic.hxx b/vcl/inc/vcl/mnemonic.hxx new file mode 100644 index 000000000000..1a0aac80a4a4 --- /dev/null +++ b/vcl/inc/vcl/mnemonic.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MNEMONIC_HXX +#define _SV_MNEMONIC_HXX + +#include <vcl/dllapi.h> +#include <tools/string.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/i18n/XCharacterClassification.hpp> + +// --------------------- +// - ImplMnemonicTypes - +// --------------------- + +// Mnemonic Chars, which we want support +// Latin 0-9 +#define MNEMONIC_RANGE_1_START 0x30 +#define MNEMONIC_RANGE_1_END 0x39 +// Latin A-Z +#define MNEMONIC_RANGE_2_START 0x41 +#define MNEMONIC_RANGE_2_END 0x5A +// Cyrillic +#define MNEMONIC_RANGE_3_START 0x0410 +#define MNEMONIC_RANGE_3_END 0x042F +// Greek +#define MNEMONIC_RANGE_4_START 0x0391 +#define MNEMONIC_RANGE_4_END 0x03AB +#define MNEMONIC_RANGES 4 +#define MAX_MNEMONICS ((MNEMONIC_RANGE_1_END-MNEMONIC_RANGE_1_START+1)+\ + (MNEMONIC_RANGE_2_END-MNEMONIC_RANGE_2_START+1)+\ + (MNEMONIC_RANGE_3_END-MNEMONIC_RANGE_3_START+1)+\ + (MNEMONIC_RANGE_4_END-MNEMONIC_RANGE_4_START+1)) + +#define MNEMONIC_CHAR ((sal_Unicode)'~') +#define MNEMONIC_INDEX_NOTFOUND ((sal_uInt16)0xFFFF) + +// ------------------------- +// - MnemonicGenerator - +// ------------------------- + +class VCL_DLLPUBLIC MnemonicGenerator +{ +private: + // 0 == Mnemonic; >0 == count of characters + sal_uInt8 maMnemonics[MAX_MNEMONICS]; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > mxCharClass; + +protected: + SAL_DLLPRIVATE sal_uInt16 ImplGetMnemonicIndex( sal_Unicode c ); + SAL_DLLPRIVATE sal_Unicode ImplFindMnemonic( const XubString& rKey ); + +public: + MnemonicGenerator(); + + void RegisterMnemonic( const XubString& rKey ); + sal_Bool CreateMnemonic( XubString& rKey ); + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > GetCharClass(); + + // returns a string where all '~'-characters and CJK mnemonics of the form (~A) are completely removed + static String EraseAllMnemonicChars( const String& rStr ); +}; + +#endif // _SV_MNEMONIC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/mnemonicengine.hxx b/vcl/inc/vcl/mnemonicengine.hxx new file mode 100644 index 000000000000..79f6856cb704 --- /dev/null +++ b/vcl/inc/vcl/mnemonicengine.hxx @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VCL_MNEMONICENGINE_HXX +#define VCL_MNEMONICENGINE_HXX + +#include "dllapi.h" + +#include <sal/config.h> +#include <sal/types.h> + +#include <memory> + +class String; +class KeyEvent; + +//........................................................................ +namespace vcl +{ +//........................................................................ + + //==================================================================== + //= IMnemonicEntryList + //==================================================================== + /// callback for a MnemonicEngine + class SAL_NO_VTABLE VCL_DLLPUBLIC IMnemonicEntryList + { + public: + /** returns the first list entry for the mnemonic search + + @return + a pointer which can be used to unuquely identify the entry. + The MenomonicEngine itself does not use this value, it + is only passed to other methods of this callback interface. + + If this value is <NULL/>, searching stops. + */ + virtual const void* FirstSearchEntry( String& _rEntryText ) const = 0; + + /** returns the next list entry for the mnemonic search + + @return + a pointer which can be used to unuquely identify the entry. + The MenomonicEngine itself does not use this value, it + is only passed to other methods of this callback interface. + + If this value is <NULL/>, searching stops. + + If this value is the same as returned by the previous call + to <member>FirstSearchEntry</member> (i.e. you cycled + around), then searching stops, too. + */ + virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, String& _rEntryText ) const = 0; + + /** "selects" a given entry. + + Note: The semantics of "select" depends on your implementation. You + might actually really select the entry (in the sense of a selected + list box entry, for example), you might make it the current entry, + if your implementation supports this - whatever. + + @param _pEntry + the entry to select. This is the return value of a previous call + to <member>FirstSearchEntry</member> or <member>NextSearchEntry</member>. + */ + virtual void SelectSearchEntry( const void* _pEntry ) = 0; + + /** "executes" the current search entry, i.e. the one returned + in the previous <member>NextSearchEntry</member> call. + + Note: The semantics of "execute" depends on your implementation. You + might even have a list of entries which cannot be executed at all. + + This method is called after <member>SelectSearchEntry</member>, + if and only if the current entry's mnemonic is unambiguous. + + For instance, imagine a list which has two entries with the same mnemonic + character, say "c". Now if the user presses <code>Alt-C</code>, the MnemonicEngine + will call <member>SelectCurrentEntry</member> as soon as it encounters + the first entry, but it'll never call <member>ExecuteSearchEntry</member>. + + If, however, "c" is a unique mnemonic character in your entry list, then the + call of <member>SelectSearchEntry</member> will be followed by a + call to <member>ExecuteSearchEntry</member>. + + This way, you can implement cyclic selection of entries: In + <member>FirstSearchEntry</member>, return the entry which was previously + selected, and in <member>NextSearchEntry</member>, interlly cycle around + in your list. Then, multiple user inputs of <code>Alt-C</code> will + cycle through all entries with the mnemonic being "c". + + @param _pEntry + the entry to select. This is the return value of a previous call + to <member>FirstSearchEntry</member> or <member>NextSearchEntry</member>. + */ + virtual void ExecuteSearchEntry( const void* _pEntry ) const = 0; + }; + + //==================================================================== + //= MnemonicEngine + //==================================================================== + struct MnemonicEngine_Data; + class VCL_DLLPUBLIC MnemonicEngine + { + ::std::auto_ptr< MnemonicEngine_Data > m_pData; + + public: + MnemonicEngine( IMnemonicEntryList& _rEntryList ); + ~MnemonicEngine(); + + /** handles a key event + + If the key event denotes pressing an accelerator key, then the + entry list is searched for a matching entry. If such an entry is + found, <member>IMnemonicEntryList::SelectSearchEntry</member> + is called. + + If the entry is the only one with the given mnemonic character, then + also <member>IMnemonicEntryList::ExecuteSearchEntry</member> + is called. + + @return + if the key event has been handled, and should thus not be processed + further. + */ + bool HandleKeyEvent( const KeyEvent& _rKEvt ); + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_MNEMONICENGINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/morebtn.hxx b/vcl/inc/vcl/morebtn.hxx new file mode 100644 index 000000000000..e84798479d7f --- /dev/null +++ b/vcl/inc/vcl/morebtn.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MOREBTN_HXX +#define _SV_MOREBTN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/mapmod.hxx> +#include <vcl/button.hxx> + +struct ImplMoreButtonData; + +// -------------- +// - MoreButton - +// -------------- + +class VCL_DLLPUBLIC MoreButton : public PushButton +{ +private: + ImplMoreButtonData* mpMBData; + sal_uLong mnDelta; + MapUnit meUnit; + sal_Bool mbState; + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE MoreButton( const MoreButton & ); + SAL_DLLPRIVATE MoreButton& operator=( const MoreButton & ); + SAL_DLLPRIVATE void ShowState(); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + +public: + MoreButton( Window* pParent, WinBits nStyle = 0 ); + MoreButton( Window* pParent, const ResId& rResId ); + ~MoreButton(); + + void Click(); + + void AddWindow( Window* pWindow ); + void RemoveWindow( Window* pWindow ); + + void SetDelta( sal_uLong nNewDelta ) { mnDelta = nNewDelta; } + sal_uLong GetDelta() const { return mnDelta; } + + void SetMapUnit( MapUnit eNewUnit = MAP_PIXEL ) { meUnit = eNewUnit; } + MapUnit GetMapUnit() const { return meUnit; } + + using PushButton::SetState; + void SetState( sal_Bool bNewState = sal_True ); + sal_Bool GetState() const { return mbState; } + + void SetText( const XubString& rNewText ); + XubString GetText() const; + + void SetMoreText( const XubString& rNewText ); + void SetLessText( const XubString& rNewText ); + XubString GetMoreText() const; + XubString GetLessText() const; +}; + +inline void MoreButton::SetState( sal_Bool bNewState ) +{ + if ( mbState != bNewState ) + Click(); +} + +#endif // _SV_MOREBTN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/msgbox.hxx b/vcl/inc/vcl/msgbox.hxx new file mode 100644 index 000000000000..326dae5616e3 --- /dev/null +++ b/vcl/inc/vcl/msgbox.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_MSGBOX_HXX +#define _SV_MSGBOX_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/btndlg.hxx> +#include <vcl/image.hxx> +#include <vcl/bitmap.hxx> +class FixedText; +class FixedImage; +class CheckBox; + +// ----------------- +// - MessBox-Types - +// ----------------- + +// Return-Werte von Execute +//!!! bei Aenderungen \basic\source\runtime\methods.cxx msgbox anpassen + +#define RET_OK sal_True +#define RET_CANCEL sal_False +#define RET_YES 2 +#define RET_NO 3 +#define RET_RETRY 4 +#define RET_IGNORE 5 + +#define BUTTONID_OK RET_OK +#define BUTTONID_CANCEL RET_CANCEL +#define BUTTONID_YES RET_YES +#define BUTTONID_NO RET_NO +#define BUTTONID_RETRY RET_RETRY +#define BUTTONID_IGNORE RET_IGNORE +#define BUTTONID_HELP 10 + +// ----------- +// - MessBox - +// ----------- + +class VCL_DLLPUBLIC MessBox : public ButtonDialog +{ +protected: + FixedText* mpFixedText; + FixedImage* mpFixedImage; + XubString maMessText; + Image maImage; + sal_uInt16 mnSoundType; + sal_Bool mbHelpBtn; + sal_Bool mbSound; + CheckBox* mpCheckBox; + XubString maCheckBoxText; + sal_Bool mbCheck; + + SAL_DLLPRIVATE void ImplInitMessBoxData(); + SAL_DLLPRIVATE void ImplInitButtons(); + SAL_DLLPRIVATE void ImplPosControls(); + +protected: + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + MessBox( WindowType nType ); + +public: + MessBox( Window* pParent, WinBits nStyle, + const XubString& rTitle, const XubString& rMessage ); + MessBox( Window* pParent, const ResId& rResId ); + ~MessBox(); + + virtual void StateChanged( StateChangedType nStateChange ); + + void SetMessText( const XubString& rText ) { maMessText = rText; } + const XubString& GetMessText() const { return maMessText; } + + void SetImage( const Image& rImage ) { maImage = rImage; } + const Image& GetImage() const { return maImage; } + + sal_Bool SetModeImage( const Image& rImage ); + const Image& GetModeImage( ) const; + + void SetDefaultCheckBoxText(); + void SetCheckBoxText( const XubString& rText ) { maCheckBoxText = rText;} + const XubString& GetCheckBoxText() const { return maCheckBoxText;} + void SetCheckBoxState( sal_Bool bCheck ); + sal_Bool GetCheckBoxState() const; + + virtual Size GetOptimalSize(WindowSizeType eType) const; +}; + +// ----------- +// - InfoBox - +// ----------- + +class VCL_DLLPUBLIC InfoBox : public MessBox +{ +private: + SAL_DLLPRIVATE void ImplInitInfoBoxData(); + +public: + InfoBox( Window* pParent, const XubString& rMessage ); + InfoBox( Window* pParent, const ResId & rResId ); + + static Image GetStandardImage(); +}; + +// -------------- +// - WarningBox - +// -------------- + +class VCL_DLLPUBLIC WarningBox : public MessBox +{ +private: + SAL_DLLPRIVATE void ImplInitWarningBoxData(); + +public: + WarningBox( Window* pParent, WinBits nStyle, + const XubString& rMessage ); + WarningBox( Window* pParent, const ResId& rResId ); + + void SetDefaultCheckBoxText(); + + static Image GetStandardImage(); +}; + +// ------------ +// - ErrorBox - +// ------------ + +class VCL_DLLPUBLIC ErrorBox : public MessBox +{ +private: + SAL_DLLPRIVATE void ImplInitErrorBoxData(); + +public: + ErrorBox( Window* pParent, WinBits nStyle, + const XubString& rMessage ); + ErrorBox( Window* pParent, const ResId& rResId ); + + static Image GetStandardImage(); +}; + +// ------------ +// - QueryBox - +// ------------ + +class VCL_DLLPUBLIC QueryBox : public MessBox +{ +private: + SAL_DLLPRIVATE void ImplInitQueryBoxData(); + +public: + QueryBox( Window* pParent, WinBits nStyle, + const XubString& rMessage ); + QueryBox( Window* pParent, const ResId& rResId ); + + void SetDefaultCheckBoxText(); + + static Image GetStandardImage(); +}; + +#endif // _SV_MSGBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/octree.hxx b/vcl/inc/vcl/octree.hxx new file mode 100644 index 000000000000..3cef6384a7d6 --- /dev/null +++ b/vcl/inc/vcl/octree.hxx @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_OCTREE_HXX +#define _SV_OCTREE_HXX + +#include <vcl/salbtype.hxx> +#include <vcl/dllapi.h> + +// ----------- +// - Defines - +// ----------- + +#define OCTREE_BITS 5 +#define OCTREE_BITS_1 10 + +// -------------- +// - OctreeNode - +// -------------- + +typedef struct OctreeNode +{ + sal_uLong nCount; + sal_uLong nRed; + sal_uLong nGreen; + sal_uLong nBlue; + OctreeNode* pChild[ 8 ]; + OctreeNode* pNext; + OctreeNode* pNextInCache; + sal_uInt16 nPalIndex; + sal_Bool bLeaf; +} NODE; + +typedef NODE* PNODE; +typedef PNODE* PPNODE; + +// ---------- +// - Octree - +// ---------- + +class ImpNodeCache; +class BitmapReadAccess; + +class VCL_PLUGIN_PUBLIC Octree +{ +private: + + BitmapPalette aPal; + sal_uLong nMax; + sal_uLong nLeafCount; + sal_uLong nLevel; + PNODE pTree; + PNODE pReduce[ OCTREE_BITS + 1 ]; + BitmapColor* pColor; + ImpNodeCache* pNodeCache; + const BitmapReadAccess* pAcc; + sal_uInt16 nPalIndex; + + Octree() {}; + + void CreatePalette( PNODE pNode ); + void GetPalIndex( PNODE pNode ); + + SAL_DLLPRIVATE void ImplCreateOctree(); + SAL_DLLPRIVATE void ImplDeleteOctree( PPNODE ppNode ); + SAL_DLLPRIVATE void ImplAdd( PPNODE ppNode ); + SAL_DLLPRIVATE void ImplReduce(); + +public: + + Octree( const BitmapReadAccess& rReadAcc, sal_uLong nColors ); + Octree( sal_uLong nColors ); + ~Octree(); + + void AddColor( const BitmapColor& rColor ); + + inline const BitmapPalette& GetPalette(); + inline sal_uInt16 GetBestPaletteIndex( const BitmapColor& rColor ); +}; + +// ------------------------------------------------------------------------ + +inline const BitmapPalette& Octree::GetPalette() +{ + aPal.SetEntryCount( (sal_uInt16) nLeafCount ); + nPalIndex = 0; + CreatePalette( pTree ); + return aPal; +} + +// ------------------------------------------------------------------------ + +inline sal_uInt16 Octree::GetBestPaletteIndex( const BitmapColor& rColor ) +{ + pColor = &(BitmapColor&) rColor; + nPalIndex = 65535; + nLevel = 0L; + GetPalIndex( pTree ); + return nPalIndex; +} + +// ------------------- +// - InverseColorMap - +// ------------------- + +class VCL_PLUGIN_PUBLIC InverseColorMap +{ +private: + + sal_uInt8* pBuffer; + sal_uInt8* pMap; + const sal_uLong nBits; + + + SAL_DLLPRIVATE void ImplCreateBuffers( const sal_uLong nMax ); + +public: + + explicit InverseColorMap( const BitmapPalette& rPal ); + ~InverseColorMap(); + + inline sal_uInt16 GetBestPaletteIndex( const BitmapColor& rColor ); +}; + +// ------------------------------------------------------------------------ + +inline sal_uInt16 InverseColorMap::GetBestPaletteIndex( const BitmapColor& rColor ) +{ + return pMap[ ( ( (sal_uLong) rColor.GetRed() >> nBits ) << OCTREE_BITS_1 ) | + ( ( (sal_uLong) rColor.GetGreen() >> nBits ) << OCTREE_BITS ) | + ( (sal_uLong) rColor.GetBlue() >> nBits ) ]; +} + +#endif // _SV_OCTREE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/oldprintadaptor.hxx b/vcl/inc/vcl/oldprintadaptor.hxx new file mode 100644 index 000000000000..1a6705b42cb8 --- /dev/null +++ b/vcl/inc/vcl/oldprintadaptor.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * 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 PrinterController + { + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/outdata.hxx b/vcl/inc/vcl/outdata.hxx new file mode 100644 index 000000000000..2f4a9b5ed7aa --- /dev/null +++ b/vcl/inc/vcl/outdata.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_OUTDATA_HXX +#define _SV_OUTDATA_HXX + +#include <vcl/sv.h> +#include <tools/color.hxx> +#include <vcl/salgtype.hxx> + +// ----------------- +// - Hilfemethoden - +// ----------------- + +inline SalColor ImplColorToSal( Color aColor ) +{ + return MAKE_SALCOLOR( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() ); +} + +inline int ImplIsColorTransparent( Color aColor ) +{ + return aColor.GetTransparency(); +} + +#endif // _SV_OUTDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/outdev.h b/vcl/inc/vcl/outdev.h new file mode 100644 index 000000000000..fc6bab815c48 --- /dev/null +++ b/vcl/inc/vcl/outdev.h @@ -0,0 +1,267 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_OUTDEV_H +#define _SV_OUTDEV_H + +#include <tools/solar.h> +#include <vcl/outfont.hxx> + +#include <vector> +#include <list> +#include <set> + +class Size; +class Font; +class VirtualDevice; +class ImplServerGraphics; +class ImplGetDevFontList; +class GetDevSizeList; + +// ----------------------- +// - ImplDevFontListData - +// ----------------------- + +// flags for mnMatchType member +#define IMPL_DEVFONT_SCALABLE ((sal_uIntPtr)0x00000001) +#define IMPL_DEVFONT_SYMBOL ((sal_uIntPtr)0x00000002) +#define IMPL_DEVFONT_NONESYMBOL ((sal_uIntPtr)0x00000004) +#define IMPL_DEVFONT_LIGHT ((sal_uIntPtr)0x00000010) +#define IMPL_DEVFONT_BOLD ((sal_uIntPtr)0x00000020) +#define IMPL_DEVFONT_NORMAL ((sal_uIntPtr)0x00000040) +#define IMPL_DEVFONT_NONEITALIC ((sal_uIntPtr)0x00000100) +#define IMPL_DEVFONT_ITALIC ((sal_uIntPtr)0x00000200) + +// TODO: rename ImplDevFontListData to PhysicalFontFamily +class ImplDevFontListData +{ +public: + ImplDevFontListData( const String& rSearchName ); + ~ImplDevFontListData(); + + const String& GetFamilyName() const { return maName; } + const String& GetSearchName() const { return maSearchName; } + const String& GetAliasNames() const { return maMapNames; } + bool IsScalable() const { return mpFirst->IsScalable(); } + int GetMinQuality() const { return mnMinQuality; } + + bool AddFontFace( ImplFontData* ); + void InitMatchData( const utl::FontSubstConfiguration&, + const String& rSearchName ); + ImplFontData* FindBestFontFace( const ImplFontSelectData& rFSD ) const; + + void GetFontHeights( std::set<int>& rHeights ) const; + void UpdateDevFontList( ImplGetDevFontList& ) const; + void UpdateCloneFontList( ImplDevFontList&, + bool bScalable, bool bEmbeddable ) const; + +private: +friend class ImplDevFontList; // TODO: remove soon + ImplFontData* mpFirst; // linked list of physical font faces + String maName; // Fontname (original font family name) + String maSearchName; // normalized font family name + String maMapNames; // fontname aliases + sal_uIntPtr mnTypeFaces; // Typeface Flags + sal_uIntPtr mnMatchType; // MATCH - Type + String maMatchFamilyName; // MATCH - FamilyName + FontWeight meMatchWeight; // MATCH - Weight + FontWidth meMatchWidth; // MATCH - Width + FontFamily meFamily; + FontPitch mePitch; + int mnMinQuality; // quality of the worst font face +}; + + +// ---------------------- +// - ImplGetDevFontList - +// ---------------------- + +// an ImplGetDevFontList is created by an ImplDevFontList +// it becomes invalid when original ImplDevFontList is modified +class ImplGetDevFontList +{ +private: + std::vector<ImplFontData*> maDevFontVector; + +public: + ImplGetDevFontList() { maDevFontVector.reserve(1024); } + void Add( ImplFontData* pFace ) { maDevFontVector.push_back( pFace ); } + ImplFontData* Get( int nIndex ) const { return maDevFontVector[ nIndex ]; } + int Count() const { return maDevFontVector.size(); } +}; + +// ---------------------- +// - ImplGetDevSizeList - +// ---------------------- + +class ImplGetDevSizeList +{ +private: + String maFontName; + std::vector<int> maSizeList; + +public: + ImplGetDevSizeList( const String& rFontName ) + : maFontName( rFontName ) { maSizeList.reserve( 32 ); } + void Add( int nHeight ) { maSizeList.push_back( nHeight ); } + int Count() const { return maSizeList.size(); } + int Get( int nIndex ) const { return maSizeList[ nIndex ]; } + const String& GetFontName() const { return maFontName; } +}; + +// ------------------------ +// - ImplFontSubstitution - +// ------------------------ +// nowadays these substitutions are needed for backward compatibility and tight platform integration: +// - substitutions from configuration entries (Tools->Options->FontReplacement and/or fontconfig) +// - device specific substitutions (e.g. for PS printer builtin fonts) +// - substitutions for missing fonts defined by configuration entries (generic and/or platform dependent fallbacks) +// - substitutions for missing fonts defined by multi-token fontnames (e.g. fontname="SpecialFont;FallbackA;FallbackB") +// - substitutions for incomplete fonts (implicit, generic, EUDC and/or platform dependent fallbacks) +// - substitutions for missing symbol fonts by translating code points into other symbol fonts + +class ImplFontSubstitution +{ + // TODO: there is more commonality between the different substitutions +protected: + virtual ~ImplFontSubstitution() {} +}; + +// ImplDirectFontSubstitution is for Tools->Options->FontReplacement and PsPrinter substitutions +// The clss is just a simple port of the unmaintainable manual-linked-list based mechanism +// TODO: get rid of this class when the Tools->Options->FontReplacement tabpage is gone for good + +struct ImplFontSubstEntry +{ + String maName; + String maReplaceName; + String maSearchName; + String maSearchReplaceName; + sal_uInt16 mnFlags; + + ImplFontSubstEntry( const String& rFontName, const String& rSubstFontName, sal_uInt16 nSubstFlags ); +}; + +class ImplDirectFontSubstitution +: public ImplFontSubstitution +{ +private: + typedef std::list<ImplFontSubstEntry> FontSubstList; + FontSubstList maFontSubstList; +public: + void AddFontSubstitute( const String& rFontName, const String& rSubstName, sal_uInt16 nFlags ); + void RemoveFontSubstitute( int nIndex ); + bool GetFontSubstitute( int nIndex, String& rFontName, String& rSubstName, sal_uInt16& rFlags ) const; + int GetFontSubstituteCount() const { return maFontSubstList.size(); }; + bool Empty() const { return maFontSubstList.empty(); } + void Clear() { maFontSubstList.clear(); } + + bool FindFontSubstitute( String& rSubstName, const String& rFontName, sal_uInt16 nFlags ) const; +}; + +// PreMatchFontSubstitution +// abstracts the concept of a configured font substitution +// before the availability of the originally selected font has been checked +class ImplPreMatchFontSubstitution +: public ImplFontSubstitution +{ +public: + virtual bool FindFontSubstitute( ImplFontSelectData& ) const = 0; +}; + +// ImplGlyphFallbackFontSubstitution +// abstracts the concept of finding the best font to support an incomplete font +class ImplGlyphFallbackFontSubstitution +: public ImplFontSubstitution +{ +public: + virtual bool FindFontSubstitute( ImplFontSelectData&, rtl::OUString& rMissingCodes ) const = 0; +}; + +// ----------------- +// - ImplFontCache - +// ----------------- +// TODO: closely couple with ImplDevFontList + +class ImplFontCache +{ +private: + ImplFontEntry* mpFirstEntry; + int mnRef0Count; // number of unreferenced ImplFontEntries + bool mbPrinter; + + // cache of recently used font instances + struct IFSD_Equal { bool operator()( const ImplFontSelectData&, const ImplFontSelectData& ) const; }; + struct IFSD_Hash { size_t operator()( const ImplFontSelectData& ) const; }; + typedef ::boost::unordered_map<ImplFontSelectData,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList; + FontInstanceList maFontInstanceList; + + // cache of recently requested font names vs. selected font names + typedef ::boost::unordered_map<String,String,FontNameHash> FontNameList; + FontNameList maFontNameList; + +public: + ImplFontCache( bool bPrinter ); + ~ImplFontCache(); + + ImplFontEntry* GetFontEntry( ImplDevFontList*, + const Font&, const Size& rPixelSize, float fExactHeight, + ImplDirectFontSubstitution* pDevSpecific ); + ImplFontEntry* GetFontEntry( ImplDevFontList*, + ImplFontSelectData&, ImplDirectFontSubstitution* pDevSpecific ); + ImplFontEntry* GetGlyphFallbackFont( ImplDevFontList*, ImplFontSelectData&, + int nFallbackLevel, rtl::OUString& rMissingCodes ); + void Release( ImplFontEntry* ); + void Invalidate(); +}; + +// ------------------ +// - ImplOutDevData - +// ------------------ + +namespace vcl { struct ControlLayoutData; } +// #i75163# +namespace basegfx { class B2DHomMatrix; } + +struct ImplOutDevData +{ + VirtualDevice* mpRotateDev; + vcl::ControlLayoutData* mpRecordLayout; + Rectangle maRecordRect; + ImplDirectFontSubstitution maDevFontSubst; + + // #i75163# + basegfx::B2DHomMatrix* mpViewTransform; + basegfx::B2DHomMatrix* mpInverseViewTransform; +}; + +void ImplFreeOutDevFontData(); + +#endif // _SV_OUTDEV_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx new file mode 100644 index 000000000000..e6aaec2c9971 --- /dev/null +++ b/vcl/inc/vcl/outdev.hxx @@ -0,0 +1,1239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_OUTDEV_HXX +#define _SV_OUTDEV_HXX + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/rc.hxx> +#include <tools/color.hxx> +#include <vcl/font.hxx> +#include <vcl/region.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/wall.hxx> +#include <vcl/settings.hxx> +#include <vcl/salnativewidgets.hxx> +#include <tools/poly.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <com/sun/star/uno/Reference.h> +#include <unotools/fontdefs.hxx> + +#include <vector> + +struct ImplOutDevData; +class ImplFontEntry; +struct ImplObjStack; +struct ImplKernPairData; +struct SystemGraphicsData; +struct SystemFontData; +struct SystemTextLayoutData; +class ImplFontCache; +class ImplDevFontList; +class ImplGetDevFontList; +class ImplGetDevSizeList; +class ImplMultiTextLineInfo; +class SalGraphics; +class Gradient; +class Hatch; +class Bitmap; +class BitmapReadAccess; +class BitmapEx; +class Image; +class TextRectInfo; +class FontInfo; +class FontMetric; +class GDIMetaFile; +class List; +class GfxLink; +class Line; +class LineInfo; +class AlphaMask; +class FontCharMap; +class SalLayout; +class ImplLayoutArgs; +class ImplFontAttributes; +class VirtualDevice; + +namespace com { +namespace sun { +namespace star { +namespace rendering { + class XCanvas; +}}}} +namespace basegfx { + class B2DHomMatrix; + class B2DPolygon; + class B2DPolyPolygon; + typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector; +} + +namespace com { +namespace sun { +namespace star { +namespace awt { + class XGraphics; +} } } } + +typedef std::vector< Rectangle > MetricVector; + +namespace vcl +{ + class PDFWriterImpl; + class ExtOutDevData; + class ITextLayout; + struct FontCapabilities; +} + +#define OUTDEV_BUFFER_SIZE 128 + + +// --------------------- +// - OutputDevice-Data - +// --------------------- + +struct ImplMapRes +{ + long mnMapOfsX; // Offset in X Richtung + long mnMapOfsY; // Offset in Y Richtung + long mnMapScNumX; // Skal.-faktor Zaehler X Richtung + long mnMapScNumY; // Skal.-faktor Zaehler Y Richtung + long mnMapScDenomX; // Skal.-faktor Nenner X Richtung + long mnMapScDenomY; // Skal.-faktor Nenner Y Richtung +}; + +struct ImplThresholdRes +{ + long mnThresLogToPixX; // Schwellenwerte fuer Berechnung + long mnThresLogToPixY; // mit BigInts + long mnThresPixToLogX; // "" + long mnThresPixToLogY; // "" +}; + +// --------------- +// - KerningPair - +// --------------- + +struct KerningPair +{ + sal_Unicode nChar1; + sal_Unicode nChar2; + long nKern; +}; + +// ---------------------- +// - OutputDevice-Types - +// ---------------------- + +// Flags for Push() +#define PUSH_LINECOLOR ((sal_uInt16)0x0001) +#define PUSH_FILLCOLOR ((sal_uInt16)0x0002) +#define PUSH_FONT ((sal_uInt16)0x0004) +#define PUSH_TEXTCOLOR ((sal_uInt16)0x0008) +#define PUSH_MAPMODE ((sal_uInt16)0x0010) +#define PUSH_CLIPREGION ((sal_uInt16)0x0020) +#define PUSH_RASTEROP ((sal_uInt16)0x0040) +#define PUSH_TEXTFILLCOLOR ((sal_uInt16)0x0080) +#define PUSH_TEXTALIGN ((sal_uInt16)0x0100) +#define PUSH_REFPOINT ((sal_uInt16)0x0200) +#define PUSH_TEXTLINECOLOR ((sal_uInt16)0x0400) +#define PUSH_TEXTLAYOUTMODE ((sal_uInt16)0x0800) +#define PUSH_TEXTLANGUAGE ((sal_uInt16)0x1000) +#define PUSH_OVERLINECOLOR ((sal_uInt16)0x2000) +#define PUSH_ALLTEXT (PUSH_TEXTCOLOR | PUSH_TEXTFILLCOLOR | PUSH_TEXTLINECOLOR | PUSH_OVERLINECOLOR | PUSH_TEXTALIGN | PUSH_TEXTLAYOUTMODE | PUSH_TEXTLANGUAGE) +#define PUSH_ALLFONT (PUSH_ALLTEXT | PUSH_FONT) +#define PUSH_ALL ((sal_uInt16)0xFFFF) + +// Flags for DrawText() +#define TEXT_DRAW_DISABLE ((sal_uInt16)0x0001) +#define TEXT_DRAW_MNEMONIC ((sal_uInt16)0x0002) +#define TEXT_DRAW_MONO ((sal_uInt16)0x0004) +#define TEXT_DRAW_CLIP ((sal_uInt16)0x0008) +#define TEXT_DRAW_LEFT ((sal_uInt16)0x0010) +#define TEXT_DRAW_CENTER ((sal_uInt16)0x0020) +#define TEXT_DRAW_RIGHT ((sal_uInt16)0x0040) +#define TEXT_DRAW_TOP ((sal_uInt16)0x0080) +#define TEXT_DRAW_VCENTER ((sal_uInt16)0x0100) +#define TEXT_DRAW_BOTTOM ((sal_uInt16)0x0200) +#define TEXT_DRAW_ENDELLIPSIS ((sal_uInt16)0x0400) +#define TEXT_DRAW_PATHELLIPSIS ((sal_uInt16)0x0800) +#define TEXT_DRAW_MULTILINE ((sal_uInt16)0x1000) +#define TEXT_DRAW_WORDBREAK ((sal_uInt16)0x2000) +#define TEXT_DRAW_NEWSELLIPSIS ((sal_uInt16)0x4000) +// in the long run we should make text style flags longer +// but at the moment we can get away with this 2 bit field for ellipsis style +#define TEXT_DRAW_CENTERELLIPSIS (TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_PATHELLIPSIS) + +#define TEXT_DRAW_WORDBREAK_HYPHENATION (((sal_uInt16)0x8000) | TEXT_DRAW_WORDBREAK) + +// Flags for CopyArea() +#define COPYAREA_WINDOWINVALIDATE ((sal_uInt16)0x0001) + +// Flags for DrawImage() +#define IMAGE_DRAW_DISABLE ((sal_uInt16)0x0001) +#define IMAGE_DRAW_HIGHLIGHT ((sal_uInt16)0x0002) +#define IMAGE_DRAW_DEACTIVE ((sal_uInt16)0x0004) +#define IMAGE_DRAW_COLORTRANSFORM ((sal_uInt16)0x0008) +#define IMAGE_DRAW_SEMITRANSPARENT ((sal_uInt16)0x0010) +#define IMAGE_DRAW_3DLOOK 0 +#define IMAGE_DRAW_BTNLOOK 0 + +// WaveLine +#define WAVE_FLAT 1 +#define WAVE_SMALL 2 +#define WAVE_NORMAL 3 + +// Grid +#define GRID_DOTS ((sal_uLong)0x00000001) +#define GRID_HORZLINES ((sal_uLong)0x00000002) +#define GRID_VERTLINES ((sal_uLong)0x00000004) +#define GRID_LINES (GRID_HORZLINES | GRID_VERTLINES) + +// LayoutModes for Complex Text Layout +#define TEXT_LAYOUT_DEFAULT ((sal_uLong)0x00000000) +#define TEXT_LAYOUT_BIDI_LTR ((sal_uLong)0x00000000) +#define TEXT_LAYOUT_BIDI_RTL ((sal_uLong)0x00000001) +#define TEXT_LAYOUT_BIDI_STRONG ((sal_uLong)0x00000002) +#define TEXT_LAYOUT_TEXTORIGIN_LEFT ((sal_uLong)0x00000004) +#define TEXT_LAYOUT_TEXTORIGIN_RIGHT ((sal_uLong)0x00000008) +#define TEXT_LAYOUT_COMPLEX_DISABLED ((sal_uLong)0x00000100) +#define TEXT_LAYOUT_ENABLE_LIGATURES ((sal_uLong)0x00000200) +#define TEXT_LAYOUT_SUBSTITUTE_DIGITS ((sal_uLong)0x00000400) + +// DrawModes +#define DRAWMODE_DEFAULT ((sal_uLong)0x00000000) +#define DRAWMODE_BLACKLINE ((sal_uLong)0x00000001) +#define DRAWMODE_BLACKFILL ((sal_uLong)0x00000002) +#define DRAWMODE_BLACKTEXT ((sal_uLong)0x00000004) +#define DRAWMODE_BLACKBITMAP ((sal_uLong)0x00000008) +#define DRAWMODE_BLACKGRADIENT ((sal_uLong)0x00000010) +#define DRAWMODE_GRAYLINE ((sal_uLong)0x00000020) +#define DRAWMODE_GRAYFILL ((sal_uLong)0x00000040) +#define DRAWMODE_GRAYTEXT ((sal_uLong)0x00000080) +#define DRAWMODE_GRAYBITMAP ((sal_uLong)0x00000100) +#define DRAWMODE_GRAYGRADIENT ((sal_uLong)0x00000200) +#define DRAWMODE_NOFILL ((sal_uLong)0x00000400) +#define DRAWMODE_NOBITMAP ((sal_uLong)0x00000800) +#define DRAWMODE_NOGRADIENT ((sal_uLong)0x00001000) +#define DRAWMODE_GHOSTEDLINE ((sal_uLong)0x00002000) +#define DRAWMODE_GHOSTEDFILL ((sal_uLong)0x00004000) +#define DRAWMODE_GHOSTEDTEXT ((sal_uLong)0x00008000) +#define DRAWMODE_GHOSTEDBITMAP ((sal_uLong)0x00010000) +#define DRAWMODE_GHOSTEDGRADIENT ((sal_uLong)0x00020000) +#define DRAWMODE_WHITELINE ((sal_uLong)0x00100000) +#define DRAWMODE_WHITEFILL ((sal_uLong)0x00200000) +#define DRAWMODE_WHITETEXT ((sal_uLong)0x00400000) +#define DRAWMODE_WHITEBITMAP ((sal_uLong)0x00800000) +#define DRAWMODE_WHITEGRADIENT ((sal_uLong)0x01000000) +#define DRAWMODE_SETTINGSLINE ((sal_uLong)0x02000000) +#define DRAWMODE_SETTINGSFILL ((sal_uLong)0x04000000) +#define DRAWMODE_SETTINGSTEXT ((sal_uLong)0x08000000) +#define DRAWMODE_SETTINGSGRADIENT ((sal_uLong)0x10000000) +#define DRAWMODE_NOTRANSPARENCY ((sal_uLong)0x80000000) + +// Antialiasing +#define ANTIALIASING_DISABLE_TEXT ((sal_uInt16)0x0001) +#define ANTIALIASING_ENABLE_B2DDRAW ((sal_uInt16)0x0002) +#define ANTIALIASING_PIXELSNAPHAIRLINE ((sal_uInt16)0x0004) + +// AddFontSubstitute +#define FONT_SUBSTITUTE_ALWAYS ((sal_uInt16)0x0001) +#define FONT_SUBSTITUTE_SCREENONLY ((sal_uInt16)0x0002) + +#define DEFAULTFONT_FLAGS_ONLYONE ((sal_uLong)0x00000001) + +enum OutDevType { OUTDEV_DONTKNOW, OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV }; + +enum OutDevViewType { OUTDEV_VIEWTYPE_DONTKNOW, OUTDEV_VIEWTYPE_PRINTPREVIEW, OUTDEV_VIEWTYPE_SLIDESHOW }; + +// ---------------- +// - OutputDevice - +// ---------------- + +class VirtualDevice; +class Printer; +class ImplFontSelectData; +class ImplFontMetricData; + +const char* ImplDbgCheckOutputDevice( const void* pObj ); + +class VCL_DLLPUBLIC OutputDevice : public Resource +{ + friend class Application; + friend class Bitmap; + friend class ImplImageBmp; + friend class ImplQPrinter; + friend class Printer; + friend class SalGraphicsLayout; + friend class System; + friend class VirtualDevice; + friend class Window; + friend class WorkWindow; + friend class vcl::PDFWriterImpl; + friend const char* ImplDbgCheckOutputDevice( const void* pObj ); + friend void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight ); + +private: + mutable SalGraphics* mpGraphics; + mutable OutputDevice* mpPrevGraphics; + mutable OutputDevice* mpNextGraphics; + GDIMetaFile* mpMetaFile; + mutable ImplFontEntry* mpFontEntry; + mutable ImplFontCache* mpFontCache; + mutable ImplDevFontList* mpFontList; + mutable ImplGetDevFontList* mpGetDevFontList; + mutable ImplGetDevSizeList* mpGetDevSizeList; + ImplObjStack* mpObjStack; + ImplOutDevData* mpOutDevData; + List* mpUnoGraphicsList; + vcl::PDFWriterImpl* mpPDFWriter; + vcl::ExtOutDevData* mpExtOutDevData; + + // TEMP TEMP TEMP + VirtualDevice* mpAlphaVDev; + + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + long mnOutOffOrigX; + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + long mnOutOffLogicX; + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + long mnOutOffOrigY; + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + long mnOutOffLogicY; + /// Output offset for device output in pixel (pseudo window offset within window system's frames) + long mnOutOffX; + /// Output offset for device output in pixel (pseudo window offset within window system's frames) + long mnOutOffY; + long mnOutWidth; + long mnOutHeight; + sal_Int32 mnDPIX; + sal_Int32 mnDPIY; + /// font specific text alignment offsets in pixel units + mutable long mnTextOffX; + mutable long mnTextOffY; + mutable long mnEmphasisAscent; + mutable long mnEmphasisDescent; + sal_uLong mnDrawMode; + sal_uLong mnTextLayoutMode; + ImplMapRes maMapRes; + ImplThresholdRes maThresRes; + OutDevType meOutDevType; + OutDevViewType meOutDevViewType; + Region maRegion; // contains the clip region, see SetClipRegion(...) + Color maLineColor; + Color maFillColor; + Font maFont; + Color maTextColor; + Color maTextLineColor; + Color maOverlineColor; + TextAlign meTextAlign; + RasterOp meRasterOp; + Wallpaper maBackground; + AllSettings maSettings; + MapMode maMapMode; + Point maRefPoint; + sal_uInt16 mnAntialiasing; + LanguageType meTextLanguage; + mutable sal_Bool mbMap:1, + mbMapIsDefault:1, + mbClipRegion:1, + mbBackground:1, + mbOutput:1, + mbDevOutput:1, + mbOutputClipped:1, + mbLineColor:1, + mbFillColor:1, + mbInitLineColor:1, + mbInitFillColor:1, + mbInitFont:1, + mbInitTextColor:1, + mbInitClipRegion:1, + mbClipRegionSet:1, + mbKerning:1, + mbNewFont:1, + mbTextLines:1, + mbTextSpecial:1, + mbRefPoint:1, + mbEnableRTL:1; + +public: + SAL_DLLPRIVATE sal_Int32 ImplGetDPIX() const { return mnDPIX; } + SAL_DLLPRIVATE sal_Int32 ImplGetDPIY() const { return mnDPIY; } + SAL_DLLPRIVATE int ImplGetGraphics() const; + SAL_DLLPRIVATE void ImplReleaseGraphics( sal_Bool bRelease = sal_True ); + SAL_DLLPRIVATE sal_Bool ImplHasMirroredGraphics(); + SAL_DLLPRIVATE void ImplReMirror( Point &rPoint ) const; + SAL_DLLPRIVATE void ImplReMirror( Rectangle &rRect ) const; + SAL_DLLPRIVATE void ImplReMirror( Region &rRegion ) const; + SAL_DLLPRIVATE void ImplInitOutDevData(); + SAL_DLLPRIVATE void ImplDeInitOutDevData(); + SAL_DLLPRIVATE void ImplInitLineColor(); + SAL_DLLPRIVATE void ImplInitFillColor(); + SAL_DLLPRIVATE bool ImplNewFont() const; + SAL_DLLPRIVATE void ImplInitFont() const; + SAL_DLLPRIVATE void ImplInitTextColor(); + SAL_DLLPRIVATE void ImplInitClipRegion(); + SAL_DLLPRIVATE bool ImplSelectClipRegion( const Region&, SalGraphics* pGraphics = NULL ); + SAL_DLLPRIVATE void ImplSetClipRegion( const Region* pRegion ); + + SAL_DLLPRIVATE SalLayout* ImplLayout( const String&, xub_StrLen nIndex, + xub_StrLen nLen, const Point& rLogicPos = Point(0,0), + long nLogicWidth=0, const sal_Int32* pLogicDXArray=NULL, + bool bFilter = false ) const; + SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( String&, + xub_StrLen nIndex, xub_StrLen nLen, + long nPixelWidth, + const sal_Int32* pPixelDXArray ) const; + SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const; + + SAL_DLLPRIVATE long ImplGetTextWidth( const SalLayout& ) const; + static + SAL_DLLPRIVATE XubString ImplGetEllipsisString( const OutputDevice& rTargetDevice, const XubString& rStr, + long nMaxWidth, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ); + static + SAL_DLLPRIVATE void ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& rRect, + const String& rOrigStr, sal_uInt16 nStyle, + MetricVector* pVector, String* pDisplayText, ::vcl::ITextLayout& _rLayout ); + SAL_DLLPRIVATE void ImplDrawTextBackground( const SalLayout& ); + SAL_DLLPRIVATE void ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, sal_Bool bWordLine, sal_Bool bUnderlineAbove ); + SAL_DLLPRIVATE bool ImplDrawRotateText( SalLayout& ); + SAL_DLLPRIVATE void ImplDrawTextDirect( SalLayout&, sal_Bool bTextLines ); + SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& ); + SAL_DLLPRIVATE void ImplDrawText( SalLayout& ); + SAL_DLLPRIVATE Rectangle ImplGetTextBoundRect( const SalLayout& ); + SAL_DLLPRIVATE void ImplDrawEmphasisMarks( SalLayout& ); + + SAL_DLLPRIVATE void ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight ); + + SAL_DLLPRIVATE void ImplInitTextLineSize(); + SAL_DLLPRIVATE void ImplInitAboveTextLineSize(); + SAL_DLLPRIVATE void ImplDrawWaveLine( long nBaseX, long nBaseY, long nStartX, long nStartY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor ); + SAL_DLLPRIVATE void ImplDrawWaveTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ); + SAL_DLLPRIVATE void ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontUnderline eTextLine, Color aColor, sal_Bool bIsAbove ); + SAL_DLLPRIVATE void ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); + SAL_DLLPRIVATE void ImplDrawStrikeoutChar( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); + SAL_DLLPRIVATE void ImplDrawTextLine( long nBaseX, long nX, long nY, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, sal_Bool bUnderlineAbove ); + SAL_DLLPRIVATE void ImplDrawMnemonicLine( long nX, long nY, long nWidth ); + SAL_DLLPRIVATE void ImplGetEmphasisMark( PolyPolygon& rPolyPoly, sal_Bool& rPolyLine, Rectangle& rRect1, Rectangle& rRect2, long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short nOrient ); + SAL_DLLPRIVATE void ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const PolyPolygon& rPolyPoly, sal_Bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 ); + static + SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ); + SAL_DLLPRIVATE void ImplInitFontList() const; + SAL_DLLPRIVATE void ImplUpdateFontData( bool bNewFontLists ); + SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists ); + + SAL_DLLPRIVATE long ImplLogicXToDevicePixel( long nX ) const; + SAL_DLLPRIVATE long ImplLogicYToDevicePixel( long nY ) const; + SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel( long nWidth ) const; + SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel( long nHeight ) const; + SAL_DLLPRIVATE long ImplDevicePixelToLogicWidth( long nWidth ) const; + SAL_DLLPRIVATE long ImplDevicePixelToLogicHeight( long nHeight ) const; + SAL_DLLPRIVATE float ImplFloatLogicWidthToDevicePixel( float ) const; + SAL_DLLPRIVATE float ImplFloatLogicHeightToDevicePixel( float ) const; + SAL_DLLPRIVATE float ImplFloatDevicePixelToLogicWidth( float ) const; + SAL_DLLPRIVATE float ImplFloatDevicePixelToLogicHeight( float ) const; + SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const; + SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const; + SAL_DLLPRIVATE Rectangle ImplLogicToDevicePixel( const Rectangle& rLogicRect ) const; + SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& ) const; + SAL_DLLPRIVATE ::basegfx::B2DPolyPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolyPolygon& ) const; + SAL_DLLPRIVATE Polygon ImplLogicToDevicePixel( const Polygon& rLogicPoly ) const; + SAL_DLLPRIVATE PolyPolygon ImplLogicToDevicePixel( const PolyPolygon& rLogicPolyPoly ) const; + SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const; + SAL_DLLPRIVATE Rectangle ImplDevicePixelToLogic( const Rectangle& rLogicRect ) const; + SAL_DLLPRIVATE Region ImplPixelToDevicePixel( const Region& rRegion ) const; + SAL_DLLPRIVATE void ImplInvalidateViewTransform(); + SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const; + + SAL_DLLPRIVATE void ImplDrawPolygon( const Polygon& rPoly, const PolyPolygon* pClipPolyPoly = NULL ); + SAL_DLLPRIVATE void ImplDrawPolyPolygon( const PolyPolygon& rPolyPoly, const PolyPolygon* pClipPolyPoly = NULL ); + SAL_DLLPRIVATE void ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPolyPoly ); + SAL_DLLPRIVATE void ImplDrawLinearGradient( const Rectangle& rRect, const Gradient& rGradient, sal_Bool bMtf, const PolyPolygon* pClipPolyPoly ); + SAL_DLLPRIVATE void ImplDrawComplexGradient( const Rectangle& rRect, const Gradient& rGradient, sal_Bool bMtf, const PolyPolygon* pClipPolyPoly ); + + SAL_DLLPRIVATE void ImplDrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch, sal_Bool bMtf ); + SAL_DLLPRIVATE void ImplCalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); + SAL_DLLPRIVATE void ImplDrawHatchLine( const Line& rLine, const PolyPolygon& rPolyPoly, Point* pPtBuffer, sal_Bool bMtf ); + + SAL_DLLPRIVATE void ImplDrawWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void ImplDrawColorWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void ImplDrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void ImplDrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void ImplDraw2ColorFrame( const Rectangle& rRect, const Color& rLeftTopColor, const Color& rRightBottomColor ); + + SAL_DLLPRIVATE void ImplDrawOutDevDirect( const OutputDevice* pSrcDev, void* pPosAry ); + SAL_DLLPRIVATE void ImplDrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const sal_uLong nAction ); + SAL_DLLPRIVATE void ImplDrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const BitmapEx& rBitmapEx, const sal_uLong nAction ); + SAL_DLLPRIVATE void ImplDrawMask( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const Color& rMaskColor, + const sal_uLong nAction ); + SAL_DLLPRIVATE void ImplDrawAlpha( const Bitmap& rBmp, const AlphaMask& rAlpha, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ); + SAL_DLLPRIVATE Bitmap ImplBlend( Bitmap aBmp, + BitmapReadAccess* pP, + BitmapReadAccess* pA, + const sal_Int32 nOffY, + const sal_Int32 nDstHeight, + const sal_Int32 nOffX, + const sal_Int32 nDstWidth, + const Rectangle& aBmpRect, + const Size& aOutSz, + const bool bHMirr, + const bool bVMirr, + const long* pMapX, + const long* pMapY ); + SAL_DLLPRIVATE Bitmap ImplBlendWithAlpha( Bitmap aBmp, + BitmapReadAccess* pP, + BitmapReadAccess* pA, + const Rectangle& aDstRect, + const sal_Int32 nOffY, + const sal_Int32 nDstHeight, + const sal_Int32 nOffX, + const sal_Int32 nDstWidth, + const long* pMapX, + const long* pMapY ); + SAL_DLLPRIVATE void ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ); + SAL_DLLPRIVATE void ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ); + SAL_DLLPRIVATE void ImplDrawFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize, + const OutputDevice& rOutDev, const Region& rRegion ); + SAL_DLLPRIVATE void ImplGetFrameDev( const Point& rPt, const Point& rDevPt, const Size& rDevSize, + OutputDevice& rOutDev ); + SAL_DLLPRIVATE void ImplGetFrameBitmap( const Point& rPt, const Size& rSize, + Bitmap& rBitmap ) const; + + SAL_DLLPRIVATE sal_Bool ImplIsRecordLayout() const; + + void ImplAddDevFontSubstitute( const XubString& rFontName, + const XubString& rReplaceFontName, + sal_uInt16 nFlags = 0 ); + + SAL_DLLPRIVATE static FontEmphasisMark ImplGetEmphasisMarkStyle( const Font& rFont ); + SAL_DLLPRIVATE static sal_Bool ImplIsUnderlineAbove( const Font& ); + + // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI + SAL_DLLPRIVATE bool ImplIsAntiparallel() const ; + + // #i101491# + // Helper which holds the old line geometry creation and is extended to use AA when + // switched on. Advantage is that line geometry is only temporarily used for paint + SAL_DLLPRIVATE void ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo); + + // #i101491# + // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon + // without MetaFile processing + SAL_DLLPRIVATE void ImpDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly); + + // #i101491# + // 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); + + SAL_DLLPRIVATE void forceFallbackFontToFit(SalLayout &rFallback, ImplFontEntry &rFallbackFont, + ImplFontSelectData &rFontSelData, int nFallbackLevel, + ImplLayoutArgs& rLayoutArgs, const ImplFontMetricData& rOrigMetric) const; +protected: + OutputDevice(); + +private: + SAL_DLLPRIVATE OutputDevice( const OutputDevice& rOutDev ); + SAL_DLLPRIVATE OutputDevice& operator =( const OutputDevice& rOutDev ); + +public: + virtual ~OutputDevice(); + + OutDevType GetOutDevType() const { return meOutDevType; } + + /** query an <code>OutputDevice</code> whether it spports a specific operation + + @return + true if operation supported, else false + */ + bool supportsOperation( OutDevSupportType ) const; + + vcl::PDFWriterImpl* GetPDFWriter() const { return mpPDFWriter; } + + void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; } + vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; } + + void DrawTextLine( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontUnderline eUnderline, + FontUnderline eOverline, + sal_Bool bUnderlineAbove = sal_False ); + static sal_Bool IsTextUnderlineAbove( const Font& rFont ); + + void DrawText( const Point& rStartPt, const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + MetricVector* pVector = NULL, String* pDisplayText = NULL ); + long GetTextWidth( const XubString& rStr, xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN ) const; + long GetTextHeight() const; + void DrawTextArray( const Point& rStartPt, const XubString& rStr, + const sal_Int32* pDXAry = NULL, + xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN ); + long GetTextArray( const XubString& rStr, sal_Int32* pDXAry = NULL, + xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN ) const; + bool GetCaretPositions( const XubString&, sal_Int32* pCaretXArray, + xub_StrLen nIndex, xub_StrLen nLen, + sal_Int32* pDXAry = NULL, long nWidth = 0, + sal_Bool bCellBreaking = sal_True ) const; + void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, + const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); + xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + long nCharExtra = 0, sal_Bool bCellBreaking = sal_True ) const; + xub_StrLen GetTextBreak( const XubString& rStr, long nTextWidth, + sal_uInt16 nExtraChar, xub_StrLen& rExtraCharPos, + xub_StrLen nIndex, xub_StrLen nLen, + long nCharExtra = 0 ) const; + /** Generate MetaTextActions for the text rect + + This method splits up the text rect into multiple + MetaTextActions, one for each line of text. This is comparable + to AddGradientActions(), which splits up a gradient into its + constituing polygons. Parameter semantics fully compatible to + DrawText(). + */ + void AddTextRectActions( const Rectangle& rRect, + const String& rOrigStr, + sal_uInt16 nStyle, + GDIMetaFile& rMtf ); + void DrawText( const Rectangle& rRect, + const XubString& rStr, sal_uInt16 nStyle = 0, + MetricVector* pVector = NULL, String* pDisplayText = NULL, + ::vcl::ITextLayout* _pTextLayout = NULL ); + Rectangle GetTextRect( const Rectangle& rRect, + const XubString& rStr, sal_uInt16 nStyle = TEXT_DRAW_WORDBREAK, + TextRectInfo* pInfo = NULL, + const ::vcl::ITextLayout* _pTextLayout = NULL ) const; + XubString GetEllipsisString( const XubString& rStr, long nMaxWidth, + sal_uInt16 nStyle = TEXT_DRAW_ENDELLIPSIS ) const; + void DrawCtrlText( const Point& rPos, const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC, MetricVector* pVector = NULL, String* pDisplayText = NULL ); + long GetCtrlTextWidth( const XubString& rStr, xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN, + sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC ) const; + static XubString GetNonMnemonicString( const XubString& rStr, xub_StrLen& rMnemonicPos ); + static XubString GetNonMnemonicString( const XubString& rStr ) + { xub_StrLen nDummy; return GetNonMnemonicString( rStr, nDummy ); } + + sal_uLong GetKerningPairCount() const; + void GetKerningPairs( sal_uLong nPairs, KerningPair* pKernPairs ) const; + + sal_Bool GetTextBoundRect( Rectangle& rRect, + const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; + sal_Bool GetTextOutline( PolyPolygon&, + const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, + sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; + sal_Bool GetTextOutlines( PolyPolyVector&, + const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, + sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; + sal_Bool GetTextOutlines( ::basegfx::B2DPolyPolygonVector&, + const String& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN, sal_Bool bOptimize = sal_True, + sal_uLong nLayoutWidth = 0, const sal_Int32* pDXArray = NULL ) const; + sal_Bool GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, + int nLen, int nBase, MetricVector& rVector ); + + void DrawPixel( const Point& rPt ); + void DrawPixel( const Point& rPt, const Color& rColor ); + void DrawPixel( const Polygon& rPts, const Color* pColors = NULL ); + void DrawPixel( const Polygon& rPts, const Color& rColor ); + + void DrawLine( const Point& rStartPt, const Point& rEndPt ); + void DrawLine( const Point& rStartPt, const Point& rEndPt, + const LineInfo& rLineInfo ); + + /** Render the given polygon as a line stroke + + The given polygon is stroked with the current LineColor, start + and end point are not automatically connected + + @see DrawPolygon + @see DrawPolyPolygon + */ + void DrawPolyLine( const Polygon& rPoly ); + void DrawPolyLine( const basegfx::B2DPolygon&, double fLineWidth = 0.0, basegfx::B2DLineJoin = basegfx::B2DLINEJOIN_ROUND ); + + /** Render the given polygon as a line stroke + + The given polygon is stroked with the current LineColor, start + and end point are not automatically connected. The line is + rendered according to the specified LineInfo, e.g. supplying a + dash pattern, or a line thickness. + + @see DrawPolygon + @see DrawPolyPolygon + */ + void DrawPolyLine( const Polygon& rPoly, + const LineInfo& rLineInfo ); + + /** Render the given polygon + + The given polygon is stroked with the current LineColor, and + filled with the current FillColor. If one of these colors are + transparent, the corresponding stroke or fill stays + invisible. Start and end point of the polygon are + automatically connected. + + @see DrawPolyLine + */ + void DrawPolygon( const Polygon& rPoly ); + void DrawPolygon( const basegfx::B2DPolygon& ); + + /** Render the given poly-polygon + + The given poly-polygon is stroked with the current LineColor, + and filled with the current FillColor. If one of these colors + are transparent, the corresponding stroke or fill stays + invisible. Start and end points of the contained polygons are + automatically connected. + + @see DrawPolyLine + */ + void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); + void DrawPolyPolygon( const basegfx::B2DPolyPolygon& ); + + void DrawRect( const Rectangle& rRect ); + void DrawRect( const Rectangle& rRect, + sal_uLong nHorzRount, sal_uLong nVertRound ); + void DrawEllipse( const Rectangle& rRect ); + void DrawArc( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawPie( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawChord( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + void DrawOutDev( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize ); + void DrawOutDev( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize, + const OutputDevice& rOutDev ); + void CopyArea( const Point& rDestPt, + const Point& rSrcPt, const Size& rSrcSize, + sal_uInt16 nFlags = 0 ); + + void DrawBitmap( const Point& rDestPt, + const Bitmap& rBitmap ); + void DrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap ); + void DrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap ); + + void DrawBitmapEx( const Point& rDestPt, + const BitmapEx& rBitmapEx ); + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const BitmapEx& rBitmapEx ); + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const BitmapEx& rBitmapEx ); + + void DrawMask( const Point& rDestPt, + const Bitmap& rBitmap, const Color& rMaskColor ); + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap, const Color& rMaskColor ); + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const Color& rMaskColor ); + + void DrawImage( const Point& rPos, + const Image& rImage, sal_uInt16 nStyle = 0 ); + void DrawImage( const Point& rPos, const Size& rSize, + const Image& rImage, sal_uInt16 nStyle = 0 ); + + void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); + void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); + void AddGradientActions( const Rectangle& rRect, + const Gradient& rGradient, + GDIMetaFile& rMtf ); + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + void DrawHatch( const PolyPolygon& rPolyPoly, const ::Hatch& rHatch ); + void AddHatchActions( const PolyPolygon& rPolyPoly, + const ::Hatch& rHatch, + GDIMetaFile& rMtf ); +#else + void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); + void AddHatchActions( const PolyPolygon& rPolyPoly, + const Hatch& rHatch, + GDIMetaFile& rMtf ); +#endif + + void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); + void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle ); + void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); + + void DrawTransparent( const PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ); + void DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency); + void DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize, const Gradient& rTransparenceGradient ); + + Color GetPixel( const Point& rPt ) const; + Color* GetPixel( const Polygon& rPts ) const; + + Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const; + + /** Query extended bitmap (with alpha channel, if available). + */ + BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const; + + void EnableMapMode( sal_Bool bEnable = sal_True ); + sal_Bool IsMapModeEnabled() const { return mbMap; } + + // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout + void EnableRTL( sal_Bool bEnable = sal_True); + sal_Bool IsRTLEnabled() const { return mbEnableRTL; } + + void SetConnectMetaFile( GDIMetaFile* pMtf ); + GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; } + + void EnableOutput( sal_Bool bEnable = sal_True ); + sal_Bool IsOutputEnabled() const { return mbOutput; } + sal_Bool IsDeviceOutput() const { return mbDevOutput; } + sal_Bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); } + sal_Bool IsOutputNecessary() const { return ((mbOutput && mbDevOutput) || (mpMetaFile != NULL)); } + + void SetClipRegion(); + void SetClipRegion( const Region& rRegion ); + Region GetClipRegion() const; + sal_Bool IsClipRegion() const { return mbClipRegion; } + Region GetActiveClipRegion() const; + + void MoveClipRegion( long nHorzMove, long nVertMove ); + void IntersectClipRegion( const Rectangle& rRect ); + void IntersectClipRegion( const Region& rRegion ); + + void SetAntialiasing( sal_uInt16 nMode = 0 ); + sal_uInt16 GetAntialiasing() const { return mnAntialiasing; } + + void SetDrawMode( sal_uLong nDrawMode ); + sal_uLong GetDrawMode() const { return mnDrawMode; } + + void SetLayoutMode( sal_uLong nTextLayoutMode ); + sal_uLong GetLayoutMode() const { return mnTextLayoutMode; } + + void SetDigitLanguage( LanguageType ); + LanguageType GetDigitLanguage() const { return meTextLanguage; } + + void SetRasterOp( RasterOp eRasterOp ); + RasterOp GetRasterOp() const { return meRasterOp; } + + /** + If this OutputDevice is used for displaying a Print Preview + the OutDevViewType should be set to 'OUTDEV_VIEWTYPE_PRINTPREVIEW'. + + A View than can make painting decisions dependent on this OutDevViewType. + E.g. text colors need to be handled different, dependent on wether it's a PrintPreview or not. (see #106611# for more) + */ + void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; } + OutDevViewType GetOutDevViewType() const { return meOutDevViewType; } + + void SetLineColor(); + void SetLineColor( const Color& rColor ); + const Color& GetLineColor() const { return maLineColor; } + sal_Bool IsLineColor() const { return mbLineColor; } + + void SetFillColor(); + void SetFillColor( const Color& rColor ); + const Color& GetFillColor() const { return maFillColor; } + sal_Bool IsFillColor() const { return mbFillColor; } + + void SetBackground(); + void SetBackground( const Wallpaper& rBackground ); + + const Wallpaper& GetBackground() const { return maBackground; } + sal_Bool IsBackground() const { return mbBackground; } + + void SetFont( const Font& rNewFont ); + const Font& GetFont() const { return maFont; } + + SystemFontData GetSysFontData( int nFallbacklevel ) const; + SystemTextLayoutData GetSysTextLayoutData( const Point& rStartPt, const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + const sal_Int32* pDXAry = NULL ) const; + + void SetTextColor( const Color& rColor ); + const Color& GetTextColor() const { return maTextColor; } + void SetTextFillColor(); + void SetTextFillColor( const Color& rColor ); + + Color GetTextFillColor() const; + sal_Bool IsTextFillColor() const { return !maFont.IsTransparent(); } + void SetTextLineColor(); + void SetTextLineColor( const Color& rColor ); + const Color& GetTextLineColor() const { return maTextLineColor; } + sal_Bool IsTextLineColor() const { return (maTextLineColor.GetTransparency() == 0); } + void SetOverlineColor(); + void SetOverlineColor( const Color& rColor ); + const Color& GetOverlineColor() const { return maOverlineColor; } + sal_Bool IsOverlineColor() const { return (maOverlineColor.GetTransparency() == 0); } + void SetTextAlign( TextAlign eAlign ); + TextAlign GetTextAlign() const { return maFont.GetAlign(); } + + virtual void SetSettings( const AllSettings& rSettings ); + const AllSettings& GetSettings() const { return maSettings; } + + SystemGraphicsData GetSystemGfxData() const; + ::com::sun::star::uno::Any GetSystemGfxDataAny() const; + + virtual void SetMapMode(); + virtual void SetMapMode( const MapMode& rNewMapMode ); + virtual void SetRelativeMapMode( const MapMode& rNewMapMode ); + const MapMode& GetMapMode() const { return maMapMode; } + sal_Bool IsMapMode() const { return mbMap; } + + void SetRefPoint(); + void SetRefPoint( const Point& rRefPoint ); + const Point& GetRefPoint() const { return maRefPoint; } + sal_Bool IsRefPoint() const { return mbRefPoint; } + + // #i75163# + basegfx::B2DHomMatrix GetViewTransformation() const; + basegfx::B2DHomMatrix GetInverseViewTransformation() const; + + basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const; + basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const; + + + /** Set an offset in pixel + + This method offsets every drawing operation that converts its + coordinates to pixel by the given value. Normally, the effect + can be achieved by setting a MapMode with a different + origin. Unfortunately, this origin is in logical coordinates + and can lead to rounding errors (see #102532# for details). + + @attention This offset is only applied when converting to + pixel, i.e. some output modes such as metafile recordings + might be completely unaffected by this method! Use with + care. Furthermore, if the OutputDevice's MapMode is the + default (that's MAP_PIXEL), then, too, any pixel offset set is + ignored. This might be unintuitive for cases, but would have + been far more fragile to implement. What's more, the reason + why the pixel offset was introduced (avoiding rounding errors) + does not apply for MAP_PIXEL, because one can always use the + MapMode origin then. + + @param rOffset + The offset in pixel + */ + void SetPixelOffset( const Size& rOffset ); + + /** Get the offset in pixel + + @see OutputDevice::SetPixelOffset for details + + @return the current offset in pixel + */ + Size GetPixelOffset() const; + + Point LogicToPixel( const Point& rLogicPt ) const; + Size LogicToPixel( const Size& rLogicSize ) const; + Rectangle LogicToPixel( const Rectangle& rLogicRect ) const; + Polygon LogicToPixel( const Polygon& rLogicPoly ) const; + basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPolyPoly ) const; + PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const; + Region LogicToPixel( const Region& rLogicRegion )const; + Point LogicToPixel( const Point& rLogicPt, + const MapMode& rMapMode ) const; + Size LogicToPixel( const Size& rLogicSize, + const MapMode& rMapMode ) const; + Rectangle LogicToPixel( const Rectangle& rLogicRect, + const MapMode& rMapMode ) const; + Polygon LogicToPixel( const Polygon& rLogicPoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolygon LogicToPixel( const basegfx::B2DPolygon& rLogicPoly, + const MapMode& rMapMode ) const; + PolyPolygon LogicToPixel( const PolyPolygon& rLogicPolyPoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, + const MapMode& rMapMode ) const; + Region LogicToPixel( const Region& rLogicRegion, + const MapMode& rMapMode ) const; + Point PixelToLogic( const Point& rDevicePt ) const; + Size PixelToLogic( const Size& rDeviceSize ) const; + Rectangle PixelToLogic( const Rectangle& rDeviceRect ) const; + Polygon PixelToLogic( const Polygon& rDevicePoly ) const; + basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly ) const; + PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const; + Region PixelToLogic( const Region& rDeviceRegion ) const; + Point PixelToLogic( const Point& rDevicePt, + const MapMode& rMapMode ) const; + Size PixelToLogic( const Size& rDeviceSize, + const MapMode& rMapMode ) const; + Rectangle PixelToLogic( const Rectangle& rDeviceRect, + const MapMode& rMapMode ) const; + Polygon PixelToLogic( const Polygon& rDevicePoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly, + const MapMode& rMapMode ) const; + PolyPolygon PixelToLogic( const PolyPolygon& rDevicePolyPoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly, + const MapMode& rMapMode ) const; + Region PixelToLogic( const Region& rDeviceRegion, + const MapMode& rMapMode ) const; + + Point LogicToLogic( const Point& rPtSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + Size LogicToLogic( const Size& rSzSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + Rectangle LogicToLogic( const Rectangle& rRectSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + long* LogicToLogic( long* pX, + sal_uInt16 nCount, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + static Point LogicToLogic( const Point& rPtSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static Size LogicToLogic( const Size& rSzSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static Rectangle LogicToLogic( const Rectangle& rRectSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static long LogicToLogic( long nLongSource, + MapUnit eUnitSource, + MapUnit eUnitDest ); + + static basegfx::B2DPolygon LogicToLogic( const basegfx::B2DPolygon& rPoly, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static basegfx::B2DPolyPolygon LogicToLogic( const basegfx::B2DPolyPolygon& rPolyPoly, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + + Size GetOutputSizePixel() const + { return Size( mnOutWidth, mnOutHeight ); } + long GetOutputWidthPixel() const { return mnOutWidth; } + long GetOutputHeightPixel() const { return mnOutHeight; } + long GetOutOffXPixel() const { return mnOutOffX; } + long GetOutOffYPixel() const { return mnOutOffY; } + + Size GetOutputSize() const + { return PixelToLogic( GetOutputSizePixel() ); } + + void Erase(); + void Erase( const Rectangle& rRect ) { DrawWallpaper( rRect, GetBackground() ); } + + sal_Bool AddTempDevFont( const String& rFileURL, const String& rFontName ); + int GetDevFontCount() const; + FontInfo GetDevFont( int nDevFontIndex ) const; + int GetDevFontSizeCount( const Font& ) const; + Size GetDevFontSize( const Font& rFont, int nSizeIndex ) const; + sal_Bool IsFontAvailable( const String& rFontName ) const; + + FontMetric GetFontMetric() const; + FontMetric GetFontMetric( const Font& rFont ) const; + sal_Bool GetFontCharMap( FontCharMap& rFontCharMap ) const; + bool GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const; + + xub_StrLen HasGlyphs( const Font& rFont, const String& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ) const; + + long GetMinKashida() const; + long GetMinKashida( const Font& rFont ) const; + + // i60594 + // validate kashida positions against the current font + // returns count of invalid kashida positions + xub_StrLen ValidateKashidas ( const String& rTxt, + xub_StrLen nIdx, xub_StrLen nLen, + xub_StrLen nKashCount, // number of suggested kashida positions (in) + const xub_StrLen* pKashidaPos, // suggested kashida positions (in) + xub_StrLen* pKashidaPosDropped // invalid kashida positions (out) + ) const; + + sal_uInt16 GetBitCount() const; + + sal_Bool GetTextIsRTL( const String&, xub_StrLen nIndex, + xub_StrLen nLen ) const; + + /** Query the existence and depth of the alpha channel + + @return 0, if no alpha channel available, and the bit depth of + the alpha channel otherwise. + */ + sal_uInt16 GetAlphaBitCount() const; + sal_uLong GetColorCount() const; + + void Push( sal_uInt16 nFlags = PUSH_ALL ); + void Pop(); + // returns the curren stack depth; that is the number of Push() calls minus the number of Pop() calls + // this should not normally be used since Push and Pop must always be used symmetrically + // however this may be e.g. a help when debugging code in which this somehow is not the case + sal_uInt32 GetGCStackDepth() const; + + /** Query availability of alpha channel + + @return sal_True, if this device has an alpha channel. + */ + sal_Bool HasAlpha(); + + /** 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 in 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 + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvas > GetCanvas() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > CreateUnoGraphics(); + List* GetUnoGraphicsList() const { return mpUnoGraphicsList; } + List* CreateUnoGraphicsList() { mpUnoGraphicsList = new List; return mpUnoGraphicsList; } + + static void BeginFontSubstitution(); + static void EndFontSubstitution(); + static void AddFontSubstitute( const XubString& rFontName, + const XubString& rReplaceFontName, + sal_uInt16 nFlags = 0 ); + static void RemoveFontSubstitute( sal_uInt16 n ); + static sal_uInt16 GetFontSubstituteCount(); + static void GetFontSubstitute( sal_uInt16 n, + XubString& rFontName, + XubString& rReplaceFontName, + sal_uInt16& rFlags ); + + static Font GetDefaultFont( sal_uInt16 nType, + LanguageType eLang, + sal_uLong nFlags, + const OutputDevice* pOutDev = NULL ); + + /** helper method removing transparencies from a metafile (e.g. for printing) + + @returns + true: transparencies were removed + 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, + bool bReduceTransparency, + bool bTransparencyAutoMode, + bool bDownsampleBitmaps, + const Color& rBackground = Color( COL_TRANSPARENT ) + ); + /** Retrieve downsampled and cropped bitmap + + @attention This method ignores negative rDstSz values, thus + mirroring must happen outside this method (e.g. in DrawBitmap) + */ + Bitmap GetDownsampledBitmap( const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const Bitmap& rBmp, long nMaxBmpDPIX, long nMaxBmpDPIY ); + /** Retrieve downsampled and cropped bitmapEx + + @attention This method ignores negative rDstSz values, thus + mirroring must happen outside this method (e.g. in DrawBitmapEx) + */ + BitmapEx GetDownsampledBitmapEx( const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const BitmapEx& rBmpEx, long nMaxBmpDPIX, long nMaxBmpDPIY ); + + //------------------------------------- + // Native Widget Rendering functions + //------------------------------------- + + // These all just call through to the private mpGraphics functions of the same name. + + // Query the platform layer for control support + sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart ); + + // Query the native control to determine if it was acted upon + sal_Bool HitTestNativeControl( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + const Point& aPos, + sal_Bool& rIsInside ); + + // Request rendering of a particular control and/or part + sal_Bool DrawNativeControl( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ); + + // Request rendering of a caption string for a control + sal_Bool DrawNativeControlText( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption ); + + // Query the native control's actual drawing region (including adornment) + sal_Bool GetNativeControlRegion( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + ::rtl::OUString aCaption, + Rectangle &rNativeBoundingRegion, + Rectangle &rNativeContentRegion ); + +}; + +#endif // _SV_OUTDEV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/outfont.hxx b/vcl/inc/vcl/outfont.hxx new file mode 100644 index 000000000000..faf2b00793f2 --- /dev/null +++ b/vcl/inc/vcl/outfont.hxx @@ -0,0 +1,407 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_OUTFONT_HXX +#define _SV_OUTFONT_HXX + +#include <tools/string.hxx> +#include <i18npool/lang.h> +#include <tools/gen.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <unotools/fontdefs.hxx> +#include <vcl/vclenum.hxx> + +#include <boost/unordered_map.hpp> + +class ImplDevFontListData; +class ImplGetDevFontList; +class ImplGetDevSizeList; +class ImplFontEntry; +class ImplDirectFontSubstitution; +class ImplPreMatchFontSubstitution; +class ImplGlyphFallbackFontSubstitution; +class ImplFontSelectData; +class Font; +class ConvertChar; +struct FontMatchStatus; +class OutputDevice; + +namespace com { namespace sun { namespace star { namespace lang { struct Locale; }}}} + +// ---------------------- +// - ImplFontAttributes - +// ---------------------- +// device independent font properties + +class ImplFontAttributes +{ +public: // TODO: create matching interface class + const String& GetFamilyName() const { return maName; } + const String& GetStyleName() const { return maStyleName; } + FontWeight GetWeight() const { return meWeight; } + FontItalic GetSlant() const { return meItalic; } + FontFamily GetFamilyType() const { return meFamily; } + FontPitch GetPitch() const { return mePitch; } + FontWidth GetWidthType() const { return meWidthType; } + bool IsSymbolFont() const { return mbSymbolFlag; } + +public: // TODO: hide members behind accessor methods + String maName; // Font Family Name + String maStyleName; // Font Style Name + FontWeight meWeight; // Weight Type + FontItalic meItalic; // Slant Type + FontFamily meFamily; // Family Type + FontPitch mePitch; // Pitch Type + FontWidth meWidthType; // Width Type + bool mbSymbolFlag; +}; + +// ------------------------- +// - ImplDevFontAttributes - +// ------------------------- +// device dependent font properties + +class ImplDevFontAttributes : public ImplFontAttributes +{ +public: // TODO: create matching interface class + const String& GetAliasNames() const { return maMapNames; } + int GetQuality() const { return mnQuality; } + bool IsRotatable() const { return mbOrientation; } + bool IsDeviceFont() const { return mbDevice; } + bool IsEmbeddable() const { return mbEmbeddable; } + bool IsSubsettable() const { return mbSubsettable; } + +public: // TODO: hide members behind accessor methods + String maMapNames; // List of family name aliass separated with ';' + int mnQuality; // Quality (used when similar fonts compete) + bool mbOrientation; // true: physical font can be rotated + bool mbDevice; // true: built in font + bool mbSubsettable; // true: a subset of the font can be created + bool mbEmbeddable; // true: the font can be embedded +}; + +// ---------------- +// - ImplFontData - +// ---------------- +// TODO: rename ImplFontData to PhysicalFontFace +// TODO: no more direct access to members +// TODO: add reference counting +// TODO: get rid of height/width for scalable fonts +// TODO: make cloning cheaper + +// abstract base class for physical font faces +class VCL_PLUGIN_PUBLIC ImplFontData : public ImplDevFontAttributes +{ +public: + // by using an ImplFontData object as a factory for its corresponding + // ImplFontEntry an ImplFontEntry can be extended to cache device and + // font instance specific data + virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const = 0; + + virtual int GetHeight() const { return mnHeight; } + virtual int GetWidth() const { return mnWidth; } + virtual sal_IntPtr GetFontId() const = 0; + int GetFontMagic() const { return mnMagic; } + bool IsScalable() const { return (mnHeight == 0); } + bool CheckMagic( int n ) const { return (n == mnMagic); } + ImplFontData* GetNextFace() const { return mpNext; } + ImplFontData* CreateAlias() const { return Clone(); } + + bool IsBetterMatch( const ImplFontSelectData&, FontMatchStatus& ) const; + StringCompare CompareWithSize( const ImplFontData& ) const; + StringCompare CompareIgnoreSize( const ImplFontData& ) const; + virtual ~ImplFontData() {} + virtual ImplFontData* Clone() const = 0; + +protected: + explicit ImplFontData( const ImplDevFontAttributes&, int nMagic ); + void SetBitmapSize( int nW, int nH ) { mnWidth=nW; mnHeight=nH; } + + long mnWidth; // Width (in pixels) + long mnHeight; // Height (in pixels) + +private: +friend class ImplDevFontListData; + const int mnMagic; // poor man's RTTI + ImplFontData* mpNext; +}; + +// ---------------------- +// - ImplFontSelectData - +// ---------------------- + +class ImplFontSelectData : public ImplFontAttributes +{ +public: + ImplFontSelectData( const Font&, const String& rSearchName, + const Size&, float fExactHeight ); + ImplFontSelectData( const ImplFontData&, const Size&, + float fExactHeight, int nOrientation, bool bVertical ); + +public: // TODO: change to private + String maTargetName; // name of the font name token that is chosen + String maSearchName; // name of the font that matches best + int mnWidth; // width of font in pixel units + int mnHeight; // height of font in pixel units + float mfExactHeight; // requested height (in pixels with subpixel details) + int mnOrientation; // text orientation in 3600 system + LanguageType meLanguage; // text language + bool mbVertical; // vertical mode of requested font + bool mbNonAntialiased; // true if antialiasing is disabled + + const ImplFontData* mpFontData; // a matching ImplFontData object + ImplFontEntry* mpFontEntry; // pointer to the resulting FontCache entry +}; + +// ------------------- +// - ImplDevFontList - +// ------------------- +// TODO: merge with ImplFontCache +// TODO: rename to LogicalFontManager + +class VCL_PLUGIN_PUBLIC ImplDevFontList +{ +private: + friend class WinGlyphFallbackSubstititution; + mutable bool mbMatchData; // true if matching attributes are initialized + bool mbMapNames; // true if MapNames are available + + typedef boost::unordered_map<const String, ImplDevFontListData*,FontNameHash> DevFontList; + DevFontList maDevFontList; + + ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution + ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyh fallback substitution + +public: + explicit ImplDevFontList(); + virtual ~ImplDevFontList(); + + // fill the list with device fonts + void Add( ImplFontData* ); + void Clear(); + int Count() const { return maDevFontList.size(); } + + // find the device font + ImplDevFontListData* FindFontFamily( const String& rFontName ) const; + ImplDevFontListData* ImplFindByFont( ImplFontSelectData&, bool bPrinter, ImplDirectFontSubstitution* ) const; + ImplDevFontListData* ImplFindBySearchName( const String& ) const; + + // suggest fonts for glyph fallback + ImplDevFontListData* GetGlyphFallbackFont( ImplFontSelectData&, + rtl::OUString& rMissingCodes, int nFallbackLevel ) const; + + // prepare platform specific font substitutions + void SetPreMatchHook( ImplPreMatchFontSubstitution* ); + void SetFallbackHook( ImplGlyphFallbackFontSubstitution* ); + + // misc utilities + ImplDevFontList* Clone( bool bScalable, bool bEmbeddable ) const; + ImplGetDevFontList* GetDevFontList() const; + ImplGetDevSizeList* GetDevSizeList( const String& rFontName ) const; + + //used by 2-level font fallback + ImplDevFontListData* ImplFindByLocale( com::sun::star::lang::Locale& ) const; + +protected: + void InitMatchData() const; + bool AreMapNamesAvailable() const { return mbMapNames; } + + ImplDevFontListData* ImplFindByTokenNames( const String& ) const; + ImplDevFontListData* ImplFindByAliasName( const String& rSearchName, const String& rShortName ) const; + ImplDevFontListData* ImplFindBySubstFontAttr( const utl::FontNameAttr& ) const; + ImplDevFontListData* ImplFindByAttributes( sal_uLong nSearchType, FontWeight, FontWidth, + FontFamily, FontItalic, const String& rSearchFamily ) const; + ImplDevFontListData* FindDefaultFont() const; + +private: + void InitGenericGlyphFallback() const; + mutable ImplDevFontListData** mpFallbackList; + mutable int mnFallbackCount; +}; + +// -------------------- +// - ImplKernPairData - +// -------------------- +// TODO: get rid of ImplKernPairData and use outdev.hxx's KerningPair struct +// the problem is that outdev.hxx is too high level for the device layers +// and outdev.hxx's customers depend on KerningPair being defined there + +struct ImplKernPairData +{ + sal_uInt16 mnChar1; + sal_uInt16 mnChar2; + long mnKern; +}; + + +// ----------------------- +// - ImplFontMetricData - +// ----------------------- + +class ImplFontMetricData : public ImplFontAttributes +{ +public: + explicit ImplFontMetricData( const ImplFontSelectData& ); + void ImplInitTextLineSize( const OutputDevice* pDev ); + void ImplInitAboveTextLineSize(); + +public: // TODO: hide members behind accessor methods + // font instance attributes from the font request + long mnWidth; // Reference Width + short mnOrientation; // Rotation in 1/10 degrees + + // font metrics measured for the font instance + long mnAscent; // Ascent + long mnDescent; // Descent + long mnIntLeading; // Internal Leading + long mnExtLeading; // External Leading + int mnSlant; // Slant (Italic/Oblique) + long mnMinKashida; // Minimal width of kashida (Arabic) + + // font attributes queried from the font instance + int meFamilyType; // Font Family Type + bool mbDevice; // Flag for Device Fonts + bool mbScalableFont; + bool mbKernableFont; + + // font metrics that are usually derived from the measurements + long mnUnderlineSize; // Lineheight of Underline + long mnUnderlineOffset; // Offset from Underline to Baseline + long mnBUnderlineSize; // Hoehe von fetter Unterstreichung + long mnBUnderlineOffset; // Offset von fetter Unterstreichung zur Baseline + long mnDUnderlineSize; // Hoehe von doppelter Unterstreichung + long mnDUnderlineOffset1; // Offset von doppelter Unterstreichung zur Baseline + long mnDUnderlineOffset2; // Offset von doppelter Unterstreichung zur Baseline + long mnWUnderlineSize; // Hoehe von WaveLine-Unterstreichung + long mnWUnderlineOffset; // Offset von WaveLine-Unterstreichung zur Baseline, jedoch zentriert zur WaveLine + long mnAboveUnderlineSize; // Hoehe von einfacher Unterstreichung (for Vertical Right) + long mnAboveUnderlineOffset; // Offset von einfacher Unterstreichung zur Baseline (for Vertical Right) + long mnAboveBUnderlineSize; // Hoehe von fetter Unterstreichung (for Vertical Right) + long mnAboveBUnderlineOffset; // Offset von fetter Unterstreichung zur Baseline (for Vertical Right) + long mnAboveDUnderlineSize; // Hoehe von doppelter Unterstreichung (for Vertical Right) + long mnAboveDUnderlineOffset1; // Offset von doppelter Unterstreichung zur Baseline (for Vertical Right) + long mnAboveDUnderlineOffset2; // Offset von doppelter Unterstreichung zur Baseline (for Vertical Right) + long mnAboveWUnderlineSize; // Hoehe von WaveLine-Unterstreichung (for Vertical Right) + long mnAboveWUnderlineOffset; // Offset von WaveLine-Unterstreichung zur Baseline, jedoch zentriert zur WaveLine (for Vertical Right) + long mnStrikeoutSize; // Hoehe von einfacher Durchstreichung + long mnStrikeoutOffset; // Offset von einfacher Durchstreichung zur Baseline + long mnBStrikeoutSize; // Hoehe von fetter Durchstreichung + long mnBStrikeoutOffset; // Offset von fetter Durchstreichung zur Baseline + long mnDStrikeoutSize; // Hoehe von doppelter Durchstreichung + long mnDStrikeoutOffset1; // Offset von doppelter Durchstreichung zur Baseline + long mnDStrikeoutOffset2; // Offset von doppelter Durchstreichung zur Baseline +}; + +// ----------------- +// - ImplFontEntry - +// ------------------ +// TODO: rename ImplFontEntry to LogicalFontInstance +// TODO: allow sharing of metrics for related fonts + +class VCL_PLUGIN_PUBLIC ImplFontEntry +{ +public: + explicit ImplFontEntry( const ImplFontSelectData& ); + virtual ~ImplFontEntry(); + +public: // TODO: make data members private + ImplFontSelectData maFontSelData; // FontSelectionData + ImplFontMetricData maMetric; // Font Metric + const ConvertChar* mpConversion; // used e.g. for StarBats->StarSymbol + long mnLineHeight; + sal_uLong mnRefCount; + sal_uInt16 mnSetFontFlags; // Flags returned by SalGraphics::SetFont() + short mnOwnOrientation; // text angle if lower layers don't rotate text themselves + short mnOrientation; // text angle in 3600 system + bool mbInit; // true if maMetric member is valid + + void AddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const String& rFontName ); + bool GetFallbackForUnicode( sal_UCS4, FontWeight eWeight, String* pFontName ) const; + void IgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, const String& rFontName ); + +private: + // cache of Unicode characters and replacement font names + // TODO: a fallback map can be shared with many other ImplFontEntries + // TODO: at least the ones which just differ in orientation, stretching or height + typedef ::std::pair<sal_UCS4,FontWeight> GFBCacheKey; + struct GFBCacheKey_Hash{ size_t operator()( const GFBCacheKey& ) const; }; + typedef ::boost::unordered_map<GFBCacheKey,String,GFBCacheKey_Hash> UnicodeFallbackList; + UnicodeFallbackList* mpUnicodeFallbackList; +}; + + +class ImplTextLineInfo +{ +private: + long mnWidth; + xub_StrLen mnIndex; + xub_StrLen mnLen; + +public: + ImplTextLineInfo( long nWidth, xub_StrLen nIndex, xub_StrLen nLen ) + { + mnWidth = nWidth; + mnIndex = nIndex; + mnLen = nLen; + } + + long GetWidth() const { return mnWidth; } + xub_StrLen GetIndex() const { return mnIndex; } + xub_StrLen GetLen() const { return mnLen; } +}; + +#define MULTITEXTLINEINFO_RESIZE 16 +typedef ImplTextLineInfo* PImplTextLineInfo; + +class ImplMultiTextLineInfo +{ +private: + PImplTextLineInfo* mpLines; + xub_StrLen mnLines; + xub_StrLen mnSize; + +public: + ImplMultiTextLineInfo(); + ~ImplMultiTextLineInfo(); + + void AddLine( ImplTextLineInfo* pLine ); + void Clear(); + + ImplTextLineInfo* GetLine( sal_uInt16 nLine ) const + { return mpLines[nLine]; } + xub_StrLen Count() const { return mnLines; } + +private: + ImplMultiTextLineInfo( const ImplMultiTextLineInfo& ); + ImplMultiTextLineInfo& operator=( const ImplMultiTextLineInfo& ); +}; + +#endif // _SV_OUTFONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/pdfextoutdevdata.hxx b/vcl/inc/vcl/pdfextoutdevdata.hxx new file mode 100644 index 000000000000..f4b8039fc9e8 --- /dev/null +++ b/vcl/inc/vcl/pdfextoutdevdata.hxx @@ -0,0 +1,521 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_PDFEXTOUTDEVDATA_HXX +#define _VCL_PDFEXTOUTDEVDATA_HXX + +#include <vcl/dllapi.h> + +#include <vcl/pdfwriter.hxx> +#include <vcl/extoutdevdata.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/mapmod.hxx> +#include <tools/rtti.hxx> +#include <vector> +#include <deque> + +class Graphic; + +namespace vcl { class PDFWriter; } + +namespace vcl +{ + +/* + A PDFExtOutDevBookmarkEntry is being created by the EditEngine if + a bookmark URL has been parsed. The Application is requested to take + care of each bookmark entry by emptying out the bookmark vector. +*/ +struct PDFExtOutDevBookmarkEntry +{ + sal_Int32 nLinkId; + rtl::OUString aBookmark; +}; + +/* + Class that is being set at the OutputDevice allowing the + application to send enhanced PDF commands like CreateLink +*/ +struct PageSyncData; +struct GlobalSyncData; +class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData +{ + + const OutputDevice& mrOutDev; + + sal_Bool mbTaggedPDF; + sal_Bool mbExportNotes; + sal_Bool mbTransitionEffects; + sal_Bool mbUseLosslessCompression; + sal_Bool mbReduceImageResolution; + sal_Bool mbExportFormFields; + sal_Bool mbExportBookmarks; + sal_Bool mbExportNDests; //i56629 + sal_Int32 mnFormsFormat; + sal_Int32 mnPage; + com::sun::star::lang::Locale maDocLocale; + + PageSyncData* mpPageSyncData; + GlobalSyncData* mpGlobalSyncData; + + std::vector< PDFExtOutDevBookmarkEntry > maBookmarks; + +public : + + TYPEINFO(); + PDFExtOutDevData( const OutputDevice& rOutDev ); + virtual ~PDFExtOutDevData(); + + sal_Bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction ); + void ResetSyncData(); + + void PlayGlobalActions( PDFWriter& rWriter ); + + + + sal_Bool GetIsExportNotes() const; + void SetIsExportNotes( const sal_Bool bExportNotes ); + + sal_Bool GetIsExportTaggedPDF() const; + void SetIsExportTaggedPDF( const sal_Bool bTaggedPDF ); + + sal_Bool GetIsExportTransitionEffects() const; + void SetIsExportTransitionEffects( const sal_Bool bTransitionalEffects ); + + sal_Bool GetIsExportFormFields() const; + void SetIsExportFormFields( const sal_Bool bExportFormFields ); + + sal_Int32 GetFormsFormat() const; + void SetFormsFormat( const sal_Int32 nFormsFormat ); + + sal_Bool GetIsExportBookmarks() const; + void SetIsExportBookmarks( const sal_Bool bExportBookmarks ); + + sal_Bool GetIsExportNamedDestinations() const; //i56629 + void SetIsExportNamedDestinations( const sal_Bool bExportNDests ); //i56629 + + // PageNumber, Compression is being set by the PDFExport + sal_Int32 GetCurrentPageNumber() const; + void SetCurrentPageNumber( const sal_Int32 nPage ); + + sal_Bool GetIsLosslessCompression() const; + void SetIsLosslessCompression( const sal_Bool bLosslessCompression ); + + sal_Bool GetIsReduceImageResolution() const; + void SetIsReduceImageResolution( const sal_Bool bReduceImageResolution ); + + const com::sun::star::lang::Locale& GetDocumentLocale() const; + void SetDocumentLocale( const com::sun::star::lang::Locale& rLoc ); + + std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks(); + + /** Start a new group of render output + + Use this method to group render output. + */ + void BeginGroup(); + + /** End render output + + This method ends grouped render output without + further actions. + */ + void EndGroup(); + + /** End render output + + This method ends grouped render output, that can be + represented by a GfxLink. This is typically used for + external graphic files, such as JPEGs, EPS files etc. + The BeginGroup/EndGroup calls must exactly enclose the + relevant OutputDevice calls issued to render the + graphic the normal way. + + @param rGraphic + The link to the original graphic + + @param nTransparency + Eight bit transparency value, with 0 denoting full opacity, + and 255 full transparency. + + @param rOutputRect + The output rectangle of the graphic. + + @param rVisibleOutputRect + The visible part of the output. This might be less than + rOutputRect, e.g. for cropped graphics. + */ + void EndGroup( const Graphic& rGraphic, + sal_uInt8 nTransparency, + const Rectangle& rOutputRect, + const Rectangle& rVisibleOutputRect ); +//--->i56629 + /** Create a new named destination to be used in a link to this document from another PDF document + (see PDF spec 1.4, 8.2.1) + + @parm sDestName + the name this destination will be addressed with from others PDF document + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateNamedDest( const String& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); +//<---i56629 + + /** Create a new destination to be used in a link + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::XYZ ); + /** Create a new link on a page + + @param rRect + active rectangle of the link (that is the area that has to be + hit to activate the link) + + @param nPageNr + number of page the link is on (as returned by NewPage) + or -1 in which case the current page is used + + @returns + the link id (to be used in SetLinkDest, SetLinkURL) or + -1 if page id does not exist + */ + sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 ); + /** Set the destination for a link + <p>will change a URL type link to a dest link if necessary</p> + + @param nLinkId + the link to be changed + + @param nDestId + the dest the link shall point to + @returns + 0 for success + -1 in case the link id does not exist + -2 in case the dest id does not exist + */ + sal_Int32 SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); + /** Set the URL for a link + <p>will change a dest type link to an URL type link if necessary</p> + @param nLinkId + the link to be changed + + @param rURL + the URL the link shall point to. + there will be no error checking or any kind of + conversion done to this parameter execept this: + it will be output as 7bit Ascii. The URL + will appear literally in the PDF file produced + + @returns + 0 for success + -1 in case the link id does not exist + */ + sal_Int32 SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL ); + /** Create a new outline item + + @param nParent + declares the parent of the new item in the outline hierarchy. + An invalid value will result in a new toplevel item. + + @param rText + sets the title text of the item + + @param nDestId + declares which Dest (created with CreateDest) the outline item + will point to + + @returns + the outline item id of the new item + */ + sal_Int32 CreateOutlineItem( sal_Int32 nParent = 0, const rtl::OUString& rText = rtl::OUString(), sal_Int32 nDestID = -1 ); + + /** Set an outline item's parent + + @param nItem + specififies which item should be reparented. + + @param nNewParent + specifies which outline item will be the item's new parent. + Use 0 for reparenting to top level. + + @returns + -1 if the item does not exist + -2 if the new parent does not exist, item will be reparented to top level. + */ + sal_Int32 SetOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent ); + + /** Set an outline item's title text + + @param nItem + specififies which item should get a new text + + @param rText + sets the title text of the item + + @returns + 0 if the item exists and the text was changed + -1 if the item does not exist + */ + sal_Int32 SetOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText ); + + /** Set an outline item's destination + + @param nItem + specififies which item should get a new dest + + @param nDestID + specifies the item's new destination + + @returns + -1 if the item does not exist + -2 if the new dest does not exist, dest will remain unchanged + */ + sal_Int32 SetOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID ); + + /** Create a new note on a page + + @param rRect + active rectangle of the note (that is the area that has to be + hit to popup the annotation) + + @param rNote + specifies the contents of the note + + @param nPageNr + number of page the note is on (as returned by NewPage) + or -1 in which case the current page is used + */ + void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 ); + + /** begin a new logical structure element + + BeginStructureElement/EndStructureElement calls build the logical structure + of the PDF - the basis for tagged PDF. Structural elements are implemented + using marked content tags. Each structural element can contain sub elements + (e.g. a section can contain a heading and a paragraph). The structure hierarchy + is build automatically from the Begin/EndStructureElement calls. + + A structural element need not be contained on one page; e.g. paragraphs often + run from one page to the next. In this case the corresponding EndStructureElement + must be called while drawing the next page. + + BeginStructureElement and EndStructureElement must be called only after + <member scope="vcl">PDFWriter::NewPage</member> has been called and before + <member scope="vcl">PDFWriter::Emit</member>gets called. The current page + number is an implicit context parameter for Begin/EndStructureElement. + + For pagination artifacts that are not part of the logical structure + of the document (like header, footer or page number) the special + StructElement <code>NonStructElement</code> exists. To place content + outside of the struture tree simply call + <code>BeginStructureElement( NonStructElement )</code> then draw your + content and then call <code>EndStructureElement()</code>. Any children + of a <code>NonStructElement</code> will not be part of the structure as well. + + @param eType + denotes what kind of element to begin (e.g. a heading or paragraph) + + @param rAlias + the specified alias will be used as structure tag. Also an entry in the PDF's + role map will be created mapping alias to regular structure type. + + @returns + the id of the newly created structural element + */ + sal_Int32 BeginStructureElement( PDFWriter::StructElement eType, const rtl::OUString& rAlias = rtl::OUString() ); + /** end a logical structure element + + @see BeginStructureElement + */ + void EndStructureElement(); + /** set the current structure element + + <p> + For different purposes it may be useful to paint a structure element's + content discontinously. In that case an already existing structure element + can be appended to by using <code>SetCurrentStructureElement</code>. The + refenrenced structure element becomes the current structure element with + all consequences: all following structure elements are appended as children + of the current element. + </p> + + @param nElement + the id of the new current structure element + + @returns + <true/> if the current structure element could be set successfully + <false/> if the current structure element could not be changed + (e.g. if the passed element id is invalid) + */ + bool SetCurrentStructureElement( sal_Int32 nElement ); + /** get the current structure element id + + @returns + the id of the current structure element + */ + sal_Int32 GetCurrentStructureElement(); + + /** set a structure attribute on the current structural element + + SetStructureAttribute sets an attribute of the current structural element to a + new value. A consistency check is performed before actually setting the value; + if the check fails, the function returns <FALSE/> and the attribute remains + unchanged. + + @param eAttr + denotes what attribute to change + + @param eVal + the value to set the attribute to + + @returns + <TRUE/> if the value was valid and the change has been performed, + <FALSE/> if the attribute or value was invalid; attribute remains unchanged + */ + bool SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal ); + /** set a structure attribute on the current structural element + + SetStructureAttributeNumerical sets an attribute of the current structural element + to a new numerical value. A consistency check is performed before actually setting + the value; if the check fails, the function returns <FALSE/> and the attribute + remains unchanged. + + @param eAttr + denotes what attribute to change + + @param nValue + the value to set the attribute to + + @returns + <TRUE/> if the value was valid and the change has been performed, + <FALSE/> if the attribute or value was invalid; attribute remains unchanged + */ + bool SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue ); + /** set the bounding box of a structural element + + SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox + attribute can only be applied to <code>Table</code>, <code>Figure</code>, + <code>Form</code> and <code>Formula</code> elements, a call of this function + for other element types will be ignored and the BBox attribute not be set. + + @param rRect + the new bounding box for the structural element + */ + void SetStructureBoundingBox( const Rectangle& rRect ); + + /** set the ActualText attribute of a structural element + + ActualText contains the Unicode text without layout artifacts that is shown by + a structural element. For example if a line is ended prematurely with a break in + a word and continued on the next line (e.g. "happen-<newline>stance") the + corresponding ActualText would contain the unbroken line (e.g. "happenstance"). + + @param rText + contains the complete logical text the structural element displays. + */ + void SetActualText( const String& rText ); + + /** set the Alt attribute of a strutural element + + Alt is s replacement text describing the contents of a structural element. This + is mainly used by accessibility applications; e.g. a screen reader would read + the Alt replacement text for an image to a visually impaired user. + + @param rText + contains the replacement text for the structural element + */ + void SetAlternateText( const String& rText ); + + /** Sets the time in seconds a page will appear before the next + page is shown automatically + + @param nSeconds + time in seconds the current page will be shown; pass 0 for manual advancement + + @param nPageNr + the page number to apply the autoadvance time to; -1 denotes the current page + */ + void SetAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr = -1 ); + + /** Sets the transitional effect to be applied when the current page gets shown. + + @param eType + the kind of effect to be used; use Regular to disable transitional effects + for this page + + @param nMilliSec + the duration of the transitional effect in milliseconds; + set 0 to disable transitional effects + + @param nPageNr + the page number to apply the effect to; -1 denotes the current page + */ + void SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 ); + + /** create a new form control + + This function creates a new form control in the PDF and sets its various + properties. Do not pass an actual AnyWidget as <code>rControlType</code> + will be cast to the type described by the type member. + + @param rControlType + a descendant of <code>AnyWidget</code> determing the control's properties + */ + void CreateControl( const PDFWriter::AnyWidget& rControlType, sal_Int32 nPageNr = -1 ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/pdfwriter.hxx b/vcl/inc/vcl/pdfwriter.hxx new file mode 100644 index 000000000000..b1f76046678d --- /dev/null +++ b/vcl/inc/vcl/pdfwriter.hxx @@ -0,0 +1,1342 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _VCL_PDFWRITER_HXX +#define _VCL_PDFWRITER_HXX + +#include <sal/types.h> + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <tools/color.hxx> + +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> +#include <vcl/font.hxx> +#include <vcl/graphictools.hxx> + +#include "com/sun/star/io/XOutputStream.hpp" +#include "com/sun/star/beans/XMaterialHolder.hpp" + +#include <list> +#include <vector> +#include <set> + +class Font; +class Point; +class OutputDevice; +class GDIMetaFile; +class MapMode; +class Polygon; +class LineInfo; +class PolyPolygon; +class Bitmap; +class BitmapEx; +class Image; +class Gradient; +class Hatch; +class Wallpaper; + +namespace vcl +{ + +class PDFExtOutDevData; + +struct PDFNote +{ + String Title; // optional title for the popup containing the note + String Contents; // contents of the note +}; + +class VCL_DLLPUBLIC PDFOutputStream +{ + public: + virtual ~PDFOutputStream(); + virtual void write( const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xStream ) = 0; +}; + +class VCL_DLLPUBLIC PDFWriter +{ + void* pImplementation; +public: + // extended line info + enum CapType { capButt, capRound, capSquare }; + enum JoinType { joinMiter, joinRound, joinBevel }; + struct ExtLineInfo + { + double m_fLineWidth; + double m_fTransparency; + CapType m_eCap; + JoinType m_eJoin; + double m_fMiterLimit; + std::vector< double > m_aDashArray; + + ExtLineInfo() : m_fLineWidth( 0.0 ), + m_fTransparency( 0.0 ), + m_eCap( capButt ), + m_eJoin( joinMiter ), + m_fMiterLimit( 10.0 ) + {} + }; + + enum Orientation { Portrait, Landscape, Seascape, Inherit }; + + // in case the below enum is added PDF_1_6 PDF_1_7, please add them just after PDF_1_5 + enum PDFVersion { PDF_1_2, PDF_1_3, PDF_1_4, PDF_1_5, PDF_A_1 };//i59651, PDF/A-1b & -1a, only -1b implemented for now + // for the meaning of DestAreaType please look at PDF Reference Manual + // version 1.4 section 8.2.1, page 475 + enum DestAreaType { XYZ, Fit, FitHorizontal, FitVertical, + FitRectangle, FitPageBoundingBox, FitPageBoundingBoxHorizontal, + FitPageBoundingBoxVertical + }; + + // for a definition of structural element types please refer to + // PDF Reference, 3rd ed. section 9.7.4 + enum StructElement + { + // special element to place outside the structure hierarchy + NonStructElement, + // Grouping elements + Document, Part, Article, Section, Division, BlockQuote, + Caption, TOC, TOCI, Index, + + // block level elements + Paragraph, Heading, H1, H2, H3, H4, H5, H6, + List, ListItem, LILabel, LIBody, + Table, TableRow, TableHeader, TableData, + + // inline level elements + Span, Quote, Note, Reference, BibEntry, Code, Link, + + // illustration elements + Figure, Formula, Form + }; + + enum StructAttribute + { + Placement, WritingMode, SpaceBefore, SpaceAfter, StartIndent, EndIndent, + TextIndent, TextAlign, Width, Height, BlockAlign, InlineAlign, + LineHeight, BaselineShift, TextDecorationType, ListNumbering, + RowSpan, ColSpan, + + // link destination is an artificial attribute that sets + // the link annotation ID of a Link element + // further note: since structure attributes can only be + // set during content creation, but links can be + // created after the fact, it is possible to set + // an arbitrary id as structure attribute here. In this + // case the arbitrary id has to be passed again when the + // actual link annotation is created via SetLinkPropertyID + LinkAnnotation, + // Language currently sets a LanguageType (see i18npool/lang.h) + // which will be internally changed to a corresponding locale + Language + }; + + enum StructAttributeValue + { + Invalid, + NONE, + // Placement + Block, Inline, Before, After, Start, End, + // WritingMode + LrTb, RlTb, TbRl, + // TextAlign + Center, Justify, + // Width, Height, + Auto, + // BlockAlign + Middle, + // LineHeight + Normal, + // TextDecorationType + Underline, Overline, LineThrough, + // ListNumbering + Disc, Circle, Square, Decimal, UpperRoman, LowerRoman, UpperAlpha, LowerAlpha + }; + + enum PageTransition + { + Regular, + SplitHorizontalInward, SplitHorizontalOutward, + SplitVerticalInward, SplitVerticalOutward, + BlindsHorizontal, BlindsVertical, + BoxInward, BoxOutward, + WipeLeftToRight, WipeBottomToTop, WipeRightToLeft, WipeTopToBottom, + Dissolve, + GlitterLeftToRight, GlitterTopToBottom, GlitterTopLeftToBottomRight + }; + + enum WidgetType + { + PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox, Hierarchy + }; + + enum WidgetState + { + // PushButton, RadioButton, CheckBox; Down means selected for + // RadioButton and CheckBox + Up, Down + }; + + enum ErrorCode + { + // transparent object occurred and was draw opaque because + // PDF/A does not allow transparency + Warning_Transparency_Omitted_PDFA, + + // transparent object occurred but is only supported since + // PDF 1.4 + Warning_Transparency_Omitted_PDF13, + + // a form action was exported that is not suitable for PDF/A + // the action was skipped + Warning_FormAction_Omitted_PDFA, + + // transparent objects were converted to a bitmap in order + // to removetransparencies from the output + Warning_Transparency_Converted + }; + + struct VCL_DLLPUBLIC AnyWidget + { + protected: + WidgetType Type; // primitive RTTI + public: + rtl::OUString Name; // a distinct name to identify the control + rtl::OUString Description;// descriptive text for the contro (e.g. for tool tip) + rtl::OUString Text; // user text to appear on the control + sal_uInt16 TextStyle; // style flags + bool ReadOnly; + Rectangle Location; // describes the area filled by the control + bool Border; // true: widget should have a border, false: no border + Color BorderColor;// COL_TRANSPARENT and Border=true means get color from application settings + bool Background; // true: widget shall draw its background, false: no background + Color BackgroundColor; // COL_TRANSPARENT and Background=true means get color from application settings + Font TextFont; // an empty font will be replaced by the + // appropriate font from the user settings + Color TextColor; // COL_TRANSPARENT will be replaced by the appropriate color from application settings + sal_Int32 TabOrder; // lowest number is first in tab order + + /* style flags for text are those for OutputDevice::DrawText + allowed values are: + TEXT_DRAW_LEFT, TEXT_DRAW_CENTER, TEXT_DRAW_RIGHT, TEXT_DRAW_TOP, + TEXT_DRAW_VCENTER, TEXT_DRAW_BOTTOM, + TEXT_DRAW_MULTILINE, TEXT_DRAW_WORDBREAK + + if TextStyle is 0, then each control will fill in default values + */ + + // note: the Name member comprises the field name of the resulting + // PDF field names need to be globally unique. Therefore if any + // Widget with an already used name is created, the name will be + // made unique by adding an underscore ('_') and an ascending number + // to the name. + + AnyWidget( WidgetType eType ) : + Type( eType ), + TextStyle( 0 ), + ReadOnly( false ), + Border( false ), + BorderColor( COL_TRANSPARENT ), + Background( false ), + BackgroundColor( COL_TRANSPARENT ), + TextColor( COL_TRANSPARENT ), + TabOrder( -1 ) + {} + virtual ~AnyWidget(); + + WidgetType getType() const { return Type; } + + virtual AnyWidget* Clone() const = 0; + + protected: + // note that this equals the default compiler-generated copy-ctor, but we want to have it + // protected, to only allow sub classes to access it + AnyWidget( const AnyWidget& rSource ) + :Type( rSource.Type ) + ,Name( rSource.Name ) + ,Description( rSource.Description ) + ,Text( rSource.Text ) + ,TextStyle( rSource.TextStyle ) + ,ReadOnly( rSource.ReadOnly ) + ,Location( rSource.Location ) + ,Border( rSource.Border ) + ,BorderColor( rSource.BorderColor ) + ,Background( rSource.Background ) + ,BackgroundColor( rSource.BackgroundColor ) + ,TextFont( rSource.TextFont ) + ,TextColor( rSource.TextColor ) + ,TabOrder( rSource.TabOrder ) + { + } + AnyWidget& operator=( const AnyWidget& ); // never implemented + }; + + struct PushButtonWidget : public AnyWidget + { + /* If Dest is set to a valid link destination, + Then pressing the button will act as a goto + action within the docuemnt. + + Else: + An empty URL means this button will reset the form. + + If URL is not empty and Submit is set, then the URL + contained will be set as the URL to submit the + form to. In this case the submit method will be + either GET if SubmitGet is true or POST if + SubmitGet is false. + + If URL is not empty and Submit is clear, then + the URL contained will be interpreted as a + hyperlink to be executed on pushing the button. + + There will be no error checking or any kind of + conversion done to the URL parameter execept this: + it will be output as 7bit Ascii. The URL + will appear literally in the PDF file produced + */ + sal_Int32 Dest; + rtl::OUString URL; + bool Submit; + bool SubmitGet; + + PushButtonWidget() + : AnyWidget( vcl::PDFWriter::PushButton ), + Dest( -1 ), Submit( false ), SubmitGet( false ) + {} + + virtual AnyWidget* Clone() const + { + return new PushButtonWidget( *this ); + } + }; + + struct CheckBoxWidget : public AnyWidget + { + bool Checked; + bool ButtonIsLeft; + + CheckBoxWidget() + : AnyWidget( vcl::PDFWriter::CheckBox ), + Checked( false ), + ButtonIsLeft( true ) + {} + + virtual AnyWidget* Clone() const + { + return new CheckBoxWidget( *this ); + } + }; + + struct RadioButtonWidget : public AnyWidget + { + bool Selected; + sal_Int32 RadioGroup; + bool ButtonIsLeft; + rtl::OUString OnValue; // the value of the radio button if it is selected + + RadioButtonWidget() + : AnyWidget( vcl::PDFWriter::RadioButton ), + Selected( false ), + RadioGroup( 0 ), + ButtonIsLeft( true ) + {} + + virtual AnyWidget* Clone() const + { + return new RadioButtonWidget( *this ); + } + // radio buttons having the same RadioGroup id comprise one + // logical radio button group, that is at most one of the RadioButtons + // in a group can be checked at any time + // + // note: a PDF radio button field consists of a named field + // containing unnamed checkbox child fields. The name of the + // radio button field is taken from the first RadioButtonWidget created + // in the group + }; + + struct EditWidget : public AnyWidget + { + bool MultiLine; // whether multiple lines are allowed + bool Password; // visible echo off + bool FileSelect; // field is a file selector + sal_Int32 MaxLen; // maximum field length in characters, 0 means unlimited + + EditWidget() + : AnyWidget( vcl::PDFWriter::Edit ), + MultiLine( false ), + Password( false ), + FileSelect( false ), + MaxLen( 0 ) + {} + + virtual AnyWidget* Clone() const + { + return new EditWidget( *this ); + } + }; + + struct ListBoxWidget : public AnyWidget + { + bool DropDown; + bool Sort; + bool MultiSelect; + std::vector<rtl::OUString> Entries; + std::vector<sal_Int32> SelectedEntries; + // if MultiSelect is false only the first entry of SelectedEntries + // will be taken into account. the same is implicit for PDF < 1.4 + // since multiselect is a 1.4+ feature + + ListBoxWidget() + : AnyWidget( vcl::PDFWriter::ListBox ), + DropDown( false ), + Sort( false ), + MultiSelect( false ) + {} + + virtual AnyWidget* Clone() const + { + return new ListBoxWidget( *this ); + } + }; + + // note: PDF only supports dropdown comboboxes + struct ComboBoxWidget : public AnyWidget + { + bool Sort; + std::vector<rtl::OUString> Entries; + // set the current value in AnyWidget::Text + + ComboBoxWidget() + : AnyWidget( vcl::PDFWriter::ComboBox ), + Sort( false ) + {} + + virtual AnyWidget* Clone() const + { + return new ComboBoxWidget( *this ); + } + }; + + enum ExportDataFormat { HTML, XML, FDF, PDF }; +// see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also +// These emuns are treated as integer while reading/writing to configuration + enum PDFViewerPageMode + { + ModeDefault, + UseOutlines, + UseThumbs + }; +// These emuns are treated as integer while reading/writing to configuration + enum PDFViewerAction + { + ActionDefault, + FitInWindow, + FitWidth, + FitVisible, + ActionZoom + }; +// These enums are treated as integer while reading/writing to configuration + enum PDFPageLayout + { + DefaultLayout, + SinglePage, + Continuous, + ContinuousFacing + }; + + // These emuns are treated as integer while reading/writing to configuration + //what default action to generate in a PDF hyperlink to external document/site + enum PDFLinkDefaultAction + { + URIAction, + URIActionDestination, + LaunchAction + }; + +/* +The following structure describes the permissions used in PDF security + */ + struct PDFEncryptionProperties + { + + bool Security128bit; // true to select 128 bit encryption, false for 40 bit + //for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20. + bool CanPrintTheDocument; + bool CanModifyTheContent; + bool CanCopyOrExtract; + bool CanAddOrModify; + //for revision 3 (bit 128 security) only + bool CanFillInteractive; + bool CanExtractForAccessibility; + bool CanAssemble; + bool CanPrintFull; + + // encryption will only happen if EncryptionKey is not empty + // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier + // if these do not match, behavior is undefined, most likely an invalid PDF will be produced + // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from + // PDFDocInfo, Owner password and User password used the InitEncryption method which + // implements the algorithms described in the PDF reference chapter 3.5: Encryption + std::vector<sal_uInt8> OValue; + std::vector<sal_uInt8> UValue; + std::vector<sal_uInt8> EncryptionKey; + std::vector<sal_uInt8> DocumentIdentifier; + + //permission default set for 128 bit, accessibility only + PDFEncryptionProperties() : + Security128bit ( true ), + CanPrintTheDocument ( false ), + CanModifyTheContent ( false ), + CanCopyOrExtract ( false ), + CanAddOrModify ( false ), + CanFillInteractive ( false ), + CanExtractForAccessibility ( true ), + CanAssemble ( false ), + CanPrintFull ( false ) + {} + + + bool Encrypt() const + { return ! OValue.empty() && ! UValue.empty() && ! DocumentIdentifier.empty(); } + }; + + struct PDFDocInfo + { + String Title; // document title + String Author; // document author + String Subject; // subject + String Keywords; // keywords + String Creator; // application that created the original document + String Producer; // OpenOffice + }; + + enum ColorMode + { + DrawColor, DrawGreyscale + }; + + struct PDFWriterContext + { + /* must be a valid file: URL usable by osl */ + rtl::OUString URL; + /* the URL of the document being exported, used for relative links*/ + rtl::OUString BaseURL; + /*if relative to file system should be formed*/ + bool RelFsys;//i56629, i49415?, i64585? + /*the action to set the PDF hyperlink to*/ + PDFWriter::PDFLinkDefaultAction DefaultLinkAction; + //convert the .od? target file type in a link to a .pdf type + //this is examined before doing anything else + bool ConvertOOoTargetToPDFTarget; + //when the file type is .pdf, force the GoToR action + bool ForcePDFAction; + + /* decides the PDF language level to be produced */ + PDFVersion Version; + /* valid for PDF >= 1.4 + causes the MarkInfo entry in the document catalog to be set + */ + bool Tagged; + /* forces the embedding of PDF standard fonts */ + bool EmbedStandardFonts; + /* determines in which format a form + will be submitted. + */ + PDFWriter::ExportDataFormat SubmitFormat; + bool AllowDuplicateFieldNames; + bool FieldsUseSystemFonts; + /* the following data members are used to customize the PDF viewer + preferences + */ + /* see 3.6.1 PDF v 1.4 ref*/ + PDFWriter::PDFViewerPageMode PDFDocumentMode; + PDFWriter::PDFViewerAction PDFDocumentAction; + // in percent, valid only if PDFDocumentAction == ActionZoom + sal_Int32 Zoom; + + /* see 8.6 PDF v 1.4 ref + specifies whether to hide the viewer tool + bars when the document is active. + */ + bool HideViewerToolbar; + bool HideViewerMenubar; + bool HideViewerWindowControls; + bool FitWindow; + bool OpenInFullScreenMode; + bool CenterWindow; + bool DisplayPDFDocumentTitle; + PDFPageLayout PageLayout; + bool FirstPageLeft; + // intially visible page in viewer (starting with 0 for first page) + sal_Int32 InitialPage; + sal_Int32 OpenBookmarkLevels; // -1 means all levels + + PDFWriter::PDFEncryptionProperties Encryption; + PDFWriter::PDFDocInfo DocumentInfo; + + com::sun::star::lang::Locale DocumentLocale; // defines the document default language + sal_uInt32 DPIx, DPIy; // how to handle MapMode( MAP_PIXEL ) + // 0 here specifies a default handling + PDFWriter::ColorMode ColorMode; + + PDFWriterContext() : + RelFsys( false ), //i56629, i49415?, i64585? + DefaultLinkAction( PDFWriter::URIAction ), + ConvertOOoTargetToPDFTarget( false ), + ForcePDFAction( false ), + Version( PDFWriter::PDF_1_4 ), + Tagged( false ), + EmbedStandardFonts( false ), + SubmitFormat( PDFWriter::FDF ), + AllowDuplicateFieldNames( false ), + FieldsUseSystemFonts( true ), + PDFDocumentMode( PDFWriter::ModeDefault ), + PDFDocumentAction( PDFWriter::ActionDefault ), + Zoom( 100 ), + HideViewerToolbar( false ), + HideViewerMenubar( false ), + HideViewerWindowControls( false ), + FitWindow( false ), + OpenInFullScreenMode( false ), + CenterWindow( false ), + DisplayPDFDocumentTitle( true ), + PageLayout( PDFWriter::DefaultLayout ), + FirstPageLeft( false ), + InitialPage( 1 ), + OpenBookmarkLevels( -1 ), + Encryption(), + DPIx( 0 ), + DPIy( 0 ), + ColorMode( PDFWriter::DrawColor ) + {} + }; + + PDFWriter( const PDFWriterContext& rContext, const com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder >& ); + ~PDFWriter(); + + /** Returns an OutputDevice for formatting + <p>This Output device is guaranteed to use the same + font metrics as the resulting PDF file.</p> + + @returns + the reference output device + */ + OutputDevice* GetReferenceDevice(); + + /** Creates a new page to fill + <p>If width and height are not set the page size + is inherited from the page tree</p> + <p>other effects: + resets the graphics state: MapMode, Font + Colors and other state information MUST + be set again or are undefined. + </p> + + @returns + returns the page id of the new page + */ + sal_Int32 NewPage( sal_Int32 nPageWidth = 0, sal_Int32 nPageHeight = 0, Orientation eOrientation = Inherit ); + /** Play a metafile like an outputdevice would do + */ + struct PlayMetafileContext + { + int m_nMaxImageResolution; + bool m_bOnlyLosslessCompression; + int m_nJPEGQuality; + bool m_bTransparenciesWereRemoved; + + PlayMetafileContext() + : m_nMaxImageResolution( 0 ) + , m_bOnlyLosslessCompression( false ) + , m_nJPEGQuality( 90 ) + , m_bTransparenciesWereRemoved( false ) + {} + + }; + void PlayMetafile( const GDIMetaFile&, const PlayMetafileContext&, vcl::PDFExtOutDevData* pDevDat = NULL ); + + /* sets the document locale originally passed with the context to a new value + * only affects the output if used before calling <code>Emit/code>. + */ + void SetDocumentLocale( const com::sun::star::lang::Locale& rDocLocale ); + + /* finishes the file */ + bool Emit(); + + /* + * Get a list of errors that occurred during processing + * this should enable the producer to give feedback about + * any anomalies that might have occurred + */ + std::set< ErrorCode > GetErrors(); + + PDFVersion GetVersion() const; + + static com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder > + InitEncryption( const rtl::OUString& i_rOwnerPassword, + const rtl::OUString& i_rUserPassword, + bool b128Bit + ); + + /* functions for graphics state */ + /* flag values: see vcl/outdev.hxx */ + void Push( sal_uInt16 nFlags = 0xffff ); + void Pop(); + + void SetClipRegion(); + void SetClipRegion( const basegfx::B2DPolyPolygon& rRegion ); + void MoveClipRegion( long nHorzMove, long nVertMove ); + void IntersectClipRegion( const Rectangle& rRect ); + void IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ); + + void SetAntialiasing( sal_uInt16 nMode = 0 ); + + void SetLayoutMode( sal_uLong nMode ); + void SetDigitLanguage( LanguageType eLang ); + + void SetLineColor( const Color& rColor ); + void SetLineColor() { SetLineColor( Color( COL_TRANSPARENT ) ); } + + void SetFillColor( const Color& rColor ); + void SetFillColor() { SetFillColor( Color( COL_TRANSPARENT ) ); } + + void SetFont( const Font& rNewFont ); + void SetTextColor( const Color& rColor ); + void SetTextFillColor(); + void SetTextFillColor( const Color& rColor ); + + void SetTextLineColor(); + void SetTextLineColor( const Color& rColor ); + void SetOverlineColor(); + void SetOverlineColor( const Color& rColor ); + void SetTextAlign( ::TextAlign eAlign ); + + void SetMapMode(); + void SetMapMode( const MapMode& rNewMapMode ); + + + /* actual drawing functions */ + void DrawText( const Point& rPos, const String& rText ); + + void DrawTextLine( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontUnderline eUnderline, + FontUnderline eOverline, + sal_Bool bUnderlineAbove = sal_False ); + void DrawTextArray( const Point& rStartPt, const XubString& rStr, + const sal_Int32* pDXAry = NULL, + xub_StrLen nIndex = 0, + xub_StrLen nLen = STRING_LEN ); + void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, + const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ); + void DrawText( const Rectangle& rRect, + const XubString& rStr, sal_uInt16 nStyle = 0 ); + + void DrawPixel( const Point& rPt, const Color& rColor ); + void DrawPixel( const Point& rPt ) + { DrawPixel( rPt, Color( COL_TRANSPARENT ) ); } + void DrawPixel( const Polygon& rPts, const Color* pColors = NULL ); + void DrawPixel( const Polygon& rPts, const Color& rColor ) + { Push(); SetLineColor( rColor ); DrawPixel( rPts ); Pop(); } + + void DrawLine( const Point& rStartPt, const Point& rEndPt ); + void DrawLine( const Point& rStartPt, const Point& rEndPt, + const LineInfo& rLineInfo ); + void DrawPolyLine( const Polygon& rPoly ); + void DrawPolyLine( const Polygon& rPoly, + const LineInfo& rLineInfo ); + void DrawPolyLine( const Polygon& rPoly, const ExtLineInfo& rInfo ); + void DrawPolygon( const Polygon& rPoly ); + void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); + void DrawRect( const Rectangle& rRect ); + void DrawRect( const Rectangle& rRect, + sal_uLong nHorzRount, sal_uLong nVertRound ); + void DrawEllipse( const Rectangle& rRect ); + void DrawArc( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawPie( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawChord( const Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + void DrawBitmap( const Point& rDestPt, + const Bitmap& rBitmap ); + void DrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap ); + void DrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap ); + + void DrawBitmapEx( const Point& rDestPt, + const BitmapEx& rBitmapEx ); + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const BitmapEx& rBitmapEx ); + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const BitmapEx& rBitmapEx ); + + void DrawMask( const Point& rDestPt, + const Bitmap& rBitmap, const Color& rMaskColor ); + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap, const Color& rMaskColor ); + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const Color& rMaskColor ); + + void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); + void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); + + void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); + + void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); + void DrawTransparent( const PolyPolygon& rPolyPoly, + sal_uInt16 nTransparencePercent ); + + /** Start a transparency group + + Drawing operations can be grouped together to acquire a common transparency + behaviour; after calling <code>BeginTransparencyGroup</code> all drawing + operations will be grouped together into a transparent object. + + The transparency behaviour is set with ond of the <code>EndTransparencyGroup</code> + calls and can be either a constant transparency factor or a transparent + soft mask in form of an 8 bit gray scale bitmap. + + It is permissible to nest transparency group. + + Transparency groups MUST NOT span multiple pages + + Transparency is a feature introduced in PDF1.4, so transparency group + will be ignored if the produced PDF has a lower version. The drawing + operations will be emitted normally. + */ + void BeginTransparencyGroup(); + + /** End a transparency group with constant transparency factor + + This ends a transparency group and inserts it on the current page. The + coordinates of the group result out of the grouped drawing operations. + + @param rBoundRect + The bounding rectangle of the group + + @param nTransparencePercent + The transparency factor + */ + void EndTransparencyGroup( const Rectangle& rBoundRect, sal_uInt16 nTransparencePercent ); + + /** End a transparency group with an alpha mask + + This ends a transparency group and inserts it on the current page. The + coordinates of the group result out of the grouped drawing operations. + + @param rBoundRect + The bounding rectangle of the group + + @param rAlphaMask + The transparency mask; must be an 8 bit grayscale image + */ + void EndTransparencyGroup( const Rectangle& rBoundRect, const Bitmap& rAlphaMask ); + + /** Insert a JPG encoded image (optionally with mask) + + @param rJPGData + a Stream containing the encoded image + + @param bIsTrueColor + true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale + + @param rSrcSizePixel + size in pixel of the image + + @param rTargetArea + where to put the image + + @param rMask + optional mask; if not empty it must have + the same pixel size as the image and + be either 1 bit black&white or 8 bit grey + */ + void DrawJPGBitmap( SvStream& rJPGData, bool bIsTrueColor, const Size& rSrcSizePixel, const Rectangle& rTargetArea, const Bitmap& rMask ); + + /** Create a new named destination to be used in a link from another PDF document + + @parm sDestName + the name (label) of the bookmark, to be used to jump to + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateNamedDest( const rtl::OUString& sDestName, const Rectangle& rRect, sal_Int32 nPageNr = -1, DestAreaType eType = XYZ ); + /** Create a new destination to be used in a link + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateDest( const Rectangle& rRect, sal_Int32 nPageNr = -1, DestAreaType eType = XYZ ); + /** Create a new link on a page + + @param rRect + active rectangle of the link (that is the area that has to be + hit to activate the link) + + @param nPageNr + number of page the link is on (as returned by NewPage) + or -1 in which case the current page is used + + @returns + the link id (to be used in SetLinkDest, SetLinkURL) or + -1 if page id does not exist + */ + sal_Int32 CreateLink( const Rectangle& rRect, sal_Int32 nPageNr = -1 ); + /** Set the destination for a link + <p>will change a URL type link to a dest link if necessary</p> + + @param nLinkId + the link to be changed + + @param nDestId + the dest the link shall point to + @returns + 0 for success + -1 in case the link id does not exist + -2 in case the dest id does not exist + */ + sal_Int32 SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); + /** Set the URL for a link + <p>will change a dest type link to an URL type link if necessary</p> + @param nLinkId + the link to be changed + + @param rURL + the URL the link shall point to. + The URL will be parsed (and corrected) by the <code>com.sun.star.util.URLTransformer</code> + service; the result will then appear literally in the PDF file produced + + @returns + 0 for success + -1 in case the link id does not exist + */ + sal_Int32 SetLinkURL( sal_Int32 nLinkId, const rtl::OUString& rURL ); + /** Resolve link in logical structure + <p> + If a link is created after the corresponding visual appearance was drawn + it is not possible to set the link id as a property attribute to the + link structure item that should be created in tagged PDF around the + visual appearance of a link. + </p> + <p> + For this reason an arbitrary id can be given to + <code>SetStructureAttributeNumerical</code> at the time the text for + the link is drawn. To resolve this arbitrary id again when the actual + link annotation is created use SetLinkPropertyID. When <code>Emit</code> + finally gets called all <code>LinkAnnotation</code> type structure attributes + will be replaced with the correct link id. + </p> + <p> + CAUTION: this technique must be used either for all or none of the links + in a document since the link id space and arbitrary property id space + could overlap and it would be impossible to resolve whether a <code>Link</code> + structure attribute value was arbitrary or already a real id. + </p> + + @param nLinkId + the link to be mapped + + @param nPropertyID + the arbitrary id set in a <code>Link</code> structure element to address + the link with real id <code>nLinkId</code> + */ + void SetLinkPropertyID( sal_Int32 nLinkId, sal_Int32 nPropertyID ); + /** Create a new outline item + + @param nParent + declares the parent of the new item in the outline hierarchy. + An invalid value will result in a new toplevel item. + + @param rText + sets the title text of the item + + @param nDestId + declares which Dest (created with CreateDest) the outline item + will point to + + @returns + the outline item id of the new item + */ + sal_Int32 CreateOutlineItem( sal_Int32 nParent = 0, const rtl::OUString& rText = rtl::OUString(), sal_Int32 nDestID = -1 ); + + /** Set an outline item's parent + + @param nItem + specififies which item should be reparented. + + @param nNewParent + specifies which outline item will be the item's new parent. + Use 0 for reparenting to top level. + + @returns + -1 if the item does not exist + -2 if the new parent does not exist, item will be reparented to top level. + */ + sal_Int32 SetOutlineItemParent( sal_Int32 nItem, sal_Int32 nNewParent ); + + /** Set an outline item's title text + + @param nItem + specififies which item should get a new text + + @param rText + sets the title text of the item + + @returns + 0 if the item exists and the text was changed + -1 if the item does not exist + */ + sal_Int32 SetOutlineItemText( sal_Int32 nItem, const rtl::OUString& rText ); + + /** Set an outline item's destination + + @param nItem + specififies which item should get a new dest + + @param nDestID + specifies the item's new destination + + @returns + -1 if the item does not exist + -2 if the new dest does not exist, dest will remain unchanged + */ + sal_Int32 SetOutlineItemDest( sal_Int32 nItem, sal_Int32 nDestID ); + + /** Create a new note on a page + + @param rRect + active rectangle of the note (that is the area that has to be + hit to popup the annotation) + + @param rNote + specifies the contents of the note + + @param nPageNr + number of page the note is on (as returned by NewPage) + or -1 in which case the current page is used + */ + void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 ); + + /** begin a new logical structure element + + <p> + BeginStructureElement/EndStructureElement calls build the logical structure + of the PDF - the basis for tagged PDF. Structural elements are implemented + using marked content tags. Each structural element can contain sub elements + (e.g. a section can contain a heading and a paragraph). The structure hierarchy + is build automatically from the Begin/EndStructureElement calls. + + A structural element need not be contained on one page; e.g. paragraphs often + run from one page to the next. In this case the corresponding EndStructureElement + must be called while drawing the next page. + </p> + + <p> + BeginStructureElement and EndStructureElement must be called only after + <member scope="vcl">PDFWriter::NewPage</member> has been called and before + <member scope="vcl">PDFWriter::Emit</member>gets called. The current page + number is an implicit context parameter for Begin/EndStructureElement. + </p> + + <p> + For pagination artifacts that are not part of the logical structure + of the document (like header, footer or page number) the special + StructElement <code>NonStructElement</code> exists. To place content + outside of the struture tree simply call + <code>BeginStructureElement( NonStructElement )</code> then draw your + content and then call <code>EndStructureElement()</code>. All children + of a <code>NonStructElement</code> will not be part of the structure. + Nonetheless if you add a child structural element to a + <code>NonStructElement</code> you will still have to call + <code>EndStructureElement</code> for it. Best think of the structure + tree as a stack. + </p> + + <p> + Note: there is always one structural element in existance without having + called <code>BeginStructureElement</code>; this is the root of the structure + tree (called StructTreeRoot). The StructTreeRoot has always the id 0. + </p> + + @param eType + denotes what kind of element to begin (e.g. a heading or paragraph) + + @param rAlias + the specified alias will be used as structure tag. Also an entry in the PDF's + role map will be created mapping alias to regular structure type. + + @returns + the new structure element's id for use in <code>SetCurrentStructureElement</code> + */ + sal_Int32 BeginStructureElement( enum StructElement eType, const rtl::OUString& rAlias = rtl::OUString() ); + /** end the current logical structure element + + <p> + Close the current structure element. The current element's + parent becomes the current structure element again. + </p> + + @see BeginStructureElement + */ + void EndStructureElement(); + /** set the current structure element + + <p> + For different purposes it may be useful to paint a structure element's + content discontinously. In that case an already existing structure element + can be appended to by using <code>SetCurrentStructureElement</code>. The + refenrenced structure element becomes the current structure element with + all consequences: all following structure elements are appended as children + of the current element. + </p> + + @param nElement + the id of the new current structure element + + @returns + <true/> if the current structure element could be set successfully + <false/> if the current structure element could not be changed + (e.g. if the passed element id is invalid) + */ + bool SetCurrentStructureElement( sal_Int32 nElement ); + /** get the current structure element's id + + @returns + the id of the current structure element or -1 if no structure exists + (e.g. if no tagged PDF is being produced) + */ + sal_Int32 GetCurrentStructureElement(); + + /** set a structure attribute on the current structural element + + SetStructureAttribute sets an attribute of the current structural element to a + new value. A consistency check is performed before actually setting the value; + if the check fails, the function returns <FALSE/> and the attribute remains + unchanged. + + @param eAttr + denotes what attribute to change + + @param eVal + the value to set the attribute to + + @returns + <TRUE/> if the value was valid and the change has been performed, + <FALSE/> if the attribute or value was invalid; attribute remains unchanged + */ + bool SetStructureAttribute( enum StructAttribute eAttr, enum StructAttributeValue eVal ); + /** set a structure attribute on the current structural element + + SetStructureAttributeNumerical sets an attribute of the current structural element + to a new numerical value. A consistency check is performed before actually setting + the value; if the check fails, the function returns <FALSE/> and the attribute + remains unchanged. + + @param eAttr + denotes what attribute to change + + @param nValue + the value to set the attribute to + + @returns + <TRUE/> if the value was valid and the change has been performed, + <FALSE/> if the attribute or value was invalid; attribute remains unchanged + */ + bool SetStructureAttributeNumerical( enum StructAttribute eAttr, sal_Int32 nValue ); + /** set the bounding box of a structural element + + SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox + attribute can only be applied to <code>Table</code>, <code>Figure</code>, + <code>Form</code> and <code>Formula</code> elements, a call of this function + for other element types will be ignored and the BBox attribute not be set. + + @param rRect + the new bounding box for the structural element + */ + void SetStructureBoundingBox( const Rectangle& rRect ); + + /** set the ActualText attribute of a structural element + + ActualText contains the Unicode text without layout artifacts that is shown by + a structural element. For example if a line is ended prematurely with a break in + a word and continued on the next line (e.g. "happen-<newline>stance") the + corresponding ActualText would contain the unbroken line (e.g. "happenstance"). + + @param rText + contains the complete logical text the structural element displays. + */ + void SetActualText( const String& rText ); + + /** set the Alt attribute of a strutural element + + Alt is s replacement text describing the contents of a structural element. This + is mainly used by accessibility applications; e.g. a screen reader would read + the Alt replacement text for an image to a visually impaired user. + + @param rText + contains the replacement text for the structural element + */ + void SetAlternateText( const String& rText ); + + /** Sets the time in seconds a page will appear before the next + page is shown automatically + + @param nSeconds + time in seconds the current page will be shown; pass 0 for manual advancement + + @param nPageNr + the page number to apply the autoadvance time to; -1 denotes the current page + */ + void SetAutoAdvanceTime( sal_uInt32 nSeconds, sal_Int32 nPageNr = -1 ); + + /** Sets the transitional effect to be applied when the current page gets shown. + + @param eType + the kind of effect to be used; use Regular to disable transitional effects + for this page + + @param nMilliSec + the duration of the transitional effect in milliseconds; + set 0 to disable transitional effects + + @param nPageNr + the page number to apply the effect to; -1 denotes the current page + */ + void SetPageTransition( PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr = -1 ); + + /** create a new form control + + This function creates a new form control in the PDF and sets its various + properties. Do not pass an actual AnyWidget as <code>rControlType</code> + will be cast to the type described by the type member. + + @param rControlType + a descendant of <code>AnyWidget</code> determing the control's properties + + @returns + the new control's id for reference purposes + */ + sal_Int32 CreateControl( const AnyWidget& rControlType, sal_Int32 nPageNr = -1 ); + + /** Inserts an additional stream to the PDF file + + This function adds an arbitrary stream to the produced PDF file. May be called + any time before <code>Emit()</code>. The stream will be written during + <code>Emit</code> by calling the <code>PDFOutputStream</code> Object's <code>write</code> + method. After the call the <code>PDFOutputStream</code> will be deleted. + + All additional streams and their mimetypes will be entered into an array + in the trailer dictionary. + + @param rMimeType + the mimetype of the stream + + @param rStream + the interface to the additional stream + + @param bCompress + specifies whether the stream should be flate encoded by PDFWriter or not + */ + void AddStream( const String& rMimeType, PDFOutputStream* pStream, bool bCompress ); + + /** create a new pattern for filling operations + + This function creates a new pattern to be used for subsequent filling operations. + A pattern can consist of arbitrary drawing operations; all drawing operations + between <code>BeingPattern()</code> and <code>EndPattern()</code> calls + will be recorded and considered as forming up the pattern. + + @param rCellBounds + a rectangle defining the "cell" that will be repeated to form the pattern + */ + void BeginPattern( const Rectangle& ); + /** finish a new pattern for filling operations + + This functions finishes the pattern create begun with <code>BeginPattern()</code> + and returns a pattern id to be used in subsequent drawing operations. + + @param rMatrix + a transformation to be imposed on the drawing operations that make up the pattern + + @returns + the new pattern's id + */ + sal_Int32 EndPattern( const SvtGraphicFill::Transform& rTransformation ); + /** draw a polypolygon filled with a pattern + + @param rPolyPoly + PolyPolygon to filled + + @param nPatternId + the pattern previously obtained in the <code>EndPattern</code> call. + + @param bEOFill + true: polypolygon gets filled with EvenOdd method, + false: polypolygon gets filled with nonzero winding method + */ + void DrawPolyPolygon( const PolyPolygon& rPolyPoly, sal_Int32 nPatternId, bool bEOFill ); +}; + +} + +#endif // _VCL_PDFWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/pngread.hxx b/vcl/inc/vcl/pngread.hxx new file mode 100644 index 000000000000..64385f604537 --- /dev/null +++ b/vcl/inc/vcl/pngread.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PNGREAD_HXX +#define _SV_PNGREAD_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> +#include <vector> + +// ------------- +// - PNGReader - +// ------------- + +namespace vcl +{ + class PNGReaderImpl; + + class VCL_DLLPUBLIC PNGReader + { + PNGReaderImpl* mpImpl; + + public: + + /* the PNG chunks are read within the c'tor, so the stream will + be positioned at the end of the PNG */ + PNGReader( SvStream& rStm ); + ~PNGReader(); + + /* an empty preview size hint (=default) will read the whole image + */ + BitmapEx Read( const Size& i_rPreviewHint = Size() ); + + // retrieve every chunk that resides inside the PNG + struct ChunkData + { + sal_uInt32 nType; + std::vector< sal_uInt8 > aData; + }; + const std::vector< ChunkData >& GetChunks() const; + + void SetIgnoreGammaChunk( sal_Bool b ); + }; +} + +#endif // _SV_PNGREAD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/pngwrite.hxx b/vcl/inc/vcl/pngwrite.hxx new file mode 100644 index 000000000000..15c8c624a5ff --- /dev/null +++ b/vcl/inc/vcl/pngwrite.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PNGWRITE_HXX +#define _SV_PNGWRITE_HXX + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> +#include <vector> + +// ------------- +// - PNGWriter - +// ------------- + +namespace vcl +{ + class PNGWriterImpl; + + class VCL_DLLPUBLIC PNGWriter + { + PNGWriterImpl* mpImpl; + + public: + + PNGWriter( const BitmapEx& BmpEx, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData = NULL ); + ~PNGWriter(); + + sal_Bool Write( SvStream& rStm ); + + // additional method to be able to modify all chunk before they are stored + struct ChunkData + { + sal_uInt32 nType; + std::vector< sal_uInt8 > aData; + }; + std::vector< vcl::PNGWriter::ChunkData >& GetChunks(); + }; +} + +#endif // _SV_PNGWRITE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/pointr.hxx b/vcl/inc/vcl/pointr.hxx new file mode 100644 index 000000000000..d5d2a49b33f0 --- /dev/null +++ b/vcl/inc/vcl/pointr.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_POINTR_HXX +#define _VCL_POINTR_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/ptrstyle.hxx> + +class Point; + +// ----------- +// - Pointer - +// ----------- + +class VCL_DLLPUBLIC Pointer +{ + PointerStyle meStyle; + +public: + Pointer() + { meStyle = POINTER_ARROW; } + Pointer( PointerStyle eStyle ) + { meStyle = eStyle; } + + PointerStyle GetStyle() const { return meStyle; } + + sal_Bool operator==( const Pointer& rPointer ) const + { return (meStyle == rPointer.meStyle); } + sal_Bool operator!=( const Pointer& rPointer ) const + { return !(Pointer::operator==( rPointer )); } +}; + +#endif // _VCL_POINTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/polyscan.hxx b/vcl/inc/vcl/polyscan.hxx new file mode 100644 index 000000000000..da91477f6a67 --- /dev/null +++ b/vcl/inc/vcl/polyscan.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_POLYSCAN_HXX +#define _SV_POLYSCAN_HXX + +#include <tools/gen.hxx> + +// ----------------- +// - ScanlinePoint - +// ----------------- + +struct ScanlinePoint +{ + long mnX; + ScanlinePoint* mpNext; + + ScanlinePoint() : mnX( 0L ), mpNext( NULL ) {}; + ScanlinePoint( long nX, ScanlinePoint* pNext ) : mnX( nX ), mpNext( pNext ) {}; + ~ScanlinePoint() {}; + + void Set( long nX, ScanlinePoint* pNext ) { mnX = nX, mpNext = pNext; } +}; + +// ------------------- +// - PolyScanSegment - +// ------------------- + +struct PolyScanSegment +{ + long mnStart; + long mnEnd; + + PolyScanSegment() : mnStart( 0L ), mnEnd( 0L ) {}; + PolyScanSegment( long nStart, long nEnd ) : mnStart( nStart ), mnEnd( nEnd ) {}; + ~PolyScanSegment() {}; +}; + +// ---------------- +// - PolyScanline - +// ---------------- + +struct ScanlinePoint; +class Polygon; +class PolyPolygon; + +class PolyScanline +{ +private: + + ScanlinePoint* mpFirst; + ScanlinePoint* mpLast; + ScanlinePoint* mpAct; + long mnLeft; + long mnRight; + + void ImplDelete(); + +public: + + PolyScanline(); + ~PolyScanline(); + + void Insert( long nX ); + void Set( long nStart, long nEnd ); + void Set( const PolyScanSegment& rSegment ) { Set( rSegment.mnStart, rSegment.mnEnd ); } + + inline sal_Bool GetFirstX( long& rX ); + inline sal_Bool GetNextX( long& rX ); + + sal_Bool GetFirstSegment( PolyScanSegment& rSegment ); + sal_Bool GetNextSegment( PolyScanSegment& rSegment ); +}; + +// ------------------------------------------------------------------------ + +inline sal_Bool PolyScanline::GetFirstX( long& rX ) +{ + mpAct = mpFirst; + return( mpAct ? ( rX = mpAct->mnX, mpAct = mpAct->mpNext, sal_True ) : sal_False ); +} + +// ------------------------------------------------------------------------ + +inline sal_Bool PolyScanline::GetNextX( long& rX ) +{ + return( mpAct ? ( rX = mpAct->mnX, mpAct = mpAct->mpNext, sal_True ) : sal_False ); +} + +// --------------- +// - PolyScanner - +// --------------- + +class PolyScanner +{ +private: + + PolyScanline* mpArray; + long mnLeft; + long mnTop; + long mnRight; + long mnBottom; + + PolyScanner() {}; + +protected: + + void InsertLine( const Point& rStart, const Point& rEnd ); + +public: + + PolyScanner( const Rectangle& rRect ); + PolyScanner( const Polygon& rPoly ); + PolyScanner( const PolyPolygon& rPolyPoly ); + ~PolyScanner(); + + long Left() const { return mnLeft; } + long Top() const { return mnTop; } + long Right() const { return mnRight; } + long Bottom() const { return mnBottom; } + + long Width() const { return( mnRight - mnLeft + 1L ); } + long Height() const { return( mnBottom - mnTop + 1L ); } + + Rectangle GetBoundRect() const { return Rectangle( mnLeft, mnTop, mnRight, mnBottom ); } + + sal_uLong Count() const { return Height(); } + PolyScanline* operator[]( sal_uLong nPos ) const; +}; + +#endif // _SV_POLYSCAN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/popupmenuwindow.hxx b/vcl/inc/vcl/popupmenuwindow.hxx new file mode 100644 index 000000000000..9759ab42fb73 --- /dev/null +++ b/vcl/inc/vcl/popupmenuwindow.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __POPUPMENUWINDOW_HXX__ +#define __POPUPMENUWINDOW_HXX__ + +#include "vcl/floatwin.hxx" + +class VCL_DLLPUBLIC PopupMenuFloatingWindow : public FloatingWindow +{ +private: + struct ImplData; + ImplData* mpImplData; +public: + PopupMenuFloatingWindow( Window* pParent, WinBits nStyle = (WB_SYSTEMFLOATWIN|WB_SYSTEMWINDOW|WB_NOBORDER) ); + ~PopupMenuFloatingWindow(); + + sal_uInt16 GetMenuStackLevel() const; + void SetMenuStackLevel( sal_uInt16 nLevel ); + bool IsPopupMenu() const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/ppdparser.hxx b/vcl/inc/vcl/ppdparser.hxx new file mode 100644 index 000000000000..846835e22d3b --- /dev/null +++ b/vcl/inc/vcl/ppdparser.hxx @@ -0,0 +1,342 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _PSPRINT_PPDPARSER_HXX_ +#define _PSPRINT_PPDPARSER_HXX_ + +#include <list> +#include <vector> +#include <boost/unordered_map.hpp> + +#include "tools/string.hxx" +#include "tools/stream.hxx" + +#include "com/sun/star/lang/Locale.hpp" + +#define PRINTER_PPDDIR "driver" + +namespace psp { + +class PPDParser; +class PPDTranslator; + +enum PPDValueType { eInvocation, eQuoted, eSymbol, eString, eNo }; + +struct PPDValue +{ + PPDValueType m_eType; + String m_aOption; + String m_aValue; +}; + +// ---------------------------------------------------------------------- + +/* + * PPDKey - a container for the available options (=values) of a PPD keyword + */ + +class PPDKey +{ + friend class PPDParser; + + typedef ::boost::unordered_map< ::rtl::OUString, PPDValue, ::rtl::OUStringHash > hash_type; + typedef ::std::vector< PPDValue* > value_type; + + String m_aKey; + hash_type m_aValues; + value_type m_aOrderedValues; + const PPDValue* m_pDefaultValue; + bool m_bQueryValue; + PPDValue m_aQueryValue; + +public: + enum UIType { PickOne, PickMany, Boolean }; + enum SetupType { ExitServer, Prolog, DocumentSetup, PageSetup, JCLSetup, AnySetup }; +private: + + bool m_bUIOption; + UIType m_eUIType; + int m_nOrderDependency; + SetupType m_eSetupType; + + void eraseValue( const String& rOption ); +public: + PPDKey( const String& rKey ); + ~PPDKey(); + + PPDValue* insertValue( const String& rOption ); + int countValues() const + { return m_aValues.size(); } + // neither getValue will return the query option + const PPDValue* getValue( int n ) const; + const PPDValue* getValue( const String& rOption ) const; + const PPDValue* getValueCaseInsensitive( const String& rOption ) const; + const PPDValue* getDefaultValue() const { return m_pDefaultValue; } + const PPDValue* getQueryValue() const { return m_bQueryValue ? &m_aQueryValue : NULL; } + + const String& getKey() const { return m_aKey; } + bool isUIKey() const { return m_bUIOption; } + UIType getUIType() const { return m_eUIType; } + SetupType getSetupType() const { return m_eSetupType; } + int getOrderDependency() const { return m_nOrderDependency; } +}; + +// define a hash for PPDKey +struct PPDKeyhash +{ + size_t operator()( const PPDKey * pKey) const + { return (size_t)pKey; } +}; + +// ---------------------------------------------------------------------- + +/* + * PPDParser - parses a PPD file and contains all available keys from it + */ + +class PPDContext; +class CUPSManager; + +class PPDParser +{ + friend class PPDContext; + friend class CUPSManager; + friend class PPDCache; + + typedef ::boost::unordered_map< ::rtl::OUString, PPDKey*, ::rtl::OUStringHash > hash_type; + typedef ::std::vector< PPDKey* > value_type; + + void insertKey( const String& rKey, PPDKey* pKey ); +public: + struct PPDConstraint + { + const PPDKey* m_pKey1; + const PPDValue* m_pOption1; + const PPDKey* m_pKey2; + const PPDValue* m_pOption2; + + PPDConstraint() : m_pKey1( NULL ), m_pOption1( NULL ), m_pKey2( NULL ), m_pOption2( NULL ) {} + }; +private: + hash_type m_aKeys; + value_type m_aOrderedKeys; + ::std::list< PPDConstraint > m_aConstraints; + + // some identifying fields + String m_aPrinterName; + String m_aNickName; + // the full path of the PPD file + String m_aFile; + // some basic attributes + bool m_bColorDevice; + bool m_bType42Capable; + sal_uLong m_nLanguageLevel; + rtl_TextEncoding m_aFileEncoding; + + + // shortcuts to important keys and their default values + // imageable area + const PPDValue* m_pDefaultImageableArea; + const PPDKey* m_pImageableAreas; + // paper dimensions + const PPDValue* m_pDefaultPaperDimension; + const PPDKey* m_pPaperDimensions; + // paper trays + const PPDValue* m_pDefaultInputSlot; + const PPDKey* m_pInputSlots; + // resolutions + const PPDValue* m_pDefaultResolution; + const PPDKey* m_pResolutions; + // duplex commands + const PPDValue* m_pDefaultDuplexType; + const PPDKey* m_pDuplexTypes; + + // fonts + const PPDKey* m_pFontList; + + // translations + PPDTranslator* m_pTranslator; + + PPDParser( const String& rFile ); + ~PPDParser(); + + void parseOrderDependency( const ByteString& rLine ); + void parseOpenUI( const ByteString& rLine ); + void parseConstraint( const ByteString& rLine ); + void parse( std::list< ByteString >& rLines ); + + String handleTranslation( const ByteString& i_rString, bool i_bIsGlobalized ); + + static void scanPPDDir( const String& rDir ); + static void initPPDFiles(); + static String getPPDFile( const String& rFile ); +public: + static const PPDParser* getParser( const String& rFile ); + static String getPPDPrinterName( const String& rFile ); + static void freeAll(); + static void getKnownPPDDrivers( std::list< rtl::OUString >& o_rDrivers, bool bRefresh = false ); + + const String& getFilename() const { return m_aFile; } + + const PPDKey* getKey( int n ) const; + const PPDKey* getKey( const String& rKey ) const; + int getKeys() const { return m_aKeys.size(); } + bool hasKey( const PPDKey* ) const; + + const ::std::list< PPDConstraint >& getConstraints() const { return m_aConstraints; } + + const String& getPrinterName() const + { return m_aPrinterName.Len() ? m_aPrinterName : m_aNickName; } + const String& getNickName() const + { return m_aNickName.Len() ? m_aNickName : m_aPrinterName; } + + bool isColorDevice() const { return m_bColorDevice; } + bool isType42Capable() const { return m_bType42Capable; } + sal_uLong getLanguageLevel() const { return m_nLanguageLevel; } + + String getDefaultPaperDimension() const; + void getDefaultPaperDimension( int& rWidth, int& rHeight ) const + { getPaperDimension( getDefaultPaperDimension(), rWidth, rHeight ); } + bool getPaperDimension( const String& rPaperName, + int& rWidth, int& rHeight ) const; + // width and height in pt + // returns false if paper not found + int getPaperDimensions() const + { return m_pPaperDimensions ? m_pPaperDimensions->countValues() : 0; } + String getPaperDimension( int ) const; + String getPaperDimensionCommand( int ) const; + String getPaperDimensionCommand( const String & ) const; + + // match the best paper for width and height + String matchPaper( int nWidth, int nHeight ) const; + + bool getMargins( const String& rPaperName, + int &rLeft, int& rRight, + int &rUpper, int& rLower ) const; + // values in pt + // returns true if paper found + + // values int pt + + String getDefaultInputSlot() const; + int getInputSlots() const + { return m_pInputSlots ? m_pInputSlots->countValues() : 0; } + String getSlot( int ) const; + String getSlotCommand( int ) const; + String getSlotCommand( const String& ) const; + + void getDefaultResolution( int& rXRes, int& rYRes ) const; + int getResolutions() const; + void getResolution( int, int& rXRes, int& rYRes ) const; + String getResolutionCommand( int nXRes, int nYRes ) const; + // values in dpi + void getResolutionFromString( const String&, int&, int& ) const; + // helper function + + String getDefaultDuplexType() const; + int getDuplexTypes() const + { return m_pDuplexTypes ? m_pDuplexTypes->countValues() : 0; } + String getDuplex( int ) const; + String getDuplexCommand( int ) const; + String getDuplexCommand( const String& ) const; + + int getFonts() const + { return m_pFontList ? m_pFontList->countValues() : 0; } + void getFontAttributes( int, + String& rEncoding, + String& rCharset ) const; + void getFontAttributes( const String&, + String& rEncoding, + String& rCharset ) const; + String getFont( int ) const; + + + rtl::OUString translateKey( const rtl::OUString& i_rKey, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const; + rtl::OUString translateOption( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const; + rtl::OUString translateValue( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const; +}; + +// ---------------------------------------------------------------------- + +/* + * PPDContext - a class to manage user definable states based on the + * contents of a PPDParser. + */ + +class PPDContext +{ + typedef ::boost::unordered_map< const PPDKey*, const PPDValue*, PPDKeyhash > hash_type; + hash_type m_aCurrentValues; + const PPDParser* m_pParser; + + // returns false: check failed, new value is constrained + // true: check succeded, new value can be set + bool checkConstraints( const PPDKey*, const PPDValue*, bool bDoReset ); + bool resetValue( const PPDKey*, bool bDefaultable = false ); +public: + PPDContext( const PPDParser* pParser = NULL ); + PPDContext( const PPDContext& rContext ) { operator=( rContext ); } + PPDContext& operator=( const PPDContext& rContext ); + ~PPDContext(); + + void setParser( const PPDParser* ); + const PPDParser* getParser() const { return m_pParser; } + + const PPDValue* getValue( const PPDKey* ) const; + const PPDValue* setValue( const PPDKey*, const PPDValue*, bool bDontCareForConstraints = false ); + + int countValuesModified() const { return m_aCurrentValues.size(); } + const PPDKey* getModifiedKey( int n ) const; + + // public wrapper for the private method + bool checkConstraints( const PPDKey*, const PPDValue* ); + + void getUnconstrainedValues( const PPDKey*, ::std::list< const PPDValue* >& rValues ); + + // for printer setup + void* getStreamableBuffer( sal_uLong& rBytes ) const; + void rebuildFromStreamBuffer( void* pBuffer, sal_uLong nBytes ); + + // convenience + int getRenderResolution() const; + + // width, height in points, paper will contain the name of the selected + // paper after the call + void getPageSize( String& rPaper, int& rWidth, int& rHeight ) const; +}; + +} // namespace + +#endif // _PSPRINT_PPDPARSER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/print.h b/vcl/inc/vcl/print.h new file mode 100644 index 000000000000..db236f2a0f17 --- /dev/null +++ b/vcl/inc/vcl/print.h @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PRINT_H +#define _SV_PRINT_H + +#include "vcl/sv.h" +#include "vcl/dllapi.h" + +#include <vector> +#include <boost/unordered_map.hpp> + +struct SalPrinterQueueInfo; +class QueueInfo; +class JobSetup; + +namespace vcl +{ class PrinterListener; } + +// -------------------- +// - ImplPrnQueueData - +// -------------------- + +struct ImplPrnQueueData +{ + QueueInfo* mpQueueInfo; + SalPrinterQueueInfo* mpSalQueueInfo; +}; + +// -------------------- +// - ImplPrnQueueList - +// -------------------- + +class VCL_PLUGIN_PUBLIC ImplPrnQueueList +{ +public: + boost::unordered_map< rtl::OUString, sal_Int32, rtl::OUStringHash > + m_aNameToIndex; + std::vector< ImplPrnQueueData > m_aQueueInfos; + std::vector< rtl::OUString > m_aPrinterList; + + ImplPrnQueueList() {} + ~ImplPrnQueueList(); + + void Add( SalPrinterQueueInfo* pData ); + ImplPrnQueueData* Get( const rtl::OUString& rPrinter ); +}; + +// -------------- +// - Prototypes - +// -------------- + +void ImplDeletePrnQueueList(); +void SAL_DLLPRIVATE ImplUpdateJobSetupPaper( JobSetup& rJobSetup ); + + +#endif // _SV_PRINT_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx new file mode 100644 index 000000000000..182258aeb3c1 --- /dev/null +++ b/vcl/inc/vcl/print.hxx @@ -0,0 +1,704 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PRINT_HXX +#define _SV_PRINT_HXX + +#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/PropertyValue.hpp" +#include "com/sun/star/view/PrintableState.hpp" + +#include <boost/shared_ptr.hpp> +#include <boost/unordered_map.hpp> +#include <set> + +struct SalPrinterInfoQueue; +class SalInfoPrinter; +struct SalPrinterQueueInfo; +class SalPrinter; +class VirtualDevice; +class Window; + +namespace vcl { + class PrinterController; + class PrintDialog; +} + +// ----------------- +// - Printer-Types - +// ----------------- + +#define PAGEQUEUE_ALLPAGES 0xFFFF + +enum PrinterSupport { SUPPORT_SET_ORIENTATION, SUPPORT_SET_PAPERBIN, + SUPPORT_SET_PAPERSIZE, SUPPORT_SET_PAPER, + SUPPORT_COPY, SUPPORT_COLLATECOPY, + SUPPORT_SETUPDIALOG, SUPPORT_FAX, SUPPORT_PDF }; + +// --------------- +// - PrinterPage - +// --------------- + +class VCL_DLLPUBLIC PrinterPage +{ + GDIMetaFile* mpMtf; + JobSetup maJobSetup; + sal_uInt16 mbNewJobSetup; + +public: + + PrinterPage() : mpMtf( new GDIMetaFile() ) {} + PrinterPage( GDIMetaFile* pMtf, sal_Bool bNewJobSetup, const JobSetup& rSetup ) : + mpMtf( pMtf ), maJobSetup( rSetup ), mbNewJobSetup( bNewJobSetup ) {} + ~PrinterPage() { delete mpMtf; } + + GDIMetaFile* GetGDIMetaFile() const { return mpMtf; } + const JobSetup& GetJobSetup() const { return maJobSetup; } + sal_Bool IsNewJobSetup() const { return (mbNewJobSetup != 0); } + + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const PrinterPage& rPage ) + { rOStm << rPage.mbNewJobSetup; rOStm << rPage.maJobSetup; rPage.mpMtf->Write( rOStm ); return rOStm; } + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, PrinterPage& rPage ) + { return rIStm >> rPage.mbNewJobSetup >> rPage.maJobSetup >> *rPage.mpMtf; } +}; + + +// ------------- +// - QueueInfo - +// ------------- + +class VCL_DLLPUBLIC QueueInfo +{ + friend class Printer; + +private: + XubString maPrinterName; + XubString maDriver; + XubString maLocation; + XubString maComment; + sal_uInt32 mnStatus; + sal_uInt32 mnJobs; + +public: + QueueInfo(); + QueueInfo( const QueueInfo& rInfo ); + ~QueueInfo(); + + const XubString& GetPrinterName() const { return maPrinterName; } + const XubString& GetDriver() const { return maDriver; } + const XubString& GetLocation() const { return maLocation; } + const XubString& GetComment() const { return maComment; } + sal_uInt32 GetStatus() const { return mnStatus; } + sal_uInt32 GetJobs() const { return mnJobs; } + + bool operator==( const QueueInfo& rInfo ) const; + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, QueueInfo& rInfo ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const QueueInfo& rInfo ); +}; + +// ------------------ +// - PrinterOptions - +// ------------------ + +enum PrinterTransparencyMode +{ + PRINTER_TRANSPARENCY_AUTO = 0, + PRINTER_TRANSPARENCY_NONE = 1 +}; + +// ----------------------------------------------------------------------------- + +enum PrinterGradientMode +{ + PRINTER_GRADIENT_STRIPES = 0, + PRINTER_GRADIENT_COLOR = 1 +}; + +// ----------------------------------------------------------------------------- + +enum PrinterBitmapMode +{ + PRINTER_BITMAP_OPTIMAL = 0, + PRINTER_BITMAP_NORMAL = 1, + PRINTER_BITMAP_RESOLUTION = 2 +}; + +// ----------------------------------------------------------------------------- + +class VCL_DLLPUBLIC PrinterOptions +{ +private: + + sal_Bool mbReduceTransparency; + PrinterTransparencyMode meReducedTransparencyMode; + sal_Bool mbReduceGradients; + PrinterGradientMode meReducedGradientsMode; + sal_uInt16 mnReducedGradientStepCount; + sal_Bool mbReduceBitmaps; + PrinterBitmapMode meReducedBitmapMode; + sal_uInt16 mnReducedBitmapResolution; + sal_Bool mbReducedBitmapsIncludeTransparency; + sal_Bool mbConvertToGreyscales; + +public: + + PrinterOptions(); + ~PrinterOptions(); + + sal_Bool IsReduceTransparency() const { return mbReduceTransparency; } + void SetReduceTransparency( sal_Bool bSet ) { mbReduceTransparency = bSet; } + + PrinterTransparencyMode GetReducedTransparencyMode() const { return meReducedTransparencyMode; } + void SetReducedTransparencyMode( PrinterTransparencyMode eMode ) { meReducedTransparencyMode = eMode; } + + sal_Bool IsReduceGradients() const { return mbReduceGradients; } + void SetReduceGradients( sal_Bool bSet ) { mbReduceGradients = bSet; } + + PrinterGradientMode GetReducedGradientMode() const { return meReducedGradientsMode; } + void SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; } + + sal_uInt16 GetReducedGradientStepCount() const { return mnReducedGradientStepCount; } + void SetReducedGradientStepCount( sal_uInt16 nStepCount ) { mnReducedGradientStepCount = nStepCount; } + + sal_Bool IsReduceBitmaps() const { return mbReduceBitmaps; } + void SetReduceBitmaps( sal_Bool bSet ) { mbReduceBitmaps = bSet; } + + PrinterBitmapMode GetReducedBitmapMode() const { return meReducedBitmapMode; } + void SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; } + + sal_uInt16 GetReducedBitmapResolution() const { return mnReducedBitmapResolution; } + void SetReducedBitmapResolution( sal_uInt16 nResolution ) { mnReducedBitmapResolution = nResolution; } + + sal_Bool IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; } + void SetReducedBitmapIncludesTransparency( sal_Bool bSet ) { mbReducedBitmapsIncludeTransparency = bSet; } + + sal_Bool IsConvertToGreyscales() const { return mbConvertToGreyscales; } + void SetConvertToGreyscales( sal_Bool bSet ) { mbConvertToGreyscales = bSet; } + + // read printer options from configuration, parameter decides whether the set for + // print "to printer" or "to file" should be read. + // returns true if config was read, false if an error occured + bool ReadFromConfig( bool bFile ); +}; + +// ----------- +// - Printer - +// ----------- + +class VCL_DLLPUBLIC Printer : public OutputDevice +{ + friend class OutputDevice; + friend class ImplQPrinter; + +private: + SalInfoPrinter* mpInfoPrinter; + SalPrinter* mpPrinter; + SalGraphics* mpJobGraphics; + Printer* mpPrev; + Printer* mpNext; + VirtualDevice* mpDisplayDev; + PrinterOptions* mpPrinterOptions; + XubString maPrinterName; + XubString maDriver; + XubString maPrintFile; + XubString maJobName; + JobSetup maJobSetup; + Point maPageOffset; + Size maPaperSize; + sal_uLong mnError; + sal_uInt16 mnCurPage; + sal_uInt16 mnCurPrintPage; + sal_uInt16 mnPageQueueSize; + sal_uInt16 mnCopyCount; + sal_Bool mbDefPrinter; + sal_Bool mbPrinting; + sal_Bool mbJobActive; + sal_Bool mbCollateCopy; + sal_Bool mbPrintFile; + sal_Bool mbInPrintPage; + sal_Bool mbNewJobSetup; + sal_Bool mbIsQueuePrinter; + sal_Bool mbUserSetupCompleted; + sal_Bool mbUserSetupResult; + Link maErrorHdl; + + SAL_DLLPRIVATE void ImplInitData(); + SAL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo ); + SAL_DLLPRIVATE void ImplInitDisplay( const Window* pWindow ); + SAL_DLLPRIVATE static SalPrinterQueueInfo* ImplGetQueueInfo( const XubString& rPrinterName, + const XubString* pDriver ); + SAL_DLLPRIVATE void ImplUpdatePageData(); + SAL_DLLPRIVATE void ImplUpdateFontList(); + SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup&, bool bMatchNearest ); + DECL_DLLPRIVATE_LINK( ImplDestroyPrinterAsync, void* ); + + SAL_DLLPRIVATE bool StartJob( const rtl::OUString& rJobName, boost::shared_ptr<vcl::PrinterController>& ); + + static SAL_DLLPRIVATE sal_uLong ImplSalPrinterErrorCodeToVCL( sal_uLong nError ); + +private: + SAL_DLLPRIVATE void ImplEndPrint(); + SAL_DLLPRIVATE sal_Bool EndJob(); + SAL_DLLPRIVATE Printer( const Printer& rPrinter ); + SAL_DLLPRIVATE Printer& operator =( const Printer& rPrinter ); +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 ); + +protected: + + void SetSelfAsQueuePrinter( sal_Bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; } + sal_Bool IsQueuePrinter() const { return mbIsQueuePrinter; } + +public: + Printer(); + Printer( const Window* pWindow ); + Printer( const JobSetup& rJobSetup ); + Printer( const QueueInfo& rQueueInfo ); + Printer( const XubString& rPrinterName ); + virtual ~Printer(); + + static const std::vector< rtl::OUString >& GetPrinterQueues(); + static const QueueInfo* GetQueueInfo( const String& rPrinterName, bool bStatusUpdate ); + static XubString GetDefaultPrinterName(); + + virtual void Error(); + + const XubString& GetName() const { return maPrinterName; } + const XubString& GetDriverName() const { return maDriver; } + sal_Bool IsDefPrinter() const { return mbDefPrinter; } + sal_Bool IsDisplayPrinter() const { return mpDisplayDev != NULL; } + sal_Bool IsValid() const { return !IsDisplayPrinter(); } + + sal_uLong GetCapabilities( sal_uInt16 nType ) const; + sal_Bool HasSupport( PrinterSupport eFeature ) const; + + sal_Bool SetJobSetup( const JobSetup& rSetup ); + const JobSetup& GetJobSetup() const { return maJobSetup; } + String GetJobValue( const String& rKey ) const { return maJobSetup.GetValue( rKey ); } + void SetJobValue( const String& rKey, const String& rValue ) { maJobSetup.SetValue( rKey, rValue ); } + + sal_Bool Setup( Window* pWindow = NULL ); + sal_Bool SetPrinterProps( const Printer* pPrinter ); + + // SetPrinterOptions is used internally only now + // in earlier times it was used only to set the options loaded directly from the configuration + // in SfxPrinter::InitJob, this is now handled internally + // should the need arise to set the printer options outside vcl, also a method would have to be devised + // to not override these again internally + SAL_DLLPRIVATE void SetPrinterOptions( const PrinterOptions& rOptions ); + const PrinterOptions& GetPrinterOptions() const { return( *mpPrinterOptions ); } + + sal_Bool SetOrientation( Orientation eOrient ); + Orientation GetOrientation() const; + DuplexMode GetDuplexMode() const; + sal_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 + int GetLandscapeAngle() const; + sal_Bool SetPaperBin( sal_uInt16 nPaperBin ); + sal_uInt16 GetPaperBin() const; + sal_Bool SetPaper( Paper ePaper ); + sal_Bool SetPaperSizeUser( const Size& rSize ); + sal_Bool SetPaperSizeUser( const Size& rSize, bool bMatchNearest ); + Paper GetPaper() const; + static rtl::OUString GetPaperName( Paper ePaper ); + // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER + rtl::OUString GetPaperName( bool i_bPaperUser = true ) const; + + // returns number of available paper formats + int GetPaperInfoCount() const; + // returns info about paper format nPaper + const PaperInfo& GetPaperInfo( int nPaper ) const; + sal_uInt16 GetPaperBinCount() const; + XubString GetPaperBinName( sal_uInt16 nPaperBin ) const; + + const Size& GetPaperSizePixel() const { return maPaperSize; } + Size GetPaperSize() const { return PixelToLogic( maPaperSize ); } + const Point& GetPageOffsetPixel() const { return maPageOffset; } + Point GetPageOffset() const { return PixelToLogic( maPageOffset ); } + + sal_Bool SetCopyCount( sal_uInt16 nCopy, sal_Bool bCollate = sal_False ); + sal_uInt16 GetCopyCount() const { return mnCopyCount; } + sal_Bool IsCollateCopy() const { return mbCollateCopy; } + + sal_Bool IsPrinting() const { return mbPrinting; } + + sal_Bool AbortJob(); + const XubString& GetCurJobName() const { return maJobName; } + sal_uInt16 GetCurPage() const { return mnCurPage; } + sal_Bool IsJobActive() const { return mbJobActive; } + + sal_uLong GetError() const { return ERRCODE_TOERROR(mnError); } + sal_uLong GetErrorCode() const { return mnError; } + + void SetErrorHdl( const Link& rLink ) { maErrorHdl = rLink; } + const Link& GetErrorHdl() const { return maErrorHdl; } + + void Compat_OldPrinterMetrics( bool bSet ); + + /** checks the printer list and updates it necessary + * + * sends a DataChanged event of type DATACHANGED_PRINTER + * 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<vcl::PrinterController>& 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<vcl::PrinterController>& i_pController, + const JobSetup& i_rInitSetup + ); +}; + +namespace vcl +{ +class ImplPrinterControllerData; + +class VCL_DLLPUBLIC PrinterController +{ + ImplPrinterControllerData* mpImplData; +protected: + PrinterController( const boost::shared_ptr<Printer>& ); +public: + enum NupOrderType + { LRTB, TBLR, TBRL, RLTB }; + 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; + PrinterController::NupOrderType nOrder; + + MultiPageSetup() + : nRows( 1 ), nColumns( 1 ), nRepeat( 1 ), aPaperSize( 21000, 29700 ) + , nLeftMargin( 0 ), nTopMargin( 0 ) + , nRightMargin( 0 ), nBottomMargin( 0 ) + , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 ) + , bDrawBorder( false ) + , nOrder( LRTB ) + { + } + }; + + 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(); + + const boost::shared_ptr<Printer>& getPrinter() 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 PropertyValue of a Property + */ + 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; + /* 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 + */ + 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 + 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; + bool isUIChoiceEnabled( const rtl::OUString& rPropName, sal_Int32 nChoice ) 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 + (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. + */ + // 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 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; + + void abortJob(); + + bool isShowDialogs() const; + bool isDirectPrint() const; + + // implementation details, not usable outside vcl + // don't use outside vcl. Some of these are exported for + // the benefit of vcl's plugins. + // Still: DO NOT USE OUTSIDE VCL + VCL_PLUGIN_PUBLIC int getFilteredPageCount(); + SAL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, bool i_bMayUseCache = false ); + VCL_PLUGIN_PUBLIC 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<Printer>& ); + SAL_DLLPRIVATE void setOptionChangeHdl( const Link& ); + VCL_PLUGIN_PUBLIC void createProgressDialog(); + VCL_PLUGIN_PUBLIC bool isProgressCanceled() const; + SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); + SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const; + VCL_PLUGIN_PUBLIC void setLastPage( sal_Bool i_bLastPage ); + SAL_DLLPRIVATE void setReversePrint( sal_Bool i_bReverse ); + SAL_DLLPRIVATE bool getReversePrint() const; + SAL_DLLPRIVATE void pushPropertiesToPrinter(); + VCL_PLUGIN_PUBLIC 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; + + SAL_DLLPRIVATE sal_uLong removeTransparencies( GDIMetaFile& i_rIn, GDIMetaFile& o_rOut ); + SAL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput ); +}; + +class VCL_DLLPUBLIC PrinterOptionsHelper +{ + protected: + boost::unordered_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 occurred + * 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; + + // 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; + // 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 + sal_Bool getBoolValue( const char* i_pPropName, sal_Bool i_bDefault = sal_False ) const + { return getBoolValue( rtl::OUString::createFromAscii( i_pPropName ), i_bDefault ); } + + sal_Int64 getIntValue( const rtl::OUString& i_rPropertyName, sal_Int64 i_nDefault = 0 ) const; + // convenience for fixed strings + 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; + // 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 + struct UIControlOptions + { + rtl::OUString maDependsOnName; + sal_Int32 mnDependsOnEntry; + 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_bEnabled = sal_True + ) + : maDependsOnName( i_rDependsOnName ) + , mnDependsOnEntry( i_nDependsOnEntry ) + , mbAttachToDependency( i_bAttachToDependency ) + , maGroupHint( i_rGroupHint ) + , mbInternalOnly( i_bInternalOnly ) + , mbEnabled( i_bEnabled ) {} + }; + + // note: in the following helper functions HelpIds are expected as an rtl::OUString + // the normal HelpId form is rtl::OString (byte string instead of UTF16 string) + // this is because the whole interface is base on UNO properties; in fact the structures + // are passed over UNO interfaces. UNO does not know a byte string, hence the string is + // transported via UTF16 strings. + + // general control + static com::sun::star::uno::Any getUIControlOpt( const rtl::OUString& i_rTitle, + const com::sun::star::uno::Sequence< rtl::OUString >& i_rHelpId, + const rtl::OUString& i_rType, + const com::sun::star::beans::PropertyValue* i_pValue = NULL, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); + // 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, const rtl::OUString& i_rHelpId ); + + // 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_rHelpId, + 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_rHelpId, + const rtl::OUString& i_rProperty, + sal_Bool i_bValue, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); + + // 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_rHelpId, + 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 com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(), + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); + + // 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_rHelpId, + const rtl::OUString& i_rProperty, + sal_Int32 i_nValue, + sal_Int32 i_nMinValue = -1, + sal_Int32 i_nMaxValue = -2, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); + + // 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_rHelpId, + const rtl::OUString& i_rProperty, + const rtl::OUString& i_rValue, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); +}; + +} + + +#endif // _SV_PRINT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/printergfx.hxx b/vcl/inc/vcl/printergfx.hxx new file mode 100644 index 000000000000..8bfd1c69a7d2 --- /dev/null +++ b/vcl/inc/vcl/printergfx.hxx @@ -0,0 +1,444 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_PRINTERGFX_HXX_ +#define _PSPRINT_PRINTERGFX_HXX_ + +#include "vcl/helper.hxx" +#include "vcl/sallayout.hxx" +#include "osl/file.hxx" +#include "tools/gen.hxx" + +#include <list> +#include <boost/unordered_map.hpp> + +namespace psp { + +// forwards +class JobData; + +/* + * lightweight container to handle RGB values + */ + +class PrinterColor +{ +public: + + enum ColorSpace { eInvalid, eRGB }; + +private: + + sal_uInt8 mnRed; + sal_uInt8 mnGreen; + sal_uInt8 mnBlue; + ColorSpace meColorspace; + +public: + + PrinterColor () : + meColorspace(eInvalid) + {} + PrinterColor (sal_uInt16 nRed, sal_uInt16 nGreen, + sal_uInt16 nBlue) : + mnRed (nRed), + mnGreen (nGreen), + mnBlue (nBlue), + meColorspace (eRGB) + {} + PrinterColor (sal_uInt32 nRGB) : + mnRed ((nRGB & 0x00ff0000) >> 16), + mnGreen ((nRGB & 0x0000ff00) >> 8), + mnBlue ((nRGB & 0x000000ff) ), + meColorspace (eRGB) + {} + ~PrinterColor () + {} + + sal_Bool Is () const + { return meColorspace != eInvalid; } + + ColorSpace GetColorSpace () const + { return meColorspace; } + sal_uInt16 GetRed () const + { return mnRed; } + sal_uInt16 GetGreen () const + { return mnGreen; } + sal_uInt16 GetBlue () const + { return mnBlue; } + sal_Bool operator== (const PrinterColor& aColor) const + { + return aColor.Is() && this->Is() + && mnRed == aColor.mnRed + && mnGreen == aColor.mnGreen + && mnBlue == aColor.mnBlue; + } + sal_Bool operator!= (const PrinterColor& aColor) const + { return ! (aColor==*this); } + PrinterColor& operator= (const PrinterColor& aColor) + { + meColorspace = aColor.meColorspace; + mnRed = aColor.mnRed; + mnGreen = aColor.mnGreen; + mnBlue = aColor.mnBlue; + + return *this; + } + + PrinterColor& operator= (sal_uInt32 nRGB) + { + meColorspace = eRGB; + mnBlue = (nRGB & 0x000000ff); + mnGreen = (nRGB & 0x0000ff00) >> 8; + mnRed = (nRGB & 0x00ff0000) >> 16; + + return *this; + } +}; + +/* + * forward declarations + */ + +class Font3; +class GlyphSet; +class PrinterJob; +class PrintFontManager; +class KernPair; +struct CharacterMetric; + +/* + * Bitmap Interface, this has to be filled with your actual bitmap implementation + * sample implementations can be found in: + * psprint/workben/cui/pspdem.cxx + * vcl/unx/source/gdi/salgdi2.cxx + */ + +class PrinterBmp +{ +public: + + virtual ~PrinterBmp () = 0; + virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const = 0; + virtual sal_uInt32 GetPaletteEntryCount () const = 0; + virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0; + virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0; + virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0; + virtual sal_uInt32 GetWidth () const = 0; + virtual sal_uInt32 GetHeight () const = 0; + virtual sal_uInt32 GetDepth () const = 0; +}; + +typedef enum { + InvalidType = 0, + TrueColorImage, + MonochromeImage, + PaletteImage, + GrayScaleImage +} ImageType; + +/* + * printer raster operations + */ + +struct GraphicsStatus +{ + rtl::OString maFont; + rtl_TextEncoding maEncoding; + bool mbArtItalic; + bool mbArtBold; + sal_Int32 mnTextHeight; + sal_Int32 mnTextWidth; + PrinterColor maColor; + double mfLineWidth; + + GraphicsStatus(); +}; + +class Font3; + +class PrinterGfx +{ +private: + + /* common settings */ + + double mfScaleX; + double mfScaleY; + + sal_uInt32 mnDpi; + sal_uInt16 mnDepth; + + sal_uInt16 mnPSLevel; + sal_Bool mbColor; + sal_Bool mbUploadPS42Fonts; + + osl::File* mpPageHeader; + osl::File* mpPageBody; + + void TranslateCoordinates (sal_Int32 &rXOut, sal_Int32 &rYOut, + sal_Int32 nXIn, sal_Int32 nYIn ) + { rXOut = nXIn; rYOut = nYIn; } + void TranslateCoordinates (Point& rOut, const Point& rIn) + { rOut = rIn; } + + /* text/font related data, for a type1 font it has to be checked + whether this font has already been downloaded. A TrueType font + will be converted into one or more Type3 fonts, containing glyphs + in no particular order. In addition to the existence of the + glyph in one of the subfonts, the mapping from unicode to the + glyph has to be remembered */ + + std::list< sal_Int32 > maPS1Font; + std::list< GlyphSet > maPS3Font; + + sal_Int32 mnFontID; + sal_Int32 mnFallbackID; + sal_Int32 mnTextAngle; + bool mbTextVertical; + PrintFontManager& mrFontMgr; + + /* bitmap drawing implementation */ + + sal_Bool mbCompressBmp; + + void DrawPS1GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea); + void writePS2ImageHeader (const Rectangle& rArea, psp::ImageType nType); + void writePS2Colorspace (const PrinterBmp& rBitmap, psp::ImageType nType); + void DrawPS2GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea); + void DrawPS2PaletteImage (const PrinterBmp& rBitmap, const Rectangle& rArea); + void DrawPS2TrueColorImage (const PrinterBmp& rBitmap, const Rectangle& rArea); + void DrawPS2MonoImage (const PrinterBmp& rBitmap, const Rectangle& rArea); + + /* clip region */ + + std::list< Rectangle > maClipRegion; + sal_Bool JoinVerticalClipRectangles( std::list< Rectangle >::iterator& it, + Point& aOldPoint, sal_Int32& nColumn ); + + /* color settings */ + PrinterColor maFillColor; + PrinterColor maTextColor; + PrinterColor maLineColor; + + /* graphics state */ + GraphicsStatus maVirtualStatus; + std::list< GraphicsStatus > maGraphicsStack; + GraphicsStatus& currentState() { return maGraphicsStack.front(); } + + /* font / font substitution */ + friend class Font3; + const ::boost::unordered_map< fontID, fontID >* mpFontSubstitutes; + int getCharWidth (sal_Bool b_vert, sal_Unicode n_char, + CharacterMetric *p_bbox); + fontID getCharMetric (const Font3 &rFont, sal_Unicode n_char, + CharacterMetric *p_bbox); + fontID getFontSubstitute () const; + fontID getFallbackID () const { return mnFallbackID; } + + bool mbStrictSO52Compatibility; +public: + /* grahics status update */ + void PSSetColor (); + void PSSetLineWidth (); + void PSSetFont (); + + /* graphics status functions */ + void PSSetColor (const PrinterColor& rColor) + { maVirtualStatus.maColor = rColor; } + + void PSUploadPS1Font (sal_Int32 nFontID); + void PSSetFont (const rtl::OString& rName, + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_DONTKNOW) + { maVirtualStatus.maFont = rName; maVirtualStatus.maEncoding = nEncoding; } + + /* graphics status stack */ + void PSGSave (); + void PSGRestore (); + + + /* PS helpers */ + enum pspath_t { moveto = 0, lineto = 1 }; + void PSBinLineTo (const Point& rCurrent, Point& rOld, + sal_Int32& nColumn); + void PSBinMoveTo (const Point& rCurrent, Point& rOld, + sal_Int32& nColumn); + void PSBinStartPath (); + void PSBinEndPath (); + void PSBinCurrentPath (sal_uInt32 nPoints, const Point* pPath); + void PSBinPath (const Point& rCurrent, Point& rOld, + pspath_t eType, sal_Int32& nColumn); + + void PSRotate (sal_Int32 nAngle); + void PSTranslate (const Point& rPoint); + void PSMoveTo (const Point& rPoint); + void PSRMoveTo (sal_Int32 nDx, sal_Int32 nDy = 0); + void PSScale (double fScaleX, double fScaleY); + void PSLineTo(const Point& rPoint ); + void PSPointOp (const Point& rPoint, const sal_Char* pOperator); + void PSHexString (const sal_uChar* pString, sal_Int16 nLen); + void PSDeltaArray (const sal_Int32 *pArray, sal_Int16 nEntries); + void PSShowText (const sal_uChar* pString, + sal_Int16 nGlyphs, sal_Int16 nBytes, + const sal_Int32* pDeltaArray = NULL); + void PSComment (const sal_Char* pComment ); + void LicenseWarning (const Point& rPoint, const sal_Unicode* pStr, + sal_Int16 nLen, const sal_Int32* pDeltaArray); + + void OnEndPage (); + void OnEndJob (); + void writeResources( osl::File* pFile, std::list< rtl::OString >& rSuppliedFonts, std::list< rtl::OString >& rNeededFonts ); + PrintFontManager& GetFontMgr () { return mrFontMgr; } + + void drawVerticalizedText (const Point& rPoint, + const sal_Unicode* pStr, + sal_Int16 nLen, + const sal_Int32* pDeltaArray ); + void drawText (const Point& rPoint, + const sal_Unicode* pStr, sal_Int16 nLen, + const sal_Int32* pDeltaArray = NULL); + + void drawGlyphs( const Point& rPoint, + sal_GlyphId* pGlyphIds, + sal_Unicode* pUnicodes, + sal_Int16 nLen, + sal_Int32* pDeltaArray ); +public: + PrinterGfx(); + ~PrinterGfx(); + sal_Bool Init (PrinterJob &rPrinterSpec); + sal_Bool Init (const JobData& rData); + void Clear(); + + // query depth and size + void GetResolution (sal_Int32 &rDpiX, sal_Int32 &rDpiY) const; + sal_uInt16 GetBitCount (); + + // clip region + void ResetClipRegion (); + void BeginSetClipRegion (sal_uInt32); + sal_Bool UnionClipRegion (sal_Int32 nX, sal_Int32 nY, + sal_Int32 nDX, sal_Int32 nDY); + void EndSetClipRegion (); + + // set xy color + void SetLineColor (const PrinterColor& rLineColor = PrinterColor()) + { maLineColor = rLineColor; } + void SetFillColor (const PrinterColor& rFillColor = PrinterColor()) + { maFillColor = rFillColor; } + + // drawing primitives + void DrawPixel (const Point& rPoint, const PrinterColor& rPixelColor); + void DrawPixel (const Point& rPoint) + { DrawPixel (rPoint, maLineColor); } + void DrawLine (const Point& rFrom, const Point& rTo); + void DrawRect (const Rectangle& rRectangle); + void DrawPolyLine (sal_uInt32 nPoints, const Point* pPath ); + void DrawPolygon (sal_uInt32 nPoints, const Point* pPath); + void DrawPolyPolygon (sal_uInt32 nPoly, + const sal_uInt32 *pPolygonSize, + const Point** pPolygonList); + void DrawPolyLineBezier (sal_uInt32 nPoints, + const Point* pPath, + const sal_uInt8* pFlgAry ); + void DrawPolygonBezier (sal_uInt32 nPoints, + const Point* pPath, + const sal_uInt8* pFlgAry); + void DrawPolyPolygonBezier (sal_uInt32 nPoly, + const sal_uInt32* pPoints, + const Point* const* pPtAry, + const sal_uInt8* const* pFlgAry); + + // eps + sal_Bool DrawEPS ( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize); + + // image drawing + void DrawBitmap (const Rectangle& rDest, const Rectangle& rSrc, + const PrinterBmp& rBitmap); + void DrawBitmap (const Rectangle& rDest, const Rectangle& rSrc, + const PrinterBmp& rBitmap, + const PrinterBmp& rTransBitmap); + void DrawMask (const Rectangle& rDest, const Rectangle& rSrc, + const PrinterBmp &rBitmap, PrinterColor& rMaskColor); + + // font and text handling + sal_uInt16 SetFont ( + sal_Int32 nFontID, + sal_Int32 nPointHeight, + sal_Int32 nPointWidth, + sal_Int32 nAngle, + bool bVertical, + bool bArtItalic, + bool bArtBold + ); + sal_uInt16 SetFallbackFont ( sal_Int32 nFontID ); + sal_Int32 GetFontAngle () const + { return mnTextAngle; } + sal_Int32 GetFontID () const + { return mnFontID; } + bool GetFontVertical() const + { return mbTextVertical; } + sal_Int32 GetFontHeight () const + { return maVirtualStatus.mnTextHeight; } + sal_Int32 GetFontWidth () const + { return maVirtualStatus.mnTextWidth; } + bool GetArtificialItalic() const + { return maVirtualStatus.mbArtItalic; } + bool GetArtificialBold() const + { return maVirtualStatus.mbArtBold; } + void DrawText (const Point& rPoint, + const sal_Unicode* pStr, sal_Int16 nLen, + const sal_Int32* pDeltaArray = NULL); + void SetTextColor (PrinterColor& rTextColor) + { maTextColor = rTextColor; } + sal_Int32 GetCharWidth (sal_uInt16 nFrom, sal_uInt16 nTo, + long *pWidthArray); + const ::std::list< KernPair >& getKernPairs( bool bVertical = false ) const; + // advanced font handling + sal_Bool GetGlyphBoundRect (sal_Unicode c, Rectangle& rOutRect); + sal_uInt32 GetGlyphOutline (sal_Unicode c, + sal_uInt16 **ppPolySizes, Point **ppPoints, + sal_uInt8 **ppFlags); + + // for CTL + void DrawGlyphs( const Point& rPoint, + sal_GlyphId* pGlyphIds, + sal_Unicode* pUnicodes, + sal_Int16 nLen, + sal_Int32* pDeltaArray ); + + bool getStrictSO52Compatibility() const; + void setStrictSO52Compatibility( bool ); +}; + +} /* namespace psp */ + + +#endif /* _PSPRINT_PRINTERGFX_HXX_ */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/printerinfomanager.hxx b/vcl/inc/vcl/printerinfomanager.hxx new file mode 100644 index 000000000000..b6ebc072b8cf --- /dev/null +++ b/vcl/inc/vcl/printerinfomanager.hxx @@ -0,0 +1,249 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_ +#define _PSPRINT_PRINTERINFOMANAGER_HXX_ + +#include <boost/unordered_map.hpp> +#include <list> + +#include "vcl/dllapi.h" +#include "vcl/helper.hxx" +#include "vcl/jobdata.hxx" +#include "vcl/helper.hxx" +#include "osl/file.hxx" + +#include <cstdio> + +namespace psp +{ + +class SystemQueueInfo; + +struct PrinterInfo : JobData +{ + // basename of PPD + rtl::OUString m_aDriverName; + // can be the queue + rtl::OUString m_aLocation; + // a user defined comment + rtl::OUString m_aComment; + // a command line to pipe a PS-file to + rtl::OUString m_aCommand; + // a command line to pipe a PS-file to in case of direct print + rtl::OUString m_aQuickCommand; + // a list of special features separated by ',' not used by psprint + // but assigned from the outside (currently for "fax","pdf=","autoqueue","external_dialog") + rtl::OUString m_aFeatures; + // a mapping of fonts to other fonts. + // this provides a method for the user + // to replace arbitrary fonts by printer builtin fonts + // currently this is only a mapping between font names + // assuming that only adbobe standard encoding fonts are + // built into the printer. in future it may be necessary + // to map to a font name and UCS2 vector which should be mapped + // this vector is currently implicitly given by the adobe + // standard encoding + bool m_bPerformFontSubstitution; + boost::unordered_map< rtl::OUString, rtl::OUString, rtl::OUStringHash > + m_aFontSubstitutes; + boost::unordered_map< fontID, fontID > + m_aFontSubstitutions; + + PrinterInfo() : + JobData(), + m_bPerformFontSubstitution( false ) + {} +}; + +class VCL_DLLPUBLIC PrinterInfoManager +{ +public: + enum Type { Default = 0, CUPS = 1 }; + + struct SystemPrintQueue + { + rtl::OUString m_aQueue; + rtl::OUString m_aLocation; + rtl::OUString m_aComment; + }; +protected: + // needed for checkPrintersChanged: files (not necessarily existant) + // and their last known modification time + struct WatchFile + { + // the file in question + rtl::OUString m_aFilePath; + // the last know modification time or 0, if file did not exist + TimeValue m_aModified; + }; + + // internal data to describe a printer + struct Printer + { + // configuration file containing this printer + // empty means a freshly added printer that has to be saved yet + rtl::OUString m_aFile; + // details other config files that have this printer + // in case of removal all have to be removed + std::list< rtl::OUString > m_aAlternateFiles; + // group in m_aFile containing the printer + // this must be unique over all configuration files + // it usually should be the printer name + rtl::OString m_aGroup; + // whether changes need to be saved + bool m_bModified; + // the corresponding info and job data + PrinterInfo m_aInfo; + }; + + boost::unordered_map< rtl::OUString, Printer, rtl::OUStringHash > m_aPrinters; + PrinterInfo m_aGlobalDefaults; + std::list< WatchFile > m_aWatchFiles; + rtl::OUString m_aDefaultPrinter; + rtl::OUString m_aSystemPrintCommand; + + std::list< SystemPrintQueue > m_aSystemPrintQueues; + + SystemQueueInfo* m_pQueueInfo; + + Type m_eType; + bool m_bUseIncludeFeature; + bool m_bUseJobPatch; + rtl::OUString m_aSystemDefaultPaper; + + bool m_bDisableCUPS; + + PrinterInfoManager( Type eType = Default ); + + virtual void initialize(); + + // fill in font substitutions + // the resulting boost::unordered_map maps from source to target font ids + void fillFontSubstitutions( PrinterInfo& rInfo ) const; + + // fill default paper if not configured in config file + // default paper is e.g. locale dependent + // if a paper is already set it will not be overwritten + void setDefaultPaper( PPDContext& rInfo ) const; + + void initSystemDefaultPaper(); +public: + + // there can only be one + static PrinterInfoManager& get(); + // only called by SalData destructor, frees the global instance + static void release(); + + // get PrinterInfoManager type + Type getType() const { return m_eType; } + + // lists the names of all known printers + void listPrinters( std::list< rtl::OUString >& rList ) const; + + // gets the number of known printers + int countPrinters() const { return m_aPrinters.size(); } + + // gets info about a named printer + const PrinterInfo& getPrinterInfo( const rtl::OUString& rPrinter ) const; + + // gets the name of the default printer + const rtl::OUString& getDefaultPrinter() const { return m_aDefaultPrinter; } + + virtual void setupJobContextData( JobData& rData ); + + // changes the info about a named printer + virtual void changePrinterInfo( const rtl::OUString& rPrinter, const PrinterInfo& rNewInfo ); + + // check if the printer configuration has changed + // if bwait is true, then this method waits for eventual asynchronous + // printer discovery to finish + virtual bool checkPrintersChanged( bool bWait ); + + // members for administration (->padmin) + + // add a named printer + // addPrinter fails if a printer with the same name already exists + // or the driver does not exist + virtual bool addPrinter( const rtl::OUString& rPrinterName, const rtl::OUString& rDriverName ); + + // remove a named printer + // this fails if the config file belonging to this printer + // is not writeable + // if bCheckOnly is true, the printer is not really removed; + // this is for checking if the removal would fail + virtual bool removePrinter( const rtl::OUString& rPrinterName, bool bCheckOnly = false ); + + // save the changes to all printers. this fails if there + // is no writable config file at all + virtual bool writePrinterConfig(); + + // set a new default printer + // fails if the specified printer does not exist + virtual bool setDefaultPrinter( const rtl::OUString& rPrinterName ); + + // primarily used internally but also by padmin + // returns the printer queue names + virtual const std::list< SystemPrintQueue >& getSystemPrintQueues(); + + // similar but returnse whole commandlines + virtual void getSystemPrintCommands( std::list< rtl::OUString >& rCommands ); + + // abstract print command + // returns a stdio FILE* that a postscript file may be written to + // this may either be a regular file or the result of popen() + virtual FILE* startSpool( const rtl::OUString& rPrinterName, bool bQuickCommand ); + // close the FILE* returned by startSpool and does the actual spooling + // set bBanner to "false" will attempt to suppress banner printing + // set bBanner to "true" will rely on the system default + // returns a numerical job id + virtual int endSpool( const rtl::OUString& rPrinterName, const rtl::OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner ); + + // for spadmin: whether adding or removing a printer is possible + virtual bool addOrRemovePossible() const; + + bool getUseIncludeFeature() const { return m_bUseIncludeFeature; } + bool getUseJobPatch() const { return m_bUseJobPatch; } + + // check whether a printer's feature string contains a subfeature + bool checkFeatureToken( const rtl::OUString& rPrinterName, const char* pToken ) const; + + // set m_bDisableCUPS and update printer config + void setCUPSDisabled( bool ); + + // gets m_bDisableCUPS, initialized from printer config + bool isCUPSDisabled() const; + + virtual ~PrinterInfoManager(); +}; + +} // namespace + +#endif // _PSPRINT_PRINTERINFOMANAGER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/printerjob.hxx b/vcl/inc/vcl/printerjob.hxx new file mode 100644 index 000000000000..62a1c078bc32 --- /dev/null +++ b/vcl/inc/vcl/printerjob.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PSPRINT_PRINTERJOB_HXX_ +#define _PSPRINT_PRINTERJOB_HXX_ + +#include "vcl/jobdata.hxx" +#include "osl/file.hxx" +#include "rtl/string.hxx" + +#include <list> + +namespace psp { + +// forward declarations +class PrinterGfx; + + +class PrinterJob +{ +private: // private data + + rtl::OUString maSpoolDirName; + rtl::OUString maFileName; // empty: spool to command, else spool to named file + rtl::OUString maJobTitle; + int mnFileMode; + + osl::File* mpJobHeader; + osl::File* mpJobTrailer; + + std::list< osl::File* > maPageList; + std::list< osl::File* > maHeaderList; + + JobData m_aDocumentJobData; + JobData m_aLastJobData; + PrinterGfx* m_pGraphics; + + sal_uInt32 mnResolution; + + sal_uInt32 mnWidthPt; + sal_uInt32 mnHeightPt; + sal_uInt32 mnMaxWidthPt; + sal_uInt32 mnMaxHeightPt; + + int mnLandscapes; + int mnPortraits; + + sal_uInt32 mnLMarginPt; + sal_uInt32 mnRMarginPt; + sal_uInt32 mnTMarginPt; + sal_uInt32 mnBMarginPt; + + double mfXScale; + double mfYScale; + + sal_Int32 mnErrorCode; + bool m_bQuickJob; + +private: // private methods + + osl::File* CreateSpoolFile (const rtl::OUString& rName, + const rtl::OUString& rExtension); + void InitPaperSize (const JobData& rJobSetup); + + bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup ); + bool writeSetup( 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& ); + +public: // for usage in PrinterGfx + + sal_uInt32 GetResolution () const { return mnResolution; } + void GetScale (double &rXScale, double &rYScale) const; + sal_uInt16 GetDepth () const; + sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const; + sal_Bool IsColorPrinter () const; + + osl::File* GetDocumentHeader (); + osl::File* GetDocumentTrailer (); + osl::File* GetCurrentPageHeader (); + osl::File* GetCurrentPageBody (); + + const ::rtl::OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; } + +public: + PrinterJob (); + ~PrinterJob (); + + /* rFileName: if length is greater than 0 save resulting PostScript + * to named file. + * nMode: only meaningful when saving to file: if nonzero, try + * to impose the mode on the resulting file's inode; for nonexistant + * files use open, for existant files try a chmod + * rJobName: text to appear in the %%Title comment + * rAppName: text to appear in the %%Creator comment + * rSetupData: JobData that apply to this job + * pGraphics: the graphics used to print this job; + * this graphics must live until End/AbortJob has returned + * bIsQuickJob: the job was started as "direct print" meaning + * the quick command for spooling should be used instead + * of the normal command + */ + sal_Bool StartJob (const rtl::OUString& rFileName, + int nMode, + const rtl::OUString& rJobName, + const rtl::OUString& rAppName, + const JobData& rSetupData, + PrinterGfx* pGraphics, + bool bIsQuickJob + ); + sal_Bool EndJob (); + + sal_Bool AbortJob (); + + sal_Bool StartPage (const JobData& rJobSetup); + sal_Bool EndPage (); + + sal_uInt32 GetErrorCode (); +}; + +} /* namespace psp */ + +#endif /* _PSPRINT_PRINTERJOB_HXX_ */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/prndlg.hxx b/vcl/inc/vcl/prndlg.hxx new file mode 100644 index 000000000000..247998303178 --- /dev/null +++ b/vcl/inc/vcl/prndlg.hxx @@ -0,0 +1,337 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PRNDLG_HXX +#define _SV_PRNDLG_HXX + +#include <vcl/dllapi.h> + +#include "vcl/print.hxx" +#include "vcl/print.h" + +#include "vcl/dialog.hxx" +#include "vcl/fixed.hxx" +#include "vcl/button.hxx" +#include "vcl/gdimtf.hxx" +#include "vcl/lstbox.hxx" +#include "vcl/field.hxx" +#include "vcl/tabctrl.hxx" +#include "vcl/tabpage.hxx" +#include "vcl/arrange.hxx" +#include "vcl/virdev.hxx" + +#include <boost/shared_ptr.hpp> +#include <map> + +namespace vcl +{ + class PrintDialog : public ModalDialog + { + class PrintPreviewWindow : public Window + { + GDIMetaFile maMtf; + Size maOrigSize; + Size maPreviewSize; + VirtualDevice maPageVDev; + rtl::OUString maReplacementString; + rtl::OUString maToolTipString; + bool mbGreyscale; + FixedLine maHorzDim; + FixedLine maVertDim; + + public: + PrintPreviewWindow( Window* pParent, const ResId& ); + virtual ~PrintPreviewWindow(); + + 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& i_rPaperSize, + const rtl::OUString& i_rPaperName, + const rtl::OUString& i_rNoPageString, + sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, + bool i_bGreyscale + ); + }; + + 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: + FixedLine maNupLine; + RadioButton maPagesBtn; + RadioButton maBrochureBtn; + FixedText maPagesBoxTitleTxt; + ListBox maNupPagesBox; + + // controls for "Custom" page mode + FixedText maNupNumPagesTxt; + NumericField maNupColEdt; + FixedText maNupTimesTxt; + NumericField maNupRowsEdt; + FixedText maPageMarginTxt1; + MetricField maPageMarginEdt; + FixedText maPageMarginTxt2; + FixedText maSheetMarginTxt1; + MetricField maSheetMarginEdt; + FixedText maSheetMarginTxt2; + FixedText maNupOrientationTxt; + ListBox maNupOrientationBox; + + // page order ("left to right, then down") + FixedText maNupOrderTxt; + ListBox maNupOrderBox; + ShowNupOrderWindow maNupOrderWin; + // border around each page + CheckBox maBorderCB; + + boost::shared_ptr< vcl::RowOrColumn > mxBrochureDep; + boost::shared_ptr< vcl::LabeledElement >mxPagesBtnLabel; + + void setupLayout(); + + NUpTabPage( Window*, const ResId& ); + virtual ~NUpTabPage(); + + void readFromSettings(); + void storeToSettings(); + void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& ); + void enableNupControls( bool bEnable ); + + void showAdvancedControls( bool ); + + // virtual void Resize(); + }; + + class JobTabPage : public TabPage + { + public: + FixedLine maPrinterFL; + ListBox maPrinters; + DisclosureButton maDetailsBtn; + FixedText maStatusLabel; + FixedText maStatusTxt; + FixedText maLocationLabel; + FixedText maLocationTxt; + FixedText maCommentLabel; + FixedText maCommentTxt; + + PushButton maSetupButton; + + FixedLine maCopies; + FixedLine maCopySpacer; + FixedText maCopyCount; + NumericField maCopyCountField; + CheckBox maCollateBox; + FixedImage maCollateImage; + CheckBox maReverseOrderBox; + + Image maCollateImg; + Image maNoCollateImg; + + long mnCollateUIMode; + + boost::shared_ptr<vcl::RowOrColumn> mxPrintRange; + boost::shared_ptr<vcl::WindowArranger> mxDetails; + + 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; + + boost::shared_ptr<vcl::RowOrColumn> mxOptGroup; + + OutputOptPage( Window*, const ResId& ); + virtual ~OutputOptPage(); + + void readFromSettings(); + void storeToSettings(); + + // virtual void Resize(); + + void setupLayout(); + }; + + OKButton maOKButton; + CancelButton maCancelButton; + HelpButton maHelpButton; + PrintPreviewWindow maPreviewWindow; + NumericField maPageEdit; + FixedText maNumPagesText; + PushButton maBackwardBtn; + PushButton maForwardBtn; + + TabControl maTabCtrl; + NUpTabPage maNUpPage; + JobTabPage maJobPage; + OutputOptPage maOptionsPage; + + FixedLine maButtonLine; + + boost::shared_ptr< PrinterController > maPController; + + rtl::OUString maPageStr; + rtl::OUString maNoPageStr; + sal_Int32 mnCurPage; + sal_Int32 mnCachedPages; + + std::list< Window* > maControls; + std::map< Window*, rtl::OUString > maControlToPropertyMap; + std::map< rtl::OUString, std::vector< Window* > > + maPropertyToWindowMap; + std::map< Window*, sal_Int32 > maControlToNumValMap; + std::set< rtl::OUString > maReverseDependencySet; + + Size maNupPortraitSize; + Size maNupLandscapeSize; + + // internal, used for automatic Nup-Portrait/landscape + Size maFirstPageSize; + + rtl::OUString maPrintToFileText; + rtl::OUString maPrintText; + rtl::OUString maDefPrtText; + + boost::shared_ptr<vcl::RowOrColumn> mxPreviewCtrls; + + Size maDetailsCollapsedSize; + Size maDetailsExpandedSize; + + sal_Bool mbShowLayoutPage; + + Size getJobPageSize(); + void updateNup(); + void updateNupFromPages(); + void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); + void setPreviewText( sal_Int32 ); + void updatePrinterText(); + void checkControlDependencies(); + void checkOptionalControlDependencies(); + void makeEnabled( Window* ); + void updateWindowFromProperty( const rtl::OUString& ); + void setupOptionalUI(); + void readFromSettings(); + void storeToSettings(); + com::sun::star::beans::PropertyValue* getValueForWindow( Window* ) const; + + virtual void Resize(); + virtual void Command( const CommandEvent& ); + virtual void DataChanged( const DataChangedEvent& ); + + DECL_LINK( SelectHdl, ListBox* ); + 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* ); + DECL_LINK( UIOption_ModifyHdl, Edit* ); + + void setupLayout(); + public: + PrintDialog( Window*, const boost::shared_ptr< PrinterController >& ); + virtual ~PrintDialog(); + + bool isPrintToFile(); + int getCopyCount(); + bool isCollate(); + bool isSingleJobs(); + + void previewForward(); + void previewBackward(); + }; + + class PrintProgressDialog : public ModelessDialog + { + String maStr; + FixedText maText; + CancelButton maButton; + + bool mbCanceled; + sal_Int32 mnCur; + sal_Int32 mnMax; + long mnProgressHeight; + Rectangle maProgressRect; + bool mbNativeProgress; + + DECL_LINK( ClickHdl, Button* ); + + void implCalcProgressRect(); + public: + PrintProgressDialog( Window* i_pParent, int i_nMax ); + ~PrintProgressDialog(); + + bool isCanceled() const { return mbCanceled; } + void setProgress( int i_nCurrent, int i_nMax = -1 ); + void tick(); + void reset(); + + virtual void Paint( const Rectangle& ); + }; +} + + +#endif // _SV_PRNDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/prntypes.hxx b/vcl/inc/vcl/prntypes.hxx new file mode 100644 index 000000000000..13d87a94d3ac --- /dev/null +++ b/vcl/inc/vcl/prntypes.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_PRNTYPES_HXX +#define _SV_PRNTYPES_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <i18npool/paper.hxx> + +// --------------- +// - Duplex Mode - +// --------------- + +enum DuplexMode { DUPLEX_UNKNOWN, DUPLEX_OFF, DUPLEX_LONGEDGE, DUPLEX_SHORTEDGE }; + +// --------------- +// - Orientation - +// --------------- + +enum Orientation { ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE }; + +// ------------------- +// - QueueInfo-Types - +// ------------------- + +#define QUEUE_STATUS_READY ((sal_uLong)0x00000001) +#define QUEUE_STATUS_PAUSED ((sal_uLong)0x00000002) +#define QUEUE_STATUS_PENDING_DELETION ((sal_uLong)0x00000004) +#define QUEUE_STATUS_BUSY ((sal_uLong)0x00000008) +#define QUEUE_STATUS_INITIALIZING ((sal_uLong)0x00000010) +#define QUEUE_STATUS_WAITING ((sal_uLong)0x00000020) +#define QUEUE_STATUS_WARMING_UP ((sal_uLong)0x00000040) +#define QUEUE_STATUS_PROCESSING ((sal_uLong)0x00000080) +#define QUEUE_STATUS_PRINTING ((sal_uLong)0x00000100) +#define QUEUE_STATUS_OFFLINE ((sal_uLong)0x00000200) +#define QUEUE_STATUS_ERROR ((sal_uLong)0x00000400) +#define QUEUE_STATUS_SERVER_UNKNOWN ((sal_uLong)0x00000800) +#define QUEUE_STATUS_PAPER_JAM ((sal_uLong)0x00001000) +#define QUEUE_STATUS_PAPER_OUT ((sal_uLong)0x00002000) +#define QUEUE_STATUS_MANUAL_FEED ((sal_uLong)0x00004000) +#define QUEUE_STATUS_PAPER_PROBLEM ((sal_uLong)0x00008000) +#define QUEUE_STATUS_IO_ACTIVE ((sal_uLong)0x00010000) +#define QUEUE_STATUS_OUTPUT_BIN_FULL ((sal_uLong)0x00020000) +#define QUEUE_STATUS_TONER_LOW ((sal_uLong)0x00040000) +#define QUEUE_STATUS_NO_TONER ((sal_uLong)0x00080000) +#define QUEUE_STATUS_PAGE_PUNT ((sal_uLong)0x00100000) +#define QUEUE_STATUS_USER_INTERVENTION ((sal_uLong)0x00200000) +#define QUEUE_STATUS_OUT_OF_MEMORY ((sal_uLong)0x00400000) +#define QUEUE_STATUS_DOOR_OPEN ((sal_uLong)0x00800000) +#define QUEUE_STATUS_POWER_SAVE ((sal_uLong)0x01000000) + +#define QUEUE_JOBS_DONTKNOW ((sal_uLong)0xFFFFFFFF) + +// ----------------- +// - Printer-Types - +// ----------------- + +#define PRINTER_CAPABILITIES_SUPPORTDIALOG ((sal_uInt16)1) +#define PRINTER_CAPABILITIES_COPIES ((sal_uInt16)2) +#define PRINTER_CAPABILITIES_COLLATECOPIES ((sal_uInt16)3) +#define PRINTER_CAPABILITIES_SETORIENTATION ((sal_uInt16)4) +#define PRINTER_CAPABILITIES_SETPAPERBIN ((sal_uInt16)5) +#define PRINTER_CAPABILITIES_SETPAPERSIZE ((sal_uInt16)6) +#define PRINTER_CAPABILITIES_SETPAPER ((sal_uInt16)7) +#define PRINTER_CAPABILITIES_FAX ((sal_uInt16)8) +#define PRINTER_CAPABILITIES_PDF ((sal_uInt16)9) +#define PRINTER_CAPABILITIES_EXTERNALDIALOG ((sal_uInt16)10) +#define PRINTER_CAPABILITIES_SETDUPLEX ((sal_uInt16)11) +#define PRINTER_CAPABILITIES_USEPULLMODEL ((sal_uInt16)12) + +#endif // _SV_PRNTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/ptrstyle.hxx b/vcl/inc/vcl/ptrstyle.hxx new file mode 100644 index 000000000000..1f6b375e81b5 --- /dev/null +++ b/vcl/inc/vcl/ptrstyle.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_PTRSTYLE_HXX +#define _VCL_PTRSTYLE_HXX + +#include <vcl/sv.h> + +// ----------------- +// - Pointer-Types - +// ----------------- + +typedef sal_uInt16 PointerStyle; + +#define POINTER_ARROW ((PointerStyle)0) +#define POINTER_NULL ((PointerStyle)1) +#define POINTER_WAIT ((PointerStyle)2) +#define POINTER_TEXT ((PointerStyle)3) +#define POINTER_HELP ((PointerStyle)4) +#define POINTER_CROSS ((PointerStyle)5) +#define POINTER_MOVE ((PointerStyle)6) +#define POINTER_NSIZE ((PointerStyle)7) +#define POINTER_SSIZE ((PointerStyle)8) +#define POINTER_WSIZE ((PointerStyle)9) +#define POINTER_ESIZE ((PointerStyle)10) +#define POINTER_NWSIZE ((PointerStyle)11) +#define POINTER_NESIZE ((PointerStyle)12) +#define POINTER_SWSIZE ((PointerStyle)13) +#define POINTER_SESIZE ((PointerStyle)14) +#define POINTER_WINDOW_NSIZE ((PointerStyle)15) +#define POINTER_WINDOW_SSIZE ((PointerStyle)16) +#define POINTER_WINDOW_WSIZE ((PointerStyle)17) +#define POINTER_WINDOW_ESIZE ((PointerStyle)18) +#define POINTER_WINDOW_NWSIZE ((PointerStyle)19) +#define POINTER_WINDOW_NESIZE ((PointerStyle)20) +#define POINTER_WINDOW_SWSIZE ((PointerStyle)21) +#define POINTER_WINDOW_SESIZE ((PointerStyle)22) +#define POINTER_HSPLIT ((PointerStyle)23) +#define POINTER_VSPLIT ((PointerStyle)24) +#define POINTER_HSIZEBAR ((PointerStyle)25) +#define POINTER_VSIZEBAR ((PointerStyle)26) +#define POINTER_HAND ((PointerStyle)27) +#define POINTER_REFHAND ((PointerStyle)28) +#define POINTER_PEN ((PointerStyle)29) +#define POINTER_MAGNIFY ((PointerStyle)30) +#define POINTER_FILL ((PointerStyle)31) +#define POINTER_ROTATE ((PointerStyle)32) +#define POINTER_HSHEAR ((PointerStyle)33) +#define POINTER_VSHEAR ((PointerStyle)34) +#define POINTER_MIRROR ((PointerStyle)35) +#define POINTER_CROOK ((PointerStyle)36) +#define POINTER_CROP ((PointerStyle)37) +#define POINTER_MOVEPOINT ((PointerStyle)38) +#define POINTER_MOVEBEZIERWEIGHT ((PointerStyle)39) +#define POINTER_MOVEDATA ((PointerStyle)40) +#define POINTER_COPYDATA ((PointerStyle)41) +#define POINTER_LINKDATA ((PointerStyle)42) +#define POINTER_MOVEDATALINK ((PointerStyle)43) +#define POINTER_COPYDATALINK ((PointerStyle)44) +#define POINTER_MOVEFILE ((PointerStyle)45) +#define POINTER_COPYFILE ((PointerStyle)46) +#define POINTER_LINKFILE ((PointerStyle)47) +#define POINTER_MOVEFILELINK ((PointerStyle)48) +#define POINTER_COPYFILELINK ((PointerStyle)49) +#define POINTER_MOVEFILES ((PointerStyle)50) +#define POINTER_COPYFILES ((PointerStyle)51) +#define POINTER_NOTALLOWED ((PointerStyle)52) +#define POINTER_DRAW_LINE ((PointerStyle)53) +#define POINTER_DRAW_RECT ((PointerStyle)54) +#define POINTER_DRAW_POLYGON ((PointerStyle)55) +#define POINTER_DRAW_BEZIER ((PointerStyle)56) +#define POINTER_DRAW_ARC ((PointerStyle)57) +#define POINTER_DRAW_PIE ((PointerStyle)58) +#define POINTER_DRAW_CIRCLECUT ((PointerStyle)59) +#define POINTER_DRAW_ELLIPSE ((PointerStyle)60) +#define POINTER_DRAW_FREEHAND ((PointerStyle)61) +#define POINTER_DRAW_CONNECT ((PointerStyle)62) +#define POINTER_DRAW_TEXT ((PointerStyle)63) +#define POINTER_DRAW_CAPTION ((PointerStyle)64) +#define POINTER_CHART ((PointerStyle)65) +#define POINTER_DETECTIVE ((PointerStyle)66) +#define POINTER_PIVOT_COL ((PointerStyle)67) +#define POINTER_PIVOT_ROW ((PointerStyle)68) +#define POINTER_PIVOT_FIELD ((PointerStyle)69) +#define POINTER_CHAIN ((PointerStyle)70) +#define POINTER_CHAIN_NOTALLOWED ((PointerStyle)71) +#define POINTER_TIMEEVENT_MOVE ((PointerStyle)72) +#define POINTER_TIMEEVENT_SIZE ((PointerStyle)73) +#define POINTER_AUTOSCROLL_N ((PointerStyle)74) +#define POINTER_AUTOSCROLL_S ((PointerStyle)75) +#define POINTER_AUTOSCROLL_W ((PointerStyle)76) +#define POINTER_AUTOSCROLL_E ((PointerStyle)77) +#define POINTER_AUTOSCROLL_NW ((PointerStyle)78) +#define POINTER_AUTOSCROLL_NE ((PointerStyle)79) +#define POINTER_AUTOSCROLL_SW ((PointerStyle)80) +#define POINTER_AUTOSCROLL_SE ((PointerStyle)81) +#define POINTER_AUTOSCROLL_NS ((PointerStyle)82) +#define POINTER_AUTOSCROLL_WE ((PointerStyle)83) +#define POINTER_AUTOSCROLL_NSWE ((PointerStyle)84) +#define POINTER_AIRBRUSH ((PointerStyle)85) +#define POINTER_TEXT_VERTICAL ((PointerStyle)86) +#define POINTER_PIVOT_DELETE ((PointerStyle)87) + +// --> FME 2004-07-30 #i32329# Enhanced table selection +#define POINTER_TAB_SELECT_S ((PointerStyle)88) +#define POINTER_TAB_SELECT_E ((PointerStyle)89) +#define POINTER_TAB_SELECT_SE ((PointerStyle)90) +#define POINTER_TAB_SELECT_W ((PointerStyle)91) +#define POINTER_TAB_SELECT_SW ((PointerStyle)92) +// <-- + +// --> FME 2004-08-16 #i20119# Paintbrush tool +#define POINTER_PAINTBRUSH ((PointerStyle)93) +// <-- + +#define POINTER_COUNT 94 + +#endif // _VCL_PTRSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/quickselectionengine.hxx b/vcl/inc/vcl/quickselectionengine.hxx new file mode 100644 index 000000000000..f70736428010 --- /dev/null +++ b/vcl/inc/vcl/quickselectionengine.hxx @@ -0,0 +1,95 @@ +/************************************************************************* +* 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 +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef VCL_QUICKSELECTIONENGINE_HXX +#define VCL_QUICKSELECTIONENGINE_HXX + +#include "dllapi.h" + +#include <tools/string.hxx> + +#include <memory> + +class KeyEvent; + +//........................................................................ +namespace vcl +{ +//........................................................................ + + typedef const void* StringEntryIdentifier; + + //==================================================================== + //= ISearchableStringList + //==================================================================== + // TODO: consolidate this with ::vcl::IMnemonicEntryList + class SAL_NO_VTABLE VCL_DLLPUBLIC ISearchableStringList + { + public: + /** returns the current entry in the list of searchable strings. + + Search operations will start with this entry. + */ + virtual StringEntryIdentifier CurrentEntry( String& _out_entryText ) const = 0; + + /** returns the next entry in the list. + + The implementation is expected to wrap around. That is, if the given entry denotes the last + entry in the list, then NextEntry should return the first entry. + */ + virtual StringEntryIdentifier NextEntry( StringEntryIdentifier _currentEntry, String& _out_entryText ) const = 0; + + /** selects a given entry + */ + virtual void SelectEntry( StringEntryIdentifier _entry ) = 0; + }; + + //==================================================================== + //= QuickSelectionEngine + //==================================================================== + struct QuickSelectionEngine_Data; + class VCL_DLLPUBLIC QuickSelectionEngine + { + public: + QuickSelectionEngine( ISearchableStringList& _entryList ); + ~QuickSelectionEngine(); + + bool HandleKeyEvent( const KeyEvent& _rKEvt ); + void Reset(); + + private: + ::std::auto_ptr< QuickSelectionEngine_Data > m_pData; + + private: + QuickSelectionEngine(); // never implemented + QuickSelectionEngine( const QuickSelectionEngine& ); // never implemented + QuickSelectionEngine& operator=( const QuickSelectionEngine& ); // never implemented + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_QUICKSELECTIONENGINE_HXX diff --git a/vcl/inc/vcl/regband.hxx b/vcl/inc/vcl/regband.hxx new file mode 100644 index 000000000000..0ebacbdb93d4 --- /dev/null +++ b/vcl/inc/vcl/regband.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_REGBAND_HXX +#define _SV_REGBAND_HXX + +#include <vcl/sv.h> +#include <tools/poly.hxx> + +/* ======================================================================= + +class ImplRegionBand + +This class handles one y-band of the region. In this band may contain one +or more seprarations in x-direction. The y-Band do not contain any +separation after creation. + +The separations are modified with basic clipping functions like Union and +Intersection - the Class will process the clipping for the actual band. + +The actual separations may be checked by functions like IsInside or +IsOver. + +======================================================================= */ + +// ------------------------ +// - ImplRegionBand-Types - +// ------------------------ + +// element for the list with x-separations +struct ImplRegionBandSep +{ + ImplRegionBandSep* mpNextSep; + long mnXLeft; + long mnXRight; + sal_Bool mbRemoved; +}; + +enum LineType { LINE_ASCENDING, LINE_DESCENDING, LINE_HORIZONTAL }; + +// element for the list with x-separations +struct ImplRegionBandPoint +{ + ImplRegionBandPoint* mpNextBandPoint; + long mnX; + long mnLineId; + sal_Bool mbEndPoint; + LineType meLineType; +}; + +// ------------------ +// - ImplRegionBand - +// ------------------ + +class ImplRegionBand +{ +public: + ImplRegionBand* mpNextBand; // pointer to the next element of the list + ImplRegionBand* mpPrevBand; // pointer to the previous element of the list (only used temporaery) + ImplRegionBandSep* mpFirstSep; // root of the list with x-separations + ImplRegionBandPoint* mpFirstBandPoint; // root of the list with lines + long mnYTop; // actual boundary of the band + long mnYBottom; + sal_Bool mbTouched; + + // create y-band with boundaries + ImplRegionBand( long nYTop, long nYBottom ); + /** copy y-band with with all data + @param theSourceBand + The new ImplRegionBand object will + be a copy of this band. + @param bIgnorePoints + When <TRUE/> (the default) the + band points pointed to by + mpFirstBandPoint are not copied. + When <FALSE/> they are copied. + You need the points when you are + planning to call ProcessPoints() + later on. + */ + ImplRegionBand( const ImplRegionBand & theSourceBand, + const bool bIgnorePoints = true); + ~ImplRegionBand(); + + long GetXLeftBoundary() const; + long GetXRightBoundary() const; + + // combine overlapping bands + sal_Bool OptimizeBand(); + + // generate separations from lines and process + // union with existing separations + void ProcessPoints(); + // insert point in the list for later processing + sal_Bool InsertPoint( long nX, long nLineID, + sal_Bool bEndPoint, LineType eLineType ); + + void Union( long nXLeft, long nXRight ); + void Intersect( long nXLeft, long nXRight ); + void Exclude( long nXLeft, long nXRight ); + void XOr( long nXLeft, long nXRight ); + + void MoveX( long nHorzMove ); + void ScaleX( double fHorzScale ); + + sal_Bool IsInside( long nX ); + sal_Bool IsInside( long nLeft, long nRight ); + sal_Bool IsOver( long nLeft, long nRight ); + + sal_Bool IsEmpty() const { return ((!mpFirstSep) && (!mpFirstBandPoint)); } + + sal_Bool operator==( const ImplRegionBand& rRegionBand ) const; + + /** Split the called band at the given vertical coordinate. After the + split the called band will cover the upper part not including nY. + The new band will cover the lower part including nY. + @param nY + The band is split at this y coordinate. The new, lower band + will include this very value. + @return + Returns the new, lower band. + */ + ImplRegionBand* SplitBand (const sal_Int32 nY); +}; + +#endif // _SV_REGBAND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/region.h b/vcl/inc/vcl/region.h new file mode 100644 index 000000000000..5814e981aac2 --- /dev/null +++ b/vcl/inc/vcl/region.h @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_REGION_H +#define _SV_REGION_H + +#include <vcl/regband.hxx> +#include <tools/poly.hxx> +#include <vcl/region.hxx> + +// ----------------- +// - Hilfsmethoden - +// ----------------- + +#ifdef DBG_UTIL +const char* ImplDbgTestRegion( const void* pObj ); +#endif + +// -------------------- +// - ImplRegionHandle - +// -------------------- + +struct ImplRegionHandle +{ + Region* mpRegion; + ImplRegionBand* mpCurrRectBand; + ImplRegionBandSep* mpCurrRectBandSep; + sal_Bool mbFirst; +}; + +// ------------------ +// - ImplRegionInfo - +// ------------------ + +struct ImplRegionInfo +{ + void* mpVoidCurrRectBand; + void* mpVoidCurrRectBandSep; +}; + +// -------------- +// - ImplRegion - +// -------------- + +struct ImplRegionBase +{ +public: + ImplRegionBase( int nCount = 1 ); // TODO: replace manual refcounting + virtual ~ImplRegionBase(); +public: + sal_uIntPtr mnRefCount; + sal_uIntPtr mnRectCount; + PolyPolygon* mpPolyPoly; + basegfx::B2DPolyPolygon* mpB2DPolyPoly; +}; + +class ImplRegion : public ImplRegionBase +{ + friend class Region; + +private: + ImplRegionBand* mpFirstBand; // root of the list with y-bands + ImplRegionBand* mpLastCheckedBand; + +public: + ImplRegion(); + ImplRegion( const PolyPolygon& rPolyPoly ); + ImplRegion( const basegfx::B2DPolyPolygon& ); + ImplRegion( const ImplRegion& rImplRegion ); + ~ImplRegion(); + + ImplRegionBand* ImplGetFirstRegionBand() const { return mpFirstBand; } + PolyPolygon* ImplGetPolyPoly() const { return mpPolyPoly; } + + void CreateBandRange( long nYTop, long nYBottom ); + void InsertBands( long nYTop, long nYBottom ); + sal_Bool InsertSingleBand( ImplRegionBand* mpImplRegionBand, + long nYBandPosition ); + sal_Bool InsertLine( const Point & rFirstPoint, + const Point & rSecondPoint, + long nLineID ); + sal_Bool InsertPoint( const Point &rPoint, + long nLineID, + sal_Bool bEndPoint, LineType eLineType ); + + /** Insert one band either after another band or as the first or only + band. Both the forward as well as the backward links are updated. + @param pPreviousBand + When <NULL/> then pBandToInsert is inserted as first band or as + only band when there are no other bands. + When not <NULL/> then pBandToInsert is inserted directly after + pPreviousBand. + @param pBandToInsert + The band to insert. + */ + void InsertBand (ImplRegionBand* pPreviousBand, + ImplRegionBand* pBandToInsert); + + void Union( long nLeft, long nTop, long nRight, long nBottom ); + void Exclude( long nLeft, long nTop, long nRight, long nBottom ); + void XOr( long nLeft, long nTop, long nRight, long nBottom ); + + // remove emtpy rects + sal_Bool OptimizeBandList(); + + friend SvStream& operator>>( SvStream& rIStm, Region& rRegion ); + friend SvStream& operator<<( SvStream& rOStm, const Region& rRegion ); +}; + +#endif // _SV_REGION_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/region.hxx b/vcl/inc/vcl/region.hxx new file mode 100644 index 000000000000..f21cca472252 --- /dev/null +++ b/vcl/inc/vcl/region.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_REGION_HXX +#define _SV_REGION_HXX + +#include <tools/gen.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +#include <basegfx/polygon/b2dpolypolygon.hxx> + +class ImplRegion; +class ImplRegionBand; +class Polygon; +class PolyPolygon; +struct ImplRegionInfo; + +// -------------- +// - RegionType - +// -------------- + +enum RegionType { REGION_NULL, REGION_EMPTY, REGION_RECTANGLE, REGION_COMPLEX }; +enum RegionOverlapType { REGION_INSIDE, REGION_OVER, REGION_OUTSIDE }; + +typedef long RegionHandle; + +// ---------- +// - Region - +// ---------- + +class VCL_DLLPUBLIC Region +{ + friend class OutputDevice; + friend class Window; + friend class Bitmap; + +private: + ImplRegion* mpImplRegion; + + SAL_DLLPRIVATE void ImplCopyData(); + SAL_DLLPRIVATE void ImplCreateRectRegion( const Rectangle& rRect ); + SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly ); + SAL_DLLPRIVATE void ImplPolyPolyRegionToBandRegionFunc(); + SAL_DLLPRIVATE inline void ImplPolyPolyRegionToBandRegion(); + SAL_DLLPRIVATE const ImplRegion* ImplGetImplRegion() const { return mpImplRegion; } + SAL_DLLPRIVATE ImplRegion* ImplGetImplRegion() { return mpImplRegion; } + SAL_DLLPRIVATE void ImplBeginAddRect( ); + SAL_DLLPRIVATE sal_Bool ImplAddRect( const Rectangle& rRect ); + SAL_DLLPRIVATE void ImplEndAddRect( ); + SAL_DLLPRIVATE void ImplIntersectWithPolyPolygon( const Region& ); + SAL_DLLPRIVATE void ImplExcludePolyPolygon( const Region& ); + SAL_DLLPRIVATE void ImplUnionPolyPolygon( const Region& ); + SAL_DLLPRIVATE void ImplXOrPolyPolygon( const Region& ); + +public: // public within vcl + VCL_PLUGIN_PUBLIC bool ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo, + long& nX, long& nY, long& nWidth, long& nHeight ) const; + VCL_PLUGIN_PUBLIC bool ImplGetNextRect( ImplRegionInfo& rImplRegionInfo, + long& nX, long& nY, long& nWidth, long& nHeight ) const; +#ifdef DBG_UTIL + friend const char* ImplDbgTestRegion( const void* pObj ); +#endif + +public: + Region(); + Region( RegionType eType ); + Region( const Rectangle& rRect ); + Region( const Polygon& rPolygon ); + Region( const PolyPolygon& rPolyPoly ); + Region( const basegfx::B2DPolyPolygon& ); + Region( const Region& rRegion ); + ~Region(); + + void Move( long nHorzMove, long nVertMove ); + void Scale( double fScaleX, double fScaleY ); + sal_Bool Union( const Rectangle& rRegion ); + sal_Bool Intersect( const Rectangle& rRegion ); + sal_Bool Exclude( const Rectangle& rRegion ); + sal_Bool XOr( const Rectangle& rRegion ); + sal_Bool Union( const Region& rRegion ); + sal_Bool Intersect( const Region& rRegion ); + sal_Bool Exclude( const Region& rRegion ); + sal_Bool XOr( const Region& rRegion ); + + RegionType GetType() const; + sal_Bool IsEmpty() const { return GetType() == REGION_EMPTY; }; + sal_Bool IsNull() const { return GetType() == REGION_NULL; }; + + void SetEmpty(); + void SetNull(); + + Rectangle GetBoundRect() const; + + sal_Bool HasPolyPolygon() const; + PolyPolygon GetPolyPolygon() const; + // returns an empty polypolygon in case HasPolyPolygon is sal_False + const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const; + // returns a PolyPolygon either copied from the set PolyPolygon region + // or created from the constituent rectangles + basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon(); + + sal_uLong GetRectCount() const; + RegionHandle BeginEnumRects(); + sal_Bool GetEnumRects( RegionHandle hRegionHandle, Rectangle& rRect ); + sal_Bool GetNextEnumRect( RegionHandle hRegionHandle, Rectangle& rRect ) + { return GetEnumRects( hRegionHandle, rRect ); } + void EndEnumRects( RegionHandle hRegionHandle ); + + sal_Bool IsInside( const Point& rPoint ) const; + sal_Bool IsInside( const Rectangle& rRect ) const; + sal_Bool IsOver( const Rectangle& rRect ) const; + + Region& operator=( const Region& rRegion ); + Region& operator=( const Rectangle& rRect ); + + sal_Bool operator==( const Region& rRegion ) const; + sal_Bool operator!=( const Region& rRegion ) const + { return !(Region::operator==( rRegion )); } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Region& rRegion ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Region& rRegion ); + + /* workaround: faster conversion for PolyPolygons + * if half of the Polygons contained in rPolyPoly are actually + * rectangles, then the returned Region will be constructed by + * XOr'ing the contained Polygons together; in the case of + * only Rectangles this can be up to eight times faster than + * Region( const PolyPolygon& ). + * Caution: this is only useful if the Region is known to be + * changed to rectangles; e.g. if being set as clip region + */ + static Region GetRegionFromPolyPolygon( const PolyPolygon& rPolyPoly ); +}; + +#endif // _SV_REGION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salbmp.hxx b/vcl/inc/vcl/salbmp.hxx new file mode 100644 index 000000000000..d880be0d6d37 --- /dev/null +++ b/vcl/inc/vcl/salbmp.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALBMP_HXX +#define _SV_SALBMP_HXX + +#include <tools/gen.hxx> +#include <vcl/dllapi.h> + +#include <com/sun/star/rendering/XBitmapCanvas.hpp> + +struct BitmapBuffer; +class SalGraphics; +class BitmapPalette; +struct BitmapSystemData; + +class VCL_PLUGIN_PUBLIC SalBitmap +{ +public: + SalBitmap() {} + virtual ~SalBitmap(); + + virtual bool Create( const Size& rSize, + sal_uInt16 nBitCount, + const BitmapPalette& rPal ) = 0; + virtual bool Create( const SalBitmap& rSalBmp ) = 0; + virtual bool Create( const SalBitmap& rSalBmp, + SalGraphics* pGraphics ) = 0; + virtual bool Create( const SalBitmap& rSalBmp, + sal_uInt16 nNewBitCount ) = 0; + virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > xBitmapCanvas, + Size& rSize, + bool bMask = false ) = 0; + virtual void Destroy() = 0; + virtual Size GetSize() const = 0; + virtual sal_uInt16 GetBitCount() const = 0; + + virtual BitmapBuffer* AcquireBuffer( bool bReadOnly ) = 0; + virtual void ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly ) = 0; + virtual bool GetSystemData( BitmapSystemData& rData ) = 0; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salbtype.hxx b/vcl/inc/vcl/salbtype.hxx new file mode 100644 index 000000000000..111fdecda62d --- /dev/null +++ b/vcl/inc/vcl/salbtype.hxx @@ -0,0 +1,899 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALBTYPE_HXX +#define _SV_SALBTYPE_HXX +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <osl/endian.h> +#include <tools/debug.hxx> +#include <vcl/salgtype.hxx> +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +// ---------- +// - Memory - +// ---------- + +typedef sal_uInt8* HPBYTE; +typedef HPBYTE Scanline; +typedef const sal_uInt8* ConstHPBYTE; +typedef ConstHPBYTE ConstScanline; + +// ------------------ +// - Bitmap formats - +// ------------------ + +#define BMP_FORMAT_BOTTOM_UP 0x00000000UL +#define BMP_FORMAT_TOP_DOWN 0x80000000UL + +#define BMP_FORMAT_1BIT_MSB_PAL 0x00000001UL +#define BMP_FORMAT_1BIT_LSB_PAL 0x00000002UL + +#define BMP_FORMAT_4BIT_MSN_PAL 0x00000004UL +#define BMP_FORMAT_4BIT_LSN_PAL 0x00000008UL + +#define BMP_FORMAT_8BIT_PAL 0x00000010UL +#define BMP_FORMAT_8BIT_TC_MASK 0x00000020UL + +// #define BMP_FORMAT_16BIT_TC_MASK 0x00000040UL + +#define BMP_FORMAT_24BIT_TC_BGR 0x00000080UL +#define BMP_FORMAT_24BIT_TC_RGB 0x00000100UL +#define BMP_FORMAT_24BIT_TC_MASK 0x00000200UL + +#define BMP_FORMAT_32BIT_TC_ABGR 0x00000400UL +#define BMP_FORMAT_32BIT_TC_ARGB 0x00000800UL +#define BMP_FORMAT_32BIT_TC_BGRA 0x00001000UL +#define BMP_FORMAT_32BIT_TC_RGBA 0x00002000UL +#define BMP_FORMAT_32BIT_TC_MASK 0x00004000UL + +#define BMP_FORMAT_16BIT_TC_MSB_MASK 0x00008000UL +#define BMP_FORMAT_16BIT_TC_LSB_MASK 0x00010000UL + +#define BMP_SCANLINE_ADJUSTMENT( Mac_nBmpFormat ) ( (Mac_nBmpFormat) & 0x80000000UL ) +#define BMP_SCANLINE_FORMAT( Mac_nBmpFormat ) ( (Mac_nBmpFormat) & 0x7FFFFFFFUL ) + +// ------------------------------------------------------------------ + +#define MASK_TO_COLOR( d_nVal, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_Col ) \ +sal_uLong _def_cR = (sal_uInt8) ( d_RS < 0L ? ( (d_nVal) & d_RM ) << -d_RS : ( (d_nVal) & d_RM ) >> d_RS ); \ +sal_uLong _def_cG = (sal_uInt8) ( d_GS < 0L ? ( (d_nVal) & d_GM ) << -d_GS : ( (d_nVal) & d_GM ) >> d_GS ); \ +sal_uLong _def_cB = (sal_uInt8) ( d_BS < 0L ? ( (d_nVal) & d_BM ) << -d_BS : ( (d_nVal) & d_BM ) >> d_BS ); \ +d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift ) ), \ + (sal_uInt8) ( _def_cG | ( ( _def_cG & mnGOr ) >> mnGOrShift ) ), \ + (sal_uInt8) ( _def_cB | ( ( _def_cB & mnBOr ) >> mnBOrShift ) ) ); + +// ------------------------------------------------------------------ + +#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS ) \ +( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \ + ( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \ + ( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \ + ( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \ + ( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \ + ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) ) + +// --------------- +// - BitmapColor - +// --------------- + +class Color; + +class VCL_DLLPUBLIC BitmapColor +{ +private: + +// !!! Achtung: +// !!! da auf die Member dieser Klasse via memcpy +// !!! zugegriffen wird, darf diese Klasse weder +// !!! in der Groesse noch der Reihenfolge der +// !!! Member veraendert werden (KA 02.09.97) + sal_uInt8 mcBlueOrIndex; + sal_uInt8 mcGreen; + sal_uInt8 mcRed; + sal_uInt8 mbIndex; + +public: + + inline BitmapColor(); + inline BitmapColor( const BitmapColor& rBitmapColor ); + inline BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue ); + inline BitmapColor( const Color& rColor ); + inline BitmapColor( sal_uInt8 cIndex ); + inline ~BitmapColor() {}; + + inline sal_Bool operator==( const BitmapColor& rBitmapColor ) const; + inline sal_Bool operator!=( const BitmapColor& rBitmapColor ) const; + inline BitmapColor& operator=( const BitmapColor& rBitmapColor ); + + inline sal_Bool IsIndex() const; + + inline sal_uInt8 GetRed() const; + inline void SetRed( sal_uInt8 cRed ); + + inline sal_uInt8 GetGreen() const; + inline void SetGreen( sal_uInt8 cGreen ); + + inline sal_uInt8 GetBlue() const; + inline void SetBlue( sal_uInt8 cBlue ); + + inline sal_uInt8 GetIndex() const; + inline void SetIndex( sal_uInt8 cIndex ); + + operator Color() const; + inline operator sal_uInt8() const; + + inline sal_uInt8 GetBlueOrIndex() const; + + inline BitmapColor& Invert(); + + inline sal_uInt8 GetLuminance() const; + inline BitmapColor& IncreaseLuminance( sal_uInt8 cGreyInc ); + inline BitmapColor& DecreaseLuminance( sal_uInt8 cGreyDec ); + + inline BitmapColor& Merge( const BitmapColor& rColor, sal_uInt8 cTransparency ); + inline BitmapColor& Merge( sal_uInt8 cR, sal_uInt8 cG, sal_uInt8 cB, sal_uInt8 cTransparency ); + + inline sal_uLong GetColorError( const BitmapColor& rBitmapColor ) const; +}; + +// --------------- +// - BitmapPalette - +// --------------- + +class Palette; + +class VCL_DLLPUBLIC BitmapPalette +{ + friend class SalBitmap; + friend class BitmapAccess; + +private: + + BitmapColor* mpBitmapColor; + sal_uInt16 mnCount; + + +public: + + SAL_DLLPRIVATE inline BitmapColor* ImplGetColorBuffer() const; + + +public: + + inline BitmapPalette(); + inline BitmapPalette( const BitmapPalette& rBitmapPalette ); + inline BitmapPalette( sal_uInt16 nCount ); + inline ~BitmapPalette(); + + inline BitmapPalette& operator=( const BitmapPalette& rBitmapPalette ); + inline sal_Bool operator==( const BitmapPalette& rBitmapPalette ) const; + inline sal_Bool operator!=( const BitmapPalette& rBitmapPalette ) const; + inline sal_Bool operator!(); + + inline sal_uInt16 GetEntryCount() const; + inline void SetEntryCount( sal_uInt16 nCount ); + + inline const BitmapColor& operator[]( sal_uInt16 nIndex ) const; + inline BitmapColor& operator[]( sal_uInt16 nIndex ); + + inline sal_uInt16 GetBestIndex( const BitmapColor& rCol ) const; + bool IsGreyPalette() const; +}; + +// --------------- +// - ColorMask - +// --------------- + +class VCL_DLLPUBLIC ColorMask +{ + sal_uLong mnRMask; + sal_uLong mnGMask; + sal_uLong mnBMask; + long mnRShift; + long mnGShift; + long mnBShift; + sal_uLong mnROrShift; + sal_uLong mnGOrShift; + sal_uLong mnBOrShift; + sal_uLong mnROr; + sal_uLong mnGOr; + sal_uLong mnBOr; + + SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const; + +public: + + inline ColorMask( sal_uLong nRedMask = 0UL, sal_uLong nGreenMask = 0UL, sal_uLong nBlueMask = 0UL ); + inline ~ColorMask() {} + + inline sal_uLong GetRedMask() const; + inline sal_uLong GetGreenMask() const; + inline sal_uLong GetBlueMask() const; + + inline void GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const; + inline void SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const; + + inline void GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const; + inline void SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const; + inline void GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const; + inline void SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const; + + inline void GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const; + inline void SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const; + + inline void GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const; + inline void SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const; +}; + +// --------------- +// - BitmapBuffer - +// --------------- + +struct VCL_DLLPUBLIC BitmapBuffer +{ + sal_uLong mnFormat; + long mnWidth; + long mnHeight; + long mnScanlineSize; + sal_uInt16 mnBitCount; + ColorMask maColorMask; + BitmapPalette maPalette; + sal_uInt8* mpBits; + + BitmapBuffer(){} + ~BitmapBuffer() {} +}; + +// --------------------- +// - StretchAndConvert - +// --------------------- + +VCL_DLLPUBLIC BitmapBuffer* StretchAndConvert( const BitmapBuffer& rSrcBuffer, const SalTwoRect& rTwoRect, + sal_uLong nDstBitmapFormat, BitmapPalette* pDstPal = NULL, ColorMask* pDstMask = NULL ); + +// ------------------------------------------------------------------ + +inline BitmapColor::BitmapColor() : + mcBlueOrIndex ( 0 ), + mcGreen ( 0 ), + mcRed ( 0 ), + mbIndex ( sal_False ) +{ +} + +// ------------------------------------------------------------------ + +inline BitmapColor::BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue ) : + mcBlueOrIndex ( cBlue ), + mcGreen ( cGreen ), + mcRed ( cRed ), + mbIndex ( sal_False ) +{ +} + +// ------------------------------------------------------------------ + +inline BitmapColor::BitmapColor( const BitmapColor& rBitmapColor ) : + mcBlueOrIndex ( rBitmapColor.mcBlueOrIndex ), + mcGreen ( rBitmapColor.mcGreen ), + mcRed ( rBitmapColor.mcRed ), + mbIndex ( rBitmapColor.mbIndex ) +{ +} + +// ------------------------------------------------------------------ + +inline BitmapColor::BitmapColor( const Color& rColor ) : + mcBlueOrIndex ( rColor.GetBlue() ), + mcGreen ( rColor.GetGreen() ), + mcRed ( rColor.GetRed() ), + mbIndex ( 0 ) +{ +} + +// ------------------------------------------------------------------ + +inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) : + mcBlueOrIndex ( cIndex ), + mcGreen ( 0 ), + mcRed ( 0 ), + mbIndex ( sal_True ) +{ +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapColor::operator==( const BitmapColor& rBitmapColor ) const +{ + return( ( mcBlueOrIndex == rBitmapColor.mcBlueOrIndex ) && + ( mbIndex ? rBitmapColor.mbIndex : + ( mcGreen == rBitmapColor.mcGreen && mcRed == rBitmapColor.mcRed ) ) ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapColor::operator!=( const BitmapColor& rBitmapColor ) const +{ + return !( *this == rBitmapColor ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::operator=( const BitmapColor& rBitmapColor ) +{ + mcBlueOrIndex = rBitmapColor.mcBlueOrIndex; + mcGreen = rBitmapColor.mcGreen; + mcRed = rBitmapColor.mcRed; + mbIndex = rBitmapColor.mbIndex; + + return *this; +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapColor::IsIndex() const +{ + return mbIndex; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetRed() const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + return mcRed; +} + +// ------------------------------------------------------------------ + +inline void BitmapColor::SetRed( sal_uInt8 cRed ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcRed = cRed; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetGreen() const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + return mcGreen; +} + +// ------------------------------------------------------------------ + +inline void BitmapColor::SetGreen( sal_uInt8 cGreen ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcGreen = cGreen; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetBlue() const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + return mcBlueOrIndex; +} + +// ------------------------------------------------------------------ + +inline void BitmapColor::SetBlue( sal_uInt8 cBlue ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = cBlue; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetIndex() const +{ + DBG_ASSERT( mbIndex, "Pixel represents color values!" ); + return mcBlueOrIndex; +} + +// ------------------------------------------------------------------ + +inline void BitmapColor::SetIndex( sal_uInt8 cIndex ) +{ + DBG_ASSERT( mbIndex, "Pixel represents color values!" ); + mcBlueOrIndex = cIndex; +} + +// ------------------------------------------------------------------ + +inline BitmapColor::operator Color() const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + return Color( mcRed, mcGreen, mcBlueOrIndex ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor::operator sal_uInt8() const +{ + DBG_ASSERT( mbIndex, "Pixel represents color values!" ); + return mcBlueOrIndex; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetBlueOrIndex() const +{ + // #i47518# Yield a value regardless of mbIndex + return mcBlueOrIndex; +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::Invert() +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = ~mcBlueOrIndex, mcGreen = ~mcGreen, mcRed = ~mcRed; + + return *this; +} + +// ------------------------------------------------------------------ + +inline sal_uInt8 BitmapColor::GetLuminance() const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + return( (sal_uInt8) ( ( mcBlueOrIndex * 28UL + mcGreen * 151UL + mcRed * 77UL ) >> 8UL ) ); +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::IncreaseLuminance( sal_uInt8 cGreyInc ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = (sal_uInt8) MinMax( (long) mcBlueOrIndex + cGreyInc, 0L, 255L ); + mcGreen = (sal_uInt8) MinMax( (long) mcGreen + cGreyInc, 0L, 255L ); + mcRed = (sal_uInt8) MinMax( (long) mcRed + cGreyInc, 0L, 255L ); + + return *this; +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::DecreaseLuminance( sal_uInt8 cGreyDec ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = (sal_uInt8) MinMax( (long) mcBlueOrIndex - cGreyDec, 0L, 255L ); + mcGreen = (sal_uInt8) MinMax( (long) mcGreen - cGreyDec, 0L, 255L ); + mcRed = (sal_uInt8) MinMax( (long) mcRed - cGreyDec, 0L, 255L ); + + return *this; +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::Merge( const BitmapColor& rBitmapColor, sal_uInt8 cTransparency ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + DBG_ASSERT( !rBitmapColor.mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = COLOR_CHANNEL_MERGE( mcBlueOrIndex, rBitmapColor.mcBlueOrIndex, cTransparency ); + mcGreen = COLOR_CHANNEL_MERGE( mcGreen, rBitmapColor.mcGreen, cTransparency ); + mcRed = COLOR_CHANNEL_MERGE( mcRed, rBitmapColor.mcRed, cTransparency ); + + return *this; +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapColor::Merge( sal_uInt8 cR, sal_uInt8 cG, sal_uInt8 cB, sal_uInt8 cTransparency ) +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + mcBlueOrIndex = COLOR_CHANNEL_MERGE( mcBlueOrIndex, cB, cTransparency ); + mcGreen = COLOR_CHANNEL_MERGE( mcGreen, cG, cTransparency ); + mcRed = COLOR_CHANNEL_MERGE( mcRed, cR, cTransparency ); + + return *this; +} + +// ------------------------------------------------------------------ + +inline sal_uLong BitmapColor::GetColorError( const BitmapColor& rBitmapColor ) const +{ + DBG_ASSERT( !mbIndex, "Pixel represents index into colortable!" ); + DBG_ASSERT( !rBitmapColor.mbIndex, "Pixel represents index into colortable!" ); + return( (sal_uLong) ( labs( mcBlueOrIndex - rBitmapColor.mcBlueOrIndex ) + + labs( mcGreen - rBitmapColor.mcGreen ) + + labs( mcRed - rBitmapColor.mcRed ) ) ); +} + +// ------------------------------------------------------------------ + +inline BitmapPalette::BitmapPalette() : + mpBitmapColor ( NULL ), + mnCount ( 0 ) +{ +} + +// ------------------------------------------------------------------ + +inline BitmapPalette::BitmapPalette( const BitmapPalette& rBitmapPalette ) : + mnCount( rBitmapPalette.mnCount ) +{ + if( mnCount ) + { + const sal_uLong nSize = mnCount * sizeof( BitmapColor ); + mpBitmapColor = (BitmapColor*) new sal_uInt8[ nSize ]; + memcpy( mpBitmapColor, rBitmapPalette.mpBitmapColor, nSize ); + } + else + mpBitmapColor = NULL; +} + +// ------------------------------------------------------------------ + +inline BitmapPalette::BitmapPalette( sal_uInt16 nCount ) : + mnCount( nCount ) +{ + if( mnCount ) + { + const sal_uLong nSize = mnCount * sizeof( BitmapColor ); + mpBitmapColor = (BitmapColor*) new sal_uInt8[ nSize ]; + memset( mpBitmapColor, 0, nSize ); + } + else + mpBitmapColor = NULL; +} + +// ------------------------------------------------------------------ + +inline BitmapPalette::~BitmapPalette() +{ + delete[] (sal_uInt8*) mpBitmapColor; +} + +// ------------------------------------------------------------------ + +inline BitmapPalette& BitmapPalette::operator=( const BitmapPalette& rBitmapPalette ) +{ + delete[] (sal_uInt8*) mpBitmapColor; + mnCount = rBitmapPalette.mnCount; + + if( mnCount ) + { + const sal_uLong nSize = mnCount * sizeof( BitmapColor ); + mpBitmapColor = (BitmapColor*) new sal_uInt8[ nSize ]; + memcpy( mpBitmapColor, rBitmapPalette.mpBitmapColor, nSize ); + } + else + mpBitmapColor = NULL; + + return *this; +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapPalette::operator==( const BitmapPalette& rBitmapPalette ) const +{ + sal_Bool bRet = sal_False; + + if( rBitmapPalette.mnCount == mnCount ) + { + bRet = sal_True; + + for( sal_uInt16 i = 0; i < mnCount; i++ ) + { + if( mpBitmapColor[ i ] != rBitmapPalette.mpBitmapColor[ i ] ) + { + bRet = sal_False; + break; + } + } + } + + return bRet; +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapPalette::operator!=( const BitmapPalette& rBitmapPalette ) const +{ + return !( *this == rBitmapPalette ); +} + +// ------------------------------------------------------------------ + +inline sal_Bool BitmapPalette::operator!() +{ + return( !mnCount || !mpBitmapColor ); +} + +// ------------------------------------------------------------------ + +inline sal_uInt16 BitmapPalette::GetEntryCount() const +{ + return mnCount; +} + +// ------------------------------------------------------------------ + +inline void BitmapPalette::SetEntryCount( sal_uInt16 nCount ) +{ + if( !nCount ) + { + delete[] (sal_uInt8*) mpBitmapColor; + mpBitmapColor = NULL; + mnCount = 0; + } + else if( nCount != mnCount ) + { + const sal_uLong nNewSize = nCount * sizeof( BitmapColor ); + const sal_uLong nMinSize = Min( mnCount, nCount ) * sizeof( BitmapColor ); + sal_uInt8* pNewColor = new sal_uInt8[ nNewSize ]; + + if ( nMinSize && mpBitmapColor ) + memcpy( pNewColor, mpBitmapColor, nMinSize ); + delete[] (sal_uInt8*) mpBitmapColor; + memset( pNewColor + nMinSize, 0, nNewSize - nMinSize ); + mpBitmapColor = (BitmapColor*) pNewColor; + mnCount = nCount; + } +} + +// ------------------------------------------------------------------ + +inline const BitmapColor& BitmapPalette::operator[]( sal_uInt16 nIndex ) const +{ + DBG_ASSERT( nIndex < mnCount, "Palette index is out of range!" ); + return mpBitmapColor[ nIndex ]; +} + +// ------------------------------------------------------------------ + +inline BitmapColor& BitmapPalette::operator[]( sal_uInt16 nIndex ) +{ + DBG_ASSERT( nIndex < mnCount, "Palette index is out of range!" ); + return mpBitmapColor[ nIndex ]; +} + +// ------------------------------------------------------------------ + +inline BitmapColor* BitmapPalette::ImplGetColorBuffer() const +{ + DBG_ASSERT( mpBitmapColor, "No color buffer available!" ); + return mpBitmapColor; +} +// ------------------------------------------------------------------ + +inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const +{ + sal_uInt16 nRetIndex = 0; + + if( mpBitmapColor && mnCount ) + { + sal_Bool bFound = sal_False; + + for( long j = 0L; ( j < mnCount ) && !bFound; j++ ) + if( rCol == mpBitmapColor[ j ] ) + nRetIndex = ( (sal_uInt16) j ), bFound = sal_True; + + if( !bFound ) + { + long nActErr, nLastErr = rCol.GetColorError( mpBitmapColor[ nRetIndex = mnCount - 1 ] ); + + for( long i = nRetIndex - 1; i >= 0L; i-- ) + if ( ( nActErr = rCol.GetColorError( mpBitmapColor[ i ] ) ) < nLastErr ) + nLastErr = nActErr, nRetIndex = (sal_uInt16) i; + } + } + + return nRetIndex; +} + +// ------------------------------------------------------------------ + +inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask ) : + mnRMask( nRedMask ), + mnGMask( nGreenMask ), + mnBMask( nBlueMask ), + mnROrShift( 0L ), + mnGOrShift( 0L ), + mnBOrShift( 0L ), + mnROr( 0L ), + mnGOr( 0L ), + mnBOr( 0L ) +{ + mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L ); + mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L ); + mnBShift = ( mnBMask ? ImplCalcMaskShift( mnBMask, mnBOr, mnBOrShift ) : 0L ); +} + +// ------------------------------------------------------------------ + +inline long ColorMask::ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const +{ + long nShift; + long nRet; + sal_uLong nLen = 0UL; + + // bei welchen Bits faengt die Maske an + for( nShift = 31L; ( nShift >= 0L ) && !( nMask & ( 1 << (sal_uLong) nShift ) ); nShift-- ) + {} + + nRet = nShift; + + // XXX Anzahl der gesetzten Bits ermitteln => nach rechts bis Null laufen + while( ( nShift >= 0L ) && ( nMask & ( 1 << (sal_uLong) nShift ) ) ) + { + nShift--; + nLen++; + } + + rOrShift = 8L - nLen; + rOr = (sal_uInt8) ( ( 0xffUL >> nLen ) << rOrShift ); + + return( nRet -= 7 ); +} + +// ------------------------------------------------------------------ + +inline sal_uLong ColorMask::GetRedMask() const +{ + return mnRMask; +} + +// ------------------------------------------------------------------ + +inline sal_uLong ColorMask::GetGreenMask() const +{ + return mnGMask; +} + +// ------------------------------------------------------------------ + +inline sal_uLong ColorMask::GetBlueMask() const +{ + return mnBMask; +} + +// ------------------------------------------------------------------ + +inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const +{ + const sal_uInt32 nVal = *pPixel; + MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const +{ + *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const +{ +#ifdef OSL_BIGENDIAN + const sal_uInt32 nVal = *(sal_uInt16*) pPixel; +#else + const sal_uInt32 nVal = pPixel[ 1 ] | ( (sal_uInt32) pPixel[ 0 ] << 8UL ); +#endif + + MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const +{ + const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); + +#ifdef OSL_BIGENDIAN + *(sal_uInt16*) pPixel = nVal; +#else + pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U); + pPixel[ 1 ] = (sal_uInt8) nVal; +#endif +} + +// ------------------------------------------------------------------ + +inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPixel ) const +{ +#ifdef OSL_BIGENDIAN + const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ); +#else + const sal_uInt32 nVal = *(sal_uInt16*) pPixel; +#endif + + MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const +{ + const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); + +#ifdef OSL_BIGENDIAN + pPixel[ 0 ] = (sal_uInt8) nVal; + pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U); +#else + *(sal_uInt16*) pPixel = nVal; +#endif +} + + +// ------------------------------------------------------------------ + +inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const +{ + const sal_uInt32 nVal = pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | ( (sal_uInt32) pPixel[ 2 ] << 16UL ); + MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const +{ + const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); + pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const +{ +#ifdef OSL_BIGENDIAN + const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) | + ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL ); +#else + const sal_uInt32 nVal = *(sal_uInt32*) pPixel; +#endif + + MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor ); +} + +// ------------------------------------------------------------------ + +inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const +{ +#ifdef OSL_BIGENDIAN + const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); + pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); + pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL ); +#else + *(sal_uInt32*) pPixel = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift ); +#endif +} + +#endif // _SV_SALBTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salctype.hxx b/vcl/inc/vcl/salctype.hxx new file mode 100644 index 000000000000..93eb69bd439d --- /dev/null +++ b/vcl/inc/vcl/salctype.hxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALCTYPE_HXX +#define _SV_SALCTYPE_HXX + +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <vcl/graph.hxx> + +// ----------- +// - Defines - +// ----------- + +#define CVT_UNKNOWN (0x00000000UL) +#define CVT_BMP (0x00000001UL) +#define CVT_GIF (0x00000002UL) +#define CVT_JPG (0x00000003UL) +#define CVT_MET (0x00000004UL) +#define CVT_PCT (0x00000005UL) +#define CVT_PNG (0x00000006UL) +#define CVT_SVM (0x00000007UL) +#define CVT_TIF (0x00000008UL) +#define CVT_WMF (0x00000009UL) +#define CVT_EMF (0x0000000aUL) + +// --------------- +// - ConvertData - +// --------------- + +class SvStream; + +struct ConvertData +{ +private: + + ConvertData(); + +public: + + Graphic maGraphic; + SvStream& mrStm; + sal_uLong mnFormat; + + ConvertData( const Graphic& rGraphic, SvStream& rStm, sal_uLong nFormat ) : + maGraphic( rGraphic ), mrStm( rStm ), mnFormat( nFormat ) {} + ~ConvertData() {} +}; + +// ------------ +// - Callback - +// ------------ + +typedef sal_uLong (*SALGRFCVTPROC)( void* pInst, + sal_uLong nInFormat, void* pInBuffer, sal_uLong nInBufSize, + sal_uLong nOutFormat, void** ppOutBuffer ); + +// ------------------- +// - BitmapConverter - +// ------------------- + +namespace vcl +{ +com::sun::star::uno::Reference< com::sun::star::script::XInvocation > createBmpConverter(); +} + +#endif // _SV_SALCTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/saldatabasic.hxx b/vcl/inc/vcl/saldatabasic.hxx new file mode 100644 index 000000000000..e080cb91ff99 --- /dev/null +++ b/vcl/inc/vcl/saldatabasic.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALDATABASIC_HXX +#define _SV_SALDATABASIC_HXX + +#include <vcl/svdata.hxx> +#include <vcl/salinst.hxx> +#include <osl/module.h> + +namespace psp +{ + class PrinterInfoManager; +} + +class VCL_PLUGIN_PUBLIC SalData +{ +public: + SalInstance* m_pInstance; // pointer to instance + oslModule m_pPlugin; // plugin library handle + psp::PrinterInfoManager* m_pPIManager; + + SalData(); + virtual ~SalData(); + +}; + +// -=-= inlines =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +inline void SetSalData( SalData* pData ) +{ ImplGetSVData()->mpSalData = (void*)pData; } + +inline SalData* GetSalData() +{ return (SalData*)ImplGetSVData()->mpSalData; } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salframe.hxx b/vcl/inc/vcl/salframe.hxx new file mode 100644 index 000000000000..f5b98756f5f6 --- /dev/null +++ b/vcl/inc/vcl/salframe.hxx @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALFRAME_HXX +#define _SV_SALFRAME_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +#ifdef __cplusplus + +#include <vcl/ptrstyle.hxx> +#include <vcl/sndstyle.hxx> + +#endif // __cplusplus +#include <vcl/salwtype.hxx> +#include <vcl/salgeom.hxx> +#include <tools/gen.hxx> +#include <vcl/region.hxx> + +#include <vcl/impdel.hxx> +#include <rtl/ustring.hxx> +#include <vcl/keycod.hxx> + +class AllSettings; +class SalGraphics; +class SalBitmap; +class SalMenu; +class Window; + + +struct SalFrameState; +struct SalInputContext; +struct SystemEnvData; + +// ----------------- +// - SalFrameTypes - +// ----------------- + +#define SAL_FRAME_TOTOP_RESTOREWHENMIN ((sal_uInt16)0x0001) +#define SAL_FRAME_TOTOP_FOREGROUNDTASK ((sal_uInt16)0x0002) +#define SAL_FRAME_TOTOP_GRABFOCUS ((sal_uInt16)0x0004) +#define SAL_FRAME_TOTOP_GRABFOCUS_ONLY ((sal_uInt16)0x0008) + +#define SAL_FRAME_ENDEXTTEXTINPUT_COMPLETE ((sal_uInt16)0x0001) +#define SAL_FRAME_ENDEXTTEXTINPUT_CANCEL ((sal_uInt16)0x0002) + + +// ----------------- +// - SalFrameStyle - +// ----------------- + +#define SAL_FRAME_STYLE_DEFAULT ((sal_uLong)0x00000001) +#define SAL_FRAME_STYLE_MOVEABLE ((sal_uLong)0x00000002) +#define SAL_FRAME_STYLE_SIZEABLE ((sal_uLong)0x00000004) +#define SAL_FRAME_STYLE_CLOSEABLE ((sal_uLong)0x00000008) + +// no shadow effect on WindowsXP +#define SAL_FRAME_STYLE_NOSHADOW ((sal_uLong)0x00000010) +// indicate tooltip windows, so they can always be topmost +#define SAL_FRAME_STYLE_TOOLTIP ((sal_uLong)0x00000020) +// windows without windowmanager decoration, this typically only applies to floating windows +#define SAL_FRAME_STYLE_OWNERDRAWDECORATION ((sal_uLong)0x00000040) +// dialogs +#define SAL_FRAME_STYLE_DIALOG ((sal_uLong)0x00000080) +// partial fullscreen: fullscreen on one monitor of a multimonitor display +#define SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ((sal_uLong)0x00800000) +// plugged system child window +#define SAL_FRAME_STYLE_PLUG ((sal_uLong)0x10000000) +// system child window inside another SalFrame +#define SAL_FRAME_STYLE_SYSTEMCHILD ((sal_uLong)0x08000000) +// floating window +#define SAL_FRAME_STYLE_FLOAT ((sal_uLong)0x20000000) +// floating window that needs to be focusable +#define SAL_FRAME_STYLE_FLOAT_FOCUSABLE ((sal_uLong)0x04000000) +// toolwindows should be painted with a smaller decoration +#define SAL_FRAME_STYLE_TOOLWINDOW ((sal_uLong)0x40000000) +// the window containing the intro bitmap, aka splashscreen +#define SAL_FRAME_STYLE_INTRO ((sal_uLong)0x80000000) + +/* +#define SAL_FRAME_STYLE_MINABLE ((sal_uLong)0x00000008) +#define SAL_FRAME_STYLE_MAXABLE ((sal_uLong)0x00000010) +#define SAL_FRAME_STYLE_BORDER ((sal_uLong)0x00000040) +#define SAL_FRAME_STYLE_DOC ((sal_uLong)0x00004000) +#define SAL_FRAME_STYLE_DIALOG ((sal_uLong)0x00008000) +#define SAL_FRAME_STYLE_TOOL ((sal_uLong)0x00010000) +#define SAL_FRAME_STYLE_FULLSIZE ((sal_uLong)0x00020000) +*/ + +// ---------------------------------------- +// - extended frame style - +// - (sal equivalent to extended WinBits) - +// ---------------------------------------- +typedef sal_uInt64 SalExtStyle; +#define SAL_FRAME_EXT_STYLE_DOCUMENT SalExtStyle(0x00000001) +#define SAL_FRAME_EXT_STYLE_DOCMODIFIED SalExtStyle(0x00000002) + +// ------------------------ +// - Flags for SetPosSize - +// ------------------------ + +#define SAL_FRAME_POSSIZE_X ((sal_uInt16)0x0001) +#define SAL_FRAME_POSSIZE_Y ((sal_uInt16)0x0002) +#define SAL_FRAME_POSSIZE_WIDTH ((sal_uInt16)0x0004) +#define SAL_FRAME_POSSIZE_HEIGHT ((sal_uInt16)0x0008) + +#ifdef __cplusplus + +using ::rtl::OUString; +using ::rtl::OString; + +// ------------ +// - SalFrame - +// ------------ + +struct SystemParentData; + +class VCL_PLUGIN_PUBLIC SalFrame : public vcl::DeletionNotifier +{ + // the VCL window corresponding to this frame + Window* m_pWindow; + SALFRAMEPROC m_pProc; +public: // public for Sal Implementation + SalFrame() : m_pWindow( NULL ), m_pProc( NULL ) {} + virtual ~SalFrame(); + +public: // public for Sal Implementation + SalFrameGeometry maGeometry; + +public: + // SalGraphics or NULL, but two Graphics for all SalFrames + // must be returned + virtual SalGraphics* GetGraphics() = 0; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0; + + // Event must be destroyed, when Frame is destroyed + // When Event is called, SalInstance::Yield() must be returned + virtual sal_Bool PostEvent( void* pData ) = 0; + + virtual void SetTitle( const XubString& rTitle ) = 0; + virtual void SetIcon( sal_uInt16 nIcon ) = 0; + virtual void SetRepresentedURL( const rtl::OUString& ); + virtual void SetMenu( SalMenu *pSalMenu ) = 0; + virtual void DrawMenuBar() = 0; + + virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) = 0; + + // Before the window is visible, a resize event + // must be sent with the correct size + virtual void Show( sal_Bool bVisible, sal_Bool bNoActivate = sal_False ) = 0; + virtual void Enable( sal_Bool bEnable ) = 0; + // Set ClientSize and Center the Window to the desktop + // and send/post a resize message + virtual void SetMinClientSize( long nWidth, long nHeight ) = 0; + virtual void SetMaxClientSize( long nWidth, long nHeight ) = 0; + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) = 0; + virtual void GetClientSize( long& rWidth, long& rHeight ) = 0; + virtual void GetWorkArea( Rectangle& rRect ) = 0; + virtual SalFrame* GetParent() const = 0; + // Note: x will be mirrored at parent if UI mirroring is active + SalFrameGeometry GetGeometry(); + const SalFrameGeometry& GetUnmirroredGeometry() const { return maGeometry; } + virtual void SetWindowState( const SalFrameState* pState ) = 0; + virtual sal_Bool GetWindowState( SalFrameState* pState ) = 0; + virtual void ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nDisplay ) = 0; + // Enable/Disable ScreenSaver, SystemAgents, ... + virtual void StartPresentation( sal_Bool bStart ) = 0; + // Show Window over all other Windows + virtual void SetAlwaysOnTop( sal_Bool bOnTop ) = 0; + + // Window to top and grab focus + virtual void ToTop( sal_uInt16 nFlags ) = 0; + + // this function can call with the same + // pointer style + virtual void SetPointer( PointerStyle ePointerStyle ) = 0; + virtual void CaptureMouse( sal_Bool bMouse ) = 0; + virtual void SetPointerPos( long nX, long nY ) = 0; + + // flush output buffer + virtual void Flush( void) = 0; + virtual void Flush( const Rectangle& ); + // flush output buffer, wait till outstanding operations are done + virtual void Sync() = 0; + + virtual void SetInputContext( SalInputContext* pContext ) = 0; + virtual void EndExtTextInput( sal_uInt16 nFlags ) = 0; + + virtual String GetKeyName( sal_uInt16 nKeyCode ) = 0; + virtual String GetSymbolKeyName( const XubString& rFontName, sal_uInt16 nKeyCode ) = 0; + + // returns in 'rKeyCode' the single keycode that translates to the given unicode when using a keyboard layout of language 'aLangType' + // returns sal_False if no mapping exists or function not supported + // this is required for advanced menu support + virtual sal_Bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, KeyCode& rKeyCode ) = 0; + + // returns the input language used for the last key stroke + // may be LANGUAGE_DONTKNOW if not supported by the OS + virtual LanguageType GetInputLanguage() = 0; + + virtual SalBitmap* SnapShot() = 0; + + virtual void UpdateSettings( AllSettings& rSettings ) = 0; + + virtual void Beep( SoundType eSoundType ) = 0; + + // returns system data (most prominent: window handle) + virtual const SystemEnvData* GetSystemData() const = 0; + + // sets a background bitmap on the frame; the implementation + // must not make assumptions about the lifetime of the passed SalBitmap + // but should copy its contents to an own buffer + virtual void SetBackgroundBitmap( SalBitmap* ) = 0; + + + // get current modifier, button mask and mouse position + struct SalPointerState + { + sal_uLong mnState; + Point maPos; // in frame coordinates + }; + + virtual SalPointerState GetPointerState() = 0; + + struct SalIndicatorState + { + sal_uInt16 mnState; + }; + + virtual SalIndicatorState GetIndicatorState() = 0; + + virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) = 0; + + // set new parent window + virtual void SetParent( SalFrame* pNewParent ) = 0; + // reparent window to act as a plugin; implementation + // may choose to use a new system window inetrnally + // return false to indicate failure + virtual bool SetPluginParent( SystemParentData* pNewParent ) = 0; + + // move the frame to a new screen + virtual void SetScreenNumber( unsigned int nScreen ) = 0; + + virtual void SetApplicationID( const rtl::OUString &rApplicationID) = 0; + + // shaped system windows + // set clip region to none (-> rectangular windows, normal state) + virtual void ResetClipRegion() = 0; + // start setting the clipregion consisting of nRects rectangles + virtual void BeginSetClipRegion( sal_uLong nRects ) = 0; + // add a rectangle to the clip region + virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) = 0; + // done setting up the clipregion + virtual void EndSetClipRegion() = 0; + + // Callbacks (indepent part in vcl/source/window/winproc.cxx) + // for default message handling return 0 + void SetCallback( Window* pWindow, SALFRAMEPROC pProc ) + { m_pWindow = pWindow; m_pProc = pProc; } + + // returns the instance set + Window* GetWindow() const { return m_pWindow; } + + // Call the callback set; this sometimes necessary for implementation classes + // that should not now more than necessary about the SalFrame implementation + // (e.g. input methods, printer update handlers). + long CallCallback( sal_uInt16 nEvent, const void* pEvent ) const + { return m_pProc ? m_pProc( m_pWindow, const_cast<SalFrame*>(this), nEvent, pEvent ) : 0; } +}; + + + +#endif // __cplusplus + +#endif // _SV_SALFRAME_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx new file mode 100644 index 000000000000..f2aa64a9549a --- /dev/null +++ b/vcl/inc/vcl/salgdi.hxx @@ -0,0 +1,492 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALGDI_HXX +#define _SV_SALGDI_HXX + +#include "tools/string.hxx" +#include "rtl/ustring.hxx" +#include "vcl/sv.h" +#include "vcl/dllapi.h" +#include "vcl/salgtype.hxx" +#include "osl/thread.hxx" +#include "vcl/outdev.hxx" +#include "vcl/salnativewidgets.hxx" +#include "sallayout.hxx" + +#include <map> + +class ImplDevFontList; +class SalBitmap; +class ImplFontSelectData; +class ImplFontMetricData; +struct ImplKernPairData; +class ImplFontData; +class ImplFontCharMap; +class SalLayout; +class ImplLayoutArgs; +class Rectangle; +class FontSubsetInfo; +class OutputDevice; +class ServerFontLayout; +struct SystemGraphicsData; +struct SystemFontData; + +namespace basegfx { + class B2DVector; + class B2DPolygon; + class B2DPolyPolygon; +} + +// --------------------- +// - SalGraphics-Codes - +// --------------------- + +#define SAL_SETFONT_REMOVEANDMATCHNEW ((sal_uInt16)0x0001) +#define SAL_SETFONT_USEDRAWTEXT ((sal_uInt16)0x0002) +#define SAL_SETFONT_USEDRAWTEXTARRAY ((sal_uInt16)0x0004) +#define SAL_SETFONT_UNICODE ((sal_uInt16)0x0008) +#define SAL_SETFONT_BADFONT ((sal_uInt16)0x1000) + +#define SAL_COPYAREA_WINDOWINVALIDATE ((sal_uInt16)0x0001) + +// ------------------- +// - common typedefs - +// ------------------- + +typedef sal_Unicode sal_Ucs; // TODO: use sal_UCS4 instead of sal_Unicode +typedef std::map< sal_Ucs, sal_Int32 > Ucs2SIntMap; +typedef std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap; +typedef std::map< sal_Ucs, rtl::OString > Ucs2OStrMap; +typedef std::vector< sal_Int32 > Int32Vector; + +// --------------- +// - SalGraphics - +// --------------- + +// note: if you add any new methods to class SalGraphics using coordinates +// make sure they have a corresponding protected pure virtual method +// which has to be implemented by the platform dependent part. +// Add a method that performs coordinate mirroring if required, (see +// existing methods as sample) and then calls the equivalent pure method. + +// note: all positions are in pixel and relative to +// the top/left-position of the virtual output area + +class VCL_PLUGIN_PUBLIC SalGraphics +{ + int m_nLayout; // 0: mirroring off, 1: mirror x-axis + +protected: + // flags which hold the SetAntialiasing() value from OutputDevice + bool m_bAntiAliasB2DDraw; + +public: + // get/set AA + void setAntiAliasB2DDraw(bool bNew) { m_bAntiAliasB2DDraw = bNew; } + bool getAntiAliasB2DDraw() const { return m_bAntiAliasB2DDraw; } + + SalGraphics(); + virtual ~SalGraphics(); + +protected: + virtual bool setClipRegion( const Region& ) = 0; + // draw --> LineColor and FillColor and RasterOp and ClipRegion + virtual void drawPixel( long nX, long nY ) = 0; + virtual void drawPixel( long nX, long nY, SalColor nSalColor ) = 0; + virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) = 0; + virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) = 0; + virtual void drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry ) = 0; + virtual void drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ) = 0; + virtual void drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry ) = 0; + virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ) = 0; + virtual bool drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency, const ::basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin ) = 0; + virtual sal_Bool drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) = 0; + virtual sal_Bool drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) = 0; + virtual sal_Bool drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints, const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry ) = 0; + + // CopyArea --> No RasterOp, but ClipRegion + virtual void copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, + long nSrcHeight, sal_uInt16 nFlags ) = 0; + + // CopyBits and DrawBitmap --> RasterOp and ClipRegion + // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics + virtual void copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics ) = 0; + virtual void drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) = 0; + virtual void drawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nTransparentColor ) = 0; + virtual void drawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rMaskBitmap ) = 0; + virtual void drawMask( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nMaskColor ) = 0; + + virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) = 0; + virtual SalColor getPixel( long nX, long nY ) = 0; + + // invert --> ClipRegion (only Windows or VirDevs) + virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) = 0; + virtual void invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags ) = 0; + + virtual sal_Bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) = 0; + + // native widget rendering methods that require mirroring + virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, + const Point& aPos, sal_Bool& rIsInside ); + virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + const rtl::OUString& aCaption ); + virtual sal_Bool drawNativeControlText( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + const rtl::OUString& aCaption ); + virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, + const ImplControlValue& aValue, const rtl::OUString& aCaption, + Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ); + + /** Render bitmap with alpha channel + + @param rSourceBitmap + Source bitmap to blit + + @param rAlphaBitmap + Alpha channel to use for blitting + + @return true, if the operation succeeded, and false + otherwise. In this case, clients should try to emulate alpha + compositing themselves + */ + virtual bool drawAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSourceBitmap, + const SalBitmap& rAlphaBitmap ) = 0; + /** Render solid rectangle with given transparency + + @param nTransparency + Transparency value (0-255) to use. 0 blits and opaque, 255 a + fully transparent rectangle + */ + virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) = 0; + +public: + // public SalGraphics methods, the interface to the independent vcl part + + // get device resolution + virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) = 0; + // get the depth of the device + virtual sal_uInt16 GetBitCount() const = 0; + // get the width of the device + virtual long GetGraphicsWidth() const = 0; + + // set the clip region to empty + virtual void ResetClipRegion() = 0; + + // set the line color to transparent (= don't draw lines) + virtual void SetLineColor() = 0; + // set the line color to a specific color + virtual void SetLineColor( SalColor nSalColor ) = 0; + // set the fill color to transparent (= don't fill) + virtual void SetFillColor() = 0; + // set the fill color to a specific color, shapes will be + // filled accordingly + virtual void SetFillColor( SalColor nSalColor ) = 0; + // enable/disable XOR drawing + virtual void SetXORMode( bool bSet, bool bInvertOnly ) = 0; + // set line color for raster operations + virtual void SetROPLineColor( SalROPColor nROPColor ) = 0; + // set fill color for raster operations + virtual void SetROPFillColor( SalROPColor nROPColor ) = 0; + // set the text color to a specific color + virtual void SetTextColor( SalColor nSalColor ) = 0; + // set the font + virtual sal_uInt16 SetFont( ImplFontSelectData*, int nFallbackLevel ) = 0; + // release the fonts + void ReleaseFonts() { SetFont( NULL, 0 ); } + // get the current font's metrics + virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel = 0 ) = 0; + + // get kernign pairs of the current font + // return only PairCount if (pKernPairs == NULL) + virtual sal_uLong GetKernPairs( sal_uLong nMaxPairCount, ImplKernPairData* ) = 0; + // get the repertoire of the current font + virtual const ImplFontCharMap* GetImplFontCharMap() const = 0; + // get the layout capabilities of the current font + virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0; + // graphics must fill supplied font list + virtual void GetDevFontList( ImplDevFontList* ) = 0; + // graphics should call ImplAddDevFontSubstitute on supplied + // OutputDevice for all its device specific preferred font substitutions + virtual void GetDevFontSubstList( OutputDevice* ) = 0; + virtual bool AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName ) = 0; + // CreateFontSubset: a method to get a subset of glyhps of a font + // inside a new valid font file + // returns sal_True if creation of subset was successfull + // parameters: rToFile: contains a osl file URL to write the subset to + // pFont: describes from which font to create a subset + // pGlyphIDs: the glyph ids to be extracted + // pEncoding: the character code corresponding to each glyph + // pWidths: the advance widths of the correspoding glyphs (in PS font units) + // nGlyphs: the number of glyphs + // rInfo: additional outgoing information + // implementation note: encoding 0 with glyph id 0 should be added implicitly + // as "undefined character" + virtual sal_Bool CreateFontSubset( const rtl::OUString& rToFile, + const ImplFontData* pFont, + sal_Int32* pGlyphIDs, + sal_uInt8* pEncoding, + sal_Int32* pWidths, + int nGlyphs, + FontSubsetInfo& rInfo // out parameter + ) = 0; + + // GetFontEncodingVector: a method to get the encoding map Unicode + // to font encoded character; this is only used for type1 fonts and + // may return NULL in case of unknown encoding vector + // if ppNonEncoded is set and non encoded characters (that is type1 + // glyphs with only a name) exist it is set to the corresponding + // map for non encoded glyphs; the encoding vector contains -1 + // as encoding for these cases + virtual const Ucs2SIntMap* GetFontEncodingVector( const ImplFontData*, const Ucs2OStrMap** ppNonEncoded ) = 0; + + // GetEmbedFontData: gets the font data for a font marked + // embeddable by GetDevFontList or NULL in case of error + // parameters: pFont: describes the font in question + // pUnicodes: contains the Unicodes assigned to + // code points 0 to 255; must contain at least 256 members + // pWidths: the widths of all glyphs from char code 0 to 255 + // pWidths MUST support at least 256 members; + // rInfo: additional outgoing information + // pDataLen: out parameter, contains the byte length of the returned buffer + virtual const void* GetEmbedFontData( const ImplFontData* pFont, + const sal_Ucs* pUnicodes, + sal_Int32* pWidths, + FontSubsetInfo& rInfo, + long* pDataLen ) = 0; + // frees the font data again + virtual void FreeEmbedFontData( const void* pData, long nDataLen ) = 0; + + // get the same widths as in CreateFontSubset and GetEmbedFontData + // in case of an embeddable font also fill the mapping + // between unicode and glyph id + // leave widths vector and mapping untouched in case of failure + virtual void GetGlyphWidths( const ImplFontData* pFont, + bool bVertical, + Int32Vector& rWidths, + Ucs2UIntMap& rUnicodeEnc ) = 0; + + virtual sal_Bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) = 0; + virtual sal_Bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) = 0; + + virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0; + virtual void DrawServerFontLayout( const ServerFontLayout& ) = 0; + /** Filter text from DrawText commands in a device specific manner + <p> + This function allows a device (or rather the corresponding SalGraphics + implementation) to prevent text portions from being drawn. This currently + is used only for filtering out the fax number in a document that is printed + to one of psprint's specialized "fax" printers. + </p> + + @param rOrigText + The original text + + @param rNewText + A String that will be filled with the adjusted version + + @param nIndex + The index inside <code>rOrigText</code> that marks the first draw character + + @param rLen + in: length of text beginning at <code>nIndex</code> to be drawn + out: length of <code>rNewText</code> containing the substituted text + + @param rCutStart + out: index at which the cutout portion of <code>rOrigText</code> begins + + @param rCutStop + out: index at which the cutout portion of <code>rOrigText</code> ends + + @returns + true: a substitution has taken place and rNewText rLen, rCutStart and rCutStop have been filled accordingly + false: no substitution has taken place, rNewText, rLen, rCutStart, rCutStop remain unchanged + */ + virtual bool filterText( const String& rOrigText, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ); + + virtual bool supportsOperation( OutDevSupportType ) const = 0; + + // mirroring specifica + int GetLayout() { return m_nLayout; } + void SetLayout( int aLayout ) { m_nLayout = aLayout;} + + void mirror( long& nX, const OutputDevice *pOutDev, bool bBack = false ) const; + void mirror( long& nX, long& nWidth, const OutputDevice *pOutDev, bool bBack = false ) const; + sal_Bool mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack = false ) const; + void mirror( Rectangle& rRect, const OutputDevice*, bool bBack = false ) const; + void mirror( Region& rRgn, const OutputDevice *pOutDev, bool bBack = false ) const; + void mirror( ControlType,const ImplControlValue&,const OutputDevice*,bool bBack = false) const; + basegfx::B2DPoint mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *pOutDev, bool bBack = false ) const; + basegfx::B2DPolygon mirror( const basegfx::B2DPolygon& i_rPoly, const OutputDevice *pOutDev, bool bBack = false ) const; + basegfx::B2DPolyPolygon mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *pOutDev, bool bBack = false ) const; + + // non virtual methods; these do possible coordinate mirroring and + // then delegate to protected virtual methods + bool SetClipRegion( const Region&, const OutputDevice *pOutDev ); + + // draw --> LineColor and FillColor and RasterOp and ClipRegion + void DrawPixel( long nX, long nY, const OutputDevice *pOutDev ); + void DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev ); + void DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev ); + void DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev ); + void DrawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev ); + void DrawPolygon( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev ); + void DrawPolyPolygon( sal_uInt32 nPoly, + const sal_uInt32* pPoints, + PCONSTSALPOINT* pPtAry, + const OutputDevice *pOutDev ); + bool DrawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency, const OutputDevice* ); + bool DrawPolyLine( const basegfx::B2DPolygon&, double fTransparency, const basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin, const OutputDevice* ); + sal_Bool DrawPolyLineBezier( sal_uLong nPoints, + const SalPoint* pPtAry, + const sal_uInt8* pFlgAry, + const OutputDevice *pOutDev ); + sal_Bool DrawPolygonBezier( sal_uLong nPoints, + const SalPoint* pPtAry, + const sal_uInt8* pFlgAry, + const OutputDevice *pOutDev ); + sal_Bool DrawPolyPolygonBezier( sal_uInt32 nPoly, + const sal_uInt32* pPoints, + const SalPoint* const* pPtAry, + const sal_uInt8* const* pFlgAry, + const OutputDevice *pOutDev ); + + // CopyArea --> No RasterOp, but ClipRegion + void CopyArea( long nDestX, + long nDestY, + long nSrcX, + long nSrcY, + long nSrcWidth, + long nSrcHeight, + sal_uInt16 nFlags, + const OutputDevice *pOutDev ); + + // CopyBits and DrawBitmap --> RasterOp and ClipRegion + // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics + void CopyBits( const SalTwoRect* pPosAry, + SalGraphics* pSrcGraphics, + const OutputDevice *pOutDev, + const OutputDevice *pSrcOutDev ); + void DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const OutputDevice *pOutDev ); + void DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nTransparentColor, + const OutputDevice *pOutDev ); + void DrawBitmap( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + const SalBitmap& rTransparentBitmap, + const OutputDevice *pOutDev ); + + void DrawMask( const SalTwoRect* pPosAry, + const SalBitmap& rSalBitmap, + SalColor nMaskColor, + const OutputDevice *pOutDev ); + + SalBitmap* GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev ); + SalColor GetPixel( long nX, long nY, const OutputDevice *pOutDev ); + + // invert --> ClipRegion (only Windows) + void Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev ); + void Invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev ); + + sal_Bool DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize, const OutputDevice *pOutDev ); + + //------------------------------------- + // Native Widget Rendering functions + //------------------------------------- + + // Query the platform layer for control support + virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart ); + + // Query the native control to determine if it was acted upon + sal_Bool HitTestNativeControl( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + const Point& aPos, + sal_Bool& rIsInside, + const OutputDevice *pOutDev ); + + // Request rendering of a particular control and/or part + sal_Bool DrawNativeControl( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const rtl::OUString& aCaption, + const OutputDevice *pOutDev ); + + // Request rendering of a caption string for a control + sal_Bool DrawNativeControlText( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const rtl::OUString& aCaption, + const OutputDevice *pOutDev ); + + // Query the native control's actual drawing region (including adornment) + sal_Bool GetNativeControlRegion( ControlType nType, + ControlPart nPart, + const Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const rtl::OUString& aCaption, + Rectangle &rNativeBoundingRegion, + Rectangle &rNativeContentRegion, + const OutputDevice *pOutDev ); + + static void AddDevFontSubstitute( OutputDevice* pOutDev, + const String& rFontName, + const String& rReplaceFontName, + sal_uInt16 nFlags = 0 ); + + bool DrawAlphaBitmap( const SalTwoRect&, + const SalBitmap& rSourceBitmap, + const SalBitmap& rAlphaBitmap, + const OutputDevice *pOutDev ); + + bool DrawAlphaRect( long nX, long nY, long nWidth, long nHeight, + sal_uInt8 nTransparency, const OutputDevice *pOutDev ); + + virtual SystemGraphicsData GetGraphicsData() const = 0; + virtual SystemFontData GetSysFontData( int nFallbacklevel ) const = 0; +}; + +#endif // _SV_SALGDI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salgeom.hxx b/vcl/inc/vcl/salgeom.hxx new file mode 100644 index 000000000000..c512d0a195fa --- /dev/null +++ b/vcl/inc/vcl/salgeom.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALGEOM_HXX +#define _SV_SALGEOM_HXX + +typedef struct _SalFrameGeometry { + // screen position of upper left corner of drawable area in pixel + long nX, nY; + // dimensions of the drawable area in pixel + unsigned long nWidth, nHeight; + // thickness of the decoration in pixel + unsigned long nLeftDecoration, + nTopDecoration, + nRightDecoration, + nBottomDecoration; + unsigned int nScreenNumber; + + _SalFrameGeometry() : + nX( 0 ), nY( 0 ), nWidth( 1 ), nHeight( 1 ), + nLeftDecoration( 0 ), nTopDecoration( 0 ), + nRightDecoration( 0 ), nBottomDecoration( 0 ), + nScreenNumber( 0 ) + {} +} SalFrameGeometry; + +#endif // _SV_SALGEOM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salgtype.hxx b/vcl/inc/vcl/salgtype.hxx new file mode 100644 index 000000000000..7f994f452f2c --- /dev/null +++ b/vcl/inc/vcl/salgtype.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALGTYPE_HXX +#define _SV_SALGTYPE_HXX + +#include <vcl/sv.h> + +// ------------ +// - SalColor - +// ------------ + +typedef sal_uInt32 SalColor; +#define MAKE_SALCOLOR( r, g, b ) ((SalColor)(((sal_uInt32)((sal_uInt8)(b))))|(((sal_uInt32)((sal_uInt8)(g)))<<8)|(((sal_uInt32)((sal_uInt8)(r)))<<16)) +#define SALCOLOR_RED( n ) ((sal_uInt8)((n)>>16)) +#define SALCOLOR_GREEN( n ) ((sal_uInt8)(((sal_uInt16)(n)) >> 8)) +#define SALCOLOR_BLUE( n ) ((sal_uInt8)(n)) +#define SALCOLOR_NONE (~(SalColor)0) +// ------------ +// - SalPoint - +// ------------ + +// must equal to class Point +struct SalPoint +{ + long mnX; + long mnY; +}; + +typedef const SalPoint* PCONSTSALPOINT; + +// -------------- +// - SalTwoRect - +// -------------- + +struct SalTwoRect +{ + long mnSrcX; + long mnSrcY; + long mnSrcWidth; + long mnSrcHeight; + long mnDestX; + long mnDestY; + long mnDestWidth; + long mnDestHeight; +}; + +// --------------- +// - SalROPColor - +// --------------- + +typedef sal_uInt16 SalROPColor; +#define SAL_ROP_0 ((SalROPColor)0) +#define SAL_ROP_1 ((SalROPColor)1) +#define SAL_ROP_INVERT ((SalROPColor)2) + +// ------------- +// - SalInvert - +// ------------- + +typedef sal_uInt16 SalInvert; +#define SAL_INVERT_HIGHLIGHT ((SalInvert)0x0001) +#define SAL_INVERT_50 ((SalInvert)0x0002) +#define SAL_INVERT_TRACKFRAME ((SalInvert)0x0004) + +#endif // _SV_SALGTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salimestatus.hxx b/vcl/inc/vcl/salimestatus.hxx new file mode 100644 index 000000000000..13362c20071d --- /dev/null +++ b/vcl/inc/vcl/salimestatus.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALIMESTATUS_HXX +#define _SV_SALIMESTATUS_HXX + +#include <vcl/dllapi.h> + +class VCL_PLUGIN_PUBLIC SalI18NImeStatus +{ +public: + SalI18NImeStatus() {} + virtual ~SalI18NImeStatus(); + + // asks whether there is a status window available + // to toggle into menubar + virtual bool canToggle() = 0; + virtual void toggle() = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salinst.hxx b/vcl/inc/vcl/salinst.hxx new file mode 100644 index 000000000000..d878dd7fea80 --- /dev/null +++ b/vcl/inc/vcl/salinst.hxx @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALINST_HXX +#define _SV_SALINST_HXX + +#include "com/sun/star/uno/Reference.hxx" + +#include "vcl/sv.h" +#include "vcl/displayconnectiondispatch.hxx" +#include "vcl/dllapi.h" + +#include "tools/string.hxx" + +#include "rtl/ref.hxx" +#include "rtl/string.hxx" + +#include <list> + +struct SystemParentData; +struct SalPrinterQueueInfo; +struct SalStatus; +struct ImplJobSetup; +class SalGraphics; +class SalFrame; +class SalObject; +class SalMenu; +class SalMenuItem; +class SalVirtualDevice; +class SalInfoPrinter; +class SalPrinter; +class SalTimer; +class ImplPrnQueueList; +class SalI18NImeStatus; +class SalSystem; +class SalBitmap; +struct SalItemParams; +class SalSession; +struct SystemGraphicsData; +struct SystemWindowData; +class Menu; + +// --------------- +// - SalInstance - +// --------------- + +class VCL_PLUGIN_PUBLIC SalInstance +{ +private: + rtl::Reference< vcl::DisplayConnectionDispatch > m_pEventInst; + +public: + SalInstance() {} + virtual ~SalInstance(); + + // Frame + // DisplayName for Unix ??? + virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) = 0; + virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ) = 0; + virtual void DestroyFrame( SalFrame* pFrame ) = 0; + + // Object (System Child Window) + virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ) = 0; + virtual void DestroyObject( SalObject* pObject ) = 0; + + // VirtualDevice + // nDX and nDY in Pixel + // nBitCount: 0 == Default(=as window) / 1 == Mono + // pData allows for using a system dependent graphics or device context + virtual SalVirtualDevice* CreateVirtualDevice( SalGraphics* pGraphics, + long nDX, long nDY, + sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ) = 0; + virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice ) = 0; + + // Printer + // pSetupData->mpDriverData can be 0 + // pSetupData must be updatet with the current + // JobSetup + virtual SalInfoPrinter* CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, + ImplJobSetup* pSetupData ) = 0; + virtual void DestroyInfoPrinter( SalInfoPrinter* pPrinter ) = 0; + virtual SalPrinter* CreatePrinter( SalInfoPrinter* pInfoPrinter ) = 0; + virtual void DestroyPrinter( SalPrinter* pPrinter ) = 0; + + virtual void GetPrinterQueueInfo( ImplPrnQueueList* pList ) = 0; + virtual void GetPrinterQueueState( SalPrinterQueueInfo* pInfo ) = 0; + virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) = 0; + virtual String GetDefaultPrinter() = 0; + + // SalTimer + virtual SalTimer* CreateSalTimer() = 0; + // SalI18NImeStatus + virtual SalI18NImeStatus* CreateI18NImeStatus() = 0; + // SalSystem + virtual SalSystem* CreateSalSystem() = 0; + // SalBitmap + virtual SalBitmap* CreateSalBitmap() = 0; + + // YieldMutex + virtual osl::SolarMutex* GetYieldMutex() = 0; + virtual sal_uLong ReleaseYieldMutex() = 0; + virtual void AcquireYieldMutex( sal_uLong nCount ) = 0; + // return true, if yield mutex is owned by this thread, else false + virtual bool CheckYieldMutex() = 0; + + // wait next event and dispatch + // must returned by UserEvent (SalFrame::PostEvent) + // and timer + virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ) = 0; + virtual bool AnyInput( sal_uInt16 nType ) = 0; + + // Menues + virtual SalMenu* CreateMenu( sal_Bool bMenuBar, Menu* pMenu ); + virtual void DestroyMenu( SalMenu* pMenu); + virtual SalMenuItem* CreateMenuItem( const SalItemParams* pItemData ); + virtual void DestroyMenuItem( SalMenuItem* pItem ); + + // may return NULL to disable session management + virtual SalSession* CreateSalSession() = 0; + + // methods for XDisplayConnection + + void SetEventCallback( rtl::Reference< vcl::DisplayConnectionDispatch > const & pInstance ) + { m_pEventInst = pInstance; } + bool CallEventCallback( void* pEvent, int nBytes ) + { return m_pEventInst.is() && m_pEventInst->dispatchEvent( pEvent, nBytes ); } + bool CallErrorCallback( void* pEvent, int nBytes ) + { return m_pEventInst.is() && m_pEventInst->dispatchErrorEvent( pEvent, nBytes ); } + + enum ConnectionIdentifierType { AsciiCString, Blob }; + virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) = 0; + + // this is a vehicle for PrintFontManager to bridge the gap between vcl and libvclplug_* + // this is only necessary because PrintFontManager is an exported vcl API and therefore + // needs to be in libvcl while libvclplug_* do not contain exported C++ API + virtual void FillFontPathList( std::list< rtl::OString >& o_rFontPaths ); + + // dtrans implementation + virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > + CreateClipboard( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& i_rArguments ); + virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDragSource(); + virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > CreateDropTarget(); + virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType) = 0; + + // callbacks for printer updates + virtual void updatePrinterUpdate() {} + virtual void jobStartedPrinterUpdate() {} + virtual void jobEndedPrinterUpdate() {} +}; + +// called from SVMain +SalInstance* CreateSalInstance(); +void DestroySalInstance( SalInstance* pInst ); + +// ------------------------- +// - SalInstance-Functions - +// ------------------------- + +void SalAbort( const XubString& rErrorText ); + +VCL_PLUGIN_PUBLIC const ::rtl::OUString& SalGetDesktopEnvironment(); + +// ----------- +// - SalData - +// ----------- + +void InitSalData(); // called from Application-Ctor +void DeInitSalData(); // called from Application-Dtor + +void InitSalMain(); +void DeInitSalMain(); + +// ---------- +// - SVMain - +// ---------- + +// Callbacks (indepen in \sv\source\app\svmain.cxx) +VCL_DLLPUBLIC int SVMain(); + +#endif // _SV_SALINST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/sallayout.hxx b/vcl/inc/vcl/sallayout.hxx new file mode 100644 index 000000000000..b91185769b27 --- /dev/null +++ b/vcl/inc/vcl/sallayout.hxx @@ -0,0 +1,393 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALLAYOUT_HXX +#define _SV_SALLAYOUT_HXX + +#include <tools/gen.hxx> + +#include <vector> +namespace basegfx { + class B2DPolyPolygon; + typedef std::vector<B2DPolyPolygon> B2DPolyPolygonVector; +} + +#ifndef _TOOLS_LANG_HXX +typedef unsigned short LanguageType; +#endif + +#include <vector> +#include <list> +#include <vcl/dllapi.h> + +// for typedef sal_UCS4 +#include <vcl/vclenum.hxx> + +class SalGraphics; +class ImplFontData; + +#define MAX_FALLBACK 16 + +// ---------------- +// - LayoutOption - +// ---------------- + +#define SAL_LAYOUT_BIDI_RTL 0x0001 +#define SAL_LAYOUT_BIDI_STRONG 0x0002 +#define SAL_LAYOUT_RIGHT_ALIGN 0x0004 +#define SAL_LAYOUT_KERNING_PAIRS 0x0010 +#define SAL_LAYOUT_KERNING_ASIAN 0x0020 +#define SAL_LAYOUT_VERTICAL 0x0040 +#define SAL_LAYOUT_COMPLEX_DISABLED 0x0100 +#define SAL_LAYOUT_ENABLE_LIGATURES 0x0200 +#define SAL_LAYOUT_SUBSTITUTE_DIGITS 0x0400 +#define SAL_LAYOUT_KASHIDA_JUSTIFICATON 0x0800 +#define SAL_LAYOUT_DISABLE_GLYPH_PROCESSING 0x1000 +#define SAL_LAYOUT_FOR_FALLBACK 0x2000 + +// ----------------- + +// used for managing runs e.g. for BiDi, glyph and script fallback +class VCL_PLUGIN_PUBLIC ImplLayoutRuns +{ +private: + int mnRunIndex; + std::vector<int> maRuns; + +public: + ImplLayoutRuns() { mnRunIndex = 0; maRuns.reserve(8); } + + void Clear() { maRuns.clear(); } + bool AddPos( int nCharPos, bool bRTL ); + bool AddRun( int nMinRunPos, int nEndRunPos, bool bRTL ); + + bool IsEmpty() const { return maRuns.empty(); } + void ResetPos() { mnRunIndex = 0; } + void NextRun() { mnRunIndex += 2; } + bool GetRun( int* nMinRunPos, int* nEndRunPos, bool* bRTL ) const; + bool GetNextPos( int* nCharPos, bool* bRTL ); + bool PosIsInRun( int nCharPos ) const; + bool PosIsInAnyRun( int nCharPos ) const; +}; + +// ----------------- + +class ImplLayoutArgs +{ +public: + // string related inputs + int mnFlags; + int mnLength; + int mnMinCharPos; + int mnEndCharPos; + const xub_Unicode* mpStr; + + // positioning related inputs + const sal_Int32* mpDXArray; // in pixel units + long mnLayoutWidth; // in pixel units + int mnOrientation; // in 0-3600 system + + // data for bidi and glyph+script fallback + ImplLayoutRuns maRuns; + ImplLayoutRuns maReruns; + +public: + ImplLayoutArgs( const xub_Unicode* pStr, int nLength, + int nMinCharPos, int nEndCharPos, int nFlags ); + + void SetLayoutWidth( long nWidth ) { mnLayoutWidth = nWidth; } + void SetDXArray( const sal_Int32* pDXArray ) { mpDXArray = pDXArray; } + void SetOrientation( int nOrientation ) { mnOrientation = nOrientation; } + + void ResetPos() + { maRuns.ResetPos(); } + bool GetNextPos( int* nCharPos, bool* bRTL ) + { return maRuns.GetNextPos( nCharPos, bRTL ); } + bool GetNextRun( int* nMinRunPos, int* nEndRunPos, bool* bRTL ); + bool NeedFallback( int nCharPos, bool bRTL ) + { return maReruns.AddPos( nCharPos, bRTL ); } + bool NeedFallback( int nMinRunPos, int nEndRunPos, bool bRTL ) + { return maReruns.AddRun( nMinRunPos, nEndRunPos, bRTL ); } + // methods used by BiDi and glyph fallback + bool NeedFallback() const + { return !maReruns.IsEmpty(); } + bool PrepareFallback(); + +protected: + void AddRun( int nMinCharPos, int nEndCharPos, bool bRTL ); +}; + +// helper functions often used with ImplLayoutArgs +bool IsDiacritic( sal_UCS4 ); +int GetVerticalFlags( sal_UCS4 ); +sal_UCS4 GetVerticalChar( sal_UCS4 ); +// #i80090# GetMirroredChar also needed outside vcl, moved to svapp.hxx +// VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 ); +sal_UCS4 GetLocalizedChar( sal_UCS4, LanguageType ); +VCL_PLUGIN_PUBLIC const char* GetAutofallback( sal_UCS4 ) ; + +// ------------- +// - SalLayout - +// ------------- + +typedef sal_uInt32 sal_GlyphId; + +// Glyph Flags +#define GF_NONE 0x00000000 +#define GF_FLAGMASK 0xFF800000 +#define GF_IDXMASK ~GF_FLAGMASK +#define GF_ISCHAR 0x00800000 +#define GF_ROTL 0x01000000 +// caution !!! +#define GF_VERT 0x02000000 +// GF_VERT is only for windows implementation +// (win/source/gdi/salgdi3.cxx, win/source/gdi/winlayout.cxx) +// don't use this elsewhere !!! +#define GF_ROTR 0x03000000 +#define GF_ROTMASK 0x03000000 +#define GF_UNHINTED 0x04000000 +#define GF_GSUB 0x08000000 +#define GF_FONTMASK 0xF0000000 +#define GF_FONTSHIFT 28 + +#define GF_DROPPED 0xFFFFFFFF + +// all positions/widths are in font units +// one exception: drawposition is in pixel units + +class VCL_PLUGIN_PUBLIC SalLayout +{ +public: + // used by upper layers + Point& DrawBase() { return maDrawBase; } + const Point& DrawBase() const { return maDrawBase; } + Point& DrawOffset() { return maDrawOffset; } + const Point& DrawOffset() const { return maDrawOffset; } + Point GetDrawPosition( const Point& rRelative = Point(0,0) ) const; + + virtual bool LayoutText( ImplLayoutArgs& ) = 0; // first step of layouting + virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting after fallback etc. + virtual void InitFont() const {} + virtual void DrawText( SalGraphics& ) const = 0; + + int GetUnitsPerPixel() const { return mnUnitsPerPixel; } + int GetOrientation() const { return mnOrientation; } + + virtual const ImplFontData* GetFallbackFontData( sal_GlyphId ) const; + + // methods using string indexing + virtual int GetTextBreak( long nMaxWidth, long nCharExtra=0, int nFactor=1 ) const = 0; + virtual long FillDXArray( sal_Int32* pDXArray ) const = 0; + virtual long GetTextWidth() const { return FillDXArray( NULL ); } + virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const = 0; + virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594 + + // methods using glyph indexing + virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdAry, Point& rPos, int&, + sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL ) const = 0; + virtual bool GetOutline( SalGraphics&, ::basegfx::B2DPolyPolygonVector& ) const; + virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const; + + virtual bool IsSpacingGlyph( sal_GlyphId ) const; + + // reference counting + void Reference() const; + void Release() const; + + // used by glyph+font+script fallback + virtual void MoveGlyph( int nStart, long nNewXPos ) = 0; + virtual void DropGlyph( int nStart ) = 0; + virtual void Simplify( bool bIsBase ) = 0; + virtual void DisableGlyphInjection( bool /*bDisable*/ ) {} + +protected: + // used by layout engines + SalLayout(); + virtual ~SalLayout(); + + // used by layout layers + void SetUnitsPerPixel( int n ) { mnUnitsPerPixel = n; } + void SetOrientation( int nOrientation ) // in 0-3600 system + { mnOrientation = nOrientation; } + + static int CalcAsianKerning( sal_UCS4, bool bLeft, bool bVertical ); + +private: + // enforce proper copy semantic + SAL_DLLPRIVATE SalLayout( const SalLayout& ); + SAL_DLLPRIVATE SalLayout& operator=( const SalLayout& ); + +protected: + int mnMinCharPos; + int mnEndCharPos; + int mnLayoutFlags; + + int mnUnitsPerPixel; + int mnOrientation; + + mutable int mnRefCount; + mutable Point maDrawOffset; + Point maDrawBase; +}; + +// ------------------ +// - MultiSalLayout - +// ------------------ + +class VCL_PLUGIN_PUBLIC MultiSalLayout : public SalLayout +{ +public: + virtual void DrawText( SalGraphics& ) const; + virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const; + virtual long FillDXArray( sal_Int32* pDXArray ) const; + virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const; + virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos, + int&, sal_Int32* pGlyphAdvAry, int* pCharPosAry ) const; + virtual bool GetOutline( SalGraphics&, ::basegfx::B2DPolyPolygonVector& ) const; + virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const; + + // used only by OutputDevice::ImplLayout, TODO: make friend + explicit MultiSalLayout( SalLayout& rBaseLayout, + const ImplFontData* pBaseFont = NULL ); + virtual bool AddFallback( SalLayout& rFallbackLayout, + ImplLayoutRuns&, const ImplFontData* pFallbackFont ); + virtual bool LayoutText( ImplLayoutArgs& ); + virtual void AdjustLayout( ImplLayoutArgs& ); + virtual void InitFont() const; + + virtual const ImplFontData* GetFallbackFontData( sal_GlyphId ) const; + + void SetInComplete(bool bInComplete = true); + +protected: + virtual ~MultiSalLayout(); + +private: + // dummy implementations + virtual void MoveGlyph( int, long ) {} + virtual void DropGlyph( int ) {} + virtual void Simplify( bool ) {} + + // enforce proper copy semantic + SAL_DLLPRIVATE MultiSalLayout( const MultiSalLayout& ); + SAL_DLLPRIVATE MultiSalLayout& operator=( const MultiSalLayout& ); + +private: + SalLayout* mpLayouts[ MAX_FALLBACK ]; + const ImplFontData* mpFallbackFonts[ MAX_FALLBACK ]; + ImplLayoutRuns maFallbackRuns[ MAX_FALLBACK ]; + int mnLevel; + bool mbInComplete; +}; + +// -------------------- +// - GenericSalLayout - +// -------------------- + +struct GlyphItem +{ + int mnFlags; + int mnCharPos; // index in string + int mnOrigWidth; // original glyph width + int mnNewWidth; // width after adjustments + sal_GlyphId mnGlyphIndex; + Point maLinearPos; // absolute position of non rotated string + +public: + GlyphItem() {} + + GlyphItem( int nCharPos, sal_GlyphId nGlyphIndex, const Point& rLinearPos, + long nFlags, int nOrigWidth ) + : mnFlags(nFlags), mnCharPos(nCharPos), + mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth), + mnGlyphIndex(nGlyphIndex), maLinearPos(rLinearPos) + {} + + enum{ FALLBACK_MASK=0xFF, IS_IN_CLUSTER=0x100, IS_RTL_GLYPH=0x200, IS_DIACRITIC=0x400 }; + + bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); } + bool IsRTLGlyph() const { return ((mnFlags & IS_RTL_GLYPH) != 0); } + bool IsDiacritic() const { return ((mnFlags & IS_DIACRITIC) != 0); } +}; + +// --------------- + +typedef std::list<GlyphItem> GlyphList; +typedef std::vector<GlyphItem> GlyphVector; + +// --------------- + +class VCL_PLUGIN_PUBLIC GenericSalLayout : public SalLayout +{ +public: + // used by layout engines + void AppendGlyph( const GlyphItem& ); + virtual void AdjustLayout( ImplLayoutArgs& ); + virtual void ApplyDXArray( ImplLayoutArgs& ); + virtual void Justify( long nNewWidth ); + void KashidaJustify( long nIndex, int nWidth ); + void ApplyAsianKerning( const sal_Unicode*, int nLength ); + void SortGlyphItems(); + + // used by upper layers + virtual long GetTextWidth() const; + virtual long FillDXArray( sal_Int32* pDXArray ) const; + virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const; + virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const; + + // used by display layers + virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos, int&, + sal_Int32* pGlyphAdvAry = NULL, int* pCharPosAry = NULL ) const; + +protected: + GenericSalLayout(); + virtual ~GenericSalLayout(); + + // for glyph+font+script fallback + virtual void MoveGlyph( int nStart, long nNewXPos ); + virtual void DropGlyph( int nStart ); + virtual void Simplify( bool bIsBase ); + + bool GetCharWidths( sal_Int32* pCharWidths ) const; + +private: + GlyphItem* mpGlyphItems; // TODO: change to GlyphList + int mnGlyphCount; + int mnGlyphCapacity; + mutable Point maBasePoint; + + // enforce proper copy semantic + SAL_DLLPRIVATE GenericSalLayout( const GenericSalLayout& ); + SAL_DLLPRIVATE GenericSalLayout& operator=( const GenericSalLayout& ); +}; + +#undef SalGraphics + +#endif // _SV_SALLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salmenu.hxx b/vcl/inc/vcl/salmenu.hxx new file mode 100644 index 000000000000..63fb12ee4a84 --- /dev/null +++ b/vcl/inc/vcl/salmenu.hxx @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALMENU_HXX +#define _SV_SALMENU_HXX + +#include <vcl/sv.h> +#include "vcl/dllapi.h" +#include <vcl/menu.hxx> +#include <vcl/keycod.hxx> +#include <vcl/image.hxx> + +struct SystemMenuData; +class FloatingWindow; +class SalFrame; + +struct SalItemParams +{ + sal_uInt16 nId; // item Id + MenuItemType eType; // MenuItem-Type + MenuItemBits nBits; // MenuItem-Bits + Menu* pMenu; // Pointer to Menu + XubString aText; // Menu-Text + Image aImage; // Image +}; + + +struct SalMenuButtonItem +{ + sal_uInt16 mnId; + Image maImage; + rtl::OUString maToolTipText; + + SalMenuButtonItem() : mnId( 0 ) {} + SalMenuButtonItem( sal_uInt16 i_nId, const Image& rImg, const rtl::OUString& i_rTTText = rtl::OUString() ) + : mnId( i_nId ), maImage( rImg ), maToolTipText( i_rTTText ) {} +}; + +class VCL_PLUGIN_PUBLIC SalMenuItem +{ +public: + SalMenuItem() {} + virtual ~SalMenuItem(); +}; + +class VCL_PLUGIN_PUBLIC SalMenu +{ +public: + SalMenu() {} + virtual ~SalMenu(); + + virtual sal_Bool VisibleMenuBar() = 0; // must return sal_True to actually DISPLAY native menu bars + // otherwise only menu messages are processed (eg, OLE on Windows) + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) = 0; + virtual void RemoveItem( unsigned nPos ) = 0; + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) = 0; + virtual void SetFrame( const SalFrame* pFrame ) = 0; + virtual void CheckItem( unsigned nPos, sal_Bool bCheck ) = 0; + virtual void EnableItem( unsigned nPos, sal_Bool bEnable ) = 0; + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const XubString& rText )= 0; + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage ) = 0; + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const KeyCode& rKeyCode, const XubString& rKeyName ) = 0; + virtual void GetSystemMenuData( SystemMenuData* pData ) = 0; + virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const Rectangle& rRect, sal_uLong nFlags); + virtual bool AddMenuBarButton( const SalMenuButtonItem& ); // return false if not implemented or failure + virtual void RemoveMenuBarButton( sal_uInt16 nId ); + + // return an empty rectangle if not implemented + // return Rectangle( Point( -1, -1 ), Size( 1, 1 ) ) if menu bar buttons implemented + // but rectangle cannot be determined + virtual Rectangle GetMenuBarButtonRectPixel( sal_uInt16 i_nItemId, SalFrame* i_pReferenceFrame ); +}; + + +#endif // _SV_SALMENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salnativewidgets.hxx b/vcl/inc/vcl/salnativewidgets.hxx new file mode 100644 index 000000000000..696a8660bb2f --- /dev/null +++ b/vcl/inc/vcl/salnativewidgets.hxx @@ -0,0 +1,475 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_NATIVEWIDGETS_HXX +#define _SV_NATIVEWIDGETS_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <tools/gen.hxx> + +/* Control Types: + * + * Specify the overall, whole control + * type (as opposed to parts of the + * control if it were composite). + */ + +typedef sal_uInt32 ControlType; + +// for use in general purpose ImplControlValue +#define CTRL_GENERIC 0 + +// Normal PushButton/Command Button +#define CTRL_PUSHBUTTON 1 + +// Normal single radio button +#define CTRL_RADIOBUTTON 2 + +// Normal single checkbox +#define CTRL_CHECKBOX 10 + +// Combobox, i.e. a ListBox +// that allows data entry by user +#define CTRL_COMBOBOX 20 + +// Control that allows text entry +#define CTRL_EDITBOX 30 + +// Control that allows text entry, but without the usual border +// Has to be handled separately, because this one cannot handle +// HAS_BACKGROUND_TEXTURE, which is drawn in the edit box'es +// border window. +#define CTRL_EDITBOX_NOBORDER 31 + +// Control that allows text entry +// ( some systems distingish between single and multi line edit boxes ) +#define CTRL_MULTILINE_EDITBOX 32 + +// Control that pops up a menu, +// but does NOT allow data entry +#define CTRL_LISTBOX 35 + +// An edit field together with two little +// buttons on the side (aka spin field) +#define CTRL_SPINBOX 40 + +// Two standalone spin buttons +// without an edit field +#define CTRL_SPINBUTTONS 45 + +// A single tab +#define CTRL_TAB_ITEM 50 + +// The border around a tab area, +// but without the tabs themselves. +// May have a gap at the top for +// the active tab +#define CTRL_TAB_PANE 55 + +// Background of a Tab Pane +#define CTRL_TAB_BODY 56 + +// Normal scrollbar, including +// all parts like slider, buttons +#define CTRL_SCROLLBAR 60 + +#define CTRL_SLIDER 65 + +// Border around a group of related +// items, perhaps also displaying +// a label of identification +#define CTRL_GROUPBOX 70 + +// A separator line +#define CTRL_FIXEDLINE 80 + +// A rectangular border, like a +// Tab Pane, but without the +// possible gap for a tab +#define CTRL_FIXEDBORDER 90 + +// A toolbar control with buttons and a grip +#define CTRL_TOOLBAR 100 + +// The menubar +#define CTRL_MENUBAR 120 +// popup menu +#define CTRL_MENU_POPUP 121 + +// The statusbar +#define CTRL_STATUSBAR 130 +#define CTRL_PROGRESS 131 +// Progress bar for the intro window +// (aka splash screen), in case some +// wants native progress bar in the +// application but not for the splash +// screen (used in desktop/) +#define CTRL_INTROPROGRESS 132 + +// tool tips +#define CTRL_TOOLTIP 140 + +// to draw the implemented theme +#define CTRL_WINDOW_BACKGROUND 150 + +//to draw border of frames natively +#define CTRL_FRAME 160 + +// for nodes in listviews +// used in svtools/source/contnr/svtreebx.cxx +#define CTRL_LISTNODE 170 +// nets between elements of listviews +// with nodes +#define CTRL_LISTNET 171 + + +/* Control Parts: + * + * Uniquely identify a part of a control, + * for example the slider of a scroll bar. + */ + +typedef sal_uInt32 ControlPart; + +#define PART_ENTIRE_CONTROL 1 +#define PART_WINDOW 5 // the static listbox window containing the list +#define PART_BUTTON 100 +#define PART_BUTTON_UP 101 +#define PART_BUTTON_DOWN 102 // Also for ComboBoxes/ListBoxes +#define PART_BUTTON_LEFT 103 +#define PART_BUTTON_RIGHT 104 +#define PART_ALL_BUTTONS 105 +#define PART_SEPARATOR 106 +#define PART_TRACK_HORZ_LEFT 200 +#define PART_TRACK_VERT_UPPER 201 +#define PART_TRACK_HORZ_RIGHT 202 +#define PART_TRACK_VERT_LOWER 203 +#define PART_TRACK_HORZ_AREA 204 +#define PART_TRACK_VERT_AREA 205 +#define PART_THUMB_HORZ 210 // Also used as toolbar grip +#define PART_THUMB_VERT 211 // Also used as toolbar grip +#define PART_MENU_ITEM 250 +#define PART_MENU_ITEM_CHECK_MARK 251 +#define PART_MENU_ITEM_RADIO_MARK 252 +#define PART_MENU_SEPARATOR 253 + +/* #i77549# + HACK: for scrollbars in case of thumb rect, page up and page down rect we + abuse the HitTestNativeControl interface. All theming engines but aqua + are actually able to draw the thumb according to our internal representation. + However aqua draws a little outside. The canonical way would be to enhance the + HitTestNativeControl passing a ScrollbarValue additionally so all necessary + information is available in the call. + . + However since there is only this one small exception we will deviate a little and + instead pass the respective rect as control region to allow for a small correction. + + So all places using HitTestNativeControl on PART_THUMB_HORZ, PART_THUMB_VERT, + PART_TRACK_HORZ_LEFT, PART_TRACK_HORZ_RIGHT, PART_TRACK_VERT_UPPER, PART_TRACK_VERT_LOWER + do not use the control rectangle as region but the actuall part rectangle, making + only small deviations feasible. +*/ + +/** The edit field part of a control, e.g. of the combo box. + + Currently used just for combo boxes and just for GetNativeControlRegion(). + It is valid only if GetNativeControlRegion() supports PART_BUTTON_DOWN as + well. +*/ +#define PART_SUB_EDIT 300 + +// For controls that require the entire background +// to be drawn first, and then other pieces over top. +// (GTK+ scrollbars for example). Control region passed +// in to draw this part is expected to be the entire +// area of the control. +// A control may respond to one or both. +#define PART_DRAW_BACKGROUND_HORZ 1000 +#define PART_DRAW_BACKGROUND_VERT 1001 + +// GTK+ also draws tabs right->left since there is a +// hardcoded 2 pixel overlap between adjacent tabs +#define PART_TABS_DRAW_RTL 3000 + +// For themes that do not want to have the focus +// rectangle part drawn by VCL but take care of the +// whole inner control part by themselves +// eg, listboxes or comboboxes or spinbuttons +#define HAS_BACKGROUND_TEXTURE 4000 + +// For scrollbars that have 3 buttons (most KDE themes) +#define HAS_THREE_BUTTONS 5000 + +#define PART_BACKGROUND_WINDOW 6000 +#define PART_BACKGROUND_DIALOG 6001 + +//to draw natively the border of frames +#define PART_BORDER 7000 + +/* Control State: + * + * Specify how a particular part of the control + * is to be drawn. Constants are bitwise OR-ed + * together to compose a final drawing state. + * A _disabled_ state is assumed by the drawing + * functions until an ENABLED or HIDDEN is passed + * in the ControlState. + */ + +typedef sal_uInt32 ControlState; + +#define CTRL_STATE_ENABLED 0x0001 +#define CTRL_STATE_FOCUSED 0x0002 +#define CTRL_STATE_PRESSED 0x0004 +#define CTRL_STATE_ROLLOVER 0x0008 +#define CTRL_STATE_HIDDEN 0x0010 +#define CTRL_STATE_DEFAULT 0x0020 +#define CTRL_STATE_SELECTED 0x0040 +#define CTRL_CACHING_ALLOWED 0x8000 // set when the control is completely visible (i.e. not clipped) + +/* ButtonValue: + * + * Identifies the tri-state value options + * that buttons allow + */ + +enum ButtonValue { + BUTTONVALUE_DONTKNOW, + BUTTONVALUE_ON, + BUTTONVALUE_OFF, + BUTTONVALUE_MIXED +}; + +/* ImplControlValue: + * + * Generic value container for all control parts. + */ + +class VCL_DLLPUBLIC ImplControlValue +{ + friend class SalFrame; + + private: + ControlType mType; + ButtonValue mTristate; // Tristate value: on, off, mixed + long mNumber; // numeric value + protected: + ImplControlValue( ControlType i_eType, ButtonValue i_eTriState, long i_nNumber ) + : mType( i_eType ) + , mTristate( i_eTriState ) + , mNumber( i_nNumber ) + {} + + public: + explicit ImplControlValue( ButtonValue nTristate ) + : mType( CTRL_GENERIC ), mTristate(nTristate), mNumber(0) {} + explicit ImplControlValue( long nNumeric ) + : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber( nNumeric) {} + inline ImplControlValue() + : mType( CTRL_GENERIC ), mTristate(BUTTONVALUE_DONTKNOW), mNumber(0) {} + + virtual ~ImplControlValue(); + + ControlType getType() const { return mType; } + + inline ButtonValue getTristateVal( void ) const { return mTristate; } + inline void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; } + + inline long getNumericVal( void ) const { return mNumber; } + inline void setNumericVal( long nNumeric ) { mNumber = nNumeric; } +}; + +/* ScrollbarValue: + * + * Value container for scrollbars. + */ +class VCL_DLLPUBLIC ScrollbarValue : public ImplControlValue +{ + public: + long mnMin; + long mnMax; + long mnCur; + long mnVisibleSize; + Rectangle maThumbRect; + Rectangle maButton1Rect; + Rectangle maButton2Rect; + ControlState mnButton1State; + ControlState mnButton2State; + ControlState mnThumbState; + ControlState mnPage1State; + ControlState mnPage2State; + + inline ScrollbarValue() + : ImplControlValue( CTRL_SCROLLBAR, BUTTONVALUE_DONTKNOW, 0 ) + { + mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0; + mnButton1State = 0; mnButton2State = 0; + mnThumbState = 0; mnPage1State = 0; mnPage2State = 0; + }; + virtual ~ScrollbarValue(); +}; + +class VCL_DLLPUBLIC SliderValue : public ImplControlValue +{ + public: + long mnMin; + long mnMax; + long mnCur; + Rectangle maThumbRect; + ControlState mnThumbState; + + SliderValue() + : ImplControlValue( CTRL_SLIDER, BUTTONVALUE_DONTKNOW, 0 ) + , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( 0 ) + {} + virtual ~SliderValue(); +}; + +/* TabitemValue: + * + * Value container for tabitems. + */ + +/* TABITEM constants are OR-ed together */ +#define TABITEM_NOTALIGNED 0x000 // the tabitem is an inner item +#define TABITEM_LEFTALIGNED 0x001 // the tabitem is aligned with the left border of the TabControl +#define TABITEM_RIGHTALIGNED 0x002 // the tabitem is aligned with the right border of the TabControl +#define TABITEM_FIRST_IN_GROUP 0x004 // the tabitem is the first in group of tabitems +#define TABITEM_LAST_IN_GROUP 0x008 // the tabitem is the last in group of tabitems + +class VCL_DLLPUBLIC TabitemValue : public ImplControlValue +{ + public: + unsigned int mnAlignment; + + inline TabitemValue() + : ImplControlValue( CTRL_TAB_ITEM, BUTTONVALUE_DONTKNOW, 0 ) + { + mnAlignment = 0; + }; + virtual ~TabitemValue(); + + sal_Bool isLeftAligned() const { return (mnAlignment & TABITEM_LEFTALIGNED) != 0; } + sal_Bool isRightAligned() const { return (mnAlignment & TABITEM_RIGHTALIGNED) != 0; } + sal_Bool isBothAligned() const { return isLeftAligned() && isRightAligned(); } + sal_Bool isNotAligned() const { return (mnAlignment & (TABITEM_LEFTALIGNED | TABITEM_RIGHTALIGNED)) == 0; } + sal_Bool isFirst() const { return (mnAlignment & TABITEM_FIRST_IN_GROUP) != 0; } + sal_Bool isLast() const { return (mnAlignment & TABITEM_LAST_IN_GROUP) != 0; } +}; + +/* SpinbuttonValue: + * + * Value container for spinbuttons to paint both buttons at once. + * Note: the other parameters of DrawNativeControl will have no meaning + * all parameters for spinbuttons are carried here + */ +class VCL_DLLPUBLIC SpinbuttonValue : public ImplControlValue +{ + public: + Rectangle maUpperRect; + Rectangle maLowerRect; + ControlState mnUpperState; + ControlState mnLowerState; + int mnUpperPart; + int mnLowerPart; + + inline SpinbuttonValue() + : ImplControlValue( CTRL_SPINBUTTONS, BUTTONVALUE_DONTKNOW, 0 ) + { + mnUpperState = mnLowerState = 0; + }; + virtual ~SpinbuttonValue(); +}; + +/* Toolbarvalue: + * + * Value container for toolbars detailing the grip position + */ +class ToolbarValue : public ImplControlValue +{ +public: + ToolbarValue() : ImplControlValue( CTRL_TOOLBAR, BUTTONVALUE_DONTKNOW, 0 ) + { mbIsTopDockingArea = sal_False; } + virtual ~ToolbarValue(); + Rectangle maGripRect; + sal_Bool mbIsTopDockingArea; // indicates that this is the top aligned dockingarea + // adjacent to the menubar +}; + +/* MenubarValue: + * + * Value container for menubars specifying height of adjacent docking area + */ +class MenubarValue : public ImplControlValue +{ +public: + MenubarValue() : ImplControlValue( CTRL_MENUBAR, BUTTONVALUE_DONTKNOW, 0 ) + { maTopDockingAreaHeight=0; } + virtual ~MenubarValue(); + int maTopDockingAreaHeight; +}; + +/* MenupopupValue: + * + * Value container for menu items; specifies the rectangle for the whole item which + * may be useful when drawing parts with a smaller rectangle. + */ +class MenupopupValue : public ImplControlValue +{ +public: + MenupopupValue() : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, 0 ) + {} + MenupopupValue( long i_nGutterWidth, const Rectangle& i_rItemRect ) + : ImplControlValue( CTRL_MENU_POPUP, BUTTONVALUE_DONTKNOW, i_nGutterWidth ) + , maItemRect( i_rItemRect ) + {} + virtual ~MenupopupValue(); + Rectangle maItemRect; +}; + +/* PushButtonValue: + * + * Value container for pushbuttons specifying additional drawing hints + */ +class PushButtonValue : public ImplControlValue +{ +public: + PushButtonValue() + : ImplControlValue( CTRL_PUSHBUTTON, BUTTONVALUE_DONTKNOW, 0 ) + , mbBevelButton( false ), mbSingleLine( true ) {} + virtual ~PushButtonValue(); + + bool mbBevelButton:1; + bool mbSingleLine:1; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salobj.hxx b/vcl/inc/vcl/salobj.hxx new file mode 100644 index 000000000000..4e781787b0c9 --- /dev/null +++ b/vcl/inc/vcl/salobj.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALOBJ_HXX +#define _SV_SALOBJ_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/salgtype.hxx> +#include <vcl/salwtype.hxx> + +struct SystemEnvData; + +// ------------------- +// - SalObject-Types - +// ------------------- + +#define SAL_OBJECT_CLIP_INCLUDERECTS ((sal_uInt16)0x0001) +#define SAL_OBJECT_CLIP_EXCLUDERECTS ((sal_uInt16)0x0002) +#define SAL_OBJECT_CLIP_ABSOLUTE ((sal_uInt16)0x0004) + +// ------------- +// - SalObject - +// ------------- + +class VCL_PLUGIN_PUBLIC SalObject +{ + void* m_pInst; + SALOBJECTPROC m_pCallback; + sal_Bool m_bMouseTransparent:1, + m_bEraseBackground:1; +public: + SalObject() : m_pInst( NULL ), m_pCallback( NULL ), m_bMouseTransparent( sal_False ), m_bEraseBackground( sal_True ) {} + virtual ~SalObject(); + + virtual void ResetClipRegion() = 0; + virtual sal_uInt16 GetClipRegionType() = 0; + virtual void BeginSetClipRegion( sal_uLong nRects ) = 0; + virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) = 0; + virtual void EndSetClipRegion() = 0; + + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight ) = 0; + virtual void Show( sal_Bool bVisible ) = 0; + virtual void Enable( sal_Bool nEnable ) = 0; + virtual void GrabFocus() = 0; + + virtual void SetBackground() = 0; + virtual void SetBackground( SalColor nSalColor ) = 0; + + virtual void SetForwardKey( sal_Bool /*bEnable*/ ) {} + + virtual const SystemEnvData* GetSystemData() const = 0; + + virtual void InterceptChildWindowKeyDown( sal_Bool bIntercept ) = 0; + + void SetCallback( void* pInst, SALOBJECTPROC pProc ) + { m_pInst = pInst; m_pCallback = pProc; } + long CallCallback( sal_uInt16 nEvent, const void* pEvent ) + { return m_pCallback ? m_pCallback( m_pInst, this, nEvent, pEvent ) : 0; } + void SetMouseTransparent( sal_Bool bMouseTransparent ) + { m_bMouseTransparent = bMouseTransparent; } + sal_Bool IsMouseTransparent() + { return m_bMouseTransparent; } + void EnableEraseBackground( sal_Bool bEnable ) + { m_bEraseBackground = bEnable; } + sal_Bool IsEraseBackgroundEnabled() + { return m_bEraseBackground; } +}; + +#endif // _SV_SALOBJ_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salprn.hxx b/vcl/inc/vcl/salprn.hxx new file mode 100644 index 000000000000..e820614e4cdd --- /dev/null +++ b/vcl/inc/vcl/salprn.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALPRN_HXX +#define _SV_SALPRN_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/prntypes.hxx> + +#include <vector> + +class SalGraphics; +class SalFrame; +struct ImplJobSetup; +namespace vcl { class PrinterController; } + +// ----------------------- +// - SalPrinterQueueInfo - +// ----------------------- + +struct VCL_PLUGIN_PUBLIC SalPrinterQueueInfo +{ + XubString maPrinterName; + XubString maDriver; + XubString maLocation; + XubString maComment; + sal_uLong mnStatus; + sal_uLong mnJobs; + void* mpSysData; + + SalPrinterQueueInfo(); + ~SalPrinterQueueInfo(); +}; + +// ------------------ +// - SalInfoPrinter - +// ------------------ + +class VCL_PLUGIN_PUBLIC SalInfoPrinter +{ +public: + std::vector< PaperInfo > m_aPaperFormats; // all printer supported formats + bool m_bPapersInit; // set to true after InitPaperFormats + bool m_bCompatMetrics; + + SalInfoPrinter() : m_bPapersInit( false ), m_bCompatMetrics( false ) {} + virtual ~SalInfoPrinter(); + + // SalGraphics or NULL, but two Graphics for all SalFrames + // must be returned + virtual SalGraphics* GetGraphics() = 0; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0; + + virtual sal_Bool Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ) = 0; + // This function set the driver data and + // set the new indepen data in pSetupData + virtual sal_Bool SetPrinterData( ImplJobSetup* pSetupData ) = 0; + // This function merged the indepen driver data + // and set the new indepen data in pSetupData + // Only the data must changed, where the bit + // in nFlags is set + virtual sal_Bool SetData( sal_uLong nFlags, ImplJobSetup* pSetupData ) = 0; + + virtual void GetPageInfo( const ImplJobSetup* pSetupData, + long& rOutWidth, long& rOutHeight, + long& rPageOffX, long& rPageOffY, + long& rPageWidth, long& rPageHeight ) = 0; + virtual sal_uLong GetCapabilities( const ImplJobSetup* pSetupData, sal_uInt16 nType ) = 0; + virtual sal_uLong GetPaperBinCount( const ImplJobSetup* pSetupData ) = 0; + virtual String GetPaperBinName( const ImplJobSetup* pSetupData, sal_uLong nPaperBin ) = 0; + // fills m_aPaperFormats and sets m_bPapersInit to true + 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; +}; + +// -------------- +// - SalPrinter - +// -------------- + +class VCL_PLUGIN_PUBLIC SalPrinter +{ +public: // public for Sal Implementation + SalPrinter() {} + virtual ~SalPrinter(); + + virtual sal_Bool StartJob( const String* pFileName, + const String& rJobName, + const String& rAppName, + sal_uLong nCopies, + bool bCollate, + bool bDirect, + ImplJobSetup* pSetupData ) = 0; + + // implement for pull model print systems only, + // default implementations (see salvtables.cxx) just returns sal_False + virtual sal_Bool StartJob( const String* pFileName, + const String& rJobName, + const String& rAppName, + ImplJobSetup* pSetupData, + vcl::PrinterController& rController ); + + virtual sal_Bool EndJob() = 0; + virtual sal_Bool AbortJob() = 0; + virtual SalGraphics* StartPage( ImplJobSetup* pSetupData, sal_Bool bNewJobData ) = 0; + virtual sal_Bool EndPage() = 0; + virtual sal_uLong GetErrorCode() = 0; + +}; + +#endif // _SV_SALPRN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salptype.hxx b/vcl/inc/vcl/salptype.hxx new file mode 100644 index 000000000000..ca47f599271c --- /dev/null +++ b/vcl/inc/vcl/salptype.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALPTYPE_HXX +#define _SV_SALPTYPE_HXX + +#include <vcl/sv.h> + +// -------------------- +// - SalJobSetupFlags - +// -------------------- + +#define SAL_JOBSET_ORIENTATION ((sal_uLong)0x00000001) +#define SAL_JOBSET_PAPERBIN ((sal_uLong)0x00000002) +#define SAL_JOBSET_PAPERSIZE ((sal_uLong)0x00000004) +#define SAL_JOBSET_DUPLEXMODE ((sal_uLong)0x00000008) +#define SAL_JOBSET_ALL (SAL_JOBSET_ORIENTATION |\ + SAL_JOBSET_PAPERBIN |\ + SAL_JOBSET_PAPERSIZE |\ + SAL_JOBSET_DUPLEXMODE) + +// ------------------- +// - SalPrinterError - +// ------------------- + +#define SAL_PRINTER_ERROR_GENERALERROR 1 +#define SAL_PRINTER_ERROR_ABORT 2 + +// ------------------- +// - SalPrinterProcs - +// ------------------- + +class SalPrinter; +typedef long (*SALPRNABORTPROC)( void* pInst, SalPrinter* pPrinter ); + +#endif // _SV_SALPTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salsession.hxx b/vcl/inc/vcl/salsession.hxx new file mode 100644 index 000000000000..c912565a920c --- /dev/null +++ b/vcl/inc/vcl/salsession.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_SALSESSION_HXX +#define _VCL_SALSESSION_HXX + +#include "vcl/dllapi.h" + +enum SalSessionEventType +{ + Interaction, + SaveRequest, + ShutdownCancel, + Quit +}; + +struct SalSessionEvent +{ + SalSessionEventType m_eType; + + SalSessionEvent( SalSessionEventType eType ) + : m_eType( eType ) + {} +}; + +struct SalSessionInteractionEvent : public SalSessionEvent +{ + bool m_bInteractionGranted; + + SalSessionInteractionEvent( bool bGranted ) + : SalSessionEvent( Interaction ), + m_bInteractionGranted( bGranted ) + {} +}; + +struct SalSessionSaveRequestEvent : public SalSessionEvent +{ + bool m_bShutdown; + bool m_bCancelable; + + SalSessionSaveRequestEvent( bool bShutdown, bool bCancelable ) + : SalSessionEvent( SaveRequest ), + m_bShutdown( bShutdown ), + m_bCancelable( bCancelable ) + {} +}; + +struct SalSessionShutdownCancelEvent : public SalSessionEvent +{ + SalSessionShutdownCancelEvent() + : SalSessionEvent( ShutdownCancel ) + {} +}; + +struct SalSessionQuitEvent : public SalSessionEvent +{ + SalSessionQuitEvent() + : SalSessionEvent( Quit ) + {} +}; + +typedef void(*SessionProc)( SalSessionEvent *pEvent); + +class VCL_PLUGIN_PUBLIC SalSession +{ + SessionProc m_aProc; +public: + SalSession() + : m_aProc( 0 ) + {} + virtual ~SalSession(); + + void SetCallback( SessionProc aCallback ) + { + m_aProc = aCallback; + } + void CallCallback( SalSessionEvent* pEvent ) + { + if( m_aProc ) + m_aProc( pEvent ); + } + + // query the session manager for a user interaction slot + virtual void queryInteraction() = 0; + // signal the session manager that we're done with user interaction + virtual void interactionDone() = 0; + // signal that we're done saving + virtual void saveDone() = 0; + // try to cancel the sutdown in progress + virtual bool cancelShutdown() = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salsys.hxx b/vcl/inc/vcl/salsys.hxx new file mode 100644 index 000000000000..2f2f6d08e9e6 --- /dev/null +++ b/vcl/inc/vcl/salsys.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALSYS_HXX +#define _SV_SALSYS_HXX + +#include <tools/string.hxx> +#include <tools/gen.hxx> +#include <vcl/dllapi.h> + + +/* Button combinations for ShowNativeMessageBox +*/ +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK = 0; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL = 1; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE = 2; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL = 3; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO = 4; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL = 5; + +/* Button identifier for ShowNativeMessageBox +*/ +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK = 1; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL = 2; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT = 3; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY = 4; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE = 5; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES = 6; +const int SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO = 7; + + + +// ------------- +// - SalSystem - +// ------------- + +class VCL_PLUGIN_PUBLIC SalSystem +{ +public: + SalSystem() {} + virtual ~SalSystem(); + + // get info about the display + + /* Gets the number of active screens attached to the display + + @returns the number of active screens + */ + virtual unsigned int GetDisplayScreenCount() = 0; + /* Queries whether multiple screens are truly separate + + @returns true if screens are distinct and windows cannot + be moved between them or span multiple of them + false if screens form up one big display + */ + virtual bool IsMultiDisplay() = 0; + /* Queries the default screen number. The default screen is the + screen on which windows will appear if no special positioning + is made. + + @returns the default screen number + */ + virtual unsigned int GetDefaultDisplayNumber() = 0; + /* Gets relative position and size of the screens attached to the display + + @param nScreen + The screen number to be queried + + @returns position: (0,0) in case of IsMultiscreen() == true + else position relative to whole display + size: size of the screen + */ + virtual Rectangle GetDisplayScreenPosSizePixel( unsigned int nScreen ) = 0; + /* Gets position and size of the work area of a screen attached to the display + + @param nScreen + The screen number to be queried + + @returns position and size relative to the scree + */ + virtual Rectangle GetDisplayWorkAreaPosSizePixel( unsigned int nScreen ) = 0; + /* Gets the name of a screen + + @param nScreen + The screen number to be queried + + @returns the name of the screen + */ + virtual rtl::OUString GetScreenName( unsigned int nScreen ) = 0; + + /* Shows a native message box with the specified title, message and button + combination. + + @param rTitle + The title to be shown by the dialog box. + + @param rMessage + The message to be shown by the dialog box. + + @param nButtonCombination + Specify which button combination the message box should display. + See button combinations above. + + @param nDefaultButton + Specifies which button has the focus initially. + See button identifiers above. + The effect of specifying a button that doesn't belong + to the specified button combination is undefined. + + @returns the identifier of the button that was pressed by the user. + See button identifier above. If the function fails the + return value is 0. + */ + virtual int ShowNativeMessageBox( const String& rTitle, + const String& rMessage, + int nButtonCombination, + int nDefaultButton) = 0; +}; + +SalSystem* ImplGetSalSystem(); + +#endif // _SV_SALSYS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/saltimer.hxx b/vcl/inc/vcl/saltimer.hxx new file mode 100644 index 000000000000..4bbaddb65b31 --- /dev/null +++ b/vcl/inc/vcl/saltimer.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALTIMER_HXX +#define _SV_SALTIMER_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/salwtype.hxx> + +// ------------ +// - SalTimer - +// ------------ + +/* + * note: there will be only a single instance of SalTimer + * SalTimer originally had only static methods, but + * this needed to be virtualized for the sal plugin migration + */ + +class VCL_PLUGIN_PUBLIC SalTimer +{ + SALTIMERPROC m_pProc; +public: + SalTimer() : m_pProc( NULL ) {} + virtual ~SalTimer(); + + // AutoRepeat and Restart + virtual void Start( sal_uLong nMS ) = 0; + virtual void Stop() = 0; + + // Callbacks (indepen in \sv\source\app\timer.cxx) + void SetCallback( SALTIMERPROC pProc ) + { + m_pProc = pProc; + } + + void CallCallback() + { + if( m_pProc ) + m_pProc(); + } +}; + +#endif // _SV_SALTIMER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salvd.hxx b/vcl/inc/vcl/salvd.hxx new file mode 100644 index 000000000000..68ed56a901d8 --- /dev/null +++ b/vcl/inc/vcl/salvd.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALVD_HXX +#define _SV_SALVD_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +class SalGraphics; + +// -------------------- +// - SalVirtualDevice - +// -------------------- + +class VCL_PLUGIN_PUBLIC SalVirtualDevice +{ +public: // public for Sal Implementation + SalVirtualDevice() {} + virtual ~SalVirtualDevice(); + + // SalGraphics or NULL, but two Graphics for all SalVirtualDevices + // must be returned + virtual SalGraphics* GetGraphics() = 0; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0; + + // Set new size, without saving the old contents + virtual sal_Bool SetSize( long nNewDX, long nNewDY ) = 0; + + /// Get actual VDev size in pixel + virtual void GetSize( long& rWidth, long& rHeight ) = 0; +}; + +#endif // _SV_SALVD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/salwtype.hxx b/vcl/inc/vcl/salwtype.hxx new file mode 100644 index 000000000000..d8bd6c527f85 --- /dev/null +++ b/vcl/inc/vcl/salwtype.hxx @@ -0,0 +1,349 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SALWTYPE_HXX +#define _SV_SALWTYPE_HXX + +#include <i18npool/lang.h> +#include <tools/string.hxx> +#include <vcl/sv.h> + +class SalGraphics; +class SalFrame; +class SalObject; +class Window; + +class ImplFontSelectData; + +// --------------- +// - SalExtInput - +// --------------- + +// Muessen mit den Defines in cmdevt.hxx uebereinstimmen, da diese +// nicht konvertiert werden +#define SAL_EXTTEXTINPUT_ATTR_GRAYWAVELINE ((sal_uInt16)0x0100) +#define SAL_EXTTEXTINPUT_ATTR_UNDERLINE ((sal_uInt16)0x0200) +#define SAL_EXTTEXTINPUT_ATTR_BOLDUNDERLINE ((sal_uInt16)0x0400) +#define SAL_EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE ((sal_uInt16)0x0800) +#define SAL_EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE ((sal_uInt16)0x1000) +#define SAL_EXTTEXTINPUT_ATTR_HIGHLIGHT ((sal_uInt16)0x2000) +#define SAL_EXTTEXTINPUT_ATTR_REDTEXT ((sal_uInt16)0x4000) +#define SAL_EXTTEXTINPUT_ATTR_HALFTONETEXT ((sal_uInt16)0x8000) + +#define SAL_EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001) +#define SAL_EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002) + +// ------------ +// - SalEvent - +// ------------ + +#define SALEVENT_MOUSEMOVE ((sal_uInt16)1) +#define SALEVENT_MOUSELEAVE ((sal_uInt16)2) +#define SALEVENT_MOUSEBUTTONDOWN ((sal_uInt16)3) +#define SALEVENT_MOUSEBUTTONUP ((sal_uInt16)4) +#define SALEVENT_KEYINPUT ((sal_uInt16)5) +#define SALEVENT_KEYUP ((sal_uInt16)6) +#define SALEVENT_KEYMODCHANGE ((sal_uInt16)7) +#define SALEVENT_PAINT ((sal_uInt16)8) +#define SALEVENT_RESIZE ((sal_uInt16)9) +#define SALEVENT_GETFOCUS ((sal_uInt16)10) +#define SALEVENT_LOSEFOCUS ((sal_uInt16)11) +#define SALEVENT_CLOSE ((sal_uInt16)12) +#define SALEVENT_SHUTDOWN ((sal_uInt16)13) +#define SALEVENT_SETTINGSCHANGED ((sal_uInt16)14) +#define SALEVENT_VOLUMECHANGED ((sal_uInt16)15) +#define SALEVENT_PRINTERCHANGED ((sal_uInt16)16) +#define SALEVENT_DISPLAYCHANGED ((sal_uInt16)17) +#define SALEVENT_FONTCHANGED ((sal_uInt16)18) +#define SALEVENT_DATETIMECHANGED ((sal_uInt16)19) +#define SALEVENT_KEYBOARDCHANGED ((sal_uInt16)20) +#define SALEVENT_WHEELMOUSE ((sal_uInt16)21) +#define SALEVENT_USEREVENT ((sal_uInt16)22) +#define SALEVENT_MOUSEACTIVATE ((sal_uInt16)23) +#define SALEVENT_EXTTEXTINPUT ((sal_uInt16)24) +#define SALEVENT_ENDEXTTEXTINPUT ((sal_uInt16)25) +#define SALEVENT_EXTTEXTINPUTPOS ((sal_uInt16)26) +#define SALEVENT_INPUTCONTEXTCHANGE ((sal_uInt16)27) +#define SALEVENT_MOVE ((sal_uInt16)28) +#define SALEVENT_MOVERESIZE ((sal_uInt16)29) +#define SALEVENT_CLOSEPOPUPS ((sal_uInt16)30) +#define SALEVENT_EXTERNALKEYINPUT ((sal_uInt16)31) +#define SALEVENT_EXTERNALKEYUP ((sal_uInt16)32) +#define SALEVENT_MENUCOMMAND ((sal_uInt16)33) +#define SALEVENT_MENUHIGHLIGHT ((sal_uInt16)34) +#define SALEVENT_MENUACTIVATE ((sal_uInt16)35) +#define SALEVENT_MENUDEACTIVATE ((sal_uInt16)36) +#define SALEVENT_EXTERNALMOUSEMOVE ((sal_uInt16)37) +#define SALEVENT_EXTERNALMOUSEBUTTONDOWN ((sal_uInt16)38) +#define SALEVENT_EXTERNALMOUSEBUTTONUP ((sal_uInt16)39) +#define SALEVENT_INPUTLANGUAGECHANGE ((sal_uInt16)40) +#define SALEVENT_SHOWDIALOG ((sal_uInt16)41) +#define SALEVENT_MENUBUTTONCOMMAND ((sal_uInt16)42) +#define SALEVENT_SURROUNDINGTEXTREQUEST ((sal_uInt16)43) +#define SALEVENT_SURROUNDINGTEXTSELECTIONCHANGE ((sal_uInt16)44) +#define SALEVENT_STARTRECONVERSION ((sal_uInt16)45) +#define SALEVENT_COUNT ((sal_uInt16)45) + +// MOUSELEAVE must send, when the pointer leave the client area and +// the mouse is not captured +// MOUSEMOVE, MOUSELEAVE, MOUSEBUTTONDOWN and MOUSEBUTTONUP +// MAC: Ctrl+Button is MOUSE_RIGHT +struct SalMouseEvent +{ + sal_uLong mnTime; // Time in ms, when event is created + long mnX; // X-Position (Pixel, TopLeft-Output) + long mnY; // Y-Position (Pixel, TopLeft-Output) + sal_uInt16 mnButton; // 0-MouseMove/MouseLeave, MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE + sal_uInt16 mnCode; // SV-ModifierCode (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT) +}; + +// KEYINPUT and KEYUP +struct SalKeyEvent +{ + sal_uLong mnTime; // Time in ms, when event is created + sal_uInt16 mnCode; // SV-KeyCode (KEY_xxx | KEY_SHIFT | KEY_MOD1 | KEY_MOD2) + sal_uInt16 mnCharCode; // SV-CharCode + sal_uInt16 mnRepeat; // Repeat-Count (KeyInputs-1) +}; + +// MENUEVENT +struct SalMenuEvent +{ + sal_uInt16 mnId; // Menu item ID + void* mpMenu; // pointer to VCL menu (class Menu) + + SalMenuEvent() : mnId( 0 ), mpMenu( NULL ) {} + SalMenuEvent( sal_uInt16 i_nId, void* i_pMenu ) + : mnId( i_nId ), mpMenu( i_pMenu ) {} +}; + +// KEYMODCHANGE +struct SalKeyModEvent +{ + sal_uLong mnTime; // Time in ms, when event is created + sal_uInt16 mnCode; // SV-ModifierCode (KEY_SHIFT | KEY_MOD1 | KEY_MOD2) + sal_uInt16 mnModKeyCode; // extended Modifier (MODKEY_LEFT, MODKEY_RIGHT, MODKEY_PRESS, MODKEY_RELEASE) +}; + +// PAINT +struct SalPaintEvent +{ + long mnBoundX; // BoundRect - X + long mnBoundY; // BoundRect - Y + long mnBoundWidth; // BoundRect - Width + long mnBoundHeight; // BoundRect - Height + bool mbImmediateUpdate; // set to true to force an immediate update + + SalPaintEvent( long x, long y, long w, long h, bool bImmediate = false ) : + mnBoundX( x ), mnBoundY( y ), + mnBoundWidth( w ), mnBoundHeight( h ), + mbImmediateUpdate( bImmediate ) + {} +}; + +// USEREVENT +// pEvent == pData + +// WHEELMOUSE +#define SAL_WHEELMOUSE_EVENT_PAGESCROLL ((sal_uLong)0xFFFFFFFF) +struct SalWheelMouseEvent +{ + sal_uLong mnTime; // Time in ms, when event is created + long mnX; // X-Position (Pixel, TopLeft-Output) + long mnY; // Y-Position (Pixel, TopLeft-Output) + long mnDelta; // Anzahl Drehungen + long mnNotchDelta; // Anzahl feste Drehungen + sal_uLong mnScrollLines; // Aktuelle Anzahl zu scrollende Zeilen + sal_uInt16 mnCode; // SV-ModifierCode (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT) + sal_Bool mbHorz; // Horizontal + sal_Bool mbDeltaIsPixel; // delta value is a pixel value (on mac) + + SalWheelMouseEvent() + : mnTime( 0 ), mnX( 0 ), mnY( 0 ), mnDelta( 0 ), mnNotchDelta( 0 ), mnScrollLines( 0 ), mnCode( 0 ), mbHorz( sal_False ), mbDeltaIsPixel( sal_False ) + {} +}; + +// MOUSEACTIVATE +struct SalMouseActivateEvent +{ + long mnX; // X-Position (Pixel, TopLeft-Output) + long mnY; // Y-Position (Pixel, TopLeft-Output) +}; + +#ifdef __cplusplus + +// EXTTEXTINPUT +struct SalExtTextInputEvent +{ + sal_uLong mnTime; // Time in ms, when event is created + UniString maText; // Text + const sal_uInt16* mpTextAttr; // Text-Attribute + sal_uLong mnCursorPos; // Cursor-Position + sal_uLong mnDeltaStart; // Start-Position der letzten Aenderung + sal_uInt8 mnCursorFlags; // SAL_EXTTEXTINPUT_CURSOR_xxx + sal_Bool mbOnlyCursor; // sal_True: Nur Cursor-Position wurde geaendert +}; + +#endif // __cplusplus + +// EXTTEXTINPUTPOS +struct SalExtTextInputPosEvent +{ + long mnX; // Cursor-X-Position to upper left corner of frame + long mnY; // Cursor-Y-Position to upper left corner of frame + long mnWidth; // Cursor-Width in Pixel + long mnHeight; // Cursor-Height in Pixel + long mnExtWidth; // Width of the PreEdit area + bool mbVertical; // true if in vertical mode +}; + +#ifdef __cplusplus + +// INPUTCONTEXTCHANGE +struct SalInputContextChangeEvent +{ + LanguageType meLanguage; // Neue Sprache +}; + +#endif // __cplusplus + +#ifdef __cplusplus + +// SURROUNDINGTEXTREQUEST +struct SalSurroundingTextRequestEvent +{ + UniString maText; // Text + sal_uLong mnStart; // The beggining index of selected range + sal_uLong mnEnd; // The end index of selected range +}; + +#endif // __cplusplus + +#ifdef __cplusplus + +// SURROUNDINGTEXTSELECTIONCHANGE +struct SalSurroundingTextSelectionChangeEvent +{ + sal_uLong mnStart; // The beggining index of selected range + sal_uLong mnEnd; // The end index of selected range +}; + +#endif // __cplusplus + +// ------------------ +// - SalFrame-Types - +// ------------------ + +typedef long (*SALFRAMEPROC)( Window* pInst, SalFrame* pFrame, + sal_uInt16 nEvent, const void* pEvent ); + +// -------------------- +// - SalObject-Events - +// -------------------- + +#define SALOBJ_EVENT_GETFOCUS ((sal_uInt16)1) +#define SALOBJ_EVENT_LOSEFOCUS ((sal_uInt16)2) +#define SALOBJ_EVENT_TOTOP ((sal_uInt16)3) +#define SALOBJ_EVENT_COUNT ((sal_uInt16)4) + +// ------------------ +// - SalObject-Types - +// ------------------ + +typedef long (*SALOBJECTPROC)( void* pInst, SalObject* pObject, + sal_uInt16 nEvent, const void* pEvent ); + +// ----------------- +// - SalFrameState - +// ----------------- + +// Must be the same as in syswin.hxx +#define SAL_FRAMESTATE_MASK_X ((sal_uLong)0x00000001) +#define SAL_FRAMESTATE_MASK_Y ((sal_uLong)0x00000002) +#define SAL_FRAMESTATE_MASK_WIDTH ((sal_uLong)0x00000004) +#define SAL_FRAMESTATE_MASK_HEIGHT ((sal_uLong)0x00000008) +#define SAL_FRAMESTATE_MASK_MAXIMIZED_X ((sal_uLong)0x00000100) +#define SAL_FRAMESTATE_MASK_MAXIMIZED_Y ((sal_uLong)0x00000200) +#define SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH ((sal_uLong)0x00000400) +#define SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT ((sal_uLong)0x00000800) +#define SAL_FRAMESTATE_MASK_STATE ((sal_uLong)0x00000010) + +#define SAL_FRAMESTATE_NORMAL ((sal_uLong)0x00000001) +#define SAL_FRAMESTATE_MINIMIZED ((sal_uLong)0x00000002) +#define SAL_FRAMESTATE_MAXIMIZED ((sal_uLong)0x00000004) +#define SAL_FRAMESTATE_ROLLUP ((sal_uLong)0x00000008) +#define SAL_FRAMESTATE_MAXIMIZED_HORZ ((sal_uLong)0x00000010) +#define SAL_FRAMESTATE_MAXIMIZED_VERT ((sal_uLong)0x00000020) +#define SAL_FRAMESTATE_SYSTEMMASK ((sal_uLong)0x0000FFFF) + +struct SalFrameState +{ + sal_uLong mnMask; + long mnX; + long mnY; + long mnWidth; + long mnHeight; + long mnMaximizedX; + long mnMaximizedY; + long mnMaximizedWidth; + long mnMaximizedHeight; + sal_uLong mnState; +}; + +// ------------------- +// - SalInputContext - +// ------------------- + +// Muessen mit den Defines in inputctx.hxx uebereinstimmen, da diese +// nicht konvertiert werden +#define SAL_INPUTCONTEXT_TEXT ((sal_uLong)0x00000001) +#define SAL_INPUTCONTEXT_EXTTEXTINPUT ((sal_uLong)0x00000002) +#define SAL_INPUTCONTEXT_EXTTEXTINPUT_ON ((sal_uLong)0x00000004) +#define SAL_INPUTCONTEXT_EXTTEXTINPUT_OFF ((sal_uLong)0x00000008) +#define SAL_INPUTCONTEXT_CHANGELANGUAGE ((sal_uLong)0x00000010) + +#ifdef __cplusplus + +struct SalInputContext +{ + ImplFontSelectData* mpFont; + LanguageType meLanguage; + sal_uLong mnOptions; +}; + +#endif // __cplusplus + +// ------------------ +// - SalTimer-Types - +// ------------------ + +typedef void (*SALTIMERPROC)(); + +#endif // _SV_SALWTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/scrbar.hxx b/vcl/inc/vcl/scrbar.hxx new file mode 100644 index 000000000000..6e894bc2263b --- /dev/null +++ b/vcl/inc/vcl/scrbar.hxx @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SCRBAR_HXX +#define _SV_SCRBAR_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> + +class AutoTimer; + +// ------------------- +// - ScrollBar-Types - +// ------------------- + +enum ScrollType { SCROLL_DONTKNOW, SCROLL_LINEUP, SCROLL_LINEDOWN, + SCROLL_PAGEUP, SCROLL_PAGEDOWN, SCROLL_DRAG, SCROLL_SET }; + +// ------------- +// - ScrollBar - +// ------------- +struct ImplScrollBarData; + +class VCL_DLLPUBLIC ScrollBar : public Control +{ +private: + Rectangle maBtn1Rect; + Rectangle maBtn2Rect; + Rectangle maPage1Rect; + Rectangle maPage2Rect; + Rectangle maThumbRect; + ImplScrollBarData* mpData; + long mnStartPos; + long mnMouseOff; + long mnThumbPixRange; + long mnThumbPixPos; + long mnThumbPixSize; + long mnMinRange; + long mnMaxRange; + long mnThumbPos; + long mnVisibleSize; + long mnLineSize; + long mnPageSize; + long mnDelta; + sal_uInt16 mnDragDraw; + sal_uInt16 mnStateFlags; + ScrollType meScrollType; + ScrollType meDDScrollType; + sal_Bool mbCalcSize; + sal_Bool mbFullDrag; + Link maScrollHdl; + Link maEndScrollHdl; + + SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt ); + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True ); + SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); + SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); + SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True ); + SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev ); + using Window::ImplScroll; + SAL_DLLPRIVATE long ImplScroll( long nNewPos, sal_Bool bCallEndScroll ); + SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndScroll ); + SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True ); + SAL_DLLPRIVATE void ImplInvert(); + SAL_DLLPRIVATE sal_Bool ImplDrawNative( sal_uInt16 nDrawFlags ); + SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos ); + DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* ); + DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, AutoTimer* ); + +public: + ScrollBar( Window* pParent, WinBits nStyle = WB_VERT ); + ScrollBar( Window* pParent, const ResId& rResId ); + ~ScrollBar(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual void GetFocus(); + virtual void LoseFocus(); + + using Window::Scroll; + virtual void Scroll(); + virtual void EndScroll(); + + long DoScroll( long nNewPos ); + long DoScrollAction( ScrollType eScrollType ); + + void EnableDrag( sal_Bool bEnable = sal_True ) + { mbFullDrag = bEnable; } + sal_Bool IsDragEnabled() const { return mbFullDrag; } + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } + void SetThumbPos( long nThumbPos ); + long GetThumbPos() const { return mnThumbPos; } + void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; } + long GetLineSize() const { return mnLineSize; } + void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; } + long GetPageSize() const { return mnPageSize; } + void SetVisibleSize( long nNewSize ); + long GetVisibleSize() const { return mnVisibleSize; } + + long GetDelta() const { return mnDelta; } + ScrollType GetType() const { return meScrollType; } + + void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } + const Link& GetScrollHdl() const { return maScrollHdl; } + void SetEndScrollHdl( const Link& rLink ) { maEndScrollHdl = rLink; } + const Link& GetEndScrollHdl() const { return maEndScrollHdl; } +}; + +// ---------------- +// - ScrollBarBox - +// ---------------- + +class VCL_DLLPUBLIC ScrollBarBox : public Window +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + +public: + ScrollBarBox( Window* pParent, WinBits nStyle = 0 ); + ScrollBarBox( Window* pParent, const ResId& rResId ); + + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); +}; + +#endif // _SV_SCRBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/seleng.hxx b/vcl/inc/vcl/seleng.hxx new file mode 100644 index 000000000000..8466df46a901 --- /dev/null +++ b/vcl/inc/vcl/seleng.hxx @@ -0,0 +1,259 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SELENG_HXX +#define _SV_SELENG_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/event.hxx> + +class Window; +class CommandEvent; + +// Timerticks +#define SELENG_DRAGDROP_TIMEOUT 400 +#define SELENG_AUTOREPEAT_INTERVAL 50 +#define SELENG_AUTOREPEAT_INTERVAL_MIN 25 +#define SELENG_AUTOREPEAT_INTERVAL_MAX 300 + +enum SelectionMode { NO_SELECTION, SINGLE_SELECTION, RANGE_SELECTION, MULTIPLE_SELECTION }; + +// --------------- +// - FunctionSet - +// --------------- + +class VCL_DLLPUBLIC FunctionSet +{ +public: + virtual void BeginDrag() = 0; + + virtual void CreateAnchor() = 0; // Anker-Pos := Cursor-Pos + virtual void DestroyAnchor() = 0; + + // Cursor neu setzen, dabei die beim Anker beginnende + // Selektion der neuen Cursor-Position anpassen. sal_True == Ok + virtual sal_Bool SetCursorAtPoint( const Point& rPointPixel, + sal_Bool bDontSelectAtCursor = sal_False ) = 0; + + virtual sal_Bool IsSelectionAtPoint( const Point& rPointPixel ) = 0; + virtual void DeselectAtPoint( const Point& rPointPixel ) = 0; + // Anker loeschen & alles deselektieren + virtual void DeselectAll() = 0; +}; + +// ------------------- +// - SelectionEngine - +// ------------------- + +#define SELENG_DRG_ENAB 0x0001 +#define SELENG_IN_SEL 0x0002 +#define SELENG_IN_ADD 0x0004 +#define SELENG_ADD_ALW 0x0008 +#define SELENG_IN_DRG 0x0010 +#define SELENG_HAS_ANCH 0x0020 +#define SELENG_CMDEVT 0x0040 +#define SELENG_WAIT_UPEVT 0x0080 +#define SELENG_EXPANDONMOVE 0x0100 + +class VCL_DLLPUBLIC SelectionEngine +{ +private: + FunctionSet* pFunctionSet; + Window* pWin; + Rectangle aArea; + Timer aWTimer; // erzeugt kuenstliche Mouse-Moves + MouseEvent aLastMove; + SelectionMode eSelMode; + sal_uLong nUpdateInterval; + // Stufigkeit fuer Mausbewegungen waehrend einer Selektion + sal_uInt16 nMouseSensitivity; + sal_uInt16 nLockedMods; + sal_uInt16 nFlags; + DECL_DLLPRIVATE_LINK( ImpWatchDog, Timer * ); + + inline sal_Bool ShouldDeselect( sal_Bool bModifierKey1 ) const; + // determines to deselect or not when Ctrl-key is pressed on CursorPosChanging +public: + + SelectionEngine( Window* pWindow, + FunctionSet* pFunctions = NULL, + sal_uLong nAutoRepeatInterval = SELENG_AUTOREPEAT_INTERVAL ); + ~SelectionEngine(); + + // sal_True: Event wurde von Selection-Engine verarbeitet. + sal_Bool SelMouseButtonDown( const MouseEvent& rMEvt ); + sal_Bool SelMouseButtonUp( const MouseEvent& rMEvt ); + sal_Bool SelMouseMove( const MouseEvent& rMEvt ); + + // Tastatur + void CursorPosChanging( sal_Bool bShift, sal_Bool bMod1 ); + + // wird benoetigt, um bei ausserhalb des Bereichs stehender + // Maus ueber einen Timer Move-Events zu erzeugen + void SetVisibleArea( const Rectangle rNewArea ) + { aArea = rNewArea; } + const Rectangle& GetVisibleArea() const { return aArea; } + + void SetAddMode( sal_Bool); + sal_Bool IsAddMode() const; + + void AddAlways( sal_Bool bOn ); + sal_Bool IsAlwaysAdding() const; + + void EnableDrag( sal_Bool bOn ); + sal_Bool IsDragEnabled() const; + void ActivateDragMode(); + sal_Bool IsInDragMode() const; + + void SetSelectionMode( SelectionMode eMode ); + SelectionMode GetSelectionMode() const { return eSelMode; } + + void SetFunctionSet( FunctionSet* pFuncs ) + { pFunctionSet = pFuncs; } + const FunctionSet* GetFunctionSet() const { return pFunctionSet; } + + void SetMouseSensitivity( sal_uInt16 nSensitivity ) + { nMouseSensitivity = nSensitivity; } + sal_uInt16 GetMouseSensitivity() const + { return nMouseSensitivity; } + + const Point& GetMousePosPixel() const + { return aLastMove.GetPosPixel(); } + const MouseEvent& GetMouseEvent() const { return aLastMove; } + + void SetWindow( Window*); + Window* GetWindow() const { return pWin; } + + void LockModifiers( sal_uInt16 nModifiers ) + { nLockedMods = nModifiers; } + sal_uInt16 GetLockedModifiers() const { return nLockedMods; } + + sal_Bool IsInSelection() const; + void Reset(); + + void Command( const CommandEvent& rCEvt ); + + sal_Bool HasAnchor() const; + void SetAnchor( sal_Bool bAnchor ); + + void SetUpdateInterval( sal_uLong nInterval ); + + // wird im Ctor eingeschaltet + void ExpandSelectionOnMouseMove( sal_Bool bExpand = sal_True ) + { + if( bExpand ) + nFlags |= SELENG_EXPANDONMOVE; + else + nFlags &= ~SELENG_EXPANDONMOVE; + } +}; + +inline sal_Bool SelectionEngine::IsDragEnabled() const +{ + if ( nFlags & SELENG_DRG_ENAB ) + return sal_True; + else + return sal_False; +} + +inline sal_Bool SelectionEngine::IsAddMode() const +{ + if ( nFlags & (SELENG_IN_ADD | SELENG_ADD_ALW) ) + return sal_True; + else + return sal_False; +} + +inline void SelectionEngine::SetAddMode( sal_Bool bNewMode ) +{ + if ( bNewMode ) + nFlags |= SELENG_IN_ADD; + else + nFlags &= (~SELENG_IN_ADD); +} + +inline void SelectionEngine::EnableDrag( sal_Bool bOn ) +{ + if ( bOn ) + nFlags |= SELENG_DRG_ENAB; + else + nFlags &= (~SELENG_DRG_ENAB); +} + +inline void SelectionEngine::AddAlways( sal_Bool bOn ) +{ + if( bOn ) + nFlags |= SELENG_ADD_ALW; + else + nFlags &= (~SELENG_ADD_ALW); +} + +inline sal_Bool SelectionEngine::IsAlwaysAdding() const +{ + if ( nFlags & SELENG_ADD_ALW ) + return sal_True; + else + return sal_False; +} + +inline sal_Bool SelectionEngine::IsInDragMode() const +{ + if ( nFlags & SELENG_IN_DRG ) + return sal_True; + else + return sal_False; +} + +inline sal_Bool SelectionEngine::IsInSelection() const +{ + if ( nFlags & SELENG_IN_SEL ) + return sal_True; + else + return sal_False; +} + +inline sal_Bool SelectionEngine::HasAnchor() const +{ + if ( nFlags & SELENG_HAS_ANCH ) + return sal_True; + else + return sal_False; +} + +inline void SelectionEngine::SetAnchor( sal_Bool bAnchor ) +{ + if ( bAnchor ) + nFlags |= SELENG_HAS_ANCH; + else + nFlags &= (~SELENG_HAS_ANCH); +} + +#endif // _SV_SELENG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx new file mode 100644 index 000000000000..c35815506b98 --- /dev/null +++ b/vcl/inc/vcl/settings.hxx @@ -0,0 +1,1263 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SETTINGS_HXX +#define _SV_SETTINGS_HXX + +#include "vcl/sv.h" +#include "vcl/dllapi.h" +#include "tools/color.hxx" +#include "vcl/font.hxx" +#include "vcl/accel.hxx" +#include "vcl/wall.hxx" +#include "com/sun/star/lang/Locale.hpp" +#include <unotools/syslocale.hxx> + +class CollatorWrapper; +class LocaleDataWrapper; + +namespace vcl { + class I18nHelper; +} + +// ------------------- +// - ImplMachineData - +// ------------------- + +class ImplMachineData +{ + friend class MachineSettings; + + ImplMachineData(); + ImplMachineData( const ImplMachineData& rData ); + +private: + sal_uLong mnRefCount; + sal_uLong mnOptions; + sal_uLong mnScreenOptions; + sal_uLong mnPrintOptions; + long mnScreenRasterFontDeviation; +}; + +// ------------------- +// - MachineSettings - +// ------------------- + +class VCL_DLLPUBLIC MachineSettings +{ + void CopyData(); + +private: + ImplMachineData* mpData; + +public: + MachineSettings(); + MachineSettings( const MachineSettings& rSet ); + ~MachineSettings(); + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + void SetScreenOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnScreenOptions = nOptions; } + sal_uLong GetScreenOptions() const + { return mpData->mnScreenOptions; } + void SetPrintOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnPrintOptions = nOptions; } + sal_uLong GetPrintOptions() const + { return mpData->mnPrintOptions; } + + void SetScreenRasterFontDeviation( long nDeviation ) + { CopyData(); mpData->mnScreenRasterFontDeviation = nDeviation; } + long GetScreenRasterFontDeviation() const + { return mpData->mnScreenRasterFontDeviation; } + + const MachineSettings& operator =( const MachineSettings& rSet ); + + sal_Bool operator ==( const MachineSettings& rSet ) const; + sal_Bool operator !=( const MachineSettings& rSet ) const + { return !(*this == rSet); } +}; + +// ----------------- +// - ImplMouseData - +// ----------------- + +class ImplMouseData +{ + friend class MouseSettings; + + ImplMouseData(); + ImplMouseData( const ImplMouseData& rData ); + +private: + sal_uLong mnRefCount; + sal_uLong mnOptions; + sal_uLong mnDoubleClkTime; + long mnDoubleClkWidth; + long mnDoubleClkHeight; + long mnStartDragWidth; + long mnStartDragHeight; + sal_uInt16 mnStartDragCode; + sal_uInt16 mnDragMoveCode; + sal_uInt16 mnDragCopyCode; + sal_uInt16 mnDragLinkCode; + sal_uInt16 mnContextMenuCode; + sal_uInt16 mnContextMenuClicks; + sal_Bool mbContextMenuDown; + sal_uLong mnScrollRepeat; + sal_uLong mnButtonStartRepeat; + sal_uLong mnButtonRepeat; + sal_uLong mnActionDelay; + sal_uLong mnMenuDelay; + sal_uLong mnFollow; + sal_uInt16 mnMiddleButtonAction; + sal_uInt16 mnWheelBehavior; + sal_Bool mbAlign1; +}; + +// ----------------- +// - MouseSettings - +// ----------------- + +#define MOUSE_OPTION_AUTOFOCUS ((sal_uLong)0x00000001) +#define MOUSE_OPTION_AUTOCENTERPOS ((sal_uLong)0x00000002) +#define MOUSE_OPTION_AUTODEFBTNPOS ((sal_uLong)0x00000004) + +#define MOUSE_FOLLOW_MENU ((sal_uLong)0x00000001) +#define MOUSE_FOLLOW_DDLIST ((sal_uLong)0x00000002) + +#define MOUSE_MIDDLE_NOTHING ((sal_uInt16)0) +#define MOUSE_MIDDLE_AUTOSCROLL ((sal_uInt16)1) +#define MOUSE_MIDDLE_PASTESELECTION ((sal_uInt16)2) + +#define MOUSE_WHEEL_DISABLE ((sal_uInt16)0) +#define MOUSE_WHEEL_FOCUS_ONLY ((sal_uInt16)1) +#define MOUSE_WHEEL_ALWAYS ((sal_uInt16)2) + +class VCL_DLLPUBLIC MouseSettings +{ + void CopyData(); + +private: + ImplMouseData* mpData; + +public: + MouseSettings(); + MouseSettings( const MouseSettings& rSet ); + ~MouseSettings(); + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + + void SetDoubleClickTime( sal_uLong nDoubleClkTime ) + { CopyData(); mpData->mnDoubleClkTime = nDoubleClkTime; } + sal_uLong GetDoubleClickTime() const + { return mpData->mnDoubleClkTime; } + void SetDoubleClickWidth( long nDoubleClkWidth ) + { CopyData(); mpData->mnDoubleClkWidth = nDoubleClkWidth; } + long GetDoubleClickWidth() const + { return mpData->mnDoubleClkWidth; } + void SetDoubleClickHeight( long nDoubleClkHeight ) + { CopyData(); mpData->mnDoubleClkHeight = nDoubleClkHeight; } + long GetDoubleClickHeight() const + { return mpData->mnDoubleClkHeight; } + + void SetStartDragWidth( long nDragWidth ) + { CopyData(); mpData->mnStartDragWidth = nDragWidth; } + long GetStartDragWidth() const + { return mpData->mnStartDragWidth; } + void SetStartDragHeight( long nDragHeight ) + { CopyData(); mpData->mnStartDragHeight = nDragHeight; } + long GetStartDragHeight() const + { return mpData->mnStartDragHeight; } + void SetStartDragCode( sal_uInt16 nCode ) + { CopyData(); mpData->mnStartDragCode = nCode; } + sal_uInt16 GetStartDragCode() const + { return mpData->mnStartDragCode; } + void SetDragMoveCode( sal_uInt16 nCode ) + { CopyData(); mpData->mnDragMoveCode = nCode; } + sal_uInt16 GetDragMoveCode() const + { return mpData->mnDragMoveCode; } + void SetDragCopyCode( sal_uInt16 nCode ) + { CopyData(); mpData->mnDragCopyCode = nCode; } + sal_uInt16 GetDragCopyCode() const + { return mpData->mnDragCopyCode; } + void SetDragLinkCode( sal_uInt16 nCode ) + { CopyData(); mpData->mnDragLinkCode = nCode; } + sal_uInt16 GetDragLinkCode() const + { return mpData->mnDragLinkCode; } + + void SetContextMenuCode( sal_uInt16 nCode ) + { CopyData(); mpData->mnContextMenuCode = nCode; } + sal_uInt16 GetContextMenuCode() const + { return mpData->mnContextMenuCode; } + void SetContextMenuClicks( sal_uInt16 nClicks ) + { CopyData(); mpData->mnContextMenuClicks = nClicks; } + sal_uInt16 GetContextMenuClicks() const + { return mpData->mnContextMenuClicks; } + void SetContextMenuDown( sal_Bool bDown ) + { CopyData(); mpData->mbContextMenuDown = bDown; } + sal_Bool GetContextMenuDown() const + { return mpData->mbContextMenuDown; } + + void SetScrollRepeat( sal_uLong nRepeat ) + { CopyData(); mpData->mnScrollRepeat = nRepeat; } + sal_uLong GetScrollRepeat() const + { return mpData->mnScrollRepeat; } + void SetButtonStartRepeat( sal_uLong nRepeat ) + { CopyData(); mpData->mnButtonStartRepeat = nRepeat; } + sal_uLong GetButtonStartRepeat() const + { return mpData->mnButtonStartRepeat; } + void SetButtonRepeat( sal_uLong nRepeat ) + { CopyData(); mpData->mnButtonRepeat = nRepeat; } + sal_uLong GetButtonRepeat() const + { return mpData->mnButtonRepeat; } + void SetActionDelay( sal_uLong nDelay ) + { CopyData(); mpData->mnActionDelay = nDelay; } + sal_uLong GetActionDelay() const + { return mpData->mnActionDelay; } + void SetMenuDelay( sal_uLong nDelay ) + { CopyData(); mpData->mnMenuDelay = nDelay; } + sal_uLong GetMenuDelay() const + { return mpData->mnMenuDelay; } + + void SetFollow( sal_uLong nFollow ) + { CopyData(); mpData->mnFollow = nFollow; } + sal_uLong GetFollow() const + { return mpData->mnFollow; } + + void SetMiddleButtonAction( sal_uInt16 nAction ) + { CopyData(); mpData->mnMiddleButtonAction = nAction; } + sal_uInt16 GetMiddleButtonAction() const + { return mpData->mnMiddleButtonAction; } + + void SetWheelBehavior( sal_uInt16 nBehavior ) + { CopyData(); mpData->mnWheelBehavior = nBehavior; } + sal_uInt16 GetWheelBehavior() const + { return mpData->mnWheelBehavior; } + + const MouseSettings& operator =( const MouseSettings& rSet ); + + sal_Bool operator ==( const MouseSettings& rSet ) const; + sal_Bool operator !=( const MouseSettings& rSet ) const + { return !(*this == rSet); } +}; + +// -------------------- +// - ImplKeyboardData - +// -------------------- + +class ImplKeyboardData +{ + friend class KeyboardSettings; + + ImplKeyboardData(); + ImplKeyboardData( const ImplKeyboardData& rData ); + +private: + sal_uLong mnRefCount; + Accelerator maStandardAccel; + sal_uLong mnOptions; +}; + +// -------------------- +// - KeyboardSettings - +// -------------------- + +#define KEYBOARD_OPTION_QUICKCURSOR ((sal_uLong)0x00000001) + +class VCL_DLLPUBLIC KeyboardSettings +{ + void CopyData(); + +private: + ImplKeyboardData* mpData; + +public: + KeyboardSettings(); + KeyboardSettings( const KeyboardSettings& rSet ); + ~KeyboardSettings(); + + void SetStandardAccel( const Accelerator& rAccelerator ) + { CopyData(); mpData->maStandardAccel = rAccelerator; } + const Accelerator& GetStandardAccel() const + { return mpData->maStandardAccel; } + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + + const KeyboardSettings& operator =( const KeyboardSettings& rSet ); + + sal_Bool operator ==( const KeyboardSettings& rSet ) const; + sal_Bool operator !=( const KeyboardSettings& rSet ) const + { return !(*this == rSet); } +}; + +// ----------------- +// - ImplStyleData - +// ----------------- + +class ImplStyleData +{ + friend class StyleSettings; + + ImplStyleData(); + ImplStyleData( const ImplStyleData& rData ); + void SetStandardStyles(); + +private: + sal_uLong mnRefCount; + + void* mpStyleData_NotUsedYet; + + Color maActiveBorderColor; + Color maActiveColor; + Color maActiveColor2; + Color maActiveTextColor; + Color maButtonTextColor; + Color maButtonRolloverTextColor; + Color maCheckedColor; + Color maDarkShadowColor; + Color maDeactiveBorderColor; + Color maDeactiveColor; + Color maDeactiveColor2; + Color maDeactiveTextColor; + Color maDialogColor; + Color maDialogTextColor; + Color maDisableColor; + Color maFaceColor; + Color maFieldColor; + Color maFieldTextColor; + Color maFieldRolloverTextColor; + Color maFontColor; + Color maGroupTextColor; + Color maHelpColor; + Color maHelpTextColor; + Color maHighlightColor; + Color maHighlightLinkColor; + Color maHighlightTextColor; + Color maInfoTextColor; + Color maLabelTextColor; + Color maLightBorderColor; + Color maLightColor; + Color maLinkColor; + Color maMenuBarColor; + Color maMenuBorderColor; + Color maMenuColor; + Color maMenuHighlightColor; + Color maMenuHighlightTextColor; + Color maMenuTextColor; + Color maMenuBarTextColor; + Color maMonoColor; + Color maRadioCheckTextColor; + Color maShadowColor; + Color maVisitedLinkColor; + Color maWindowColor; + Color maWindowTextColor; + Color maWorkspaceColor; + Color maActiveTabColor; + Color maInactiveTabColor; + Font maAppFont; + Font maHelpFont; + Font maTitleFont; + Font maFloatTitleFont; + Font maMenuFont; + Font maToolFont; + Font maLabelFont; + Font maInfoFont; + Font maRadioCheckFont; + Font maPushButtonFont; + Font maFieldFont; + Font maIconFont; + Font maGroupFont; + long mnBorderSize; + long mnTitleHeight; + long mnFloatTitleHeight; + long mnTearOffTitleHeight; + long mnScrollBarSize; + long mnSplitSize; + long mnSpinSize; + long mnCursorSize; + long mnMenuBarHeight; + long mnIconHorzSpace; + long mnIconVertSpace; + long mnAntialiasedMin; + sal_uLong mnCursorBlinkTime; + sal_uLong mnDragFullOptions; + sal_uLong mnAnimationOptions; + sal_uLong mnSelectionOptions; + sal_uLong mnLogoDisplayTime; + sal_uLong mnDisplayOptions; + sal_uLong mnToolbarIconSize; + sal_uLong mnUseFlatMenues; + sal_uLong mnOptions; + sal_uInt16 mnScreenZoom; + sal_uInt16 mnScreenFontZoom; + sal_uInt16 mnHighContrast; + sal_uInt16 mnUseSystemUIFonts; + sal_uInt16 mnAutoMnemonic; + sal_uInt16 mnUseImagesInMenus; + sal_uLong mnUseFlatBorders; + sal_Bool mbPreferredUseImagesInMenus; + long mnMinThumbSize; + sal_uLong mnSymbolsStyle; + sal_uLong mnPreferredSymbolsStyle; + sal_uInt16 mnSkipDisabledInMenus; + sal_Bool mnAcceleratorsInContextMenus; + Wallpaper maWorkspaceGradient; + const void* mpFontOptions; +}; + +#define DEFAULT_WORKSPACE_GRADIENT_START_COLOR Color( 0xa3, 0xae, 0xb8 ) +#define DEFAULT_WORKSPACE_GRADIENT_END_COLOR Color( 0x73, 0x7e, 0x88 ) + +// ----------------- +// - StyleSettings - +// ----------------- + +#define STYLE_OPTION_MONO ((sal_uLong)0x00000001) +#define STYLE_OPTION_COLOR ((sal_uLong)0x00000002) +#define STYLE_OPTION_FLAT ((sal_uLong)0x00000004) +#define STYLE_OPTION_GREAT ((sal_uLong)0x00000008) +#define STYLE_OPTION_HIGHLIGHT ((sal_uLong)0x00000010) +#define STYLE_OPTION_ADVANCEDUSER ((sal_uLong)0x00000020) +#define STYLE_OPTION_SCROLLARROW ((sal_uLong)0x00000040) +#define STYLE_OPTION_SPINARROW ((sal_uLong)0x00000080) +#define STYLE_OPTION_SPINUPDOWN ((sal_uLong)0x00000100) +#define STYLE_OPTION_NOMNEMONICS ((sal_uLong)0x00000200) +#define STYLE_OPTION_HIDEDISABLED ((sal_uLong)0x00100000) + +#define DRAGFULL_OPTION_WINDOWMOVE ((sal_uLong)0x00000001) +#define DRAGFULL_OPTION_WINDOWSIZE ((sal_uLong)0x00000002) +#define DRAGFULL_OPTION_OBJECTMOVE ((sal_uLong)0x00000004) +#define DRAGFULL_OPTION_OBJECTSIZE ((sal_uLong)0x00000008) +#define DRAGFULL_OPTION_DOCKING ((sal_uLong)0x00000010) +#define DRAGFULL_OPTION_SPLIT ((sal_uLong)0x00000020) +#define DRAGFULL_OPTION_SCROLL ((sal_uLong)0x00000040) + +#define LOGO_DISPLAYTIME_NOLOGO ((sal_uLong)0) +#define LOGO_DISPLAYTIME_STARTTIME ((sal_uLong)0xFFFFFFFF) + +#define ANIMATION_OPTION_MINIMIZE ((sal_uLong)0x00000001) +#define ANIMATION_OPTION_POPUP ((sal_uLong)0x00000002) +#define ANIMATION_OPTION_DIALOG ((sal_uLong)0x00000004) +#define ANIMATION_OPTION_TREE ((sal_uLong)0x00000008) +#define ANIMATION_OPTION_SCROLL ((sal_uLong)0x00000010) + +#define SELECTION_OPTION_WORD ((sal_uLong)0x00000001) +#define SELECTION_OPTION_FOCUS ((sal_uLong)0x00000002) +#define SELECTION_OPTION_INVERT ((sal_uLong)0x00000004) +#define SELECTION_OPTION_SHOWFIRST ((sal_uLong)0x00000008) + +#define DISPLAY_OPTION_AA_DISABLE ((sal_uLong)0x00000001) + +#define STYLE_RADIOBUTTON_MONO ((sal_uInt16)0x0001) // legacy +#define STYLE_CHECKBOX_MONO ((sal_uInt16)0x0001) // legacy + +#define STYLE_TOOLBAR_ICONSIZE_UNKNOWN ((sal_uLong)0) +#define STYLE_TOOLBAR_ICONSIZE_SMALL ((sal_uLong)1) +#define STYLE_TOOLBAR_ICONSIZE_LARGE ((sal_uLong)2) + +#define STYLE_SYMBOLS_AUTO ((sal_uLong)0) +#define STYLE_SYMBOLS_DEFAULT ((sal_uLong)1) +#define STYLE_SYMBOLS_HICONTRAST ((sal_uLong)2) +#define STYLE_SYMBOLS_INDUSTRIAL ((sal_uLong)3) +#define STYLE_SYMBOLS_CRYSTAL ((sal_uLong)4) +#define STYLE_SYMBOLS_TANGO ((sal_uLong)5) +#define STYLE_SYMBOLS_OXYGEN ((sal_uLong)6) +#define STYLE_SYMBOLS_CLASSIC ((sal_uLong)7) +#define STYLE_SYMBOLS_HUMAN ((sal_uLong)8) +#define STYLE_SYMBOLS_THEMES_MAX ((sal_uLong)9) + +#define STYLE_MENUIMAGES_OFF ((sal_uInt16)0) +#define STYLE_MENUIMAGES_ON ((sal_uInt16)1) +#define STYLE_MENUIMAGES_AUTO ((sal_uInt16)2) + +#define STYLE_CURSOR_NOBLINKTIME ((sal_uLong)0xFFFFFFFF) + +class VCL_DLLPUBLIC StyleSettings +{ + void CopyData(); + +private: + ImplStyleData* mpData; + +public: + StyleSettings(); + StyleSettings( const StyleSettings& rSet ); + ~StyleSettings(); + + void Set3DColors( const Color& rColor ); + void SetFaceColor( const Color& rColor ) + { CopyData(); mpData->maFaceColor = rColor; } + const Color& GetFaceColor() const + { return mpData->maFaceColor; } + Color GetFaceGradientColor() const; + Color GetSeparatorColor() const; + void SetCheckedColor( const Color& rColor ) + { CopyData(); mpData->maCheckedColor = rColor; } + const Color& GetCheckedColor() const + { return mpData->maCheckedColor; } + void SetLightColor( const Color& rColor ) + { CopyData(); mpData->maLightColor = rColor; } + const Color& GetLightColor() const + { return mpData->maLightColor; } + void SetLightBorderColor( const Color& rColor ) + { CopyData(); mpData->maLightBorderColor = rColor; } + const Color& GetLightBorderColor() const + { return mpData->maLightBorderColor; } + void SetShadowColor( const Color& rColor ) + { CopyData(); mpData->maShadowColor = rColor; } + const Color& GetShadowColor() const + { return mpData->maShadowColor; } + void SetDarkShadowColor( const Color& rColor ) + { CopyData(); mpData->maDarkShadowColor = rColor; } + const Color& GetDarkShadowColor() const + { return mpData->maDarkShadowColor; } + void SetButtonTextColor( const Color& rColor ) + { CopyData(); mpData->maButtonTextColor = rColor; } + const Color& GetButtonTextColor() const + { return mpData->maButtonTextColor; } + void SetButtonRolloverTextColor( const Color& rColor ) + { CopyData(); mpData->maButtonRolloverTextColor = rColor; } + const Color& GetButtonRolloverTextColor() const + { return mpData->maButtonRolloverTextColor; } + void SetRadioCheckTextColor( const Color& rColor ) + { CopyData(); mpData->maRadioCheckTextColor = rColor; } + const Color& GetRadioCheckTextColor() const + { return mpData->maRadioCheckTextColor; } + void SetGroupTextColor( const Color& rColor ) + { CopyData(); mpData->maGroupTextColor = rColor; } + const Color& GetGroupTextColor() const + { return mpData->maGroupTextColor; } + void SetLabelTextColor( const Color& rColor ) + { CopyData(); mpData->maLabelTextColor = rColor; } + const Color& GetLabelTextColor() const + { return mpData->maLabelTextColor; } + void SetInfoTextColor( const Color& rColor ) + { CopyData(); mpData->maInfoTextColor = rColor; } + const Color& GetInfoTextColor() const + { return mpData->maInfoTextColor; } + void SetWindowColor( const Color& rColor ) + { CopyData(); mpData->maWindowColor = rColor; } + const Color& GetWindowColor() const + { return mpData->maWindowColor; } + void SetWindowTextColor( const Color& rColor ) + { CopyData(); mpData->maWindowTextColor = rColor; } + const Color& GetWindowTextColor() const + { return mpData->maWindowTextColor; } + void SetDialogColor( const Color& rColor ) + { CopyData(); mpData->maDialogColor = rColor; } + const Color& GetDialogColor() const + { return mpData->maDialogColor; } + void SetDialogTextColor( const Color& rColor ) + { CopyData(); mpData->maDialogTextColor = rColor; } + const Color& GetDialogTextColor() const + { return mpData->maDialogTextColor; } + void SetWorkspaceColor( const Color& rColor ) + { CopyData(); mpData->maWorkspaceColor = rColor; } + const Color& GetWorkspaceColor() const + { return mpData->maWorkspaceColor; } + void SetFieldColor( const Color& rColor ) + { CopyData(); mpData->maFieldColor = rColor; } + const Color& GetFieldColor() const + { return mpData->maFieldColor; } + void SetFieldTextColor( const Color& rColor ) + { CopyData(); mpData->maFieldTextColor = rColor; } + const Color& GetFieldTextColor() const + { return mpData->maFieldTextColor; } + void SetFieldRolloverTextColor( const Color& rColor ) + { CopyData(); mpData->maFieldRolloverTextColor = rColor; } + const Color& GetFieldRolloverTextColor() const + { return mpData->maFieldRolloverTextColor; } + void SetActiveColor( const Color& rColor ) + { CopyData(); mpData->maActiveColor = rColor; } + const Color& GetActiveColor() const + { return mpData->maActiveColor; } + void SetActiveColor2( const Color& rColor ) + { CopyData(); mpData->maActiveColor2 = rColor; } + const Color& GetActiveColor2() const + { return mpData->maActiveColor2; } + void SetActiveTextColor( const Color& rColor ) + { CopyData(); mpData->maActiveTextColor = rColor; } + const Color& GetActiveTextColor() const + { return mpData->maActiveTextColor; } + void SetActiveBorderColor( const Color& rColor ) + { CopyData(); mpData->maActiveBorderColor = rColor; } + const Color& GetActiveBorderColor() const + { return mpData->maActiveBorderColor; } + void SetDeactiveColor( const Color& rColor ) + { CopyData(); mpData->maDeactiveColor = rColor; } + const Color& GetDeactiveColor() const + { return mpData->maDeactiveColor; } + void SetDeactiveColor2( const Color& rColor ) + { CopyData(); mpData->maDeactiveColor2 = rColor; } + const Color& GetDeactiveColor2() const + { return mpData->maDeactiveColor2; } + void SetDeactiveTextColor( const Color& rColor ) + { CopyData(); mpData->maDeactiveTextColor = rColor; } + const Color& GetDeactiveTextColor() const + { return mpData->maDeactiveTextColor; } + void SetDeactiveBorderColor( const Color& rColor ) + { CopyData(); mpData->maDeactiveBorderColor = rColor; } + const Color& GetDeactiveBorderColor() const + { return mpData->maDeactiveBorderColor; } + void SetHighlightColor( const Color& rColor ) + { CopyData(); mpData->maHighlightColor = rColor; } + const Color& GetHighlightColor() const + { return mpData->maHighlightColor; } + void SetHighlightTextColor( const Color& rColor ) + { CopyData(); mpData->maHighlightTextColor = rColor; } + const Color& GetHighlightTextColor() const + { return mpData->maHighlightTextColor; } + void SetDisableColor( const Color& rColor ) + { CopyData(); mpData->maDisableColor = rColor; } + const Color& GetDisableColor() const + { return mpData->maDisableColor; } + void SetHelpColor( const Color& rColor ) + { CopyData(); mpData->maHelpColor = rColor; } + const Color& GetHelpColor() const + { return mpData->maHelpColor; } + void SetHelpTextColor( const Color& rColor ) + { CopyData(); mpData->maHelpTextColor = rColor; } + const Color& GetHelpTextColor() const + { return mpData->maHelpTextColor; } + void SetMenuColor( const Color& rColor ) + { CopyData(); mpData->maMenuColor = rColor; } + const Color& GetMenuColor() const + { return mpData->maMenuColor; } + void SetMenuBarColor( const Color& rColor ) + { CopyData(); mpData->maMenuBarColor = rColor; } + const Color& GetMenuBarColor() const + { return mpData->maMenuBarColor; } + void SetMenuBorderColor( const Color& rColor ) + { CopyData(); mpData->maMenuBorderColor = rColor; } + const Color& GetMenuBorderColor() const + { return mpData->maMenuBorderColor; } + void SetMenuTextColor( const Color& rColor ) + { CopyData(); mpData->maMenuTextColor = rColor; } + const Color& GetMenuTextColor() const + { return mpData->maMenuTextColor; } + void SetMenuBarTextColor( const Color& rColor ) + { CopyData(); mpData->maMenuBarTextColor = rColor; } + const Color& GetMenuBarTextColor() const + { return mpData->maMenuBarTextColor; } + void SetMenuHighlightColor( const Color& rColor ) + { CopyData(); mpData->maMenuHighlightColor = rColor; } + const Color& GetMenuHighlightColor() const + { return mpData->maMenuHighlightColor; } + void SetMenuHighlightTextColor( const Color& rColor ) + { CopyData(); mpData->maMenuHighlightTextColor = rColor; } + const Color& GetMenuHighlightTextColor() const + { return mpData->maMenuHighlightTextColor; } + void SetLinkColor( const Color& rColor ) + { CopyData(); mpData->maLinkColor = rColor; } + const Color& GetLinkColor() const + { return mpData->maLinkColor; } + void SetVisitedLinkColor( const Color& rColor ) + { CopyData(); mpData->maVisitedLinkColor = rColor; } + const Color& GetVisitedLinkColor() const + { return mpData->maVisitedLinkColor; } + void SetHighlightLinkColor( const Color& rColor ) + { CopyData(); mpData->maHighlightLinkColor = rColor; } + const Color& GetHighlightLinkColor() const + { return mpData->maHighlightLinkColor; } + + void SetMonoColor( const Color& rColor ) + { CopyData(); mpData->maMonoColor = rColor; } + const Color& GetMonoColor() const + { return mpData->maMonoColor; } + + void SetActiveTabColor( const Color& rColor ) + { CopyData(); mpData->maActiveTabColor = rColor; } + const Color& GetActiveTabColor() const + { return mpData->maActiveTabColor; } + void SetInactiveTabColor( const Color& rColor ) + { CopyData(); mpData->maInactiveTabColor = rColor; } + const Color& GetInactiveTabColor() const + { return mpData->maInactiveTabColor; } + + void SetHighContrastMode( sal_Bool bHighContrast ) + { CopyData(); mpData->mnHighContrast = bHighContrast; } + sal_Bool GetHighContrastMode() const + { return (sal_Bool) mpData->mnHighContrast; } + sal_Bool IsHighContrastBlackAndWhite() const; + void SetUseSystemUIFonts( sal_Bool bUseSystemUIFonts ) + { CopyData(); mpData->mnUseSystemUIFonts = bUseSystemUIFonts; } + sal_Bool GetUseSystemUIFonts() const + { return (sal_Bool) mpData->mnUseSystemUIFonts; } + void SetUseFlatBorders( sal_Bool bUseFlatBorders ) + { CopyData(); mpData->mnUseFlatBorders = bUseFlatBorders; } + sal_Bool GetUseFlatBorders() const + { return (sal_Bool) mpData->mnUseFlatBorders; } + void SetUseFlatMenues( sal_Bool bUseFlatMenues ) + { CopyData(); mpData->mnUseFlatMenues = bUseFlatMenues; } + sal_Bool GetUseFlatMenues() const + { return (sal_Bool) mpData->mnUseFlatMenues; } + void SetUseImagesInMenus( sal_Bool bUseImagesInMenus ) + { CopyData(); mpData->mnUseImagesInMenus = bUseImagesInMenus; } + sal_Bool GetUseImagesInMenus() const; + void SetPreferredUseImagesInMenus( sal_Bool bPreferredUseImagesInMenus ) + { CopyData(); mpData->mbPreferredUseImagesInMenus = bPreferredUseImagesInMenus; } + sal_Bool GetPreferredUseImagesInMenus() const + { return mpData->mbPreferredUseImagesInMenus; } + void SetSkipDisabledInMenus( sal_Bool bSkipDisabledInMenus ) + { CopyData(); mpData->mnSkipDisabledInMenus = bSkipDisabledInMenus; } + sal_Bool GetSkipDisabledInMenus() const + { return (sal_Bool) mpData->mnSkipDisabledInMenus; } + void SetAcceleratorsInContextMenus( sal_Bool bAcceleratorsInContextMenus ) + { CopyData(); mpData->mnAcceleratorsInContextMenus = bAcceleratorsInContextMenus; } + sal_Bool GetAcceleratorsInContextMenus() const + { return mpData->mnAcceleratorsInContextMenus; } + + void SetCairoFontOptions( const void *pOptions ) + { CopyData(); mpData->mpFontOptions = pOptions; } + const void* GetCairoFontOptions() const + { return mpData->mpFontOptions; } + + void SetAppFont( const Font& rFont ) + { CopyData(); mpData->maAppFont = rFont; } + const Font& GetAppFont() const + { return mpData->maAppFont; } + void SetHelpFont( const Font& rFont ) + { CopyData(); mpData->maHelpFont = rFont; } + const Font& GetHelpFont() const + { return mpData->maHelpFont; } + void SetTitleFont( const Font& rFont ) + { CopyData(); mpData->maTitleFont = rFont; } + const Font& GetTitleFont() const + { return mpData->maTitleFont; } + void SetFloatTitleFont( const Font& rFont ) + { CopyData(); mpData->maFloatTitleFont = rFont; } + const Font& GetFloatTitleFont() const + { return mpData->maFloatTitleFont; } + void SetMenuFont( const Font& rFont ) + { CopyData(); mpData->maMenuFont = rFont; } + const Font& GetMenuFont() const + { return mpData->maMenuFont; } + void SetToolFont( const Font& rFont ) + { CopyData(); mpData->maToolFont = rFont; } + const Font& GetToolFont() const + { return mpData->maToolFont; } + void SetGroupFont( const Font& rFont ) + { CopyData(); mpData->maGroupFont = rFont; } + const Font& GetGroupFont() const + { return mpData->maGroupFont; } + void SetLabelFont( const Font& rFont ) + { CopyData(); mpData->maLabelFont = rFont; } + const Font& GetLabelFont() const + { return mpData->maLabelFont; } + void SetInfoFont( const Font& rFont ) + { CopyData(); mpData->maInfoFont = rFont; } + const Font& GetInfoFont() const + { return mpData->maInfoFont; } + void SetRadioCheckFont( const Font& rFont ) + { CopyData(); mpData->maRadioCheckFont = rFont; } + const Font& GetRadioCheckFont() const + { return mpData->maRadioCheckFont; } + void SetPushButtonFont( const Font& rFont ) + { CopyData(); mpData->maPushButtonFont = rFont; } + const Font& GetPushButtonFont() const + { return mpData->maPushButtonFont; } + void SetFieldFont( const Font& rFont ) + { CopyData(); mpData->maFieldFont = rFont; } + const Font& GetFieldFont() const + { return mpData->maFieldFont; } + void SetIconFont( const Font& rFont ) + { CopyData(); mpData->maIconFont = rFont; } + const Font& GetIconFont() const + { return mpData->maIconFont; } + + void SetBorderSize( long nSize ) + { CopyData(); mpData->mnBorderSize = nSize; } + long GetBorderSize() const + { return mpData->mnBorderSize; } + void SetTitleHeight( long nSize ) + { CopyData(); mpData->mnTitleHeight = nSize; } + long GetTitleHeight() const + { return mpData->mnTitleHeight; } + void SetFloatTitleHeight( long nSize ) + { CopyData(); mpData->mnFloatTitleHeight = nSize; } + long GetFloatTitleHeight() const + { return mpData->mnFloatTitleHeight; } + void SetTearOffTitleHeight( long nSize ) + { CopyData(); mpData->mnTearOffTitleHeight = nSize; } + long GetTearOffTitleHeight() const + { return mpData->mnTearOffTitleHeight; } + void SetMenuBarHeight( long nSize ) + { CopyData(); mpData->mnMenuBarHeight = nSize; } + long GetMenuBarHeight() const + { return mpData->mnMenuBarHeight; } + void SetScrollBarSize( long nSize ) + { CopyData(); mpData->mnScrollBarSize = nSize; } + long GetScrollBarSize() const + { return mpData->mnScrollBarSize; } + void SetMinThumbSize( long nSize ) + { CopyData(); mpData->mnMinThumbSize = nSize; } + long GetMinThumbSize() const + { return mpData->mnMinThumbSize; } + void SetSpinSize( long nSize ) + { CopyData(); mpData->mnSpinSize = nSize; } + long GetSpinSize() const + { return mpData->mnSpinSize; } + void SetSplitSize( long nSize ) + { CopyData(); mpData->mnSplitSize = nSize; } + long GetSplitSize() const + { return mpData->mnSplitSize; } + + void SetIconHorzSpace( long nSpace ) + { CopyData(); mpData->mnIconHorzSpace = nSpace; } + long GetIconHorzSpace() const + { return mpData->mnIconHorzSpace; } + void SetIconVertSpace( long nSpace ) + { CopyData(); mpData->mnIconVertSpace = nSpace; } + long GetIconVertSpace() const + { return mpData->mnIconVertSpace; } + + void SetCursorSize( long nSize ) + { CopyData(); mpData->mnCursorSize = nSize; } + long GetCursorSize() const + { return mpData->mnCursorSize; } + void SetCursorBlinkTime( long nBlinkTime ) + { CopyData(); mpData->mnCursorBlinkTime = nBlinkTime; } + long GetCursorBlinkTime() const + { return (long) mpData->mnCursorBlinkTime; } + + void SetScreenZoom( sal_uInt16 nPercent ) + { CopyData(); mpData->mnScreenZoom = nPercent; } + sal_uInt16 GetScreenZoom() const + { return mpData->mnScreenZoom; } + void SetScreenFontZoom( sal_uInt16 nPercent ) + { CopyData(); mpData->mnScreenFontZoom = nPercent; } + sal_uInt16 GetScreenFontZoom() const + { return mpData->mnScreenFontZoom; } + + void SetLogoDisplayTime( sal_uLong nDisplayTime ) + { CopyData(); mpData->mnLogoDisplayTime = nDisplayTime; } + sal_uLong GetLogoDisplayTime() const + { return mpData->mnLogoDisplayTime; } + + void SetDragFullOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnDragFullOptions = nOptions; } + sal_uLong GetDragFullOptions() const + { return mpData->mnDragFullOptions; } + + void SetAnimationOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnAnimationOptions = nOptions; } + sal_uLong GetAnimationOptions() const + { return mpData->mnAnimationOptions; } + + void SetSelectionOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnSelectionOptions = nOptions; } + sal_uLong GetSelectionOptions() const + { return mpData->mnSelectionOptions; } + + void SetDisplayOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnDisplayOptions = nOptions; } + sal_uLong GetDisplayOptions() const + { return mpData->mnDisplayOptions; } + void SetAntialiasingMinPixelHeight( long nMinPixel ) + { CopyData(); mpData->mnAntialiasedMin = nMinPixel; } + sal_uLong GetAntialiasingMinPixelHeight() const + { return mpData->mnAntialiasedMin; } + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + void SetAutoMnemonic( sal_Bool bAutoMnemonic ) + { CopyData(); mpData->mnAutoMnemonic = (sal_uInt16)bAutoMnemonic; } + sal_Bool GetAutoMnemonic() const + { return mpData->mnAutoMnemonic ? sal_True : sal_False; } + + void SetFontColor( const Color& rColor ) + { CopyData(); mpData->maFontColor = rColor; } + const Color& GetFontColor() const + { return mpData->maFontColor; } + + void SetToolbarIconSize( sal_uLong nSize ) + { CopyData(); mpData->mnToolbarIconSize = nSize; } + sal_uLong GetToolbarIconSize() const + { return mpData->mnToolbarIconSize; } + + void SetSymbolsStyle( sal_uLong nStyle ) + { CopyData(); mpData->mnSymbolsStyle = nStyle; } + sal_uLong GetSymbolsStyle() const + { return mpData->mnSymbolsStyle; } + + void SetPreferredSymbolsStyle( sal_uLong nStyle ) + { CopyData(); mpData->mnPreferredSymbolsStyle = nStyle; } + void SetPreferredSymbolsStyleName( const ::rtl::OUString &rName ); + sal_uLong GetPreferredSymbolsStyle() const + { return mpData->mnPreferredSymbolsStyle; } + // check whether the symbols style is supported (icons are installed) + bool CheckSymbolStyle( sal_uLong nStyle ) const; + sal_uLong GetAutoSymbolsStyle() const; + + sal_uLong GetCurrentSymbolsStyle() const; + + void SetSymbolsStyleName( const ::rtl::OUString &rName ) + { return SetSymbolsStyle( ImplNameToSymbolsStyle( rName ) ); } + ::rtl::OUString GetSymbolsStyleName() const + { return ImplSymbolsStyleToName( GetSymbolsStyle() ); } + ::rtl::OUString GetCurrentSymbolsStyleName() const + { return ImplSymbolsStyleToName( GetCurrentSymbolsStyle() ); } + + const Wallpaper& GetWorkspaceGradient() const + { return mpData->maWorkspaceGradient; } + void SetWorkspaceGradient( const Wallpaper& rWall ) + { CopyData(); mpData->maWorkspaceGradient = rWall; } + + void SetStandardStyles(); + + const StyleSettings& operator =( const StyleSettings& rSet ); + + sal_Bool operator ==( const StyleSettings& rSet ) const; + sal_Bool operator !=( const StyleSettings& rSet ) const + { return !(*this == rSet); } + +protected: + ::rtl::OUString ImplSymbolsStyleToName( sal_uLong nStyle ) const; + sal_uLong ImplNameToSymbolsStyle( const ::rtl::OUString &rName ) const; +}; + +// ---------------- +// - ImplMiscData - +// ---------------- + +class ImplMiscData +{ + friend class MiscSettings; + + ImplMiscData(); + ImplMiscData( const ImplMiscData& rData ); + +private: + sal_uLong mnRefCount; + sal_uInt16 mnEnableATT; + sal_Bool mbEnableLocalizedDecimalSep; + sal_uInt16 mnDisablePrinting; +}; + +// ---------------- +// - MiscSettings - +// ---------------- + +class VCL_DLLPUBLIC MiscSettings +{ + void CopyData(); + +private: + ImplMiscData* mpData; + +public: + MiscSettings(); + MiscSettings( const MiscSettings& rSet ); + ~MiscSettings(); + + void SetEnableATToolSupport( sal_Bool bEnable ); + sal_Bool GetEnableATToolSupport() const; + void SetDisablePrinting( sal_Bool bEnable ); + sal_Bool GetDisablePrinting() const; + void SetEnableLocalizedDecimalSep( sal_Bool bEnable ); + sal_Bool GetEnableLocalizedDecimalSep() const; + const MiscSettings& operator =( const MiscSettings& rSet ); + + sal_Bool operator ==( const MiscSettings& rSet ) const; + sal_Bool operator !=( const MiscSettings& rSet ) const + { return !(*this == rSet); } +}; + +// ------------------------ +// - ImplNotificationData - +// ------------------------ + +class ImplNotificationData +{ + friend class NotificationSettings; + + ImplNotificationData(); + ImplNotificationData( const ImplNotificationData& rData ); + +private: + sal_uLong mnRefCount; + sal_uLong mnOptions; +}; + +// ------------------------ +// - NotificationSettings - +// ------------------------ + +class VCL_DLLPUBLIC NotificationSettings +{ + void CopyData(); + +private: + ImplNotificationData* mpData; + +public: + NotificationSettings(); + NotificationSettings( const NotificationSettings& rSet ); + ~NotificationSettings(); + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + + const NotificationSettings& operator =( const NotificationSettings& rSet ); + + sal_Bool operator ==( const NotificationSettings& rSet ) const; + sal_Bool operator !=( const NotificationSettings& rSet ) const + { return !(*this == rSet); } +}; + +// ---------------- +// - ImplHelpData - +// ---------------- + +class ImplHelpData +{ + friend class HelpSettings; + + ImplHelpData(); + ImplHelpData( const ImplHelpData& rData ); + +private: + sal_uLong mnRefCount; + sal_uLong mnOptions; + sal_uLong mnTipDelay; + sal_uLong mnTipTimeout; + sal_uLong mnBalloonDelay; +}; + +// ---------------- +// - HelpSettings - +// ---------------- + +#define HELP_OPTION_QUICK ((sal_uLong)0x00000001) +#define HELP_OPTION_ACTIVE ((sal_uLong)0x00000002) + +class VCL_DLLPUBLIC HelpSettings +{ + void CopyData(); + +private: + ImplHelpData* mpData; + +public: + HelpSettings(); + HelpSettings( const HelpSettings& rSet ); + ~HelpSettings(); + + void SetOptions( sal_uLong nOptions ) + { CopyData(); mpData->mnOptions = nOptions; } + sal_uLong GetOptions() const + { return mpData->mnOptions; } + void SetTipDelay( sal_uLong nTipDelay ) + { CopyData(); mpData->mnTipDelay = nTipDelay; } + sal_uLong GetTipDelay() const + { return mpData->mnTipDelay; } + void SetTipTimeout( sal_uLong nTipTimeout ) + { CopyData(); mpData->mnTipTimeout = nTipTimeout; } + sal_uLong GetTipTimeout() const + { return mpData->mnTipTimeout; } + void SetBalloonDelay( sal_uLong nBalloonDelay ) + { CopyData(); mpData->mnBalloonDelay = nBalloonDelay; } + sal_uLong GetBalloonDelay() const + { return mpData->mnBalloonDelay; } + + const HelpSettings& operator =( const HelpSettings& rSet ); + + sal_Bool operator ==( const HelpSettings& rSet ) const; + sal_Bool operator !=( const HelpSettings& rSet ) const + { return !(*this == rSet); } +}; + +// ----------------------- +// - ImplAllSettingsData - +// ----------------------- +class LocaleConfigurationListener; +class ImplAllSettingsData +{ + friend class AllSettings; + + ImplAllSettingsData(); + ImplAllSettingsData( const ImplAllSettingsData& rData ); + ~ImplAllSettingsData(); + +private: + sal_uLong mnRefCount; + MachineSettings maMachineSettings; + MouseSettings maMouseSettings; + KeyboardSettings maKeyboardSettings; + StyleSettings maStyleSettings; + MiscSettings maMiscSettings; + NotificationSettings maNotificationSettings; + HelpSettings maHelpSettings; + ::com::sun::star::lang::Locale maLocale; + sal_uLong mnSystemUpdate; + sal_uLong mnWindowUpdate; + ::com::sun::star::lang::Locale maUILocale; + LanguageType meLanguage; + LanguageType meUILanguage; + LocaleDataWrapper* mpLocaleDataWrapper; + LocaleDataWrapper* mpUILocaleDataWrapper; + vcl::I18nHelper* mpI18nHelper; + vcl::I18nHelper* mpUII18nHelper; + LocaleConfigurationListener* mpLocaleCfgListener; + SvtSysLocale maSysLocale; +}; + +// --------------- +// - AllSettings - +// --------------- + +#define SETTINGS_MACHINE ((sal_uLong)0x00000001) +#define SETTINGS_MOUSE ((sal_uLong)0x00000002) +#define SETTINGS_KEYBOARD ((sal_uLong)0x00000004) +#define SETTINGS_STYLE ((sal_uLong)0x00000008) +#define SETTINGS_MISC ((sal_uLong)0x00000010) +#define SETTINGS_SOUND ((sal_uLong)0x00000020) +#define SETTINGS_NOTIFICATION ((sal_uLong)0x00000040) +#define SETTINGS_HELP ((sal_uLong)0x00000080) +#define SETTINGS_INTERNATIONAL ((sal_uLong)0x00000100) /* was for class International, has no effect anymore */ +#define SETTINGS_LOCALE ((sal_uLong)0x00000200) +#define SETTINGS_UILOCALE ((sal_uLong)0x00000400) +#define SETTINGS_ALLSETTINGS (SETTINGS_MACHINE |\ + SETTINGS_MOUSE | SETTINGS_KEYBOARD |\ + SETTINGS_STYLE | SETTINGS_MISC |\ + SETTINGS_SOUND | SETTINGS_NOTIFICATION |\ + SETTINGS_HELP |\ + SETTINGS_LOCALE | SETTINGS_UILOCALE ) +#define SETTINGS_IN_UPDATE_SETTINGS ((sal_uLong)0x00000800) // this flag indicates that the data changed event was created + // in Windows::UpdateSettings probably because of a global + // settings changed + +class VCL_DLLPUBLIC AllSettings +{ + void CopyData(); + +private: + ImplAllSettingsData* mpData; + +public: + AllSettings(); + AllSettings( const AllSettings& rSet ); + ~AllSettings(); + + void SetMachineSettings( const MachineSettings& rSet ) + { CopyData(); mpData->maMachineSettings = rSet; } + const MachineSettings& GetMachineSettings() const + { return mpData->maMachineSettings; } + + void SetMouseSettings( const MouseSettings& rSet ) + { CopyData(); mpData->maMouseSettings = rSet; } + const MouseSettings& GetMouseSettings() const + { return mpData->maMouseSettings; } + + void SetKeyboardSettings( const KeyboardSettings& rSet ) + { CopyData(); mpData->maKeyboardSettings = rSet; } + const KeyboardSettings& GetKeyboardSettings() const + { return mpData->maKeyboardSettings; } + + void SetStyleSettings( const StyleSettings& rSet ) + { CopyData(); mpData->maStyleSettings = rSet; } + const StyleSettings& GetStyleSettings() const + { return mpData->maStyleSettings; } + + void SetMiscSettings( const MiscSettings& rSet ) + { CopyData(); mpData->maMiscSettings = rSet; } + const MiscSettings& GetMiscSettings() const + { return mpData->maMiscSettings; } + + void SetNotificationSettings( const NotificationSettings& rSet ) + { CopyData(); mpData->maNotificationSettings = rSet; } + const NotificationSettings& GetNotificationSettings() const + { return mpData->maNotificationSettings; } + + void SetHelpSettings( const HelpSettings& rSet ) + { CopyData(); mpData->maHelpSettings = rSet; } + const HelpSettings& GetHelpSettings() const + { return mpData->maHelpSettings; } + + void SetLocale( const ::com::sun::star::lang::Locale& rLocale ); + const ::com::sun::star::lang::Locale& GetLocale() const; + void SetUILocale( const ::com::sun::star::lang::Locale& rLocale ); + const ::com::sun::star::lang::Locale& GetUILocale() const; + void SetLanguage( LanguageType eLang ); + LanguageType GetLanguage() const; + void SetUILanguage( LanguageType eLang ); + LanguageType GetUILanguage() const; + sal_Bool GetLayoutRTL() const; // returns sal_True if UI language requires right-to-left UI + const LocaleDataWrapper& GetLocaleDataWrapper() const; + const LocaleDataWrapper& GetUILocaleDataWrapper() const; + const vcl::I18nHelper& GetLocaleI18nHelper() const; + const vcl::I18nHelper& GetUILocaleI18nHelper() const; +/* + const CollatorWrapper& GetCollatorWrapper() const; + const CollatorWrapper& GetUICollatorWrapper() const; + sal_Unicode GetMnemonicMatchChar( sal_Unicode c ) const; + String GetMatchString( const String& rStr ) const; + String GetUIMatchString( const String& rStr ) const; + int MatchString( const String& rStr1, xub_StrLen nPos1, xub_StrLen nCount1, + const String& rStr2, xub_StrLen nPos2, xub_StrLen nCount2 ) const; + int MatchUIString( const String& rStr1, xub_StrLen nPos1, xub_StrLen nCount1, + const String& rStr2, xub_StrLen nPos2, xub_StrLen nCount2 ) const; +*/ + + void SetSystemUpdate( sal_uLong nUpdate ) + { CopyData(); mpData->mnSystemUpdate = nUpdate; } + sal_uLong GetSystemUpdate() const + { return mpData->mnSystemUpdate; } + void SetWindowUpdate( sal_uLong nUpdate ) + { CopyData(); mpData->mnWindowUpdate = nUpdate; } + sal_uLong GetWindowUpdate() const + { return mpData->mnWindowUpdate; } + + sal_uLong Update( sal_uLong nFlags, const AllSettings& rSettings ); + sal_uLong GetChangeFlags( const AllSettings& rSettings ) const; + + const AllSettings& operator =( const AllSettings& rSet ); + + sal_Bool operator ==( const AllSettings& rSet ) const; + sal_Bool operator !=( const AllSettings& rSet ) const + { return !(*this == rSet); } + static void LocaleSettingsChanged( sal_uInt32 nHint ); + SvtSysLocale& GetSysLocale() { return mpData->maSysLocale; } +}; + +#endif // _SV_SETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/slider.hxx b/vcl/inc/vcl/slider.hxx new file mode 100644 index 000000000000..15f049555386 --- /dev/null +++ b/vcl/inc/vcl/slider.hxx @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SLIDER_HXX +#define _SV_SLIDER_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +// for enum ScrollType +#include <vcl/scrbar.hxx> + +// ---------- +// - Slider - +// ---------- + +class VCL_DLLPUBLIC Slider : public Control +{ +private: + Rectangle maChannel1Rect; + Rectangle maChannel2Rect; + Rectangle maThumbRect; + long mnStartPos; + long mnMouseOff; + long mnThumbPixOffset; + long mnThumbPixRange; + long mnThumbPixPos; + long mnChannelPixOffset; + long mnChannelPixRange; + long mnChannelPixTop; + long mnChannelPixBottom; + long mnMinRange; + long mnMaxRange; + long mnThumbPos; + long mnLineSize; + long mnPageSize; + long mnDelta; + sal_uInt16 mnDragDraw; + sal_uInt16 mnStateFlags; + ScrollType meScrollType; + sal_Bool mbCalcSize; + sal_Bool mbFullDrag; + Link maSlideHdl; + Link maEndSlideHdl; + + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True ); + SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); + SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); + SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True ); + SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags ); + SAL_DLLPRIVATE sal_Bool ImplIsPageUp( const Point& rPos ); + SAL_DLLPRIVATE sal_Bool ImplIsPageDown( const Point& rPos ); + SAL_DLLPRIVATE long ImplSlide( long nNewPos, sal_Bool bCallEndSlide ); + SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndSlide ); + SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True ); + SAL_DLLPRIVATE long ImplDoSlide( long nNewPos ); + SAL_DLLPRIVATE long ImplDoSlideAction( ScrollType eScrollType ); + +public: + Slider( Window* pParent, WinBits nStyle = WB_HORZ ); + Slider( Window* pParent, const ResId& rResId ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Slide(); + virtual void EndSlide(); + + void EnableDrag( sal_Bool bEnable = sal_True ) + { mbFullDrag = bEnable; } + sal_Bool IsDragEnabled() const { return mbFullDrag; } + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } + void SetThumbPos( long nThumbPos ); + long GetThumbPos() const { return mnThumbPos; } + void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; } + long GetLineSize() const { return mnLineSize; } + void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; } + long GetPageSize() const { return mnPageSize; } + + long GetDelta() const { return mnDelta; } + + Size CalcWindowSizePixel(); + + void SetSlideHdl( const Link& rLink ) { maSlideHdl = rLink; } + const Link& GetSlideHdl() const { return maSlideHdl; } + void SetEndSlideHdl( const Link& rLink ) { maEndSlideHdl = rLink; } + const Link& GetEndSlideHdl() const { return maEndSlideHdl; } +}; + +#endif // _SV_SLIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/sndstyle.hxx b/vcl/inc/vcl/sndstyle.hxx new file mode 100644 index 000000000000..170a51173726 --- /dev/null +++ b/vcl/inc/vcl/sndstyle.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SNDSTYLE_HXX +#define _SV_SNDSTYLE_HXX + +#include <vcl/sv.h> + +// --------------- +// - Sound-Types - +// --------------- + +typedef sal_uInt16 SoundType; +#define SOUND_DEFAULT ((SoundType)0) +#define SOUND_INFO ((SoundType)1) +#define SOUND_WARNING ((SoundType)2) +#define SOUND_ERROR ((SoundType)3) +#define SOUND_QUERY ((SoundType)4) + +#define SOUND_DISABLE ((SoundType)5) + +#endif // _SV_SNDSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/solarmutex.hxx b/vcl/inc/vcl/solarmutex.hxx new file mode 100644 index 000000000000..96119d295b9d --- /dev/null +++ b/vcl/inc/vcl/solarmutex.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _VCL_SOLARMUTEX_HXX_ +#define _VCL_SOLARMUTEX_HXX_ + +#include <osl/mutex.hxx> +#include <vcl/dllapi.h> + +namespace vcl +{ + +/** Implementation of the SolarMutex interface. + */ +class VCL_DLLPUBLIC SolarMutexObject : public osl::SolarMutex +{ +public: + //static SolarMutex& SAL_CALL getGlobalMutex(); + + /** Creates mutex + */ + SolarMutexObject(); + + /** Implicitly destroys mutex + */ + virtual ~SolarMutexObject(); + + /** Blocks if Mutex is already in use + */ + virtual void SAL_CALL acquire(); + + /** Tries to get the mutex without blocking. + @return True if mutex could be obtained, otherwise False + */ + virtual sal_Bool SAL_CALL tryToAcquire(); + + /** Releases the mutex. + */ + virtual void SAL_CALL release(); + +protected: + oslMutex m_solarMutex; + +private: + /* Disable copy/assignment + */ + SolarMutexObject( const SolarMutexObject& ); + SolarMutexObject& SAL_CALL operator=( const SolarMutexObject& ); +}; + +} + +#endif // _VCL_SOLARMUTEX_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/sound.hxx b/vcl/inc/vcl/sound.hxx new file mode 100644 index 000000000000..1a32a27154ce --- /dev/null +++ b/vcl/inc/vcl/sound.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SOUND_HXX +#define _SV_SOUND_HXX + +#include <vcl/dllapi.h> +#include <vcl/sndstyle.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <tools/time.hxx> + +class Window; +class Timer; + +// --------- +// - Sound - +// --------- + +class VCL_DLLPUBLIC Sound +{ +public: + static void Beep( SoundType eType = SOUND_DEFAULT, Window* pWindow = NULL ); +}; + +#endif // _SV_SOUND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/spin.h b/vcl/inc/vcl/spin.h new file mode 100644 index 000000000000..f7b69cbf2a16 --- /dev/null +++ b/vcl/inc/vcl/spin.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SPIN_H +#define _SV_SPIN_H + +#include <vcl/sv.h> + +class Rectangle; +class OutputDevice; + +// ----------------------------------------------------------------------- + +#define SPIN_DELAY 280 +#define SPIN_SPEED 60 + +// ----------------------------------------------------------------------- + +void ImplDrawSpinButton( OutputDevice* pOutDev, + const Rectangle& rUpperRect, + const Rectangle& rLowerRect, + sal_Bool bUpperIn, sal_Bool bLowerIn, + sal_Bool bUpperEnabled = sal_True, + sal_Bool bLowerEnabled = sal_True, + sal_Bool bHorz = sal_False, sal_Bool bMirrorHorz = sal_False ); + +#endif // _SV_SPIN_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/spin.hxx b/vcl/inc/vcl/spin.hxx new file mode 100644 index 000000000000..02141bccd448 --- /dev/null +++ b/vcl/inc/vcl/spin.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SPIN_HXX +#define _SV_SPIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/timer.hxx> + +// -------------- +// - SpinButton - +// -------------- + +class VCL_DLLPUBLIC SpinButton : public Control +{ +private: + AutoTimer maRepeatTimer; + Rectangle maUpperRect; + Rectangle maLowerRect; + Rectangle maFocusRect; + sal_Bool mbRepeat : 1; + sal_Bool mbUpperIn : 1; + sal_Bool mbLowerIn : 1; + sal_Bool mbInitialUp : 1; + sal_Bool mbInitialDown : 1; + sal_Bool mbHorz : 1; + sal_Bool mbUpperIsFocused : 1; + Link maUpHdlLink; + Link maDownHdlLink; + long mnMinRange; + long mnMaxRange; + long mnValue; + long mnValueStep; + + SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt ); + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* ); + +public: + SpinButton( Window* pParent, WinBits nStyle = 0 ); + SpinButton( Window* pParent, const ResId& rResId ); + ~SpinButton(); + + virtual void Up(); + virtual void Down(); + + virtual void Resize(); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void GetFocus(); + virtual void LoseFocus(); + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } + void SetValue( long nValue ); + long GetValue() const { return mnValue; } + void SetValueStep( long nNewStep ) { mnValueStep = nNewStep; } + long GetValueStep() const { return mnValueStep; } + virtual long PreNotify( NotifyEvent& rNEvt ); + + void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; } + const Link& GetUpHdl() const { return maUpHdlLink; } + void SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; } + const Link& GetDownHdl() const { return maDownHdlLink; } + +private: + // moves the focus to the upper or lower rect. Return sal_True if the focus rect actually changed. + SAL_DLLPRIVATE sal_Bool ImplMoveFocus( sal_Bool _bUpper ); + SAL_DLLPRIVATE void ImplCalcFocusRect( sal_Bool _bUpper ); + + SAL_DLLPRIVATE inline sal_Bool ImplIsUpperEnabled( ) const + { + return mnValue + mnValueStep <= mnMaxRange; + } + SAL_DLLPRIVATE inline sal_Bool ImplIsLowerEnabled( ) const + { + return mnValue >= mnMinRange + mnValueStep; + } +}; + +#endif // _SV_SPIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/spinfld.hxx b/vcl/inc/vcl/spinfld.hxx new file mode 100644 index 000000000000..becfe4be426f --- /dev/null +++ b/vcl/inc/vcl/spinfld.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SPINFLD_HXX +#define _SV_SPINFLD_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/edit.hxx> +#include <vcl/timer.hxx> + +// ------------- +// - SpinField - +// ------------- + +class VCL_DLLPUBLIC SpinField : public Edit +{ +protected: + Edit* mpEdit; + AutoTimer maRepeatTimer; + Rectangle maUpperRect; + Rectangle maLowerRect; + Rectangle maDropDownRect; // noch nicht angebunden... + Link maUpHdlLink; + Link maDownHdlLink; + Link maFirstHdlLink; + Link maLastHdlLink; + sal_Bool mbRepeat:1, + mbSpin:1, + mbInitialUp:1, + mbInitialDown:1, + mbNoSelect:1, + mbUpperIn:1, + mbLowerIn:1, + mbInDropDown:1; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + +private: + DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* ); + SAL_DLLPRIVATE void ImplInitSpinFieldData(); + SAL_DLLPRIVATE void ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rectangle& rDDArea, Rectangle& rSpinUpArea, Rectangle& rSpinDownArea ); + +protected: + SpinField( WindowType nTyp ); + + virtual long Notify( NotifyEvent& rNEvt ); + virtual void Command( const CommandEvent& rCEvt ); + + void EndDropDown(); + + virtual void FillLayoutData() const; + Rectangle * ImplFindPartRect( const Point& rPt ); +public: + SpinField( Window* pParent, WinBits nWinStyle = 0 ); + SpinField( Window* pParent, const ResId& rResId ); + ~SpinField(); + + virtual sal_Bool ShowDropDown( sal_Bool bShow ); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; } + const Link& GetUpHdl() const { return maUpHdlLink; } + void SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; } + const Link& GetDownHdl() const { return maDownHdlLink; } + void SetFirstHdl( const Link& rLink ) { maFirstHdlLink = rLink; } + const Link& GetFirstHdl() const { return maFirstHdlLink; } + void SetLastHdl( const Link& rLink ) { maLastHdlLink = rLink; } + const Link& GetLastHdl() const { return maLastHdlLink; } + + virtual Size CalcMinimumSize() const; + virtual Size GetOptimalSize(WindowSizeType eType) const; + virtual Size CalcSize( sal_uInt16 nChars ) const; +}; + +#endif // _SV_SPINFLD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/split.hxx b/vcl/inc/vcl/split.hxx new file mode 100644 index 000000000000..66371c6da1a2 --- /dev/null +++ b/vcl/inc/vcl/split.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SPLIT_HXX +#define _SV_SPLIT_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +#define SPLITTER_DEFAULTSTEPSIZE 0xFFFF + +// ------------ +// - Splitter - +// ------------ + +class VCL_DLLPUBLIC Splitter : public Window +{ +private: + Window* mpRefWin; + long mnSplitPos; + long mnLastSplitPos; + long mnStartSplitPos; + Point maDragPos; + Rectangle maDragRect; + sal_Bool mbHorzSplit; + sal_Bool mbDragFull; + sal_Bool mbKbdSplitting; + long mbInKeyEvent; + long mnKeyboardStepSize; + Link maStartSplitHdl; + Link maSplitHdl; + Link maEndSplitHdl; + + SAL_DLLPRIVATE void ImplInitSplitterData(); + SAL_DLLPRIVATE void ImplDrawSplitter(); + SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos ); + SAL_DLLPRIVATE void ImplStartKbdSplitting(); + SAL_DLLPRIVATE void ImplKbdTracking( KeyCode aKeyCode ); + SAL_DLLPRIVATE sal_Bool ImplSplitterActive(); + SAL_DLLPRIVATE Splitter* ImplFindSibling(); + SAL_DLLPRIVATE void ImplRestoreSplitter(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE Splitter (const Splitter &); + SAL_DLLPRIVATE Splitter& operator= (const Splitter &); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nWinStyle ); + +public: + Splitter( Window* pParent, WinBits nStyle = WB_VSCROLL ); + Splitter( Window* pParent, const ResId& rResId ); + ~Splitter(); + + virtual void StartSplit(); + virtual void EndSplit(); + virtual void Split(); + virtual void Splitting( Point& rSplitPos ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + + virtual long Notify( NotifyEvent& rNEvt ); + + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rPaintRect ); + + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void StartDrag(); + + void SetDragRectPixel( const Rectangle& rDragRect, + Window* pRefWin = NULL ); + const Rectangle& GetDragRectPixel() const { return maDragRect; } + Window* GetDragWindow() const { return mpRefWin; } + + virtual void SetSplitPosPixel( long nPos ); + long GetSplitPosPixel() const { return mnSplitPos; } + + void SetLastSplitPosPixel( long nNewPos ); + long GetLastSplitPosPixel() const { return mnLastSplitPos; } + + sal_Bool IsHorizontal() const { return mbHorzSplit; } + + // set the stepsize of the splitter for cursor movement + // the default is 10% of the reference window's width/height + void SetKeyboardStepSize( long nStepSize ); + long GetKeyboardStepSize() const; + + void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; } + const Link& GetStartSplitHdl() const { return maStartSplitHdl; } + void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; } + void SetEndSplitHdl( const Link& rLink ) { maEndSplitHdl = rLink; } + const Link& GetEndSplitHdl() const { return maEndSplitHdl; } + const Link& GetSplitHdl() const { return maSplitHdl; } +}; + +#endif // _SV_SPLIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/splitwin.hxx b/vcl/inc/vcl/splitwin.hxx new file mode 100644 index 000000000000..ce1e74958f48 --- /dev/null +++ b/vcl/inc/vcl/splitwin.hxx @@ -0,0 +1,283 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SPLITWIN_HXX +#define _SV_SPLITWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/dockwin.hxx> + +class Wallpaper; +struct ImplSplitSet; + +// ----------------------- +// - SplitWindowItemBits - +// ----------------------- + +typedef sal_uInt16 SplitWindowItemBits; + +// ------------------------------- +// - Bits fuer SplitWindow-Items - +// ------------------------------- + +#define SWIB_FIXED ((SplitWindowItemBits)0x0001) +#define SWIB_RELATIVESIZE ((SplitWindowItemBits)0x0002) +#define SWIB_PERCENTSIZE ((SplitWindowItemBits)0x0004) +#define SWIB_COLSET ((SplitWindowItemBits)0x0008) +#define SWIB_INVISIBLE ((SplitWindowItemBits)0x0010) + +// --------------------- +// - SplitWindow-Types - +// --------------------- + +#define SPLITWINDOW_APPEND ((sal_uInt16)0xFFFF) +#define SPLITWINDOW_ITEM_NOTFOUND ((sal_uInt16)0xFFFF) + +// --------------- +// - SplitWindow - +// --------------- + +class VCL_DLLPUBLIC SplitWindow : public DockingWindow +{ +private: + ImplSplitSet* mpMainSet; + ImplSplitSet* mpBaseSet; + ImplSplitSet* mpSplitSet; + long* mpLastSizes; + Rectangle maDragRect; + long mnDX; + long mnDY; + long mnLeftBorder; + long mnTopBorder; + long mnRightBorder; + long mnBottomBorder; + long mnMaxSize; + long mnMouseOff; + long mnMStartPos; + long mnMSplitPos; + WinBits mnWinStyle; + WindowAlign meAlign; + sal_uInt16 mnSplitTest; + sal_uInt16 mnSplitPos; + sal_uInt16 mnMouseModifier; + sal_Bool mbDragFull:1, + mbHorz:1, + mbBottomRight:1, + mbCalc:1, + mbRecalc:1, + mbInvalidate:1, + mbSizeable:1, + mbBorder:1, + mbAutoHide:1, + mbFadeIn:1, + mbFadeOut:1, + mbAutoHideIn:1, + mbAutoHideDown:1, + mbFadeInDown:1, + mbFadeOutDown:1, + mbAutoHidePressed:1, + mbFadeInPressed:1, + mbFadeOutPressed:1, + mbFadeNoButtonMode:1, + mbNoAlign:1; + Link maStartSplitHdl; + Link maSplitHdl; + Link maSplitResizeHdl; + Link maAutoHideHdl; + Link maFadeInHdl; + Link maFadeOutHdl; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplCalcLayout(); + SAL_DLLPRIVATE void ImplUpdate(); + SAL_DLLPRIVATE void ImplUpdateSet( ImplSplitSet* pSet ); + SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta ); + SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos ); + SAL_DLLPRIVATE void ImplGetButtonRect( Rectangle& rRect, long nEx, sal_Bool bTest ) const; + SAL_DLLPRIVATE void ImplGetAutoHideRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const; + SAL_DLLPRIVATE void ImplGetFadeInRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const; + SAL_DLLPRIVATE void ImplGetFadeOutRect( Rectangle& rRect, sal_Bool bTest = sal_False ) const; + SAL_DLLPRIVATE void ImplDrawButtonRect( const Rectangle& rRect, long nSize ); + SAL_DLLPRIVATE void ImplDrawAutoHide( sal_Bool bInPaint ); + SAL_DLLPRIVATE void ImplDrawFadeIn( sal_Bool bInPaint ); + SAL_DLLPRIVATE void ImplDrawFadeOut( sal_Bool bInPaint ); + SAL_DLLPRIVATE void ImplNewAlign(); + SAL_DLLPRIVATE void ImplDrawGrip( const Rectangle& rRect, sal_Bool bHorz, sal_Bool bLeft ); + SAL_DLLPRIVATE void ImplDrawFadeArrow( const Point& rPt, sal_Bool bHorz, sal_Bool bLeft ); + SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt ); + + static SAL_DLLPRIVATE void ImplDrawBorder( SplitWindow* pWin ); + static SAL_DLLPRIVATE void ImplDrawBorderLine( SplitWindow* pWin ); + static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, sal_Bool bHide, + sal_Bool bRows, sal_Bool bDown = sal_True ); + static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, ImplSplitSet* pSet ); + static SAL_DLLPRIVATE void ImplDrawBack( SplitWindow* pWindow, const Rectangle& rRect, + const Wallpaper* pWall, const Bitmap* pBitmap ); + static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos, + long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos, + sal_Bool bRows, sal_Bool bDown = sal_True ); + static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( SplitWindow* pWindow, const Point& rPos, + long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos ); + static SAL_DLLPRIVATE void ImplDrawSplitTracking( SplitWindow* pThis, const Point& rPos ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE SplitWindow (const SplitWindow &); + SAL_DLLPRIVATE SplitWindow & operator= (const SplitWindow &); +public: + SplitWindow( Window* pParent, WinBits nStyle = 0 ); + SplitWindow( Window* pParent, const ResId& rResId ); + ~SplitWindow(); + + virtual void StartSplit(); + virtual void Split(); + virtual void SplitResize(); + virtual void AutoHide(); + virtual void FadeIn(); + virtual void FadeOut(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Move(); + virtual void Resize(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + void InsertItem( sal_uInt16 nId, Window* pWindow, long nSize, + sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0, + SplitWindowItemBits nBits = 0 ); + void InsertItem( sal_uInt16 nId, long nSize, + sal_uInt16 nPos = SPLITWINDOW_APPEND, sal_uInt16 nSetId = 0, + SplitWindowItemBits nBits = 0 ); + void MoveItem( sal_uInt16 nId, sal_uInt16 nNewPos, sal_uInt16 nNewSetId = 0 ); + void RemoveItem( sal_uInt16 nId, sal_Bool bHide = sal_True ); + void Clear(); + + void SetBaseSet( sal_uInt16 nSetId = 0 ); + sal_uInt16 GetBaseSet() const; + + void SetSplitSize( sal_uInt16 nSetId, long nSplitSize, + sal_Bool bWithChilds = sal_False ); + long GetSplitSize( sal_uInt16 nSetId ) const; + void SetItemBackground( sal_uInt16 nSetId ); + void SetItemBackground( sal_uInt16 nSetId, const Wallpaper& rWallpaper ); + Wallpaper GetItemBackground( sal_uInt16 nSetId ) const; + sal_Bool IsItemBackground( sal_uInt16 nSetId ) const; + void SetItemBitmap( sal_uInt16 nSetId, const Bitmap& rBitmap ); + Bitmap GetItemBitmap( sal_uInt16 nSetId ) const; + + void SplitItem( sal_uInt16 nId, long nNewSize, + sal_Bool bPropSmall = sal_False, + sal_Bool bPropGreat = sal_False ); + void SetItemSize( sal_uInt16 nId, long nNewSize ); + long GetItemSize( sal_uInt16 nId ) const; + /** Set a range that limits the (variable part of the) size with an + upper and a lower bound (both are valid values themselves.) + @param nId + Id of the item for which the size limits are set. + @param aRange + Values of -1 define missing bounds, thus setting a range (-1,-1) + (the default) removes the size limitiation. + */ + void SetItemSizeRange (sal_uInt16 nId, const Range aRange); + /** Return the current size limits for the specified item. + */ + Range GetItemSizeRange (sal_uInt16 nId) const; + long GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const; + void SetItemBits( sal_uInt16 nId, SplitWindowItemBits nNewBits ); + SplitWindowItemBits GetItemBits( sal_uInt16 nId ) const; + Window* GetItemWindow( sal_uInt16 nId ) const; + sal_uInt16 GetSet( sal_uInt16 nId ) const; + sal_Bool GetSet( sal_uInt16 nId, sal_uInt16& rSetId, sal_uInt16& rPos ) const; + sal_uInt16 GetItemId( Window* pWindow ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const; + sal_uInt16 GetItemId( sal_uInt16 nPos, sal_uInt16 nSetId = 0 ) const; + sal_uInt16 GetItemCount( sal_uInt16 nSetId = 0 ) const; + sal_Bool IsItemValid( sal_uInt16 nId ) const; + + void SetNoAlign( sal_Bool bNoAlign ); + sal_Bool IsNoAlign() const { return mbNoAlign; } + void SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP ); + WindowAlign GetAlign() const { return meAlign; } + sal_Bool IsHorizontal() const { return mbHorz; } + + sal_Bool IsSplitting() const { return IsTracking(); } + + void SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; } + long GetMaxSizePixel() const { return mnMaxSize; } + + static Size CalcWindowSizePixel( const Size& rSize, + WindowAlign eAlign, + WinBits nWinStyle, + sal_Bool bExtra = sal_False ); + Size CalcWindowSizePixel( const Size& rSize ) + { return CalcWindowSizePixel( rSize, meAlign, mnWinStyle, (mbAutoHide || mbFadeOut) ); } + + Size CalcLayoutSizePixel( const Size& aNewSize ); + + void ShowAutoHideButton( sal_Bool bShow = sal_True ); + sal_Bool IsAutoHideButtonVisible() const { return mbAutoHide; } + void ShowFadeInHideButton( sal_Bool bShow = sal_True ); + void ShowFadeInButton( sal_Bool bShow = sal_True ) { ShowFadeInHideButton( bShow ); } + sal_Bool IsFadeInButtonVisible() const { return mbFadeIn; } + void ShowFadeOutButton( sal_Bool bShow = sal_True ); + sal_Bool IsFadeOutButtonVisible() const { return mbFadeOut; } + long GetFadeInSize() const; + sal_Bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode; } + + void SetAutoHideState( sal_Bool bAutoHide ); + sal_Bool GetAutoHideState() const { return mbAutoHideIn; } + + Rectangle GetAutoHideRect() const; + Rectangle GetFadeInRect() const; + Rectangle GetFadeOutRect() const; + + void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; } + const Link& GetStartSplitHdl() const { return maStartSplitHdl; } + void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; } + const Link& GetSplitHdl() const { return maSplitHdl; } + void SetSplitResizeHdl( const Link& rLink ) { maSplitResizeHdl = rLink; } + const Link& GetSplitResizeHdl() const { return maSplitResizeHdl; } + void SetAutoHideHdl( const Link& rLink ) { maAutoHideHdl = rLink; } + const Link& GetAutoHideHdl() const { return maAutoHideHdl; } + void SetFadeInHdl( const Link& rLink ) { maFadeInHdl = rLink; } + const Link& GetFadeInHdl() const { return maFadeInHdl; } + void SetFadeOutHdl( const Link& rLink ) { maFadeOutHdl = rLink; } + const Link& GetFadeOutHdl() const { return maFadeOutHdl; } +}; + +#endif // _SV_SPLITWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/status.hxx b/vcl/inc/vcl/status.hxx new file mode 100644 index 000000000000..d039ddf8f203 --- /dev/null +++ b/vcl/inc/vcl/status.hxx @@ -0,0 +1,229 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_STATUS_HXX +#define _SV_STATUS_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <vector> + +struct ImplStatusItem; +typedef ::std::vector< ImplStatusItem* > ImplStatusItemList; + +// -------------------- +// - Progress-Ausgabe - +// -------------------- + +void VCL_DLLPUBLIC DrawProgress( Window* pWindow, const Point& rPos, + long nOffset, long nPrgsWidth, long nPrgsHeight, + sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount, + const Rectangle& rFramePosSize + ); + +// --------------------- +// - StatusBarItemBits - +// --------------------- + +typedef sal_uInt16 StatusBarItemBits; + +// ---------------------------- +// - Bits fuer StatusBarItems - +// ---------------------------- + +#define SIB_LEFT ((StatusBarItemBits)0x0001) +#define SIB_CENTER ((StatusBarItemBits)0x0002) +#define SIB_RIGHT ((StatusBarItemBits)0x0004) +#define SIB_IN ((StatusBarItemBits)0x0008) +#define SIB_OUT ((StatusBarItemBits)0x0010) +#define SIB_FLAT ((StatusBarItemBits)0x0020) +#define SIB_AUTOSIZE ((StatusBarItemBits)0x0040) +#define SIB_USERDRAW ((StatusBarItemBits)0x0080) + +// ------------------- +// - StatusBar-Types - +// ------------------- + +#define STATUSBAR_APPEND ((sal_uInt16)0xFFFF) +#define STATUSBAR_ITEM_NOTFOUND ((sal_uInt16)0xFFFF) +#define STATUSBAR_OFFSET ((long)5) + +// ------------- +// - StatusBar - +// ------------- + +class VCL_DLLPUBLIC StatusBar : public Window +{ + class ImplData; +private: + ImplStatusItemList* mpItemList; + ImplData* mpImplData; + XubString maPrgsTxt; + Point maPrgsTxtPos; + Rectangle maPrgsFrameRect; + long mnPrgsSize; + long mnItemsWidth; + long mnDX; + long mnDY; + long mnCalcHeight; + long mnTextY; + long mnItemY; + sal_uInt16 mnCurItemId; + sal_uInt16 mnPercent; + sal_uInt16 mnPercentCount; + sal_Bool mbVisibleItems; + sal_Bool mbFormat; + sal_Bool mbProgressMode; + sal_Bool mbInUserDraw; + sal_Bool mbBottomBorder; + Link maClickHdl; + Link maDoubleClickHdl; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplFormat(); + SAL_DLLPRIVATE sal_Bool ImplIsItemUpdate(); + using OutputDevice::ImplDrawText; + SAL_DLLPRIVATE void ImplDrawText( sal_Bool bOffScreen, long nOldTextWidth ); + SAL_DLLPRIVATE void ImplDrawItem( sal_Bool bOffScreen, sal_uInt16 nPos, sal_Bool bDrawText, sal_Bool bDrawFrame ); + SAL_DLLPRIVATE void ImplDrawProgress( sal_Bool bPaint, + sal_uInt16 nOldPerc, sal_uInt16 nNewPerc ); + SAL_DLLPRIVATE void ImplCalcProgressRect(); + SAL_DLLPRIVATE Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const; + SAL_DLLPRIVATE void ImplCalcBorder(); + +public: + StatusBar( Window* pParent, + WinBits nWinStyle = WB_BORDER | WB_RIGHT ); + StatusBar( Window* pParent, const ResId& rResId ); + ~StatusBar(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Move(); + virtual void Resize(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Click(); + virtual void DoubleClick(); + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + + void InsertItem( sal_uInt16 nItemId, sal_uLong nWidth, + StatusBarItemBits nBits = SIB_CENTER | SIB_IN, + long nOffset = STATUSBAR_OFFSET, + sal_uInt16 nPos = STATUSBAR_APPEND ); + void RemoveItem( sal_uInt16 nItemId ); + + void ShowItem( sal_uInt16 nItemId ); + void HideItem( sal_uInt16 nItemId ); + sal_Bool IsItemVisible( sal_uInt16 nItemId ) const; + + void ShowItems(); + void HideItems(); + sal_Bool AreItemsVisible() const { return mbVisibleItems; } + + void CopyItems( const StatusBar& rStatusBar ); + void Clear(); + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + Rectangle GetItemRect( sal_uInt16 nItemId ) const; + Point GetItemTextPos( sal_uInt16 nItemId ) const; + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + + sal_uLong GetItemWidth( sal_uInt16 nItemId ) const; + StatusBarItemBits GetItemBits( sal_uInt16 nItemId ) const; + long GetItemOffset( sal_uInt16 nItemId ) const; + + void SetItemText( sal_uInt16 nItemId, const XubString& rText ); + const XubString& GetItemText( sal_uInt16 nItemId ) const; + + void SetItemData( sal_uInt16 nItemId, void* pNewData ); + void* GetItemData( sal_uInt16 nItemId ) const; + + void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand ); + const XubString& GetItemCommand( sal_uInt16 nItemId ); + + void SetHelpText( sal_uInt16 nItemId, const XubString& rText ); + const XubString& GetHelpText( sal_uInt16 nItemId ) const; + + using Window::SetQuickHelpText; + void SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText ); + using Window::GetQuickHelpText; + const XubString& GetQuickHelpText( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ); + rtl::OString GetHelpId( sal_uInt16 nItemId ) const; + + void SetBottomBorder( sal_Bool bBottomBorder = sal_True ); + sal_Bool IsBottomBorder() const { return mbBottomBorder; } + + void SetTopBorder( sal_Bool bTopBorder = sal_True ); + sal_Bool IsTopBorder() const; + + void StartProgressMode( const XubString& rText ); + void SetProgressValue( sal_uInt16 nPercent ); + void EndProgressMode(); + sal_Bool IsProgressMode() const { return mbProgressMode; } + void ResetProgressMode(); + + void SetText( const XubString& rText ); + + void SetHelpText( const XubString& rText ) + { Window::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return Window::GetHelpText(); } + + void SetHelpId( const rtl::OString& rId ) + { Window::SetHelpId( rId ); } + const rtl::OString& GetHelpId() const + { return Window::GetHelpId(); } + + Size CalcWindowSizePixel() const; + + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } + void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } + const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } + + using Window::SetAccessibleName; + void SetAccessibleName( sal_uInt16 nItemId, const XubString& rName ); + using Window::GetAccessibleName; + const XubString& GetAccessibleName( sal_uInt16 nItemId ) const; +}; + +#endif // _SV_STATUS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/stdtext.hxx b/vcl/inc/vcl/stdtext.hxx new file mode 100644 index 000000000000..693a2692b010 --- /dev/null +++ b/vcl/inc/vcl/stdtext.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_STDTEXT_HXX +#define _VCL_STDTEXT_HXX + +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +class Window; + +// ------------------ +// - Standard-Texte - +// ------------------ + +#define STANDARD_TEXT_FIRST STANDARD_TEXT_SERVICE_NOT_AVAILABLE +#define STANDARD_TEXT_SERVICE_NOT_AVAILABLE ((sal_uInt16)0) +#define STANDARD_TEXT_LAST STANDARD_TEXT_SERVICE_NOT_AVAILABLE + +XubString VCL_DLLPUBLIC GetStandardText( sal_uInt16 nStdText ); + +// ------------------------------------- +// - Hilfsmethoden fuer Standard-Texte - +// ------------------------------------- + +void VCL_DLLPUBLIC ShowServiceNotAvailableError( Window* pParent, const XubString& rServiceName, sal_Bool bError ); + +#endif // _VCL_STDTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/strhelper.hxx b/vcl/inc/vcl/strhelper.hxx new file mode 100644 index 000000000000..450139b0ba14 --- /dev/null +++ b/vcl/inc/vcl/strhelper.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _PSPRINT_STRHELPER_HXX_ +#define _PSPRINT_STRHELPER_HXX_ + +#include "vcl/dllapi.h" + +#include <tools/string.hxx> +#include <rtl/math.hxx> + +#include <cstring> + +namespace psp { + +String VCL_DLLPUBLIC GetCommandLineToken( int, const String& ); +ByteString VCL_DLLPUBLIC GetCommandLineToken( int, const ByteString& ); +// gets one token of a unix command line style string +// doublequote, singlequote and singleleftquote protect their respective +// contents + +int VCL_DLLPUBLIC GetCommandLineTokenCount( const String& ); +int VCL_DLLPUBLIC GetCommandLineTokenCount( const ByteString& ); +// returns number of tokens (zero if empty or whitespace only) + +String VCL_DLLPUBLIC WhitespaceToSpace( const String&, sal_Bool bProtect = sal_True ); +ByteString VCL_DLLPUBLIC WhitespaceToSpace( const ByteString&, sal_Bool bProtect = sal_True ); +// returns a string with multiple adjacent occurrences of whitespace +// converted to a single space. if bProtect is sal_True (nonzero), then +// doublequote, singlequote and singleleftquote protect their respective +// contents + + +// parses the first double in the string; decimal is '.' only +inline double VCL_DLLPUBLIC StringToDouble( const String& rStr ) +{ + rtl_math_ConversionStatus eStatus; + return rtl::math::stringToDouble( rStr, sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL); +} + +inline double VCL_DLLPUBLIC StringToDouble( const ByteString& rStr ) +{ + rtl_math_ConversionStatus eStatus; + return rtl::math::stringToDouble( rtl::OStringToOUString( rStr, osl_getThreadTextEncoding() ), sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL); +} + +// fills a character buffer with the string representation of a double +// the buffer has to be long enough (e.g. 128 bytes) +// returns the string len +inline int VCL_DLLPUBLIC getValueOfDouble( char* pBuffer, double f, int nPrecision = 0) +{ + rtl::OString aStr( rtl::math::doubleToString( f, rtl_math_StringFormat_G, nPrecision, '.', true ) ); + int nLen = aStr.getLength(); + std::strncpy( pBuffer, aStr.getStr(), nLen+1 ); // copy string including terminating zero + return nLen; +} + +} // namespace + +#endif // _PSPRINT_STRHELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/subedit.hxx b/vcl/inc/vcl/subedit.hxx new file mode 100644 index 000000000000..17b22e2b5587 --- /dev/null +++ b/vcl/inc/vcl/subedit.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SUBEDIT_HXX +#define _SV_SUBEDIT_HXX + +#include <vcl/sv.h> +#include <vcl/edit.hxx> + +// --------------- +// - ImplSubEdit - +// --------------- + +class ImplSubEdit : public Edit +{ +public: + ImplSubEdit( Edit* pParent, WinBits nStyle ); + + Edit* GetParent() const { return (Edit*)Edit::GetParent(); } + + virtual void Modify(); +}; + +#endif // _SV_SUBEDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/sv.h b/vcl/inc/vcl/sv.h new file mode 100644 index 000000000000..543e08caec8f --- /dev/null +++ b/vcl/inc/vcl/sv.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SV_H +#define _SV_SV_H + +#include <tools/solar.h> + +#endif // _SV_SV_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx new file mode 100644 index 000000000000..85e902161a48 --- /dev/null +++ b/vcl/inc/vcl/svapp.hxx @@ -0,0 +1,661 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SVAPP_HXX +#define _SV_SVAPP_HXX + +#include <osl/thread.hxx> +#include <osl/mutex.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <tools/unqid.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/apptypes.hxx> +#include <vcl/settings.hxx> +#include <vcl/vclevent.hxx> +class BitmapEx; +class Link; +class AllSettings; +class DataChangedEvent; +class Accelerator; +class Help; +class OutputDevice; +class Window; +class WorkWindow; +class MenuBar; +class UnoWrapperBase; +class Reflection; +class KeyCode; +class NotifyEvent; +class KeyEvent; +class MouseEvent; + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/connection/XConnection.hpp> + +namespace com { +namespace sun { +namespace star { +namespace lang { + class XMultiServiceFactory; +} +namespace awt { + class XToolkit; + class XDisplayConnection; +} +} } } + +// helper needed by SalLayout implementations as well as svx/source/dialog/svxbmpnumbalueset.cxx +VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 ); + +// -------------------- +// - SystemWindowMode - +// -------------------- + +#define SYSTEMWINDOW_MODE_NOAUTOMODE ((sal_uInt16)0x0001) +#define SYSTEMWINDOW_MODE_DIALOG ((sal_uInt16)0x0002) + +// ------------- +// - EventHook - +// ------------- + +typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData ); + +// -------------------- +// - ApplicationEvent - +// -------------------- + +// Erstmal wieder eingebaut, damit AppEvents auf dem MAC funktionieren +#ifdef UNX +// enum Doppelt in daemon.cxx unter unix Achtung !!! +enum Service { SERVICE_OLE, SERVICE_APPEVENT, SERVICE_IPC }; +#endif + +class VCL_DLLPUBLIC ApplicationAddress +{ +friend class Application; +protected: + UniString aHostName; + UniString aDisplayName; + UniString aDomainName; + int nPID; + +public: + ApplicationAddress(); + ApplicationAddress( const UniString& rDomain ); + ApplicationAddress( const UniString& rHost, + const UniString& rDisp, + const UniString& rDomain ); + ApplicationAddress( const UniString& rHost, int nPID ); + + const UniString& GetHost() const { return aHostName; } + const UniString& GetDisplay() const { return aDisplayName; } + const UniString& GetDomain() const { return aDomainName; } + int GetPID() const { return nPID; } + + sal_Bool IsConnectToSame( const ApplicationAddress& rAdr ) const; +}; + +inline ApplicationAddress::ApplicationAddress() +{ + nPID = 0; +} + +inline ApplicationAddress::ApplicationAddress( const UniString& rDomain ) +{ + aDomainName = rDomain; + nPID = 0; +} + +inline ApplicationAddress::ApplicationAddress( const UniString& rHost, + const UniString& rDisp, + const UniString& rDomain ) +{ + aHostName = rHost; + aDisplayName = rDisp; + aDomainName = rDomain; + nPID = 0; +} + +inline ApplicationAddress::ApplicationAddress( const UniString& rHost, int nPIDPar ) +{ + aHostName = rHost; + nPID = nPIDPar; +} + +inline sal_Bool ApplicationAddress::IsConnectToSame( const ApplicationAddress& rAdr ) const +{ + if ( nPID && ((nPID == rAdr.nPID) && (aHostName.Equals( rAdr.aHostName))) ) + return sal_True; + else + return sal_False; +} + +#define APPEVENT_PARAM_DELIMITER '\n' + +#define APPEVENT_OPEN_STRING "Open" +#define APPEVENT_PRINT_STRING "Print" +#define APPEVENT_DISKINSERT_STRING "DiskInsert" +#define APPEVENT_SAVEDOCUMENTS_STRING "SaveDocuments" + +class VCL_DLLPUBLIC ApplicationEvent +{ +private: + UniString aSenderAppName; // Absender Applikationsname + ByteString aEvent; // Event + UniString aData; // Uebertragene Daten + ApplicationAddress aAppAddr; // Absender Addresse + +public: + ApplicationEvent() {} + ApplicationEvent( const UniString& rSenderAppName, + const ApplicationAddress& rAppAddr, + const ByteString& rEvent, + const UniString& rData ); + + const UniString& GetSenderAppName() const { return aSenderAppName; } + const ByteString& GetEvent() const { return aEvent; } + const UniString& GetData() const { return aData; } + const ApplicationAddress& GetAppAddress() const { return aAppAddr; } + + sal_Bool IsOpenEvent() const; + sal_Bool IsPrintEvent() const; + sal_Bool IsDiskInsertEvent() const; + + sal_uInt16 GetParamCount() const { return aData.GetTokenCount( APPEVENT_PARAM_DELIMITER ); } + UniString GetParam( sal_uInt16 nParam ) const { return aData.GetToken( nParam, APPEVENT_PARAM_DELIMITER ); } +}; + +inline ApplicationEvent::ApplicationEvent( const UniString& rSenderAppName, + const ApplicationAddress& rAppAddr, + const ByteString& rEvent, + const UniString& rData ) : + aSenderAppName( rSenderAppName ), + aEvent( rEvent ), + aData( rData ), + aAppAddr( rAppAddr ) +{ +} + +inline sal_Bool ApplicationEvent::IsOpenEvent() const +{ + if ( aEvent.Equals( APPEVENT_OPEN_STRING )) + return sal_True; + else + return sal_False; +} + +inline sal_Bool ApplicationEvent::IsPrintEvent() const +{ + if ( aEvent.Equals( APPEVENT_PRINT_STRING )) + return sal_True; + else + return sal_False; +} + +inline sal_Bool ApplicationEvent::IsDiskInsertEvent() const +{ + if ( aEvent.Equals( APPEVENT_DISKINSERT_STRING )) + return sal_True; + else + return sal_False; +} + +class VCL_DLLPUBLIC PropertyHandler +{ +public: + virtual void Property( ApplicationProperty& ) = 0; +}; + +// --------------- +// - Application - +// --------------- + +class VCL_DLLPUBLIC Application +{ +public: + Application(); + virtual ~Application(); + + virtual int Main() = 0; + + virtual sal_Bool QueryExit(); + + virtual void UserEvent( sal_uLong nEvent, void* pEventData ); + + virtual void ActivateExtHelp(); + virtual void DeactivateExtHelp(); + + virtual void ShowStatusText( const XubString& rText ); + virtual void HideStatusText(); + + virtual void FocusChanged(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Init(); + virtual void InitFinished(); + virtual void DeInit(); + + static void InitAppRes( const ResId& rResId ); + + static sal_uInt16 GetCommandLineParamCount(); + static XubString GetCommandLineParam( sal_uInt16 nParam ); + static const XubString& GetAppFileName(); + + virtual sal_uInt16 Exception( sal_uInt16 nError ); + static void Abort( const XubString& rErrorText ); + + static void Execute(); + static void Quit(); + static void Reschedule( bool bAllEvents = false ); + static void Yield( bool bAllEvents = false ); + static void EndYield(); + static osl::SolarMutex& GetSolarMutex(); + static oslThreadIdentifier GetMainThreadIdentifier(); + static sal_uLong ReleaseSolarMutex(); + static void AcquireSolarMutex( sal_uLong nCount ); + static void EnableNoYieldMode( bool i_bNoYield ); + static void AddPostYieldListener( const Link& i_rListener ); + static void RemovePostYieldListener( const Link& i_rListener ); + + static sal_Bool IsInMain(); + static sal_Bool IsInExecute(); + static sal_Bool IsShutDown(); + static sal_Bool IsInModalMode(); + static sal_uInt16 GetModalModeCount(); + + static sal_uInt16 GetDispatchLevel(); + static sal_Bool AnyInput( sal_uInt16 nType = INPUT_ANY ); + static sal_uLong GetLastInputInterval(); + static sal_Bool IsUICaptured(); + static sal_Bool IsUserActive( sal_uInt16 nTest = USERACTIVE_ALL ); + + virtual void SystemSettingsChanging( AllSettings& rSettings, + Window* pFrame ); + static void MergeSystemSettings( AllSettings& rSettings ); + /** validate that the currently selected system UI font is suitable + to display the application's UI. + + A localized test string will be checked if it can be displayed + in the currently selected system UI font. If no glyphs are + missing it can be assumed that the font is proper for display + of the application's UI. + + @returns + <TRUE/> if the system font is suitable for our UI + <FALSE/> if the test string could not be displayed with the system font + */ + static bool ValidateSystemFont(); + + static void SetSettings( const AllSettings& rSettings ); + static const AllSettings& GetSettings(); + static void NotifyAllWindows( DataChangedEvent& rDCEvt ); + + static void AddEventListener( const Link& rEventListener ); + static void RemoveEventListener( const Link& rEventListener ); + static void AddKeyListener( const Link& rKeyListener ); + static void RemoveKeyListener( const Link& rKeyListener ); + static void ImplCallEventListeners( sal_uLong nEvent, Window* pWin, void* pData ); + static void ImplCallEventListeners( VclSimpleEvent* pEvent ); + static sal_Bool HandleKey( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent ); + + static sal_uLong PostKeyEvent( sal_uLong nEvent, Window *pWin, KeyEvent* pKeyEvent ); + static sal_uLong PostMouseEvent( sal_uLong nEvent, Window *pWin, MouseEvent* pMouseEvent ); + static void RemoveMouseAndKeyEvents( Window *pWin ); + static sal_Bool IsProcessedMouseOrKeyEvent( sal_uLong nEventId ); + + static sal_uLong PostUserEvent( sal_uLong nEvent, void* pEventData = NULL ); + static sal_uLong PostUserEvent( const Link& rLink, void* pCaller = NULL ); + static sal_Bool PostUserEvent( sal_uLong& rEventId, sal_uLong nEvent, void* pEventData = NULL ); + static sal_Bool PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL ); + static void RemoveUserEvent( sal_uLong nUserEvent ); + + static sal_Bool InsertIdleHdl( const Link& rLink, sal_uInt16 nPriority ); + static void RemoveIdleHdl( const Link& rLink ); + + virtual void AppEvent( const ApplicationEvent& rAppEvent ); + + virtual void Property( ApplicationProperty& ); + void SetPropertyHandler( PropertyHandler* pHandler ); + +#ifndef NO_GETAPPWINDOW + static WorkWindow* GetAppWindow(); +#endif + + static Window* GetFocusWindow(); + static OutputDevice* GetDefaultDevice(); + + static Window* GetFirstTopLevelWindow(); + static Window* GetNextTopLevelWindow( Window* pWindow ); + + static long GetTopWindowCount(); + static Window* GetTopWindow( long nIndex ); + static Window* GetActiveTopWindow(); + + static void SetAppName( const String& rUniqueName ); + static String GetAppName(); + static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap); + + static void SetDisplayName( const UniString& rDisplayName ); + static UniString GetDisplayName(); + + static unsigned int GetScreenCount(); + // IsMultiDisplay returns: + // true: different screens are separate and windows cannot be moved + // between them (e.g. Xserver with multiple screens) + // false: screens form up one large display area + // windows can be moved between single screens + // (e.g. Xserver with Xinerama, Windows) + static bool IsMultiDisplay(); + static Rectangle GetScreenPosSizePixel( unsigned int nScreen ); + static Rectangle GetWorkAreaPosSizePixel( unsigned int nScreen ); + static rtl::OUString GetScreenName( unsigned int nScreen ); + static unsigned int GetDefaultDisplayNumber(); + // if IsMultiDisplay() == false the return value will be + // nearest screen of the target rectangle + // in case of IsMultiDisplay() == true the return value + // will always be GetDefaultDisplayNumber() + static unsigned int GetBestScreen( const Rectangle& ); + + static const LocaleDataWrapper& GetAppLocaleDataWrapper(); + + static sal_Bool InsertAccel( Accelerator* pAccel ); + static void RemoveAccel( Accelerator* pAccel ); + static void FlushAccel(); + static sal_Bool CallAccel( const KeyCode& rKeyCode, sal_uInt16 nRepeat = 0 ); + + static sal_uLong AddHotKey( const KeyCode& rKeyCode, const Link& rLink, void* pData = NULL ); + static void RemoveHotKey( sal_uLong nId ); + static sal_uLong AddEventHook( VCLEventHookProc pProc, void* pData = NULL ); + static void RemoveEventHook( sal_uLong nId ); + static long CallEventHooks( NotifyEvent& rEvt ); + static long CallPreNotify( NotifyEvent& rEvt ); + static long CallEvent( NotifyEvent& rEvt ); + + static void SetHelp( Help* pHelp = NULL ); + static Help* GetHelp(); + + static void EnableAutoHelpId( sal_Bool bEnabled = sal_True ); + static sal_Bool IsAutoHelpIdEnabled(); + + static void EnableAutoMnemonic( sal_Bool bEnabled = sal_True ); + static sal_Bool IsAutoMnemonicEnabled(); + + static sal_uLong GetReservedKeyCodeCount(); + static const KeyCode* GetReservedKeyCode( sal_uLong i ); + static String GetReservedKeyCodeDescription( sal_uLong i ); + + static void SetDefDialogParent( Window* pWindow ); + static Window* GetDefDialogParent(); + + static void EnableDialogCancel( sal_Bool bDialogCancel = sal_True ); + static sal_Bool IsDialogCancelEnabled(); + + static void SetSystemWindowMode( sal_uInt16 nMode ); + static sal_uInt16 GetSystemWindowMode(); + + static void SetDialogScaleX( short nScale ); + static short GetDialogScaleX(); + + static void SetFontPath( const String& rPath ); + static const String& GetFontPath(); + + static UniqueItemId CreateUniqueId(); + + static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > GetDisplayConnection(); + + // The global service manager has to be created before! + static ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > GetVCLToolkit(); + static UnoWrapperBase* GetUnoWrapper( sal_Bool bCreateIfNotExists = sal_True ); + static void SetUnoWrapper( UnoWrapperBase* pWrapper ); + + static void SetFilterHdl( const Link& rLink ); + static const Link& GetFilterHdl(); + + static sal_Bool IsAccessibilityEnabled(); + + static void EnableHeadlessMode( sal_Bool bEnable = sal_True ); + static sal_Bool IsHeadlessModeEnabled(); + + static void ShowNativeErrorBox(const String& sTitle , + const String& sMessage); + + // IME Status Window Control: + + /** Return true if any IME status window can be toggled on and off + externally. + + Must only be called with the Solar mutex locked. + */ + static bool CanToggleImeStatusWindow(); + + /** Toggle any IME status window on and off. + + This only works if CanToggleImeStatusWinodw returns true (otherwise, + any calls of this method are ignored). + + Must only be called with the Solar mutex locked. + */ + static void ShowImeStatusWindow(bool bShow); + + /** Return true if any IME status window should be turned on by default + (this decision can be locale dependent, for example). + + Can be called without the Solar mutex locked. + */ + static bool GetShowImeStatusWindowDefault(); + + /** Returns a string representing the desktop environment + the process is currently running in. + */ + static const ::rtl::OUString& GetDesktopEnvironment(); + + /** Add a file to the system shells recent document list if there is any. + This function may have no effect under Unix because there is no + standard API among the different desktop managers. + + @param rFileUrl + The file url of the document. + + @param rMimeType + The mime content type of the document specified by aFileUrl. + If an empty string will be provided "application/octet-stream" + will be used. + */ + static void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); + +private: + + DECL_STATIC_LINK( Application, PostEventHandler, void* ); +}; + + +class VCL_DLLPUBLIC SolarMutexGuard +{ + private: + SolarMutexGuard( const SolarMutexGuard& ); + const SolarMutexGuard& operator = ( const SolarMutexGuard& ); + ::osl::SolarMutex& m_solarMutex; + + public: + + /** Acquires the object specified as parameter. + */ + SolarMutexGuard() : + m_solarMutex(Application::GetSolarMutex()) + { + m_solarMutex.acquire(); + } + + /** Releases the mutex or interface. */ + ~SolarMutexGuard() + { + m_solarMutex.release(); + } +}; + +class VCL_DLLPUBLIC SolarMutexClearableGuard +{ + SolarMutexClearableGuard( const SolarMutexClearableGuard& ); + const SolarMutexClearableGuard& operator = ( const SolarMutexClearableGuard& ); + bool m_bCleared; +public: + /** Acquires mutex + @param pMutex pointer to mutex which is to be acquired */ + SolarMutexClearableGuard() + : m_bCleared(false) + , m_solarMutex( Application::GetSolarMutex() ) + { + m_solarMutex.acquire(); + } + + /** Releases mutex. */ + virtual ~SolarMutexClearableGuard() + { + if( !m_bCleared ) + { + m_solarMutex.release(); + } + } + + /** Releases mutex. */ + void SAL_CALL clear() + { + if( !m_bCleared ) + { + m_solarMutex.release(); + m_bCleared = true; + } + } +protected: + osl::SolarMutex& m_solarMutex; +}; + +class VCL_DLLPUBLIC SolarMutexResettableGuard +{ + SolarMutexResettableGuard( const SolarMutexResettableGuard& ); + const SolarMutexResettableGuard& operator = ( const SolarMutexResettableGuard& ); + bool m_bCleared; +public: + /** Acquires mutex + @param pMutex pointer to mutex which is to be acquired */ + SolarMutexResettableGuard() + : m_bCleared(false) + , m_solarMutex( Application::GetSolarMutex() ) + { + m_solarMutex.acquire(); + } + + /** Releases mutex. */ + virtual ~SolarMutexResettableGuard() + { + if( !m_bCleared ) + { + m_solarMutex.release(); + } + } + + /** Releases mutex. */ + void SAL_CALL clear() + { + if( !m_bCleared) + { + m_solarMutex.release(); + m_bCleared = true; + } + } + /** Releases mutex. */ + void SAL_CALL reset() + { + if( m_bCleared) + { + m_solarMutex.acquire(); + m_bCleared = false; + } + } +protected: + osl::SolarMutex& m_solarMutex; +}; + + +/** + A helper class that calls Application::ReleaseSolarMutex() in its constructor + and restores the mutex in its destructor. +*/ +class SolarMutexReleaser +{ + sal_uLong mnReleased; + const bool mbRescheduleDuringAcquire; +public: + enum + { + RescheduleDuringAcquire = true + }; + SolarMutexReleaser( const bool i_rescheduleDuringAcquire = false ) + : mnReleased( Application::ReleaseSolarMutex()) + , mbRescheduleDuringAcquire( i_rescheduleDuringAcquire ) + { + } + + ~SolarMutexReleaser() + { + if ( mnReleased > 0 ) + { + if ( mbRescheduleDuringAcquire ) + { + while ( !Application::GetSolarMutex().tryToAcquire() ) + { + Application::Reschedule(); + } + --mnReleased; + } + Application::AcquireSolarMutex( mnReleased ); + } + } +}; + +VCL_DLLPUBLIC Application* GetpApp(); + +VCL_DLLPUBLIC sal_Bool InitVCL( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); +VCL_DLLPUBLIC void DeInitVCL(); + +VCL_DLLPUBLIC sal_Bool InitAccessBridge( sal_Bool bAllowCancel, sal_Bool &rCancelled ); + +// only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory. +VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData ); +VCL_DLLPUBLIC void JoinMainLoopThread(); + +inline void Application::EndYield() +{ + PostUserEvent( Link() ); +} + +#endif // _APP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/svcompat.hxx b/vcl/inc/vcl/svcompat.hxx new file mode 100644 index 000000000000..70d31381287f --- /dev/null +++ b/vcl/inc/vcl/svcompat.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SVCOMPAT_HXX +#define _SV_SVCOMPAT_HXX + +#include <sv.h> + +// ----------- +// - Defines - +// ----------- + +#define COMPAT_FORMAT( char1, char2, char3, char4 ) \ + ((sal_uLong)((((sal_uLong)(char)(char1)))| \ + (((sal_uLong)(char)(char2))<<8UL)| \ + (((sal_uLong)(char)(char3))<<16UL)| \ + ((sal_uLong)(char)(char4))<<24UL)) + + +class SvStream; + +// -------------- +// - ImplCompat - +// -------------- + +class ImplCompat +{ + SvStream* mpRWStm; + sal_uInt32 mnCompatPos; + sal_uInt32 mnTotalSize; + sal_uInt16 mnStmMode; + sal_uInt16 mnVersion; + + ImplCompat() {} + ImplCompat( const ImplCompat& rCompat ) {} + ImplCompat& operator=( const ImplCompat& rCompat ) { return *this; } + sal_Bool operator==( const ImplCompat& rCompat ) { return sal_False; } + +public: + ImplCompat( SvStream& rStm, sal_uInt16 nStreamMode, sal_uInt16 nVersion = 1 ); + ~ImplCompat(); + + sal_uInt16 GetVersion() const { return mnVersion; } +}; + +#endif // _SV_SVCOMPAT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/svdata.hxx b/vcl/inc/vcl/svdata.hxx new file mode 100644 index 000000000000..b28283f1a405 --- /dev/null +++ b/vcl/inc/vcl/svdata.hxx @@ -0,0 +1,461 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SVDATA_HXX +#define _SV_SVDATA_HXX + +#include <osl/thread.hxx> +#include <rtl/ref.hxx> +#include "tools/gen.hxx" +#include "tools/shl.hxx" +#include "tools/link.hxx" +#include "tools/fldunit.hxx" +#include "tools/string.hxx" +#include "vcl/vclevent.hxx" +#include "vcl/sv.h" +#include "tools/color.hxx" +#include "tools/debug.hxx" +#include "vcl/dllapi.h" +#include "com/sun/star/uno/Reference.hxx" +#include "unotools/options.hxx" + +#include <boost/unordered_map.hpp> + +namespace com { +namespace sun { +namespace star { +namespace lang { + class XMultiServiceFactory; +} +namespace frame { + class XSessionManagerClient; +} +}}} + +struct ImplTimerData; +struct ImplFileImageCacheData; +struct ImplConfigData; +class ImplDirectFontSubstitution; +struct ImplHotKey; +struct ImplEventHook; +class Point; +class Rectangle; +class ImpResMgr; +class ResMgr; +class UniqueIndex; +class ImplAccelManager; +class ImplDevFontList; +class ImplFontCache; +class HelpTextWindow; +class ImplTBDragMgr; +class ImplButtonList; +class ImplIdleMgr; +class DbgWindow; +class FloatingWindow; +class AllSettings; +class KeyCode; +class NotifyEvent; +class Timer; +class AutoTimer; +class Help; +class ImageList; +class Image; +class PopupMenu; +class Application; +class OutputDevice; +class Window; +class SystemWindow; +class WorkWindow; +class Dialog; +class VirtualDevice; +class Printer; +class SalFrame; +class SalInstance; +class SalSystem; +class SalProcessWindowList; +class SalTrayList; +class UniqueIdContainer; +class List; +class ImplPrnQueueList; +class ImplVDevCache; +class UnoWrapperBase; +class GraphicConverter; +class ImplWheelWindow; +class SalTimer; +class SalI18NImeStatus; +class DockingManager; +class VclEventListeners2; + +namespace vcl { class DisplayConnection; class SettingsConfigItem; class DeleteOnDeinitBase; } +namespace utl { class DefaultFontConfiguration; class FontSubstConfiguration; } + +// ----------------- +// - ImplSVAppData - +// ----------------- +class LocaleConfigurationListener : public utl::ConfigurationListener +{ +public: + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ); +}; + +struct ImplSVAppData +{ + enum ImeStatusWindowMode + { + ImeStatusWindowMode_UNKNOWN, + ImeStatusWindowMode_HIDE, + ImeStatusWindowMode_SHOW + }; + + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + String* mpMSFTempFileName; + AllSettings* mpSettings; // Application settings + LocaleConfigurationListener* mpCfgListener; + VclEventListeners* mpEventListeners; // listeners for vcl events (eg, extended toolkit) + VclEventListeners* mpKeyListeners; // listeners for key events only (eg, extended toolkit) + ImplAccelManager* mpAccelMgr; // Accelerator Manager + XubString* mpAppName; // Application name + XubString* mpAppFileName; // Abs. Application FileName + XubString* mpDisplayName; // Application Display Name + String* mpFontPath; // Additional Fontpath + Help* mpHelp; // Application help + PopupMenu* mpActivePopupMenu; // Actives Popup-Menu (in Execute) + UniqueIdContainer* mpUniqueIdCont; // Fuer Eindeutige Id's + ImplIdleMgr* mpIdleMgr; // Idle-Manager + ImplWheelWindow* mpWheelWindow; // WheelWindow + ImplHotKey* mpFirstHotKey; // HotKey-Verwaltung + ImplEventHook* mpFirstEventHook; // Event-Hooks + VclEventListeners2* mpPostYieldListeners; // post yield listeners + sal_uLong mnLastInputTime; // GetLastInputTime() + sal_uInt16 mnDispatchLevel; // DispatchLevel + sal_uInt16 mnModalMode; // ModalMode Count + sal_uInt16 mnModalDialog; // ModalDialog Count + sal_uInt16 mnAccessCount; // AccessHdl Count + sal_uInt16 mnSysWinMode; // Modus, wann SystemWindows erzeugt werden sollen + sal_uInt16 mnLayout; // --- RTL-Flags --- currently not used, only for testing + short mnDialogScaleX; // Scale X-Positions and sizes in Dialogs + sal_Bool mbInAppMain; // is Application::Main() on stack + sal_Bool mbInAppExecute; // is Application::Execute() on stack + sal_Bool mbAppQuit; // is Application::Quit() called + sal_Bool mbSettingsInit; // sal_True: Settings are initialized + sal_Bool mbDialogCancel; // sal_True: Alle Dialog::Execute()-Aufrufe werden mit return sal_False sofort beendet + sal_Bool mbNoYield; // Application::Yield will not wait for events if the queue is empty + // essentially that makes it the same as Application::Reschedule + long mnDefaultLayoutBorder; // default value in pixel for layout distances used + // in window arrangers + + /** Controls whether showing any IME status window is toggled on or off. + + Only meaningful if showing IME status windows can be toggled on and off + externally (see Application::CanToggleImeStatusWindow). + */ + ImeStatusWindowMode meShowImeStatusWindow; + + DECL_STATIC_LINK( ImplSVAppData, ImplQuitMsg, void* ); + +}; + + +// ----------------- +// - ImplSVGDIData - +// ----------------- + +struct ImplSVGDIData +{ + OutputDevice* mpFirstWinGraphics; // First OutputDevice with a Frame Graphics + OutputDevice* mpLastWinGraphics; // Last OutputDevice with a Frame Graphics + OutputDevice* mpFirstVirGraphics; // First OutputDevice with a VirtualDevice Graphics + OutputDevice* mpLastVirGraphics; // Last OutputDevice with a VirtualDevice Graphics + OutputDevice* mpFirstPrnGraphics; // First OutputDevice with a InfoPrinter Graphics + OutputDevice* mpLastPrnGraphics; // Last OutputDevice with a InfoPrinter Graphics + VirtualDevice* mpFirstVirDev; // First VirtualDevice + VirtualDevice* mpLastVirDev; // Last VirtualDevice + Printer* mpFirstPrinter; // First Printer + Printer* mpLastPrinter; // Last Printer + ImplPrnQueueList* mpPrinterQueueList; // List of all printer queue + ImplDevFontList* mpScreenFontList; // Screen-Font-List + ImplFontCache* mpScreenFontCache; // Screen-Font-Cache + ImplDirectFontSubstitution* mpDirectFontSubst;// Font-Substitutons defined in Tools->Options->Fonts + GraphicConverter* mpGrfConverter; // Converter for graphics + long mnRealAppFontX; // AppFont X-Numenator for 40/tel Width + long mnAppFontX; // AppFont X-Numenator for 40/tel Width + DialogScaleX + long mnAppFontY; // AppFont Y-Numenator for 80/tel Height + sal_Bool mbFontSubChanged; // sal_True: FontSubstitution wurde zwischen Begin/End geaendert + utl::DefaultFontConfiguration* mpDefaultFontConfiguration; + utl::FontSubstConfiguration* mpFontSubstConfiguration; + bool mbNativeFontConfig; // true: do not override UI font + bool mbNoXORClipping; // true: do not use XOR to achieve clipping effects +}; + + +// ----------------- +// - ImplSVWinData - +// ----------------- + +struct ImplSVWinData +{ + Window* mpFirstFrame; // First FrameWindow + Window* mpDefDialogParent; // Default Dialog Parent + WorkWindow* mpAppWin; // Application-Window + Window* mpFocusWin; // window, that has the focus + Window* mpActiveApplicationFrame; // the last active application frame, can be used as DefModalDialogParent if no focuswin set + Window* mpCaptureWin; // window, that has the mouse capture + Window* mpLastDeacWin; // Window, that need a deactivate (FloatingWindow-Handling) + DbgWindow* mpDbgWin; // debug window + FloatingWindow* mpFirstFloat; // First FloatingWindow in PopupMode + Dialog* mpLastExecuteDlg; // Erster Dialog, der sich in Execute befindet + Window* mpExtTextInputWin; // Window, which is in ExtTextInput + Window* mpTrackWin; // window, that is in tracking mode + AutoTimer* mpTrackTimer; // tracking timer + ImageList* mpMsgBoxImgList; // ImageList for MessageBox + Window* mpAutoScrollWin; // window, that is in AutoScrollMode mode + sal_uInt16 mnTrackFlags; // tracking flags + sal_uInt16 mnAutoScrollFlags; // auto scroll flags + sal_Bool mbNoDeactivate; // sal_True: keine Deactivate durchfuehren + sal_Bool mbNoSaveFocus; // sal_True: menues must not save/restore focus + sal_Bool mbNoSaveBackground; // sal_True: save background is unnecessary or even less performant +}; + + +// ------------------ +// - ImplSVCtrlData - +// ------------------ + +typedef std::vector< std::pair< String, FieldUnit > > FieldUnitStringList; + +struct ImplSVCtrlData +{ + ImageList* mpCheckImgList; // ImageList for CheckBoxes + ImageList* mpRadioImgList; // ImageList for RadioButtons + ImageList* mpPinImgList; // ImageList for PIN + ImageList* mpSplitHPinImgList; // ImageList for Horizontale SplitWindows + 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* mpDisclosureMinus; + ImplTBDragMgr* mpTBDragMgr; // DragMgr for ToolBox + sal_uInt16 mnCheckStyle; // CheckBox-Style for ImageList-Update + sal_uInt16 mnRadioStyle; // Radio-Style for ImageList-Update + sal_uLong mnLastCheckFColor; // Letzte FaceColor fuer CheckImage + sal_uLong mnLastCheckWColor; // Letzte WindowColor fuer CheckImage + sal_uLong mnLastCheckWTextColor; // Letzte WindowTextColor fuer CheckImage + sal_uLong mnLastCheckLColor; // Letzte LightColor fuer CheckImage + sal_uLong mnLastRadioFColor; // Letzte FaceColor fuer RadioImage + sal_uLong mnLastRadioWColor; // Letzte WindowColor fuer RadioImage + sal_uLong mnLastRadioLColor; // Letzte LightColor fuer RadioImage + FieldUnitStringList* mpFieldUnitStrings; // list with field units + FieldUnitStringList* mpCleanUnitStrings; // same list but with some "fluff" like spaces removed +}; + + +// ------------------ +// - ImplSVHelpData - +// ------------------ + +struct ImplSVHelpData +{ + sal_Bool mbContextHelp : 1; // is ContextHelp enabled + sal_Bool mbExtHelp : 1; // is ExtendedHelp enabled + sal_Bool mbExtHelpMode : 1; // is in ExtendedHelp Mode + sal_Bool mbOldBalloonMode : 1; // BallonMode, befor ExtHelpMode started + sal_Bool mbBalloonHelp : 1; // is BalloonHelp enabled + sal_Bool mbQuickHelp : 1; // is QuickHelp enabled + sal_Bool mbSetKeyboardHelp : 1; // tiphelp was activated by keyboard + sal_Bool mbKeyboardHelp : 1; // tiphelp was activated by keyboard + sal_Bool mbAutoHelpId : 1; // generate HelpIds + sal_Bool mbRequestingHelp : 1; // In Window::RequestHelp + HelpTextWindow* mpHelpWin; // HelpWindow + sal_uLong mnLastHelpHideTime; // ticks of last show +}; + +struct ImplSVNWFData +{ + bool mbMenuBarDockingAreaCommonBG; // e.g. WinXP default theme + bool mbDockingAreaSeparateTB; // individual toolbar backgrounds + // instead of one for docking area + bool mbToolboxDropDownSeparate; // two adjacent buttons for + // toolbox dropdown buttons + int mnMenuFormatExtraBorder; // inner popup menu border + bool mbFlatMenu; // no popup 3D border + Color maMenuBarHighlightTextColor; // override higlight text color + // in menubar if not transparent + bool mbOpenMenuOnF10; // on gnome the first menu opens on F10 + bool mbNoFocusRects; // on Aqua focus rects are not used + bool mbNoBoldTabFocus; // on Aqua and Gnome the focused tab has not bold text + bool mbCenteredTabs; // on Aqua, tabs are centered + bool mbNoActiveTabTextRaise; // on Aqua the text for the selected tab + // should not "jump up" a pixel + bool mbProgressNeedsErase; // set true for platforms that should draw the + // window background before drawing the native + // progress bar + bool mbCheckBoxNeedsErase; // set true for platforms that should draw the + // window background before drawing the native + // checkbox + bool mbScrollbarJumpPage; // true for "jump to here" behavior + int mnStatusBarLowerRightOffset; // amount in pixel to avoid in the lower righthand corner + bool mbCanDrawWidgetAnySize; // set to true currently on gtk +}; + + +// -------------- +// - ImplSVData - +// -------------- + +struct ImplSVData +{ + void* mpSalData; // SalData + SalInstance* mpDefInst; // Default SalInstance + Application* mpApp; // pApp + WorkWindow* mpDefaultWin; // Default-Window + sal_Bool mbDeInit; // Is VCL deinitializing + sal_uLong mnThreadCount; // is VCL MultiThread enabled + ImplConfigData* mpFirstConfigData; // Zeiger auf ersten Config-Block + ImplTimerData* mpFirstTimerData; // list of all running timers + SalTimer* mpSalTimer; // interface to sal event loop/timers + SalI18NImeStatus* mpImeStatus; // interface to ime status window + SalSystem* mpSalSystem; // SalSystem interface + ResMgr* mpResMgr; // SV-Resource-Manager + sal_uLong mnTimerPeriod; // current timer period + sal_uLong mnTimerUpdate; // TimerCallbackProcs on stack + sal_Bool mbNotAllTimerCalled;// sal_True: Es muessen noch Timer abgearbeitet werden + sal_Bool mbNoCallTimer; // sal_True: No Timeout calls + ImplSVAppData maAppData; // indepen data for class Application + ImplSVGDIData maGDIData; // indepen data for Output classes + ImplSVWinData maWinData; // indepen data for Windows classes + ImplSVCtrlData maCtrlData; // indepen data for Control classes + ImplSVHelpData maHelpData; // indepen data for Help classes + ImplSVNWFData maNWFData; + UnoWrapperBase* mpUnoWrapper; + Window* mpIntroWindow; // the splash screen + DockingManager* mpDockingManager; + sal_Bool mbIsTestTool; + + oslThreadIdentifier mnMainThreadId; + rtl::Reference< vcl::DisplayConnection > mxDisplayConnection; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxAccessBridge; + com::sun::star::uno::Reference< com::sun::star::frame::XSessionManagerClient > xSMClient; + ::vcl::SettingsConfigItem* mpSettingsConfigItem; + std::list< vcl::DeleteOnDeinitBase* >* mpDeinitDeleteList; + boost::unordered_map< int, rtl::OUString >* mpPaperNames; +}; + +void ImplInitSVData(); +void ImplDeInitSVData(); +void ImplDestroySVData(); +Window* ImplGetDefaultWindow(); +VCL_PLUGIN_PUBLIC ResMgr* ImplGetResMgr(); +VCL_PLUGIN_PUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr +DockingManager* ImplGetDockingManager(); +void ImplWindowAutoMnemonic( Window* pWindow ); + +void ImplUpdateSystemProcessWindow(); +Window* ImplFindWindow( const SalFrame* pFrame, Point& rSalFramePos ); + +// SVAPP.CXX +sal_Bool ImplCallHotKey( const KeyCode& rKeyCode ); +void ImplFreeHotKeyData(); +void ImplFreeEventHookData(); + +// WINPROC.CXX +long ImplCallPreNotify( NotifyEvent& rEvt ); +long ImplCallEvent( NotifyEvent& rEvt ); + +extern VCL_PLUGIN_PUBLIC ImplSVData* pImplSVData; +inline VCL_PLUGIN_PUBLIC ImplSVData* ImplGetSVData() { return pImplSVData; } +inline ImplSVData* ImplGetAppSVData() { return ImplGetSVData(); } + +bool ImplInitAccessBridge( sal_Bool bAllowCancel, sal_Bool &rCancelled ); + +FieldUnitStringList* ImplGetFieldUnits(); +FieldUnitStringList* ImplGetCleanedFieldUnits(); + + +// ----------------------------------------------------------------------- + +// ----------------- +// - ImplSVEmpyStr - +// ----------------- + +// Empty-SV-String + +inline const String& ImplGetSVEmptyStr() + { return String::EmptyString(); } +inline const ByteString& ImplGetSVEmptyByteStr() + { return ByteString::EmptyString(); } + +// ----------------------------------------------------------------------- + +// ---------------------- +// - struct ImplDelData - +// ---------------------- +// ImplDelData is used as a "dog tag" by a window when it +// does something that could indirectly destroy the window +// TODO: wild destruction of a window should not be possible + +struct ImplDelData +{ + ImplDelData* mpNext; + const Window* mpWindow; + sal_Bool mbDel; + + ImplDelData( const Window* pWindow = NULL ) + : mpNext( NULL ), mpWindow( NULL ), mbDel( sal_False ) + { if( pWindow ) AttachToWindow( pWindow ); } + + virtual ~ImplDelData(); + + bool IsDead() const + { + DBG_ASSERT( mbDel == sal_False, "object deleted while in use !" ); + return (mbDel!=sal_False); + } + sal_Bool /*deprecated */IsDelete() const { return (sal_Bool)IsDead(); } + +private: + void AttachToWindow( const Window* ); +}; + +// --------------- +// - ImplSVEvent - +// --------------- + +struct ImplSVEvent +{ + sal_uLong mnEvent; + void* mpData; + Link* mpLink; + Window* mpWindow; + ImplDelData maDelData; + sal_Bool mbCall; +}; + +#endif // _SV_SVDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/svids.hrc b/vcl/inc/vcl/svids.hrc new file mode 100644 index 000000000000..bc76c70e1ebe --- /dev/null +++ b/vcl/inc/vcl/svids.hrc @@ -0,0 +1,254 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SVIDS_HRC +#define _SV_SVIDS_HRC + +#include "svl/solar.hrc" + +#define SV_RESID_STDOFFSET 0 +#define SV_RESID_MONOOFFSET 1 + +// Achtung: Diese Id's muessen min. 10 Werte auseinanderliegen, da +// je nach Style noch ein Offset aufgerechnet wird +#define SV_RESID_BITMAP_CHECK 1000 +#define SV_RESID_BITMAP_RADIO 1010 + +#define SV_RESID_BITMAP_MSGBOX 1020 + +#define SV_RESID_BITMAP_PIN 1030 + +#define SV_RESID_BITMAP_SPLITHPIN 1040 +#define SV_RESID_BITMAP_SPLITVPIN 1041 +#define SV_RESID_BITMAP_SPLITHARW 1042 +#define SV_RESID_BITMAP_SPLITVARW 1043 + +#define SV_RESID_BITMAP_SCROLLMSK 1050 +#define SV_RESID_BITMAP_SCROLLBMP 1051 +#define SV_RESID_BITMAP_CLOSEDOC 1052 + +#define SV_DISCLOSURE_PLUS 1060 +#define SV_DISCLOSURE_MINUS 1061 + +#define RID_STR_PAPERNAMES 1070 + +#define SV_RESID_MENU_EDIT 2000 +#define SV_MENU_EDIT_UNDO 1 +#define SV_MENU_EDIT_CUT 2 +#define SV_MENU_EDIT_COPY 3 +#define SV_MENU_EDIT_PASTE 4 +#define SV_MENU_EDIT_DELETE 5 +#define SV_MENU_EDIT_SELECTALL 6 +#define SV_MENU_EDIT_INSERTSYMBOL 7 +#define SV_RESID_STRING_NOSELECTIONPOSSIBLE 2001 + +#define SV_MENU_MAC_SERVICES 2002 +#define SV_MENU_MAC_HIDEAPP 2003 +#define SV_MENU_MAC_HIDEALL 2004 +#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_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_DEFPRT_TXT 15 +#define SV_PRINT_PRINTPREVIEW_TXT 16 + +#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 +#define SV_PRINT_PRT_NUP_ORIENTATION_LANDSCAPE 2 + +#define SV_PRINT_PRT_NUP_ORDER_LRTB 0 +#define SV_PRINT_PRT_NUP_ORDER_TBLR 1 +#define SV_PRINT_PRT_NUP_ORDER_TBRL 2 +#define SV_PRINT_PRT_NUP_ORDER_RLTB 3 + +#define SV_PRINT_TAB_JOB 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 +#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_NOPAGES 19 +#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_OPT_REVERSE 24 + +#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_DLG_PRINT_PROGRESS 2049 +#define SV_PRINT_PROGRESS_CANCEL 1 +#define SV_PRINT_PROGRESS_TEXT 2 + +#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 +#define SV_HELPTEXT_MAXIMIZE 10002 +#define SV_HELPTEXT_RESTORE 10003 +#define SV_HELPTEXT_ROLLDOWN 10004 +#define SV_HELPTEXT_ROLLUP 10005 +#define SV_HELPTEXT_HELP 10006 +#define SV_HELPTEXT_ALWAYSVISIBLE 10007 +#define SV_HELPTEXT_FADEIN 10008 +#define SV_HELPTEXT_FADEOUT 10009 +#define SV_HELPTEXT_SPLITFLOATING 10010 +#define SV_HELPTEXT_SPLITFIXED 10011 +#define SV_HELPTEXT_CLOSEDOCUMENT 10012 + +#define SV_BUTTONTEXT_OK 10100 +#define SV_BUTTONTEXT_CANCEL 10101 +#define SV_BUTTONTEXT_YES 10102 +#define SV_BUTTONTEXT_NO 10103 +#define SV_BUTTONTEXT_RETRY 10104 +#define SV_BUTTONTEXT_HELP 10105 +#define SV_BUTTONTEXT_CLOSE SV_HELPTEXT_CLOSE +#define SV_BUTTONTEXT_MORE 10107 +#define SV_BUTTONTEXT_IGNORE 10108 +#define SV_BUTTONTEXT_ABORT 10109 +#define SV_BUTTONTEXT_LESS 10110 + +#define SV_STDTEXT_FIRST SV_STDTEXT_SERVICENOTAVAILABLE +#define SV_STDTEXT_SERVICENOTAVAILABLE 10200 +#define SV_STDTEXT_DONTHINTAGAIN 10201 +#define SV_STDTEXT_DONTASKAGAIN 10202 +#define SV_STDTEXT_DONTWARNAGAIN 10203 +#define SV_STDTEXT_ABOUT 10204 +#define SV_STDTEXT_PREFERENCES 10205 +#define SV_MAC_SCREENNNAME 10206 +#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 +#define SV_ACCESSERROR_BRIDGE_MSG 10501 +#define SV_ACCESSERROR_OK_CANCEL_MSG 10502 +#define SV_ACCESSERROR_MISSING_BRIDGE 10503 +#define SV_ACCESSERROR_FAULTY_JAVA 10504 +#define SV_ACCESSERROR_JAVA_MSG 10505 +#define SV_ACCESSERROR_MISSING_JAVA 10506 +#define SV_ACCESSERROR_JAVA_NOT_CONFIGURED 10507 +#define SV_ACCESSERROR_JAVA_DISABLED 10508 +#define SV_ACCESSERROR_TURNAROUND_MSG 10509 +#define SV_ACCESSERROR_NO_FONTS 10510 +#define SV_ACCESSERROR_LAST SV_ACCESSERROR_NO_FONTS + +#define SV_SHORTCUT_HELP 10600 +#define SV_SHORTCUT_CONTEXTHELP 10601 +#define SV_SHORTCUT_ACTIVEHELP 10602 +#define SV_SHORTCUT_DOCKUNDOCK 10603 +#define SV_SHORTCUT_NEXTSUBWINDOW 10604 +#define SV_SHORTCUT_PREVSUBWINDOW 10605 +#define SV_SHORTCUT_TODOCUMENT 10606 +#define SV_SHORTCUT_MENUBAR 10607 +#define SV_SHORTCUT_SPLITTER 10608 + +#define SV_EDIT_WARNING_BOX 10650 + +#define SV_FUNIT_STRINGS 10700 + +#define SV_ICON_SIZE48_START 20000 +#define SV_ICON_SIZE32_START 21000 +#define SV_ICON_SIZE16_START 23000 + +#define SV_ICON_LARGE_START 24000 +#define SV_ICON_SMALL_START 25000 + +#define SV_ICON_ID_OFFICE 1 +#define SV_ICON_ID_TEXT 2 +#define SV_ICON_ID_TEXT_TEMPLATE 3 +#define SV_ICON_ID_SPREADSHEET 4 +#define SV_ICON_ID_SPREADSHEET_TEMPLATE 5 +#define SV_ICON_ID_DRAWING 6 +#define SV_ICON_ID_DRAWING_TEMPLATE 7 +#define SV_ICON_ID_PRESENTATION 8 +#define SV_ICON_ID_PRESENTATION_TEMPLATE 9 +#define SV_ICON_ID_PRESENTATION_COMPRESSED 10 +#define SV_ICON_ID_MASTER_DOCUMENT 11 +#define SV_ICON_ID_HTML_DOCUMENT 12 +#define SV_ICON_ID_CHART 13 +#define SV_ICON_ID_DATABASE 14 +#define SV_ICON_ID_FORMULA 15 +#define SV_ICON_ID_TEMPLATE 16 +#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/inc/vcl/symbol.hxx b/vcl/inc/vcl/symbol.hxx new file mode 100644 index 000000000000..c03bf9a6af58 --- /dev/null +++ b/vcl/inc/vcl/symbol.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SYMBOL_HXX +#define _SV_SYMBOL_HXX + +#include <vcl/sv.h> + +// ---------------- +// - Symbol-Types - +// ---------------- + +// By changes you must also change: rsc/vclrsc.hxx +typedef sal_uInt16 SymbolType; +#define SYMBOL_DONTKNOW ((SymbolType)0) +#define SYMBOL_IMAGE ((SymbolType)1) +#define SYMBOL_ARROW_UP ((SymbolType)2) +#define SYMBOL_ARROW_DOWN ((SymbolType)3) +#define SYMBOL_ARROW_LEFT ((SymbolType)4) +#define SYMBOL_ARROW_RIGHT ((SymbolType)5) +#define SYMBOL_SPIN_UP ((SymbolType)6) +#define SYMBOL_SPIN_DOWN ((SymbolType)7) +#define SYMBOL_SPIN_LEFT ((SymbolType)8) +#define SYMBOL_SPIN_RIGHT ((SymbolType)9) +#define SYMBOL_FIRST ((SymbolType)10) +#define SYMBOL_LAST ((SymbolType)11) +#define SYMBOL_PREV ((SymbolType)12) +#define SYMBOL_NEXT ((SymbolType)13) +#define SYMBOL_PAGEUP ((SymbolType)14) +#define SYMBOL_PAGEDOWN ((SymbolType)15) +#define SYMBOL_PLAY ((SymbolType)16) +#define SYMBOL_REVERSEPLAY ((SymbolType)17) +#define SYMBOL_RECORD ((SymbolType)18) +#define SYMBOL_STOP ((SymbolType)19) +#define SYMBOL_PAUSE ((SymbolType)20) +#define SYMBOL_WINDSTART ((SymbolType)21) +#define SYMBOL_WINDEND ((SymbolType)22) +#define SYMBOL_WINDBACKWARD ((SymbolType)23) +#define SYMBOL_WINDFORWARD ((SymbolType)24) +#define SYMBOL_CLOSE ((SymbolType)25) +#define SYMBOL_ROLLUP ((SymbolType)26) +#define SYMBOL_ROLLDOWN ((SymbolType)27) +#define SYMBOL_CHECKMARK ((SymbolType)28) +#define SYMBOL_RADIOCHECKMARK ((SymbolType)29) +#define SYMBOL_SPIN_UPDOWN ((SymbolType)30) +#define SYMBOL_FLOAT ((SymbolType)31) +#define SYMBOL_DOCK ((SymbolType)32) +#define SYMBOL_HIDE ((SymbolType)33) +#define SYMBOL_HELP ((SymbolType)34) +#define SYMBOL_MENU SYMBOL_SPIN_DOWN + +#define SYMBOL_NOSYMBOL (SYMBOL_DONTKNOW) + +#endif // _SV_SYMBOL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/syschild.hxx b/vcl/inc/vcl/syschild.hxx new file mode 100644 index 000000000000..275e41312f17 --- /dev/null +++ b/vcl/inc/vcl/syschild.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SYSCHILD_HXX +#define _SV_SYSCHILD_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +struct SystemEnvData; +struct SystemWindowData; + +// --------------------- +// - SystemChildWindow - +// --------------------- + +class VCL_DLLPUBLIC SystemChildWindow : public Window +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInitSysChild( Window* pParent, WinBits nStyle, SystemWindowData *pData, sal_Bool bShow = sal_False ); + SAL_DLLPRIVATE void ImplTestJavaException( void* pEnv ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE SystemChildWindow (const SystemChildWindow &); + SAL_DLLPRIVATE SystemChildWindow & operator= (const SystemChildWindow &); + +public: + SystemChildWindow( Window* pParent, WinBits nStyle = 0 ); + // create a SystemChildWindow using the given SystemWindowData + SystemChildWindow( Window* pParent, WinBits nStyle, SystemWindowData *pData, sal_Bool bShow = sal_True ); + SystemChildWindow( Window* pParent, const ResId& rResId ); + ~SystemChildWindow(); + + const SystemEnvData* GetSystemData() const; + + // per default systemchildwindows erase their background for better plugin support + // however, this might not always be required + void EnableEraseBackground( sal_Bool bEnable = sal_True ); + sal_Bool IsEraseBackgroundEnabled(); + void SetForwardKey( sal_Bool bEnable ); + // return the platform specific handle/id of this window; + // in case the flag bUseJava is set, a java compatible overlay window + // is created on which other java windows can be created (plugin interface) + sal_IntPtr GetParentWindowHandle( sal_Bool bUseJava = sal_False ); +}; + +#endif // _SV_SYSCHILD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/sysdata.hxx b/vcl/inc/vcl/sysdata.hxx new file mode 100644 index 000000000000..199f0ad67cac --- /dev/null +++ b/vcl/inc/vcl/sysdata.hxx @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SYSDATA_HXX +#define _SV_SYSDATA_HXX + +#include <vector> + +#ifdef QUARTZ +// predeclare the native classes to avoid header/include problems +typedef struct CGContext *CGContextRef; +typedef struct CGLayer *CGLayerRef; +#ifdef __OBJC__ +@class NSView; +#else +class NSView; +#endif +#endif +#if defined( WNT ) || defined( OS2 ) +#include <windef.h> +#endif + +// ----------------- +// - SystemEnvData - +// ----------------- + +struct SystemEnvData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) || defined( OS2 ) + HWND hWnd; // the window hwnd +#elif defined( QUARTZ ) + NSView* pView; // the cocoa (NSView *) implementing this object +#elif defined( UNX ) + void* pDisplay; // the relevant display connection + long aWindow; // the window of the object + void* pSalFrame; // contains a salframe, if object has one + void* pWidget; // the corresponding widget + void* pVisual; // the visual in use + int nScreen; // the current screen of the window + int nDepth; // depth of said visual + long aColormap; // the colormap being used + void* pAppContext; // the application context in use + long aShellWindow; // the window of the frame's shell + void* pShellWidget; // the frame's shell widget +#endif +}; + +#define SystemChildData SystemEnvData + +// -------------------- +// - SystemParentData - +// -------------------- + +struct SystemParentData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) || defined( OS2 ) + HWND hWnd; // the window hwnd +#elif defined( QUARTZ ) + NSView* pView; // the cocoa (NSView *) implementing this object +#elif defined( UNX ) + long aWindow; // the window of the object + bool bXEmbedSupport:1; // decides whether the object in question + // should support the XEmbed protocol +#endif +}; + +// -------------------- +// - SystemMenuData - +// -------------------- + +struct SystemMenuData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) + HMENU hMenu; // the menu handle of the menu bar +#elif defined( QUARTZ ) + //not defined +#elif defined( UNX ) + long aMenu; // ??? +#endif +}; + +// -------------------- +// - SystemGraphicsData - +// -------------------- + +struct SystemGraphicsData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) + HDC hDC; // handle to a device context +#elif defined( QUARTZ ) + CGContextRef rCGContext; // QUARTZ graphic context +#elif defined( UNX ) + void* pDisplay; // the relevant display connection + long hDrawable; // a drawable + void* pVisual; // the visual in use + int nScreen; // the current screen of the drawable + int nDepth; // depth of said visual + long aColormap; // the colormap being used + void* pXRenderFormat; // render format for drawable +#endif +}; + + +// -------------------- +// - SystemWindowData - +// -------------------- + +struct SystemWindowData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) // meaningless on Windows +#elif defined( QUARTZ ) // meaningless on Mac OS X / Quartz +#elif defined( UNX ) + void* pVisual; // the visual to be used +#endif +}; + + +// -------------------- +// - SystemGlyphData - +// -------------------- + +struct SystemGlyphData +{ + unsigned long index; + double x; + double y; + int fallbacklevel; +}; + + +// -------------------- +// - SystemFontData - +// -------------------- + +struct SystemFontData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) + HFONT hFont; // native font object +#elif defined( QUARTZ ) + void* aATSUFontID; // native font object +#elif defined( UNX ) + void* nFontId; // native font id + int nFontFlags; // native font flags +#endif + bool bFakeBold; // Does this font need faking the bold style + bool bFakeItalic; // Does this font need faking the italic style + bool bAntialias; // Should this font be antialiased + bool bVerticalCharacterType; // Is the font using vertical character type +}; + +// -------------------- +// - SystemTextLayoutData - +// -------------------- + +typedef std::vector<SystemGlyphData> SystemGlyphDataVector; + +struct SystemTextLayoutData +{ + unsigned long nSize; // size in bytes of this structure + SystemGlyphDataVector rGlyphData; // glyph data + int orientation; // Text orientation +}; + +#endif // _SV_SYSDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/syswin.hxx b/vcl/inc/vcl/syswin.hxx new file mode 100644 index 000000000000..0fd2fd8d1512 --- /dev/null +++ b/vcl/inc/vcl/syswin.hxx @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_SYSWIN_HXX +#define _SV_SYSWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +class ModalDialog; +class MenuBar; +class TaskPaneList; + +// -------------- +// - Icon-Types - +// -------------- + +#define ICON_DEFAULT 0 +#define ICON_SO_DEFAULT 1 +#define ICON_TEXT_DOCUMENT 2 +#define ICON_TEXT_TEMPLATE 3 +#define ICON_SPREADSHEET_DOCUMENT 4 +#define ICON_SPREADSHEET_TEMPLATE 5 +#define ICON_DRAWING_DOCUMENT 6 +#define ICON_DRAWING_TEMPLATE 7 +#define ICON_PRESENTATION_DOCUMENT 8 +#define ICON_PRESENTATION_TEMPLATE 9 +#define ICON_PRESENTATION_COMPRESSED 10 +#define ICON_GLOBAL_DOCUMENT 11 +#define ICON_HTML_DOCUMENT 12 +#define ICON_CHART_DOCUMENT 13 +#define ICON_DATABASE_DOCUMENT 14 +#define ICON_MATH_DOCUMENT 15 +#define ICON_TEMPLATE 16 +#define ICON_MACROLIBRARY 17 +#define ICON_PLAYER 100 +#define ICON_SETUP 500 + +// ------------------- +// - WindowStateData - +// ------------------- + +#define WINDOWSTATE_MASK_X ((sal_uLong)0x00000001) +#define WINDOWSTATE_MASK_Y ((sal_uLong)0x00000002) +#define WINDOWSTATE_MASK_WIDTH ((sal_uLong)0x00000004) +#define WINDOWSTATE_MASK_HEIGHT ((sal_uLong)0x00000008) +#define WINDOWSTATE_MASK_STATE ((sal_uLong)0x00000010) +#define WINDOWSTATE_MASK_MINIMIZED ((sal_uLong)0x00000020) +#define WINDOWSTATE_MASK_MAXIMIZED_X ((sal_uLong)0x00000100) +#define WINDOWSTATE_MASK_MAXIMIZED_Y ((sal_uLong)0x00000200) +#define WINDOWSTATE_MASK_MAXIMIZED_WIDTH ((sal_uLong)0x00000400) +#define WINDOWSTATE_MASK_MAXIMIZED_HEIGHT ((sal_uLong)0x00000800) +#define WINDOWSTATE_MASK_POS (WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y) +#define WINDOWSTATE_MASK_ALL (WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT | WINDOWSTATE_MASK_MAXIMIZED_X | WINDOWSTATE_MASK_MAXIMIZED_Y | WINDOWSTATE_MASK_MAXIMIZED_WIDTH | WINDOWSTATE_MASK_MAXIMIZED_HEIGHT | WINDOWSTATE_MASK_STATE | WINDOWSTATE_MASK_MINIMIZED) + +#define WINDOWSTATE_STATE_NORMAL ((sal_uLong)0x00000001) +#define WINDOWSTATE_STATE_MINIMIZED ((sal_uLong)0x00000002) +#define WINDOWSTATE_STATE_MAXIMIZED ((sal_uLong)0x00000004) +#define WINDOWSTATE_STATE_ROLLUP ((sal_uLong)0x00000008) +#define WINDOWSTATE_STATE_MAXIMIZED_HORZ ((sal_uLong)0x00000010) +#define WINDOWSTATE_STATE_MAXIMIZED_VERT ((sal_uLong)0x00000020) + +class VCL_PLUGIN_PUBLIC WindowStateData +{ +private: + sal_uInt32 mnValidMask; + int mnX; + int mnY; + unsigned int mnWidth; + unsigned int mnHeight; + int mnMaximizedX; + int mnMaximizedY; + unsigned int mnMaximizedWidth; + unsigned int mnMaximizedHeight; + sal_uInt32 mnState; + +public: + WindowStateData() + { + mnValidMask = mnX = mnY = mnWidth = mnHeight = mnState = 0; + mnMaximizedX = mnMaximizedY = mnMaximizedWidth = mnMaximizedHeight = 0; + } + + void SetMask( sal_uLong nValidMask ) { mnValidMask = nValidMask; } + sal_uInt32 GetMask() const { return mnValidMask; } + + void SetX( int nX ) { mnX = nX; } + int GetX() const { return mnX; } + void SetY( int nY ) { mnY = nY; } + int GetY() const { return mnY; } + void SetWidth( unsigned int nWidth ) { mnWidth = nWidth; } + unsigned int GetWidth() const { return mnWidth; } + void SetHeight( unsigned int nHeight ) { mnHeight = nHeight; } + unsigned int GetHeight() const { return mnHeight; } + void SetState( sal_uInt32 nState ) { mnState = nState; } + sal_uInt32 GetState() const { return mnState; } + void SetMaximizedX( int nRX ) { mnMaximizedX = nRX; } + int GetMaximizedX() const { return mnMaximizedX; } + void SetMaximizedY( int nRY ) { mnMaximizedY = nRY; } + int GetMaximizedY() const { return mnMaximizedY; } + void SetMaximizedWidth( unsigned int nRWidth ) { mnMaximizedWidth = nRWidth; } + unsigned int GetMaximizedWidth() const { return mnMaximizedWidth; } + void SetMaximizedHeight( unsigned int nRHeight ) { mnMaximizedHeight = nRHeight; } + unsigned int GetMaximizedHeight() const { return mnMaximizedHeight; } +}; + +// ---------------------- +// - SystemWindow-Types - +// ---------------------- + +#define MENUBAR_MODE_NORMAL ((sal_uInt16)0) +#define MENUBAR_MODE_HIDE ((sal_uInt16)1) + +#define TITLE_BUTTON_DOCKING ((sal_uInt16)1) +#define TITLE_BUTTON_HIDE ((sal_uInt16)2) +#define TITLE_BUTTON_MENU ((sal_uInt16)4) + +// ---------------- +// - SystemWindow - +// ---------------- + + +class VCL_DLLPUBLIC SystemWindow : public Window +{ + friend class WorkWindow; + class ImplData; + +private: + MenuBar* mpMenuBar; + Size maOrgSize; + Size maRollUpOutSize; + Size maMinOutSize; + sal_Bool mbPined; + sal_Bool mbRollUp; + sal_Bool mbRollFunc; + sal_Bool mbDockBtn; + sal_Bool mbHideBtn; + sal_Bool mbSysChild; + sal_uInt16 mnMenuBarMode; + sal_uInt16 mnIcon; + ImplData* mpImplData; + +#if _SOLAR__PRIVATE +public: + using Window::ImplIsInTaskPaneList; + SAL_DLLPRIVATE sal_Bool ImplIsInTaskPaneList( Window* pWin ); +#endif + +private: + // Default construction is forbidden and not implemented. + SystemWindow(); + + // Copy assignment is forbidden and not implemented. + SystemWindow (const SystemWindow &); + SystemWindow & operator= (const SystemWindow &); + + SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, Window* i_pConfigureWin ); + +protected: + // Single argument ctors shall be explicit. + explicit SystemWindow( WindowType nType ); + + void SetWindowStateData( const WindowStateData& rData ); + +public: + ~SystemWindow(); + virtual long Notify( NotifyEvent& rNEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + virtual sal_Bool Close(); + virtual void TitleButtonClick( sal_uInt16 nButton ); + virtual void Pin(); + virtual void Roll(); + virtual void Resizing( Size& rSize ); + + void SetIcon( sal_uInt16 nIcon ); + sal_uInt16 GetIcon() const { return mnIcon; } + // for systems like MacOSX which can display the URL a document is loaded from + // separately from the window title + void SetRepresentedURL( const rtl::OUString& ); + const rtl::OUString& GetRepresentedURL() const; + + void SetZLevel( sal_uInt8 nLevel ); + sal_uInt8 GetZLevel() const; + + void EnableSaveBackground( sal_Bool bSave = sal_True ); + sal_Bool IsSaveBackgroundEnabled() const; + + void ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible = sal_True ); + sal_Bool IsTitleButtonVisible( sal_uInt16 nButton ) const; + + void SetPin( sal_Bool bPin ); + sal_Bool IsPined() const { return mbPined; } + + void RollUp(); + void RollDown(); + sal_Bool IsRollUp() const { return mbRollUp; } + + void SetRollUpOutputSizePixel( const Size& rSize ) { maRollUpOutSize = rSize; } + Size GetRollUpOutputSizePixel() const { return maRollUpOutSize; } + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const { return maMinOutSize; } + void SetMaxOutputSizePixel( const Size& rSize ); + const Size& GetMaxOutputSizePixel() const; + Size GetResizeOutputSizePixel() const; + + void SetWindowState( const ByteString& rStr ); + ByteString GetWindowState( sal_uLong nMask = WINDOWSTATE_MASK_ALL ) const; + + void SetMenuBar( MenuBar* pMenuBar ); + MenuBar* GetMenuBar() const { return mpMenuBar; } + void SetMenuBarMode( sal_uInt16 nMode ); + sal_uInt16 GetMenuBarMode() const { return mnMenuBarMode; } + + TaskPaneList* GetTaskPaneList(); + void GetWindowStateData( WindowStateData& rData ) const; + + /** + Returns the screen number the window is on + + The screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code>, + <code>Application::GetWorkAreaPosSizePixel</code>, + <code>Application::GetScreenName</code> + and of course <code>SystemWindow::SetScreenNumber</code> + are counted in. + + In case the window is positioned on multiple screens the + screen number returned will be of the screen containing the + upper left pixel of the frame area (that is of the client + area on system decorated windows, or the frame area of + undecorated resp. owner decorated windows. + + @returns the screen number + + @see SystemWindow::SetScreenNumber + */ + unsigned int GetScreenNumber() const; + /** + Move the Window to a new screen. The same rules for + positioning apply as in <code>SystemWindow::GetScreenNumber</code> + + The screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code>, + <code>Application::GetWorkAreaPosSizePixel</code>, + <code>Application::GetScreenName</code> + and of course <code>SystemWindow::GetScreenNumber</code> + are counted in. + + @see GetScreenNumber + */ + void SetScreenNumber( unsigned int nNewScreen ); + + void SetApplicationID( const rtl::OUString &rApplicationID ); +}; + +#endif // _SV_SYSWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx new file mode 100644 index 000000000000..c6525138f73b --- /dev/null +++ b/vcl/inc/vcl/tabctrl.hxx @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TABCTRL_HXX +#define _SV_TABCTRL_HXX + +#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 - +// -------------------- + +#ifndef TAB_APPEND +#define TAB_APPEND ((sal_uInt16)0xFFFF) +#define TAB_PAGE_NOTFOUND ((sal_uInt16)0xFFFF) +#endif /* !TAB_APPEND */ + +// -------------- +// - TabControl - +// -------------- + +class VCL_DLLPUBLIC TabControl : public Control +{ +private: + void* mpDummyPtr; // FIXME: remove before integration + ImplTabCtrlData* mpTabCtrlData; + long mnLastWidth; + long mnLastHeight; + long mnBtnSize; + long mnMaxPageWidth; + sal_uInt16 mnActPageId; + sal_uInt16 mnCurPageId; + sal_Bool mbFormat; + sal_Bool mbRestoreHelpId; + sal_Bool mbRestoreUnqId; + sal_Bool mbSmallInvalidate; + sal_Bool mbExtraSpace; + Link maActivateHdl; + Link maDeactivateHdl; + + using Control::ImplInitSettings; + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const; + SAL_DLLPRIVATE Size ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ); + SAL_DLLPRIVATE Rectangle ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 ); + SAL_DLLPRIVATE void ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ); + SAL_DLLPRIVATE sal_Bool ImplPosCurTabPage(); + SAL_DLLPRIVATE void ImplActivateTabPage( sal_Bool bNext ); + SAL_DLLPRIVATE void ImplShowFocus(); + SAL_DLLPRIVATE void ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false ); + SAL_DLLPRIVATE void ImplPaint( const Rectangle& rRect, bool bLayout = false ); + SAL_DLLPRIVATE void ImplFreeLayoutData(); + SAL_DLLPRIVATE long ImplHandleKeyEvent( const KeyEvent& rKeyEvent ); + + DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox* ); + DECL_DLLPRIVATE_LINK( ImplWindowEventListener, VclSimpleEvent* ); + + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + + virtual void FillLayoutData() const; + virtual const Font& GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt ); + +public: + TabControl( Window* pParent, + WinBits nStyle = WB_STDTABCONTROL ); + TabControl( Window* pParent, const ResId& rResId ); + ~TabControl(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + + virtual void ActivatePage(); + virtual long DeactivatePage(); + + virtual Size GetOptimalSize(WindowSizeType eType) const; + void SetMinimumSizePixel( const Size& ); + + void SetTabPageSizePixel( const Size& rSize ); + Size GetTabPageSizePixel() const; + + // pixel offset for the tab items, default is (0,0) + void SetItemsOffset( const Point& rOffs ); + Point GetItemsOffset() const; + + void InsertPage( const ResId& rResId, + sal_uInt16 nPos = TAB_APPEND ); + void InsertPage( sal_uInt16 nPageId, const XubString& rText, + sal_uInt16 nPos = TAB_APPEND ); + void RemovePage( sal_uInt16 nPageId ); + void Clear(); + void EnablePage( sal_uInt16 nPageId, bool bEnable = true ); + + sal_uInt16 GetPageCount() const; + sal_uInt16 GetPageId( sal_uInt16 nPos ) const; + sal_uInt16 GetPagePos( sal_uInt16 nPageId ) const; + sal_uInt16 GetPageId( const Point& rPos ) const; + + void SetCurPageId( sal_uInt16 nPageId ); + sal_uInt16 GetCurPageId() const; + + void SelectTabPage( sal_uInt16 nPageId ); + + void SetMaxPageWidth( long nMaxWidth ) { mnMaxPageWidth = nMaxWidth; } + long GetMaxPageWidth() const { return mnMaxPageWidth; } + void ResetMaxPageWidth() { SetMaxPageWidth( 0 ); } + sal_Bool IsMaxPageWidth() const { return mnMaxPageWidth != 0; } + + void SetTabPage( sal_uInt16 nPageId, TabPage* pPage ); + TabPage* GetTabPage( sal_uInt16 nPageId ) const; + sal_uInt16 GetTabPageResId( sal_uInt16 nPageId ) const; + + void SetPageText( sal_uInt16 nPageId, const XubString& rText ); + XubString GetPageText( sal_uInt16 nPageId ) const; + + void SetHelpText( sal_uInt16 nPageId, const XubString& rText ); + const XubString& GetHelpText( sal_uInt16 nPageId ) const; + + void SetHelpId( sal_uInt16 nPageId, const rtl::OString& rHelpId ); + rtl::OString GetHelpId( sal_uInt16 nPageId ) const; + + void SetPageImage( sal_uInt16 nPageId, const Image& rImage ); + const Image* GetPageImage( sal_uInt16 nPageId ) const; + + void SetHelpText( const XubString& rText ) + { Control::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return Control::GetHelpText(); } + + void SetHelpId( const rtl::OString& rId ) + { Control::SetHelpId( rId ); } + const rtl::OString& GetHelpId() const + { return Control::GetHelpId(); } + + void SetActivatePageHdl( const Link& rLink ) { maActivateHdl = rLink; } + const Link& GetActivatePageHdl() const { return maActivateHdl; } + void SetDeactivatePageHdl( const Link& rLink ) { maDeactivateHdl = rLink; } + const Link& GetDeactivatePageHdl() const { return maDeactivateHdl; } + + // returns (control relative) bounding rectangle for the + // character at index nIndex relative to the text of page nPageId + using Control::GetCharacterBounds; + Rectangle GetCharacterBounds( sal_uInt16 nPageId, long nIndex ) const; + + // returns the index relative to the text of page nPageId (also returned) + // at position rPoint (control relative) + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const; + + // returns the bounding rectangle of the union of tab page area and the + // corresponding tab + Rectangle GetTabPageBounds( sal_uInt16 nPageId ) const; + + // returns the rectangle of the tab for page nPageId + Rectangle GetTabBounds( sal_uInt16 nPageId ) const; +}; + +#endif // _SV_TABCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/tabdlg.hxx b/vcl/inc/vcl/tabdlg.hxx new file mode 100644 index 000000000000..0b654b409f33 --- /dev/null +++ b/vcl/inc/vcl/tabdlg.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TABDLG_HXX +#define _SV_TABDLG_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/dialog.hxx> + +class FixedLine; +class TabControl; + +// ---------------------- +// - TabDialog - +// ---------------------- + +class VCL_DLLPUBLIC TabDialog : public Dialog +{ +private: + FixedLine* mpFixedLine; + Window* mpViewWindow; + WindowAlign meViewAlign; + sal_Bool mbPosControls; + + SAL_DLLPRIVATE void ImplInitTabDialogData(); + SAL_DLLPRIVATE void ImplPosControls(); + +public: + TabDialog( Window* pParent, + WinBits nStyle = WB_STDTABDIALOG ); + TabDialog( Window* pParent, const ResId& rResId ); + ~TabDialog(); + + virtual void Resize(); + virtual void StateChanged( StateChangedType nStateChange ); + + void AdjustLayout(); + + void SetViewWindow( Window* pWindow ) { mpViewWindow = pWindow; } + Window* GetViewWindow() const { return mpViewWindow; } + void SetViewAlign( WindowAlign eAlign ) { meViewAlign = eAlign; } + WindowAlign GetViewAlign() const { return meViewAlign; } +}; + +#endif // _SV_TABDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/tabpage.hxx b/vcl/inc/vcl/tabpage.hxx new file mode 100644 index 000000000000..92a00f892845 --- /dev/null +++ b/vcl/inc/vcl/tabpage.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TABPAGE_HXX +#define _SV_TABPAGE_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +// ----------- +// - TabPage - +// ----------- + +class VCL_DLLPUBLIC TabPage : public Window +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + +public: + TabPage( Window* pParent, WinBits nStyle = 0 ); + TabPage( Window* pParent, const ResId& rResId ); + + virtual void Paint( const Rectangle& rRect ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void ActivatePage(); + virtual void DeactivatePage(); +}; + +#endif // _SV_TABPAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/taskpanelist.hxx b/vcl/inc/vcl/taskpanelist.hxx new file mode 100644 index 000000000000..102f755554f2 --- /dev/null +++ b/vcl/inc/vcl/taskpanelist.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TASKPANELIST_HXX +#define _SV_TASKPANELIST_HXX + +#include <vcl/dllapi.h> + +#include <vector> +#include <vcl/window.hxx> + +class VCL_DLLPUBLIC TaskPaneList +{ + ::std::vector<Window *> mTaskPanes; + Window *FindNextPane( Window *pWindow, sal_Bool bForward = sal_True ); + Window *FindNextFloat( Window *pWindow, sal_Bool bForward = sal_True ); + Window *FindNextSplitter( Window *pWindow, sal_Bool bForward = sal_True ); + +public: + sal_Bool IsInList( Window *pWindow ); + +public: + TaskPaneList(); + ~TaskPaneList(); + + void AddWindow( Window *pWindow ); + void RemoveWindow( Window *pWindow ); + sal_Bool HandleKeyEvent( KeyEvent aKeyEvent ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/textlayout.hxx b/vcl/inc/vcl/textlayout.hxx new file mode 100644 index 000000000000..5902573f8746 --- /dev/null +++ b/vcl/inc/vcl/textlayout.hxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ***********************************************************************/ + +#ifndef VCL_TEXTLAYOUT_HXX +#define VCL_TEXTLAYOUT_HXX + +#include "vcl/outdev.hxx" + +#include <tools/solar.h> +#include <tools/string.hxx> + +#include <memory> + +class Control; + +//........................................................................ +namespace vcl +{ +//........................................................................ + + //==================================================================== + //= ITextLayout + //==================================================================== + class SAL_NO_VTABLE ITextLayout + { + public: + virtual long GetTextWidth( const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0; + virtual void DrawText( const Point& _rStartPoint, const XubString& _rText, xub_StrLen _nStartIndex, xub_StrLen _nLength, + MetricVector* _pVector, String* _pDisplayText ) = 0; + virtual bool GetCaretPositions( const XubString& _rText, sal_Int32* _pCaretXArray, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0; + virtual xub_StrLen GetTextBreak( const XubString& _rText, long _nMaxTextWidth, xub_StrLen _nStartIndex, xub_StrLen _nLength ) const = 0; + virtual bool DecomposeTextRectAction() const = 0; + }; + + //==================================================================== + //= DefaultTextLayout + //==================================================================== + /** is an implementation of the ITextLayout interface which simply delegates its calls to the respective + methods of an OutputDevice instance, without any inbetween magic. + */ + class DefaultTextLayout : public ITextLayout + { + public: + DefaultTextLayout( OutputDevice& _rTargetDevice ) + :m_rTargetDevice( _rTargetDevice ) + { + } + virtual ~DefaultTextLayout(); + + // ITextLayout overridables + virtual long GetTextWidth( + const XubString& _rText, + xub_StrLen _nStartIndex, + xub_StrLen _nLength + ) const; + virtual void DrawText( + const Point& _rStartPoint, + const XubString& _rText, + xub_StrLen _nStartIndex, + xub_StrLen _nLength, + MetricVector* _pVector, + String* _pDisplayText + ); + virtual bool GetCaretPositions( + const XubString& _rText, + sal_Int32* _pCaretXArray, + xub_StrLen _nStartIndex, + xub_StrLen _nLength + ) const; + virtual xub_StrLen GetTextBreak( + const XubString& _rText, + long _nMaxTextWidth, + xub_StrLen _nStartIndex, + xub_StrLen _nLength + ) const; + virtual bool DecomposeTextRectAction() const; + + private: + OutputDevice& m_rTargetDevice; + }; + + //==================================================================== + //= ControlTextRenderer + //==================================================================== + class ReferenceDeviceTextLayout; + /** a class which allows rendering text of a Control onto a device, by taking into account the metrics of + a reference device. + */ + class ControlTextRenderer + { + public: + ControlTextRenderer( const Control& _rControl, OutputDevice& _rTargetDevice, OutputDevice& _rReferenceDevice ); + virtual ~ControlTextRenderer(); + + Rectangle DrawText( const Rectangle& _rRect, + const XubString& _rText, sal_uInt16 _nStyle = 0, + MetricVector* _pVector = NULL, String* _pDisplayText = NULL ); + + private: + ControlTextRenderer(); // never implemented + ControlTextRenderer( const ControlTextRenderer& ); // never implemented + ControlTextRenderer& operator=( const ControlTextRenderer& ); // never implemented + + private: + ::std::auto_ptr< ReferenceDeviceTextLayout > m_pImpl; + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_TEXTLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/threadex.hxx b/vcl/inc/vcl/threadex.hxx new file mode 100644 index 000000000000..429b43e6ac7c --- /dev/null +++ b/vcl/inc/vcl/threadex.hxx @@ -0,0 +1,290 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <osl/conditn.h> +#include <osl/thread.h> +#include <tools/link.hxx> +#include <vcl/dllapi.h> + +#if ! defined(_CPPUHELPER_EXC_HLP_HXX_) +#include "cppuhelper/exc_hlp.hxx" +#endif +#include "boost/optional.hpp" +#include <memory> + +namespace vcl +{ + class VCL_DLLPUBLIC ThreadExecutor + { + oslThread m_aThread; + oslCondition m_aFinish; + long m_nReturn; + + #ifdef THREADEX_IMPLEMENTATION + public: + SAL_DLLPRIVATE static void SAL_CALL worker( void* ); + #endif + public: + ThreadExecutor(); + virtual ~ThreadExecutor(); + + virtual long doIt() = 0; + long execute(); + }; + + class VCL_DLLPUBLIC SolarThreadExecutor + { + oslCondition m_aStart; + oslCondition m_aFinish; + long m_nReturn; + bool m_bTimeout; + + DECL_DLLPRIVATE_LINK( worker, void* ); + + public: + SolarThreadExecutor(); + virtual ~SolarThreadExecutor(); + + virtual long doIt() = 0; + long execute() { return impl_execute( NULL ); } + // caution: timeout for getting the solar mutex, not for ending + // the operation of doIt(). If doIt actually gets called within + // the specified timeout, execute will only return after + // doIt() completed + long execute( const TimeValue& _rTimeout ) { return impl_execute( &_rTimeout ); } + + public: + bool didTimeout() const { return m_bTimeout; } + + private: + long impl_execute( const TimeValue* _pTimeout ); + }; + +namespace solarthread { + +/// @internal +namespace detail { + +template <typename FuncT, typename ResultT> +class GenericSolarThreadExecutor : public SolarThreadExecutor +{ +public: + static ResultT exec( FuncT const& func ) + { + typedef GenericSolarThreadExecutor<FuncT, ResultT> ExecutorT; + ::std::auto_ptr<ExecutorT> const pExecutor( new ExecutorT(func) ); + pExecutor->execute(); +#if ! defined(EXCEPTIONS_OFF) + if (pExecutor->m_exc.hasValue()) + ::cppu::throwException( pExecutor->m_exc ); +#endif + return *pExecutor->m_result; + } + +private: + explicit GenericSolarThreadExecutor( FuncT const& func ) + : m_exc(), m_func(func), m_result() {} + + virtual long doIt() + { +#if defined(EXCEPTIONS_OFF) + m_result.reset( m_func() ); +#else + try { + m_result.reset( m_func() ); + } + catch (::com::sun::star::uno::Exception &) { + // only UNO exceptions can be dispatched: + m_exc = ::cppu::getCaughtException(); + } +#endif + return 0; + } + + ::com::sun::star::uno::Any m_exc; + FuncT const m_func; + // using boost::optional here omits the need that ResultT is default + // constructable: + ::boost::optional<ResultT> m_result; +}; + +template <typename FuncT> +class GenericSolarThreadExecutor<FuncT, void> : public SolarThreadExecutor +{ +public: + static void exec( FuncT const& func ) + { + typedef GenericSolarThreadExecutor<FuncT, void> ExecutorT; + ::std::auto_ptr<ExecutorT> const pExecutor( new ExecutorT(func) ); + pExecutor->execute(); +#if ! defined(EXCEPTIONS_OFF) + if (pExecutor->m_exc.hasValue()) + ::cppu::throwException( pExecutor->m_exc ); +#endif + } + +private: + explicit GenericSolarThreadExecutor( FuncT const& func ) + : m_exc(), m_func(func) {} + + virtual long doIt() + { +#if defined(EXCEPTIONS_OFF) + m_func(); +#else + try { + m_func(); + } + catch (::com::sun::star::uno::Exception &) { + // only UNO exceptions can be dispatched: + m_exc = ::cppu::getCaughtException(); + } +#endif + return 0; + } + + ::com::sun::star::uno::Any m_exc; + FuncT const m_func; +}; + +template <typename T> +class copy_back_wrapper +{ +public: + operator T *() const { return &m_holder->m_value; } + operator T &() const { return m_holder->m_value; } + + explicit copy_back_wrapper( T * p ) : m_holder( new data_holder(p) ) {} + + // no thread-safe counting needed here, because calling thread blocks + // until solar thread has executed the functor. + copy_back_wrapper( copy_back_wrapper<T> const& r ) + : m_holder(r.m_holder) { ++m_holder->m_refCount; } + ~copy_back_wrapper() { + --m_holder->m_refCount; + if (m_holder->m_refCount == 0) { + delete m_holder; + } + } +private: + struct data_holder { + T m_value; + T * const m_ptr; + sal_Int32 m_refCount; + data_holder( T * p ) : m_value(*p), m_ptr(p), m_refCount(1) {} + ~data_holder() { *m_ptr = m_value; } + }; + data_holder * const m_holder; +}; + +} // namespace detail + +/** Makes a copy back reference wrapper to be used for inout parameters. + Only use for syncExecute(), the returned wrapper relies on its + implemenation, i.e. the function object is stored in free store. + Type T needs to be copy constructable assignable. + + @see syncExecute() + @param r reference to a stack variable + @return reference wrapper +*/ +template <typename T> +inline detail::copy_back_wrapper<T> inout_by_ref( T & r ) +{ + return detail::copy_back_wrapper<T>(&r); +} + +/** Makes a copy back ptr wrapper to be used for inout parameters. + Only use for syncExecute(), the returned wrapper relies on its + implemenation, i.e. the function object is stored in free store. + Type T needs to be copy constructable assignable. + + @see syncExecute() + @param p pointer to a stack variable + @return ptr wrapper +*/ +template <typename T> +inline detail::copy_back_wrapper<T> inout_by_ptr( T * p ) +{ + return detail::copy_back_wrapper<T>(p); +} + +/** This function will execute the passed functor synchronously in the + solar thread, thus the calling thread will (eventually) be blocked until + the functor has been called. + Any UNO exception that came up calling the functor in the solar thread + will be caught and rethrown in the calling thread. Any non-UNO + exception needs to be handled by the called functor. + The result type of this function needs to be default constructable. + Please keep in mind not to pass addresses to stack variables + (e.g. for out parameters) to foreign threads, use inout_by_ref() + for this purpose. For in parameters, this may not affect you, because + the functor object is copy constructed into free store. This way + you must not use boost::cref()/boost::ref() or similar for objects on + your thread's stack. + Use inout_by_ref() or inout_by_ptr() for this purpose, e.g. + + <pre> + using namespace vcl::solarthread; + + long n = 3; + // calling foo( long & r ): + syncExecute( boost::bind( &foo, inout_by_ref(n) ) ); + // calling foo( long * p ): + syncExecute( boost::bind( &foo, inout_by_ptr(&n) ) ); + + char const* pc = "default"; + // calling foo( char const** ppc ): + syncExecute( boost::bind( &foo, inout_by_ptr(&pc) ) ); + // calling foo( char const*& rpc ): + syncExecute( boost::bind( &foo, inout_by_ref(pc) ) ); + </pre> + + @tpl ResultT result type, defaults to FuncT::result_type to seamlessly + support mem_fn and bind + @tpl FuncT functor type, let your compiler deduce this type + @param func functor object to be executed in solar thread + @return return value of functor +*/ +template <typename ResultT, typename FuncT> +inline ResultT syncExecute( FuncT const& func ) +{ + return detail::GenericSolarThreadExecutor<FuncT, ResultT>::exec(func); +} + +template <typename FuncT> +inline typename FuncT::result_type syncExecute( FuncT const& func ) +{ + return detail::GenericSolarThreadExecutor< + FuncT, typename FuncT::result_type>::exec(func); +} + +} // namespace solarthread +} // namespace vcl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/throbber.hxx b/vcl/inc/vcl/throbber.hxx new file mode 100644 index 000000000000..ce45631d2fda --- /dev/null +++ b/vcl/inc/vcl/throbber.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VCL_THROBBER_HXX +#define VCL_THROBBER_HXX + +#include "vcl/dllapi.h" +#include "vcl/imgctrl.hxx" +#include "vcl/timer.hxx" + +#include <com/sun/star/graphic/XGraphic.hpp> + +#include <vector> + +class VCL_DLLPUBLIC Throbber : public ImageControl +{ +public: + enum ImageSet + { + /// no (default) images at all + IMAGES_NONE, + /// automatically decide between different image sets, depending on what fits best the actual size + IMAGES_AUTO, + /// default images, 16x16 pixels + IMAGES_16_PX, + /// default images, 32x32 pixels + IMAGES_32_PX, + /// default images, 64x64 pixels + IMAGES_64_PX, + }; + +public: + Throbber( Window* i_parentWindow, WinBits i_style, const ImageSet i_imageSet = IMAGES_AUTO ); + Throbber( Window* i_parentWindow, const ResId& i_resId, const ImageSet i_imageSet = IMAGES_AUTO ); + ~Throbber(); + + // Properties + void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } + sal_Int32 getStepTime() const { return mnStepTime; } + + void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } + sal_Bool getRepeat() const { return mbRepeat; } + + // animation control + void start(); + void stop(); + bool isRunning() const; + + void setImageList( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > >& ImageList ); + void setImageList( ::std::vector< Image > const& i_images ); + + // default images + static ::std::vector< ::rtl::OUString > + getDefaultImageURLs( const ImageSet i_imageSet ); + +protected: + // Window overridables + virtual void Resize(); + +private: + SAL_DLLPRIVATE void initImages(); + +private: + ::std::vector< Image > maImageList; + + sal_Bool mbRepeat; + sal_Int32 mnStepTime; + sal_Int32 mnCurStep; + sal_Int32 mnStepCount; + AutoTimer maWaitTimer; + ImageSet meImageSet; + + DECL_LINK( TimeOutHdl, void* ); +}; + +#endif // VCL_THROBBER_HXX + diff --git a/vcl/inc/vcl/timer.hxx b/vcl/inc/vcl/timer.hxx new file mode 100644 index 000000000000..efc4b00924a7 --- /dev/null +++ b/vcl/inc/vcl/timer.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TIMER_HXX +#define _SV_TIMER_HXX + +#include <tools/link.hxx> +#include <vcl/sv.h> +#include <vcl/dllapi.h> + +struct ImplTimerData; +struct ImplSVData; + +// --------- +// - Timer - +// --------- + +class VCL_DLLPUBLIC Timer +{ +protected: + ImplTimerData* mpTimerData; + sal_uLong mnTimeout; + sal_Bool mbActive; + sal_Bool mbAuto; + Link maTimeoutHdl; + +public: + Timer(); + Timer( const Timer& rTimer ); + virtual ~Timer(); + + virtual void Timeout(); + + void Start(); + void Stop(); + + void SetTimeout( sal_uLong nTimeout ); + sal_uLong GetTimeout() const { return mnTimeout; } + sal_Bool IsActive() const { return mbActive; } + + void SetTimeoutHdl( const Link& rLink ) { maTimeoutHdl = rLink; } + const Link& GetTimeoutHdl() const { return maTimeoutHdl; } + + Timer& operator=( const Timer& rTimer ); + +// #ifdef _SOLAR__PRIVATE + static void ImplDeInitTimer(); + static void ImplTimerCallbackProc(); +// #endif +}; + +// ------------- +// - AutoTimer - +// ------------- + +class VCL_DLLPUBLIC AutoTimer : public Timer +{ +public: + AutoTimer(); + AutoTimer( const AutoTimer& rTimer ); + + AutoTimer& operator=( const AutoTimer& rTimer ); +}; + +#endif // _SV_TIMER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/toolbox.h b/vcl/inc/vcl/toolbox.h new file mode 100644 index 000000000000..aec0c11cf790 --- /dev/null +++ b/vcl/inc/vcl/toolbox.h @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TOOLBOX_H +#define _SV_TOOLBOX_H + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <vcl/sv.h> +#include <vcl/image.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/controllayout.hxx> +#include <vcl/ImageListProvider.hxx> + +#include <vector> + +#define TB_DROPDOWNARROWWIDTH 11 + +#define TB_MENUBUTTON_SIZE 12 +#define TB_MENUBUTTON_OFFSET 2 + +#define TB_SMALLIMAGESIZE 16 + +#define TB_LARGEIMAGESIZE 26 +#define TB_LARGEIMAGESIZE_INDUSTRIAL 24 +#define TB_LARGEIMAGESIZE_CRYSTAL 22 +#define TB_LARGEIMAGESIZE_OXYGEN 22 + +class Window; + +// ---------------- +// - ImplToolItem - +// ---------------- + +struct ImplToolItem +{ + Window* mpWindow; + void* mpUserData; + Image maImage; + Image maHighImage; + long mnImageAngle; + bool mbMirrorMode; + XubString maText; + XubString maQuickHelpText; + XubString maHelpText; + String maCommandStr; + rtl::OString maHelpId; + Rectangle maRect; + Rectangle maCalcRect; + // the overall horizontal item size, including one or more of [image size + textlength + dropdown arrow] + Size maItemSize; + long mnSepSize; + long mnDropDownArrowWidth; + ToolBoxItemType meType; + ToolBoxItemBits mnBits; + TriState meState; + sal_uInt16 mnId; + sal_Bool mbEnabled:1, + mbVisible:1, + mbEmptyBtn:1, + mbShowWindow:1, + mbBreak:1, + mbVisibleText:1; // indicates if text will definitely be drawn, influences dropdown pos + + ImplToolItem(); + ImplToolItem( sal_uInt16 nItemId, const Image& rImage, + ToolBoxItemBits nItemBits ); + ImplToolItem( sal_uInt16 nItemId, const XubString& rTxt, + ToolBoxItemBits nItemBits ); + ImplToolItem( sal_uInt16 nItemId, const Image& rImage, + const XubString& rTxt, + ToolBoxItemBits nItemBits ); + ~ImplToolItem(); + + ImplToolItem( const ImplToolItem& ); + ImplToolItem& operator=(const ImplToolItem&); + + // returns the size of a item, taking toolbox orientation into account + // the default size is the precomputed size for standard items + // ie those that are just ordinary buttons (no windows or text etc.) + // bCheckMaxWidth indicates that item windows must not exceed maxWidth in which case they will be painted as buttons + Size GetSize( sal_Bool bHorz, sal_Bool bCheckMaxWidth, long maxWidth, const Size& rDefaultSize ); + + // only useful for buttons: returns if the text or image part or both can be drawn according to current button drawing style + void DetermineButtonDrawStyle( ButtonType eButtonType, sal_Bool& rbImage, sal_Bool& rbText ) const; + + // returns the rectangle which contains the drop down arrow + // or an empty rect if there is none + // bHorz denotes the toolbox alignment + Rectangle GetDropDownRect( sal_Bool bHorz ) const; + + // returns sal_True if the toolbar item is currently clipped, which can happen for docked toolbars + sal_Bool IsClipped() const; +}; + +namespace vcl +{ + +struct ToolBoxLayoutData : public ControlLayoutData +{ + std::vector< sal_uInt16 > m_aLineItemIds; + std::vector< sal_uInt16 > m_aLineItemPositions; +}; + + +} /* namespace vcl */ + + +struct ImplToolBoxPrivateData +{ + vcl::ToolBoxLayoutData* m_pLayoutData; + std::vector< ImplToolItem > m_aItems; + + ImplToolBoxPrivateData(); + ~ImplToolBoxPrivateData(); + + void ImplClearLayoutData() { delete m_pLayoutData; m_pLayoutData = NULL; } + + // called when dropdown items are clicked + Link maDropdownClickHdl; + Timer maDropdownTimer; // for opening dropdown items on "long click" + + // large or small buttons ? + ToolBoxButtonSize meButtonSize; + + // the optional custom menu + PopupMenu* mpMenu; + sal_uInt16 maMenuType; + sal_uIntPtr mnEventId; + + // called when menu button is clicked and before the popup menu is executed + Link maMenuButtonHdl; + + // a dummy item representing the custom menu button + ImplToolItem maMenubuttonItem; + long mnMenuButtonWidth; + + Wallpaper maDisplayBackground; + + // support for highcontrast + vcl::IImageListProvider* mpImageListProvider; + vcl::ImageListType meImageListType; + + sal_Bool mbIsLocked:1, // keeps last lock state from ImplDockingWindowWrapper + mbAssumeDocked:1, // only used during calculations to override current floating/popup mode + mbAssumeFloating:1, + mbAssumePopupMode:1, + mbKeyInputDisabled:1, // no KEY input if all items disabled, closing/docking will be allowed though + mbIsPaintLocked:1, // don't allow paints + mbMenubuttonSelected:1, // menu button is highlighted + mbPageScroll:1, // determines if we scroll a page at a time + mbNativeButtons:1, // system supports native toolbar buttons + mbWillUsePopupMode:1, // this toolbox will be opened in popup mode + mbDropDownByKeyboard:1; // tells whether a dropdown was started by key input +}; + + +#endif // _SV_TOOLBOX_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/toolbox.hxx b/vcl/inc/vcl/toolbox.hxx new file mode 100644 index 000000000000..ccd7c229346b --- /dev/null +++ b/vcl/inc/vcl/toolbox.hxx @@ -0,0 +1,681 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_TOOLBOX_HXX +#define _SV_TOOLBOX_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/dockwin.hxx> +#include <vcl/image.hxx> +#include <vcl/timer.hxx> +#include <vcl/virdev.hxx> + +class UserDrawEvent; + +struct ImplToolItem; +struct ImplToolSizeArray; +struct ImplToolSize; +struct ImplToolBoxPrivateData; +class ImplTrackRect; +class PopupMenu; + +namespace vcl +{ + class IImageListProvider; +} + +// ------------------------- +// - ToolBoxCustomizeEvent - +// ------------------------- + +#define TOOLBOX_CUSTOMIZE_RESIZE ((sal_uInt16)0xFFFE) + +class VCL_DLLPUBLIC ToolBoxCustomizeEvent +{ +private: + ToolBox* mpTargetBox; + void* mpData; + sal_uInt16 mnIdFrom; + sal_uInt16 mnPosTo; + +public: + ToolBoxCustomizeEvent(); + ToolBoxCustomizeEvent( ToolBox* pDropBox, + sal_uInt16 nId, sal_uInt16 nPos = 0, + void* pUserData = NULL ); + + ToolBox* GetTargetBox() const { return mpTargetBox; } + sal_uInt16 GetTargetPos() const { return mnPosTo; } + sal_uInt16 GetSourceId() const { return mnIdFrom; } + void* GetData() const { return mpData; } + sal_Bool IsResized() const; +}; + +inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent() +{ + mpTargetBox = NULL; + mnIdFrom = 0; + mnPosTo = 0; + mpData = NULL; +} + +inline ToolBoxCustomizeEvent::ToolBoxCustomizeEvent( ToolBox* pDropBox, + sal_uInt16 nId, sal_uInt16 nPos, + void* pUserData ) +{ + mpTargetBox = pDropBox; + mnIdFrom = nId; + mnPosTo = nPos; + mpData = pUserData; +} + +inline sal_Bool ToolBoxCustomizeEvent::IsResized() const +{ + if ( mnPosTo == TOOLBOX_CUSTOMIZE_RESIZE ) + return sal_True; + else + return sal_False; +} + +// ------------------- +// - ToolBoxItemBits - +// ------------------- + +typedef sal_uInt16 ToolBoxItemBits; + +// -------------------------- +// - Bits fuer ToolBoxItems - +// -------------------------- + +// By changes you must also change: rsc/vclrsc.hxx +#define TIB_CHECKABLE ((ToolBoxItemBits)0x0001) +#define TIB_RADIOCHECK ((ToolBoxItemBits)0x0002) +#define TIB_AUTOCHECK ((ToolBoxItemBits)0x0004) +#define TIB_LEFT ((ToolBoxItemBits)0x0008) +#define TIB_AUTOSIZE ((ToolBoxItemBits)0x0010) +#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 - +// ----------------- + +#define TOOLBOX_STYLE_OUTBUTTON ((sal_uInt16)0x0001) +#define TOOLBOX_STYLE_HANDPOINTER ((sal_uInt16)0x0002) +#define TOOLBOX_STYLE_FLAT ((sal_uInt16)0x0004) + +#define TOOLBOX_APPEND ((sal_uInt16)0xFFFF) +#define TOOLBOX_ITEM_NOTFOUND ((sal_uInt16)0xFFFF) + +// item ids in the custom menu may not exceed this constant +#define TOOLBOX_MENUITEM_START ((sal_uInt16)0xE000) + +// defines for the menubutton +#define TOOLBOX_MENUTYPE_NONE ((sal_uInt16)0x0000) // no menu at all, scrolling by spin buttons +#define TOOLBOX_MENUTYPE_CLIPPEDITEMS ((sal_uInt16)0x0001) // menu will contain "more" indicator +#define TOOLBOX_MENUTYPE_CUSTOMIZE ((sal_uInt16)0x0002) // menu will contain "customization" and "more" indicator + +// By changes you must also change: rsc/vclrsc.hxx +enum ButtonType { BUTTON_SYMBOL, BUTTON_TEXT, BUTTON_SYMBOLTEXT }; + +// By changes you must also change: rsc/vclrsc.hxx +enum ToolBoxItemType { TOOLBOXITEM_DONTKNOW, TOOLBOXITEM_BUTTON, + TOOLBOXITEM_SPACE, TOOLBOXITEM_SEPARATOR, + TOOLBOXITEM_BREAK }; + +// small or large force an exact toolbox size for proper alignemnt +// dontcare will let the toolbox decide about its size +enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, TOOLBOX_BUTTONSIZE_LARGE }; + +// used for internal sizing calculations +enum FloatingSizeMode { FSMODE_AUTO, FSMODE_FAVOURWIDTH, FSMODE_FAVOURHEIGHT }; + +// ----------- +// - ToolBox - +// ----------- + +class VCL_DLLPUBLIC ToolBox : public DockingWindow +{ + friend class FloatingWindow; + friend class ImplTBDragMgr; + +private: + ImplToolBoxPrivateData* mpData; + VirtualDevice* mpBtnDev; // TODO: remove unused member + ImplToolSizeArray* mpFloatSizeAry; + XubString maCvtStr; + XubString maNextToolBoxStr; + ImageList maImageList; + Timer maTimer; + Rectangle maUpperRect; + Rectangle maLowerRect; + Rectangle maNextToolRect; + Rectangle maOutDockRect; + Rectangle maInDockRect; + Rectangle maPaintRect; + FloatingWindow* mpFloatWin; + sal_uInt16 mnKeyModifier; + long mnDX; + long mnDY; + long mnMaxItemWidth; // max item width + long mnMaxItemHeight; // max item height (for standard items) + long mnWinHeight; // max window height (for window items) + long mnBorderX; // custom border + long mnBorderY; + long mnLeftBorder; // inner border + long mnTopBorder; + long mnRightBorder; + long mnBottomBorder; + long mnLastResizeDY; + long mnActivateCount; + sal_uInt16 mnLastFocusItemId; + sal_uInt16 mnFocusPos; + sal_uInt16 mnOutStyle; + sal_uInt16 mnHighItemId; + sal_uInt16 mnCurItemId; + sal_uInt16 mnDownItemId; + sal_uInt16 mnCurPos; + sal_uInt16 mnLines; // total number of toolbox lines + sal_uInt16 mnCurLine; // the currently visible line + sal_uInt16 mnCurLines; // number of lines due to line breaking + sal_uInt16 mnVisLines; // number of visible lines (for scrolling) + sal_uInt16 mnFloatLines; // number of lines during floating mode + sal_uInt16 mnDockLines; + sal_uInt16 mnConfigItem; + sal_uInt16 mnMouseClicks; + sal_uInt16 mnMouseModifier; + unsigned int mbDrag:1, + mbSelection:1, + mbCommandDrag:1, + mbUpper:1, + mbLower:1, + mbNextTool:1, + mbIn:1, + mbCalc:1, + mbFormat:1, + mbFullPaint:1, + mbHorz:1, + mbScroll:1, + mbLastFloatMode:1, + mbCustomize:1, + mbCustomizeMode:1, + mbDragging:1, + mbMenuStrings:1, + mbIsShift:1, + mbIsKeyEvent:1, + mbChangingHighlight:1; + WindowAlign meAlign; + WindowAlign meDockAlign; + ButtonType meButtonType; + PointerStyle meLastStyle; + WinBits mnWinStyle; + Link maClickHdl; + Link maDoubleClickHdl; + Link maActivateHdl; + Link maDeactivateHdl; + Link maHighlightHdl; + Link maSelectHdl; + Link maNextToolBoxHdl; + + public: + using Window::ImplInit; + private: + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + using DockingWindow::ImplInitSettings; + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE ImplToolItem* ImplGetItem( sal_uInt16 nId ) const; + SAL_DLLPRIVATE sal_Bool ImplCalcItem(); + SAL_DLLPRIVATE sal_uInt16 ImplCalcBreaks( long nWidth, long* pMaxLineWidth, sal_Bool bCalcHorz ); + SAL_DLLPRIVATE void ImplFormat( sal_Bool bResize = sal_False ); + SAL_DLLPRIVATE void ImplDrawSpin( sal_Bool bUpperIn, sal_Bool bLowerIn ); + SAL_DLLPRIVATE void ImplDrawNext( sal_Bool bIn ); + SAL_DLLPRIVATE void ImplDrawSeparator( sal_uInt16 nPos, Rectangle rRect ); + SAL_DLLPRIVATE void ImplDrawItem( sal_uInt16 nPos, sal_Bool bHighlight = sal_False, sal_Bool bPaint = sal_False, sal_Bool bLayout = sal_False ); + using Window::ImplInvalidate; + SAL_DLLPRIVATE void ImplInvalidate( sal_Bool bNewCalc = sal_False, sal_Bool bFullPaint = sal_False ); + SAL_DLLPRIVATE void ImplUpdateItem( sal_uInt16 nIndex = 0xFFFF ); + SAL_DLLPRIVATE void ImplStartCustomizeMode(); + SAL_DLLPRIVATE void ImplEndCustomizeMode(); + SAL_DLLPRIVATE const XubString& ImplConvertMenuString( const XubString& rStr ); + SAL_DLLPRIVATE sal_Bool ImplHandleMouseMove( const MouseEvent& rMEvt, sal_Bool bRepeat = sal_False ); + SAL_DLLPRIVATE sal_Bool ImplHandleMouseButtonUp( const MouseEvent& rMEvt, sal_Bool bCancel = sal_False ); + SAL_DLLPRIVATE void ImplChangeHighlight( ImplToolItem* pItem, sal_Bool bNoGrabFocus = sal_False ); + SAL_DLLPRIVATE sal_Bool ImplChangeHighlightUpDn( sal_Bool bUp, sal_Bool bNoCycle = sal_False ); + SAL_DLLPRIVATE sal_uInt16 ImplGetItemLine( ImplToolItem* pCurrentItem ); + SAL_DLLPRIVATE ImplToolItem* ImplGetFirstValidItem( sal_uInt16 nLine ); + SAL_DLLPRIVATE ImplToolItem* ImplGetLastValidItem( sal_uInt16 nLine ); + SAL_DLLPRIVATE sal_Bool ImplOpenItem( KeyCode aKeyCode ); + SAL_DLLPRIVATE sal_Bool ImplActivateItem( KeyCode aKeyCode ); + SAL_DLLPRIVATE void ImplShowFocus(); + SAL_DLLPRIVATE void ImplHideFocus(); + SAL_DLLPRIVATE void ImplUpdateInputEnable(); + SAL_DLLPRIVATE void ImplFillLayoutData() const; + SAL_DLLPRIVATE void ImplUpdateCustomMenu(); + SAL_DLLPRIVATE sal_Bool ImplHasClippedItems(); + SAL_DLLPRIVATE Point ImplGetPopupPosition( const Rectangle& rRect, const Size& rSize ) const; + SAL_DLLPRIVATE void ImplExecuteCustomMenu(); + SAL_DLLPRIVATE sal_Bool ImplIsFloatingMode() const; + SAL_DLLPRIVATE sal_Bool ImplIsInPopupMode() const; + SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const; + SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize( FloatingSizeMode eMode ); + SAL_DLLPRIVATE sal_Bool ImplHasExternalMenubutton(); + SAL_DLLPRIVATE void ImplDrawFloatwinBorder( ImplToolItem* pItem ); + + DECL_DLLPRIVATE_LINK( ImplCallExecuteCustomMenu, void* ); + DECL_DLLPRIVATE_LINK( ImplUpdateHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplResetAutoSizeTriesHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent* ); + DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, ToolBox* ); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE ToolBox (const ToolBox &); + SAL_DLLPRIVATE ToolBox& operator= (const ToolBox &); + + SAL_DLLPRIVATE void ImplUpdateImageList(); // called if StateChanged +public: + SAL_DLLPRIVATE void ImplFloatControl( sal_Bool bStart, FloatingWindow* pWindow = NULL ); + SAL_DLLPRIVATE void ImplDisableFlatButtons(); + + static SAL_DLLPRIVATE int ImplGetDragWidth( ToolBox* pThis ); + static SAL_DLLPRIVATE void ImplUpdateDragArea( ToolBox *pThis ); + static SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop, + long& rRight, long& rBottom, const ToolBox *pThis ); + static SAL_DLLPRIVATE void ImplDrawGrip( ToolBox* pThis ); + static SAL_DLLPRIVATE void ImplDrawGradientBackground( ToolBox* pThis, ImplDockingWindowWrapper *pWrapper ); + static SAL_DLLPRIVATE sal_Bool ImplDrawNativeBackground( ToolBox* pThis, const Region &rRegion ); + static SAL_DLLPRIVATE void ImplDrawTransparentBackground( ToolBox* pThis, const Region &rRegion ); + static SAL_DLLPRIVATE void ImplDrawConstantBackground( ToolBox* pThis, const Region &rRegion, sal_Bool bIsInPopupMode ); + static SAL_DLLPRIVATE void ImplDrawBackground( ToolBox* pThis, const Rectangle &rRect ); + static SAL_DLLPRIVATE void ImplErase( ToolBox* pThis, const Rectangle &rRect, sal_Bool bHighlight = sal_False, sal_Bool bHasOpenPopup = sal_False ); + static SAL_DLLPRIVATE void ImplDrawBorder( ToolBox* pWin ); + static SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem( const ToolBox* pThis ); + static SAL_DLLPRIVATE Size ImplCalcSize( const ToolBox* pThis, sal_uInt16 nCalcLines, sal_uInt16 nCalcMode = 0 ); + static SAL_DLLPRIVATE void ImplCalcFloatSizes( ToolBox* pThis ); + static SAL_DLLPRIVATE Size ImplCalcFloatSize( ToolBox* pThis, sal_uInt16& rLines ); + static SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( ToolBox* pThis, Size& rMinSize, Size& rMaxSize ); + static SAL_DLLPRIVATE void ImplSetMinMaxFloatSize( ToolBox *pThis ); + static SAL_DLLPRIVATE sal_uInt16 ImplCalcLines( ToolBox* pThis, long nToolSize ); + static SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( ToolBox* pThis, const Point& rPos ); + static SAL_DLLPRIVATE void ImplLineSizing( ToolBox* pThis, const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode ); + static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( ToolBox* pBox, const Point& rPos ); + static SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const ImplToolItem* pItem, const std::vector< ImplToolItem >& rList ); + static SAL_DLLPRIVATE void ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, sal_Bool bBlack, sal_Bool bColTransform, + sal_Bool bLeft = sal_False, sal_Bool bTop = sal_False, + long nSize = 6 ); + static SAL_DLLPRIVATE void SetToolArrowClipregion( ToolBox* pBox, long nX, long nY, + sal_Bool bLeft = sal_False, sal_Bool bTop = sal_False, + long nSize = 6 ); + static SAL_DLLPRIVATE void ImplDrawMenubutton( ToolBox *pThis, sal_Bool bHighlight ); + static SAL_DLLPRIVATE sal_uInt16 ImplCountLineBreaks( const ToolBox *pThis ); + SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData; } + +protected: + void SetCurItemId(sal_uInt16 nSet) { mnCurItemId = nSet; } + +public: + ToolBox( Window* pParent, WinBits nStyle = 0 ); + ToolBox( Window* pParent, const ResId& rResId ); + ~ToolBox(); + + virtual void Click(); + virtual void DoubleClick(); + virtual void Activate(); + virtual void Deactivate(); + virtual void Highlight(); + virtual void Select(); + virtual void NextToolBox(); + virtual void Customize( const ToolBoxCustomizeEvent& rCEvt ); + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Move(); + virtual void Resize(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void StateChanged( StateChangedType nType ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void KeyInput( const KeyEvent& rKEvt ); + + virtual sal_Bool PrepareToggleFloatingMode(); + virtual void ToggleFloatingMode(); + virtual void StartDocking(); + virtual sal_Bool Docking( const Point& rPos, Rectangle& rRect ); + virtual void EndDocking( const Rectangle& rRect, sal_Bool bFloatMode ); + virtual void Resizing( Size& rSize ); + + void InsertItem( const ResId& rResId, + sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + ToolBoxItemBits nBits = 0, + sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + const XubString& rText, + ToolBoxItemBits nBits = 0, + sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertItem( sal_uInt16 nItemId, const XubString& rText, + ToolBoxItemBits nBits = 0, + sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertWindow( sal_uInt16 nItemId, Window* pWindow, + ToolBoxItemBits nBits = 0, + sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertSpace( sal_uInt16 nPos = TOOLBOX_APPEND ); + void InsertSeparator( sal_uInt16 nPos = TOOLBOX_APPEND, + sal_uInt16 nPixSize = 0 ); + void InsertBreak( sal_uInt16 nPos = TOOLBOX_APPEND ); + void RemoveItem( sal_uInt16 nPos ); + void MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos = TOOLBOX_APPEND ); + void CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId, + sal_uInt16 nNewPos = TOOLBOX_APPEND ); + void CopyItems( const ToolBox& rToolBox ); + void Clear(); + void RecalcItems(); + + const ImageList& GetImageList() const { return maImageList; } + void SetImageList( const ImageList& rImageList ); + + void SetButtonType( ButtonType eNewType = BUTTON_SYMBOL ); + ButtonType GetButtonType() const { return meButtonType; } + + // sets a fixed button size (small, large or dontcare (==autosize)) + void SetToolboxButtonSize( ToolBoxButtonSize eSize ); + ToolBoxButtonSize GetToolboxButtonSize() const; + + void SetAlign( WindowAlign eNewAlign = WINDOWALIGN_TOP ); + WindowAlign GetAlign() const { return meAlign; } + sal_Bool IsHorizontal() const { return mbHorz; } + + void SetLineCount( sal_uInt16 nNewLines ); + sal_uInt16 GetLineCount() const { return mnLines; } + sal_uInt16 GetCurLine() const { return mnCurLine; } + void ShowLine( sal_Bool bNext ); + + // Used to enable/disable scrolling one page at a time for toolbar + void SetPageScroll( sal_Bool b ); + sal_Bool GetPageScroll(); + + void SetNextToolBox( const XubString& rStr ); + const XubString& GetNextToolBox() const { return maNextToolBoxStr; } + + sal_uInt16 GetItemCount() const; + ToolBoxItemType GetItemType( sal_uInt16 nPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + sal_uInt16 GetItemPos( const Point& rPos ) const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + Rectangle GetItemRect( sal_uInt16 nItemId ) const; + Rectangle GetItemPosRect( sal_uInt16 nPos ) const; + Rectangle GetItemDropDownRect( sal_uInt16 nItemId ) const; + Rectangle GetItemPosDropDownRect( sal_uInt16 nPos ) const; + + // retrieves the optimal position to place a popup window for this item (subtoolbar or dropdown) + Point GetItemPopupPosition( sal_uInt16 nItemId, const Size& rSize ) const; + + Rectangle GetScrollRect() const; + Rectangle GetMenubuttonRect() const; + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + sal_uInt16 GetDownItemId() const { return mnDownItemId; } + sal_uInt16 GetClicks() const { return mnMouseClicks; } + sal_uInt16 GetModifier() const { return mnMouseModifier; } + sal_uInt16 GetKeyModifier() const { return mnKeyModifier; } + + void SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ); + ToolBoxItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetItemData( sal_uInt16 nItemId, void* pNewData ); + void* GetItemData( sal_uInt16 nItemId ) const; + void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemImage( sal_uInt16 nItemId ) const; + void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); + long GetItemImageAngle( sal_uInt16 nItemId ) const; + void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror ); + sal_Bool GetItemImageMirrorMode( sal_uInt16 ) const; + void SetItemHighImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemHighImage( sal_uInt16 nItemId ) const; + void SetItemText( sal_uInt16 nItemId, const XubString& rText ); + const XubString& GetItemText( sal_uInt16 nItemId ) const; + void SetItemWindow( sal_uInt16 nItemId, Window* pNewWindow ); + Window* GetItemWindow( sal_uInt16 nItemId ) const; + sal_uInt16 GetHighlightItemId() const { return mnHighItemId; } + + void StartSelection(); + void EndSelection(); + + void SetItemDown( sal_uInt16 nItemId, sal_Bool bDown, sal_Bool bRelease = sal_True ); + sal_Bool IsItemDown( sal_uInt16 nItemId ) const; + + void SetItemState( sal_uInt16 nItemId, TriState eState ); + TriState GetItemState( sal_uInt16 nItemId ) const; + + void CheckItem( sal_uInt16 nItemId, sal_Bool bCheck = sal_True ); + sal_Bool IsItemChecked( sal_uInt16 nItemId ) const; + + void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable = sal_True ); + sal_Bool IsItemEnabled( sal_uInt16 nItemId ) const; + + void TriggerItem( sal_uInt16 nItemId, sal_Bool bShift = sal_False, sal_Bool bCtrl = sal_False ); + void ShowItem( sal_uInt16 nItemId, sal_Bool bVisible = sal_True ); + void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, sal_False ); } + sal_Bool IsItemVisible( sal_uInt16 nItemId ) const; + sal_Bool IsItemReallyVisible( sal_uInt16 nItemId ) const; + + void SetItemCommand( sal_uInt16 nItemId, const XubString& rCommand ); + const XubString& GetItemCommand( sal_uInt16 nItemId ) const; + + using Window::SetQuickHelpText; + void SetQuickHelpText( sal_uInt16 nItemId, const XubString& rText ); + using Window::GetQuickHelpText; + const XubString& GetQuickHelpText( sal_uInt16 nItemId ) const; + + void SetHelpText( sal_uInt16 nItemId, const XubString& rText ); + const XubString& GetHelpText( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const rtl::OString& rHelpId ); + rtl::OString GetHelpId( sal_uInt16 nItemId ) const; + + // window size according to current alignment, floating state and number of lines + Size CalcWindowSizePixel() const; + // window size according to current alignment, floating state and a given number of lines + Size CalcWindowSizePixel( sal_uInt16 nCalcLines ) const; + // window size according to current floating state and a given number of lines and a given alignment + Size CalcWindowSizePixel( sal_uInt16 nCalcLines, WindowAlign eAlign ) const; + // floating window size according to number of lines (uses the number of line breaks) + Size CalcFloatingWindowSizePixel() const; + // floating window size with a given number of lines + Size CalcFloatingWindowSizePixel( sal_uInt16 nCalcLines ) const; + // automatic window size for popoup mode + Size CalcPopupWindowSizePixel() const; + + // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button) + Size CalcMinimumWindowSizePixel() const; + + void SetDockingRects( const Rectangle& rOutRect, + const Rectangle& rInRect ); + void SetFloatingLines( sal_uInt16 nFloatLines ); + sal_uInt16 GetFloatingLines() const; + + void SetBorder( long nX, long nY ); + long GetBorderX() const { return mnBorderX; } + long GetBorderY() const { return mnBorderY; } + + void SetStyle( WinBits nNewStyle ) { mnWinStyle = nNewStyle; } + WinBits GetStyle() const { return mnWinStyle; } + + // enable/disable undocking + void Lock( sal_Bool bLock = sal_True ); + + // read configuration to determine locking behaviour + static sal_Bool AlwaysLocked(); + + void EnableMenuStrings( sal_Bool bEnable = sal_True ) { mbMenuStrings = (bEnable != 0); } + sal_Bool IsMenuStringsEnabled() const { return mbMenuStrings; } + + void SetOutStyle( sal_uInt16 nNewStyle ); + sal_uInt16 GetOutStyle() const { return mnOutStyle; } + + void EnableCustomize( sal_Bool bEnable = sal_True ); + sal_Bool IsCustomize() { return mbCustomize; } + void StartCustomize( const Rectangle& rRect, void* pData = NULL ); + void SetCustomizeMode( sal_Bool ); + sal_Bool IsInCustomizeMode() const { return mbCustomizeMode; } + + static void StartCustomizeMode(); + static void EndCustomizeMode(); + static sal_Bool IsCustomizeMode(); + + void SetHelpText( const XubString& rText ) + { DockingWindow::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return DockingWindow::GetHelpText(); } + + void SetHelpId( const rtl::OString& rId ) + { DockingWindow::SetHelpId( rId ); } + const rtl::OString& GetHelpId() const + { return DockingWindow::GetHelpId(); } + + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } + void SetDoubleClickHdl( const Link& rLink ) { maDoubleClickHdl = rLink; } + const Link& GetDoubleClickHdl() const { return maDoubleClickHdl; } + void SetDropdownClickHdl( const Link& rLink ); + const Link& GetDropdownClickHdl() const; + 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 SetHighlightHdl( const Link& rLink ) { maHighlightHdl = rLink; } + const Link& GetHighlightHdl() const { return maHighlightHdl; } + void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; } + const Link& GetSelectHdl() const { return maSelectHdl; } + void SetNextToolBoxHdl( const Link& rLink ) { maNextToolBoxHdl = rLink; } + const Link& GetNextToolBoxHdl() const { return maNextToolBoxHdl; } + + // support for custom menu (eg for configuration) + // note: this menu will also be used to display currently + // clipped toolbox items, so you should only touch + // items that you added by yourself + // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START + // to allow for customization of the menu the coresponding handler is called + // when the menu button was clicked and before the menu is executed + void SetMenuType( sal_uInt16 aType = TOOLBOX_MENUTYPE_CUSTOMIZE ); + sal_uInt16 GetMenuType() const; + sal_Bool IsMenuEnabled() const; + PopupMenu* GetMenu() const; + void SetMenuButtonHdl( const Link& rLink ); + const Link& GetMenuButtonHdl() const; + + // open custommenu + void ExecuteCustomMenu(); + + // allow Click Handler to detect special key + bool IsShift() const { return mbIsShift; } + // allow Click Handler to distinguish between mouse and key input + sal_Bool IsKeyEvent() const { return mbIsKeyEvent; } + + // allows framework to set/query the planned popupmode + sal_Bool WillUsePopupMode() const; + void WillUsePopupMode( sal_Bool b); + + // accessibility helpers + + // gets the displayed text + String GetDisplayText() const; + // returns the bounding box for the character at index nIndex + // where nIndex is relative to the starting index of the item + // with id nItemId (in coordinates of the displaying window) + Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const; + // -1 is returned if no character is at that point + // if an index is found the corresponding item id is filled in (else 0) + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const; + // returns the number of portions in the result of GetDisplayText() + long GetTextCount() const; + // returns the interval [start,end] of text portion nText + // returns [-1,-1] for an invalid text number + Pair GetTextStartEnd( long nText ) const; + // returns the item id for text portion nText or 0 if nText is invalid + sal_uInt16 GetDisplayItemId( long nText ) const; + + const Size& GetDefaultImageSize() const; + void ChangeHighlight( sal_uInt16 nPos ); + + void SetImageListProvider(vcl::IImageListProvider* _pProvider); +}; + +inline void ToolBox::CheckItem( sal_uInt16 nItemId, sal_Bool bCheck ) +{ + SetItemState( nItemId, (bCheck) ? STATE_CHECK : STATE_NOCHECK ); +} + +inline sal_Bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const +{ + return (GetItemState( nItemId ) == STATE_CHECK); +} + +inline Size ToolBox::CalcWindowSizePixel() const +{ + return CalcWindowSizePixel( mnLines ); +} + +inline Rectangle ToolBox::GetScrollRect() const +{ + return maUpperRect.GetUnion( maLowerRect ); +} + +inline void ToolBox::SetDockingRects( const Rectangle& rOutRect, + const Rectangle& rInRect ) +{ + maOutDockRect = rOutRect; + maInDockRect = rInRect; +} + +inline void ToolBox::SetFloatingLines( sal_uInt16 nNewLines ) +{ + mnFloatLines = nNewLines; +} + +inline sal_uInt16 ToolBox::GetFloatingLines() const +{ + return mnFloatLines; +} + +#endif // _SV_TOOLBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/unobrok.hxx b/vcl/inc/vcl/unobrok.hxx new file mode 100644 index 000000000000..67c83ea83952 --- /dev/null +++ b/vcl/inc/vcl/unobrok.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNOBROK_HXX +#define _UNOBROK_HXX + +#include <vcl/svdata.hxx> +#include <osl/thread.hxx> + +namespace vcl_accept +{ + sal_Bool accept(const ::rtl::OUString & accDcp, const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> & rSMgr); +} + +#endif // _UNOBROK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/unohelp.hxx b/vcl/inc/vcl/unohelp.hxx new file mode 100644 index 000000000000..823ee477355a --- /dev/null +++ b/vcl/inc/vcl/unohelp.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_UNOHELP_HXX +#define _VCL_UNOHELP_HXX + +#include <com/sun/star/uno/Reference.h> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XCharacterClassification; + class XCollator; +} +namespace lang { + class XMultiServiceFactory; +} +}}} + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + struct AccessibleEventObject; +} +}}} + +namespace comphelper { + namespace string { + class NaturalStringSorter; +}} + +namespace vcl +{ +namespace unohelper +{ +VCL_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > GetMultiServiceFactory(); +VCL_DLLPUBLIC ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > CreateBreakIterator(); +VCL_DLLPUBLIC ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XCharacterClassification> CreateCharacterClassification(); +//Get access to singleton Natural String Sorter collating for Application::GetLocale +VCL_DLLPUBLIC const comphelper::string::NaturalStringSorter& getNaturalStringSorterForAppLocale(); +VCL_DLLPUBLIC ::rtl::OUString CreateLibraryName( const sal_Char* pModName, sal_Bool bSUPD ); +VCL_DLLPUBLIC void NotifyAccessibleStateEventGlobally( const ::com::sun::star::accessibility::AccessibleEventObject& rEventObject ); +}} // namespace vcl::unohelper + +#endif // _VCL_UNOHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/unohelp2.hxx b/vcl/inc/vcl/unohelp2.hxx new file mode 100644 index 000000000000..5824f016c57c --- /dev/null +++ b/vcl/inc/vcl/unohelp2.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_UNOHELP2_HXX +#define _VCL_UNOHELP2_HXX + +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <cppuhelper/weak.hxx> +#include <tools/string.hxx> +#include <osl/mutex.hxx> + +namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard { + class XClipboard; +} } } } } +#include <vcl/dllapi.h> + +namespace vcl { namespace unohelper { + + class VCL_DLLPUBLIC TextDataObject : + public ::com::sun::star::datatransfer::XTransferable, + public ::cppu::OWeakObject + { + private: + String maText; + + public: + TextDataObject( const String& rText ); + ~TextDataObject(); + + String& GetString() { return maText; } + + // ::com::sun::star::uno::XInterface + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + void SAL_CALL release() throw() { OWeakObject::release(); } + + // ::com::sun::star::datatransfer::XTransferable + ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::uno::RuntimeException); + + /// copies a given string to a given clipboard + static void CopyStringTo( + const String& rContent, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard + ); + }; + + struct MutexHelper + { + private: + ::osl::Mutex maMutex; + public: + ::osl::Mutex& GetMutex() { return maMutex; } + }; + +}} // namespace vcl::unohelper + +#endif // _VCL_UNOHELP2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/unowrap.hxx b/vcl/inc/vcl/unowrap.hxx new file mode 100644 index 000000000000..3691014d7477 --- /dev/null +++ b/vcl/inc/vcl/unowrap.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_UNOWRAP_HXX +#define _VCL_UNOWRAP_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <com/sun/star/uno/Reference.h> + +class XWindowPeer; +class XToolkit; +class XVclToolkit; +class EventList; +class Window; +class OutputDevice; +class MouseEvent; +class CommandEvent; +class KeyEvent; +class Rectangle; +class XVclComponentPeer; +class Menu; + +namespace com { +namespace sun { +namespace star { +namespace awt { + class XGraphics; + class XToolkit; + class XWindowPeer; +} +namespace lang { + class XMultiServiceFactory; +} +} } } + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + class XAccessible; +}}}} + +class VCL_DLLPUBLIC UnoWrapperBase +{ +public: + virtual void Destroy() = 0; + + // Toolkit + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > GetVCLToolkit() = 0; + + // Graphics + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > CreateGraphics( OutputDevice* pOutDev ) = 0; + virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) = 0; + + // Window + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer> GetWindowInterface( Window* pWindow, sal_Bool bCreate ) = 0; + virtual void SetWindowInterface( Window* pWindow, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace ) = 0; + + virtual void WindowDestroyed( Window* pWindow ) = 0; + + // Accessibility + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + CreateAccessible( Menu* pMenu, sal_Bool bIsMenuBar ) = 0; +}; + +#endif // _VCL_UNOWRAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/vclenum.hxx b/vcl/inc/vcl/vclenum.hxx new file mode 100644 index 000000000000..80b84b2fb0f2 --- /dev/null +++ b/vcl/inc/vcl/vclenum.hxx @@ -0,0 +1,331 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_VCLENUM_HXX +#define _VCL_VCLENUM_HXX + +#include <sal/types.h> +#include <tools/solar.h> + +#ifndef ENUM_TIMEFIELDFORMAT_DECLARED +#define ENUM_TIMEFIELDFORMAT_DECLARED + +// By changes you must also change: rsc/vclrsc.hxx +enum TimeFieldFormat {TIMEF_NONE, TIMEF_SEC, TIMEF_100TH_SEC, TIMEF_SEC_CS, TimeFieldFormat_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_EXTTIMEFIELDFORMAT_DECLARED +#define ENUM_EXTTIMEFIELDFORMAT_DECLARED + +enum ExtTimeFieldFormat { EXTTIMEF_24H_SHORT, EXTTIMEF_24H_LONG, + EXTTIMEF_12H_SHORT, EXTTIMEF_12H_LONG, + EXTTIMEF_DURATION_SHORT, EXTTIMEF_DURATION_LONG }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_EXTDATEFIELDFORMAT_DECLARED +#define ENUM_EXTDATEFIELDFORMAT_DECLARED + +enum ExtDateFieldFormat { XTDATEF_SYSTEM_SHORT, XTDATEF_SYSTEM_SHORT_YY, XTDATEF_SYSTEM_SHORT_YYYY, + XTDATEF_SYSTEM_LONG, + XTDATEF_SHORT_DDMMYY, XTDATEF_SHORT_MMDDYY, XTDATEF_SHORT_YYMMDD, + XTDATEF_SHORT_DDMMYYYY, XTDATEF_SHORT_MMDDYYYY, XTDATEF_SHORT_YYYYMMDD, + XTDATEF_SHORT_YYMMDD_DIN5008, XTDATEF_SHORT_YYYYMMDD_DIN5008, ExtDateFieldFormat_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +// to avoid conflicts with enum's declared otherwise +#define GRADIENT_LINEAR GradientStyle_LINEAR +#define GRADIENT_AXIAL GradientStyle_AXIAL +#define GRADIENT_RADIAL GradientStyle_RADIAL +#define GRADIENT_ELLIPTICAL GradientStyle_ELLIPTICAL +#define GRADIENT_SQUARE GradientStyle_SQUARE +#define GRADIENT_RECT GradientStyle_RECT +#define GRADIENT_FORCE_EQUAL_SIZE GradientStyle_FORCE_EQUAL_SIZE + +#ifndef ENUM_GRADIENTSTYLE_DECLARED +#define ENUM_GRADIENTSTYLE_DECLARED + +enum GradientStyle +{ + GRADIENT_LINEAR = 0, + GRADIENT_AXIAL = 1, + GRADIENT_RADIAL = 2, + GRADIENT_ELLIPTICAL = 3, + GRADIENT_SQUARE = 4, + GRADIENT_RECT = 5, + GradientStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +#endif + +// ------------------------------------------------------------ + +// to avoid conflicts with enum's declared otherwise +#define HATCH_SINGLE HatchStyle_SINGLE +#define HATCH_DOUBLE HatchStyle_DOUBLE +#define HATCH_TRIPLE HatchStyle_TRIPLE +#define HATCH_FORCE_EQUAL_SIZE HatchStyle_FORCE_EQUAL_SIZE + +#ifndef ENUM_HATCHSTYLE_DECLARED +#define ENUM_HATCHSTYLE_DECLARED + +enum HatchStyle +{ + HATCH_SINGLE = 0, + HATCH_DOUBLE = 1, + HATCH_TRIPLE = 2, + HatchStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +#endif + +// ------------------------------------------------------------ + +// to avoid conflicts with enum's declared otherwise +#define LINE_NONE LineStyle_NONE +#define LINE_SOLID LineStyle_SOLID +#define LINE_DASH LineStyle_DASH +#define LINE_FORCE_EQUAL_SIZE LineStyle_FORCE_EQUAL_SIZE + +#ifndef ENUM_LINESTYLE_DECLARED +#define ENUM_LINESTYLE_DECLARED + +enum LineStyle +{ + LINE_NONE = 0, + LINE_SOLID = 1, + LINE_DASH = 2, + LineStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_RASTEROP_DECLARED +#define ENUM_RASTEROP_DECLARED + +enum RasterOp { ROP_OVERPAINT, ROP_XOR, ROP_0, ROP_1, ROP_INVERT }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTFAMILY_DECLARED +#define ENUM_FONTFAMILY_DECLARED + +enum FontFamily { FAMILY_DONTKNOW, FAMILY_DECORATIVE, FAMILY_MODERN, + FAMILY_ROMAN, FAMILY_SCRIPT, FAMILY_SWISS, FAMILY_SYSTEM, FontFamily_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTPITCH_DECLARED +#define ENUM_FONTPITCH_DECLARED + +enum FontPitch { PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, FontPitch_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_TEXTALIGN_DECLARED +#define ENUM_TEXTALIGN_DECLARED + +enum TextAlign { ALIGN_TOP, ALIGN_BASELINE, ALIGN_BOTTOM, TextAlign_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTWEIGHT_DECLARED +#define ENUM_FONTWEIGHT_DECLARED + +enum FontWeight { WEIGHT_DONTKNOW, WEIGHT_THIN, WEIGHT_ULTRALIGHT, + WEIGHT_LIGHT, WEIGHT_SEMILIGHT, WEIGHT_NORMAL, + WEIGHT_MEDIUM, WEIGHT_SEMIBOLD, WEIGHT_BOLD, + WEIGHT_ULTRABOLD, WEIGHT_BLACK, FontWeight_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTWIDTH_DECLARED +#define ENUM_FONTWIDTH_DECLARED + +enum FontWidth { WIDTH_DONTKNOW, WIDTH_ULTRA_CONDENSED, WIDTH_EXTRA_CONDENSED, + WIDTH_CONDENSED, WIDTH_SEMI_CONDENSED, WIDTH_NORMAL, + WIDTH_SEMI_EXPANDED, WIDTH_EXPANDED, WIDTH_EXTRA_EXPANDED, + WIDTH_ULTRA_EXPANDED, + FontWidth_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTITALIC_DECLARED +#define ENUM_FONTITALIC_DECLARED + +enum FontItalic { ITALIC_NONE, ITALIC_OBLIQUE, ITALIC_NORMAL, ITALIC_DONTKNOW, FontItalic_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTUNDERLINE_DECLARED +#define ENUM_FONTUNDERLINE_DECLARED + +enum FontUnderline { UNDERLINE_NONE, UNDERLINE_SINGLE, UNDERLINE_DOUBLE, + UNDERLINE_DOTTED, UNDERLINE_DONTKNOW, + UNDERLINE_DASH, UNDERLINE_LONGDASH, + UNDERLINE_DASHDOT, UNDERLINE_DASHDOTDOT, + UNDERLINE_SMALLWAVE, + UNDERLINE_WAVE, UNDERLINE_DOUBLEWAVE, + UNDERLINE_BOLD, UNDERLINE_BOLDDOTTED, + UNDERLINE_BOLDDASH, UNDERLINE_BOLDLONGDASH, + UNDERLINE_BOLDDASHDOT, UNDERLINE_BOLDDASHDOTDOT, + UNDERLINE_BOLDWAVE, + FontUnderline_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTSTRIKEOUT_DECLARED +#define ENUM_FONTSTRIKEOUT_DECLARED + +enum FontStrikeout { STRIKEOUT_NONE, STRIKEOUT_SINGLE, STRIKEOUT_DOUBLE, + STRIKEOUT_DONTKNOW, STRIKEOUT_BOLD, + STRIKEOUT_SLASH, STRIKEOUT_X, + FontStrikeout_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTEMPHASISMARK_DECLARED +#define ENUM_FONTEMPHASISMARK_DECLARED + +typedef sal_uInt16 FontEmphasisMark; +#define EMPHASISMARK_NONE ((FontEmphasisMark)0x0000) +#define EMPHASISMARK_DOT ((FontEmphasisMark)0x0001) +#define EMPHASISMARK_CIRCLE ((FontEmphasisMark)0x0002) +#define EMPHASISMARK_DISC ((FontEmphasisMark)0x0003) +#define EMPHASISMARK_ACCENT ((FontEmphasisMark)0x0004) +#define EMPHASISMARK_STYLE ((FontEmphasisMark)0x00FF) +#define EMPHASISMARK_POS_ABOVE ((FontEmphasisMark)0x1000) +#define EMPHASISMARK_POS_BELOW ((FontEmphasisMark)0x2000) + +// Only for kompability +#define EMPHASISMARK_DOTS_ABOVE (EMPHASISMARK_DOT | EMPHASISMARK_POS_ABOVE) +#define EMPHASISMARK_DOTS_BELOW (EMPHASISMARK_DOT | EMPHASISMARK_POS_BELOW) +#define EMPHASISMARK_SIDE_DOTS (EMPHASISMARK_ACCENT | EMPHASISMARK_POS_ABOVE) +#define EMPHASISMARK_CIRCLE_ABOVE (EMPHASISMARK_CIRCLE | EMPHASISMARK_POS_ABOVE) + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTTYPE_DECLARED +#define ENUM_FONTTYPE_DECLARED + +enum FontType { TYPE_DONTKNOW, TYPE_RASTER, TYPE_VECTOR, TYPE_SCALABLE, + FontType_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +#ifndef ENUM_FONTEMBEDDEDBITMAP_DECLARED +#define ENUM_FONTEMBEDDEDBITMAP_DECLARED + +enum FontEmbeddedBitmap { EMBEDDEDBITMAP_DONTKNOW, EMBEDDEDBITMAP_FALSE, EMBEDDEDBITMAP_TRUE }; + +#endif + +#ifndef ENUM_FONTANTIALIAS_DECLARED +#define ENUM_FONTANTIALIAS_DECLARED + +enum FontAntiAlias { ANTIALIAS_DONTKNOW, ANTIALIAS_FALSE, ANTIALIAS_TRUE }; + +#endif + +#ifndef ENUM_FONTAUTOHINT_DECLARED +#define ENUM_FONTAUTOHINT_DECLARED + +enum FontAutoHint { AUTOHINT_DONTKNOW, AUTOHINT_FALSE, AUTOHINT_TRUE }; + +#endif + +#ifndef ENUM_FONTHINTING_DECLARED +#define ENUM_FONTHINTING_DECLARED + +enum FontHinting { HINTING_DONTKNOW, HINTING_FALSE, HINTING_TRUE }; + +#endif + +#ifndef ENUM_FONTHINTSTYLE_DECLARED +#define ENUM_FONTHINTSTYLE_DECLARED + +enum FontHintStyle { HINT_NONE, HINT_SLIGHT, HINT_MEDIUM, HINT_FULL }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_KEYFUNCTYPE_DECLARED +#define ENUM_KEYFUNCTYPE_DECLARED + +enum KeyFuncType { KEYFUNC_DONTKNOW, KEYFUNC_NEW, KEYFUNC_OPEN, KEYFUNC_SAVE, + KEYFUNC_SAVEAS, KEYFUNC_PRINT, KEYFUNC_CLOSE, KEYFUNC_QUIT, + KEYFUNC_CUT, KEYFUNC_COPY, KEYFUNC_PASTE, KEYFUNC_UNDO, + KEYFUNC_REDO, KEYFUNC_DELETE, KEYFUNC_REPEAT, KEYFUNC_FIND, + KEYFUNC_FINDBACKWARD, KEYFUNC_PROPERTIES, KEYFUNC_FRONT, + KeyFuncType_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +typedef sal_uInt32 sal_UCS4; // TODO: this should be moved to rtl + +#ifndef ENUM_OUTDEVSUPPORT_DECLARED +#define ENUM_OUTDEVSUPPORT_DECLARED + +enum OutDevSupportType { OutDevSupport_TransparentRect, OutDevSupport_B2DClip, OutDevSupport_B2DDraw }; + +#endif + +#endif // _VCL_VCLENUM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/vclevent.hxx b/vcl/inc/vcl/vclevent.hxx new file mode 100644 index 000000000000..c7347f7cd978 --- /dev/null +++ b/vcl/inc/vcl/vclevent.hxx @@ -0,0 +1,308 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_VCLEVENT_HXX +#define _VCL_VCLEVENT_HXX + +#include "tools/link.hxx" +#include "tools/rtti.hxx" +#include "vcl/dllapi.h" +#include "vcl/impdel.hxx" + +#include <com/sun/star/uno/Reference.hxx> + +#include <list> +#include <vector> + +class Window; +class Menu; + +namespace com { namespace sun { namespace star { + namespace accessibility { + class XAccessible; + } +}}} + +#define VCLEVENT_OBJECT_DYING 1 + +// VclWindowEvent: +#define VCLEVENT_WINDOW_CHILDCREATED 500 // pData = Window* +#define VCLEVENT_WINDOW_CHILDDESTROYED 501 // pData = Window* +#define VCLEVENT_WINDOW_PAINT 1000 // pData = Rectangle* +#define VCLEVENT_WINDOW_MOVE 1001 +#define VCLEVENT_WINDOW_RESIZE 1002 +#define VCLEVENT_WINDOW_SHOW 1003 +#define VCLEVENT_WINDOW_HIDE 1004 +#define VCLEVENT_WINDOW_ACTIVATE 1005 +#define VCLEVENT_WINDOW_DEACTIVATE 1006 // pData = Window* = pPrevActiveWindow +#define VCLEVENT_WINDOW_CLOSE 1007 +#define VCLEVENT_WINDOW_GETFOCUS 1008 +#define VCLEVENT_WINDOW_LOSEFOCUS 1009 +#define VCLEVENT_WINDOW_MINIMIZE 1010 +#define VCLEVENT_WINDOW_NORMALIZE 1011 +#define VCLEVENT_WINDOW_KEYINPUT 1012 // pData = KeyEvent* +#define VCLEVENT_WINDOW_KEYUP 1013 // pData = KeyEvent* +#define VCLEVENT_WINDOW_COMMAND 1014 // pData = CommandEvent* +#define VCLEVENT_WINDOW_MOUSEMOVE 1015 // pData = MouseEvent* +#define VCLEVENT_WINDOW_MOUSEBUTTONDOWN 1016 // pData = MouseEvent* +#define VCLEVENT_WINDOW_MOUSEBUTTONUP 1017 // pData = MouseEvent* +#define VCLEVENT_WINDOW_FRAMETITLECHANGED 1018 // pData = XubString* = oldTitle +#define VCLEVENT_APPLICATION_DATACHANGED 1019 // pData = DataChangedEvent* +#define VCLEVENT_WINDOW_ENABLED 1020 +#define VCLEVENT_WINDOW_DISABLED 1021 +#define VCLEVENT_WINDOW_DATACHANGED 1022 // pData = DataChangedEvent* + +// VclWindowEvent +#define VCLEVENT_CONTROL_GETFOCUS 1100 +#define VCLEVENT_CONTROL_LOSEFOCUS 1101 +#define VCLEVENT_BUTTON_CLICK 1102 +#define VCLEVENT_PUSHBUTTON_TOGGLE 1103 +#define VCLEVENT_RADIOBUTTON_TOGGLE 1104 +#define VCLEVENT_CHECKBOX_TOGGLE 1105 +#define VCLEVENT_COMBOBOX_SELECT 1106 +#define VCLEVENT_COMBOBOX_DOUBLECLICK 1107 +#define VCLEVENT_LISTBOX_SELECT 1108 +#define VCLEVENT_LISTBOX_DOUBLECLICK 1109 +#define VCLEVENT_EDIT_MODIFY 1110 +#define VCLEVENT_SCROLLBAR_SCROLL 1111 +#define VCLEVENT_SCROLLBAR_ENDSCROLL 1112 +#define VCLEVENT_SPINBUTTON_UP 1113 +#define VCLEVENT_SPINBUTTON_DOWN 1114 +#define VCLEVENT_SPINFIELD_UP 1115 +#define VCLEVENT_SPINFIELD_DOWN 1116 +#define VCLEVENT_SPINFIELD_FIRST 1117 +#define VCLEVENT_SPINFIELD_LAST 1118 +#define VCLEVENT_STATUSBAR_CLICK 1119 +#define VCLEVENT_STATUSBAR_DOUBLECLICK 1120 +#define VCLEVENT_TOOLBOX_CLICK 1121 +#define VCLEVENT_TOOLBOX_DOUBLECLICK 1122 +#define VCLEVENT_TOOLBOX_ACTIVATE 1123 +#define VCLEVENT_TOOLBOX_DEACTIVATE 1124 +#define VCLEVENT_TOOLBOX_HIGHLIGHT 1125 +#define VCLEVENT_TOOLBOX_SELECT 1126 +// Resort later... +#define VCLEVENT_LISTBOX_SCROLLED 1127 +#define VCLEVENT_COMBOBOX_SCROLLED 1128 +#define VCLEVENT_EDIT_SELECTIONCHANGED 1129 +#define VCLEVENT_DROPDOWN_OPEN 1130 +#define VCLEVENT_DROPDOWN_CLOSE 1131 + +#define VCLEVENT_TOOLBOX_ITEMADDED 1132 // pData = itempos +#define VCLEVENT_TOOLBOX_ITEMREMOVED 1133 // pData = itempos +#define VCLEVENT_TOOLBOX_ALLITEMSCHANGED 1134 +#define VCLEVENT_TOOLBOX_HIGHLIGHTOFF 1135 // pData = itempos +#define VCLEVENT_WINDOW_MENUBARADDED 1136 // pData = pMenuBar +#define VCLEVENT_TABPAGE_ACTIVATE 1137 // pData = pageid +#define VCLEVENT_TABPAGE_DEACTIVATE 1138 // pData = pageid +#define VCLEVENT_TABBAR_PAGEENABLED 1139 // pData = pageid +#define VCLEVENT_TABBAR_PAGEDISABLED 1140 // pData = pageid +#define VCLEVENT_TABBAR_PAGESELECTED 1141 // pData = pageid +#define VCLEVENT_TABBAR_PAGEACTIVATED 1142 // pData = pageid +#define VCLEVENT_TABBAR_PAGEDEACTIVATED 1143 // pData = pageid +#define VCLEVENT_TABBAR_PAGEINSERTED 1144 // pData = pageid +#define VCLEVENT_TABBAR_PAGEREMOVED 1145 // pData = pageid +#define VCLEVENT_TABBAR_PAGEMOVED 1146 // pData = Pair( pagepos_old, pagepos_new ) +#define VCLEVENT_TABBAR_PAGETEXTCHANGED 1147 // pData = pageid +#define VCLEVENT_COMBOBOX_DESELECT 1148 +#define VCLEVENT_TOOLBOX_ITEMTEXTCHANGED 1149 // pData = itempos +#define VCLEVENT_TABPAGE_INSERTED 1150 // pData = pageid +#define VCLEVENT_TABPAGE_REMOVED 1151 // pData = pageid +#define VCLEVENT_TABPAGE_REMOVEDALL 1152 +#define VCLEVENT_LISTBOX_ITEMADDED 1153 // pData = itempos +#define VCLEVENT_LISTBOX_ITEMREMOVED 1154 // pData = itempos, -1=ALL +#define VCLEVENT_COMBOBOX_ITEMADDED 1155 // pData = itempos +#define VCLEVENT_COMBOBOX_ITEMREMOVED 1156 // pData = itempos, -1=ALL +// free 1157 +#define VCLEVENT_WINDOW_MENUBARREMOVED 1158 // pData = pMenuBar +#define VCLEVENT_STATUSBAR_ITEMADDED 1159 // pData = itemid +#define VCLEVENT_STATUSBAR_ITEMREMOVED 1160 // pData = itemid +#define VCLEVENT_STATUSBAR_ALLITEMSREMOVED 1161 +#define VCLEVENT_STATUSBAR_SHOWITEM 1162 // pData = itemid +#define VCLEVENT_STATUSBAR_HIDEITEM 1163 // pData = itemid +#define VCLEVENT_STATUSBAR_SHOWALLITEMS 1164 +#define VCLEVENT_STATUSBAR_HIDEALLITEMS 1165 +#define VCLEVENT_STATUSBAR_DRAWITEM 1166 // pData = itemid +#define VCLEVENT_STATUSBAR_NAMECHANGED 1167 // pData = itemid +#define VCLEVENT_TOOLBOX_ITEMENABLED 1168 // pData = itempos +#define VCLEVENT_TOOLBOX_ITEMDISABLED 1169 // pData = itempos +#define VCLEVENT_TABPAGE_PAGETEXTCHANGED 1170 // pData = pageid +#define VCLEVENT_ROADMAP_ITEMSELECTED 1171 +#define VCLEVENT_TOOLBOX_FORMATCHANGED 1172 // request new layout +#define VCLEVENT_COMBOBOX_SETTEXT 1173 +// --> OD 2009-04-01 #i92103# +#define VCLEVENT_ITEM_EXPANDED 1174 +#define VCLEVENT_ITEM_COLLAPSED 1175 +// <-- +#define VCLEVENT_DROPDOWN_PRE_OPEN 1176 + +// VclMenuEvent +#define VCLEVENT_MENU_ACTIVATE 1200 +#define VCLEVENT_MENU_DEACTIVATE 1201 +#define VCLEVENT_MENU_HIGHLIGHT 1202 +#define VCLEVENT_MENU_SELECT 1203 +#define VCLEVENT_MENU_ENABLE 1204 +#define VCLEVENT_MENU_INSERTITEM 1205 +#define VCLEVENT_MENU_REMOVEITEM 1206 +#define VCLEVENT_MENU_SUBMENUACTIVATE 1207 +#define VCLEVENT_MENU_SUBMENUDEACTIVATE 1208 +#define VCLEVENT_MENU_SUBMENUCHANGED 1209 +#define VCLEVENT_MENU_DEHIGHLIGHT 1210 +#define VCLEVENT_MENU_DISABLE 1211 +#define VCLEVENT_MENU_ITEMTEXTCHANGED 1212 +#define VCLEVENT_MENU_ITEMCHECKED 1213 +#define VCLEVENT_MENU_ITEMUNCHECKED 1214 +#define VCLEVENT_MENU_ACCESSIBLENAMECHANGED 1215 + +#define VCLEVENT_MENU_SHOW 1250 +#define VCLEVENT_MENU_HIDE 1251 + +#define VCLEVENT_TOOLBOX_ITEMWINDOWCHANGED 1216 + +// DockingWindow +#define VCLEVENT_WINDOW_STARTDOCKING 1217 // pData = DockingData +#define VCLEVENT_WINDOW_DOCKING 1218 +#define VCLEVENT_WINDOW_ENDDOCKING 1219 // pData = EndDockingData +#define VCLEVENT_WINDOW_PREPARETOGGLEFLOATING 1220 // pData = sal_Bool +#define VCLEVENT_WINDOW_TOGGLEFLOATING 1221 +#define VCLEVENT_WINDOW_ENDPOPUPMODE 1222 // pData = EndPopupModeData + +#define VCLEVENT_TOOLBOX_BUTTONSTATECHANGED 1223 // pData = itempos +#define VCLEVENT_TABLECELL_NAMECHANGED 1224 // pData = struct(Entry, Column, oldText) +#define VCLEVENT_TABLEROW_SELECT 1225 + +class VCL_DLLPUBLIC VclSimpleEvent +{ +private: + sal_uLong nId; + +public: + VclSimpleEvent( sal_uLong n ) { nId = n; } + TYPEINFO(); + + sal_uLong GetId() const { return nId; } +}; + +class VCL_DLLPUBLIC VclWindowEvent : public VclSimpleEvent +{ +private: + Window* pWindow; + void* pData; + +public: + VclWindowEvent( Window* pWin, sal_uLong n, void* pDat = NULL ) : VclSimpleEvent(n) { pWindow = pWin; pData = pDat; } + TYPEINFO(); + + Window* GetWindow() const { return pWindow; } + void* GetData() const { return pData; } +}; + +/* +class VclMouseEvent : public VclWindowEvent +{ +private: + MouseEvent aEvent; + +public: + VclMouseEvent( Window* pWin, sal_uLong n, const MouseEvent& rEvent ) : VclWindowEvent( pWin, n ), aEvent(rEvent) { ; } + TYPEINFO(); + + const MouseEvent& GetEvent() const { return aEvent; } +}; +*/ + +class VCL_DLLPUBLIC VclMenuEvent : public VclSimpleEvent +{ +private: + Menu* pMenu; + sal_uInt16 mnPos; + +public: + VclMenuEvent( Menu* pM, sal_uLong n, sal_uInt16 nPos ) : VclSimpleEvent(n) { pMenu = pM; mnPos = nPos; } + TYPEINFO(); + + Menu* GetMenu() const { return pMenu; } + sal_uInt16 GetItemPos() const { return mnPos; } +}; + +class VCL_DLLPUBLIC VclAccessibleEvent: public VclSimpleEvent +{ +public: + VclAccessibleEvent( sal_uLong n, const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible ); + virtual ~VclAccessibleEvent(); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible() const; + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible; +}; + +class VCL_DLLPUBLIC VclEventListeners +{ +public: + void Call( VclSimpleEvent* pEvent ) const; + + // stops notifying when any handler has processed the event + // and returns sal_True in that case + // a handler must return sal_True to signal that it has processed the event + sal_Bool Process( VclSimpleEvent* pEvent ) const; + void addListener( const Link& rListener ); + void removeListener( const Link& rListener ); +private: + std::list<Link> m_aListeners; +}; + +class VCL_DLLPUBLIC VclEventListeners2 : public vcl::DeletionNotifier +{ + std::list< Link > m_aListeners; + + struct ListenerIt + { + std::list< Link >::iterator m_aIt; + bool m_bWasInvalidated; + + ListenerIt(const std::list<Link>::iterator& rIt) + : m_aIt(rIt) + , m_bWasInvalidated( false ) + {} + }; + + std::vector< ListenerIt > m_aIterators; + + +public: + VclEventListeners2(); + ~VclEventListeners2(); + + void addListener( const Link& ); + void removeListener( const Link& ); + + void callListeners( VclSimpleEvent* ); +}; + +#endif // _VCL_VCLEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/virdev.hxx b/vcl/inc/vcl/virdev.hxx new file mode 100644 index 000000000000..79b8233cf964 --- /dev/null +++ b/vcl/inc/vcl/virdev.hxx @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_VIRDEV_HXX +#define _SV_VIRDEV_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> + +// ----------------- +// - VirtualDevice - +// ----------------- + +class SalVirtualDevice; +class RmVirtualDevice; +struct SystemGraphicsData; + +class VCL_DLLPUBLIC VirtualDevice : public OutputDevice +{ + friend class Application; + friend class OutputDevice; + +private: + SalVirtualDevice* mpVirDev; + VirtualDevice* mpPrev; + VirtualDevice* mpNext; + sal_uInt16 mnBitCount; + sal_Bool mbScreenComp; + sal_Int8 mnAlphaDepth; + sal_uInt8 meRefDevMode; + + SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ); + SAL_DLLPRIVATE sal_Bool ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase ); + + // Copy assignment is forbidden and not implemented. + VirtualDevice (const VirtualDevice &); + VirtualDevice & operator= (const VirtualDevice &); + + /** Used for alpha VDev, to set areas to opaque + + @since #i32109# + */ + SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const Rectangle& rRect ); + + // TODO: add extra member for refdev backward compatibility options + #define REFDEV_FORCE_ZERO_EXTLEAD 0x80 + SAL_DLLPRIVATE bool ForceZeroExtleadBug() const + { return ((meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD) != 0); } +public: + VirtualDevice( sal_uInt16 nBitCount = 0 ); + VirtualDevice( const OutputDevice& rCompDev, + sal_uInt16 nBitCount = 0 ); + /** Create a virtual device with alpha channel + + @param rCompDev + The generated vdev will be compatible to this device. By + default, Application::GetDefaultDevice() is used here. + + @param nBitCount + Bit depth of the generated virtual device. Use 0 here, to + indicate: take default screen depth. Currently, only 0 and 1 + are allowed here, with 1 denoting binary mask. + + @param nAlphaBitCount + Bit depth of the generated virtual device. Use 0 here, to + indicate: take default screen depth. Currently, only 0 and 1 + are allowed here, with 1 denoting binary mask. + */ + VirtualDevice( const OutputDevice& rCompDev, + sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount ); + + /** Create a virtual device using an existing system dependent device or graphics context + Any rendering will happen directly on the context and not on any intermediate bitmap. + Note: This might not be suported on all platforms ! + */ + VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount ); + + virtual ~VirtualDevice(); + + sal_Bool SetOutputSizePixel( const Size& rNewSize, sal_Bool bErase = sal_True ); + sal_Bool SetOutputSize( const Size& rNewSize, sal_Bool bErase = sal_True ) + { return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); } + + // reference device modes for different compatibility levels + enum RefDevMode { REFDEV_NONE = 0, + REFDEV_MODE06 = 1, // 600 dpi + REFDEV_MODE48 = 2, // 4800 dpi + REFDEV_MODE_MSO1 = 3, + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/waitobj.hxx b/vcl/inc/vcl/waitobj.hxx new file mode 100644 index 000000000000..1bbdd04506e9 --- /dev/null +++ b/vcl/inc/vcl/waitobj.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WAITOBJ_HXX +#define _SV_WAITOBJ_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +// -------------- +// - WaitObject - +// -------------- + +class VCL_DLLPUBLIC WaitObject +{ +private: + Window* mpWindow; +public: + WaitObject( Window* pWindow ) + { + mpWindow = pWindow; + if ( mpWindow ) + mpWindow->EnterWait(); + } + ~WaitObject(); +}; + +#endif // _SV_WAITOBJ_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/wall.hxx b/vcl/inc/vcl/wall.hxx new file mode 100644 index 000000000000..66a2a11038ed --- /dev/null +++ b/vcl/inc/vcl/wall.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WALL_HXX +#define _SV_WALL_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> + +class Rectangle; +class Gradient; +class BitmapEx; +class ImplWallpaper; + +// ------------------- +// - Wallpaper-Types - +// ------------------- + +#define WALLPAPER_NULL WallpaperStyle_NULL +#define WALLPAPER_TILE WallpaperStyle_TILE +#define WALLPAPER_CENTER WallpaperStyle_CENTER +#define WALLPAPER_SCALE WallpaperStyle_SCALE +#define WALLPAPER_TOPLEFT WallpaperStyle_TOPLEFT +#define WALLPAPER_TOP WallpaperStyle_TOP +#define WALLPAPER_TOPRIGHT WallpaperStyle_TOPRIGHT +#define WALLPAPER_LEFT WallpaperStyle_LEFT +#define WALLPAPER_RIGHT WallpaperStyle_RIGHT +#define WALLPAPER_BOTTOMLEFT WallpaperStyle_BOTTOMLEFT +#define WALLPAPER_BOTTOM WallpaperStyle_BOTTOM +#define WALLPAPER_BOTTOMRIGHT WallpaperStyle_BOTTOMRIGHT +#define WALLPAPER_APPLICATIONGRADIENT WallpaperStyle_APPLICATIONGRADIENT +#define WALLPAPER_FORCE_EQUAL_SIZE WallpaperStyle_FORCE_EQUAL_SIZE + +#ifndef ENUM_WALLPAPERSTYLE_DECLARED +#define ENUM_WALLPAPERSTYLE_DECLARED + +enum WallpaperStyle +{ + WALLPAPER_NULL, + WALLPAPER_TILE, + WALLPAPER_CENTER, + WALLPAPER_SCALE, + WALLPAPER_TOPLEFT, + WALLPAPER_TOP, + WALLPAPER_TOPRIGHT, + WALLPAPER_LEFT, + WALLPAPER_RIGHT, + WALLPAPER_BOTTOMLEFT, + WALLPAPER_BOTTOM, + WALLPAPER_BOTTOMRIGHT, + WALLPAPER_APPLICATIONGRADIENT, // defines a gradient that internally covers the whole application + // and uses a color derived from the face color + WALLPAPER_FORCE_EQUAL_SIZE = 0x7fffffff +}; + +#endif + +// ------------- +// - Wallpaper - +// ------------- + +class VCL_DLLPUBLIC Wallpaper +{ +private: + ImplWallpaper* mpImplWallpaper; + + SAL_DLLPRIVATE void ImplMakeUnique( sal_Bool bReleaseCache = sal_True ); + SAL_DLLPRIVATE Gradient ImplGetApplicationGradient() const; + +public: + SAL_DLLPRIVATE ImplWallpaper* ImplGetImpWallpaper() const { return mpImplWallpaper; } + + +public: + Wallpaper(); + Wallpaper( const Wallpaper& rWallpaper ); + Wallpaper( const Color& rColor ); + Wallpaper( const BitmapEx& rBmpEx ); + Wallpaper( const Gradient& rGradient ); + ~Wallpaper(); + + void SetColor( const Color& rColor ); + const Color& GetColor() const; + + void SetStyle( WallpaperStyle eStyle ); + WallpaperStyle GetStyle() const; + + void SetBitmap( const BitmapEx& rBitmap ); + void SetBitmap(); + BitmapEx GetBitmap() const; + sal_Bool IsBitmap() const; + + void SetGradient( const Gradient& rGradient ); + void SetGradient(); + Gradient GetGradient() const; + sal_Bool IsGradient() const; + + void SetRect( const Rectangle& rRect ); + void SetRect(); + Rectangle GetRect() const; + sal_Bool IsRect() const; + + sal_Bool IsFixed() const; + sal_Bool IsScrollable() const; + + Wallpaper& operator=( const Wallpaper& rWallpaper ); + sal_Bool operator==( const Wallpaper& rWallpaper ) const; + sal_Bool operator!=( const Wallpaper& rWallpaper ) const + { return !(Wallpaper::operator==( rWallpaper )); } + sal_Bool IsSameInstance( const Wallpaper& rWallpaper ) const + { return (mpImplWallpaper == rWallpaper.mpImplWallpaper); } + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Wallpaper& rWallpaper ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Wallpaper& rWallpaper ); +}; + +#endif // _SV_WALL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/wall2.hxx b/vcl/inc/vcl/wall2.hxx new file mode 100644 index 000000000000..162614262095 --- /dev/null +++ b/vcl/inc/vcl/wall2.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WALL2_HXX +#define _SV_WALL2_HXX + +#include <vcl/wall.hxx> + +class ImplWallpaper +{ + friend class Wallpaper; + +private: + Color maColor; + BitmapEx* mpBitmap; + Gradient* mpGradient; + Rectangle* mpRect; + WallpaperStyle meStyle; + sal_uLong mnRefCount; + BitmapEx* mpCache; + + friend SvStream& operator>>( SvStream& rIStm, ImplWallpaper& rImplWallpaper ); + friend SvStream& operator<<( SvStream& rOStm, const ImplWallpaper& rImplWallpaper ); + +public: + ImplWallpaper(); + ImplWallpaper( const ImplWallpaper& rImplWallpaper ); + ~ImplWallpaper(); + + void ImplSetCachedBitmap( BitmapEx& rBmp ); + const BitmapEx* ImplGetCachedBitmap() { return mpCache; } + void ImplReleaseCachedBitmap(); +}; + + +#endif // _SV_WALL2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/window.h b/vcl/inc/vcl/window.h new file mode 100644 index 000000000000..12f6eedc2906 --- /dev/null +++ b/vcl/inc/vcl/window.h @@ -0,0 +1,406 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WINDOW_H +#define _SV_WINDOW_H + +#include <vector> +#include <vcl/sv.h> +#include <vcl/outdev.hxx> +#include <vcl/timer.hxx> +#ifndef _SV_INPUTCTX_HXX +#include <vcl/inputctx.hxx> +#endif +#ifndef _SV_POINTR_HXX +#include <vcl/pointr.hxx> +#endif +#include <tools/wintypes.hxx> +#include <vcl/vclevent.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/weakref.hxx> + +#include <vcl/salnativewidgets.hxx> + +#include <list> + +struct SalPaintEvent; +struct ImplDelData; +struct ImplAccessibleInfos; + +class Window; +class VirtualDevice; +class Cursor; +class ImplDevFontList; +class ImplFontCache; +class VCLXWindow; +class SalFrame; +class SalObject; + + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + class XAccessible; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace rendering { + class XCanvas; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace awt { + class XWindowPeer; + class XWindow; +} +namespace uno { + class Any; + class XInterface; +} +namespace datatransfer { +namespace clipboard { + class XClipboard; +} + +namespace dnd { + class XDropTargetListener; + class XDragGestureRecognizer; + class XDragSource; + class XDropTarget; +} } } } } + +namespace vcl { + struct ControlLayoutData; + struct ExtWindowImpl; +} + + +// -------------- +// - Prototypes - +// -------------- + +long ImplWindowFrameProc( Window* pInst, SalFrame* pFrame, sal_uInt16 nEvent, const void* pEvent ); + +// ----------- +// - HitTest - +// ----------- + +#define WINDOW_HITTEST_INSIDE ((sal_uInt16)0x0001) +#define WINDOW_HITTEST_TRANSPARENT ((sal_uInt16)0x0002) + +// --------------- +// - ImplWinData - +// --------------- + +struct ImplWinData +{ + UniString* mpExtOldText; + sal_uInt16* mpExtOldAttrAry; + Rectangle* mpCursorRect; + long mnCursorExtWidth; + Rectangle* mpFocusRect; + Rectangle* mpTrackRect; + sal_uInt16 mnTrackFlags; + sal_uInt16 mnIsTopWindow; + sal_Bool mbMouseOver; // tracks mouse over for native widget paint effect + sal_Bool mbEnableNativeWidget; // toggle native widget rendering + ::std::list< Window* > + maTopWindowChildren; +}; + +// ------------------- +// - ImplOverlapData - +// ------------------- + +struct ImplOverlapData +{ + VirtualDevice* mpSaveBackDev; // Gesicherte Hintergrund-Bitmap + Region* mpSaveBackRgn; // Gesicherte Region, was invalidiert werden muss + Window* mpNextBackWin; // Naechstes Fenster mit Hintergrund-Sicherung + sal_uIntPtr mnSaveBackSize; // Groesse Bitmap fuer Hintergrund-Sicherung + sal_Bool mbSaveBack; // sal_True: Background sichern + sal_uInt8 mnTopLevel; // Level for Overlap-Window +}; + +// ----------------- +// - ImplFrameData - +// ----------------- + +struct ImplFrameData +{ + Timer maPaintTimer; // paint timer + Timer maResizeTimer; // resize timer + InputContext maOldInputContext; // Last set Input Context + Window* mpNextFrame; // next frame window + Window* mpFirstOverlap; // first overlap window + Window* mpFocusWin; // focus window (is also set, when frame doesn't have the focous) + Window* mpMouseMoveWin; // last window, where MouseMove() called + Window* mpMouseDownWin; // last window, where MouseButtonDown() called + Window* mpFirstBackWin; // Erstes Overlap-Window mit Hintergrund-Sicherung + ::std::vector<Window *> maOwnerDrawList; // List of system windows with owner draw decoration + ImplDevFontList* mpFontList; // Font-List for this frame + ImplFontCache* mpFontCache; // Font-Cache for this frame + sal_Int32 mnDPIX; // Original Screen Resolution + sal_Int32 mnDPIY; // Original Screen Resolution + ImplMapRes maMapUnitRes; // for LogicUnitToPixel + sal_uIntPtr mnAllSaveBackSize; // Groesse aller Bitmaps fuer Hintergrund-Sicherung + sal_uIntPtr mnFocusId; // FocusId for PostUserLink + sal_uIntPtr mnMouseMoveId; // MoveId for PostUserLink + long mnLastMouseX; // last x mouse position + long mnLastMouseY; // last y mouse position + long mnBeforeLastMouseX; // last but one x mouse position + long mnBeforeLastMouseY; // last but one y mouse position + long mnFirstMouseX; // first x mouse position by mousebuttondown + long mnFirstMouseY; // first y mouse position by mousebuttondown + long mnLastMouseWinX; // last x mouse position, rel. to pMouseMoveWin + long mnLastMouseWinY; // last y mouse position, rel. to pMouseMoveWin + sal_uInt16 mnModalMode; // frame based modal count (app based makes no sense anymore) + sal_uIntPtr mnMouseDownTime; // mouse button down time for double click + sal_uInt16 mnClickCount; // mouse click count + sal_uInt16 mnFirstMouseCode; // mouse code by mousebuttondown + sal_uInt16 mnMouseCode; // mouse code + sal_uInt16 mnMouseMode; // mouse mode + MapUnit meMapUnit; // last MapUnit for LogicUnitToPixel + sal_Bool mbHasFocus; // focus + sal_Bool mbInMouseMove; // is MouseMove on stack + sal_Bool mbMouseIn; // is Mouse inside the frame + sal_Bool mbStartDragCalled; // is command startdrag called + sal_Bool mbNeedSysWindow; // set, when FrameSize <= IMPL_MIN_NEEDSYSWIN + sal_Bool mbMinimized; // set, when FrameSize <= 0 + sal_Bool mbStartFocusState; // FocusState, beim abschicken des Events + sal_Bool mbInSysObjFocusHdl; // Innerhalb vom GetFocus-Handler eines SysChilds + sal_Bool mbInSysObjToTopHdl; // Innerhalb vom ToTop-Handler eines SysChilds + sal_Bool mbSysObjFocus; // Hat ein SysChild den Focus + + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > mxDragSource; + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > mxDropTarget; + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener > mxDropTargetListener; + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxClipboard; + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > mxSelection; + + sal_Bool mbInternalDragGestureRecognizer; +}; + +// ----------------------- +// - ImplAccessibleInfos - +// ----------------------- + +struct ImplAccessibleInfos +{ + sal_uInt16 nAccessibleRole; + String* pAccessibleName; + String* pAccessibleDescription; + Window* pLabeledByWindow; + Window* pLabelForWindow; + Window* pMemberOfWindow; + + ImplAccessibleInfos(); + ~ImplAccessibleInfos(); +}; + + +// --------------- +// - WindowImpl - +// --------------- + +enum AlwaysInputMode { AlwaysInputNone = 0, AlwaysInputEnabled = 1, AlwaysInputDisabled =2 }; + +class WindowImpl +{ +public: + WindowImpl(); + ~WindowImpl(); + + ImplWinData* mpWinData; + ImplOverlapData* mpOverlapData; + ImplFrameData* mpFrameData; + SalFrame* mpFrame; + SalObject* mpSysObj; + Window* mpFrameWindow; + Window* mpOverlapWindow; + Window* mpBorderWindow; + Window* mpClientWindow; + Window* mpParent; + Window* mpRealParent; + Window* mpFirstChild; + Window* mpLastChild; + Window* mpFirstOverlap; + Window* mpLastOverlap; + Window* mpPrev; + Window* mpNext; + Window* mpNextOverlap; + Window* mpLastFocusWindow; + Window* mpDlgCtrlDownWindow; + VclEventListeners maEventListeners; + VclEventListeners maChildEventListeners; + + // The canvas interface for this VCL window. Is persistent after the first GetCanvas() call + ::com::sun::star::uno::WeakReference< ::com::sun::star::rendering::XCanvas > mxCanvas; + + ImplDelData* mpFirstDel; + void* mpUserData; + vcl::ExtWindowImpl* mpExtImpl; + Cursor* mpCursor; + Pointer maPointer; + Fraction maZoom; + XubString maText; + Font* mpControlFont; + Color maControlForeground; + Color maControlBackground; + sal_Int32 mnLeftBorder; + sal_Int32 mnTopBorder; + sal_Int32 mnRightBorder; + sal_Int32 mnBottomBorder; + long mnX; + long mnY; + long mnAbsScreenX; + Point maPos; + rtl::OString maHelpId; + rtl::OString maUniqId; + XubString maHelpText; + XubString maQuickHelpText; + InputContext maInputContext; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > mxWindowPeer; + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible; + ImplAccessibleInfos* mpAccessibleInfos; + VCLXWindow* mpVCLXWindow; + Region maWinRegion; // region to 'shape' the VCL window (frame coordinates) + Region maWinClipRegion; // the (clipping) region that finally corresponds to the VCL window (frame coordinates) + Region maInvalidateRegion; // region that has to be redrawn (frame coordinates) + Region* mpChildClipRegion; // child clip region if CLIPCHILDREN is set (frame coordinates) + Region* mpPaintRegion; // only set during Paint() method call (window coordinates) + WinBits mnStyle; + WinBits mnPrevStyle; + WinBits mnExtendedStyle; + WinBits mnPrevExtendedStyle; + WindowType mnType; + ControlPart mnNativeBackground; + sal_uInt16 mnWaitCount; + sal_uInt16 mnPaintFlags; + sal_uInt16 mnGetFocusFlags; + sal_uInt16 mnParentClipMode; + sal_uInt16 mnActivateMode; + sal_uInt16 mnDlgCtrlFlags; + sal_uInt16 mnLockCount; + AlwaysInputMode meAlwaysInputMode; + sal_Bool mbFrame:1, + mbBorderWin:1, + mbOverlapWin:1, + mbSysWin:1, + mbDialog:1, + mbDockWin:1, + mbFloatWin:1, + mbPushButton:1, + mbVisible:1, + mbDisabled:1, + mbInputDisabled:1, + mbDropDisabled:1, + mbNoUpdate:1, + mbNoParentUpdate:1, + mbActive:1, + mbParentActive:1, + mbReallyVisible:1, + mbReallyShown:1, + mbInInitShow:1, + mbChildNotify:1, + mbChildPtrOverwrite:1, + mbNoPtrVisible:1, + mbPaintFrame:1, + mbInPaint:1, + mbMouseMove:1, + mbMouseButtonDown:1, + mbMouseButtonUp:1, + mbKeyInput:1, + mbKeyUp:1, + mbCommand:1, + mbDefPos:1, + mbDefSize:1, + mbCallMove:1, + mbCallResize:1, + mbWaitSystemResize:1, + mbInitWinClipRegion:1, + mbInitChildRegion:1, + mbWinRegion:1, + mbClipChildren:1, + mbClipSiblings:1, + mbChildTransparent:1, + mbPaintTransparent:1, + mbMouseTransparent:1, + mbDlgCtrlStart:1, + mbFocusVisible:1, + mbTrackVisible:1, + mbUseNativeFocus:1, + mbNativeFocusVisible:1, + mbInShowFocus:1, + mbInHideFocus:1, + mbControlForeground:1, + mbControlBackground:1, + mbAlwaysOnTop:1, + mbCompoundControl:1, + mbCompoundControlHasFocus:1, + mbPaintDisabled:1, + mbAllResize:1, + mbInDtor:1, + mbExtTextInput:1, + mbInFocusHdl:1, + mbOverlapVisible:1, + mbCreatedWithToolkit:1, + mbToolBox:1, + mbSplitter:1, + mbSuppressAccessibilityEvents:1, + mbMenuFloatingWindow:1, + mbDrawSelectionBackground:1, + mbIsInTaskPaneList:1, + mbToolbarFloatingWindow:1, + mbCallHandlersDuringInputDisabled:1, + mbDisableAccessibleLabelForRelation:1, + mbDisableAccessibleLabeledByRelation:1, + mbHelpTextDynamic:1, + mbFakeFocusSet:1, + mbInterceptChildWindowKeyDown:1; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; +}; + +// ----------------- +// - Hilfsmethoden - +// ----------------- + +long ImplHandleMouseEvent( Window* pWindow, sal_uInt16 nSVEvent, sal_Bool bMouseLeave, + long nX, long nY, sal_uIntPtr nMsgTime, + sal_uInt16 nCode, sal_uInt16 nMode ); +void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight ); + +#endif // _SV_WINDOW_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx new file mode 100644 index 000000000000..df82b7870854 --- /dev/null +++ b/vcl/inc/vcl/window.hxx @@ -0,0 +1,1191 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WINDOW_HXX +#define _SV_WINDOW_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <tools/resid.hxx> +#include <vcl/pointr.hxx> +#include <tools/wintypes.hxx> +#include <vcl/apptypes.hxx> +#include <vcl/inputctx.hxx> +#include <vcl/vclevent.hxx> +// Only for compatibility - because many people outside haven't included event.hxx +#include <vcl/event.hxx> +#include <vcl/region.hxx> +#include <vcl/salnativewidgets.hxx> +#include <rtl/ustring.hxx> +#include <cppuhelper/weakref.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <boost/shared_ptr.hpp> + +class VirtualDevice; +struct ImplDelData; +struct ImplWinData; +struct ImplOverlapData; +struct ImplFrameData; +struct ImplCalcToTopData; +struct SystemEnvData; +struct SystemParentData; +class ImplBorderWindow; +class VirtualDevice; +class Timer; +class Cursor; +class DockingManager; +class ScrollBar; +class Bitmap; +class Image; +class MouseEvent; +class KeyEvent; +class CommandEvent; +class TrackingEvent; +class HelpEvent; +class DataChangedEvent; +class NotifyEvent; +class SystemWindow; +class SalFrame; +class SalObject; +class MenuFloatingWindow; +class UNOWindowData; +// Nur fuer ExecuteDrag: +struct IDataObject; +class VCLXWindow; +struct ImplAccessibleInfos; + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + class XAccessible; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace beans { + struct PropertyValue; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace rendering { + class XCanvas; + class XSpriteCanvas; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace awt { + class XWindowPeer; + class XWindow; +} +namespace uno { + class Any; + class XInterface; +} +namespace datatransfer { +namespace clipboard { + class XClipboard; +} + +namespace dnd { + class XDragGestureRecognizer; + class XDragSource; + class XDropTarget; +} } } } } + +namespace vcl { + struct ControlLayoutData; + class WindowArranger; + struct ExtWindowImpl; +} + +namespace svt { class PopupWindowControllerImpl; } + +// --------------- +// - WindowTypes - +// --------------- + +// Type fuer GetWindow() +#define WINDOW_PARENT ((sal_uInt16)0) +#define WINDOW_FIRSTCHILD ((sal_uInt16)1) +#define WINDOW_LASTCHILD ((sal_uInt16)2) +#define WINDOW_PREV ((sal_uInt16)3) +#define WINDOW_NEXT ((sal_uInt16)4) +#define WINDOW_FIRSTOVERLAP ((sal_uInt16)5) +#define WINDOW_LASTOVERLAP ((sal_uInt16)6) +#define WINDOW_OVERLAP ((sal_uInt16)7) +#define WINDOW_PARENTOVERLAP ((sal_uInt16)8) +#define WINDOW_CLIENT ((sal_uInt16)9) +#define WINDOW_REALPARENT ((sal_uInt16)10) +#define WINDOW_FRAME ((sal_uInt16)11) +#define WINDOW_BORDER ((sal_uInt16)12) +#define WINDOW_FIRSTTOPWINDOWCHILD ((sal_uInt16)13) +#define WINDOW_LASTTOPWINDOWCHILD ((sal_uInt16)14) +#define WINDOW_PREVTOPWINDOWSIBLING ((sal_uInt16)15) +#define WINDOW_NEXTTOPWINDOWSIBLING ((sal_uInt16)16) + +// Flags for SetPosSizePixel() +#define WINDOW_POSSIZE_X ((sal_uInt16)0x0001) +#define WINDOW_POSSIZE_Y ((sal_uInt16)0x0002) +#define WINDOW_POSSIZE_WIDTH ((sal_uInt16)0x0004) +#define WINDOW_POSSIZE_HEIGHT ((sal_uInt16)0x0008) +#define WINDOW_POSSIZE_POS (WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y) +#define WINDOW_POSSIZE_SIZE (WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT) +#define WINDOW_POSSIZE_POSSIZE (WINDOW_POSSIZE_POS | WINDOW_POSSIZE_SIZE) +#define WINDOW_POSSIZE_ALL (WINDOW_POSSIZE_POSSIZE) +#define WINDOW_POSSIZE_DROPDOWN ((sal_uInt16)0x0010) + +// Flags for Show() +#define SHOW_NOPARENTUPDATE ((sal_uInt16)0x0001) +#define SHOW_NOFOCUSCHANGE ((sal_uInt16)0x0002) +#define SHOW_NOACTIVATE ((sal_uInt16)0x0004) +#define SHOW_FOREGROUNDTASK ((sal_uInt16)0x0008) + +// Flags for SetZOrder() +#define WINDOW_ZORDER_BEFOR ((sal_uInt16)0x0001) +#define WINDOW_ZORDER_BEHIND ((sal_uInt16)0x0002) +#define WINDOW_ZORDER_FIRST ((sal_uInt16)0x0004) +#define WINDOW_ZORDER_LAST ((sal_uInt16)0x0008) + +// Activate-Flags +#define ACTIVATE_MODE_GRABFOCUS ((sal_uInt16)0x0001) + +// ToTop-Flags +#define TOTOP_RESTOREWHENMIN ((sal_uInt16)0x0001) +#define TOTOP_FOREGROUNDTASK ((sal_uInt16)0x0002) +#define TOTOP_NOGRABFOCUS ((sal_uInt16)0x0004) +#define TOTOP_GRABFOCUSONLY ((sal_uInt16)0x0008) + +// Flags for Invalidate +#define INVALIDATE_CHILDREN ((sal_uInt16)0x0001) +#define INVALIDATE_NOCHILDREN ((sal_uInt16)0x0002) +#define INVALIDATE_NOERASE ((sal_uInt16)0x0004) +#define INVALIDATE_UPDATE ((sal_uInt16)0x0008) +#define INVALIDATE_TRANSPARENT ((sal_uInt16)0x0010) +#define INVALIDATE_NOTRANSPARENT ((sal_uInt16)0x0020) +#define INVALIDATE_NOCLIPCHILDREN ((sal_uInt16)0x4000) +// Temporaer fuer Kompatibilitaet +#define INVALIDATE_BACKGROUND INVALIDATE_TRANSPARENT + +// Flags for Validate +#define VALIDATE_CHILDREN ((sal_uInt16)0x0001) +#define VALIDATE_NOCHILDREN ((sal_uInt16)0x0002) + +// Flags for Scroll +#define SCROLL_CLIP ((sal_uInt16)0x0001) +#define SCROLL_CHILDREN ((sal_uInt16)0x0002) +#define SCROLL_NOCHILDREN ((sal_uInt16)0x0004) +#define SCROLL_NOERASE ((sal_uInt16)0x0008) +#define SCROLL_NOINVALIDATE ((sal_uInt16)0x0010) +#define SCROLL_NOWINDOWINVALIDATE ((sal_uInt16)0x0020) +#define SCROLL_USECLIPREGION ((sal_uInt16)0x0040) +#define SCROLL_UPDATE ((sal_uInt16)0x0080) + +// Flags for ParentClipMode +#define PARENTCLIPMODE_CLIP ((sal_uInt16)0x0001) +#define PARENTCLIPMODE_NOCLIP ((sal_uInt16)0x0002) + +// Flags for Invert() +#define INVERT_HIGHLIGHT ((sal_uInt16)0x0001) +#define INVERT_50 ((sal_uInt16)0x0002) + +// Flags for ShowTracking() +#define SHOWTRACK_SMALL ((sal_uInt16)0x0001) +#define SHOWTRACK_BIG ((sal_uInt16)0x0002) +#define SHOWTRACK_SPLIT ((sal_uInt16)0x0003) +#define SHOWTRACK_OBJECT ((sal_uInt16)0x0004) +#define SHOWTRACK_WINDOW ((sal_uInt16)0x1000) +#define SHOWTRACK_CLIP ((sal_uInt16)0x2000) +#define SHOWTRACK_STYLE ((sal_uInt16)0x000F) + +// Flags for StartTracking() +#define STARTTRACK_KEYINPUT ((sal_uInt16)0x0001) +#define STARTTRACK_KEYMOD ((sal_uInt16)0x0002) +#define STARTTRACK_NOKEYCANCEL ((sal_uInt16)0x0004) +#define STARTTRACK_SCROLLREPEAT ((sal_uInt16)0x0008) +#define STARTTRACK_BUTTONREPEAT ((sal_uInt16)0x0010) +#define STARTTRACK_MOUSEBUTTONDOWN ((sal_uInt16)0x0020) +#define STARTTRACK_FOCUSCANCEL ((sal_uInt16)0x0040) + +// Flags for StartAutoScroll() +#define AUTOSCROLL_VERT ((sal_uInt16)0x0001) +#define AUTOSCROLL_HORZ ((sal_uInt16)0x0002) + +// Flags for StateChanged() +typedef sal_uInt16 StateChangedType; +#define STATE_CHANGE_INITSHOW ((StateChangedType)1) +#define STATE_CHANGE_VISIBLE ((StateChangedType)2) +#define STATE_CHANGE_UPDATEMODE ((StateChangedType)3) +#define STATE_CHANGE_ENABLE ((StateChangedType)4) +#define STATE_CHANGE_TEXT ((StateChangedType)5) +#define STATE_CHANGE_IMAGE ((StateChangedType)6) +#define STATE_CHANGE_DATA ((StateChangedType)7) +#define STATE_CHANGE_STATE ((StateChangedType)8) +#define STATE_CHANGE_STYLE ((StateChangedType)9) +#define STATE_CHANGE_ZOOM ((StateChangedType)10) +#define STATE_CHANGE_BORDER ((StateChangedType)11) +#define STATE_CHANGE_TRANSPARENT ((StateChangedType)12) +#define STATE_CHANGE_CONTROLFONT ((StateChangedType)13) +#define STATE_CHANGE_CONTROLFOREGROUND ((StateChangedType)14) +#define STATE_CHANGE_CONTROLBACKGROUND ((StateChangedType)15) +#define STATE_CHANGE_READONLY ((StateChangedType)16) +#define STATE_CHANGE_FORMAT ((StateChangedType)17) +#define STATE_CHANGE_EXTENDEDSTYLE ((StateChangedType)18) +#define STATE_CHANGE_MIRRORING ((StateChangedType)19) +#define STATE_CHANGE_USER ((StateChangedType)10000) + +// GetFocusFlags +#define GETFOCUS_TAB ((sal_uInt16)0x0001) +#define GETFOCUS_CURSOR ((sal_uInt16)0x0002) +#define GETFOCUS_MNEMONIC ((sal_uInt16)0x0004) +#define GETFOCUS_FORWARD ((sal_uInt16)0x0010) +#define GETFOCUS_BACKWARD ((sal_uInt16)0x0020) +#define GETFOCUS_AROUND ((sal_uInt16)0x0040) +#define GETFOCUS_UNIQUEMNEMONIC ((sal_uInt16)0x0100) +#define GETFOCUS_INIT ((sal_uInt16)0x0200) +#define GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL ((sal_uInt16)0x0400) + +// Draw-Flags fuer Draw() +#define WINDOW_DRAW_MONO ((sal_uLong)0x00000001) +#define WINDOW_DRAW_NOBORDER ((sal_uLong)0x00000002) +#define WINDOW_DRAW_NOCONTROLS ((sal_uLong)0x00000004) +#define WINDOW_DRAW_NODISABLE ((sal_uLong)0x00000008) +#define WINDOW_DRAW_NOMNEMONIC ((sal_uLong)0x00000010) +#define WINDOW_DRAW_NOSELECTION ((sal_uLong)0x00000020) +#define WINDOW_DRAW_NOFOCUS ((sal_uLong)0x00000040) +#define WINDOW_DRAW_NOBACKGROUND ((sal_uLong)0x00000080) +#define WINDOW_DRAW_ROLLOVER ((sal_uLong)0x00000100) + +// Border-Styles fuer SetBorder() +#define WINDOW_BORDER_NORMAL ((sal_uInt16)0x0001) +#define WINDOW_BORDER_MONO ((sal_uInt16)0x0002) +#define WINDOW_BORDER_ACTIVE ((sal_uInt16)0x0004) +#define WINDOW_BORDER_DOUBLEOUT ((sal_uInt16)0x0008) +#define WINDOW_BORDER_MENU ((sal_uInt16)0x0010) +#define WINDOW_BORDER_NOBORDER ((sal_uInt16)0x1000) +#define WINDOW_BORDER_REMOVEBORDER ((sal_uInt16)0x2000) + +// DialogControl-Flags +#define WINDOW_DLGCTRL_RETURN ((sal_uInt16)0x0001) +#define WINDOW_DLGCTRL_WANTFOCUS ((sal_uInt16)0x0002) +#define WINDOW_DLGCTRL_MOD1TAB ((sal_uInt16)0x0004) +#define WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ((sal_uInt16)0x0008) + +// GetWindowClipRegionPixel-Flags +#define WINDOW_GETCLIPREGION_NULL ((sal_uInt16)0x0001) +#define WINDOW_GETCLIPREGION_NOCHILDREN ((sal_uInt16)0x0002) + +// EndExtTextInput-Flags +#define EXTTEXTINPUT_END_COMPLETE ((sal_uInt16)0x0001) +#define EXTTEXTINPUT_END_CANCEL ((sal_uInt16)0x0002) + +#define IMPL_MINSIZE_BUTTON_WIDTH 70 +#define IMPL_MINSIZE_BUTTON_HEIGHT 22 +#define IMPL_EXTRA_BUTTON_WIDTH 18 +#define IMPL_EXTRA_BUTTON_HEIGHT 10 +#define IMPL_SEP_BUTTON_X 5 +#define IMPL_SEP_BUTTON_Y 5 +#define IMPL_MINSIZE_MSGBOX_WIDTH 150 +#define IMPL_MINSIZE_MSGBOX_HEIGHT 80 +#define IMPL_DIALOG_OFFSET 5 +#define IMPL_DIALOG_BAR_OFFSET 3 +#define IMPL_MSGBOX_OFFSET_EXTRA_X 0 +#define IMPL_MSGBOX_OFFSET_EXTRA_Y 2 +#define IMPL_SEP_MSGBOX_IMAGE 8 + +#define DLGWINDOW_PREV 0 +#define DLGWINDOW_NEXT 1 +#define DLGWINDOW_FIRST 2 + +enum WindowSizeType { + WINDOWSIZE_MINIMUM, + WINDOWSIZE_PREFERRED, + WINDOWSIZE_MAXIMUM +}; + +// ---------- +// - Window - +// ---------- + +#ifdef DBG_UTIL +const char* ImplDbgCheckWindow( const void* pObj ); +#endif + +class WindowImpl; +class VCL_DLLPUBLIC Window : public OutputDevice +{ + friend class Cursor; + friend class OutputDevice; + friend class Application; + friend class SystemWindow; + friend class WorkWindow; + friend class Dialog; + friend class MessBox; + friend class DockingWindow; + friend class FloatingWindow; + friend class GroupBox; + friend class PushButton; + friend class RadioButton; + friend class SystemChildWindow; + friend class ImplBorderWindow; + + // TODO: improve missing functionality + // only required because of SetFloatingMode() + friend class ImplDockingWindowWrapper; + friend class ImplPopupFloatWin; + friend class MenuFloatingWindow; + + friend class svt::PopupWindowControllerImpl; + +private: + // NOTE: to remove many dependencies of other modules + // to this central file, all members are now hidden + // in the WindowImpl class and all inline functions + // were removed + // + // Please do *not* add new members or inline functions to class Window, + // but use class WindowImpl instead + // + WindowImpl* mpWindowImpl; + + SAL_DLLPRIVATE void ImplInitWindowData( WindowType nType ); + +#ifdef DBG_UTIL + friend const char* ImplDbgCheckWindow( const void* pObj ); +#endif + friend Window* ImplFindWindow( const SalFrame* pFrame, Point& rSalFramePos ); +public: + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ); + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken ); + SAL_DLLPRIVATE WinBits ImplInitRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplWindowRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplSetFrameParent( const Window* pParent ); + SAL_DLLPRIVATE void ImplInsertWindow( Window* pParent ); + SAL_DLLPRIVATE void ImplRemoveWindow( sal_Bool bRemoveFrameData ); + SAL_DLLPRIVATE Window* ImplGetWindow(); + SAL_DLLPRIVATE ImplFrameData* ImplGetFrameData(); + SAL_DLLPRIVATE SalFrame* ImplGetFrame() const; + SAL_DLLPRIVATE ImplWinData* ImplGetWinData() const; + SAL_DLLPRIVATE SalGraphics* ImplGetFrameGraphics() const; + SAL_DLLPRIVATE void ImplCallFocusChangeActivate( Window* pNewOverlapWindow, Window* pOldOverlapWindow ); + SAL_DLLPRIVATE Window* ImplFindWindow( const Point& rFramePos ); + SAL_DLLPRIVATE sal_uInt16 ImplHitTest( const Point& rFramePos ); + SAL_DLLPRIVATE Window* ImplGetParent() const; + SAL_DLLPRIVATE Window* ImplGetClientWindow() const; + SAL_DLLPRIVATE Window* ImplGetBorderWindow() const; + SAL_DLLPRIVATE Window* ImplGetFirstOverlapWindow(); + SAL_DLLPRIVATE const Window* ImplGetFirstOverlapWindow() const; + SAL_DLLPRIVATE Window* ImplGetFrameWindow() const; + SAL_DLLPRIVATE sal_Bool ImplIsRealParentPath( const Window* pWindow ) const; + SAL_DLLPRIVATE sal_Bool ImplIsChild( const Window* pWindow, sal_Bool bSystemWindow = sal_False ) const; + SAL_DLLPRIVATE sal_Bool ImplIsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow = sal_False ) const; + SAL_DLLPRIVATE Window* ImplGetSameParent( const Window* pWindow ) const; + SAL_DLLPRIVATE sal_Bool ImplIsDockingWindow() const; + SAL_DLLPRIVATE sal_Bool ImplIsFloatingWindow() const; + SAL_DLLPRIVATE sal_Bool ImplIsToolbox() const; + SAL_DLLPRIVATE sal_Bool ImplIsSplitter() const; + SAL_DLLPRIVATE sal_Bool ImplIsPushButton() const; + SAL_DLLPRIVATE sal_Bool ImplIsOverlapWindow() const; + SAL_DLLPRIVATE void ImplSetActive( sal_Bool bActive ); + SAL_DLLPRIVATE sal_Bool ImplIsMouseTransparent() const; + SAL_DLLPRIVATE void ImplSetMouseTransparent( sal_Bool bTransparent ); + SAL_DLLPRIVATE int ImplTestMousePointerSet(); + SAL_DLLPRIVATE PointerStyle ImplGetMousePointer() const; + SAL_DLLPRIVATE void ImplResetReallyVisible(); + SAL_DLLPRIVATE void ImplSetReallyVisible(); + SAL_DLLPRIVATE void ImplCallInitShow(); + SAL_DLLPRIVATE void ImplAddDel( ImplDelData* pDel ); + SAL_DLLPRIVATE void ImplRemoveDel( ImplDelData* pDel ); + SAL_DLLPRIVATE void ImplInitResolutionSettings(); + SAL_DLLPRIVATE void ImplPointToLogic( Font& rFont ) const; + SAL_DLLPRIVATE void ImplLogicToPoint( Font& rFont ) const; + SAL_DLLPRIVATE Point ImplOutputToFrame( const Point& rPos ); + SAL_DLLPRIVATE Point ImplFrameToOutput( const Point& rPos ); + SAL_DLLPRIVATE void ImplOutputToFrame( Rectangle& rRect ); + SAL_DLLPRIVATE void ImplFrameToOutput( Rectangle& rRect ); + SAL_DLLPRIVATE sal_Bool ImplSysObjClip( const Region* pOldRegion ); + SAL_DLLPRIVATE void ImplUpdateSysObjChildsClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjOverlapsClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjClip(); + SAL_DLLPRIVATE sal_Bool ImplSetClipFlagChilds( sal_Bool bSysObjOnlySmaller = sal_False ); + SAL_DLLPRIVATE sal_Bool ImplSetClipFlagOverlapWindows( sal_Bool bSysObjOnlySmaller = sal_False ); + SAL_DLLPRIVATE sal_Bool ImplSetClipFlag( sal_Bool bSysObjOnlySmaller = sal_False ); + SAL_DLLPRIVATE void ImplIntersectWindowClipRegion( Region& rRegion ); + SAL_DLLPRIVATE void ImplIntersectWindowRegion( Region& rRegion ); + SAL_DLLPRIVATE void ImplExcludeWindowRegion( Region& rRegion ); + SAL_DLLPRIVATE void ImplExcludeOverlapWindows( Region& rRegion ); + SAL_DLLPRIVATE void ImplExcludeOverlapWindows2( Region& rRegion ); + SAL_DLLPRIVATE void ImplClipBoundaries( Region& rRegion, sal_Bool bThis, sal_Bool bOverlaps ); + SAL_DLLPRIVATE sal_Bool ImplClipChilds( Region& rRegion ); + SAL_DLLPRIVATE void ImplClipAllChilds( Region& rRegion ); + SAL_DLLPRIVATE void ImplClipSiblings( Region& rRegion ); + SAL_DLLPRIVATE void ImplInitWinClipRegion(); + SAL_DLLPRIVATE void ImplInitWinChildClipRegion(); + SAL_DLLPRIVATE Region* ImplGetWinChildClipRegion(); + SAL_DLLPRIVATE void ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion ); + SAL_DLLPRIVATE void ImplIntersectAndUnionOverlapWindows2( const Region& rInterRegion, Region& rRegion ); + SAL_DLLPRIVATE void ImplCalcOverlapRegionOverlaps( const Region& rInterRegion, Region& rRegion ); + SAL_DLLPRIVATE void ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegion, + sal_Bool bChilds, sal_Bool bParent, sal_Bool bSiblings ); + SAL_DLLPRIVATE void ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags ); + SAL_DLLPRIVATE void ImplCallOverlapPaint(); + SAL_DLLPRIVATE void ImplPostPaint(); + SAL_DLLPRIVATE void ImplInvalidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplInvalidateOverlapFrameRegion( const Region& rRegion ); + SAL_DLLPRIVATE void ImplInvalidateParentFrameRegion( Region& rRegion ); + SAL_DLLPRIVATE void ImplInvalidate( const Region* rRegion, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplValidateFrameRegion( const Region* rRegion, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplValidate( const Region* rRegion, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplMoveInvalidateRegion( const Rectangle& rRect, long nHorzScroll, long nVertScroll, sal_Bool bChilds ); + SAL_DLLPRIVATE void ImplMoveAllInvalidateRegions( const Rectangle& rRect, long nHorzScroll, long nVertScroll, sal_Bool bChilds ); + SAL_DLLPRIVATE void ImplScroll( const Rectangle& rRect, long nHorzScroll, long nVertScroll, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplUpdateAll( sal_Bool bOverlapWindows = sal_True ); + SAL_DLLPRIVATE void ImplUpdateWindowPtr( Window* pWindow ); + SAL_DLLPRIVATE void ImplUpdateWindowPtr(); + SAL_DLLPRIVATE void ImplUpdateOverlapWindowPtr( sal_Bool bNewFrame ); + SAL_DLLPRIVATE sal_Bool ImplUpdatePos(); + SAL_DLLPRIVATE void ImplUpdateSysObjPos(); + SAL_DLLPRIVATE WindowImpl* ImplGetWindowImpl() const { return mpWindowImpl; } + SAL_DLLPRIVATE void ImplFreeExtWindowImpl(); + // creates ExtWindowImpl on demand, but may return NULL (e.g. if mbInDtor) + SAL_DLLPRIVATE vcl::ExtWindowImpl* ImplGetExtWindowImpl() const; + SAL_DLLPRIVATE void ImplDeleteOwnedChildren(); + /** check whether a font is suitable for UI + + The font to be tested will be checked whether it could display a + localized test string. If this is not the case, then the font + is deemed unsuitable as UI font. + + @param rFont + the font to be tested + + @returns + <TRUE/> if the font can be used as UI font + <FALSE/> if the font is unsuitable as UI font + */ + SAL_DLLPRIVATE bool ImplCheckUIFont( const Font& rFont ); + SAL_DLLPRIVATE void ImplUpdateGlobalSettings( AllSettings& rSettings, sal_Bool bCallHdl = sal_True ); + SAL_DLLPRIVATE void ImplAlignChilds(); + SAL_DLLPRIVATE void ImplPosSizeWindow( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplToBottomChild(); + SAL_DLLPRIVATE void ImplCalcToTop( ImplCalcToTopData* pPrevData ); + SAL_DLLPRIVATE void ImplCalcChildOverlapToTop( ImplCalcToTopData* pPrevData ); + SAL_DLLPRIVATE void ImplToTop( sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplStartToTop( sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplFocusToTop( sal_uInt16 nFlags, sal_Bool bReallyVisible ); + SAL_DLLPRIVATE void ImplShowAllOverlaps(); + SAL_DLLPRIVATE void ImplHideAllOverlaps(); + SAL_DLLPRIVATE void ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt ); + SAL_DLLPRIVATE void ImplCallMouseMove( sal_uInt16 nMouseCode, sal_Bool bModChanged = sal_False ); + SAL_DLLPRIVATE void ImplGenerateMouseMove(); + SAL_DLLPRIVATE void ImplGrabFocus( sal_uInt16 nFlags ); + SAL_DLLPRIVATE void ImplInvertFocus( const Rectangle& rRect ); + SAL_DLLPRIVATE void ImplControlFocus( sal_uInt16 nFlags = 0 ); + SAL_DLLPRIVATE Window* ImplGetDlgWindow( sal_uInt16 n, sal_uInt16 nType, sal_uInt16 nStart = 0, sal_uInt16 nEnd = 0xFFFF, sal_uInt16* pIndex = NULL ); + SAL_DLLPRIVATE sal_Bool ImplDlgCtrl( const KeyEvent& rKEvt, sal_Bool bKeyInput ); + SAL_DLLPRIVATE sal_Bool ImplHasDlgCtrl(); + SAL_DLLPRIVATE void ImplDlgCtrlNextWindow(); + SAL_DLLPRIVATE void ImplDlgCtrlFocusChanged( Window* pWindow, sal_Bool bGetFocus ); + SAL_DLLPRIVATE Window* ImplFindDlgCtrlWindow( Window* pWindow ); + SAL_DLLPRIVATE long ImplLogicUnitToPixelX( long nX, MapUnit eUnit ); + SAL_DLLPRIVATE long ImplLogicUnitToPixelY( long nY, MapUnit eUnit ); + SAL_DLLPRIVATE sal_Bool ImplIsWindowInFront( const Window* pTestWindow ) const; + SAL_DLLPRIVATE void ImplSaveOverlapBackground(); + SAL_DLLPRIVATE sal_Bool ImplRestoreOverlapBackground( Region& rInvRegion ); + SAL_DLLPRIVATE void ImplDeleteOverlapBackground(); + SAL_DLLPRIVATE void ImplInvalidateAllOverlapBackgrounds(); + SAL_DLLPRIVATE static void ImplNewInputContext(); + SAL_DLLPRIVATE void ImplCallActivateListeners(Window*); + SAL_DLLPRIVATE void ImplCallDeactivateListeners(Window*); + DECL_DLLPRIVATE_LINK( ImplHandlePaintHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplGenerateMouseMoveHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplTrackTimerHdl, Timer* ); + DECL_DLLPRIVATE_LINK( ImplAsyncFocusHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplAsyncStateChangedHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplHideOwnerDrawWindowsHdl, void* ); + DECL_DLLPRIVATE_LINK( ImplHandleResizeTimerHdl, void* ); + + SAL_DLLPRIVATE static void ImplCalcSymbolRect( Rectangle& rRect ); + SAL_DLLPRIVATE void ImplHandleScroll( ScrollBar* pHScrl, long nX, ScrollBar* pVScrl, long nY ); + SAL_DLLPRIVATE sal_Bool ImplGetCurrentBackgroundColor( Color& rCol ); + SAL_DLLPRIVATE sal_Bool ImplIsAccessibleCandidate() const; + SAL_DLLPRIVATE sal_Bool ImplIsAccessibleNativeFrame() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetAccessibleCandidateChildWindowCount( sal_uInt16 nFirstWindowType ) const; + SAL_DLLPRIVATE Window* ImplGetAccessibleCandidateChild( sal_uInt16 nChild, sal_uInt16& rChildCount, sal_uInt16 nFirstWindowType, sal_Bool bTopLevel = sal_True ) const; + SAL_DLLPRIVATE sal_Bool ImplRegisterAccessibleNativeFrame(); + SAL_DLLPRIVATE void ImplRevokeAccessibleNativeFrame(); + SAL_DLLPRIVATE void ImplCallResize(); + SAL_DLLPRIVATE void ImplExtResize(); + SAL_DLLPRIVATE void ImplCallMove(); + SAL_DLLPRIVATE Rectangle ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle& rRect ) const; + SAL_DLLPRIVATE void ImplMirrorFramePos( Point &pt ) const; + SAL_DLLPRIVATE long ImplGetUnmirroredOutOffX(); + SAL_DLLPRIVATE void ImplIncModalCount(); + SAL_DLLPRIVATE void ImplDecModalCount(); + + // retrieves the list of owner draw decorated windows for this window hiearchy + SAL_DLLPRIVATE ::std::vector<Window *>& ImplGetOwnerDrawList(); + SAL_DLLPRIVATE Window* ImplGetTopmostFrameWindow(); + + SAL_DLLPRIVATE Rectangle ImplGetWindowExtentsRelative( Window *pRelativeWindow, sal_Bool bClientOnly ) const; + SAL_DLLPRIVATE void ImplNotifyIconifiedState( sal_Bool bIconified ); + SAL_DLLPRIVATE bool ImplStopDnd(); + SAL_DLLPRIVATE void ImplStartDnd(); + + SAL_DLLPRIVATE static void ImplInitAppFontData( Window* pWindow ); + SAL_DLLPRIVATE void ImplPaintToDevice( OutputDevice* pTargetOutDev, const Point& rPos ); + + SAL_DLLPRIVATE sal_Bool ImplIsInTaskPaneList(); + SAL_DLLPRIVATE void ImplIsInTaskPaneList( sal_Bool mbIsInTaskList ); + SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > + ImplGetCanvas( const Size& rFullscreenSize, bool bFullscreen, bool bSpriteCanvas ) const; + +private: + // Default construction is forbidden and not implemented. + SAL_DLLPRIVATE Window(); + + // Copy assignment is forbidden and not implemented. + SAL_DLLPRIVATE Window (const Window &); + SAL_DLLPRIVATE Window & operator= (const Window &); + +protected: + // Single argument ctors shall be explicit. + explicit Window( WindowType nType ); + + void SetCompoundControl( sal_Bool bCompound ); + + void ImplCallEventListeners( sal_uLong nEvent, void* pData = NULL ); + void CallEventListeners( sal_uLong nEvent, void* pData = NULL ); + void FireVclEvent( VclSimpleEvent* pEvent ); + + // FIXME: this is a hack to workaround missing layout functionality + SAL_DLLPRIVATE void ImplAdjustNWFSizes(); +public: + // Single argument ctors shall be explicit. + explicit Window( Window* pParent, WinBits nStyle = 0 ); + + Window( Window* pParent, const ResId& rResId ); + virtual ~Window(); + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void PrePaint(); + virtual void Paint( const Rectangle& rRect ); + + virtual void PostPaint(); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + virtual void Move(); + virtual void Resize(); + virtual void Activate(); + virtual void Deactivate(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void UserEvent( sal_uLong nEvent, void* pEventData ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual Window* GetPreferredKeyInputWindow(); + + /*virtual*/ void AddEventListener( const Link& rEventListener ); + /*virtual*/ void RemoveEventListener( const Link& rEventListener ); + /*virtual*/ void AddChildEventListener( const Link& rEventListener ); + /*virtual*/ void RemoveChildEventListener( const Link& rEventListener ); + + sal_uLong PostUserEvent( sal_uLong nEvent, void* pEventData = NULL ); + sal_uLong PostUserEvent( const Link& rLink, void* pCaller = NULL ); + sal_Bool PostUserEvent( sal_uLong& rEventId, sal_uLong nEvent, void* pEventData = NULL ); + sal_Bool PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL ); + void RemoveUserEvent( sal_uLong nUserEvent ); + void PostStateChanged( StateChangedType nState ); + + void IncrementLockCount(); + void DecrementLockCount(); + sal_Bool IsLocked( sal_Bool bChilds = sal_False ) const; + + // returns the input language used for the last key stroke + // may be LANGUAGE_DONTKNOW if not supported by the OS + LanguageType GetInputLanguage() const; + + void SetStyle( WinBits nStyle ); + WinBits GetStyle() const; + WinBits GetPrevStyle() const; + void SetExtendedStyle( WinBits nExtendedStyle ); + WinBits GetExtendedStyle() const; + WinBits GetPrevExtendedStyle() const; + void SetType( WindowType nType ); + WindowType GetType() const; + sal_Bool IsSystemWindow() const; + sal_Bool IsDialog() const; + sal_Bool IsMenuFloatingWindow() const; + sal_Bool IsToolbarFloatingWindow() const; + sal_Bool IsTopWindow() const; + SystemWindow* GetSystemWindow() const; + + void EnableAllResize( sal_Bool bEnable = sal_True ); + sal_Bool IsAllResizeEnabled() const; + + void SetBorderStyle( sal_uInt16 nBorderStyle ); + sal_uInt16 GetBorderStyle() const; + void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + Size CalcWindowSize( const Size& rOutSz ) const; + Size CalcOutputSize( const Size& rWinSz ) const; + long CalcTitleWidth() const; + + void EnableClipSiblings( sal_Bool bClipSiblings = sal_True ); + sal_Bool IsClipSiblingsEnabled() const; + + void EnableChildTransparentMode( sal_Bool bEnable = sal_True ); + sal_Bool IsChildTransparentModeEnabled() const; + + void SetMouseTransparent( sal_Bool bTransparent ); + sal_Bool IsMouseTransparent() const; + void SetPaintTransparent( sal_Bool bTransparent ); + sal_Bool IsPaintTransparent() const; + void SetDialogControlStart( sal_Bool bStart ); + sal_Bool IsDialogControlStart() const; + void SetDialogControlFlags( sal_uInt16 nFlags ); + sal_uInt16 GetDialogControlFlags() const; + + struct PointerState + { + sal_uLong mnState; // the button state + Point maPos; // mouse position in output coordinates + }; + PointerState GetPointerState(); + sal_Bool IsMouseOver(); + + sal_uLong GetCurrentModButtons(); + + void SetInputContext( const InputContext& rInputContext ); + const InputContext& GetInputContext() const; + void EndExtTextInput( sal_uInt16 nFlags ); + sal_Bool IsExtTextInput() const; + void SetCursorRect( const Rectangle* pRect = NULL, long nExtTextInputWidth = 0 ); + const Rectangle* GetCursorRect() const; + long GetCursorExtTextInputWidth() const; + + void EnableChildNotify( sal_Bool bEnable ); + sal_Bool IsChildNotify() const; + + using OutputDevice::SetSettings; + virtual void SetSettings( const AllSettings& rSettings ); + virtual void SetSettings( const AllSettings& rSettings, sal_Bool bChild ); + void UpdateSettings( const AllSettings& rSettings, sal_Bool bChild = sal_False ); + void NotifyAllChilds( DataChangedEvent& rDCEvt ); + + void SetPointFont( const Font& rFont ); + Font GetPointFont() const; + void SetZoomedPointFont( const Font& rFont ); + long GetDrawPixel( OutputDevice* pDev, long nPixels ) const; + Font GetDrawPixelFont( OutputDevice* pDev ) const; + + void SetControlFont(); + void SetControlFont( const Font& rFont ); + Font GetControlFont() const; + sal_Bool IsControlFont() const; + void SetControlForeground(); + void SetControlForeground( const Color& rColor ); + Color GetControlForeground() const; + sal_Bool IsControlForeground() const; + void SetControlBackground(); + void SetControlBackground( const Color& rColor ); + Color GetControlBackground() const; + sal_Bool IsControlBackground() const; + + void SetParentClipMode( sal_uInt16 nMode = 0 ); + sal_uInt16 GetParentClipMode() const; + + void SetWindowRegionPixel(); + void SetWindowRegionPixel( const Region& rRegion ); + const Region& GetWindowRegionPixel() const; + sal_Bool IsWindowRegionPixel() const; + Region GetWindowClipRegionPixel( sal_uInt16 nFlags = 0 ) const; + Region GetPaintRegion() const; + sal_Bool IsInPaint() const; + // while IsInPaint returns true ExpandPaintClipRegion adds the + // submitted region to the paint clip region so you can + // paint additional parts of your window if necessary + void ExpandPaintClipRegion( const Region& rRegion ); + + void SetParent( Window* pNewParent ); + Window* GetParent() const; + + void Show( sal_Bool bVisible = sal_True, sal_uInt16 nFlags = 0 ); + void Hide( sal_uInt16 nFlags = 0 ) { Show( sal_False, nFlags ); } + sal_Bool IsVisible() const; + sal_Bool IsReallyVisible() const; + // Do not use this function, use IsReallyVisible() + sal_Bool IsParentPathVisible() const; + sal_Bool IsReallyShown() const; + sal_Bool IsInInitShow() const; + + void Enable( bool bEnable = true, bool bChild = true ); + void Disable( bool bChild = true ) { Enable( false, bChild ); } + sal_Bool IsEnabled() const; + + void EnableInput( sal_Bool bEnable = sal_True, sal_Bool bChild = sal_True ); + void EnableInput( sal_Bool bEnable, sal_Bool bChild, sal_Bool bSysWin, + const Window* pExcludeWindow = NULL ); + sal_Bool IsInputEnabled() const; + + /** Override <code>EnableInput</code>. This can be necessary due to other people + using EnableInput for whole window hierarchies. + + + <code>AlwaysEnableInput</code> and <code>AlwaysDisableInput</code> are + mutually exclusive; the last setter wins. + @param bAlways + sets always enabled flag + + @param bChild + if true children are recursively set to AlwaysEnableInput + */ + void AlwaysEnableInput( sal_Bool bAlways, sal_Bool bChild = sal_True ); + /** returns the current AlwaysEnableInput state + @return + true if window is in AlwaysEnableInput state + */ + sal_Bool IsAlwaysEnableInput() const; + /** Override <code>EnableInput</code>, counterpart to AlwaysEnableInput. + Windows with AlwaysDisableInput will not get key events even if enabled + and input enabled.This can be necessary due to other people using EnableInput + for whole window hierarchies. + + <code>AlwaysEnableInput</code> and <code>AlwaysDisableInput</code> are + mutually exclusive; the last setter wins. + + @param bAlways + sets always disable flag + + @param bChild + if true children are recursively set to AlwaysDisableInput + */ + void AlwaysDisableInput( sal_Bool bAlways, sal_Bool bChild = sal_True ); + /** returns the current AlwaysDisableInput state + @return + true if window is in AlwaysEnableInput state + */ + sal_Bool IsAlwaysDisableInput() const; + /** usually event handlers (see AddEventListener and AddChildEventListener) + are not called on disabled, modal or input disabled windows. There are however rare cases + in which one wants a Window or rather one of its Control subclasses to + not evaluate events but still react to those events externally. In these + rare cases call SetCallHandlersOnInputDisabled( true ) to have your handler + called anyway. + + Currently only mouse events get this special treatment. + + Use this sparingly, chances are if you want to use it you're wroking around + the real problem. + + @param bCall + Enable/Disable calling event handlers for this disabled, modal or input disabled window. + This call is implicity done recursively for possible child windows. + */ + void SetCallHandlersOnInputDisabled( bool bCall ); + /** get state of SetCallHandlersOnInputDisabled + + @returns whether handlers are called regardless of input enabled state + */ + bool IsCallHandlersOnInputDisabled() const; + /** A window is in modal mode if one of its children or subchildren + is a running modal window (a modal dialog) + + @returns sal_True if a child or subchild is a running modal window + */ + sal_Bool IsInModalMode() const; + + void SetActivateMode( sal_uInt16 nMode ); + sal_uInt16 GetActivateMode() const; + + void ToTop( sal_uInt16 nFlags = 0 ); + void SetZOrder( Window* pRefWindow, sal_uInt16 nFlags ); + void EnableAlwaysOnTop( sal_Bool bEnable = sal_True ); + sal_Bool IsAlwaysOnTopEnabled() const; + + virtual void SetPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + sal_uInt16 nFlags = WINDOW_POSSIZE_ALL ); + virtual void SetPosPixel( const Point& rNewPos ); + virtual Point GetPosPixel() const; + virtual void SetSizePixel( const Size& rNewSize ); + virtual Size GetSizePixel() const; + virtual void SetPosSizePixel( const Point& rNewPos, + const Size& rNewSize ); + virtual void SetOutputSizePixel( const Size& rNewSize ); + sal_Bool IsDefaultPos() const; + sal_Bool IsDefaultSize() const; + + // those conversion routines might deliver different results during UI mirroring + Point OutputToScreenPixel( const Point& rPos ) const; + Point ScreenToOutputPixel( const Point& rPos ) const; + // the normalized screen methods work independent from UI mirroring + Point OutputToNormalizedScreenPixel( const Point& rPos ) const; + Point NormalizedScreenToOutputPixel( const Point& rPos ) const; + Point OutputToAbsoluteScreenPixel( const Point& rPos ) const; + Point AbsoluteScreenToOutputPixel( const Point& rPos ) const; + Rectangle GetDesktopRectPixel() const; + // window extents including border and decoratrion + Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; + // window extents of the client window, coordinates to be used in SetPosPixel + Rectangle GetClientWindowExtentsRelative( Window *pRelativeWindow ) const; + + virtual sal_Bool IsScrollable() const; + virtual void Scroll( long nHorzScroll, long nVertScroll, + sal_uInt16 nFlags = 0 ); + virtual void Scroll( long nHorzScroll, long nVertScroll, + const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + virtual void Invalidate( sal_uInt16 nFlags = 0 ); + virtual void Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + virtual void Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 ); + void Validate( sal_uInt16 nFlags = 0 ); + void Validate( const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + void Validate( const Region& rRegion, sal_uInt16 nFlags = 0 ); + sal_Bool HasPaintEvent() const; + void Update(); + void Flush(); + void Sync(); + + // toggles new docking support, enabled via toolkit + void EnableDocking( sal_Bool bEnable = sal_True ); + // retrieves the single dockingmanager instance + static DockingManager* GetDockingManager(); + + void EnablePaint( sal_Bool bEnable ); + sal_Bool IsPaintEnabled() const; + void SetUpdateMode( sal_Bool bUpdate ); + sal_Bool IsUpdateMode() const; + void SetParentUpdateMode( sal_Bool bUpdate ); + sal_Bool IsParentUpdateMode() const; + + void GrabFocus(); + sal_Bool HasFocus() const; + sal_Bool HasChildPathFocus( sal_Bool bSystemWindow = sal_False ) const; + sal_Bool IsActive() const; + sal_Bool HasActiveChildFrame(); + sal_uInt16 GetGetFocusFlags() const; + void GrabFocusToDocument(); + + /** + * Set this when you need to act as if the window has focus even if it + * doesn't. This is necessary for implementing tab stops inside floating + * windows, but floating windows don't get focus from the system. + */ + void SetFakeFocus( bool bFocus ); + + sal_Bool IsCompoundControl() const; + sal_Bool HasCompoundControlFocus() const; + + static sal_uIntPtr SaveFocus(); + static sal_Bool EndSaveFocus( sal_uIntPtr nSaveId, sal_Bool bRestore = sal_True ); + + void CaptureMouse(); + void ReleaseMouse(); + sal_Bool IsMouseCaptured() const; + + void SetPointer( const Pointer& rPointer ); + const Pointer& GetPointer() const; + void EnableChildPointerOverwrite( sal_Bool bOverwrite = sal_True ); + sal_Bool IsChildPointerOverwrite() const; + void SetPointerPosPixel( const Point& rPos ); + Point GetPointerPosPixel(); + Point GetLastPointerPosPixel(); + void ShowPointer( sal_Bool bVisible ); + sal_Bool IsPointerVisible() const; + void EnterWait(); + void LeaveWait(); + sal_Bool IsWait() const; + + void SetCursor( Cursor* pCursor ); + Cursor* GetCursor() const; + + void SetZoom( const Fraction& rZoom ); + const Fraction& GetZoom() const; + sal_Bool IsZoom() const; + long CalcZoom( long n ) const; + + virtual void SetText( const XubString& rStr ); + virtual String GetText() const; + // return the actual text displayed + // this may have e.g. accellerators removed or portions + // replaced by ellipsis + virtual String GetDisplayText() const; + // gets the visible background color. for transparent windows + // this may be the parent's background color; for controls + // this may be a child's background color (e.g. ListBox) + virtual const Wallpaper& GetDisplayBackground() const; + + void SetHelpText( const XubString& rHelpText ); + const XubString& GetHelpText() const; + + void SetQuickHelpText( const XubString& rHelpText ); + const XubString& GetQuickHelpText() const; + + void SetHelpId( const rtl::OString& ); + const rtl::OString& GetHelpId() const; + + void SetUniqueId( const rtl::OString& ); + const rtl::OString& GetUniqueId() const; + const rtl::OString& GetUniqueOrHelpId() const; + + Window* FindWindow( const Point& rPos ) const; + + sal_uInt16 GetChildCount() const; + Window* GetChild( sal_uInt16 nChild ) const; + Window* GetWindow( sal_uInt16 nType ) const; + sal_Bool IsChild( const Window* pWindow, sal_Bool bSystemWindow = sal_False ) const; + sal_Bool IsWindowOrChild( const Window* pWindow, sal_Bool bSystemWindow = sal_False ) const; + + void SetData( void* pNewData ); + void* GetData() const; + + Bitmap SnapShot( sal_Bool bBorder = sal_True ) const; + + void ShowFocus( const Rectangle& rRect ); + void HideFocus(); + + void Invert( const Rectangle& rRect, sal_uInt16 nFlags = 0 ); + void Invert( const Polygon& rPoly, sal_uInt16 nFlags = 0 ); + + // transparent background for selected or checked items in toolboxes etc. + void DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly ); + // the same, but fills a passed Color with a text color complementing the selection background + void DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly, Color* pSelectionTextColor ); + // support rounded edges in the selection rect + void DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, sal_Bool bChecked, sal_Bool bDrawBorder, sal_Bool bDrawExtBorderOnly, long nCornerRadius, Color* pSelectionTextColor, Color* pPaintColor ); + + void ShowTracking( const Rectangle& rRect, + sal_uInt16 nFlags = SHOWTRACK_SMALL ); + void HideTracking(); + void InvertTracking( const Rectangle& rRect, + sal_uInt16 nFlags = SHOWTRACK_SMALL ); + void InvertTracking( const Polygon& rPoly, sal_uInt16 nFlags = 0 ); + + void StartTracking( sal_uInt16 nFlags = 0 ); + void EndTracking( sal_uInt16 nFlags = 0 ); + sal_Bool IsTracking() const; + + void StartAutoScroll( sal_uInt16 nFlags ); + void EndAutoScroll(); + sal_Bool IsAutoScroll() const; + + sal_Bool HandleScrollCommand( const CommandEvent& rCmd, + ScrollBar* pHScrl = NULL, + ScrollBar* pVScrl = NULL ); + + void SaveBackground( const Point& rPos, const Size& rSize, + const Point& rDestOff, VirtualDevice& rSaveDevice ); + + const SystemEnvData* GetSystemData() const; + ::com::sun::star::uno::Any GetSystemDataAny() const; + + // API zum Setzen/Abfragen des Komponenteninterfaces + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface( sal_Bool bCreate = sal_True ); + virtual void SetComponentInterface( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace ); + + // Accessibility + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible( sal_Bool bCreate = sal_True ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + void SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ); + + Window* GetAccessibleParentWindow() const; + sal_uInt16 GetAccessibleChildWindowCount(); + Window* GetAccessibleChildWindow( sal_uInt16 n ); + + void SetAccessibleRole( sal_uInt16 nRole ); + sal_uInt16 GetAccessibleRole() const; + + void SetAccessibleName( const String& rName ); + String GetAccessibleName() const; + + void SetAccessibleDescription( const String& rDescr ); + String GetAccessibleDescription() const; + + void SetAccessibleRelationLabeledBy( Window* pLabeledBy ); + Window* GetAccessibleRelationLabeledBy() const; + + void SetAccessibleRelationLabelFor( Window* pLabelFor ); + Window* GetAccessibleRelationLabelFor() const; + + void SetAccessibleRelationMemberOf( Window* pMemberOf ); + Window* GetAccessibleRelationMemberOf() const; + + + // to avoid sending accessibility events in cases like closing dialogs + // by default checks complete parent path + sal_Bool IsAccessibilityEventsSuppressed( sal_Bool bTraverseParentPath = sal_True ); + void SetAccessibilityEventsSuppressed(sal_Bool bSuppressed); + + /// request XCanvas render interface for this window + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvas > GetCanvas() const; + /// request XSpriteCanvas render interface for this window + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XSpriteCanvas > GetSpriteCanvas() const; + /// request fullscreen XSpriteCanvas render interface for this window + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XSpriteCanvas > GetFullscreenSpriteCanvas( const Size& rFullscreenSize ) const; + + /* records all DrawText operations within the passed rectangle; + * a synchronous paint is sent to achieve this + */ + void RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect ); + + // Setzen und Abfragen fuer das Toolkit + VCLXWindow* GetWindowPeer() const; + void SetWindowPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow ); + + // Merken, ob vom Toolkit erzeugt + sal_Bool IsCreatedWithToolkit() const; + void SetCreatedWithToolkit( sal_Bool b ); + + // Deprecated - can use SetAccessibleRelationLabelFor/By nowadys + virtual Window* GetParentLabelFor( const Window* pLabel ) const; + virtual Window* GetParentLabeledBy( const Window* pLabeled ) const; + KeyEvent GetActivationKey() const; + + // Drag and Drop interfaces + virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > GetDropTarget(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > GetDragSource(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > GetDragGestureRecognizer(); + // only for RVP transmission + void GetDragSourceDropTarget(::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource >& xDragSource,::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget > &xDropTarget ); + + // Clipboard/Selection interfaces + virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > GetClipboard(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard > GetPrimarySelection(); + + // Advisory Sizing - what is a good size for this widget ? + virtual Size GetOptimalSize(WindowSizeType eType) const; + + //------------------------------------- + // Native Widget Rendering functions + //------------------------------------- + + // form controls must never use native widgets, this can be toggled here + void EnableNativeWidget( sal_Bool bEnable = sal_True ); + sal_Bool IsNativeWidgetEnabled() const; + + // a helper method for a Control's Draw method + void PaintToDevice( OutputDevice* pDevice, const Point& rPos, const Size& rSize ); + + /* mark Window for deletion in top of event queue + */ + void doLazyDelete(); + + //------------------------------------- + // Keyboard access functions + //------------------------------------- + + /** Query the states of keyboard indicators - Caps Lock, Num Lock and + Scroll Lock. Use the following mask to retrieve the state of each + indicator: + + INDICATOR_CAPS_LOCK + INDICATOR_NUM_LOCK + INDICATOR_SCROLL_LOCK + */ + sal_uInt16 GetIndicatorState() const; + + void SimulateKeyPress( sal_uInt16 nKeyCode ) const; + + // let the window intercept the KeyDown messages of the system children + void InterceptChildWindowKeyDown( sal_Bool bIntercept ); + + virtual XubString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + + // ExtImpl + + // layouting + boost::shared_ptr< vcl::WindowArranger > getLayout(); + + /* add a child Window + addWindow will do the following things + - insert the passed window into the child list (equivalent to i_pWin->SetParent( this )) + - mark the window as "owned", meaning that the added Window will be destroyed by + the parent's desctructor. + This means: do not pass in member windows or stack objects here. Do not cause + the destructor of the added window to be called in any way. + + to avoid ownership pass i_bTakeOwnership as "false" + */ + void addWindow( Window* i_pWin, bool i_bTakeOwnership = true ); + + /* remove a child Window + the remove window functions will + - reparent the searched window (equivalent to i_pWin->SetParent( i_pNewParent )) + - return a pointer to the removed window or NULL if i_pWin was not found + caution: ownership passes to the new parent or the caller, if the new parent was NULL + */ + Window* removeWindow( Window* i_pWin, Window* i_pNewParent = NULL ); + + /* return the identifier of this window + */ + const rtl::OUString& getIdentifier() const; + /* set an identifier + identifiers have only loosely defined rules per se + in context of Window they must be unique over the window + hierarchy you'd like to find them again using the findWindow method + */ + void setIdentifier( const rtl::OUString& ); + + /* returns the first found descendant that matches + the passed identifier or NULL + */ + Window* findWindow( const rtl::OUString& ) const; + + /* get/set properties + this will contain window properties (like visible, enabled) + as well as properties of derived classes (e.g. text of Edit fields) + */ + virtual com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > getProperties() const; + /* + */ + virtual void setProperties( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& ); +}; + + +#endif // _SV_WINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/wpropset.hxx b/vcl/inc/vcl/wpropset.hxx new file mode 100644 index 000000000000..ac0f98fd3525 --- /dev/null +++ b/vcl/inc/vcl/wpropset.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VCL_WPROPSET_HXX +#define VCL_WPROPSET_HXX + +#include "vcl/dllapi.h" + +#include "tools/link.hxx" +#include "vcl/arrange.hxx" + +#include "com/sun/star/beans/XPropertySet.hpp" + +class VclWindowEvent; + +namespace vcl +{ + class WindowPropertySetData; + class WindowPropertySetListener; + + class VCL_DLLPUBLIC WindowPropertySet + { + WindowPropertySetData* mpImpl; + + void addWindowToSet( Window* ); + void addLayoutToSet( const boost::shared_ptr<WindowArranger>& ); + void setupProperties(); + + DECL_LINK( ChildEventListener, VclWindowEvent* ); + + void propertyChange( const com::sun::star::beans::PropertyChangeEvent& ); + friend class vcl::WindowPropertySetListener; + + public: + WindowPropertySet( Window* i_pTopWindow, bool i_bTakeOwnership ); + ~WindowPropertySet(); + + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > getPropertySet() const; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/wrkwin.hxx b/vcl/inc/vcl/wrkwin.hxx new file mode 100644 index 000000000000..c58f6971ffc0 --- /dev/null +++ b/vcl/inc/vcl/wrkwin.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SV_WRKWIN_HXX +#define _SV_WRKWIN_HXX + +#include <vcl/sv.h> +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> + +namespace com { namespace sun { namespace star { namespace uno { class Any; }}}} +struct SystemParentData; + +// ---------------------- +// - WorkWindow - Types - +// ---------------------- + +// Presentation Flags +#define PRESENTATION_HIDEALLAPPS ((sal_uInt16)0x0001) +#define PRESENTATION_NOFULLSCREEN ((sal_uInt16)0x0002) +#define PRESENTATION_NOAUTOSHOW ((sal_uInt16)0x0004) + +// -------------- +// - WorkWindow - +// -------------- + +class VCL_DLLPUBLIC WorkWindow : public SystemWindow +{ +private: + sal_uInt16 mnPresentationFlags; + sal_Bool mbPresentationMode:1, + mbPresentationVisible:1, + mbPresentationFull:1, + mbFullScreenMode:1; + + SAL_DLLPRIVATE void ImplInitWorkWindowData(); + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle, const ::com::sun::star::uno::Any& aSystemWorkWindowToken ); + +private: + SAL_DLLPRIVATE WorkWindow( const WorkWindow& rWin ); + SAL_DLLPRIVATE WorkWindow& operator =( const WorkWindow& rWin ); + +protected: + WorkWindow( WindowType nType ); + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData = NULL ); + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE void ImplSetFrameState( sal_uLong aFrameState ); + +public: + WorkWindow( Window* pParent, const ResId& rResId ); + WorkWindow( Window* pParent, WinBits nStyle = WB_STDWORK ); + WorkWindow( Window* pParent, const ::com::sun::star::uno::Any& aSystemWorkWindowToken, WinBits nStyle = WB_STDWORK ); + WorkWindow( SystemParentData* pParent ); // Not in the REMOTE-Version + ~WorkWindow(); + + virtual sal_Bool Close(); + + /** The default value of nDisplay = -1 means "don't care" and + allows to backends to use any screen [** or display? terminology!] + they like (most probably the current one). + + NOTE: The default value cannot be 0, because 0 is a legitimate + screen number. + */ + void ShowFullScreenMode( sal_Bool bFullScreenMode = sal_True, sal_Int32 nDisplay = -1 ); + void EndFullScreenMode() { ShowFullScreenMode( sal_False ); } + sal_Bool IsFullScreenMode() const { return mbFullScreenMode; } + + void StartPresentationMode( sal_Bool bPresentation = sal_True, sal_uInt16 nFlags = 0, sal_Int32 nDisplay = 0 ); + void EndPresentationMode() { StartPresentationMode( sal_False ); } + sal_Bool IsPresentationMode() const { return mbPresentationMode; } + + sal_Bool IsMinimized() const; + + sal_Bool SetPluginParent( SystemParentData* pParent ); + + void Minimize(); + void Restore(); + + void Maximize( sal_Bool bMaximize = sal_True ); + sal_Bool IsMaximized() const; +}; + +#endif // _SV_WRKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/vcl/xconnection.hxx b/vcl/inc/vcl/xconnection.hxx new file mode 100644 index 000000000000..bd3270fa24c7 --- /dev/null +++ b/vcl/inc/vcl/xconnection.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _VCL_XCONNECTION_HXX +#define _VCL_XCONNECTION_HXX + +#include <osl/mutex.hxx> +#include <rtl/ref.hxx> +#include <com/sun/star/uno/Reference.hxx> + +#include "vcl/displayconnectiondispatch.hxx" + +#ifndef _STLP_LIST +#include <list> +#endif + +namespace vcl { + + class DisplayConnection : + public DisplayConnectionDispatch + { + ::osl::Mutex m_aMutex; + ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler > > + m_aHandlers; + ::std::list< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler > > + m_aErrorHandlers; + ::com::sun::star::uno::Any m_aAny; + public: + DisplayConnection(); + virtual ~DisplayConnection(); + + void start(); + void terminate(); + + virtual bool dispatchEvent( void* pData, int nBytes ); + virtual bool dispatchErrorEvent( void* pData, int nBytes ); + + // XDisplayConnection + virtual void SAL_CALL addEventHandler( const ::com::sun::star::uno::Any& window, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler >& handler, sal_Int32 eventMask ) throw(); + virtual void SAL_CALL removeEventHandler( const ::com::sun::star::uno::Any& window, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler >& handler ) throw(); + virtual void SAL_CALL addErrorHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler >& handler ) throw(); + virtual void SAL_CALL removeErrorHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XEventHandler >& handler ) throw(); + virtual ::com::sun::star::uno::Any SAL_CALL getIdentifier() throw(); + + }; + +} + +#endif // _VCL_XCONNECTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |