diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/vcl | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/vcl')
152 files changed, 32413 insertions, 0 deletions
diff --git a/include/vcl/FilterConfigItem.hxx b/include/vcl/FilterConfigItem.hxx new file mode 100644 index 000000000000..b13f37a19680 --- /dev/null +++ b/include/vcl/FilterConfigItem.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + + +#ifndef _FILTER_CONFIG_ITEM_HXX_ +#define _FILTER_CONFIG_ITEM_HXX_ + +#include <vcl/dllapi.h> + +#include <tools/string.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> + +class VCL_DLLPUBLIC FilterConfigItem +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xUpdatableView; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet; + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aFilterData; + + sal_Bool bModified; + + sal_Bool ImplGetPropertyValue( ::com::sun::star::uno::Any& rAny, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rXPropSet, + const OUString& rPropName, + sal_Bool bTestPropertyAvailability ); + + void ImpInitTree( const String& rTree ); + + + static ::com::sun::star::beans::PropertyValue* GetPropertyValue( + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rPropSeq, + const OUString& rName ); + static sal_Bool WritePropertyValue( + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rPropSeq, + const ::com::sun::star::beans::PropertyValue& rPropValue ); + +public : + + FilterConfigItem( const OUString& rSubTree ); + FilterConfigItem( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData ); + FilterConfigItem( const OUString& rSubTree, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData ); + ~FilterConfigItem(); + + // all read methods are trying to return values in following order: + // 1. FilterData PropertySequence + // 2. configuration + // 3. given default + sal_Bool ReadBool( const OUString& rKey, sal_Bool bDefault ); + sal_Int32 ReadInt32( const OUString& rKey, sal_Int32 nDefault ); + OUString + ReadString( const OUString& rKey, const OUString& rDefault ); + + // try to store to configuration + // and always stores into the FilterData sequence + void WriteBool( const OUString& rKey, sal_Bool bValue ); + void WriteInt32( const OUString& rKey, sal_Int32 nValue ); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetFilterData() const; + + // GetStatusIndicator is returning the "StatusIndicator" property of the FilterData sequence + ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator() const; +}; + +#endif // _FILTER_CONFIG_ITEM_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicNativeMetadata.hxx b/include/vcl/GraphicNativeMetadata.hxx new file mode 100644 index 000000000000..ab5b767ceb15 --- /dev/null +++ b/include/vcl/GraphicNativeMetadata.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _GRAPHICNATIVEMETADATA_HXX +#define _GRAPHICNATIVEMETADATA_HXX + +#include <vcl/graph.hxx> + +class VCL_DLLPUBLIC GraphicNativeMetadata +{ + sal_uInt16 mRotation; + +public: + GraphicNativeMetadata(); + virtual ~GraphicNativeMetadata(); + + bool read(Graphic& rGraphic); + sal_uInt16 getRotation(); +}; + +#endif //_GRAPHICNATIVEMETADATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicNativeTransform.hxx b/include/vcl/GraphicNativeTransform.hxx new file mode 100644 index 000000000000..db727a22c5ff --- /dev/null +++ b/include/vcl/GraphicNativeTransform.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _GRAPHICNATIVETRANSFORM_HXX +#define _GRAPHICNATIVETRANSFORM_HXX + +#include <vcl/graph.hxx> + +class VCL_DLLPUBLIC GraphicNativeTransform +{ + Graphic& mrGraphic; + + bool rotateJPEG (sal_uInt16 aRotation); + bool rotateGeneric (sal_uInt16 aRotation, OUString aType); + +public: + GraphicNativeTransform(Graphic& rGraphic); + virtual ~GraphicNativeTransform(); + + bool canBeRotated(); + bool rotate(sal_uInt16 aRotation); +}; + +#endif //_GRAPHICNATIVETRANSFORM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ImageListProvider.hxx b/include/vcl/ImageListProvider.hxx new file mode 100644 index 000000000000..cfbba790850c --- /dev/null +++ b/include/vcl/ImageListProvider.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + protected: + ~IImageListProvider() {} + }; +} /* vcl */ + +#endif /* _SV_IMAGELISTPROVIDER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx new file mode 100644 index 000000000000..5f92c74d5c08 --- /dev/null +++ b/include/vcl/abstdlg.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _VCL_ABSTDLG_HXX +#define _VCL_ABSTDLG_HXX + +#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/include/vcl/accel.hxx b/include/vcl/accel.hxx new file mode 100644 index 000000000000..79136b15b1f8 --- /dev/null +++ b/include/vcl/accel.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_ACCEL_HXX +#define _SV_ACCEL_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#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; + + // Will be set by AcceleratorManager + 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 ); + + 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 GetKeyCode( sal_uInt16 nItemId ) const; + + Accelerator* GetAccel( sal_uInt16 nItemId ) 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/include/vcl/alpha.hxx b/include/vcl/alpha.hxx new file mode 100644 index 000000000000..95bb0ea29de2 --- /dev/null +++ b/include/vcl/alpha.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 ); + virtual ~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(); + } + + sal_uLong GetSizeBytes() const + { + return Bitmap::GetSizeBytes(); + } + sal_uLong GetChecksum() const + { + return Bitmap::GetChecksum(); + } + + Bitmap GetBitmap() const; + + sal_Bool CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, + const AlphaMask* pAlphaSrc = NULL); + + sal_Bool Erase( sal_uInt8 cTransparency ); + sal_Bool Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); + sal_Bool Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, + sal_uLong nTol = 0UL ); + + BitmapReadAccess* AcquireReadAccess() + { + return Bitmap::AcquireReadAccess(); + } + + BitmapWriteAccess* AcquireWriteAccess() + { + return Bitmap::AcquireWriteAccess(); + } + + void ReleaseAccess( BitmapReadAccess* pAccess ); + + typedef vcl::ScopedBitmapAccess< BitmapReadAccess, AlphaMask, &AlphaMask::AcquireReadAccess > + ScopedReadAccess; + typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireWriteAccess > + ScopedWriteAccess; + + 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/include/vcl/animate.hxx b/include/vcl/animate.hxx new file mode 100644 index 000000000000..dd374e8aed51 --- /dev/null +++ b/include/vcl/animate.hxx @@ -0,0 +1,238 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_ANIMATE_HXX +#define _SV_ANIMATE_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/bitmapex.hxx> + +#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L + +enum Disposal +{ + DISPOSE_NOT, + DISPOSE_BACK, + DISPOSE_FULL, + DISPOSE_PREVIOUS +}; + +enum CycleMode +{ + CYCLE_NOT, + CYCLE_NORMAL, + CYCLE_FALLBACK, + CYCLE_REVERS, + CYCLE_REVERS_FALLBACK +}; + +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; +}; + +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 ) {} +}; + +class ImplAnimView; +typedef ::std::vector< AnimationBitmap* > AnimationBitmapList_impl; +typedef ::std::vector< ImplAnimView* > AnimViewList_impl; + +class VCL_DLLPUBLIC Animation +{ + SAL_DLLPRIVATE static sal_uLong mnAnimCount; + + AnimationBitmapList_impl maList; + AnimViewList_impl maViewList; + Link maNotifyLink; + BitmapEx maBitmapEx; + Timer maTimer; + Size maGlobalSize; + void* mpExtraData; + long mnLoopCount; + long mnLoops; + size_t 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, void* ); + +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); } + + void Clear(); + + 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; } + + size_t Count() const { return maList.size(); } + sal_Bool Insert( const AnimationBitmap& rAnimationBitmap ); + const AnimationBitmap& Get( sal_uInt16 nAnimation ) const; + void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); + + 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 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/include/vcl/apptypes.hxx b/include/vcl/apptypes.hxx new file mode 100644 index 000000000000..ebb1eb703212 --- /dev/null +++ b/include/vcl/apptypes.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_APPTYPES_HXX +#define _VCL_APPTYPES_HXX + +#include <tools/solar.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 VCL_INPUT_MOUSE 0x0001 +#define VCL_INPUT_KEYBOARD 0x0002 +#define VCL_INPUT_PAINT 0x0004 +#define VCL_INPUT_TIMER 0x0008 +#define VCL_INPUT_OTHER 0x0010 +#define VCL_INPUT_APPEVENT 0x0020 +#define VCL_INPUT_MOUSEANDKEYBOARD (VCL_INPUT_MOUSE | VCL_INPUT_KEYBOARD) +#define VCL_INPUT_ANY (VCL_INPUT_MOUSEANDKEYBOARD | VCL_INPUT_PAINT | VCL_INPUT_TIMER | VCL_INPUT_OTHER | VCL_INPUT_APPEVENT) + +#endif // _VCL_APPTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx new file mode 100644 index 000000000000..c0ec5b17870c --- /dev/null +++ b/include/vcl/bitmap.hxx @@ -0,0 +1,896 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_BITMAP_HXX +#define _SV_BITMAP_HXX + +#include <tools/link.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/mapmod.hxx> +#include <vcl/region.hxx> +#include <vcl/scopedbitmapaccess.hxx> + +#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_SCALE_LANCZOS 0x00000003UL +#define BMP_SCALE_BICUBIC 0x00000004UL +#define BMP_SCALE_BILINEAR 0x00000005UL +#define BMP_SCALE_BOX 0x00000006UL + +// Aliases, try to use these two (or BMP_SCALE_FAST/BMP_SCALE_NONE), +// use a specific algorithm only if you really need to. +#define BMP_SCALE_BEST BMP_SCALE_LANCZOS +#define BMP_SCALE_DEFAULT BMP_SCALE_BOX + +#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 ) + +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 +}; + +class VCL_DLLPUBLIC BmpFilterParam +{ + friend class Bitmap; + friend class BitmapEx; + friend class Animation; + +private: + BmpFilter meFilter; + sal_uLong mnProgressStart; + sal_uLong mnProgressEnd; + +public: + struct MosaicTileSize + { + sal_uLong mnTileWidth; + sal_uLong mnTileHeight; + }; + + struct EmbossAngles + { + sal_uInt16 mnAzimuthAngle100; + sal_uInt16 mnElevationAngle100; + }; + +private: + union + { + sal_uInt16 mnSepiaPercent; + sal_uInt8 mcSolarGreyThreshold; + double mnRadius; + + MosaicTileSize maMosaicTileSize; + EmbossAngles maEmbossAngles; + }; + +public: + + BmpFilterParam( sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + 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( double nRadius, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : + meFilter( BMP_FILTER_SMOOTH ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), + mnRadius( nRadius ) {} + + 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; + } +}; + +// -------------------- +// Resample kernels +// -------------------- + +class Kernel +{ + +public: + Kernel () {} + virtual ~Kernel() {} + + virtual double GetWidth() = 0; + virtual double Calculate( double x ) = 0; +}; + +class Lanczos3Kernel : public Kernel +{ + +public: + virtual double GetWidth() { return 3.0; } + virtual double Calculate (double x) + { + return (-3.0 <= x && x < 3.0) ? SincFilter(x) * SincFilter( x / 3.0 ) : 0.0; + } + + inline double SincFilter(double x) + { + if (x == 0.0) + { + return 1.0; + } + x = x * M_PI; + return sin(x) / x; + } +}; + +class BicubicKernel : public Kernel { + virtual double GetWidth() { return 2.0; } + virtual double Calculate (double x) + { + if (x < 0.0) + { + x = -x; + } + + if (x <= 1.0) + { + return (1.5 * x - 2.5) * x * x + 1.0; + } + else if (x < 2.0) + { + return ((-0.5 * x + 2.5) * x - 4) * x + 2; + } + return 0.0; + } +}; + +class BilinearKernel : public Kernel { + virtual double GetWidth() { return 1.0; } + virtual double Calculate (double x) + { + if (x < 0.0) + { + x = -x; + } + if (x < 1.0) + { + return 1.0-x; + } + return 0.0; + } +}; + +class BoxKernel : public Kernel { + virtual double GetWidth() { return 0.5; } + virtual double Calculate (double x) + { + if (-0.5 <= x && x < 0.5) + return 1.0; + return 0.0; + } +}; + +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 ) + void* pDIB; // device independent byte buffer + void* pDDB; // if not NULL then this is actually an HBITMAP + #elif defined( MACOSX ) || defined( IOS ) + void* rImageContext; //Image context (CGContextRef) + #else + void* aPixmap; + void* aVisual; + #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 bool ImplScaleConvolution( const double& rScaleX, const double& rScaleY, Kernel& aKernel); + SAL_DLLPRIVATE bool ImplTransformAveraging( const double& rScaleX, const double& rScaleY, + const Rectangle& rRotatedRectangle, const long nAngle10, const Color& rFillColor ); + SAL_DLLPRIVATE bool ImplTransformBilinearFiltering( const double& rScaleX, const double& rScaleY, + const Rectangle& rRotatedRectangle, const long nAngle10, const Color& rFillColor ); + + SAL_DLLPRIVATE static void ImplCalculateContributions( const int aSourceSize, const int aDestinationSize, + int& aNumberOfContributions, double*& pWeights, int*& pPixels, int*& pCount, + Kernel& aKernel ); + + SAL_DLLPRIVATE bool ImplConvolutionPass( Bitmap& aNewBitmap, const int nNewSize, BitmapReadAccess* pReadAcc, + int aNumberOfContributions, double* pWeights, int* pPixels, int* pCount ); + + 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 ); + + SAL_DLLPRIVATE bool ImplSeparableBlurFilter( const double aRadius = 0.7 ); + SAL_DLLPRIVATE bool ImplSeparableUnsharpenFilter( const double aRadius = 0.7 ); + SAL_DLLPRIVATE void ImplBlurContributions( const int aSize, const int aNumberOfContributions, + double* pBlurVector, double*& pWeights, int*& pPixels, int*& pCount ); +public: + + Bitmap(); + Bitmap( const Bitmap& rBitmap ); + Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = NULL ); + Bitmap( const ResId& rResId ); + Bitmap( SalBitmap* pSalBitmap ); + virtual ~Bitmap(); + + Bitmap& 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; + + /** + * 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. + */ + 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_DEFAULT ); + + /** 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_DEFAULT ); + + /** 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 ); + + bool HasAlpha(); + +public: + BitmapReadAccess* AcquireReadAccess(); + BitmapWriteAccess* AcquireWriteAccess(); + void ReleaseAccess( BitmapReadAccess* pAccess ); + + typedef vcl::ScopedBitmapAccess< BitmapReadAccess, Bitmap, &Bitmap::AcquireReadAccess > + ScopedReadAccess; + typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess > + ScopedWriteAccess; + +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 ); +}; + +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/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx new file mode 100644 index 000000000000..9eaaf618200c --- /dev/null +++ b/include/vcl/bitmapex.hxx @@ -0,0 +1,389 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + 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_DEFAULT ); + + /** 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_DEFAULT ); + + /** 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/include/vcl/bmpacc.hxx b/include/vcl/bmpacc.hxx new file mode 100644 index 000000000000..097fd7cf57e3 --- /dev/null +++ b/include/vcl/bmpacc.hxx @@ -0,0 +1,454 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_BMPACC_HXX +#define _SV_BMPACC_HXX + +#include <tools/solar.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 ); + +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( const Color& rColor ); + + void SetFillColor( const Color& rColor ); + + void Erase( const Color& rColor ); + + void DrawLine( const Point& rStart, const Point& rEnd ); + + void FillRect( const Rectangle& rRect ); + void DrawRect( const Rectangle& rRect ); + +private: + + BitmapColor* mpLineColor; + BitmapColor* mpFillColor; + + BitmapWriteAccess() {} + BitmapWriteAccess( const BitmapWriteAccess& ) : BitmapReadAccess() {} + BitmapWriteAccess& operator=( const BitmapWriteAccess& ) { return *this; } +}; + +// ----------- +// - 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/include/vcl/btndlg.hxx b/include/vcl/btndlg.hxx new file mode 100644 index 000000000000..541109885079 --- /dev/null +++ b/include/vcl/btndlg.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_BTNDLG_HXX +#define _SV_BTNDLG_HXX + +#include <boost/ptr_container/ptr_vector.hpp> + +#include <tools/solar.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(); + + 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 RemoveButton( sal_uInt16 nId ); + void Clear(); + sal_uInt16 GetButtonId( sal_uInt16 nButton ) const; + PushButton* GetPushButton( sal_uInt16 nId ) const; + void SetButtonText( sal_uInt16 nId, const XubString& rText ); + void SetButtonHelpText( sal_uInt16 nId, const XubString& rText ); + + 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/include/vcl/builder.hxx b/include/vcl/builder.hxx new file mode 100644 index 000000000000..5de792aaab5e --- /dev/null +++ b/include/vcl/builder.hxx @@ -0,0 +1,365 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _VCLBUILDER_HXX +#define _VCLBUILDER_HXX + +#include <typeinfo> +#include <tools/resmgr.hxx> //for poxy ResHookProc typedef +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <xmlreader/xmlreader.hxx> +#include <map> +#include <set> +#include <stack> +#include <vector> + +class ListBox; +class NumericFormatter; +class PopupMenu; +class ScrollBar; +class DateField; +class TimeField; +class VclMultiLineEdit; + +class VCL_DLLPUBLIC VclBuilder +{ +public: + typedef std::map<OString, OString> stringmap; + typedef Window* (*customMakeWidget)(Window *pParent, stringmap &rVec); +private: + + struct PackingData + { + bool m_bVerticalOrient; + sal_Int32 m_nPosition; + PackingData(bool bVerticalOrient = false, sal_Int32 nPosition = -1) + : m_bVerticalOrient(bVerticalOrient) + , m_nPosition(nPosition) + { + } + }; + + struct WinAndId + { + OString m_sID; + Window *m_pWindow; + PackingData m_aPackingData; + WinAndId(const OString &rId, Window *pWindow, bool bVertical) + : m_sID(rId) + , m_pWindow(pWindow) + , m_aPackingData(bVertical) + { + } + }; + std::vector<WinAndId> m_aChildren; + + struct MenuAndId + { + OString m_sID; + PopupMenu *m_pMenu; + MenuAndId(const OString &rId, PopupMenu *pMenu) + : m_sID(rId) + , m_pMenu(pMenu) + { + } + }; + std::vector<MenuAndId> m_aMenus; + + struct StringPair + { + OString m_sID; + OString m_sValue; + StringPair(const OString &rId, const OString &rValue) + : m_sID(rId) + , m_sValue(rValue) + { + } + }; + + typedef StringPair RadioButtonGroupMap; + + struct ButtonImageWidgetMap + { + OString m_sID; + OString m_sValue; + bool m_bRadio; + ButtonImageWidgetMap(const OString &rId, const OString &rValue, bool bRadio) + : m_sID(rId) + , m_sValue(rValue) + , m_bRadio(bRadio) + { + } + }; + + typedef StringPair TextBufferMap; + typedef StringPair WidgetAdjustmentMap; + typedef StringPair ButtonMenuMap; + typedef StringPair MnemonicWidgetMap; + + struct ComboBoxModelMap + { + OString m_sID; + OString m_sValue; + sal_Int32 m_nActiveId; + ComboBoxModelMap(const OString &rId, const OString &rValue, sal_Int32 nActiveId) + : m_sID(rId) + , m_sValue(rValue) + , m_nActiveId(nActiveId) + { + } + }; + + struct ListStore + { + typedef std::vector<OString> row; + std::vector<row> m_aEntries; + }; + const ListStore* get_model_by_name(OString sID) const; + static void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); + + typedef stringmap TextBuffer; + const TextBuffer* get_buffer_by_name(OString sID) const; + static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer); + + typedef stringmap Adjustment; + const Adjustment *get_adjustment_by_name(OString sID) const; + static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment); + + typedef std::map<OString, OString> WidgetTranslations; + typedef std::map<OString, WidgetTranslations> Translations; + + struct stockinfo + { + OString m_sStock; + int m_nSize; + stockinfo() : m_nSize(4) {} + }; + + typedef std::map<OString, stockinfo> StockMap; + + struct SizeGroup + { + OString m_sID; + std::vector<OString> m_aWidgets; + stringmap m_aProperties; + SizeGroup(const OString &rId) + : m_sID(rId) + { + } + }; + + typedef std::map<Window*, stringmap> AtkMap; + + struct ParserState + { + std::vector<RadioButtonGroupMap> m_aGroupMaps; + + std::vector<ComboBoxModelMap> m_aModelMaps; + std::map<OString, ListStore> m_aModels; + + std::vector<TextBufferMap> m_aTextBufferMaps; + std::map<OString, TextBuffer> m_aTextBuffers; + + std::vector<WidgetAdjustmentMap> m_aNumericFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aTimeFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aDateFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aScrollAdjustmentMaps; + std::map<OString, Adjustment> m_aAdjustments; + + std::vector<ButtonImageWidgetMap> m_aButtonImageWidgetMaps; + StockMap m_aStockMap; + + std::vector<ButtonMenuMap> m_aButtonMenuMaps; + + Translations m_aTranslations; + + std::map<Window*, Window*> m_aRedundantParentWidgets; + + std::vector<SizeGroup> m_aSizeGroups; + + AtkMap m_aAtkInfo; + + std::vector<MnemonicWidgetMap> m_aMnemonicWidgetMaps; + }; + + void loadTranslations(const com::sun::star::lang::Locale &rLocale, const OUString &rUri); + OString getTranslation(const OString &rId, const OString &rProperty) const; + + OString m_sID; + OString m_sHelpRoot; + ResHookProc m_pStringReplace; + Window *m_pParent; + bool m_bToplevelHasDeferredInit; + bool m_bToplevelParentFound; + ParserState *m_pParserState; + + Window *get_by_name(OString sID); + void delete_by_name(OString sID); + + class sortIntoBestTabTraversalOrder + : public std::binary_function<const Window*, const Window*, bool> + { + VclBuilder *m_pBuilder; + public: + sortIntoBestTabTraversalOrder(VclBuilder *pBuilder) + : m_pBuilder(pBuilder) + { + } + bool operator()(const Window *pA, const Window *pB) const; + }; +public: + VclBuilder(Window *pParent, OUString sUIRootDir, OUString sUIFile, OString sID = OString()); + ~VclBuilder(); + Window *get_widget_root(); + //sID must exist and be of type T + template <typename T> T* get(T*& ret, OString sID) + { + Window *w = get_by_name(sID); + SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID.getStr() << "\" not found in .ui"); + SAL_WARN_IF(!dynamic_cast<T*>(w), + "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(w && dynamic_cast<T*>(w)); + ret = static_cast<T*>(w); + return ret; + } + PopupMenu* get_menu(PopupMenu*& ret, OString sID) + { + ret = get_menu(sID); + SAL_WARN_IF(!ret, "vcl.layout", "menu \"" << sID.getStr() << "\" not found in .ui"); + assert(ret); + return ret; + } + //sID may not exist, but must be of type T if it does + template <typename T /*=Window if we had c++11*/> T* get(OString sID) + { + Window *w = get_by_name(sID); + SAL_WARN_IF(w && !dynamic_cast<T*>(w), + "vcl.layout", ".ui widget \"" << sID.getStr() << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(!w || dynamic_cast<T*>(w)); + return static_cast<T*>(w); + } + //sID may not exist + PopupMenu* get_menu(OString sID); + + OString get_by_window(const Window *pWindow) const; + void delete_by_window(const Window *pWindow); + + //Convert _ gtk markup to ~ vcl markup + static OString convertMnemonicMarkup(const OString &rIn); + + static OString extractCustomProperty(stringmap &rMap); + +private: + Window *insertObject(Window *pParent, const OString &rClass, const OString &rID, + stringmap &rProps, stringmap &rPangoAttributes, + stringmap &rAtkProps, std::vector<OString> &rItems); + + Window *makeObject(Window *pParent, const OString &rClass, const OString &rID, + stringmap &rVec, const std::vector<OString> &rItems); + + void connectNumericFormatterAdjustment(const OString &id, const OString &rAdjustment); + void connectTimeFormatterAdjustment(const OString &id, const OString &rAdjustment); + void connectDateFormatterAdjustment(const OString &id, const OString &rAdjustment); + + bool extractGroup(const OString &id, stringmap &rVec); + bool extractModel(const OString &id, stringmap &rVec); + bool extractBuffer(const OString &id, stringmap &rVec); + bool extractScrollAdjustment(const OString &id, stringmap &rVec); + bool extractButtonImage(const OString &id, stringmap &rMap, bool bRadio); + bool extractStock(const OString &id, stringmap &rMap); + void extractMnemonicWidget(const OString &id, stringmap &rMap); + + void handleTranslations(xmlreader::XmlReader &reader); + + void handleChild(Window *pParent, xmlreader::XmlReader &reader); + Window* handleObject(Window *pParent, xmlreader::XmlReader &reader); + void handlePacking(Window *pCurrent, xmlreader::XmlReader &reader); + void applyPackingProperty(Window *pCurrent, xmlreader::XmlReader &reader); + void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec); + void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + void collectAtkAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + void collectAccelerator(xmlreader::XmlReader &reader, stringmap &rMap); + + void insertMenuObject(PopupMenu *pParent, const OString &rClass, const OString &rID, + stringmap &rProps, stringmap &rAccels); + void handleMenuChild(PopupMenu *pParent, xmlreader::XmlReader &reader); + void handleMenuObject(PopupMenu *pParent, xmlreader::XmlReader &reader); + + void handleListStore(xmlreader::XmlReader &reader, const OString &rID); + void handleRow(xmlreader::XmlReader &reader, const OString &rID, sal_Int32 nRowIndex); + void handleAdjustment(const OString &rID, stringmap &rProperties); + void handleTextBuffer(const OString &rID, stringmap &rProperties); + void handleTabChild(Window *pParent, xmlreader::XmlReader &reader); + void handleMenu(xmlreader::XmlReader &reader, const OString &rID); + std::vector<OString> handleItems(xmlreader::XmlReader &reader, const OString &rID); + + void handleSizeGroup(xmlreader::XmlReader &reader, const OString &rID); + + void handleAtkObject(xmlreader::XmlReader &reader, const OString &rID, Window *pWindow); + + PackingData get_window_packing_data(const Window *pWindow) const; + void set_window_packing_position(const Window *pWindow, sal_Int32 nPosition); + + Window* prepareWidgetOwnScrolling(Window *pParent, WinBits &rWinStyle); + void cleanupWidgetOwnScrolling(Window *pScrollParent, Window *pWindow, stringmap &rMap); + + //Helpers to retrofit all the existing code to the builder + static void reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition); +}; + + +//helper baseclass to ease retro fitting dialogs/tabpages that load a resource +//to load a .ui file instead +// +//vcl requires the Window Children of a Parent Window to be destroyed before +//the Parent Window. VclBuilderContainer owns the VclBuilder which owns the +//Children Window. So the VclBuilderContainer dtor must be called before +//the Parent Window dtor. +// +//i.e. class Dialog : public SystemWindow, public VclBuilderContainer +//not class Dialog : public VclBuilderContainer, public SystemWindow + +class VCL_DLLPUBLIC VclBuilderContainer +{ +protected: + VclBuilder *m_pUIBuilder; +public: + VclBuilderContainer(); + virtual ~VclBuilderContainer(); + static OUString getUIRootDir(); + template <typename T> T* get(T*& ret, OString sID) + { + return m_pUIBuilder->get<T>(ret, sID); + } + template <typename T /*=Window if we had c++11*/> T* get(OString sID) + { + return m_pUIBuilder->get<T>(sID); + } + PopupMenu* get_menu(PopupMenu*& ret, OString sID) + { + return m_pUIBuilder->get_menu(ret, sID); + } + PopupMenu* get_menu(OString sID) + { + return m_pUIBuilder->get_menu(sID); + } +}; + +/* + * @return true if rValue is "True", "true", "1", etc. + */ +bool VCL_DLLPUBLIC toBool(const OString &rValue); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx new file mode 100644 index 000000000000..8c116b0644dd --- /dev/null +++ b/include/vcl/button.hxx @@ -0,0 +1,574 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_BUTTON_HXX +#define _SV_BUTTON_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/image.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/salnativewidgets.hxx> +#include <rsc/rsc-vcl-shared-types.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( OUString& 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 ); + /// The x-coordinate of the vertical separator line, use in MenuButton subclass only. + SAL_DLLPRIVATE long ImplGetSeparatorX() const; + SAL_DLLPRIVATE void ImplSetSeparatorX( long nX ); + +protected: + Button( WindowType nType ); + +public: + ~Button(); + + virtual void Click(); + + void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; } + const Link& GetClickHdl() const { return maClickHdl; } + + static OUString 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; + + void EnableImageDisplay( sal_Bool bEnable ); + void EnableTextDisplay( sal_Bool bEnable ); + + void SetFocusRect( const Rectangle& rFocusRect ); + bool IsSmallSymbol() const; + void SetSmallSymbol(bool bSmall = true); +}; + +// -------------------- +// - 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 ); + + 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() const; + + void SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; } + const Link& GetToggleHdl() const { return maToggleHdl; } + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +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(); +}; + +class VCL_DLLPUBLIC CloseButton : public CancelButton +{ +public: + CloseButton(Window* pParent, WinBits nStyle = 0); +}; + + +// -------------- +// - 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: + boost::shared_ptr< std::vector<RadioButton*> > m_xGroup; + Rectangle maStateRect; + Rectangle maMouseRect; + Image maImage; + sal_Bool mbChecked; + sal_Bool mbSaveValue; + sal_Bool mbRadioCheck; + sal_Bool mbStateChanged; + Link maToggleHdl; + // when mbLegacyNoTextAlign is set then the old behaviour where + // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement + // occurs, otherwise the image ( radiobutton circle ) is placed + // to the left or right ( depending on RTL or LTR settings ) + bool mbLegacyNoTextAlign; + 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() 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 bIncludeThis + defines whether <code>this</code> is contained in the returned list + + @return + on return contains the <code>RadioButton</code>s + in the same group as this <code>RadioButton</code>. + */ + std::vector<RadioButton*> GetRadioButtonGroup(bool bIncludeThis = true) const; + + virtual bool set_property(const OString &rKey, const OString &rValue); + + /* + * Group this RadioButton with another + */ + void group(RadioButton &rOther); +}; + +// ------------ +// - CheckBox - +// ------------ + +class VCL_DLLPUBLIC CheckBox : public Button +{ +private: + Rectangle maStateRect; + Rectangle maMouseRect; + TriState meState; + TriState meSaveValue; + sal_Bool mbTriState; + Link maToggleHdl; + // when mbLegacyNoTextAlign is set then the old behaviour where + // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement + // occurs, otherwise the image ( checkbox box ) is placed + // to the left or right ( depending on RTL or LTR settings ) + bool mbLegacyNoTextAlign; + 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() const; + + void SetToggleHdl( const Link& rLink ) { maToggleHdl = rLink; } + const Link& GetToggleHdl() const { return maToggleHdl; } + bool IsLegacyNoTextAlign() { return mbLegacyNoTextAlign; } + void SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; } + + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +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 & ); + +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/include/vcl/canvastools.hxx b/include/vcl/canvastools.hxx new file mode 100644 index 000000000000..d4c2246e2544 --- /dev/null +++ b/include/vcl/canvastools.hxx @@ -0,0 +1,175 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 + { + // Bitmap conversions + // =================================================================== + + /** 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 ); + + // Color conversions (vcl/tools Color <-> canvas standard color space) + // =================================================================== + + /** 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& ); + + Size VCL_DLLPUBLIC sizeFromRealSize2D( const ::com::sun::star::geometry::RealSize2D& ); + + // geometry::Integer + ::com::sun::star::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& ); + + 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 + Point VCL_DLLPUBLIC pointFromB2IPoint( const ::basegfx::B2IPoint& ); + Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const ::basegfx::B2IRange& ); + } +} + +#endif /* _VCL_CANVASTOOLS_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/cmdevt.hxx b/include/vcl/cmdevt.hxx new file mode 100644 index 000000000000..03876e52e5a3 --- /dev/null +++ b/include/vcl/cmdevt.hxx @@ -0,0 +1,466 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_CMDEVT_HXX +#define _VCL_CMDEVT_HXX + +#include <tools/gen.hxx> +#include <tools/solar.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( 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_ZOOM_SCALE ((sal_uInt16)0x0003) +#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; +} + +// --------------------- +// - 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_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) + +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 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 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/include/vcl/combobox.h b/include/vcl/combobox.h new file mode 100644 index 000000000000..4cb8c964ee2e --- /dev/null +++ b/include/vcl/combobox.h @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_COMBOBOX_H +#define _SV_COMBOBOX_H + +#include <vcl/lstbox.h> + +#define COMBOBOX_APPEND ((sal_uInt16)0xFFFF) +#define COMBOBOX_ENTRY_NOTFOUND ((sal_uInt16)0xFFFF) +#define COMBOBOX_ERROR ((sal_uInt16)0xFFFF) + +#endif // _SV_COMBOBOX_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/combobox.hxx b/include/vcl/combobox.hxx new file mode 100644 index 000000000000..f0637109716a --- /dev/null +++ b/include/vcl/combobox.hxx @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + sal_Unicode mcMultiSep; + sal_Bool mbDDAutoSize : 1; + sal_Bool mbSyntheticModify : 1; + sal_Bool mbMatchCase : 1; + sal_Int32 m_nMaxWidthChars; + Link maSelectHdl; + Link maDoubleClickHdl; + + struct ComboBoxBounds + { + Point aSubEditPos; + Size aSubEditSize; + + Point aButtonPos; + Size aButtonSize; + }; + +private: + SAL_DLLPRIVATE void ImplInitComboBoxData(); + SAL_DLLPRIVATE void ImplUpdateFloatSelection(); + SAL_DLLPRIVATE ComboBoxBounds calcComboBoxDropDownComponentBounds( + const Size &rOutSize, const Size &rBorderOutSize) const; + + 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(); + SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const; + +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; + + 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 ); + + virtual void SetText( const OUString& rStr ); + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); + + sal_uInt16 InsertEntry( const OUString& rStr, sal_uInt16 nPos = COMBOBOX_APPEND ); + sal_uInt16 InsertEntry( const OUString& rStr, const Image& rImage, sal_uInt16 nPos = COMBOBOX_APPEND ); + + void RemoveEntry( const OUString& rStr ); + void RemoveEntry( sal_uInt16 nPos ); + + void Clear(); + + sal_uInt16 GetEntryPos( const OUString& rStr ) const; + Image GetEntryImage( sal_uInt16 nPos ) const; + OUString 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 ); + void EnableUserDraw( sal_Bool bUserDraw ); + + 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 = LISTBOX_ENTRY_NOTFOUND ); + + 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( sal_Unicode cSep ) { mcMultiSep = cSep; } + sal_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() 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 OUString& rEntries, sal_Unicode cSep = ';' ); + OUString GetMRUEntries( sal_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; + + sal_uInt16 GetTopEntry() const; + + void SetProminentEntryType( ProminentEntry eType ); + + 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; + + sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; } + void setMaxWidthChars(sal_Int32 nWidth); + + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +#endif // _COMBOBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/configsettings.hxx b/include/vcl/configsettings.hxx new file mode 100644 index 000000000000..47c96facd472 --- /dev/null +++ b/include/vcl/configsettings.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#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< OUString, OUString, OUStringHash > OUStrMap; + class SmallOUStrMap : public OUStrMap { public: SmallOUStrMap() : OUStrMap(1) {} }; + + //==================================================================== + //= SettingsConfigItem + //==================================================================== + class VCL_DLLPUBLIC SettingsConfigItem : public ::utl::ConfigItem + { + + boost::unordered_map< OUString, SmallOUStrMap, OUStringHash > m_aSettings; + + virtual void Notify( const com::sun::star::uno::Sequence< OUString >& rPropertyNames ); + + void getValues(); + SettingsConfigItem(); + public: + virtual ~SettingsConfigItem(); + + static SettingsConfigItem* get(); + + const OUString& getValue( const OUString& rGroup, const OUString& rKey ) const; + void setValue( const OUString& rGroup, const OUString& rKey, const OUString& rValue ); + + virtual void Commit(); + }; + +//........................................................................ +} // namespace vcl +//........................................................................ + +#endif // VCL_INC_CONFIGSETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/controllayout.hxx b/include/vcl/controllayout.hxx new file mode 100644 index 000000000000..5d1d13355718 --- /dev/null +++ b/include/vcl/controllayout.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 + OUString 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/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx new file mode 100644 index 000000000000..390f416ae142 --- /dev/null +++ b/include/vcl/ctrl.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_CTRL_HXX +#define _SV_CTRL_HXX + +#include <tools/link.hxx> +#include <tools/solar.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: + bool mbHasControlFocus; + 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 OUString& _rStr, sal_uInt16 _nStyle, + MetricVector* _pVector, OUString* _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 OUString& rStr ); + // gets the displayed text + virtual OUString 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 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; } + + /** determines whether the control currently has the focus + */ + bool HasControlFocus() const { return mbHasControlFocus; } + + void SetLayoutDataParent( const Control* pParent ) const; + + virtual Size GetOptimalSize() 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/include/vcl/cursor.hxx b/include/vcl/cursor.hxx new file mode 100644 index 000000000000..d0433858c3b3 --- /dev/null +++ b/include/vcl/cursor.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_CURSOR_HXX +#define _SV_CURSOR_HXX + +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/solar.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 + bool mbVisible; // Ist Cursor sichtbar + unsigned char mnDirection; // indicates direction + +public: + SAL_DLLPRIVATE void ImplDraw(); + SAL_DLLPRIVATE void ImplRestore(); + DECL_DLLPRIVATE_LINK( ImplTimerHdl, void* ); + SAL_DLLPRIVATE void ImplShow( bool bDrawDirect = true ); + SAL_DLLPRIVATE void ImplHide( bool bStopTimer ); + 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(); + 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; } + 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(); } + long GetHeight() const { return maSize.Height(); } + + 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 ); + bool operator==( const Cursor& rCursor ) const; + 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/include/vcl/cvtgrf.hxx b/include/vcl/cvtgrf.hxx new file mode 100644 index 000000000000..ee9f21870010 --- /dev/null +++ b/include/vcl/cvtgrf.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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: + + 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/include/vcl/cvtsvm.hxx b/include/vcl/cvtsvm.hxx new file mode 100644 index 000000000000..2dc9435cdfa9 --- /dev/null +++ b/include/vcl/cvtsvm.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_CVTMTF_HXX +#define _SV_CVTMTF_HXX + +#include <stack> +#include <vcl/dllapi.h> +#include <vcl/metaact.hxx> +#include <vcl/gdimtf.hxx> + +#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 + +#define GDI_LINECAP_ACTION 1036 + +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, ::std::stack<Color*>& 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/include/vcl/decoview.hxx b/include/vcl/decoview.hxx new file mode 100644 index 000000000000..31e6529c5e55 --- /dev/null +++ b/include/vcl/decoview.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_DECOVIEW_HXX +#define _SV_DECOVIEW_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <rsc/rsc-vcl-shared-types.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_NWF ((sal_uInt16)0x0006) +#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_NOLEFTLIGHTBORDER ((sal_uInt16)0x1000) +#define BUTTON_DRAW_NOTEXT ((sal_uInt16)0x2000) +#define BUTTON_DRAW_NOIMAGE ((sal_uInt16)0x4000) + +// ------------------ +// - 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/include/vcl/dialog.hxx b/include/vcl/dialog.hxx new file mode 100644 index 000000000000..d7994c61580e --- /dev/null +++ b/include/vcl/dialog.hxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_DIALOG_HXX +#define _SV_DIALOG_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/builder.hxx> +#include <vcl/syswin.hxx> +#include <vcl/timer.hxx> + +// parameter to pass to the dialog constructor if really no parent is wanted +// whereas NULL chooses the default dialog parent +#define DIALOG_NO_PARENT ((Window*)0xffffffff) + +// ---------- +// - Dialog - +// ---------- +struct DialogImpl; +class VclBox; +class VclButtonBox; +class VclContainer; + +class VCL_DLLPUBLIC Dialog + : public SystemWindow + , public VclBuilderContainer +{ +private: + Window* mpDialogParent; + Dialog* mpPrevExecuteDlg; + DialogImpl* mpDialogImpl; + long mnMousePositioned; + sal_Bool mbInExecute; + sal_Bool mbOldSaveBack; + sal_Bool mbInClose; + sal_Bool mbModalMode; + bool mbIsDefferedInit; + bool mbIsCalculatingInitialLayoutSize; + Timer maLayoutTimer; + VclButtonBox* mpActionArea; + VclBox* mpContentArea; + + 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* ); + DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, void* ); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplDialogRes( const ResId& rResId ); + SAL_DLLPRIVATE WinBits init(Window *pParent, const ResId& rResId); + + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, VclContainer &rBox); +public: + SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } + SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } + SAL_DLLPRIVATE void doDeferredInit(bool bResizable); + SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; } + +protected: + Dialog( WindowType nType ); + Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType ); + virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + +protected: + friend class VclBuilder; + void set_action_area(VclButtonBox *pBox); + void set_content_area(VclBox *pBox); + +public: + Dialog( Window* pParent, WinBits nStyle = WB_STDDIALOG ); + Dialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription ); + virtual ~Dialog(); + + virtual long Notify( NotifyEvent& rNEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual Size GetOptimalSize() const; + virtual void Resize(); + bool isLayoutEnabled() const; + void setOptimalLayoutSize(); + bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; } + virtual void queue_layout(); + virtual bool set_property(const OString &rKey, const OString &rValue); + VclButtonBox* get_action_area(); + VclBox* get_content_area(); + + virtual sal_Bool Close(); + + virtual short Execute(); + sal_Bool IsInExecute() const { return mbInExecute; } + + //////////////////////////////////////// + // Dialog::Execute replacement API +public: + // Link impl: DECL_LINK( MyEndDialogHdl, Dialog* ); <= param is dialog just ended + virtual void StartExecuteModal( const Link& rEndDialogHdl ); + 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, const ResId& rResId ); + ModelessDialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription ); +}; + +// --------------- +// - ModalDialog - +// --------------- + +class VCL_DLLPUBLIC ModalDialog : public Dialog +{ +public: + ModalDialog( Window* pParent, WinBits nStyle = WB_STDMODAL ); + ModalDialog( Window* pParent, const OString& rID, const OUString& rUIXMLDescription ); + ModalDialog( Window* pParent, const ResId& rResId ); + +protected: + using Window::Show; + void Show( sal_Bool bVisible = sal_True ); + using Window::Hide; + void Hide(); + +private: + + // 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/include/vcl/displayconnectiondispatch.hxx b/include/vcl/displayconnectiondispatch.hxx new file mode 100644 index 000000000000..06009c15867a --- /dev/null +++ b/include/vcl/displayconnectiondispatch.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dllapi.h b/include/vcl/dllapi.h new file mode 100644 index 000000000000..f501125e72f9 --- /dev/null +++ b/include/vcl/dllapi.h @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/dndhelp.hxx b/include/vcl/dndhelp.hxx new file mode 100644 index 000000000000..2504f697f2d7 --- /dev/null +++ b/include/vcl/dndhelp.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/dockingarea.hxx b/include/vcl/dockingarea.hxx new file mode 100644 index 000000000000..a5778519e3ae --- /dev/null +++ b/include/vcl/dockingarea.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_DOCKINGAREA_HXX +#define _SV_DOCKINGAREA_HXX + +#include <tools/solar.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/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx new file mode 100644 index 000000000000..19b516b004a3 --- /dev/null +++ b/include/vcl/dockwin.hxx @@ -0,0 +1,420 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_DOCKWIN_HXX +#define _SV_DOCKWIN_HXX + +#include <tools/solar.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 ); + + void SetMinOutputSizePixel( const Size& rSize ); + + void SetMaxOutputSizePixel( const Size& rSize ); + + 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 SetFloatStyle( WinBits nWinStyle ); + WinBits GetFloatStyle() 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 ) + { mpDockingWindow->SetPosSizePixel( rNewPos, rNewSize ); } + Point GetPosPixel() const; + Size GetSizePixel() 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 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 ); + + 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; + + 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/include/vcl/edit.hxx b/include/vcl/edit.hxx new file mode 100644 index 000000000000..488758ab7d4a --- /dev/null +++ b/include/vcl/edit.hxx @@ -0,0 +1,265 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_EDIT_HXX +#define _SV_EDIT_HXX + +#include <tools/solar.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; +}}}} + +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; + OUStringBuffer maText; + OUString maPlaceholderText; + OUString maSaveValue; + OUString maUndoText; + OUString maRedoText; + long mnXOffset; + Selection maSelection; + sal_uInt16 mnAlign; + xub_StrLen mnMaxTextLen; + sal_Int32 mnWidthInChars; + AutocompleteAction meAutocompleteAction; + sal_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, void* ); + + SAL_DLLPRIVATE bool ImplTruncateToMaxLen( OUString&, sal_uInt32 nSelectionLen ) const; + SAL_DLLPRIVATE void ImplInitEditData(); + SAL_DLLPRIVATE void ImplModified(); + SAL_DLLPRIVATE OUString 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 OUString& rStr, const Selection* pNewSelection = 0 ); + SAL_DLLPRIVATE void ImplInsertText( const OUString& rStr, const Selection* pNewSelection = 0, sal_Bool bIsUserInput = sal_False ); + SAL_DLLPRIVATE OUString ImplGetValidString( const OUString& rString ) const; + SAL_DLLPRIVATE void ImplClearBackground( long nXStart, long nXEnd ); + SAL_DLLPRIVATE void ImplPaintBorder( 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 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(); + SAL_DLLPRIVATE long ImplGetExtraOffset() const; + 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 ); + 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( sal_Unicode c ); + sal_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; } + + void SetWidthInChars(sal_Int32 nWidthInChars); + sal_Int32 GetWidthInChars() const { return mnWidthInChars; } + + virtual void SetSelection( const Selection& rSelection ); + virtual const Selection& GetSelection() const; + + virtual void ReplaceSelected( const OUString& rStr ); + virtual void DeleteSelected(); + virtual OUString GetSelected() const; + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + void Undo(); + + virtual void SetText( const OUString& rStr ); + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); + virtual OUString GetText() const; + + virtual void SetPlaceholderText( const OUString& rStr ); + virtual OUString GetPlaceholderText() const; + + void SaveValue() { maSaveValue = GetText(); } + const OUString& 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; } + + 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 CalcMinimumSizeForText(const OUString &rString) const; + virtual Size GetOptimalSize() 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 OUString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + virtual bool set_property(const OString &rKey, const OString &rValue); + + // 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/include/vcl/embeddedfontshelper.hxx b/include/vcl/embeddedfontshelper.hxx new file mode 100644 index 000000000000..0b66e8ab157a --- /dev/null +++ b/include/vcl/embeddedfontshelper.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef VCL_EMBEDDEDFONTSHELPER_HXX +#define VCL_EMBEDDEDFONTSHELPER_HXX + +#include <vcl/dllapi.h> + +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> +#include <tools/fontenum.hxx> +#include <vector> + +/** + Helper functions for handling embedded fonts in documents. + +*/ +class VCL_DLLPUBLIC EmbeddedFontsHelper +{ +public: + /// Specification of what kind of operation is allowed when embedding a font + enum FontRights + { + ViewingAllowed, ///< Font may be embedded for viewing the document (but not editing) + EditingAllowed ///< Font may be embedded for editing document (implies viewing) + }; + + /** + Returns URL for a font file for the given font, or empty if it does not exist. + */ + static OUString fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic, + FontWeight weight, FontPitch pitch, rtl_TextEncoding encoding, FontRights rights ); + + /** + Reads a font from the input stream, saves it to a temporary font file and activates the font. + @param stream stream of font data + @param fontName name of the font (e.g. 'Times New Roman') + @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique + @param key key to xor the data with, from the start until the key's length (not repeated) + */ + static bool addEmbeddedFont( com::sun::star::uno::Reference< com::sun::star::io::XInputStream > stream, + const OUString& fontName, const char* extra, + std::vector< unsigned char > key = std::vector< unsigned char >()); + + /** + Returns an URL for a file where to store contents of a given temporary font. + The file may or not may not exist yet, and will be cleaned up automatically as appropriate. + Use activateTemporaryFont() to actually enable usage of the font. + + @param fontName name of the font (e.g. 'Times New Roman') + @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique + */ + static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* extra ); + + /** + Adds the given font to the list of known fonts. The font is used only until application + exit. + + @param fontName name of the font (e.g. 'Times New Roman') + @param fileUrl URL of the font file + */ + static void activateFont( const OUString& fontName, const OUString& fileUrl ); + + /** + Returns if the restrictions specified in the font (if present) allow embedding + the font for a particular purpose. + @param data font data + @param size size of the font data + @param rights type of operation to be allowed for the font + */ + static bool sufficientFontRights( const void* data, long size, FontRights rights ); + + /** + Removes all temporary fonts in the path used by fileUrlForTemporaryFont(). + @internal + */ + static void clearTemporaryFontFiles(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx new file mode 100644 index 000000000000..e89d52ad1e9a --- /dev/null +++ b/include/vcl/event.hxx @@ -0,0 +1,522 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_EVENT_HXX +#define _SV_EVENT_HXX + +#include <tools/solar.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; + sal_Unicode mnCharCode; + +public: + KeyEvent(); + KeyEvent( sal_Unicode nChar, const KeyCode& rKeyCode, + sal_uInt16 nRepeat = 0 ); + + sal_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( sal_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 ); + + 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; +} + +class VCL_DLLPUBLIC ZoomEvent +{ +private: + Point maCenter; + float mfScale; + +public: + ZoomEvent() : + mfScale( 1 ) + { + } + + ZoomEvent( const Point& rCenter, + float fScale ) : + maCenter( rCenter ), + mfScale( fScale ) + { + } + + const Point& GetCenter() const + { + return maCenter; + } + + float GetScale() const + { + return mfScale; + } +}; + +class VCL_DLLPUBLIC ScrollEvent +{ +private: + int mnXOffset; + int mnYOffset; + +public: + ScrollEvent() : + mnXOffset( 0 ), + mnYOffset( 0 ) + { + } + + ScrollEvent( int xOffset, int yOffset ) : + mnXOffset( xOffset ), + mnYOffset( yOffset ) + { + } + + int GetXOffset() const + { + return mnXOffset; + } + + int GetYOffset() const + { + return mnYOffset; + } +}; + +// ------------- +// - 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 + +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/include/vcl/evntpost.hxx b/include/vcl/evntpost.hxx new file mode 100644 index 000000000000..3116ab7c58b7 --- /dev/null +++ b/include/vcl/evntpost.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#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/include/vcl/extoutdevdata.hxx b/include/vcl/extoutdevdata.hxx new file mode 100644 index 000000000000..2ee5967c473d --- /dev/null +++ b/include/vcl/extoutdevdata.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/field.hxx b/include/vcl/field.hxx new file mode 100644 index 000000000000..babab8da29d2 --- /dev/null +++ b/include/vcl/field.hxx @@ -0,0 +1,832 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; +class LanguageTag; + +// ----------------- +// - 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 OUString& rText, Selection* pNewSel = NULL ); + SAL_DLLPRIVATE sal_Bool ImplGetEmptyFieldValue() const { return mbEmptyFieldValue; } + + 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 LanguageTag& GetLanguageTag() 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: + OString m_aEditMask; + OUString maFieldString; + OUString maLiteralMask; + sal_uInt16 mnFormatFlags; + sal_Bool mbSameMask; + sal_Bool mbInPattKeyInput; + +protected: + PatternFormatter(); + + SAL_DLLPRIVATE void ImplSetMask(const OString& rEditMask, + const OUString& rLiteralMask); + SAL_DLLPRIVATE sal_Bool ImplIsSameMask() const { return mbSameMask; } + SAL_DLLPRIVATE sal_Bool& ImplGetInPattKeyInput() { return mbInPattKeyInput; } + +public: + ~PatternFormatter(); + + virtual void Reformat(); + + void SetMask(const OString& rEditMask, const OUString& rLiteralMask ); + const OString& GetEditMask() const { return m_aEditMask; } + const OUString& GetLiteralMask() const { return maLiteralMask; } + + void SetFormatFlags( sal_uInt16 nFlags ) { mnFormatFlags = nFlags; } + sal_uInt16 GetFormatFlags() const { return mnFormatFlags; } + + void SetString( const OUString& rStr ); + OUString GetString() const; + sal_Bool IsStringModified() const { return !(GetString() == maFieldString ); } +}; + +// -------------------- +// - 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(); + + void FieldUp(); + void FieldDown(); + void FieldFirst(); + void FieldLast(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplNumericReformat( const OUString& rStr, sal_Int64& rValue, OUString& 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; + virtual OUString CreateFieldText( sal_Int64 nValue ) const; + sal_Bool IsValueModified() const; + sal_Int64 GetCorrectedValue() const { return mnCorrectedValue; } + + 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: + OUString maCustomUnitText; + OUString maCurUnitText; + sal_Int64 mnBaseValue; + FieldUnit meUnit; + Link maCustomConvertLink; + +protected: + MetricFormatter(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr ); + +public: + ~MetricFormatter(); + + virtual void CustomConvert() = 0; + virtual void Reformat(); + + virtual void SetUnit( FieldUnit meUnit ); + FieldUnit GetUnit() const { return meUnit; } + void SetCustomUnitText( const OUString& rStr ); + const OUString& GetCustomUnitText() const { return maCustomUnitText; } + const OUString& 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; + virtual OUString CreateFieldText( sal_Int64 nValue ) 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: + SAL_DLLPRIVATE void ImplInit(); + +protected: + CurrencyFormatter(); + SAL_DLLPRIVATE sal_Bool ImplCurrencyReformat( const OUString& rStr, OUString& rOutStr ); + +public: + ~CurrencyFormatter(); + + virtual void Reformat(); + + String GetCurrencySymbol() const; + + virtual void SetValue( sal_Int64 nNewValue ); + virtual sal_Int64 GetValue() const; + virtual OUString CreateFieldText( sal_Int64 nValue ) 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 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 OUString& rStr, OUString& rOutStr, + const AllSettings& rSettings ); + SAL_DLLPRIVATE void ImplSetUserDate( const Date& rNewDate, + Selection* pNewSelection = NULL ); + SAL_DLLPRIVATE OUString 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; + 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 mbEnforceValidValue; + + SAL_DLLPRIVATE void ImplInit(); + +protected: + Time maFieldTime; + + TimeFormatter(); + + SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); + SAL_DLLPRIVATE sal_Bool ImplTimeReformat( const OUString& rStr, OUString& 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; + 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(); + + 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 Size CalcMinimumSize() const; + + virtual void Modify(); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + + +// ---------------- +// - 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 Size CalcMinimumSize() const; + + 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, + 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 ); } + + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + + +// ----------------- +// - CurrencyField - +// ----------------- + +class VCL_DLLPUBLIC CurrencyField : public SpinField, public CurrencyFormatter +{ +public: + CurrencyField( Window* pParent, WinBits nWinStyle ); + + ~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(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); +}; + + +// -------------- +// - 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 ); +}; + + +// ------------- +// - 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 ); + 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(); + + virtual sal_Int64 GetValue() const; +}; + +// ----------- +// - DateBox - +// ----------- + +class VCL_DLLPUBLIC DateBox : public ComboBox, public DateFormatter +{ +public: + DateBox( Window* pParent, WinBits nWinStyle ); + ~DateBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); +}; + + +// ----------- +// - TimeBox - +// ----------- + +class VCL_DLLPUBLIC TimeBox : public ComboBox, public TimeFormatter +{ +public: + TimeBox( Window* pParent, WinBits nWinStyle ); + ~TimeBox(); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rNEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Modify(); + + virtual void ReformatAll(); +}; + +#endif // _SV_FIELD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fixed.hxx b/include/vcl/fixed.hxx new file mode 100644 index 000000000000..b592d98a48d2 --- /dev/null +++ b/include/vcl/fixed.hxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_FIXED_HXX +#define _SV_FIXED_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/edit.hxx> +#include <vcl/image.hxx> + +class UserDrawEvent; + +// ------------- +// - FixedText - +// ------------- + +class VCL_DLLPUBLIC FixedText : public Control +{ +private: + sal_Int32 m_nMaxWidthChars; + sal_Int32 m_nMinWidthChars; + Window *m_pMnemonicWindow; + + 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; + + virtual Window* getAccessibleRelationLabelFor() const; + +public: + FixedText( Window* pParent, WinBits nStyle = 0 ); + FixedText( Window* pParent, const ResId& rResId ); + ~FixedText(); + + 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 setMaxWidthChars(sal_Int32 nWidth); + sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; } + void setMinWidthChars(sal_Int32 nWidth); + sal_Int32 getMinWidthChars() const { return m_nMinWidthChars; } + static Size CalcMinimumTextSize(Control const* pControl, long nMaxWidth = 0x7fffffff); + static Size getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth); + Size CalcMinimumSize(long nMaxWidth = 0x7fffffff) const; + virtual Size GetOptimalSize() const; + virtual bool set_property(const OString &rKey, const OString &rValue); + void set_mnemonic_widget(Window *pWindow); + Window* get_mnemonic_widget() const { return m_pMnemonicWindow; } +}; + +class VCL_DLLPUBLIC SelectableFixedText : public Edit +{ +public: + SelectableFixedText( Window* pParent, WinBits nStyle = 0 ); + + virtual void LoseFocus(); +}; + +// ------------- +// - 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() 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; } +}; + +// -------------- +// - 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() const; + + void SetImage( const Image& rImage ); + const Image& GetImage() const { return maImage; } + + sal_Bool SetModeImage( const Image& rImage ); + const Image& GetModeImage( ) const; + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +#endif // _SV_FIXED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fixedhyper.hxx b/include/vcl/fixedhyper.hxx new file mode 100644 index 000000000000..b43e4bd7fd6e --- /dev/null +++ b/include/vcl/fixedhyper.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef VCL_FIXEDHYPER_HXX +#define VCL_FIXEDHYPER_HXX + +#include <vcl/dllapi.h> +#include <vcl/fixed.hxx> + + //===================================================================== + //= FixedHyperlink + //===================================================================== + class VCL_DLLPUBLIC FixedHyperlink : public FixedText + { + private: + long m_nTextLen; + Pointer m_aOldPointer; + Link m_aClickHdl; + OUString m_sURL; + + /** initializes the font (link color and underline). + + Called by the Ctors. + */ + void Initialize(); + + protected: + /** overwrites Window::MouseMove(). + + Changes the pointer only over the text. + */ + virtual void MouseMove( const MouseEvent& rMEvt ); + + /** overwrites Window::MouseButtonUp(). + + Calls the set link if the mouse is over the text. + */ + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + + /** overwrites Window::RequestHelp(). + + Shows tooltip only if the mouse is over the text. + */ + virtual void RequestHelp( const HelpEvent& rHEvt ); + + public: + /** ctors + + With ResId or WinBits. + */ + FixedHyperlink( Window* pParent, const ResId& rId ); + FixedHyperlink( Window* pParent, WinBits nWinStyle = 0 ); + + /** dtor + + */ + virtual ~FixedHyperlink(); + + /** overwrites Window::GetFocus(). + + Changes the color of the text and shows a focus rectangle. + */ + virtual void GetFocus(); + + /** overwrites Window::LoseFocus(). + + Changes the color of the text and hides the focus rectangle. + */ + virtual void LoseFocus(); + + /** overwrites Window::KeyInput(). + + KEY_RETURN and KEY_SPACE calls the link handler. + */ + virtual void KeyInput( const KeyEvent& rKEvt ); + + virtual bool set_property(const OString &rKey, const OString &rValue); + + + /** sets <member>m_aClickHdl</member> with <arg>rLink</arg>. + + <member>m_aClickHdl</member> is called if the text is clicked. + */ + inline void SetClickHdl( const Link& rLink ) { m_aClickHdl = rLink; } + + /** returns <member>m_aClickHdl</member>. + + @return + <member>m_aClickHdl</member> + */ + inline const Link& GetClickHdl() const { return m_aClickHdl; } + + // ::FixedHyperbaseLink + + /** sets the URL of the hyperlink and uses it as tooltip. */ + void SetURL(const OUString& rNewURL); + + /** returns the URL of the hyperlink. + + @return + <member>m_sURL</member> + */ + OUString GetURL() const; + + /** sets new text and recalculates the text length. */ + virtual void SetText(const OUString& rNewDescription); + }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/floatwin.hxx b/include/vcl/floatwin.hxx new file mode 100644 index 000000000000..4f29b40e01a5 --- /dev/null +++ b/include/vcl/floatwin.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_FLOATWIN_HXX +#define _SV_FLOATWIN_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> + +class ToolBox; + +// ------------------------ +// - 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 ); + 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/include/vcl/fltcall.hxx b/include/vcl/fltcall.hxx new file mode 100644 index 000000000000..03a634073d95 --- /dev/null +++ b/include/vcl/fltcall.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _FLTCALL_HXX +#define _FLTCALL_HXX +#include <sal/types.h> +#include <vcl/field.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <vcl/FilterConfigItem.hxx> + +class FilterConfigItem; +class SvStream; +class Graphic; +class Window; + +struct FltCallDialogParameter +{ + + Window* pWindow; + ResMgr* pResMgr; + FieldUnit eFieldUnit; + String aFilterExt; + + // In and Out PropertySequence for all filter dialogs + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aFilterData; + + FltCallDialogParameter( Window* pW, ResMgr* pRsMgr, FieldUnit eFiUni ) : + pWindow ( pW ), + pResMgr ( pRsMgr ), + eFieldUnit ( eFiUni ) {}; +}; + +typedef sal_Bool (*PFilterCall)(SvStream & rStream, Graphic & rGraphic, + FilterConfigItem* pConfigItem, sal_Bool bPrefDialog); + // Of this type are both export-filter and import-filter functions + // rFileName is the complete path to the file to be imported or exported + // pCallBack can be NULL. pCallerData is handed to the callback function + // pOptionsConfig can be NULL; if not, the group of the config is already set + // and may not be changed by this filter! + // If bPrefDialog==sal_True, a Preferences-Dialog might be called + +typedef sal_Bool ( *PFilterDlgCall )( FltCallDialogParameter& ); + // Of this type are both export-filter and import-filter functions + // hands a pointer to the parent window and to the options config + // pOptions and pWindow can be NULL; in this case sal_False is returned, + // otherwise the group of the config is already set + // and may not be changed by this filter! + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fntstyle.hxx b/include/vcl/fntstyle.hxx new file mode 100644 index 000000000000..5e877b3f28fc --- /dev/null +++ b/include/vcl/fntstyle.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/font.hxx b/include/vcl/font.hxx new file mode 100644 index 000000000000..d886d48b9854 --- /dev/null +++ b/include/vcl/font.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_FONT_HXX +#define _SV_FONT_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <tools/string.hxx> +#include <i18nlangtag/lang.h> +#include <tools/color.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/fntstyle.hxx> + +class SvStream; +#define FontAlign TextAlign + +class Impl_Font; +class ImplFontAttributes; +class Size; + +// -------- +// - 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(); + + // setting the color on the font is obsolete, the only remaining + // valid use is for keeping backward compatibility with old MetaFiles + 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 OUString& 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/include/vcl/fontcapabilities.hxx b/include/vcl/fontcapabilities.hxx new file mode 100644 index 000000000000..5740b96c3411 --- /dev/null +++ b/include/vcl/fontcapabilities.hxx @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _VCLFONTCAPABILITIES_HXX +#define _VCLFONTCAPABILITIES_HXX + +#include <boost/dynamic_bitset.hpp> +#include <vector> + +//See OS/2 table, i.e. http://www.microsoft.com/typography/otspec/os2.htm#ur +namespace vcl +{ + namespace UnicodeCoverage + { + enum UnicodeCoverageEnum + { + 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 + }; + }; + + namespace CodePageCoverage + { + enum CodePageCoverageEnum + { + 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/include/vcl/fontmanager.hxx b/include/vcl/fontmanager.hxx new file mode 100644 index 000000000000..05955f984710 --- /dev/null +++ b/include/vcl/fontmanager.hxx @@ -0,0 +1,578 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 "vcl/timer.hxx" +#include "vcl/vclenum.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; +class FontSelectPattern; + +namespace psp { +class PPDParser; // see ppdparser.hxx + +namespace fonttype +{ +enum type { + Unknown = 0, + Type1 = 1, + TrueType = 2, + Builtin = 3 +}; +} + +/* + * 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 + OUString m_aFamilyName; + OUString m_aStyleName; + std::list< OUString > m_aAliases; + FontFamily m_eFamilyStyle; + FontItalic m_eItalic; + FontWidth m_eWidth; + FontWeight m_eWeight; + FontPitch m_ePitch; + rtl_TextEncoding m_aEncoding; + bool m_bSubsettable; + bool m_bEmbeddable; + + FastPrintFontInfo() : + m_nID( 0 ), + m_eType( fonttype::Unknown ), + m_eFamilyStyle( FAMILY_DONTKNOW ), + m_eItalic( ITALIC_DONTKNOW ), + m_eWidth( WIDTH_DONTKNOW ), + m_eWeight( WEIGHT_DONTKNOW ), + m_ePitch( PITCH_DONTKNOW ), + 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 + OUString m_aStyleName; + FontItalic m_eItalic; + FontWidth m_eWidth; + FontWeight m_eWeight; + FontPitch 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, OString > m_aNonEncoded; + + PrintFont( fonttype::type eType ); + virtual ~PrintFont(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) = 0; + + bool readAfmMetrics( utl::MultiAtomProvider* pProvider, bool bFillEncodingvector, bool bOnlyGlobalAttributes ); + }; + + struct Type1FontFile : public PrintFont + { + int m_nDirectory; // atom containing system dependent path + OString m_aFontFile; // relative to directory + OString m_aMetricFile; // dito + + /* 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 + OString m_aFontFile; // relative to directory + int m_nCollectionEntry; // 0 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 + OString m_aMetricFile; + + BuiltinFont() : PrintFont( fonttype::Builtin ) {} + virtual ~BuiltinFont(); + virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ); + }; + + fontID m_nNextFontID; + boost::unordered_map< fontID, PrintFont* > m_aFonts; + boost::unordered_map< int, FontFamily > m_aFamilyTypes; + std::list< OUString > m_aPrinterDrivers; + std::list< OString > m_aFontDirectories; + std::list< int > m_aPrivateFontDirectories; + utl::MultiAtomProvider* m_pAtoms; + // for speeding up findFontFileID + boost::unordered_map< OString, std::set< fontID >, OStringHash > + m_aFontFileToFontID; + + boost::unordered_map< OString, int, OStringHash > + m_aDirToAtom; + boost::unordered_map< int, OString > m_aAtomToDir; + int m_nNextDirAtom; + + boost::unordered_multimap< OString, sal_Unicode, OStringHash > + m_aAdobenameToUnicode; + boost::unordered_multimap< sal_Unicode, 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; + + mutable std::vector< fontID > m_aOverrideFonts; + + OString getAfmFile( PrintFont* pFont ) const; + OString getFontFile( PrintFont* pFont ) const; + + bool analyzeFontFile( int nDirID, const OString& rFileName, std::list< PrintFont* >& rNewFonts, const char *pFormat=NULL ) const; + OUString convertTrueTypeName( void* pNameRecord ) const; // actually a NameRecord* formt font subsetting code + void analyzeTrueTypeFamilyName( void* pTTFont, std::list< OUString >& rnames ) const; // actually a TrueTypeFont* from font subsetting code + bool analyzeTrueTypeFile( PrintFont* pFont ) const; + // finds the font id for the nFaceIndex face in this font file + // There may be multiple font ids for TrueType collections + fontID findFontFileID( int nDirID, const OString& rFile, int nFaceIndex ) const; + + // There may be multiple font ids for TrueType collections + std::vector<fontID> findFontFileIDs( int nDirID, const OString& rFile ) const; + + bool knownFontFile( int nDirID, const OString& rFile ) const + { + return findFontFileID(nDirID, rFile, 0) != 0; + } + + fontID findFontBuiltinID( int nPSNameAtom ) const; + + FontFamily matchFamilyName( const 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; + } + void fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& rInfo ) const; + void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const; + + OString getDirectory( int nAtom ) const; + int getDirectoryAtom( const OString& rDirectory, bool bCreate = false ); + + /* try to initialize fonts from libfontconfig + + called from <code>initialize()</code> + */ + void initFontconfig(); + void countFontconfigFonts( boost::unordered_map<OString, int, 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 OString& rDirectory); + + bool readOverrideMetrics(); + + std::set<OString> m_aPreviousLangSupportRequests; + std::vector<OString> m_aCurrentRequests; + Timer m_aFontInstallerTimer; + + DECL_LINK( autoInstallFontLangSupport, void* ); + + PrintFontManager(); + ~PrintFontManager(); +public: + static PrintFontManager& get(); // one instance only + + // There may be multiple font ids for TrueType collections + std::vector<fontID> addFontFile( const OString& rFileName ); + + 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 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 PSName name + const OUString& getPSName( 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 + FontItalic getFontItalic( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eItalic : ITALIC_DONTKNOW; + } + + // get a specific fonts width type + FontWidth getFontWidth( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eWidth : WIDTH_DONTKNOW; + } + + // get a specific fonts weight type + FontWeight getFontWeight( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_eWeight : WEIGHT_DONTKNOW; + } + + // get a specific fonts pitch type + FontPitch getFontPitch( fontID nFontID ) const + { + PrintFont* pFont = getFont( nFontID ); + return pFont ? pFont->m_ePitch : PITCH_DONTKNOW; + } + + // 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 + OString getFontFileSysPath( fontID nFontID ) const + { + return getFontFile( getFont( nFontID ) ); + } + + // get the ttc face number + int getFontFaceNumber( fontID nFontID ) const; + + // get a specific fonts ascend + int getFontAscend( fontID nFontID ) const; + + // get a specific fonts descent + int getFontDescend( fontID nFontID ) const; + + // get a fonts glyph bounding box + bool getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax ); + + // info whether an array of glyphs has vertical substitutions + void hasVerticalSubstitutions( fontID nFontID, const sal_Unicode* pCharacters, + int nCharacters, bool* pHasSubst ) 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, 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 for printing/viewing + // type1 fonts do not have such a feature, so return for them is true + // returns true for builtin fonts (surprise!) + bool isFontDownloadingAllowedForPrinting( fontID nFont ) const; + + // helper for type 1 fonts + std::list< 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 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 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 + + /* 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; + + bool Substitute( FontSelectPattern &rPattern, OUString& rMissingCodes ); + + int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar ); +}; + +} // namespace + +#endif // _PSPRINT_FONTMANAGER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fpicker.hrc b/include/vcl/fpicker.hrc new file mode 100644 index 000000000000..827d24069101 --- /dev/null +++ b/include/vcl/fpicker.hrc @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + */ +#ifndef _FPICKER_HRC +#define _FPICKER_HRC + +#include <svl/solar.hrc> + +#define STR_SVT_FILEPICKER_START (RID_FPICKER_START+1) +#define STR_SVT_FILEPICKER_AUTO_EXTENSION (STR_SVT_FILEPICKER_START+ 0) +#define STR_SVT_FILEPICKER_PASSWORD (STR_SVT_FILEPICKER_START+ 1) +#define STR_SVT_FILEPICKER_FILTER_OPTIONS (STR_SVT_FILEPICKER_START+ 2) +#define STR_SVT_FILEPICKER_READONLY (STR_SVT_FILEPICKER_START+ 3) +#define STR_SVT_FILEPICKER_INSERT_AS_LINK (STR_SVT_FILEPICKER_START+ 4) +#define STR_SVT_FILEPICKER_SHOW_PREVIEW (STR_SVT_FILEPICKER_START+ 5) +#define STR_SVT_FILEPICKER_PLAY (STR_SVT_FILEPICKER_START+ 6) +#define STR_SVT_FILEPICKER_VERSION (STR_SVT_FILEPICKER_START+ 7) +#define STR_SVT_FILEPICKER_TEMPLATES (STR_SVT_FILEPICKER_START+ 8) +#define STR_SVT_FILEPICKER_IMAGE_TEMPLATE (STR_SVT_FILEPICKER_START+ 9) +#define STR_SVT_FILEPICKER_SELECTION (STR_SVT_FILEPICKER_START+10) +#define STR_SVT_FILEPICKER_FILTER_TITLE (STR_SVT_FILEPICKER_START+11) +#define STR_SVT_FOLDERPICKER_DEFAULT_TITLE (STR_SVT_FILEPICKER_START+12) +#define STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION (STR_SVT_FILEPICKER_START+13) +#define STR_SVT_ALREADYEXISTOVERWRITE (STR_SVT_FILEPICKER_START+14) + + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx new file mode 100644 index 000000000000..bbdf14177b3b --- /dev/null +++ b/include/vcl/gdimtf.hxx @@ -0,0 +1,248 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GDIMTF_HXX +#define _SV_GDIMTF_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <vcl/mapmod.hxx> +#include <vector> + +class OutputDevice; +class MetaAction; +class MetaCommentAction; +class SvStream; +class Color; +class BitmapEx; +class Polygon; +class PolyPolygon; +class Gradient; + +// --------------------- +// - GDIMetaFile-Types - +// --------------------- + +#define GDI_METAFILE_END ((size_t)0xFFFFFFFF) +#define GDI_METAFILE_LABEL_NOTFOUND ((size_t)0xFFFFFFFF) + +#ifndef METAFILE_END +#define METAFILE_END GDI_METAFILE_END +#endif + +#ifndef METAFILE_LABEL_NOTFOUND +#define METAFILE_LABEL_NOTFOUND GDI_METAFILE_LABEL_NOTFOUND +#endif + +#define MTF_MIRROR_NONE 0x00000000UL +#define MTF_MIRROR_HORZ 0x00000001UL +#define MTF_MIRROR_VERT 0x00000002UL + +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 ); + +class VCL_DLLPUBLIC GDIMetaFile +{ +private: + ::std::vector< MetaAction* > aList; + size_t nCurrentActionElement; + + MapMode aPrefMapMode; + Size aPrefSize; + Link aHookHdlLink; + GDIMetaFile* pPrev; + GDIMetaFile* pNext; + OutputDevice* pOutDev; + 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(); + + 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 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, Rectangle* pHairline = 0 ) const; + + 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* 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, size_t nPos = GDI_METAFILE_END ); + void Play( OutputDevice* pOutDev, size_t nPos = GDI_METAFILE_END ); + void Play( OutputDevice* pOutDev, const Point& rPos, + const Size& rSize, size_t nPos = GDI_METAFILE_END ); + + void Pause( sal_Bool bPause ); + sal_Bool IsPause() const { return bPause; } + + void Stop(); + + void WindStart(); + void WindPrev(); + + size_t GetActionSize() const; + + void AddAction( MetaAction* pAction ); + void AddAction( MetaAction* pAction, size_t nPos ); + void RemoveAction( size_t nPos ); + void push_back( MetaAction* pAction ); + + MetaAction* FirstAction(); + MetaAction* NextAction(); + MetaAction* GetAction( size_t nAction ) const; + MetaAction* GetCurAction() const { return GetAction( nCurrentActionElement ); } + /** + * @param pAction takes ownership + */ + MetaAction* ReplaceAction( MetaAction* pAction, size_t nAction ); + + 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; + + // Methods for reading and writing the new formats; + // the Read method also reads the old format + SvStream& Read( SvStream& rIStm ); + SvStream& Write( SvStream& rOStm ); + + // Stream-operators write (still) the old format + // and read both the old and the new 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 OUString& rRendererServiceName, + const OUString& rGraphicServiceName, + const void* pData, + sal_uInt32 nDataSize ); + +#endif // _SV_GDIMTF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx new file mode 100644 index 000000000000..380298b500b8 --- /dev/null +++ b/include/vcl/gfxlink.hxx @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GFXLINK_HXX +#define _SV_GFXLINK_HXX + +#include <vcl/dllapi.h> +#include <tools/solar.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 +{ + 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_NATIVE_SVG = 9, // 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_SVG + +// ----------- +// - 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/include/vcl/gradient.hxx b/include/vcl/gradient.hxx new file mode 100644 index 000000000000..d9bbf7aea1ad --- /dev/null +++ b/include/vcl/gradient.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GRADIENT_HXX +#define _SV_GRADIENT_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> + +#include <vcl/vclenum.hxx> + +// ---------------- +// - Impl_Gradient - +// ---------------- + +class Rectangle; +class Point; +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, + 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/include/vcl/graph.h b/include/vcl/graph.h new file mode 100644 index 000000000000..94224b780d93 --- /dev/null +++ b/include/vcl/graph.h @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GRAPH_H +#define _SV_GRAPH_H + +#include <vcl/dllapi.h> +#include <tools/string.hxx> +#include <tools/solar.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 + void DisablePreviewMode(); + void SetPreviewSize( const Size& ); + Size GetPreviewSize() const; +}; + +#endif // _SV_GRAPH_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx new file mode 100644 index 000000000000..4f1facae5395 --- /dev/null +++ b/include/vcl/graph.hxx @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GRAPH_HXX +#define _SV_GRAPH_HXX + +#include <tools/stream.hxx> +#include <vcl/dllapi.h> +#include <tools/solar.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> +#include <vcl/svgdata.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 SvgDataPtr& rSvgDataPtr ); + 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; + sal_Bool IsEPS() 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 DrawEx( OutputDevice* pOutDev, const OUString& rText, + Font& rFont, const BitmapEx& rBitmap, + const Point& rDestPt, const Size& rDestSize ); + + 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; + + sal_uLong GetChecksum() const; + +public: + + GraphicReader* GetContext(); + void SetContext( GraphicReader* pReader ); + +public: + + void SetDocFileName( const String& rName, sal_uLong nFilePos ); + const String& GetDocFileName() const; + sal_uLong GetDocFilePos() const; + + 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& ); + + const SvgDataPtr& getSvgData() const; +}; + +#endif // _SV_GRAPH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx new file mode 100644 index 000000000000..8f42119360d1 --- /dev/null +++ b/include/vcl/graphicfilter.hxx @@ -0,0 +1,325 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _FILTER_HXX +#define _FILTER_HXX + +#include <tools/gen.hxx> +#include <tools/stream.hxx> +#include <tools/urlobj.hxx> +#include <vcl/dllapi.h> +#include <vcl/field.hxx> +#include <vcl/graph.hxx> + +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> + +class FilterConfigCache; +struct WMF_EXTERNALHEADER; +struct ConvertData; + +#define GRFILTER_OK 0 +#define GRFILTER_OPENERROR 1 +#define GRFILTER_IOERROR 2 +#define GRFILTER_FORMATERROR 3 +#define GRFILTER_VERSIONERROR 4 +#define GRFILTER_FILTERERROR 5 +#define GRFILTER_ABORT 6 +#define GRFILTER_TOOBIG 7 + +#define GRFILTER_OUTHINT_GREY 1 + +#define GRFILTER_FORMAT_NOTFOUND ((sal_uInt16)0xFFFF) +#define GRFILTER_FORMAT_DONTKNOW ((sal_uInt16)0xFFFF) + +#define GRFILTER_I_FLAGS_SET_LOGSIZE_FOR_JPEG 00000001 +#define GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG 00000002 +#define GRFILTER_I_FLAGS_FOR_PREVIEW 00000004 +#define GRFILTER_I_FLAGS_ALLOW_PARTIAL_STREAMREAD 00000010 + +#define IMP_BMP "SVBMP" +#define IMP_SVMETAFILE "SVMETAFILE" +#define IMP_WMF "SVWMF" +#define IMP_EMF "SVEMF" +#define IMP_SVSGF "SVSGF" +#define IMP_SVSGV "SVSGV" +#define IMP_GIF "SVIGIF" +#define IMP_PNG "SVIPNG" +#define IMP_JPEG "SVIJPEG" +#define IMP_XBM "SVIXBM" +#define IMP_XPM "SVIXPM" +#define IMP_SVG "SVISVG" +#define EXP_BMP "SVBMP" +#define EXP_SVMETAFILE "SVMETAFILE" +#define EXP_WMF "SVWMF" +#define EXP_EMF "SVEMF" +#define EXP_JPEG "SVEJPEG" +#define EXP_SVG "SVESVG" +#define EXP_PNG "SVEPNG" + +#define BMP_SHORTNAME "BMP" +#define GIF_SHORTNAME "GIF" +#define JPG_SHORTNAME "JPG" +#define MET_SHORTNAME "MET" +#define PCT_SHORTNAME "PCT" +#define PNG_SHORTNAME "PNG" +#define SVM_SHORTNAME "SVM" +#define TIF_SHORTNAME "TIF" +#define WMF_SHORTNAME "WMF" +#define EMF_SHORTNAME "EMF" +#define SVG_SHORTNAME "SVG" + +// Info class for all supported file formats + +#define GFF_NOT ( (sal_uInt16)0x0000 ) +#define GFF_BMP ( (sal_uInt16)0x0001 ) +#define GFF_GIF ( (sal_uInt16)0x0002 ) +#define GFF_JPG ( (sal_uInt16)0x0003 ) +#define GFF_PCD ( (sal_uInt16)0x0004 ) +#define GFF_PCX ( (sal_uInt16)0x0005 ) +#define GFF_PNG ( (sal_uInt16)0x0006 ) +#define GFF_TIF ( (sal_uInt16)0x0007 ) +#define GFF_XBM ( (sal_uInt16)0x0008 ) +#define GFF_XPM ( (sal_uInt16)0x0009 ) +#define GFF_PBM ( (sal_uInt16)0x000a ) +#define GFF_PGM ( (sal_uInt16)0x000b ) +#define GFF_PPM ( (sal_uInt16)0x000c ) +#define GFF_RAS ( (sal_uInt16)0x000d ) +#define GFF_TGA ( (sal_uInt16)0x000e ) +#define GFF_PSD ( (sal_uInt16)0x000f ) +#define GFF_EPS ( (sal_uInt16)0x0010 ) +#define GFF_DXF ( (sal_uInt16)0x00f1 ) +#define GFF_MET ( (sal_uInt16)0x00f2 ) +#define GFF_PCT ( (sal_uInt16)0x00f3 ) +#define GFF_SGF ( (sal_uInt16)0x00f4 ) +#define GFF_SVM ( (sal_uInt16)0x00f5 ) +#define GFF_WMF ( (sal_uInt16)0x00f6 ) +#define GFF_SGV ( (sal_uInt16)0x00f7 ) +#define GFF_EMF ( (sal_uInt16)0x00f8 ) +#define GFF_SVG ( (sal_uInt16)0x00f9 ) +#define GFF_XXX ( (sal_uInt16)0xffff ) + +// --------------------- +// - GraphicDescriptor - +// --------------------- + +class VCL_DLLPUBLIC GraphicDescriptor +{ + SvStream* pFileStm; + + String aPathExt; + Size aPixSize; + Size aLogSize; + sal_uInt16 nBitsPerPixel; + sal_uInt16 nPlanes; + sal_uInt16 nFormat; + sal_Bool bCompressed; + sal_Bool bOwnStream; + + void ImpConstruct(); + + sal_Bool ImpDetectBMP( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectGIF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectJPG( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPCD( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPCX( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPNG( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectTIF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectXBM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectXPM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPBM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPGM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPPM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectRAS( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectTGA( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPSD( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectEPS( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectDXF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectMET( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectPCT( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectSGF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectSVM( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectWMF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectSGV( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectEMF( SvStream& rStm, sal_Bool bExtendedInfo ); + sal_Bool ImpDetectSVG( SvStream& rStm, sal_Bool bExtendedInfo ); + GraphicDescriptor( const GraphicDescriptor& ); + GraphicDescriptor& operator=( const GraphicDescriptor& ); + +public: + + /** Ctor to set a filename + + ::Detect() must be called to identify the file + If the file has no unique header (Mtf's), the format + is determined from the extension */ + GraphicDescriptor( const INetURLObject& rPath ); + + /** Ctor using a stream + + ::Detect() must be called to identify the file + As some formats (Mtf's) do not have a unique header, it makes sense + to supply the file name (incl. ext.), so that the format can be + derived from the extension */ + GraphicDescriptor( SvStream& rInStream, const String* pPath = NULL ); + + virtual ~GraphicDescriptor(); + + /** starts the detection + + if bExtendedInfo == sal_True the file header is used to derive + as many properties as possible (size, color, etc.) */ + virtual sal_Bool Detect( sal_Bool bExtendedInfo = sal_False ); + + /** @return the file format, GFF_NOT if no format was recognized */ + sal_uInt16 GetFileFormat() const { return nFormat; } + + /** @return graphic size in pixels or 0 size */ + const Size& GetSizePixel() const { return (Size&) aPixSize; } + + /** @return the logical graphic size in 1/100mm or 0 size */ + const Size& GetSize_100TH_MM() const { return (Size&) aLogSize; } + + /** @return bits/pixel or 0 **/ + sal_uInt16 GetBitsPerPixel() const { return nBitsPerPixel; } + + /** return number of planes or 0 */ + sal_uInt16 GetPlanes() const { return nPlanes; } + + /** @return true if the graphic is compressed */ + sal_Bool IsCompressed() const { return bCompressed; } + + /** @return filter number that is needed by the GraphFilter to read this format */ + static String GetImportFormatShortName( sal_uInt16 nFormat ); +}; + +/** Information about errors during the GraphicFilter operation. */ +struct FilterErrorEx +{ + sal_uLong nFilterError; + sal_uLong nStreamError; + + FilterErrorEx() : nFilterError( 0UL ), nStreamError( 0UL ) {} +}; + +/** Class to import and export graphic formats. */ +class VCL_DLLPUBLIC GraphicFilter +{ + friend class SvFilterOptionsDialog; + +private: + + void ImplInit(); + sal_uLong ImplSetError( sal_uLong nError, const SvStream* pStm = NULL ); + sal_uInt16 ImpTestOrFindFormat( const String& rPath, SvStream& rStream, sal_uInt16& rFormat ); + + DECL_LINK( FilterCallback, ConvertData* pData ); + +protected: + + OUString aFilterPath; + FilterConfigCache* pConfig; + FilterErrorEx* pErrorEx; + sal_Bool bAbort; + sal_Bool bUseConfig; + long nExpGraphHint; + +public: + + GraphicFilter( sal_Bool bUseConfig = sal_True ); + ~GraphicFilter(); + + void SetFilterPath( const OUString& rFilterPath ) { aFilterPath = rFilterPath; }; + + sal_uInt16 GetImportFormatCount(); + sal_uInt16 GetImportFormatNumber( const String& rFormatName ); + sal_uInt16 GetImportFormatNumberForMediaType( const String& rMediaType ); + sal_uInt16 GetImportFormatNumberForShortName( const String& rShortName ); + sal_uInt16 GetImportFormatNumberForTypeName( const String& rType ); + String GetImportFormatName( sal_uInt16 nFormat ); + String GetImportFormatTypeName( sal_uInt16 nFormat ); + String GetImportFormatMediaType( sal_uInt16 nFormat ); + String GetImportFormatShortName( sal_uInt16 nFormat ); + String GetImportOSFileType( sal_uInt16 nFormat ); + String GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry = 0 ); + sal_Bool IsImportPixelFormat( sal_uInt16 nFormat ); + + sal_uInt16 GetExportFormatCount(); + sal_uInt16 GetExportFormatNumber( const String& rFormatName ); + sal_uInt16 GetExportFormatNumberForMediaType( const String& rShortName ); + sal_uInt16 GetExportFormatNumberForShortName( const String& rShortName ); + String GetExportInternalFilterName( sal_uInt16 nFormat ); + sal_uInt16 GetExportFormatNumberForTypeName( const String& rType ); + String GetExportFormatName( sal_uInt16 nFormat ); + String GetExportFormatTypeName( sal_uInt16 nFormat ); + String GetExportFormatMediaType( sal_uInt16 nFormat ); + String GetExportFormatShortName( sal_uInt16 nFormat ); + String GetExportOSFileType( sal_uInt16 nFormat ); + String GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry = 0 ); + sal_Bool IsExportPixelFormat( sal_uInt16 nFormat ); + + sal_uInt16 ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL ); + sal_uInt16 ExportGraphic( const Graphic& rGraphic, const String& rPath, + SvStream& rOStm, sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL ); + long GetExportGraphicHint() const { return nExpGraphHint; } + + sal_uInt16 CanImportGraphic( const INetURLObject& rPath, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = NULL); + + sal_uInt16 ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0 ); + + sal_uInt16 CanImportGraphic( const String& rPath, SvStream& rStream, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = NULL); + + sal_uInt16 ImportGraphic( Graphic& rGraphic, const String& rPath, + SvStream& rStream, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0, + WMF_EXTERNALHEADER *pExtHeader = NULL ); + + sal_uInt16 ImportGraphic( Graphic& rGraphic, const String& rPath, + SvStream& rStream, + sal_uInt16 nFormat, + sal_uInt16 * pDeterminedFormat, sal_uInt32 nImportFlags, + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData, + WMF_EXTERNALHEADER *pExtHeader = NULL ); + + void Abort() { bAbort = sal_True; } + + const FilterErrorEx& GetLastError() const; + void ResetLastError(); + + const Link GetFilterCallback() const; + static GraphicFilter& GetGraphicFilter(); + static int LoadGraphic( const String& rPath, const String& rFilter, + Graphic& rGraphic, + GraphicFilter* pFilter = NULL, + sal_uInt16* pDeterminedFormat = NULL ); +}; + +#endif //_FILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graphictools.hxx b/include/vcl/graphictools.hxx new file mode 100644 index 000000000000..3600f1a364fc --- /dev/null +++ b/include/vcl/graphictools.hxx @@ -0,0 +1,348 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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> + +#include <memory> +#include <vector> + +/** 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; + + // mutators + /// Set path to stroke + void setPath ( const Polygon& ); + /// Affine scaling in both X and Y dimensions + void scale ( double fScaleX, double fScaleY ); + +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, + sal_Int32 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 gradient used + GradientType getGradientType () 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; + + // mutators + /// Set path to fill + void setPath ( const PolyPolygon& rPath ); + +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; + sal_Int32 maGradientStepCount; + Graphic maFillGraphic; +}; + +#endif /* _VCL_GRAPHICTOOLS_HXX_ */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/group.hxx b/include/vcl/group.hxx new file mode 100644 index 000000000000..647aabe66570 --- /dev/null +++ b/include/vcl/group.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_GROUP_HXX +#define _SV_GROUP_HXX + +#include <tools/solar.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/include/vcl/hatch.hxx b/include/vcl/hatch.hxx new file mode 100644 index 000000000000..8112fe5d4718 --- /dev/null +++ b/include/vcl/hatch.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 ); } + + 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/include/vcl/help.hxx b/include/vcl/help.hxx new file mode 100644 index 000000000000..b74d8023f75c --- /dev/null +++ b/include/vcl/help.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_HELP_HXX +#define _SV_HELP_HXX + +#include <rtl/ustring.hxx> +#include <tools/solar.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 +{ +public: + Help(); + virtual ~Help(); + + virtual sal_Bool Start( const OUString& rHelpId, const Window* pWindow ); + virtual sal_Bool SearchKeyword( const OUString& rKeyWord ); + virtual void OpenHelpAgent( const OString& rHelpId ); + virtual OUString GetHelpText( const OUString& aHelpURL, const Window* pWindow ); + + static void EnableContextHelp(); + static void DisableContextHelp(); + static sal_Bool IsContextHelpEnabled(); + + static void EnableExtHelp(); + static void DisableExtHelp(); + static sal_Bool IsExtHelpEnabled(); + static sal_Bool StartExtHelp(); + static sal_Bool EndExtHelp(); + + static void EnableBalloonHelp(); + static void DisableBalloonHelp(); + static sal_Bool IsBalloonHelpEnabled(); + static sal_Bool ShowBalloon( Window* pParent, + const Point& rScreenPos, + const OUString& rHelpText ); + static sal_Bool ShowBalloon( Window* pParent, + const Point& rScreenPos, + const Rectangle&, + const OUString& rHelpText ); + + static void EnableQuickHelp(); + static void DisableQuickHelp(); + static sal_Bool IsQuickHelpEnabled(); + static sal_Bool ShowQuickHelp( Window* pParent, + const Rectangle& rScreenRect, + const OUString& rHelpText, + const OUString& rLongHelpText, + sal_uInt16 nStyle = 0 ); + static sal_Bool ShowQuickHelp( Window* pParent, + const Rectangle& rScreenRect, + const OUString& rHelpText, + sal_uInt16 nStyle = 0 ) + { return Help::ShowQuickHelp( pParent, rScreenRect, rHelpText, OUString(), nStyle ); } + + static void HideBalloonAndQuickHelp(); + + static sal_uLong ShowTip( Window* pParent, + const Rectangle& rScreenRect, + const OUString& rText, sal_uInt16 nStyle = 0 ); + static void UpdateTip( sal_uLong nId, + Window* pParent, + const Rectangle& rScreenRect, + const OUString& rText ); + static void HideTip( sal_uLong nId ); +}; + +#endif // _SV_HELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/helper.hxx b/include/vcl/helper.hxx new file mode 100644 index 000000000000..295df4a1a5e7 --- /dev/null +++ b/include/vcl/helper.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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< OUString >& rPathList, const char* pSubDir ); + +// note: gcc 3.4.1 warns about visibility if we retunr a const OUString& here +// seems to be a bug in gcc, now we return an object instead of a reference +OUString VCL_DLLPUBLIC getFontPath(); + +bool VCL_DLLPUBLIC convertPfbToPfa( osl::File& rInFile, osl::File& rOutFile ); + +// normalized path (equivalent to realpath) +void VCL_DLLPUBLIC normPath( OString& rPath ); + +// splits rOrgPath into dirname and basename +// rOrgPath will be subject to normPath +void VCL_DLLPUBLIC splitPath( OString& rOrgPath, OString& rDir, OString& rBase ); + +enum whichOfficePath { InstallationRootPath, UserPath, ConfigPath }; +// note: gcc 3.4.1 warns about visibility if we retunr a const OUString& here +// seems to be a bug in gcc, now we return an object instead of a reference +OUString VCL_DLLPUBLIC getOfficePath( enum whichOfficePath ePath ); +} // namespace + +#endif // _PSPRINT_HELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/i18nhelp.hxx b/include/vcl/i18nhelp.hxx new file mode 100644 index 000000000000..8ece881a9b03 --- /dev/null +++ b/include/vcl/i18nhelp.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_I18NHELP_HXX +#define _VCL_I18NHELP_HXX + +#include <com/sun/star/uno/Reference.h> +#include <osl/mutex.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <tools/string.hxx> +#include <vcl/dllapi.h> + +namespace com { +namespace sun { +namespace star { +namespace uno { + class XComponentContext; +} +}}} + +namespace utl { + class TransliterationWrapper; +} + +class LocaleDataWrapper; + +class Date; + +namespace vcl +{ + +class VCL_DLLPUBLIC I18nHelper +{ +private: + ::osl::Mutex maMutex; + LanguageTag maLanguageTag; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + + 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( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const LanguageTag& rLanguageTag ); + ~I18nHelper(); + + sal_Int32 CompareString( const OUString& rStr1, const OUString& rStr2 ) const; + + sal_Bool MatchString( const OUString& rStr1, const OUString& rStr2 ) const; + sal_Bool MatchMnemonic( const String& rString, sal_Unicode cMnemonicChar ) 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/include/vcl/image.hxx b/include/vcl/image.hxx new file mode 100644 index 000000000000..0d28bc030abd --- /dev/null +++ b/include/vcl/image.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_IMAGE_HXX +#define _SV_IMAGE_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/resid.hxx> +#include <tools/solar.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;} } } } + +#define IMAGE_STDBTN_COLOR Color( 0xC0, 0xC0, 0xC0 ) +#define IMAGELIST_IMAGE_NOTFOUND ((sal_uInt16)0xFFFF) + +enum ImageColorTransform +{ + IMAGECOLORTRANSFORM_NONE = 0, + IMAGECOLORTRANSFORM_HIGHCONTRAST = 1, + IMAGECOLORTRANSFORM_MONOCHROME_BLACK = 2, + IMAGECOLORTRANSFORM_MONOCHROME_WHITE = 3 +}; + +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; + + 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 ); +}; + +class VCL_DLLPUBLIC ImageList +{ +public: + ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 ); + ImageList( const ResId& rResId ); + ImageList( const ::std::vector< OUString >& rNameVector, + const OUString& rPrefix, + const Color* pMaskColor = NULL ); + ImageList( const ImageList& rImageList ); + ~ImageList(); + + void InsertFromHorizontalStrip( const BitmapEx &rBitmapEx, + const std::vector< 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( const OUString& rImageName, const Image& rImage ); + void AddImage( sal_uInt16 nNewId, const Image& rImage ); + + void ReplaceImage( const OUString& rImageName, const Image& rImage ); + + void RemoveImage( sal_uInt16 nId ); + + Image GetImage( sal_uInt16 nId ) const; + Image GetImage( const OUString& rImageName ) const; + + sal_uInt16 GetImagePos( sal_uInt16 nId ) const; + bool HasImageAtPos( sal_uInt16 nId ) const; + sal_uInt16 GetImagePos( const OUString& rImageName ) const; + + sal_uInt16 GetImageId( sal_uInt16 nPos ) const; + + OUString GetImageName( sal_uInt16 nPos ) const; + void GetImageNames( ::std::vector< 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 OUString& rUserImageName, + const ::std::vector< OUString >& rImageNames, + const OUString& rSymbolsStyle, + BitmapEx& rBmpEx, + const Color* pMaskColor ) const; + SAL_DLLPRIVATE void ImplInit( sal_uInt16 nItems, const Size &rSize ); + SAL_DLLPRIVATE sal_uInt16 ImplGetImageId( const OUString& rImageName ) const; +}; + +#endif // _SV_IMAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imagerepository.hxx b/include/vcl/imagerepository.hxx new file mode 100644 index 000000000000..45ee445edcd6 --- /dev/null +++ b/include/vcl/imagerepository.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 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/include/vcl/imgctrl.hxx b/include/vcl/imgctrl.hxx new file mode 100644 index 000000000000..d0da64cbe6fa --- /dev/null +++ b/include/vcl/imgctrl.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; +}; + +#endif // _SV_IMGCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/impdel.hxx b/include/vcl/impdel.hxx new file mode 100644 index 000000000000..df6e2713196e --- /dev/null +++ b/include/vcl/impdel.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + + #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/include/vcl/inputctx.hxx b/include/vcl/inputctx.hxx new file mode 100644 index 000000000000..7072f88ab404 --- /dev/null +++ b/include/vcl/inputctx.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_INPUTCTX_HXX +#define _VCL_INPUTCTX_HXX + +#include <tools/solar.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/include/vcl/introwin.hxx b/include/vcl/introwin.hxx new file mode 100644 index 000000000000..d78648cd7ef5 --- /dev/null +++ b/include/vcl/introwin.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_INTROWIN_HXX +#define _SV_INTROWIN_HXX + +#include <tools/solar.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(); +}; + +#endif // _SV_INTROWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/jobdata.hxx b/include/vcl/jobdata.hxx new file mode 100644 index 000000000000..f6fb94fccab2 --- /dev/null +++ b/include/vcl/jobdata.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _PSPRINT_JOBDATA_HXX_ +#define _PSPRINT_JOBDATA_HXX_ + +#include "vcl/ppdparser.hxx" + +namespace psp { + +namespace orientation { +enum type { + Portrait, + Landscape +}; +} + +struct VCL_DLLPUBLIC 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 languagelevel to use + int m_nColorDevice; // 0: no override, -1 grey scale, +1 color + int m_nPDFDevice; // 0: no override, -1 PostScript, +1: Automatically PDF, +2: Explicitly PDF + orientation::type m_eOrientation; + 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 + void resolveDefaultBackend(); + void setDefaultBackend(bool bUsePDF); + + // 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/include/vcl/jobset.hxx b/include/vcl/jobset.hxx new file mode 100644 index 000000000000..15f418cbda3a --- /dev/null +++ b/include/vcl/jobset.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_JOBSET_HXX +#define _SV_JOBSET_HXX + +#include <tools/solar.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(); + + OUString GetPrinterName() const; + OUString 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) + */ + void SetValue( const OUString& rKey, const OUString& 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/include/vcl/keycod.hxx b/include/vcl/keycod.hxx new file mode 100644 index 000000000000..70df7583bcca --- /dev/null +++ b/include/vcl/keycod.hxx @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_KEYCODE_HXX +#define _SV_KEYCODE_HXX + +#include <tools/string.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <tools/resid.hxx> +#include <vcl/keycodes.hxx> + +#include <vcl/vclenum.hxx> + +class Window; + +// ----------- +// - 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; } + 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; + + 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 (GetFullCode() == rKeyCode.GetFullCode()); + 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/include/vcl/keycodes.hxx b/include/vcl/keycodes.hxx new file mode 100644 index 000000000000..cfa23649e194 --- /dev/null +++ b/include/vcl/keycodes.hxx @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_KEYCODES_HXX +#define _SV_KEYCODES_HXX + +#include <tools/solar.h> +#include <rsc/rsc-vcl-shared-types.hxx> +#undef DELETE +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> + +// 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) + +// 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/include/vcl/layout.hxx b/include/vcl/layout.hxx new file mode 100644 index 000000000000..c6b6a1274fa7 --- /dev/null +++ b/include/vcl/layout.hxx @@ -0,0 +1,702 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _VCLLAYOUT_HXX +#define _VCLLAYOUT_HXX + +#include <vcl/dllapi.h> +#include <vcl/button.hxx> +#include <vcl/scrbar.hxx> +#include <vcl/window.hxx> +#include <boost/multi_array.hpp> +#include <set> + +class VCL_DLLPUBLIC VclContainer : public Window +{ +public: + VclContainer(Window *pParent, WinBits nStyle = WB_HIDE); + + //These take into account the external margins of the rWindow widget + //while GetOptimalSize/get_preferred_size and SetPosSizePixel are + //oblivious to them + static Size getLayoutRequisition(const Window &rWindow); + static void setLayoutPosSize(Window &rWindow, const Point &rPos, const Size &rSize); + + //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account + //the rWindows alignment desires within that allocation + static void setLayoutAllocation(Window &rWindow, const Point &rPos, const Size &rSize); + + void markLayoutDirty() + { + m_bLayoutDirty = true; + } +protected: + //these are the two that need to be implemented by + //containers, figure out how much space you want... + virtual Size calculateRequisition() const = 0; + //..and decide what to do when set to this size + virtual void setAllocation(const Size &rAllocation) = 0; + + virtual sal_uInt16 getDefaultAccessibleRole() const; +public: + //you don't want to override these + virtual Size GetOptimalSize() const; + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize); + virtual void SetPosPixel(const Point& rAllocPos); + virtual void SetSizePixel(const Size& rAllocation); +private: + bool m_bLayoutDirty; +}; + +class VCL_DLLPUBLIC VclBox : public VclContainer +{ +protected: + bool m_bHomogeneous; + int m_nSpacing; +public: + VclBox(Window *pParent, bool bHomogeneous, int nSpacing) + : VclContainer(pParent) + , m_bHomogeneous(bHomogeneous) + , m_nSpacing(nSpacing) + { + } + void set_spacing(int nSpacing) + { + m_nSpacing = nSpacing; + } + int get_spacing() const + { + return m_nSpacing; + } + void set_homogeneous(bool bHomogeneous) + { + m_bHomogeneous = bHomogeneous; + } + bool get_homogeneous() const + { + return m_bHomogeneous; + } + virtual bool set_property(const OString &rKey, const OString &rValue); +protected: + virtual sal_uInt16 getDefaultAccessibleRole() const; + void accumulateMaxes(const Size &rChildSize, Size &rSize) const; + Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const; + + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); + + virtual long getPrimaryDimension(const Size &rSize) const = 0; + virtual void setPrimaryDimension(Size &rSize, long) const = 0; + virtual long getPrimaryCoordinate(const Point &rPos) const = 0; + virtual void setPrimaryCoordinate(Point &rPos, long) const = 0; + virtual long getSecondaryDimension(const Size &rSize) const = 0; + virtual void setSecondaryDimension(Size &rSize, long) const = 0; + virtual long getSecondaryCoordinate(const Point &rPos) const = 0; + virtual void setSecondaryCoordinate(Point &rPos, long) const = 0; + + virtual bool getPrimaryDimensionChildExpand(const Window &rWindow) const = 0; +}; + +class VCL_DLLPUBLIC VclVBox : public VclBox +{ +public: + VclVBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) + { + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const + { + return rSize.getHeight(); + } + virtual void setPrimaryDimension(Size &rSize, long nHeight) const + { + rSize.setHeight(nHeight); + } + virtual long getPrimaryCoordinate(const Point &rPos) const + { + return rPos.getY(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const + { + rPos.setY(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const + { + return rSize.getWidth(); + } + virtual void setSecondaryDimension(Size &rSize, long nWidth) const + { + rSize.setWidth(nWidth); + } + virtual long getSecondaryCoordinate(const Point &rPos) const + { + return rPos.getX(); + } + virtual void setSecondaryCoordinate(Point &rPos, long nPos) const + { + rPos.setX(nPos); + } + virtual bool getPrimaryDimensionChildExpand(const Window &rWindow) const + { + return rWindow.get_expand() || rWindow.get_vexpand(); + } +}; + +class VCL_DLLPUBLIC VclHBox : public VclBox +{ +public: + VclHBox(Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) + { + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const + { + return rSize.getWidth(); + } + virtual void setPrimaryDimension(Size &rSize, long nWidth) const + { + rSize.setWidth(nWidth); + } + virtual long getPrimaryCoordinate(const Point &rPos) const + { + return rPos.getX(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const + { + rPos.setX(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const + { + return rSize.getHeight(); + } + virtual void setSecondaryDimension(Size &rSize, long nHeight) const + { + rSize.setHeight(nHeight); + } + virtual long getSecondaryCoordinate(const Point &rPos) const + { + return rPos.getY(); + } + virtual void setSecondaryCoordinate(Point &rPos, long nPos) const + { + rPos.setY(nPos); + } + virtual bool getPrimaryDimensionChildExpand(const Window &rWindow) const + { + return rWindow.get_expand() || rWindow.get_hexpand(); + } +}; + +enum VclButtonBoxStyle +{ + VCL_BUTTONBOX_DEFAULT_STYLE, + VCL_BUTTONBOX_SPREAD, + VCL_BUTTONBOX_EDGE, + VCL_BUTTONBOX_START, + VCL_BUTTONBOX_END, + VCL_BUTTONBOX_CENTER +}; + +class VCL_DLLPUBLIC VclButtonBox : public VclBox +{ +public: + VclButtonBox(Window *pParent, int nSpacing) + : VclBox(pParent, false, nSpacing) + , m_eLayoutStyle(VCL_BUTTONBOX_DEFAULT_STYLE) + { + } + void set_layout(VclButtonBoxStyle eStyle) + { + m_eLayoutStyle = eStyle; + } + VclButtonBoxStyle get_layout() const + { + return m_eLayoutStyle; + } + virtual bool set_property(const OString &rKey, const OString &rValue); +protected: + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); + Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const; +private: + VclButtonBoxStyle m_eLayoutStyle; + struct Requisition + { + std::vector<long> m_aMainGroupDimensions; + std::vector<long> m_aSubGroupDimensions; + Size m_aMainGroupSize; + Size m_aSubGroupSize; + }; + Requisition calculatePrimarySecondaryRequisitions() const; + Size addReqGroups(const VclButtonBox::Requisition &rReq) const; +}; + +class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox +{ +public: + VclVButtonBox(Window *pParent, int nSpacing = 0) + : VclButtonBox(pParent, nSpacing) + { + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const + { + return rSize.getHeight(); + } + virtual void setPrimaryDimension(Size &rSize, long nHeight) const + { + rSize.setHeight(nHeight); + } + virtual long getPrimaryCoordinate(const Point &rPos) const + { + return rPos.getY(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const + { + rPos.setY(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const + { + return rSize.getWidth(); + } + virtual void setSecondaryDimension(Size &rSize, long nWidth) const + { + rSize.setWidth(nWidth); + } + virtual long getSecondaryCoordinate(const Point &rPos) const + { + return rPos.getX(); + } + virtual void setSecondaryCoordinate(Point &rPos, long nPos) const + { + rPos.setX(nPos); + } + virtual bool getPrimaryDimensionChildExpand(const Window &rWindow) const + { + return rWindow.get_expand() || rWindow.get_vexpand(); + } +}; + +class VCL_DLLPUBLIC VclHButtonBox : public VclButtonBox +{ +public: + VclHButtonBox(Window *pParent, int nSpacing = 0) + : VclButtonBox(pParent, nSpacing) + { + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const + { + return rSize.getWidth(); + } + virtual void setPrimaryDimension(Size &rSize, long nWidth) const + { + rSize.setWidth(nWidth); + } + virtual long getPrimaryCoordinate(const Point &rPos) const + { + return rPos.getX(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const + { + rPos.setX(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const + { + return rSize.getHeight(); + } + virtual void setSecondaryDimension(Size &rSize, long nHeight) const + { + rSize.setHeight(nHeight); + } + virtual long getSecondaryCoordinate(const Point &rPos) const + { + return rPos.getY(); + } + virtual void setSecondaryCoordinate(Point &rPos, long nPos) const + { + rPos.setY(nPos); + } + virtual bool getPrimaryDimensionChildExpand(const Window &rWindow) const + { + return rWindow.get_expand() || rWindow.get_hexpand(); + } +}; + +class VCL_DLLPUBLIC VclGrid : public VclContainer +{ +private: + bool m_bRowHomogeneous; + bool m_bColumnHomogeneous; + int m_nRowSpacing; + int m_nColumnSpacing; + + struct GridEntry + { + Window *pChild; + sal_Int32 nSpanWidth; + sal_Int32 nSpanHeight; + GridEntry() + : pChild(0) + , nSpanWidth(0) + , nSpanHeight(0) + { + } + }; + + typedef boost::multi_array<GridEntry, 2> array_type; + + struct ExtendedGridEntry : GridEntry + { + int x; + int y; + ExtendedGridEntry() + : x(-1) + , y(-1) + { + } + }; + + typedef boost::multi_array<ExtendedGridEntry, 2> ext_array_type; + + array_type assembleGrid() const; + bool isNullGrid(const array_type& A) const; +public: + struct Value + { + long m_nValue; + bool m_bExpand; + Value() : m_nValue(0), m_bExpand(false) {} + }; +private: + void calcMaxs(const array_type &A, std::vector<Value> &rWidths, std::vector<Value> &rHeights) const; + + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); +public: + VclGrid(Window *pParent) + : VclContainer(pParent) + , m_bRowHomogeneous(false), m_bColumnHomogeneous(false) + , m_nRowSpacing(0), m_nColumnSpacing(0) + { + } + void set_row_homogeneous(bool bHomogeneous) + { + m_bRowHomogeneous = bHomogeneous; + } + void set_column_homogeneous(bool bHomogeneous) + { + m_bColumnHomogeneous = bHomogeneous; + } + bool get_row_homogeneous() const + { + return m_bRowHomogeneous; + } + bool get_column_homogeneous() const + { + return m_bColumnHomogeneous; + } + void set_row_spacing(int nSpacing) + { + m_nRowSpacing = nSpacing; + } + void set_column_spacing(int nSpacing) + { + m_nColumnSpacing = nSpacing; + } + int get_row_spacing() const + { + return m_nRowSpacing; + } + int get_column_spacing() const + { + return m_nColumnSpacing; + } + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +VCL_DLLPUBLIC void setGridAttach(Window &rWidget, sal_Int32 nLeft, sal_Int32 nTop, + sal_Int32 nWidth = 1, sal_Int32 nHeight = 1); + +class VCL_DLLPUBLIC VclBin : public VclContainer +{ +public: + VclBin(Window *pParent, WinBits nStyle = WB_HIDE) + : VclContainer(pParent, nStyle) + { + } + virtual Window *get_child(); + virtual const Window *get_child() const; + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); +}; + +class VCL_DLLPUBLIC VclFrame : public VclBin +{ +private: + Window *m_pLabel; +private: + friend class VclBuilder; + void designate_label(Window *pWindow); +public: + VclFrame(Window *pParent) + : VclBin(pParent) + , m_pLabel(NULL) + { + } + void set_label(const OUString &rLabel); + virtual Window *get_child(); + virtual const Window *get_child() const; + Window *get_label_widget(); + const Window *get_label_widget() const; +protected: + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); + virtual OUString getDefaultAccessibleName() const; +}; + +class VCL_DLLPUBLIC VclAlignment : public VclBin +{ +public: + VclAlignment(Window *pParent) + : VclBin(pParent) + , m_nBottomPadding(0) + , m_nLeftPadding(0) + , m_nRightPadding(0) + , m_nTopPadding(0) + , m_fXAlign(0.0) + , m_fXScale(1.0) + , m_fYAlign(0.0) + , m_fYScale(1.0) + { + } + virtual bool set_property(const OString &rKey, const OString &rValue); +protected: + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); +private: + sal_Int32 m_nBottomPadding; + sal_Int32 m_nLeftPadding; + sal_Int32 m_nRightPadding; + sal_Int32 m_nTopPadding; + float m_fXAlign; + float m_fXScale; + float m_fYAlign; + float m_fYScale; +}; + +class VCL_DLLPUBLIC VclExpander : public VclBin +{ +public: + VclExpander(Window *pParent) + : VclBin(pParent) + , m_bResizeTopLevel(true) + , m_aDisclosureButton(this) + { + m_aDisclosureButton.SetToggleHdl(LINK(this, VclExpander, ClickHdl)); + m_aDisclosureButton.Show(); + } + virtual Window *get_child(); + virtual const Window *get_child() const; + virtual bool set_property(const OString &rKey, const OString &rValue); +protected: + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); +private: + bool m_bResizeTopLevel; + DisclosureButton m_aDisclosureButton; + DECL_DLLPRIVATE_LINK(ClickHdl, DisclosureButton* pBtn); +}; + +//This is a work in progress, so if you want to put something inside a +//scrolled window that doesn't handle its own scrolling, then you may need to +//implement this fully +class VCL_DLLPUBLIC VclScrolledWindow : public VclBin +{ +public: + VclScrolledWindow(Window *pParent, WinBits nStyle = WB_HIDE | WB_AUTOHSCROLL | WB_AUTOVSCROLL) + : VclBin(pParent, nStyle) + , m_aVScroll(this, WB_HIDE | WB_VERT) + , m_aHScroll(this, WB_HIDE | WB_HORZ) + { + SetType(WINDOW_SCROLLWINDOW); + } + virtual Window *get_child(); + virtual const Window *get_child() const; + virtual bool set_property(const OString &rKey, const OString &rValue); + ScrollBar& getVertScrollBar() { return m_aVScroll; } + ScrollBar& getHorzScrollBar() { return m_aHScroll; } + Size getVisibleChildSize() const; +protected: + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); +private: + ScrollBar m_aVScroll; + ScrollBar m_aHScroll; +}; + +//Enforces that its children are always the same size as itself. +//Intercepts any Commands intended for its children. +// +//by default the Commands are discarded, inherit from this +//and implement "Command" to get them +class VCL_DLLPUBLIC VclEventBox : public VclBin +{ +private: + //Any Commands an EventBoxHelper receives are forwarded to its parent + //The VclEventBox ensures that m_aEventBoxHelper is the + //first child and is transparent, but covers the rest of the children + class EventBoxHelper : public Window + { + public: + EventBoxHelper(Window* pParent) + : Window(pParent, 0) + { + SetSizePixel(pParent->GetSizePixel()); + EnableChildTransparentMode(); + SetPaintTransparent(true); + SetBackground(); + } + virtual void Command(const CommandEvent& rCEvt) + { + GetParent()->Command(rCEvt); + } + }; + + EventBoxHelper m_aEventBoxHelper; +public: + VclEventBox(Window* pParent) + : VclBin(pParent) + , m_aEventBoxHelper(this) + { + m_aEventBoxHelper.Show(); + } + virtual Window *get_child(); + virtual const Window *get_child() const; + virtual Size calculateRequisition() const; + virtual void setAllocation(const Size &rAllocation); + + virtual void Command(const CommandEvent& rCEvt); +}; + +enum VclSizeGroupMode +{ + VCL_SIZE_GROUP_NONE, + VCL_SIZE_GROUP_HORIZONTAL, + VCL_SIZE_GROUP_VERTICAL, + VCL_SIZE_GROUP_BOTH +}; + +class VCL_DLLPUBLIC VclSizeGroup +{ +private: + std::set<Window*> m_aWindows; + bool m_bIgnoreHidden; + VclSizeGroupMode m_eMode; + + void trigger_queue_resize(); +public: + VclSizeGroup() + : m_bIgnoreHidden(false) + , m_eMode(VCL_SIZE_GROUP_HORIZONTAL) + { + } + void insert(Window *pWindow) + { + m_aWindows.insert(pWindow); + } + void erase(Window *pWindow) + { + m_aWindows.erase(pWindow); + } + const std::set<Window*>& get_widgets() const + { + return m_aWindows; + } + std::set<Window*>& get_widgets() + { + return m_aWindows; + } + void set_ignore_hidden(bool bIgnoreHidden); + bool get_ignore_hidden() const + { + return m_bIgnoreHidden; + } + void set_mode(VclSizeGroupMode eMode); + VclSizeGroupMode get_mode() const + { + return m_eMode; + } + bool set_property(const OString &rKey, const OString &rValue); +}; + +VCL_DLLPUBLIC Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize); + +//Get first window of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(WINDOW_FIRSTCHILD); +//in a flat hierarchy where dialogs only have one layer +//of children +VCL_DLLPUBLIC Window* firstLogicalChildOfParent(Window *pTopLevel); + +//Get next window after pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(WINDOW_NEXT); +//in a flat hierarchy where dialogs only have one layer +//of children +VCL_DLLPUBLIC Window* nextLogicalChildOfParent(Window *pTopLevel, Window *pChild); + +//Get previous window before pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(WINDOW_PREV); +//in a flat hierarchy where dialogs only have one layer +//of children +VCL_DLLPUBLIC Window* prevLogicalChildOfParent(Window *pTopLevel, Window *pChild); + +//Returns true is the Window has a single child which is a container +VCL_DLLPUBLIC bool isLayoutEnabled(const Window *pWindow); + +VCL_DLLPUBLIC inline bool isContainerWindow(const Window &rWindow) +{ + WindowType eType = rWindow.GetType(); + return (eType == WINDOW_CONTAINER || eType == WINDOW_SCROLLWINDOW); +} + +VCL_DLLPUBLIC inline bool isContainerWindow(const Window *pWindow) +{ + return pWindow && isContainerWindow(*pWindow); +} + +//Returns true if the containing dialog is doing its initial +//layout and isn't visible yet +VCL_DLLPUBLIC bool isInitialLayout(const Window *pWindow); + +// retro-fitting utilities // + +//Get a Size which is large enough to contain all children with +//an equal amount of space at top left and bottom right +Size getLegacyBestSizeForChildren(const Window &rWindow); + +//Get first parent which is not a layout widget +Window* getNonLayoutParent(Window *pParent); + +//Get first real parent which is not a layout widget +Window* getNonLayoutRealParent(Window *pParent); + +//return true if this window and its stack of containers are all shown +bool isVisibleInLayout(const Window *pWindow); + +//return true if this window and its stack of containers are all enabled +bool isEnabledInLayout(const Window *pWindow); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lazydelete.hxx b/include/vcl/lazydelete.hxx new file mode 100644 index 000000000000..ee818eef8df8 --- /dev/null +++ b/include/vcl/lazydelete.hxx @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 transferred ! + T* set( T* i_pNew ) { T* pOld = m_pT; m_pT = i_pNew; return pOld; } + + // set contents, deleting old contents + // ownership is transferred ! + void reset( T* i_pNew = NULL ) + { OSL_ASSERT( i_pNew != m_pT || i_pNew == NULL ); T* pOld = m_pT; m_pT = i_pNew; delete 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/include/vcl/lineinfo.hxx b/include/vcl/lineinfo.hxx new file mode 100644 index 000000000000..d5165a63e016 --- /dev/null +++ b/include/vcl/lineinfo.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_LINEINFO_HXX +#define _SV_LINEINFO_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <com/sun/star/drawing/LineCap.hpp> + +// ---------------- +// - 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; + com::sun::star::drawing::LineCap meLineCap; + + 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; + + 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; } + + void SetLineCap(com::sun::star::drawing::LineCap eLineCap); + com::sun::star::drawing::LineCap GetLineCap() const { return mpImplLineInfo->meLineCap; } + + sal_Bool IsDefault() const; + + friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, LineInfo& rLineInfo ); + friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo ); + + // 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/include/vcl/longcurr.hxx b/include/vcl/longcurr.hxx new file mode 100644 index 000000000000..b0d57c392ab7 --- /dev/null +++ b/include/vcl/longcurr.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + OUString maCurrencySymbol; + sal_uInt16 mnType; + sal_uInt16 mnDecimalDigits; + sal_Bool mbThousandSep; + + LongCurrencyFormatter(); +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 IsEmptyValue() const { return GetField()->GetText().isEmpty(); } + + BigInt GetCorrectedValue() const { return mnCorrectedValue; } +}; + +// --------------------- +// - LongCurrencyField - +// --------------------- + +class VCL_DLLPUBLIC LongCurrencyField : public SpinField, public LongCurrencyFormatter +{ + friend void ImplNewLongCurrencyFieldValue( LongCurrencyField*, BigInt ); + +private: + BigInt mnSpinSize; + BigInt mnFirst; + BigInt mnLast; + +public: + LongCurrencyField( Window* pParent, WinBits nWinStyle ); + ~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(); + + long PreNotify( NotifyEvent& rNEvt ); + long Notify( NotifyEvent& rNEvt ); + + void Modify(); + void ReformatAll(); + + BigInt GetValue() const + { return LongCurrencyFormatter::GetValue(); } +}; + +#endif // _LONGCURR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lstbox.h b/include/vcl/lstbox.h new file mode 100644 index 000000000000..1d9dd30c809b --- /dev/null +++ b/include/vcl/lstbox.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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) + +// -------------------------------------------------------------------- + +// 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 completely. 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/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx new file mode 100644 index 000000000000..79026116c473 --- /dev/null +++ b/include/vcl/lstbox.hxx @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + sal_Int32 m_nMaxWidthChars; + 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 ); + + 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 ); + sal_uInt16 GetTopEntry() const; + + void SaveValue() { mnSaveValue = GetSelectEntryPos(); } + sal_uInt16 GetSavedValue() const { return mnSaveValue; } + + void SetSeparatorPos( sal_uInt16 n = LISTBOX_ENTRY_NOTFOUND ); + 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; + + Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const; + + void SetUserItemSize( const Size& rSz ); + + void EnableUserDraw( sal_Bool bUserDraw ); + + 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 CalcSubEditSize() const; //size of area inside lstbox, i.e. no scrollbar/dropdown + Size CalcMinimumSize() const; //size of lstbox area, i.e. including scrollbar/dropdown + virtual Size GetOptimalSize() 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; + + 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; + + sal_Int32 getMaxWidthChars() const { return m_nMaxWidthChars; } + void setMaxWidthChars(sal_Int32 nWidth); + + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +// ---------------- +// - 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/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx new file mode 100644 index 000000000000..e6f30cf5089e --- /dev/null +++ b/include/vcl/mapmod.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_MAPMOD_HXX +#define _SV_MAPMOD_HXX + +#include <tools/gen.hxx> +#include <tools/fract.hxx> +#include <tools/solar.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/include/vcl/menu.hxx b/include/vcl/menu.hxx new file mode 100644 index 000000000000..c9bc3b538711 --- /dev/null +++ b/include/vcl/menu.hxx @@ -0,0 +1,494 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_MENU_HXX +#define _SV_MENU_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <tools/rc.hxx> +#include <tools/resid.hxx> +#include <rsc/rsc-vcl-shared-types.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 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) + +#define MENU_FLAG_NOAUTOMNEMONICS 0x0001 +#define MENU_FLAG_HIDEDISABLEDENTRIES 0x0002 + +// overrides default hiding of disabled entries in popup menus +#define MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES 0x0004 + +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 MenuButton; + 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; + + OUString aTitleText; // PopupMenu text + + sal_uLong nEventId; + sal_uInt16 mnHighlightedItemPos; // for native menus: keeps track of the highlighted item + sal_uInt16 nMenuFlags; + sal_uInt16 nDefaultItem; // Id of default item + sal_uInt16 nSelectedId; + + // for output: + sal_uInt16 nImgOrChkPos; + sal_uInt16 nTextPos; + + sal_Bool bIsMenuBar : 1, // Is this a menubar? + bCanceled : 1, // Terminated during a callback + bInCallback : 1, // In Activate/Deactivate + bKilled : 1; // Killed... + + ::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, void* ); + + 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 in rCheckHeight and rRadioHeight + // return value is maximum width and height of checkboxes and radiobuttons + SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize( Window*, long& rCheckHeight, long& rRadioHeight ) const; + + // returns native submenu arrow size and spacing from right border + // return value is whether it's supported natively + SAL_DLLPRIVATE sal_Bool ImplGetNativeSubmenuArrowSize( Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const; + + SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); + SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); +public: + SAL_DLLPRIVATE void ImplKillLayoutData() const; + SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const { return pStartedFrom; } + + Menu(); + Menu( sal_Bool bMenuBar ); + SAL_DLLPRIVATE Window* ImplGetWindow() const { return pWindow; } + 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, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + MenuItemBits nItemBits = 0, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( sal_uInt16 nItemId, + const XubString& rString, const Image& rImage, + MenuItemBits nItemBits = 0, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND ); + void InsertItem( const ResId& rResId, sal_uInt16 nPos = MENU_APPEND ); + void InsertSeparator( const OString &rIdent = OString(), + 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 GetItemId(const OString &rIdent) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + OString GetItemIdent(sal_uInt16 nItemId) const; + MenuItemType GetItemType( sal_uInt16 nPos ) const; + sal_uInt16 GetCurItemId() const; + OString GetCurItemIdent() 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 ); + void EnableItem(const OString &rIdent, bool bEnable = true) + { + EnableItem(GetItemId(rIdent), bEnable); + } + 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 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 OString& rHelpId ); + 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 menus are supported + // pData must point to a SystemMenuData structure + sal_Bool GetSystemMenuData( SystemMenuData* pData ) const; + + // accessibility helpers + + // 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 bounding rectangle for an item at pos nItemPos + Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) 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; + + // 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 +}; + +// ----------- +// - 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 MenuBar& rMenu ); + ~MenuBar(); + + MenuBar& operator =( const MenuBar& rMenu ); + + void ShowCloser( sal_Bool bShow = sal_True ); + sal_Bool HasCloser() const { return mbCloserVisible; } + sal_Bool HasFloatButton() const { return mbFloatBtnVisible; } + 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 + // 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 OUString& rTitle ) { aTitleText = rTitle; } + const OUString& 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/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx new file mode 100644 index 000000000000..4036ee9059b1 --- /dev/null +++ b/include/vcl/menubtn.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_MENUBTN_HXX +#define _SV_MENUBTN_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/button.hxx> + +class Timer; +class PopupMenu; +class VclBuilder; +class VclSimpleEvent; + +// -------------------- +// - MenuButton-Types - +// -------------------- + +#define MENUBUTTON_MENUMODE_TIMED ((sal_uInt16)0x0001) + +// -------------- +// - MenuButton - +// -------------- + +class VCL_DLLPUBLIC MenuButton : public PushButton +{ +private: + friend class VclBuilder; + + 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, void* ); + + // 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; } + OString GetCurItemIdent() const; + void SetCurItemId( sal_uInt16 nItemId ) { mnCurItemId = nItemId; } + + 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/include/vcl/metaact.hxx b/include/vcl/metaact.hxx new file mode 100644 index 000000000000..961baaecd1ff --- /dev/null +++ b/include/vcl/metaact.hxx @@ -0,0 +1,1319 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + +#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; + + ImplMetaReadData() : + meActualCharSet( RTL_TEXTENCODING_ASCII_US ) + { + } +}; + +struct ImplMetaWriteData +{ + rtl_TextEncoding meActualCharSet; + + ImplMetaWriteData() : + meActualCharSet( RTL_TEXTENCODING_ASCII_US ) + { + } +}; + +#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() {} + +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_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 ); +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +class VCL_DLLPUBLIC MetaTextAction : public MetaAction +{ +private: + + Point maPt; + OUString 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 OUString& 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 OUString& GetText() const { return maStr; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } +}; + +class VCL_DLLPUBLIC MetaTextArrayAction : public MetaAction +{ +private: + + Point maStartPt; + OUString 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 OUString& 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 OUString& GetText() const { return maStr; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } + sal_Int32* GetDXArray() const { return mpDXAry; } +}; + +class VCL_DLLPUBLIC MetaStretchTextAction : public MetaAction +{ +private: + + Point maPt; + OUString 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 OUString& 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 OUString& GetText() const { return maStr; } + sal_uInt32 GetWidth() const { return mnWidth; } + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16 GetLen() const { return mnLen; } +}; + +class VCL_DLLPUBLIC MetaTextRectAction : public MetaAction +{ +private: + + Rectangle maRect; + OUString maStr; + sal_uInt16 mnStyle; + + virtual sal_Bool Compare( const MetaAction& ) const; + +public: + DECL_META_ACTION( TextRect, META_TEXTRECT_ACTION ) + + MetaTextRectAction( const Rectangle& rRect, + const OUString& 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 OUString& GetText() const { return maStr; } + sal_uInt16 GetStyle() const { return mnStyle; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +class VCL_DLLPUBLIC MetaPopAction : public MetaAction +{ +public: + + DECL_META_ACTION( Pop, META_POP_ACTION ) +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +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; } +}; + +class VCL_DLLPUBLIC MetaCommentAction : public MetaAction +{ +private: + + OString 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 OString& rComment, sal_Int32 nValue = 0L, const sal_uInt8* pData = NULL, sal_uInt32 nDataSize = 0UL ); + + 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 OString& GetComment() const { return maComment; } + sal_Int32 GetValue() const { return mnValue; } + sal_uInt32 GetDataSize() const { return mnDataSize; } + const sal_uInt8* GetData() const { return mpData; } +}; + +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; } +}; + +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/include/vcl/metric.hxx b/include/vcl/metric.hxx new file mode 100644 index 000000000000..27108d756d2f --- /dev/null +++ b/include/vcl/metric.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + 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 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/include/vcl/mnemonic.hxx b/include/vcl/mnemonic.hxx new file mode 100644 index 000000000000..4ec22b5522a2 --- /dev/null +++ b/include/vcl/mnemonic.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/mnemonicengine.hxx b/include/vcl/mnemonicengine.hxx new file mode 100644 index 000000000000..e1def2d8d98e --- /dev/null +++ b/include/vcl/mnemonicengine.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + protected: + ~IMnemonicEntryList() {} + }; + + //==================================================================== + //= 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/include/vcl/morebtn.hxx b/include/vcl/morebtn.hxx new file mode 100644 index 000000000000..a715f37357d7 --- /dev/null +++ b/include/vcl/morebtn.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_MOREBTN_HXX +#define _SV_MOREBTN_HXX + +#include <tools/solar.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 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 OUString& rNewText ); + OUString GetText() const; + + void SetMoreText( const OUString& rNewText ); + void SetLessText( const OUString& rNewText ); + OUString GetMoreText() const; + OUString 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/include/vcl/msgbox.hxx b/include/vcl/msgbox.hxx new file mode 100644 index 000000000000..594d248a6acd --- /dev/null +++ b/include/vcl/msgbox.hxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_MSGBOX_HXX +#define _SV_MSGBOX_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/btndlg.hxx> +#include <vcl/image.hxx> +#include <vcl/bitmap.hxx> +class VclMultiLineEdit; +class FixedImage; +class CheckBox; + +// ----------------- +// - MessBox-Types - +// ----------------- + +// Return-Werte von Execute +//!!! bei Aenderungen \basic\source\runtime\methods.cxx msgbox anpassen + +#define RET_CANCEL 0 +#define RET_OK 1 +#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: + VclMultiLineEdit* mpVCLMultiLineEdit; + FixedImage* mpFixedImage; + XubString maMessText; + Image maImage; + sal_Bool mbHelpBtn; + 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 ); + +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; } + + 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() const; +}; + +// ----------- +// - InfoBox - +// ----------- + +class VCL_DLLPUBLIC InfoBox : public MessBox +{ +private: + SAL_DLLPRIVATE void ImplInitInfoBoxData(); + +public: + InfoBox( Window* pParent, const OUString& 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/include/vcl/octree.hxx b/include/vcl/octree.hxx new file mode 100644 index 000000000000..7d1054db8156 --- /dev/null +++ b/include/vcl/octree.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_OCTREE_HXX +#define _SV_OCTREE_HXX + +#include <vcl/salbtype.hxx> +#include <vcl/dllapi.h> + +#define OCTREE_BITS 5 +#define OCTREE_BITS_1 10 + +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; + +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(); + + 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; +} + +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/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx new file mode 100644 index 000000000000..adbf49c2dcad --- /dev/null +++ b/include/vcl/oldprintadaptor.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/outdev.hxx b/include/vcl/outdev.hxx new file mode 100644 index 000000000000..b0bb8e5c9389 --- /dev/null +++ b/include/vcl/outdev.hxx @@ -0,0 +1,1170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_OUTDEV_HXX +#define _SV_OUTDEV_HXX + +#include <tools/gen.hxx> +#include <tools/string.hxx> +#include <tools/solar.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 <basegfx/polygon/b2dpolypolygon.hxx> +#include <com/sun/star/drawing/LineCap.hpp> +#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 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; +} + +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; +} + +// --------------------- +// - 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; // "" +}; + +// ---------------------- +// - 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) + +// 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 FontSelectPattern; +class ImplFontMetricData; +class VCLXGraphics; + +typedef ::std::vector< VCLXGraphics* > VCLXGraphicsList_impl; + +const char* ImplDbgCheckOutputDevice( const void* pObj ); + +class VCL_DLLPUBLIC OutputDevice : public Resource +{ + friend class Application; + friend class Bitmap; + friend class ImplImageBmp; + friend class Printer; + 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; + VCLXGraphicsList_impl* 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 SalGraphics* 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 OUString&, sal_Int32 nIndex, sal_Int32 nLen, + const Point& rLogicPos = Point(0,0), long nLogicWidth=0, + const sal_Int32* pLogicDXArray=NULL, bool bFilter = false ) const; + SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen, + long nPixelWidth, const sal_Int32* pPixelDXArray ) const; + SAL_DLLPRIVATE SalLayout* ImplGlyphFallbackLayout( SalLayout*, ImplLayoutArgs& ) const; + + static + SAL_DLLPRIVATE OUString ImplGetEllipsisString( const OutputDevice& rTargetDevice, const OUString& 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, OUString* 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 OUString& 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 ImplFloatLogicHeightToDevicePixel( 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 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 sal_Bool ImplIsRecordLayout() const; + + void ImplAddDevFontSubstitute( const OUString& rFontName, + const OUString& 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 ; + SAL_DLLPRIVATE Color ImplDrawModeToColor( const Color& rColor ) 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 = 0.0, + basegfx::B2DLineJoin eLineJoin = basegfx::B2DLINEJOIN_NONE, + com::sun::star::drawing::LineCap eLineCap = com::sun::star::drawing::LineCap_BUTT); + + // 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 SalLayout* getFallbackFontThatFits(ImplFontEntry &rFallbackFont, + FontSelectPattern &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 ); + + void DrawText( const Point& rStartPt, const XubString& rStr, + xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, + MetricVector* pVector = NULL, OUString* pDisplayText = NULL ); + long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const; + /// Height where any character of the current font fits; in logic coordinates. + long GetTextHeight() const; + float approximate_char_width() 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 OUString& rStr, sal_Int32* pDXAry = NULL, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const; + bool GetCaretPositions( const OUString&, sal_Int32* pCaretXArray, + sal_Int32 nIndex, sal_Int32 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 OUString& rStr, long nTextWidth, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + long nCharExtra = 0, sal_Bool bCellBreaking = sal_True ) const; + xub_StrLen GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Unicode nExtraChar, sal_Int32& rExtraCharPos, + sal_Int32 nIndex, sal_Int32 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, OUString* 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; + OUString GetEllipsisString( const OUString& 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, OUString* 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_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, + com::sun::star::drawing::LineCap = com::sun::star::drawing::LineCap_BUTT); + + /** 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 ); + +#ifdef _MSC_VER + 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 ); + + /** 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 ); + + Color GetPixel( const Point& rPt ) 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 whether 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; + PolyPolygon LogicToPixel( const PolyPolygon& 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::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, + 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; + 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; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly, + 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; + 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 ); + + 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; + + // 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 OUString&, sal_Int32 nIndex, sal_Int32 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(); + + /// 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(); + VCLXGraphicsList_impl* GetUnoGraphicsList() const { return mpUnoGraphicsList; } + VCLXGraphicsList_impl* CreateUnoGraphicsList() + { + mpUnoGraphicsList = new VCLXGraphicsList_impl(); + return mpUnoGraphicsList; + } + + static void BeginFontSubstitution(); + static void EndFontSubstitution(); + static void AddFontSubstitute( const OUString& rFontName, + const OUString& rReplaceFontName, + sal_uInt16 nFlags = 0 ); + static void RemoveFontSubstitute( sal_uInt16 n ); + static sal_uInt16 GetFontSubstituteCount(); + + 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 ); + + //------------------------------------- + // 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, + 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, + OUString aCaption, + Rectangle &rNativeBoundingRegion, + Rectangle &rNativeContentRegion ) const; + +}; + +#endif // _SV_OUTDEV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx new file mode 100644 index 000000000000..59a118945cd4 --- /dev/null +++ b/include/vcl/pdfextoutdevdata.hxx @@ -0,0 +1,492 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 +{ + /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link. + */ + sal_Int32 nLinkId; + + /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination. + */ + sal_Int32 nDestId; + + /** link target name, respectively destination name + */ + OUString aBookmark; + + PDFExtOutDevBookmarkEntry() + :nLinkId( -1 ) + ,nDestId( -1 ) + ,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 mbExportNotesPages; + sal_Bool mbTransitionEffects; + sal_Bool mbUseLosslessCompression; + sal_Bool mbReduceImageResolution; + sal_Bool mbExportFormFields; + sal_Bool mbExportBookmarks; + sal_Bool mbExportHiddenSlides; + 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 GetIsExportNotesPages() const; + void SetIsExportNotesPages( const sal_Bool bExportNotesPages ); + + 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 ); + + void SetFormsFormat( const sal_Int32 nFormsFormat ); + + sal_Bool GetIsExportBookmarks() const; + void SetIsExportBookmarks( const sal_Bool bExportBookmarks ); + + sal_Bool GetIsExportHiddenSlides() const; + void SetIsExportHiddenSlides( const sal_Bool bExportHiddenSlides ); + + 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, 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 ); + + /** registers a destination for which a destinatin ID needs to be known immediately, instead of later on setting it via + SetLinkDest. + + This is used in contexts where a destination is referenced by means other than a link. + + Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about + the destination. + + @return + the unique Id of the destination + */ + sal_Int32 RegisterDest(); + + /** provides detailed information about a destination range which previously has been registered using RegisterDest. + */ + void DescribeRegisteredDest( sal_Int32 nDestId, 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 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 OUString& rText = OUString(), sal_Int32 nDestID = -1 ); + + /** 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 OUString& rAlias = 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 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/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx new file mode 100644 index 000000000000..3bfd5ed2f66f --- /dev/null +++ b/include/vcl/pdfwriter.hxx @@ -0,0 +1,1310 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#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 "com/sun/star/security/XCertificate.hpp" +#include "com/sun/star/lang/Locale.hpp" + +#include <boost/scoped_ptr.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; +class PDFWriterImpl; + +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 +{ + boost::scoped_ptr<PDFWriterImpl> 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 i18nlangtag/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, + Signature + }; + + 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: + OUString Name; // a distinct name to identify the control + OUString Description;// descriptive text for the contro (e.g. for tool tip) + 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 document. + + 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; + 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; + 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<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<OUString> Entries; + // set the current value in AnyWidget::Text + + ComboBoxWidget() + : AnyWidget( vcl::PDFWriter::ComboBox ), + Sort( false ) + {} + + virtual AnyWidget* Clone() const + { + return new ComboBoxWidget( *this ); + } + }; + + struct SignatureWidget: public AnyWidget + { + // Use Sig prefix for members to avoid conflict with + // the Location member of the AnyWidget which spcifies the coordinates + // of the signature + + OUString SigLocation; + OUString SigReason; + OUString SigContactInfo; + bool SigHidden; + + SignatureWidget() + : AnyWidget( vcl::PDFWriter::Signature ), + SigHidden( true ) + {} + + virtual AnyWidget* Clone() const + { + return new SignatureWidget( *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 */ + OUString URL; + /* the URL of the document being exported, used for relative links*/ + 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; + + bool SignPDF; + OUString SignLocation; + OUString SignPassword; + OUString SignReason; + OUString SignContact; + 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; + com::sun::star::uno::Reference< com::sun::star::security::XCertificate> SignCertificate; + + 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(), + SignPDF( false ), + DPIx( 0 ), + DPIy( 0 ), + ColorMode( PDFWriter::DrawColor ), + SignCertificate( 0 ) + {} + }; + + 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(); + + static com::sun::star::uno::Reference< com::sun::star::beans::XMaterialHolder > + InitEncryption( const OUString& i_rOwnerPassword, + const 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 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( 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 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 Size& rDestSize, + const Bitmap& rBitmap ); + + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const BitmapEx& rBitmapEx ); + + 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 ); + + /** 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 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 ); + + /** creates a destination which is not intended to be referred to by a link, but by a public destination Id. + + Form widgets, for instance, might refer to a destination, without ever actually creating a source link to + point to this destination. In such cases, a public destination Id will be assigned to the form widget, + and later on, the concrete destination data for this public Id will be registered using RegisterDestReference. + + @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 internal destination Id. + */ + sal_Int32 RegisterDestReference( sal_Int32 nDestId, const Rectangle& rRect, sal_Int32 nPageNr = -1, DestAreaType eType = XYZ ); + + + /** 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 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 OUString& rText = 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 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 OUString& rAlias = 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 ); + + /** 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 ); + +}; + +} + +#endif // _VCL_PDFWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pngread.hxx b/include/vcl/pngread.hxx new file mode 100644 index 000000000000..b36a0ee6106a --- /dev/null +++ b/include/vcl/pngread.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/pngwrite.hxx b/include/vcl/pngwrite.hxx new file mode 100644 index 000000000000..921ad45ddf4d --- /dev/null +++ b/include/vcl/pngwrite.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/pointr.hxx b/include/vcl/pointr.hxx new file mode 100644 index 000000000000..9cfdd6000371 --- /dev/null +++ b/include/vcl/pointr.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_POINTR_HXX +#define _VCL_POINTR_HXX + +#include <tools/solar.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/include/vcl/popupmenuwindow.hxx b/include/vcl/popupmenuwindow.hxx new file mode 100644 index 000000000000..a5856dca4bf9 --- /dev/null +++ b/include/vcl/popupmenuwindow.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + //determine if a given window is an activated PopupMenuFloatingWindow + static bool isPopupMenu(const Window *pWindow); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx new file mode 100644 index 000000000000..80fbeaf4728a --- /dev/null +++ b/include/vcl/ppdparser.hxx @@ -0,0 +1,311 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#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 "rtl/string.hxx" + +#include "vcl/dllapi.h" + +#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 VCL_DLLPUBLIC PPDValue +{ + PPDValueType m_eType; + String m_aOption; + String m_aValue; +}; + +// ---------------------------------------------------------------------- + +/* + * PPDKey - a container for the available options (=values) of a PPD keyword + */ + +class VCL_DLLPUBLIC PPDKey +{ + friend class PPDParser; + + typedef ::boost::unordered_map< OUString, PPDValue, 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 VCL_DLLPUBLIC PPDParser +{ + friend class PPDContext; + friend class CUPSManager; + friend class PPDCache; + + typedef ::boost::unordered_map< OUString, PPDKey*, 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 OString& rLine); + void parseOpenUI(const OString& rLine); + void parseConstraint(const OString& rLine); + void parse( std::list< OString >& rLines ); + + String handleTranslation(const OString& 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< 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; } + + // 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; } + + void getDefaultResolution( int& rXRes, int& rYRes ) const; + // values in dpi + void getResolutionFromString( const String&, int&, int& ) const; + // helper function + + int getDuplexTypes() const + { return m_pDuplexTypes ? m_pDuplexTypes->countValues() : 0; } + + int getFonts() const + { return m_pFontList ? m_pFontList->countValues() : 0; } + String getFont( int ) const; + + + OUString translateKey( const OUString& i_rKey, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const; + OUString translateOption( const OUString& i_rKey, + const OUString& i_rOption, + 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 VCL_DLLPUBLIC 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* ); + + // for printer setup + char* getStreamableBuffer( sal_uLong& rBytes ) const; + void rebuildFromStreamBuffer( char* 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( OUString& rPaper, int& rWidth, int& rHeight ) const; +}; + +} // namespace + +#endif // _PSPRINT_PPDPARSER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/prgsbar.hxx b/include/vcl/prgsbar.hxx new file mode 100644 index 000000000000..9f22df47c7a8 --- /dev/null +++ b/include/vcl/prgsbar.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _PRGSBAR_HXX +#define _PRGSBAR_HXX + +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +/************************************************************************* + * + * class ProgressBar + * + * this class is used to display the ProgressBar + * + * ----------------------------------------------------------------------- + * + * WinBits + * + * WB_BORDER border around the window + * WB_3DLOOK 3D representation + * + * ----------------------------------------------------------------------- + * + * Methodes + * + * Use SetValue() to set a percentage between 0 and 100. A value larger + * than 100 will cause the last rectangle to start flashing + * + ************************************************************************/ + +// ----------- +// - WinBits - +// ----------- + +#define WB_STDPROGRESSBAR WB_BORDER + +// --------------- +// - ProgressBar - +// --------------- + +class VCL_DLLPUBLIC ProgressBar : public Window +{ +private: + Point maPos; + long mnPrgsWidth; + long mnPrgsHeight; + sal_uInt16 mnPercent; + sal_uInt16 mnPercentCount; + sal_Bool mbCalcNew; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + SAL_DLLPRIVATE void ImplDrawProgress( sal_uInt16 nOldPerc, sal_uInt16 nNewPerc ); + +public: + ProgressBar( Window* pParent, WinBits nWinBits = WB_STDPROGRESSBAR ); + ProgressBar( Window* pParent, const ResId& rResId ); + ~ProgressBar(); + + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + void SetValue( sal_uInt16 nNewPercent ); + sal_uInt16 GetValue() const { return mnPercent; } +}; + +#endif // _PRGSBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx new file mode 100644 index 000000000000..c40e8bc4ab4d --- /dev/null +++ b/include/vcl/print.hxx @@ -0,0 +1,688 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_PRINT_HXX +#define _SV_PRINT_HXX + +#include <rtl/ustring.hxx> + +#include "tools/errcode.hxx" +#include "tools/solar.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> + +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); } +}; + + +// ------------- +// - QueueInfo - +// ------------- + +class VCL_DLLPUBLIC QueueInfo +{ + friend class Printer; + +private: + OUString maPrinterName; + OUString maDriver; + OUString maLocation; + OUString maComment; + sal_uInt32 mnStatus; + sal_uInt32 mnJobs; + +public: + QueueInfo(); + QueueInfo( const QueueInfo& rInfo ); + ~QueueInfo(); + + const OUString& GetPrinterName() const { return maPrinterName; } + const OUString& GetDriver() const { return maDriver; } + const OUString& GetLocation() const { return maLocation; } + const OUString& 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; + sal_Bool mbPDFAsStandardPrintJobFormat; + +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; } + + sal_Bool IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat; } + void SetPDFAsStandardPrintJobFormat( sal_Bool bSet ) { mbPDFAsStandardPrintJobFormat = 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 occurred + bool ReadFromConfig( bool bFile ); +}; + +// ----------- +// - Printer - +// ----------- + +class VCL_DLLPUBLIC Printer : public OutputDevice +{ + friend class OutputDevice; + +private: + SalInfoPrinter* mpInfoPrinter; + SalPrinter* mpPrinter; + SalGraphics* mpJobGraphics; + Printer* mpPrev; + Printer* mpNext; + VirtualDevice* mpDisplayDev; + PrinterOptions* mpPrinterOptions; + OUString maPrinterName; + OUString maDriver; + OUString maPrintFile; + OUString 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 OUString& rPrinterName, + const OUString* pDriver ); + SAL_DLLPRIVATE void ImplUpdatePageData(); + SAL_DLLPRIVATE void ImplUpdateFontList(); + SAL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup&, bool bMatchNearest ); + + SAL_DLLPRIVATE bool StartJob( const OUString& rJobName, boost::shared_ptr<vcl::PrinterController>& ); + + static SAL_DLLPRIVATE sal_uLong ImplSalPrinterErrorCodeToVCL( sal_uLong nError ); + +private: + 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 ); + +protected: + + void SetSelfAsQueuePrinter( sal_Bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; } + sal_Bool IsQueuePrinter() const { return mbIsQueuePrinter; } + +public: + Printer(); + Printer( const JobSetup& rJobSetup ); + Printer( const QueueInfo& rQueueInfo ); + Printer( const OUString& rPrinterName ); + virtual ~Printer(); + + static const std::vector< OUString >& GetPrinterQueues(); + static const QueueInfo* GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate ); + static OUString GetDefaultPrinterName(); + + virtual void Error(); + + const OUString& GetName() const { return maPrinterName; } + const OUString& 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; } + void SetJobValue( const OUString& rKey, const OUString& 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; + 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 OUString GetPaperName( Paper ePaper ); + // return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER + 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; + OUString 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; } + + const OUString& 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 ) {} + }; + + 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 OUString& i_rPropertyName ); + const com::sun::star::beans::PropertyValue* getValue( const OUString& i_rPropertyName ) const; + /* get a bool property + in case the property is unknown or not convertible to bool, i_bFallback is returned + */ + sal_Bool getBoolProperty( const OUString& i_rPropertyName, sal_Bool i_bFallback ) const; + /* get an int property + in case the property is unknown or not convertible to bool, i_nFallback is returned + */ + sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const; + + /* set a property value - can also be used to add another UI property + */ + void setValue( const 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. + */ + bool isUIOptionEnabled( const OUString& rPropName ) const; + bool isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const; + /* returns the property name rPropName depends on or an empty string + if no dependency exists. + */ + OUString getDependency( const 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. + */ + OUString makeEnabled( const 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 ); + VCL_PLUGIN_PUBLIC 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< OUString, com::sun::star::uno::Any, 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< OUString >* o_pChangeProp = NULL ); + /* append to a sequence of property values the ui property sequence passed at creation + * as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property + * will be appended. + **/ + void appendPrintUIOptions( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& io_rProps ) const; + + // returns an empty Any for not existing properties + com::sun::star::uno::Any getValue( const OUString& i_rPropertyName ) const; + + sal_Bool getBoolValue( const 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( OUString::createFromAscii( i_pPropName ), i_bDefault ); } + + sal_Int64 getIntValue( const 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( OUString::createFromAscii( i_pPropName ), i_nDefault ); } + + OUString getStringValue( const OUString& i_rPropertyName, const OUString& i_rDefault = OUString() ) const; + // convenience for fixed strings + OUString getStringValue( const char* i_pPropName, const OUString& i_rDefault = OUString() ) const + { return getStringValue( OUString::createFromAscii( i_pPropName ), i_rDefault ); } + + // helper functions for user to create a single control + struct UIControlOptions + { + OUString maDependsOnName; + sal_Int32 mnDependsOnEntry; + sal_Bool mbAttachToDependency; + OUString maGroupHint; + sal_Bool mbInternalOnly; + sal_Bool mbEnabled; + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > maAddProps; + + UIControlOptions( const OUString& i_rDependsOnName = OUString(), + sal_Int32 i_nDependsOnEntry = -1, + sal_Bool i_bAttachToDependency = sal_False, + const OUString& i_rGroupHint = 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 OUString + // the normal HelpId form is 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. + + // Show general control + static com::sun::star::uno::Any setUIControlOpt( const com::sun::star::uno::Sequence< OUString >& i_rIDs, + const OUString& i_rTitle, + const com::sun::star::uno::Sequence< OUString >& i_rHelpId, + const OUString& i_rType, + const com::sun::star::beans::PropertyValue* i_pValue = NULL, + const UIControlOptions& i_rControlOptions = UIControlOptions() + ); + + // Show and set the title of a TagPage of id i_rID + static com::sun::star::uno::Any setGroupControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const OUString& i_rHelpId); + + // Show and set the label of a VclFrame of id i_rID + static com::sun::star::uno::Any setSubgroupControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const OUString& i_rHelpId, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + // Show a bool option as a checkbox + static com::sun::star::uno::Any setBoolControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const OUString& i_rHelpId, + const OUString& i_rProperty, + sal_Bool i_bValue, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + // Show a set of choices in a list box + static com::sun::star::uno::Any setChoiceListControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const com::sun::star::uno::Sequence< OUString >& i_rHelpId, + const OUString& i_rProperty, + const com::sun::star::uno::Sequence< OUString >& i_rChoices, + sal_Int32 i_nValue, + const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(), + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + // show a set of choices as radio buttons + static com::sun::star::uno::Any setChoiceRadiosControlOpt(const com::sun::star::uno::Sequence< OUString >& i_rIDs, + const OUString& i_rTitle, + const com::sun::star::uno::Sequence< OUString >& i_rHelpId, + const OUString& i_rProperty, + const com::sun::star::uno::Sequence< OUString >& i_rChoices, + sal_Int32 i_nValue, + const com::sun::star::uno::Sequence< sal_Bool >& i_rDisabledChoices = com::sun::star::uno::Sequence< sal_Bool >(), + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + + // show 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 setRangeControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const OUString& i_rHelpId, + const OUString& i_rProperty, + sal_Int32 i_nValue, + sal_Int32 i_nMinValue = -1, + sal_Int32 i_nMaxValue = -2, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + // show a string field + // note: max value < min value means do not apply min/max values + static com::sun::star::uno::Any setEditControlOpt(const OUString& i_rID, + const OUString& i_rTitle, + const OUString& i_rHelpId, + const OUString& i_rProperty, + const OUString& i_rValue, + const UIControlOptions& i_rControlOptions = UIControlOptions()); +}; + +} + + +#endif // _SV_PRINT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/printerinfomanager.hxx b/include/vcl/printerinfomanager.hxx new file mode 100644 index 000000000000..108b31504de1 --- /dev/null +++ b/include/vcl/printerinfomanager.hxx @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 "osl/file.hxx" + +#include <cstdio> + +namespace psp +{ + +class SystemQueueInfo; + +struct PrinterInfo : JobData +{ + // basename of PPD + OUString m_aDriverName; + // can be the queue + OUString m_aLocation; + // a user defined comment + OUString m_aComment; + // a command line to pipe a PS-file to + OUString m_aCommand; + // a command line to pipe a PS-file to in case of direct print + 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") + 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< OUString, OUString, 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 + { + OUString m_aQueue; + OUString m_aLocation; + OUString m_aComment; + }; +protected: + // needed for checkPrintersChanged: files (not necessarily existant) + // and their last known modification time + struct WatchFile + { + // the file in question + 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 + OUString m_aFile; + // details other config files that have this printer + // in case of removal all have to be removed + std::list< 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 + OString m_aGroup; + // whether changes need to be saved + bool m_bModified; + // the corresponding info and job data + PrinterInfo m_aInfo; + }; + + boost::unordered_map< OUString, Printer, OUStringHash > m_aPrinters; + PrinterInfo m_aGlobalDefaults; + std::list< WatchFile > m_aWatchFiles; + OUString m_aDefaultPrinter; + OUString m_aSystemPrintCommand; + + std::list< SystemPrintQueue > m_aSystemPrintQueues; + + SystemQueueInfo* m_pQueueInfo; + + Type m_eType; + bool m_bUseIncludeFeature; + bool m_bUseJobPatch; + 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< 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 OUString& rPrinter ) const; + + // gets the name of the default printer + const OUString& getDefaultPrinter() const { return m_aDefaultPrinter; } + + virtual void setupJobContextData( JobData& rData ); + + // changes the info about a named printer + virtual void changePrinterInfo( const 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 OUString& rPrinterName, const 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 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 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< 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 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 OUString& rPrinterName, const 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 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/include/vcl/prntypes.hxx b/include/vcl/prntypes.hxx new file mode 100644 index 000000000000..4fdaaf794f08 --- /dev/null +++ b/include/vcl/prntypes.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_PRNTYPES_HXX +#define _SV_PRNTYPES_HXX + +#include <tools/solar.h> +#include <i18nutil/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/include/vcl/ptrstyle.hxx b/include/vcl/ptrstyle.hxx new file mode 100644 index 000000000000..c3f567e26036 --- /dev/null +++ b/include/vcl/ptrstyle.hxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_PTRSTYLE_HXX +#define _VCL_PTRSTYLE_HXX + +#include <tools/solar.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) + +// #i32329# +#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) + +// #i20119# +#define POINTER_PAINTBRUSH ((PointerStyle)93) + +#define POINTER_COUNT 94 + +#endif // _VCL_PTRSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/quickselectionengine.hxx b/include/vcl/quickselectionengine.hxx new file mode 100644 index 000000000000..631f0c40aa95 --- /dev/null +++ b/include/vcl/quickselectionengine.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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; + + protected: + ~ISearchableStringList() {} + }; + + //==================================================================== + //= 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/regband.hxx b/include/vcl/regband.hxx new file mode 100644 index 000000000000..0b60a801d83e --- /dev/null +++ b/include/vcl/regband.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_REGBAND_HXX +#define _SV_REGBAND_HXX + +#include <tools/solar.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 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/include/vcl/region.hxx b/include/vcl/region.hxx new file mode 100644 index 000000000000..02eebc7ec50e --- /dev/null +++ b/include/vcl/region.hxx @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_REGION_HXX +#define _SV_REGION_HXX + +#include <tools/gen.hxx> +#include <tools/solar.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 ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& 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: + explicit Region(); + explicit Region( RegionType eType ); + explicit Region( const Rectangle& rRect ); + explicit Region( const Polygon& rPolygon ); + explicit Region( const PolyPolygon& rPolyPoly ); + explicit Region( const basegfx::B2DPolyPolygon& ); + Region( const Region& rRegion ); + ~Region(); + + void Move( long nHorzMove, long nVertMove ); + void Scale( double fScaleX, double fScaleY ); + void Union( const Rectangle& rRegion ); + void Intersect( const Rectangle& rRegion ); + void Exclude( const Rectangle& rRegion ); + void XOr( const Rectangle& rRegion ); + void Union( const Region& rRegion ); + void Intersect( const Region& rRegion ); + void Exclude( const Region& rRegion ); + void 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/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx new file mode 100644 index 000000000000..85a00a197f96 --- /dev/null +++ b/include/vcl/salbtype.hxx @@ -0,0 +1,887 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/helpers.hxx> +#include <tools/solar.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: + +// ATTENTION: +// Because the members of this class are accessed via memcpy, +// you MUST NOT CHANGE the order of the members or the size of this class! + 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 = std::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; + + // from which bit starts the mask? + for( nShift = 31L; ( nShift >= 0L ) && !( nMask & ( 1 << (sal_uLong) nShift ) ); nShift-- ) + {} + + nRet = nShift; + + // XXX determine number of bits set => walk right until null + 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/include/vcl/salctype.hxx b/include/vcl/salctype.hxx new file mode 100644 index 000000000000..4fbb65d2a49a --- /dev/null +++ b/include/vcl/salctype.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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> + +#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) +#define CVT_SVG (0x0000000bUL) + +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() {} +}; + +typedef sal_uLong (*SALGRFCVTPROC)( void* pInst, + sal_uLong nInFormat, void* pInBuffer, sal_uLong nInBufSize, + sal_uLong nOutFormat, void** ppOutBuffer ); + +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/include/vcl/salgtype.hxx b/include/vcl/salgtype.hxx new file mode 100644 index 000000000000..25836f508771 --- /dev/null +++ b/include/vcl/salgtype.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SALGTYPE_HXX +#define _SV_SALGTYPE_HXX + +#include <tools/solar.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/include/vcl/salnativewidgets.hxx b/include/vcl/salnativewidgets.hxx new file mode 100644 index 000000000000..775503e29da4 --- /dev/null +++ b/include/vcl/salnativewidgets.hxx @@ -0,0 +1,476 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 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 +// for list headers +#define CTRL_LISTHEADER 172 + + +/* 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_HORZ 106 +#define PART_SEPARATOR_VERT 107 +#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_ARROW 220 +#define PART_MENU_ITEM 250 +#define PART_MENU_ITEM_CHECK_MARK 251 +#define PART_MENU_ITEM_RADIO_MARK 252 +#define PART_MENU_SEPARATOR 253 +#define PART_MENU_SUBMENU_ARROW 254 + +/* #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(); + + virtual ImplControlValue* clone() const; + + 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(); + virtual ScrollbarValue* clone() const; +}; + +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(); + virtual SliderValue* clone() const; +}; + +/* 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(); + virtual TabitemValue* clone() const; + + 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(); + virtual SpinbuttonValue* clone() const; +}; + +/* Toolbarvalue: + * + * Value container for toolbars detailing the grip position + */ +class VCL_DLLPUBLIC ToolbarValue : public ImplControlValue +{ +public: + ToolbarValue() : ImplControlValue( CTRL_TOOLBAR, BUTTONVALUE_DONTKNOW, 0 ) + { mbIsTopDockingArea = sal_False; } + virtual ~ToolbarValue(); + virtual ToolbarValue* clone() const; + 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 VCL_DLLPUBLIC MenubarValue : public ImplControlValue +{ +public: + MenubarValue() : ImplControlValue( CTRL_MENUBAR, BUTTONVALUE_DONTKNOW, 0 ) + { maTopDockingAreaHeight=0; } + virtual ~MenubarValue(); + virtual MenubarValue* clone() const; + 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 VCL_DLLPUBLIC 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(); + virtual MenupopupValue* clone() const; + Rectangle maItemRect; +}; + +/* PushButtonValue: + * + * Value container for pushbuttons specifying additional drawing hints + */ +class VCL_DLLPUBLIC PushButtonValue : public ImplControlValue +{ +public: + PushButtonValue() + : ImplControlValue( CTRL_PUSHBUTTON, BUTTONVALUE_DONTKNOW, 0 ) + , mbBevelButton( false ), mbSingleLine( true ) {} + virtual ~PushButtonValue(); + virtual PushButtonValue* clone() const; + + bool mbBevelButton:1; + bool mbSingleLine:1; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/scopedbitmapaccess.hxx b/include/vcl/scopedbitmapaccess.hxx new file mode 100644 index 000000000000..834f827e14aa --- /dev/null +++ b/include/vcl/scopedbitmapaccess.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED +#define VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED + +namespace vcl +{ + +/** This template handles BitmapAccess the RAII way. + + Please don't use directly, but through the ready-made typedefs + ScopedReadAccess and ScopedWriteAccess in classes Bitmap and + AlphaMask. + + Use as follows: + Bitmap aBitmap; + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + pReadAccess->SetPixel()... + + Bitmap aBitmap2; + Bitmap::ScopedWriteAccess pWriteAccess( bCond ? aBitmap2.AcquireWriteAccess() : 0, aBitmap2 ); + if ( pWriteAccess )... + + @attention for practical reasons, ScopedBitmapAccess stores a + reference to the provided bitmap, thus, make sure that the bitmap + specified at construction time lives at least as long as the + ScopedBitmapAccess. + */ +template < class Access, class Bitmap, Access* (Bitmap::* Acquire)() > class ScopedBitmapAccess +{ + typedef ScopedBitmapAccess< Access, Bitmap, Acquire > self_type; + typedef bool (self_type::* unspecified_bool_type)() const; + +public: + explicit ScopedBitmapAccess( Bitmap& rBitmap ) : + mpAccess( 0 ), + mrBitmap( rBitmap ) + { + mpAccess = (mrBitmap.*Acquire)(); + } + + ScopedBitmapAccess( Access* pAccess, Bitmap& rBitmap ) : + mpAccess( pAccess ), + mrBitmap( rBitmap ) + { + } + + ~ScopedBitmapAccess() + { + mrBitmap.ReleaseAccess( mpAccess ); + } + + bool operator!() const { return !mpAccess; } + operator unspecified_bool_type() const + { + return mpAccess ? &self_type::operator! : 0; + } + + 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; +}; + +} + +#endif // VCL_SCOPEDBITMAPACCESS_HXX_INCLUDED + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx new file mode 100644 index 000000000000..4a1a164121be --- /dev/null +++ b/include/vcl/scrbar.hxx @@ -0,0 +1,166 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SCRBAR_HXX +#define _SV_SCRBAR_HXX + +#include <tools/solar.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 ); + SAL_DLLPRIVATE Size getCurrentCalcSize() const; + DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* ); + DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, void* ); + +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; } + + virtual Size GetOptimalSize() const; +}; + +// ---------------- +// - 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 ); + + 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/include/vcl/seleng.hxx b/include/vcl/seleng.hxx new file mode 100644 index 000000000000..f93e74a3ebf4 --- /dev/null +++ b/include/vcl/seleng.hxx @@ -0,0 +1,232 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 ~FunctionSet() = 0; + + virtual void BeginDrag() = 0; + + virtual void CreateAnchor() = 0; // Anker-Pos := Cursor-Pos + virtual void DestroyAnchor() = 0; + + // move cursor, at the same time match cursor position to the selection + // starting at anchor. 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; + // delete anchor & deselect all + 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_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; // generate fake mouse moves + MouseEvent aLastMove; + SelectionMode eSelMode; + sal_uLong nUpdateInterval; + // sensitivity of mouse moves during a selection + sal_uInt16 nMouseSensitivity; + sal_uInt16 nLockedMods; + sal_uInt16 nFlags; + DECL_DLLPRIVATE_LINK( ImpWatchDog, void* ); + + 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 was processed by Selection Engine + sal_Bool SelMouseButtonDown( const MouseEvent& rMEvt ); + sal_Bool SelMouseButtonUp( const MouseEvent& rMEvt ); + sal_Bool SelMouseMove( const MouseEvent& rMEvt ); + + // Keyboard + void CursorPosChanging( sal_Bool bShift, sal_Bool bMod1 ); + + // is needed to generate a Move event via a Timer + // when the mouse is outside the area + 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 ); + + 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::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::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/include/vcl/settings.hxx b/include/vcl/settings.hxx new file mode 100644 index 000000000000..19dc20f3ba12 --- /dev/null +++ b/include/vcl/settings.hxx @@ -0,0 +1,1104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SETTINGS_HXX +#define _SV_SETTINGS_HXX + +#include "tools/solar.h" +#include "vcl/dllapi.h" +#include "tools/color.hxx" +#include "vcl/bitmapex.hxx" +#include "vcl/font.hxx" +#include "vcl/accel.hxx" +#include "vcl/wall.hxx" +#include <i18nlangtag/languagetag.hxx> +#include <unotools/syslocale.hxx> + +class CollatorWrapper; +class LocaleDataWrapper; + +namespace vcl { + class I18nHelper; +} + +// ----------------- +// - 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; +}; + +// ----------------- +// - 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); } +}; + +struct DialogStyle +{ + int content_area_border; + int content_area_spacing; + int button_spacing; + int action_area_border; + DialogStyle() + : content_area_border(2) + , content_area_spacing(0) + , button_spacing(6) + , action_area_border(5) + {} +}; + +struct FrameStyle +{ + int left; + int right; + int top; + int bottom; + FrameStyle() + : left(2) + , right(2) + , top(2) + , bottom(2) + {} +}; + +// ----------------- +// - ImplStyleData - +// ----------------- + +class ImplStyleData +{ + friend class StyleSettings; + + ImplStyleData(); + ImplStyleData( const ImplStyleData& rData ); + void SetStandardStyles(); + +private: + sal_uLong mnRefCount; + + 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 mnUseFlatMenus; + 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 mbHideDisabledMenuItems; + sal_Bool mbAcceleratorsInContextMenus; + //mbPrimaryButtonWarpsSlider == true for "jump to here" behavior for primary button, otherwise + //primary means scroll by single page. Secondary button takes the alternative behaviour + sal_Bool mbPrimaryButtonWarpsSlider; + Wallpaper maWorkspaceGradient; + DialogStyle maDialogStyle; + FrameStyle maFrameStyle; + const void* mpFontOptions; + + OUString maPersonaHeaderFooter; ///< Cache the settings to detect changes. + + BitmapEx maPersonaHeaderBitmap; ///< Cache the header bitmap. + BitmapEx maPersonaFooterBitmap; ///< Cache the footer bitmap. +}; + +#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 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_STARTTIME ((sal_uLong)0xFFFFFFFF) + +#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_TANGO_TESTING ((sal_uLong)9) +#define STYLE_SYMBOLS_THEMES_MAX ((sal_uLong)10) + +#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; } + void SetCheckedColorSpecialCase( ); + 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; } + 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 SetUseFlatMenus( sal_Bool bUseFlatMenus ) + { CopyData(); mpData->mnUseFlatMenus = bUseFlatMenus; } + sal_Bool GetUseFlatMenus() const + { return (sal_Bool) mpData->mnUseFlatMenus; } + 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 SetHideDisabledMenuItems( sal_Bool bHideDisabledMenuItems ) + { CopyData(); mpData->mbHideDisabledMenuItems = bHideDisabledMenuItems; } + sal_Bool GetHideDisabledMenuItems() const + { return mpData->mbHideDisabledMenuItems; } + void SetAcceleratorsInContextMenus( sal_Bool bAcceleratorsInContextMenus ) + { CopyData(); mpData->mbAcceleratorsInContextMenus = bAcceleratorsInContextMenus; } + sal_Bool GetAcceleratorsInContextMenus() const + { return mpData->mbAcceleratorsInContextMenus; } + void SetPrimaryButtonWarpsSlider( sal_Bool bPrimaryButtonWarpsSlider ) + { CopyData(); mpData->mbPrimaryButtonWarpsSlider = bPrimaryButtonWarpsSlider; } + sal_Bool GetPrimaryButtonWarpsSlider() const + { return mpData->mbPrimaryButtonWarpsSlider; } + + 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 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 OUString &rName ) + { return SetSymbolsStyle( ImplNameToSymbolsStyle( rName ) ); } + OUString GetSymbolsStyleName() const + { return ImplSymbolsStyleToName( GetSymbolsStyle() ); } + OUString GetCurrentSymbolsStyleName() const + { return ImplSymbolsStyleToName( GetCurrentSymbolsStyle() ); } + + const Wallpaper& GetWorkspaceGradient() const + { return mpData->maWorkspaceGradient; } + void SetWorkspaceGradient( const Wallpaper& rWall ) + { CopyData(); mpData->maWorkspaceGradient = rWall; } + + const DialogStyle& GetDialogStyle() const + { return mpData->maDialogStyle; } + void SetDialogStyle( const DialogStyle& rStyle ) + { CopyData(); mpData->maDialogStyle = rStyle; } + + const FrameStyle& GetFrameStyle() const + { return mpData->maFrameStyle; } + void SetFrameStyle( const FrameStyle& rStyle ) + { CopyData(); mpData->maFrameStyle = rStyle; } + + const BitmapEx GetPersonaHeader() const; + + 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: + OUString ImplSymbolsStyleToName( sal_uLong nStyle ) const; + sal_uLong ImplNameToSymbolsStyle( const 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(); + +#ifdef WNT + void SetEnableATToolSupport( sal_Bool bEnable ); +#endif + sal_Bool GetEnableATToolSupport() const; + 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); } +}; + +// ---------------- +// - 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 - +// ---------------- + +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 ImplAllSettingsData +{ + friend class AllSettings; + + ImplAllSettingsData(); + ImplAllSettingsData( const ImplAllSettingsData& rData ); + ~ImplAllSettingsData(); + +private: + sal_uLong mnRefCount; + MouseSettings maMouseSettings; + StyleSettings maStyleSettings; + MiscSettings maMiscSettings; + HelpSettings maHelpSettings; + LanguageTag maLocale; + sal_uLong mnSystemUpdate; + sal_uLong mnWindowUpdate; + LanguageTag maUILocale; + LocaleDataWrapper* mpLocaleDataWrapper; + LocaleDataWrapper* mpUILocaleDataWrapper; + vcl::I18nHelper* mpI18nHelper; + vcl::I18nHelper* mpUII18nHelper; + SvtSysLocale maSysLocale; +}; + +// --------------- +// - AllSettings - +// --------------- + +const int SETTINGS_MOUSE = 0x00000001; +const int SETTINGS_STYLE = 0x00000002; +const int SETTINGS_MISC = 0x00000004; +const int SETTINGS_SOUND = 0x00000008; +const int SETTINGS_HELP = 0x00000010; +const int SETTINGS_LOCALE = 0x00000020; +const int SETTINGS_UILOCALE = 0x00000040; +const int SETTINGS_ALLSETTINGS = ( SETTINGS_MOUSE | + SETTINGS_STYLE | SETTINGS_MISC | + SETTINGS_SOUND | + SETTINGS_HELP | + SETTINGS_LOCALE | SETTINGS_UILOCALE ); +const int SETTINGS_IN_UPDATE_SETTINGS = 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 SetMouseSettings( const MouseSettings& rSet ) + { CopyData(); mpData->maMouseSettings = rSet; } + const MouseSettings& GetMouseSettings() const + { return mpData->maMouseSettings; } + + 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 SetHelpSettings( const HelpSettings& rSet ) + { CopyData(); mpData->maHelpSettings = rSet; } + const HelpSettings& GetHelpSettings() const + { return mpData->maHelpSettings; } + + void SetLanguageTag( const LanguageTag& rLanguageTag ); + const LanguageTag& GetLanguageTag() const; + void SetUILanguageTag( const LanguageTag& rLanguageTag ); + const LanguageTag& GetUILanguageTag() const; + bool GetLayoutRTL() const; // returns 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; + + 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/include/vcl/slider.hxx b/include/vcl/slider.hxx new file mode 100644 index 000000000000..5d02217040b6 --- /dev/null +++ b/include/vcl/slider.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SLIDER_HXX +#define _SV_SLIDER_HXX + +#include <tools/solar.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 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 ); + + 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; } + + long GetRangeMin() const { return mnMinRange; } + 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/include/vcl/solarmutex.hxx b/include/vcl/solarmutex.hxx new file mode 100644 index 000000000000..a6880a62995a --- /dev/null +++ b/include/vcl/solarmutex.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/sound.hxx b/include/vcl/sound.hxx new file mode 100644 index 000000000000..7be53a0944ee --- /dev/null +++ b/include/vcl/sound.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SOUND_HXX +#define _SV_SOUND_HXX + +#include <vcl/dllapi.h> + +class Window; + +// --------- +// - Sound - +// --------- + +class VCL_DLLPUBLIC Sound +{ +public: + static void Beep( Window* pWindow = NULL ); +}; + +#endif // _SV_SOUND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/spin.h b/include/vcl/spin.h new file mode 100644 index 000000000000..0760b94ee2a5 --- /dev/null +++ b/include/vcl/spin.h @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SPIN_H +#define _SV_SPIN_H + +#include <tools/solar.h> + +class Rectangle; +class OutputDevice; + +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/include/vcl/spin.hxx b/include/vcl/spin.hxx new file mode 100644 index 000000000000..3966034c0938 --- /dev/null +++ b/include/vcl/spin.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SPIN_HXX +#define _SV_SPIN_HXX + +#include <tools/solar.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(); + + 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/include/vcl/spinfld.hxx b/include/vcl/spinfld.hxx new file mode 100644 index 000000000000..4a902d17aeaa --- /dev/null +++ b/include/vcl/spinfld.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SPINFLD_HXX +#define _SV_SPINFLD_HXX + +#include <tools/solar.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 CalcMinimumSizeForText(const OUString &rString) const; + virtual Size GetOptimalSize() const; + virtual Size CalcSize( sal_uInt16 nChars ) const; +}; + +#endif // _SV_SPINFLD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/split.hxx b/include/vcl/split.hxx new file mode 100644 index 000000000000..1710ea62f5eb --- /dev/null +++ b/include/vcl/split.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SPLIT_HXX +#define _SV_SPLIT_HXX + +#include <tools/solar.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; } + + 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 ); + + 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/include/vcl/splitwin.hxx b/include/vcl/splitwin.hxx new file mode 100644 index 000000000000..b723a449f727 --- /dev/null +++ b/include/vcl/splitwin.hxx @@ -0,0 +1,241 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SPLITWIN_HXX +#define _SV_SPLITWIN_HXX + +#include <tools/solar.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 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(); + + 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 RemoveItem( sal_uInt16 nId, sal_Bool bHide = sal_True ); + void Clear(); + + 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. + */ + long GetItemSize( sal_uInt16 nId, SplitWindowItemBits nBits ) const; + sal_uInt16 GetSet( sal_uInt16 nId ) 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; + + 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; } + + 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; } + + 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/include/vcl/status.hxx b/include/vcl/status.hxx new file mode 100644 index 000000000000..91aa97113179 --- /dev/null +++ b/include/vcl/status.hxx @@ -0,0 +1,198 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_STATUS_HXX +#define _SV_STATUS_HXX + +#include <tools/solar.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; + 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; + +public: + StatusBar( Window* pParent, + WinBits nWinStyle = WB_BORDER | WB_RIGHT ); + ~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 ); + + sal_Bool IsItemVisible( sal_uInt16 nItemId ) const; + sal_Bool AreItemsVisible() const { return mbVisibleItems; } + + 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; } + + void SetItemText( sal_uInt16 nItemId, const XubString& rText ); + const XubString& GetItemText( sal_uInt16 nItemId ) const; + + void SetItemData( sal_uInt16 nItemId, void* pNewData ); + + 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 OString& rHelpId ); + OString GetHelpId( sal_uInt16 nItemId ) const; + + void StartProgressMode( const XubString& rText ); + void SetProgressValue( sal_uInt16 nPercent ); + void EndProgressMode(); + sal_Bool IsProgressMode() const { return mbProgressMode; } + + void SetText( const OUString& rText ); + + void SetHelpText( const XubString& rText ) + { Window::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return Window::GetHelpText(); } + + void SetHelpId( const OString& rId ) + { Window::SetHelpId( rId ); } + const 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/include/vcl/stdtext.hxx b/include/vcl/stdtext.hxx new file mode 100644 index 000000000000..ab48231d23c2 --- /dev/null +++ b/include/vcl/stdtext.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_STDTEXT_HXX +#define _VCL_STDTEXT_HXX + +#include <tools/string.hxx> +#include <tools/solar.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 + +OUString VCL_DLLPUBLIC GetStandardText(sal_uInt16 nStdText); + +// ------------------------------------- +// - Hilfsmethoden fuer Standard-Texte - +// ------------------------------------- + +void VCL_DLLPUBLIC ShowServiceNotAvailableError(Window* pParent, const OUString& rServiceName, bool bError); + +#endif // _VCL_STDTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/strhelper.hxx b/include/vcl/strhelper.hxx new file mode 100644 index 000000000000..0d0949a3515f --- /dev/null +++ b/include/vcl/strhelper.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _PSPRINT_STRHELPER_HXX_ +#define _PSPRINT_STRHELPER_HXX_ + +#include "vcl/dllapi.h" + +#include <tools/string.hxx> +#include <rtl/math.hxx> + +#include <cstring> + +namespace psp +{ + VCL_DLLPUBLIC String GetCommandLineToken( int, const String& ); + VCL_DLLPUBLIC OString GetCommandLineToken(int, const OString&); + // gets one token of a unix command line style string + // doublequote, singlequote and singleleftquote protect their respective + // contents + + VCL_DLLPUBLIC int GetCommandLineTokenCount(const OUString&); + // returns number of tokens (zero if empty or whitespace only) + + VCL_DLLPUBLIC String WhitespaceToSpace( const String&, sal_Bool bProtect = sal_True ); + VCL_DLLPUBLIC OString WhitespaceToSpace(const OString&, 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 + VCL_DLLPUBLIC inline double StringToDouble( const String& rStr ) + { + return rtl::math::stringToDouble(rStr, sal_Unicode('.'), sal_Unicode(0)); + } + + VCL_DLLPUBLIC inline double StringToDouble(const OString& rStr) + { + return rtl::math::stringToDouble(rStr, '.', static_cast<sal_Char>(0)); + } + + // 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 + VCL_DLLPUBLIC inline int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0) + { + 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/include/vcl/svapp.hxx b/include/vcl/svapp.hxx new file mode 100644 index 000000000000..b4acc579ad94 --- /dev/null +++ b/include/vcl/svapp.hxx @@ -0,0 +1,538 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SVAPP_HXX +#define _SV_SVAPP_HXX + +#include <config_features.h> + +#include <sal/config.h> + +#include <stdexcept> + +#include <osl/thread.hxx> +#include <osl/mutex.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <tools/solar.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; +class ZoomEvent; +class ScrollEvent; + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/connection/XConnection.hpp> + +namespace com { +namespace sun { +namespace star { +namespace uno { + class XComponentContext; +} +namespace ui { + namespace dialogs { + class XFilePicker2; + class XFolderPicker2; + } +} +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 ); +VCL_DLLPUBLIC sal_UCS4 GetLocalizedChar( sal_UCS4, LanguageType ); + +#define SYSTEMWINDOW_MODE_NOAUTOMODE ((sal_uInt16)0x0001) +#define SYSTEMWINDOW_MODE_DIALOG ((sal_uInt16)0x0002) + +typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData ); + +// ATTENTION: ENUM duplicate in daemon.cxx under Unix! + +#ifdef UNX +enum Service { SERVICE_OLE, SERVICE_APPEVENT, SERVICE_IPC }; +#endif + +class VCL_DLLPUBLIC ApplicationEvent +{ +public: + enum Type { + TYPE_ACCEPT, TYPE_APPEAR, TYPE_HELP, TYPE_VERSION, TYPE_OPEN, + TYPE_OPENHELPURL, TYPE_PRINT, TYPE_PRIVATE_DOSHUTDOWN, TYPE_QUICKSTART, + TYPE_SHOWDIALOG, TYPE_UNACCEPT + }; + + ApplicationEvent() {} + + explicit ApplicationEvent( + Type rEvent, const OUString& rData = OUString()): + aEvent(rEvent), + aData(rData) + {} + + Type GetEvent() const { return aEvent; } + const OUString& GetData() const { return aData; } + +private: + Type aEvent; + OUString aData; +}; + + +class VCL_DLLPUBLIC Application +{ +public: + enum DialogCancelMode { + DIALOG_CANCEL_OFF, ///< do not automatically cancel dialogs + DIALOG_CANCEL_SILENT, ///< silently cancel any dialogs + DIALOG_CANCEL_FATAL + ///< cancel any dialogs by throwing a DialogCancelledException + }; + + class VCL_DLLPUBLIC DialogCancelledException: + virtual public std::runtime_error + { + public: + explicit DialogCancelledException(char const * what_arg): + runtime_error(what_arg) {} + + virtual ~DialogCancelledException() throw (); + }; + + Application(); + virtual ~Application(); + + virtual int Main() = 0; + + virtual sal_Bool QueryExit(); + + virtual void UserEvent( sal_uLong nEvent, void* pEventData ); + + virtual void FocusChanged(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + virtual void Init(); + virtual void InitFinished(); + virtual void DeInit(); + + 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 IsInModalMode(); + + static sal_uInt16 GetDispatchLevel(); + static bool AnyInput( sal_uInt16 nType = VCL_INPUT_ANY ); + static sal_uLong GetLastInputInterval(); + static sal_Bool IsUICaptured(); + + 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 ); +#if !HAVE_FEATURE_DESKTOP + static sal_uLong PostZoomEvent( sal_uLong nEvent, Window *pWin, ZoomEvent* pZoomEvent ); + static sal_uLong PostScrollEvent( sal_uLong nEvent, Window *pWin, ScrollEvent* pScrollEvent ); +#endif + static void RemoveMouseAndKeyEvents( Window *pWin ); + + static sal_uLong PostUserEvent( const Link& rLink, void* pCaller = 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 ); + +#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); + + // default name of the application for message dialogs and printing + static void SetDisplayName( const OUString& rDisplayName ); + static OUString GetDisplayName(); + + + static unsigned int GetScreenCount(); + static Rectangle GetScreenPosSizePixel( unsigned int nScreen ); + + // IsUnifiedDisplay returns: + // true: screens form up one large display area + // windows can be moved between single screens + // (e.g. Xserver with Xinerama, Windows) + // false: different screens are separate and windows cannot be moved + // between them (e.g. Xserver with multiple screens) + static bool IsUnifiedDisplay(); + // if IsUnifiedDisplay() == true the return value will be + // nearest screen of the target rectangle + // in case of IsUnifiedDisplay() == false the return value + // will always be GetDisplayDefaultScreen() + SAL_DLLPRIVATE static unsigned int GetBestScreen( const Rectangle& ); + static Rectangle GetWorkAreaPosSizePixel( unsigned int nScreen ); + // This returns the LCD screen number for a laptop, or the primary + // external VGA display for a desktop machine - it is where a presenter + // console should be rendered if there are other (non-built-in) screens + // present. + static unsigned int GetDisplayBuiltInScreen(); + // Practically, this means - Get the screen we should run a presentation on. + static unsigned int GetDisplayExternalScreen(); + + static const LocaleDataWrapper& GetAppLocaleDataWrapper(); + + static sal_Bool InsertAccel( Accelerator* pAccel ); + static void RemoveAccel( Accelerator* pAccel ); + + static long CallEventHooks( 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 void SetDefDialogParent( Window* pWindow ); + static Window* GetDefDialogParent(); + + static DialogCancelMode GetDialogCancelMode(); + static void SetDialogCancelMode( DialogCancelMode mode ); + static sal_Bool IsDialogCancelEnabled(); + + static void SetSystemWindowMode( sal_uInt16 nMode ); + static sal_uInt16 GetSystemWindowMode(); + + static void SetDialogScaleX( short nScale ); + + 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 void EnableHeadlessMode( bool dialogsAreFatal ); + static sal_Bool IsHeadlessModeEnabled(); + static bool IsHeadlessModeRequested(); + ///< check command line arguments for --headless + + 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 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 OUString& rFileUrl, const OUString& rMimeType); + + /** Do we have a native / system file selector available ? + */ + static bool hasNativeFileSelection(); + + /** Create a platform specific file picker, if one is available, + otherwise return an empty reference + */ + static com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 > + createFilePicker( const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rServiceManager ); + + /** Create a platform specific folder picker, if one is available, + otherwise return an empty reference + */ + static com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFolderPicker2 > + createFolderPicker( const com::sun::star::uno::Reference< + com::sun::star::uno::XComponentContext >& rServiceManager ); + +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; + +public: + SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {} + + ~SolarMutexReleaser() + { + Application::AcquireSolarMutex( mnReleased ); + } +}; + +VCL_DLLPUBLIC Application* GetpApp(); + +VCL_DLLPUBLIC sal_Bool InitVCL(); +VCL_DLLPUBLIC void DeInitVCL(); + +VCL_DLLPUBLIC bool InitAccessBridge( bool bAllowCancel, 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/include/vcl/svgdata.hxx b/include/vcl/svgdata.hxx new file mode 100644 index 000000000000..dccb08f8c579 --- /dev/null +++ b/include/vcl/svgdata.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SVGDATA_HXX +#define _SV_SVGDATA_HXX + +#include <basegfx/range/b2drange.hxx> +#include <boost/shared_array.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/utility.hpp> +#include <com/sun/star/graphic/XPrimitive2D.hpp> +#include <vcl/bitmapex.hxx> +#include <rtl/ustring.hxx> + +////////////////////////////////////////////////////////////////////////////// + +typedef boost::shared_array< sal_uInt8 > SvgDataArray; +typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference; +typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence; + +////////////////////////////////////////////////////////////////////////////// +// helper to convert any Primitive2DSequence to a good quality BitmapEx, +// using default parameters and graphic::XPrimitive2DRenderer + +BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( + const Primitive2DSequence& rSequence, + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels = 500000); + +////////////////////////////////////////////////////////////////////////////// + +class VCL_DLLPUBLIC SvgData : private boost::noncopyable +{ +private: + // the file and length + SvgDataArray maSvgDataArray; + sal_uInt32 mnSvgDataArrayLength; + + // The absolute Path if available + OUString maPath; + + // on demand created content + basegfx::B2DRange maRange; + Primitive2DSequence maSequence; + BitmapEx maReplacement; + + // on demand creators + void ensureReplacement(); + void ensureSequenceAndRange(); + +public: + SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath); + SvgData(const OUString& rPath); + + /// data read + const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; } + sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; } + const OUString& getPath() const { return maPath; } + + /// data read and evtl. on demand creation + const basegfx::B2DRange& getRange() const; + const Primitive2DSequence& getPrimitive2DSequence() const; + const BitmapEx& getReplacement() const; +}; + +typedef boost::shared_ptr< SvgData > SvgDataPtr; + +#endif // _SV_SVGDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/syschild.hxx b/include/vcl/syschild.hxx new file mode 100644 index 000000000000..66875e8979b5 --- /dev/null +++ b/include/vcl/syschild.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SYSCHILD_HXX +#define _SV_SYSCHILD_HXX + +#include <tools/solar.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(); + + 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 ); + 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/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx new file mode 100644 index 000000000000..d06e72aee22f --- /dev/null +++ b/include/vcl/sysdata.hxx @@ -0,0 +1,272 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SYSDATA_HXX +#define _SV_SYSDATA_HXX + +#include <vector> +#include <cstddef> + +#ifdef MACOSX +// predeclare the native classes to avoid header/include problems +typedef struct CGContext *CGContextRef; +typedef struct CGLayer *CGLayerRef; +#ifdef ENABLE_CORETEXT +typedef const struct __CTFont * CTFontRef; +#endif +#ifdef __OBJC__ +@class NSView; +#else +class NSView; +#endif +#endif + +#ifdef IOS +typedef const struct __CTFont * CTFontRef; +typedef struct CGContext *CGContextRef; +#endif + +#if defined( WNT ) +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4201) +#endif +#include <windef.h> +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif + +// ----------------- +// - SystemEnvData - +// ----------------- + +struct SystemEnvData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) + HWND hWnd; // the window hwnd +#elif defined( MACOSX ) + NSView* pView; // the cocoa (NSView *) implementing this object +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#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 ) + HWND hWnd; // the window hwnd +#elif defined( MACOSX ) + NSView* pView; // the cocoa (NSView *) implementing this object +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#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( MACOSX ) + // Nothing +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#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( MACOSX ) + CGContextRef rCGContext; // CoreGraphics graphic context +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#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 + SystemGraphicsData() + : nSize( sizeof( SystemGraphicsData ) ) +#if defined( WNT ) + , hDC( 0 ) +#elif defined( MACOSX ) + // Nothing +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#elif defined( UNX ) + , pDisplay( NULL ) + , hDrawable( 0 ) + , pVisual( NULL ) + , nScreen( 0 ) + , nDepth( 0 ) + , aColormap( 0 ) + , pXRenderFormat( NULL ) +#endif + { } +}; + + +// -------------------- +// - SystemWindowData - +// -------------------- + +struct SystemWindowData +{ + unsigned long nSize; // size in bytes of this structure +#if defined( WNT ) // meaningless on Windows +#elif defined( MACOSX ) // meaningless on Mac OS X + // Nothing +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#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( MACOSX ) +#ifdef ENABLE_CORETEXT + CTFontRef rCTFont; // native font object +#else + void* aATSUFontID; // native font object +#endif +#elif defined( IOS ) + CTFontRef rCTFont; // 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 + + SystemFontData() + : nSize( sizeof( SystemFontData ) ) +#if defined( WNT ) + , hFont( 0 ) +#elif defined( MACOSX ) +#ifdef ENABLE_CORETEXT +#else + , aATSUFontID( NULL ) +#endif +#elif defined( IOS ) +#elif defined( UNX ) + , nFontId( NULL ) + , nFontFlags( 0 ) +#endif + , bFakeBold( false ) + , bFakeItalic( false ) + , bAntialias( true ) + , bVerticalCharacterType( false ) + { + } +}; + +// -------------------- +// - 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/include/vcl/syswin.hxx b/include/vcl/syswin.hxx new file mode 100644 index 000000000000..07661431a94a --- /dev/null +++ b/include/vcl/syswin.hxx @@ -0,0 +1,270 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_SYSWIN_HXX +#define _SV_SYSWIN_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +class ModalDialog; +class MenuBar; +class TaskPaneList; + +// -------------- +// - Icon-Types - +// -------------- + +#define ICON_LO_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_MASTER_DOCUMENT 10 +#define ICON_TEMPLATE 11 +#define ICON_DATABASE_DOCUMENT 12 +#define ICON_MATH_DOCUMENT 13 +#define ICON_MACROLIBRARY 1 +#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) +#define WINDOWSTATE_STATE_SYSTEMMASK ((sal_uLong)0x0000FFFF) + +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; + +public: + using Window::ImplIsInTaskPaneList; + SAL_DLLPRIVATE sal_Bool ImplIsInTaskPaneList( Window* pWin ); + +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 OUString& ); + + 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 OString& rStr); + OString 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 Display Screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code>, + <code>Application::GetWorkAreaPosSizePixel</code>, + <code>Application::GetDisplayScreenName</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 Display Screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code>, + <code>Application::GetWorkAreaPosSizePixel</code>, + <code>Application::GetDisplayScreenName</code> + and of course <code>SystemWindow::GetScreenNumber</code> + are counted in. + + @see GetScreenNumber + */ + void SetScreenNumber( unsigned int nNewScreen ); + + void SetApplicationID( const OUString &rApplicationID ); + + void SetCloseHdl(const Link& rLink); + const Link& GetCloseHdl() const; +}; + +#endif // _SV_SYSWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx new file mode 100644 index 000000000000..05b8313b537b --- /dev/null +++ b/include/vcl/tabctrl.hxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_TABCTRL_HXX +#define _SV_TABCTRL_HXX + +#include "tools/solar.h" +#include "vcl/dllapi.h" +#include "vcl/ctrl.hxx" + +struct ImplTabItem; +struct ImplTabCtrlData; +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: + 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; + bool mbLayoutDirty; + 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, void* ); + DECL_DLLPRIVATE_LINK( ImplWindowEventListener, VclSimpleEvent* ); + + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( Window* pParent, 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() const; + + 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 GetPagePos( sal_uInt16 nPageId ) const; + sal_uInt16 GetPageCount() const; + sal_uInt16 GetPageId( sal_uInt16 nPos ) const; + sal_uInt16 GetPageId( const Point& rPos ) const; + sal_uInt16 GetPageId( const TabPage& rPage ) const; + sal_uInt16 GetPageId( const OString& rName ) 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; + + 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 OString& rId ) const; + OString GetHelpId( sal_uInt16 nPageId ) const; + + void SetPageName( sal_uInt16 nPageId, const OString& rName ) const; + OString GetPageName( sal_uInt16 nPageId ) const; + + void SetPageImage( sal_uInt16 nPageId, const Image& rImage ); + + void SetHelpText( const XubString& rText ) + { Control::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return Control::GetHelpText(); } + + void SetHelpId( const OString& rId ) + { Control::SetHelpId( rId ); } + const 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 rectangle of the tab for page nPageId + Rectangle GetTabBounds( sal_uInt16 nPageId ) const; + + virtual void SetPosPixel(const Point& rPos); + virtual void SetSizePixel(const Size& rNewSize); + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize); + + Size calculateRequisition() const; + void setAllocation(const Size &rAllocation); + + void markLayoutDirty() + { + mbLayoutDirty = true; + } +}; + +#endif // _SV_TABCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/tabdlg.hxx b/include/vcl/tabdlg.hxx new file mode 100644 index 000000000000..7555f3f01701 --- /dev/null +++ b/include/vcl/tabdlg.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_TABDLG_HXX +#define _SV_TABDLG_HXX + +#include <tools/solar.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( Window* pParent, const OString& rID, const OUString& rUIXMLDescription ); + ~TabDialog(); + + 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/include/vcl/tabpage.hxx b/include/vcl/tabpage.hxx new file mode 100644 index 000000000000..3414ec76e834 --- /dev/null +++ b/include/vcl/tabpage.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_TABPAGE_HXX +#define _SV_TABPAGE_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/builder.hxx> +#include <vcl/window.hxx> + +// ----------- +// - TabPage - +// ----------- + +class VCL_DLLPUBLIC TabPage + : public Window + , public VclBuilderContainer +{ +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 OString& rID, const OUString& rUIXMLDescription); + + 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(); + + //To-Do, consider inheriting from VclContainer + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize); + virtual void SetPosPixel(const Point& rNewPos); + virtual void SetSizePixel(const Size& rNewSize); + virtual Size GetOptimalSize() const; +}; + +#endif // _SV_TABPAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/taskpanelist.hxx b/include/vcl/taskpanelist.hxx new file mode 100644 index 000000000000..9a9621b77e88 --- /dev/null +++ b/include/vcl/taskpanelist.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 *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/include/vcl/textdata.hxx b/include/vcl/textdata.hxx new file mode 100644 index 000000000000..476ba00279df --- /dev/null +++ b/include/vcl/textdata.hxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _TEXTDATA_HXX +#define _TEXTDATA_HXX + +#include <vcl/dllapi.h> +#include <svl/brdcst.hxx> +#include <svl/smplhint.hxx> +#include <tools/string.hxx> + +// for Notify, if all paragraphs were deleted +#define TEXT_PARA_ALL 0xFFFFFFFF + +class TextPaM +{ +private: + sal_uLong mnPara; + sal_uInt16 mnIndex; + +public: + TextPaM() { mnPara = 0, mnIndex = 0; } + TextPaM( sal_uLong nPara, sal_uInt16 nIndex ) { mnPara = nPara, mnIndex = nIndex; } + + sal_uLong GetPara() const { return mnPara; } + sal_uLong& GetPara() { return mnPara; } + + sal_uInt16 GetIndex() const { return mnIndex; } + sal_uInt16& GetIndex() { return mnIndex; } + + inline sal_Bool operator == ( const TextPaM& rPaM ) const; + inline sal_Bool operator != ( const TextPaM& rPaM ) const; + inline sal_Bool operator < ( const TextPaM& rPaM ) const; + inline sal_Bool operator > ( const TextPaM& rPaM ) const; +}; + +inline sal_Bool TextPaM::operator == ( const TextPaM& rPaM ) const +{ + return ( ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex ) ) ? sal_True : sal_False; +} + +inline sal_Bool TextPaM::operator != ( const TextPaM& rPaM ) const +{ + return !( *this == rPaM ); +} + +inline sal_Bool TextPaM::operator < ( const TextPaM& rPaM ) const +{ + return ( ( mnPara < rPaM.mnPara ) || + ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex ) ) ? sal_True : sal_False; +} + +inline sal_Bool TextPaM::operator > ( const TextPaM& rPaM ) const +{ + return ( ( mnPara > rPaM.mnPara ) || + ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex ) ) ? sal_True : sal_False; +} + +class VCL_DLLPUBLIC TextSelection +{ +private: + TextPaM maStartPaM; + TextPaM maEndPaM; + +public: + TextSelection(); + TextSelection( const TextPaM& rPaM ); + TextSelection( const TextPaM& rStart, const TextPaM& rEnd ); + + const TextPaM& GetStart() const { return maStartPaM; } + TextPaM& GetStart() { return maStartPaM; } + + const TextPaM& GetEnd() const { return maEndPaM; } + TextPaM& GetEnd() { return maEndPaM; } + + void Justify(); + + sal_Bool HasRange() const { return maStartPaM != maEndPaM; } + + inline sal_Bool operator == ( const TextSelection& rSel ) const; + inline sal_Bool operator != ( const TextSelection& rSel ) const; +}; + +inline sal_Bool TextSelection::operator == ( const TextSelection& rSel ) const +{ + return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) ); +} + +inline sal_Bool TextSelection::operator != ( const TextSelection& rSel ) const +{ + return !( *this == rSel ); +} + +#define TEXT_HINT_PARAINSERTED 1 +#define TEXT_HINT_PARAREMOVED 2 +#define TEXT_HINT_PARACONTENTCHANGED 3 +#define TEXT_HINT_TEXTHEIGHTCHANGED 4 +#define TEXT_HINT_FORMATPARA 5 +#define TEXT_HINT_TEXTFORMATTED 6 +#define TEXT_HINT_MODIFIED 7 +#define TEXT_HINT_BLOCKNOTIFICATION_START 8 +#define TEXT_HINT_BLOCKNOTIFICATION_END 9 +#define TEXT_HINT_INPUT_START 10 +#define TEXT_HINT_INPUT_END 11 + +#define TEXT_HINT_VIEWSCROLLED 100 +#define TEXT_HINT_VIEWSELECTIONCHANGED 101 + +class VCL_DLLPUBLIC TextHint : public SfxSimpleHint +{ +private: + sal_uLong mnValue; + +public: + TYPEINFO(); + TextHint( sal_uLong nId ); + TextHint( sal_uLong nId, sal_uLong nValue ); + + sal_uLong GetValue() const { return mnValue; } + void SetValue( sal_uLong n ) { mnValue = n; } +}; + +struct TEIMEInfos +{ + String aOldTextAfterStartPos; + sal_uInt16* pAttribs; + TextPaM aPos; + sal_uInt16 nLen; + sal_Bool bCursor; + sal_Bool bWasCursorOverwrite; + + TEIMEInfos( const TextPaM& rPos, const String& rOldTextAfterStartPos ); + ~TEIMEInfos(); + + void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL ); + void DestroyAttribs(); +}; + +// ----------------- Wrapper for old Tools List ------------------- + +#include <vector> +#include <algorithm> + +template <class T> class ToolsList : public ::std::vector< T > +{ +public: + sal_uLong Count() const { return static_cast<sal_uLong>(::std::vector< T >::size()); } + sal_uLong GetPos( T pObject ) const { return ( ::std::find( this->begin(), this->end(), pObject ) ) - this->begin(); } + T GetObject( sal_uLong nIndex ) const { return (*this)[nIndex]; } + void Insert( T pObject, sal_uLong nPos ) { ::std::vector< T >::insert( this->begin()+nPos, pObject ); } + void Remove( sal_uLong nPos ) { ::std::vector< T >::erase( this->begin()+nPos ); } +}; + +#endif // _TEXTDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx new file mode 100644 index 000000000000..85b5a7b59a25 --- /dev/null +++ b/include/vcl/texteng.hxx @@ -0,0 +1,322 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _TEXTENG_HXX +#define _TEXTENG_HXX + +#include <vcl/dllapi.h> + +class TextDoc; +class TextView; +class TextPaM; +class TextSelection; +class TEParaPortions; +class TextAttrib; +class TextCharAttrib; +class TextUndo; +class TextUndoManager; +class EditSelFunctionSet; +class IdleFormatter; +class TextNode; +class OutputDevice; +class SfxUndoAction; +class KeyEvent; +class Timer; + +namespace svl +{ + class IUndoManager; +} + +class TextLine; +class TETextPortion; +#include <svl/brdcst.hxx> +#include <tools/link.hxx> +#include <vcl/font.hxx> +#include <tools/string.hxx> +#include <tools/gen.hxx> + +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/uno/Reference.hxx> + +struct TEIMEInfos; +class SvtCTLOptions; + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XExtendedInputSequenceChecker; +}}}} + +class LocaleDataWrapper; + +enum TxtAlign { TXTALIGN_LEFT, TXTALIGN_CENTER, TXTALIGN_RIGHT }; + +typedef std::vector<TextView*> TextViews; + +class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster +{ + friend class TextView; + friend class TextSelFunctionSet; + friend class ExtTextEngine; + friend class ExtTextView; + + friend class TextUndo; + friend class TextUndoManager; + friend class TextUndoDelPara; + friend class TextUndoConnectParas; + friend class TextUndoSplitPara; + friend class TextUndoInsertChars; + friend class TextUndoRemoveChars; + friend class TextUndoSetAttribs; + +private: + TextDoc* mpDoc; + TEParaPortions* mpTEParaPortions; + OutputDevice* mpRefDev; + + TextViews* mpViews; + TextView* mpActiveView; + + TextUndoManager* mpUndoManager; + + IdleFormatter* mpIdleFormatter; + + TEIMEInfos* mpIMEInfos; + + ::com::sun::star::lang::Locale maLocale; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIterator; + + Rectangle maInvalidRect; + Range maInvalidRange; + + LocaleDataWrapper* mpLocaleDataWrapper; + + Font maFont; + Color maTextColor; + sal_uInt16 mnCharHeight; + sal_uInt16 mnFixCharWidth100; + + sal_uLong mnMaxTextLen; + sal_uLong mnMaxTextWidth; + sal_uLong mnCurTextWidth; + sal_uLong mnCurTextHeight; + sal_uLong mnDefTab; + + TxtAlign meAlign; + + sal_Bool mbIsFormatting : 1; // semaphore for the Hook's + sal_Bool mbFormatted : 1; + sal_Bool mbUpdate : 1; + sal_Bool mbModified : 1; + sal_Bool mbUndoEnabled : 1; + sal_Bool mbIsInUndo : 1; + sal_Bool mbDowning : 1; + sal_Bool mbRightToLeft : 1; + sal_Bool mbHasMultiLineParas : 1; + + TextEngine( const TextEngine& ) : SfxBroadcaster() {} + TextEngine& operator=( const TextEngine& ) { return *this; } + +protected: + + void CursorMoved( sal_uLong nNode ); + void TextModified(); + + void ImpInitDoc(); + void ImpRemoveText(); + TextPaM ImpDeleteText( const TextSelection& rSel ); + TextPaM ImpInsertText( const TextSelection& rSel, sal_Unicode c, sal_Bool bOverwrite = sal_False ); + TextPaM ImpInsertText( const TextSelection& rSel, const String& rText ); + TextPaM ImpInsertParaBreak( const TextSelection& rTextSelection, sal_Bool bKeepEndingAttribs = sal_True ); + TextPaM ImpInsertParaBreak( const TextPaM& rPaM, sal_Bool bKeepEndingAttribs = sal_True ); + void ImpRemoveChars( const TextPaM& rPaM, sal_uInt16 nChars, SfxUndoAction* pCurUndo = 0 ); + TextPaM ImpConnectParagraphs( sal_uLong nLeft, sal_uLong nRight ); + void ImpRemoveParagraph( sal_uLong nPara ); + void ImpInitWritingDirections( sal_uLong nPara ); + LocaleDataWrapper* ImpGetLocaleDataWrapper(); + + // to remain compatible in the minor release we copy the above ImpInsertText + // function and add the extra parameter we need but make sure this function + // gets not exported. First and seconf parameter swapped to have a different signatur. + SAL_DLLPRIVATE TextPaM ImpInsertText( sal_Unicode c, const TextSelection& rSel, sal_Bool bOverwrite = sal_False, sal_Bool bIsUserInput = sal_False ); + // some other new functions needed that must not be exported to remain compatible + SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > GetInputSequenceChecker() const; + SAL_DLLPRIVATE sal_Bool IsInputSequenceCheckingRequired( sal_Unicode c, const TextSelection& rCurSel ) const; + + // broadcast or adjust selections + void ImpParagraphInserted( sal_uLong nPara ); + void ImpParagraphRemoved( sal_uLong nPara ); + void ImpCharsRemoved( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars ); + void ImpCharsInserted( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars ); + void ImpFormattingParagraph( sal_uLong nPara ); + void ImpTextHeightChanged(); + void ImpTextFormatted(); + + DECL_LINK( IdleFormatHdl, void * ); + void CheckIdleFormatter(); + void IdleFormatAndUpdate( TextView* pCurView = 0, sal_uInt16 nMaxTimerRestarts = 5 ); + + sal_Bool CreateLines( sal_uLong nPara ); + void CreateAndInsertEmptyLine( sal_uLong nPara ); + void ImpBreakLine( sal_uLong nPara, TextLine* pLine, TETextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth ); + sal_uInt16 SplitTextPortion( sal_uLong nPara, sal_uInt16 nPos ); + void CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos ); + void RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short nNewChars ); + void SeekCursor( sal_uLong nNode, sal_uInt16 nPos, Font& rFont, OutputDevice* pOutDev ); + + void FormatDoc(); + void FormatFullDoc(); + void FormatAndUpdate( TextView* pCurView = 0 ); + sal_Bool IsFormatting() const { return mbIsFormatting; } + void UpdateViews( TextView* pCurView = 0 ); + + void ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 ); + + void UpdateSelections(); + + sal_Bool IsFormatted() const { return mbFormatted; } + + sal_uInt16 GetCharPos( sal_uLong nPara, sal_uInt16 nLine, long nDocPosX, sal_Bool bSmart = sal_False ); + Rectangle GetEditCursor( const TextPaM& rPaM, sal_Bool bSpecial, sal_Bool bPreferPortionStart = sal_False ); + sal_uInt16 ImpFindIndex( sal_uLong nPortion, const Point& rPosInPara, sal_Bool bSmart ); + long ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uInt16 nTextPortion ); + long ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex, sal_Bool bPreferPortionStart = sal_False ); + long ImpGetOutputOffset( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex, sal_uInt16 nIndex2 ); + sal_uInt8 ImpGetRightToLeft( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16* pStart = NULL, sal_uInt16* pEnd = NULL ); + void ImpInitLayoutMode( OutputDevice* pOutDev, sal_Bool bDrawingR2LPortion = sal_False ); + TxtAlign ImpGetAlign() const; + + sal_uLong CalcTextHeight(); + sal_uLong CalcParaHeight( sal_uLong nParagraph ) const; + sal_uLong CalcTextWidth( sal_uLong nPara ); + sal_uLong CalcTextWidth( sal_uLong nPara, sal_uInt16 nPortionStart, sal_uInt16 nPortionLen, const Font* pFont = 0 ); + Range GetInvalidYOffsets( sal_uLong nPortion ); + + // for Undo/Redo + void InsertContent( TextNode* pNode, sal_uLong nPara ); + TextPaM SplitContent( sal_uLong nNode, sal_uInt16 nSepPos ); + TextPaM ConnectContents( sal_uLong nLeftNode ); + + // adjust PaM's and selections that were transfered to the API to a valid range + void ValidateSelection( TextSelection& rSel ) const; + void ValidatePaM( TextPaM& rPaM ) const; + +public: + TextEngine(); + ~TextEngine(); + + void SetText( const OUString& rStr ); + String GetText( LineEnd aSeparator = LINEEND_LF ) const; + String GetText( const TextSelection& rSel, LineEnd aSeparator = LINEEND_LF ) const; + String GetTextLines( LineEnd aSeparator = LINEEND_LF ) const; + void ReplaceText(const TextSelection& rSel, const String& rText); + + sal_uLong GetTextLen( LineEnd aSeparator = LINEEND_LF ) const; + sal_uLong GetTextLen( const TextSelection& rSel, LineEnd aSeparator = LINEEND_LF ) const; + + void SetFont( const Font& rFont ); + const Font& GetFont() const { return maFont; } + + sal_uInt16 GetDefTab() const; + + void SetLeftMargin( sal_uInt16 n ); + sal_uInt16 GetLeftMargin() const; + + void SetUpdateMode( sal_Bool bUpdate ); + sal_Bool GetUpdateMode() const { return mbUpdate; } + + sal_uInt16 GetViewCount() const; + TextView* GetView( sal_uInt16 nView ) const; + void InsertView( TextView* pTextView ); + void RemoveView( TextView* pTextView ); + TextView* GetActiveView() const; + void SetActiveView( TextView* pView ); + + void SetMaxTextLen( sal_uLong nLen ); + sal_uLong GetMaxTextLen() const { return mnMaxTextLen; } + + void SetMaxTextWidth( sal_uLong nWidth ); + sal_uLong GetMaxTextWidth() const { return mnMaxTextWidth; } + + sal_uLong GetTextHeight() const; + sal_uLong CalcTextWidth(); + sal_uInt16 GetCharHeight() const { return mnCharHeight; } + + sal_uLong GetParagraphCount() const; + String GetText( sal_uLong nParagraph ) const; + sal_uInt16 GetTextLen( sal_uLong nParagraph ) const; + sal_uLong GetTextHeight( sal_uLong nParagraph ) const; + + sal_uInt16 GetLineCount( sal_uLong nParagraph ) const; + sal_uInt16 GetLineLen( sal_uLong nParagraph, sal_uInt16 nLine ) const; + + void SetRightToLeft( sal_Bool bR2L ); + sal_Bool IsRightToLeft() const { return mbRightToLeft; } + + sal_Bool HasUndoManager() const { return mpUndoManager ? sal_True : sal_False; } + ::svl::IUndoManager& + GetUndoManager(); + void UndoActionStart( sal_uInt16 nId = 0 ); + void UndoActionEnd(); + void InsertUndo( TextUndo* pUndo, sal_Bool bTryMerge = sal_False ); + sal_Bool IsInUndo() { return mbIsInUndo; } + void SetIsInUndo( sal_Bool bInUndo ) { mbIsInUndo = bInUndo; } + void ResetUndo(); + + void EnableUndo( sal_Bool bEnable ); + sal_Bool IsUndoEnabled() { return mbUndoEnabled; } + + void SetModified( sal_Bool bModified ) { mbModified = bModified; } + sal_Bool IsModified() const { return mbModified; } + + sal_Bool Read( SvStream& rInput, const TextSelection* pSel = NULL ); + + sal_Bool Write( SvStream& rOutput, const TextSelection* pSel = NULL, sal_Bool bHTML = sal_False ); + + TextPaM GetPaM( const Point& rDocPos, sal_Bool bSmart = sal_True ); + Rectangle PaMtoEditCursor( const TextPaM& rPaM, sal_Bool bSpecial = sal_False ); + String GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord = 0 ); + + sal_Bool HasAttrib( sal_uInt16 nWhich ) const; + const TextAttrib* FindAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const; + const TextCharAttrib* FindCharAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const; + + void RemoveAttribs( sal_uLong nPara, sal_uInt16 nWhich, sal_Bool bIdleFormatAndUpdate ); + void RemoveAttrib( sal_uLong nPara, const TextCharAttrib& rAttrib ); + void RemoveAttribs( sal_uLong nPara, sal_Bool bIdleFormatAndUpdate = sal_True ); + void SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_Bool bIdleFormatAndUpdate = sal_True ); + + TxtAlign GetTextAlign() const { return meAlign; } + void SetTextAlign( TxtAlign eAlign ); + + void Draw( OutputDevice* pDev, const Point& rPos ); + + void SetLocale( const ::com::sun::star::lang::Locale& rLocale ); + ::com::sun::star::lang::Locale GetLocale(); + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > GetBreakIterator(); + + static sal_Bool DoesKeyChangeText( const KeyEvent& rKeyEvent ); + static sal_Bool IsSimpleCharInput( const KeyEvent& rKeyEvent ); +}; + +#endif // _TEXTENG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx new file mode 100644 index 000000000000..314e30fa4f1e --- /dev/null +++ b/include/vcl/textview.hxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _TEXTVIEW_HXX +#define _TEXTVIEW_HXX + +#include <vcl/dllapi.h> +#include <vcl/textdata.hxx> +#include <tools/gen.hxx> +#include <vcl/dndhelp.hxx> + +class TextEngine; +class OutputDevice; +class Window; +class Cursor; +class KeyEvent; +class MouseEvent; +class CommandEvent; +class TextSelFunctionSet; +class SelectionEngine; +class VirtualDevice; +struct TextDDInfo; + +namespace com { +namespace sun { +namespace star { +namespace datatransfer { +namespace clipboard { + class XClipboard; +}}}}} + +struct ImpTextView; + +class VCL_DLLPUBLIC TextView : public vcl::unohelper::DragAndDropClient +{ + friend class TextEngine; + friend class TextUndo; + friend class TextUndoManager; + friend class TextSelFunctionSet; + friend class ExtTextView; + +private: + ImpTextView* mpImpl; + + TextView( const TextView& ) : vcl::unohelper::DragAndDropClient() {} + TextView& operator=( const TextView& ) { return *this; } + +protected: + void ShowSelection(); + void HideSelection(); + void ShowSelection( const TextSelection& rSel ); + void ImpShowHideSelection( sal_Bool bShow, const TextSelection* pRange = NULL ); + + TextSelection ImpMoveCursor( const KeyEvent& rKeyEvent ); + TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ); + void ImpSetSelection( const TextSelection& rNewSel, sal_Bool bUI ); + sal_Bool IsInSelection( const TextPaM& rPaM ); + + void ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 ); + void ImpPaint( const Rectangle& rRect, sal_Bool bUseVirtDev ); + void ImpShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, sal_Bool bEndKey ); + void ImpHighlight( const TextSelection& rSel ); + void ImpSetSelection( const TextSelection& rSelection ); + Point ImpGetOutputStartPos( const Point& rStartDocPos ) const; + + void ImpHideDDCursor(); + void ImpShowDDCursor(); + + bool ImplTruncateNewText( OUString& rNewText ) const; + sal_Bool ImplCheckTextLen( const String& rNewText ); + + VirtualDevice* GetVirtualDevice(); + + // DragAndDropClient + 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); + + using DragAndDropClient::dragEnter; + using DragAndDropClient::dragExit; + using DragAndDropClient::dragOver; + +public: + TextView( TextEngine* pEng, Window* pWindow ); + virtual ~TextView(); + + TextEngine* GetTextEngine() const; + Window* GetWindow() const; + + void Invalidate(); + void Scroll( long nHorzScroll, long nVertScroll ); + + void ShowCursor( sal_Bool bGotoCursor = sal_True, sal_Bool bForceVisCursor = sal_True ); + void HideCursor(); + + void EnableCursor( sal_Bool bEnable ); + sal_Bool IsCursorEnabled() const; + + const TextSelection& GetSelection() const; + TextSelection& GetSelection(); + void SetSelection( const TextSelection& rNewSel ); + void SetSelection( const TextSelection& rNewSel, sal_Bool bGotoCursor ); + sal_Bool HasSelection() const; + + String GetSelected(); + String GetSelected( LineEnd aSeparator ); + void DeleteSelected(); + + void InsertNewText( const OUString& rNew, sal_Bool bSelect = sal_False ); + // deprecated: use InsertNewText instead + void InsertText( const String& rNew, sal_Bool bSelect = sal_False ); + + sal_Bool KeyInput( const KeyEvent& rKeyEvent ); + void Paint( const Rectangle& rRect ); + void MouseButtonUp( const MouseEvent& rMouseEvent ); + void MouseButtonDown( const MouseEvent& rMouseEvent ); + void MouseMove( const MouseEvent& rMouseEvent ); + void Command( const CommandEvent& rCEvt ); + + void Cut(); + void Copy(); + void Paste(); + + void Copy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); + void Paste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard ); + + void Undo(); + void Redo(); + + sal_Bool Read( SvStream& rInput ); + + void SetStartDocPos( const Point& rPos ); + const Point& GetStartDocPos() const; + + Point GetDocPos( const Point& rWindowPos ) const; + Point GetWindowPos( const Point& rDocPos ) const; + + void SetInsertMode( sal_Bool bInsert ); + sal_Bool IsInsertMode() const; + + void SetAutoIndentMode( sal_Bool bAutoIndent ); + + void SetReadOnly( sal_Bool bReadOnly ); + sal_Bool IsReadOnly() const; + + void SetAutoScroll( sal_Bool bAutoScroll ); + sal_Bool IsAutoScroll() const; + + sal_Bool SetCursorAtPoint( const Point& rPointPixel ); + sal_Bool IsSelectionAtPoint( const Point& rPointPixel ); + + void SetPaintSelection( sal_Bool bPaint); + + void EraseVirtualDevice(); + + // aus dem protected Teil hierher verschoben + // F�r 'SvtXECTextCursor' (TL). Mu� ggf nochmal anders gel�st werden. + TextPaM PageUp( const TextPaM& rPaM ); + TextPaM PageDown( const TextPaM& rPaM ); + TextPaM CursorUp( const TextPaM& rPaM ); + TextPaM CursorDown( const TextPaM& rPaM ); + TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); + TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); + TextPaM CursorWordLeft( const TextPaM& rPaM ); + TextPaM CursorWordRight( const TextPaM& rPaM ); + TextPaM CursorStartOfLine( const TextPaM& rPaM ); + TextPaM CursorEndOfLine( const TextPaM& rPaM ); + TextPaM CursorStartOfParagraph( const TextPaM& rPaM ); + TextPaM CursorEndOfParagraph( const TextPaM& rPaM ); + TextPaM CursorStartOfDoc(); + TextPaM CursorEndOfDoc(); + + /** + Drag and Drop, deleting and selection regards all text that has an attribute + TEXTATTR_PROTECTED set as one entitity. Drag and dropped text is automatically + attibuted as protected. + */ + void SupportProtectAttribute(sal_Bool bSupport); + + /** + Returns the number in paragraph of the line in which the cursor is blinking + if enabled, -1 otherwise. + */ + sal_Int32 GetLineNumberOfCursorInSelection() const; +}; + +#endif // _TEXTVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx new file mode 100644 index 000000000000..83198187ce1c --- /dev/null +++ b/include/vcl/threadex.hxx @@ -0,0 +1,261 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#include <osl/conditn.h> +#include <osl/thread.h> +#include <tools/link.hxx> +#include <vcl/dllapi.h> + +#include "cppuhelper/exc_hlp.hxx" +#include "boost/optional.hpp" +#include <memory> + +namespace vcl +{ + 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/include/vcl/throbber.hxx b/include/vcl/throbber.hxx new file mode 100644 index 000000000000..f2995d7555bc --- /dev/null +++ b/include/vcl/throbber.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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< 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx new file mode 100644 index 000000000000..606367277a27 --- /dev/null +++ b/include/vcl/timer.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_TIMER_HXX +#define _SV_TIMER_HXX + +#include <tools/link.hxx> +#include <tools/solar.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 ); + + static void ImplDeInitTimer(); + static void ImplTimerCallbackProc(); +}; + +// ------------- +// - 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/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx new file mode 100644 index 000000000000..3b1f69e36477 --- /dev/null +++ b/include/vcl/toolbox.hxx @@ -0,0 +1,606 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_TOOLBOX_HXX +#define _SV_TOOLBOX_HXX + +#include <tools/solar.h> +#include <rsc/rsc-vcl-shared-types.hxx> +#include <vcl/dllapi.h> +#include <vcl/dockwin.hxx> +#include <vcl/image.hxx> +#include <vcl/timer.hxx> +#include <vector> + +class UserDrawEvent; + +struct ImplToolItem; +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; +} + +// ----------------- +// - ToolBox-Types - +// ----------------- + +#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 + +// 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 }; + +// TBX_LAYOUT_NORMAL - traditional layout, items are centered in the toolbar +// TBX_LAYOUT_LOCKVERT - special mode (currently used for calc input/formula +// bar) where item's vertical position is locked, e.g. +// toolbox is prevented from centering the items +enum ToolBoxLayoutMode { TBX_LAYOUT_NORMAL, TBX_LAYOUT_LOCKVERT }; + +struct ImplToolSize +{ + long mnWidth; + long mnHeight; + sal_uInt16 mnLines; +}; + +// ----------- +// - ToolBox - +// ----------- + +class VCL_DLLPUBLIC ToolBox : public DockingWindow +{ + friend class FloatingWindow; + friend class ImplTBDragMgr; + +private: + ImplToolBoxPrivateData* mpData; + std::vector<ImplToolSize> maFloatSizes; + ImageList maImageList; + Timer maTimer; + Rectangle maUpperRect; + Rectangle maLowerRect; + 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 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, + 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; + ToolBoxLayoutMode meLayoutMode; + Link maClickHdl; + Link maDoubleClickHdl; + Link maActivateHdl; + Link maDeactivateHdl; + Link maHighlightHdl; + Link maSelectHdl; + Link maCommandHandler; + Link maStateChangedHandler; + Link maDataChangedHandler; + + 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 ImplDrawSeparator( sal_uInt16 nPos, Rectangle rRect ); + SAL_DLLPRIVATE void ImplDrawItem( sal_uInt16 nPos, sal_uInt16 nHighlight = 0, 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 const OUString 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 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 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(); + 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, void* ); + + // 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 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 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 CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId, + sal_uInt16 nNewPos = TOOLBOX_APPEND ); + void Clear(); + + 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_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; + + // 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; + 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 ); + void SetItemImageMirrorMode( sal_uInt16 nItemId, sal_Bool bMirror ); + 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 ); + + 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 OString& rHelpId ); + 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 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; } + sal_Bool IsInCustomizeMode() const { return mbCustomizeMode; } + + void SetHelpText( const XubString& rText ) + { DockingWindow::SetHelpText( rText ); } + const XubString& GetHelpText() const + { return DockingWindow::GetHelpText(); } + + void SetHelpId( const OString& rId ) + { DockingWindow::SetHelpId( rId ); } + const 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 SetCommandHdl( const Link& aLink ) { maCommandHandler = aLink; } + const Link& GetCommandHdl() const { return maCommandHandler; } + void SetStateChangedHdl( const Link& aLink ) { maStateChangedHandler = aLink; } + const Link& GetStateChangedHdl() const { return maStateChangedHandler; } + void SetDataChangedHdl( const Link& aLink ) { maDataChangedHandler = aLink; } + const Link& GetDataChangedHdl() { return maDataChangedHandler; } + + // 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 UpdateCustomMenu(); + void SetMenuButtonHdl( const Link& rLink ); + + // 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 + OUString 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; + + const Size& GetDefaultImageSize() const; + void ChangeHighlight( sal_uInt16 nPos ); + + void SetImageListProvider(vcl::IImageListProvider* _pProvider); + void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout ); +}; + +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/include/vcl/txtattr.hxx b/include/vcl/txtattr.hxx new file mode 100644 index 000000000000..feb6131d12ee --- /dev/null +++ b/include/vcl/txtattr.hxx @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _TXTATTR_HXX +#define _TXTATTR_HXX + +#include <vcl/dllapi.h> +#include <tools/color.hxx> +#include <vcl/vclenum.hxx> +#include <tools/string.hxx> +#include <tools/debug.hxx> + +class Font; + +#define TEXTATTR_INVALID 0 +#define TEXTATTR_FONTCOLOR 1 +#define TEXTATTR_HYPERLINK 2 +#define TEXTATTR_FONTWEIGHT 3 + +#define TEXTATTR_USER_START 1000 //start id for user defined text attributes +#define TEXTATTR_PROTECTED 4 + + +class VCL_DLLPUBLIC TextAttrib +{ +private: + sal_uInt16 mnWhich; + +protected: + TextAttrib( sal_uInt16 nWhich ) { mnWhich = nWhich; } + TextAttrib( const TextAttrib& rAttr ) { mnWhich = rAttr.mnWhich; } + +public: + + virtual ~TextAttrib(); + + sal_uInt16 Which() const { return mnWhich; } + virtual void SetFont( Font& rFont ) const = 0; + virtual TextAttrib* Clone() const = 0; + + virtual int operator==( const TextAttrib& rAttr ) const = 0; + int operator!=( const TextAttrib& rAttr ) const + { return !(*this == rAttr ); } +}; + + + +class VCL_DLLPUBLIC TextAttribFontColor : public TextAttrib +{ +private: + Color maColor; + +public: + TextAttribFontColor( const Color& rColor ); + TextAttribFontColor( const TextAttribFontColor& rAttr ); + ~TextAttribFontColor(); + + const Color& GetColor() const { return maColor; } + + virtual void SetFont( Font& rFont ) const; + virtual TextAttrib* Clone() const; + virtual int operator==( const TextAttrib& rAttr ) const; + +}; + +class VCL_DLLPUBLIC TextAttribFontWeight : public TextAttrib +{ +private: + FontWeight meWeight; + +public: + TextAttribFontWeight( FontWeight eWeight ); + TextAttribFontWeight( const TextAttribFontWeight& rAttr ); + ~TextAttribFontWeight(); + + virtual void SetFont( Font& rFont ) const; + virtual TextAttrib* Clone() const; + virtual int operator==( const TextAttrib& rAttr ) const; + + inline FontWeight getFontWeight() const { return meWeight; } +}; + + +class TextAttribHyperLink : public TextAttrib +{ +private: + XubString maURL; + XubString maDescription; + Color maColor; + +public: + TextAttribHyperLink( const TextAttribHyperLink& rAttr ); + ~TextAttribHyperLink(); + + void SetURL( const XubString& rURL ) { maURL = rURL; } + const XubString& GetURL() const { return maURL; } + + void SetDescription( const XubString& rDescr ) { maDescription = rDescr; } + const XubString& GetDescription() const { return maDescription; } + + void SetColor( const Color& rColor ) { maColor = rColor; } + const Color& GetColor() const { return maColor; } + + virtual void SetFont( Font& rFont ) const; + virtual TextAttrib* Clone() const; + virtual int operator==( const TextAttrib& rAttr ) const; +}; + +class VCL_DLLPUBLIC TextAttribProtect : public TextAttrib +{ +public: + TextAttribProtect(); + TextAttribProtect( const TextAttribProtect& rAttr ); + ~TextAttribProtect(); + + virtual void SetFont( Font& rFont ) const; + virtual TextAttrib* Clone() const; + virtual int operator==( const TextAttrib& rAttr ) const; + +}; + + +class TextCharAttrib +{ +private: + TextAttrib* mpAttr; + sal_uInt16 mnStart; + sal_uInt16 mnEnd; + +protected: + +public: + + TextCharAttrib( const TextAttrib& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd ); + TextCharAttrib( const TextCharAttrib& rTextCharAttrib ); + ~TextCharAttrib(); + + const TextAttrib& GetAttr() const { return *mpAttr; } + + sal_uInt16 Which() const { return mpAttr->Which(); } + + sal_uInt16 GetStart() const { return mnStart; } + sal_uInt16& GetStart() { return mnStart; } + + sal_uInt16 GetEnd() const { return mnEnd; } + sal_uInt16& GetEnd() { return mnEnd; } + + inline sal_uInt16 GetLen() const; + + inline void MoveForward( sal_uInt16 nDiff ); + inline void MoveBackward( sal_uInt16 nDiff ); + + inline void Expand( sal_uInt16 nDiff ); + inline void Collaps( sal_uInt16 nDiff ); + + inline sal_Bool IsIn( sal_uInt16 nIndex ); + inline sal_Bool IsInside( sal_uInt16 nIndex ); + inline sal_Bool IsEmpty(); + +}; + +inline sal_uInt16 TextCharAttrib::GetLen() const +{ + DBG_ASSERT( mnEnd >= mnStart, "TextCharAttrib: nEnd < nStart!" ); + return mnEnd-mnStart; +} + +inline void TextCharAttrib::MoveForward( sal_uInt16 nDiff ) +{ + DBG_ASSERT( ((long)mnEnd + nDiff) <= 0xFFFF, "TextCharAttrib: MoveForward?!" ); + mnStart = mnStart + nDiff; + mnEnd = mnEnd + nDiff; +} + +inline void TextCharAttrib::MoveBackward( sal_uInt16 nDiff ) +{ + DBG_ASSERT( ((long)mnStart - nDiff) >= 0, "TextCharAttrib: MoveBackward?!" ); + mnStart = mnStart - nDiff; + mnEnd = mnEnd - nDiff; +} + +inline void TextCharAttrib::Expand( sal_uInt16 nDiff ) +{ + DBG_ASSERT( ( ((long)mnEnd + nDiff) <= (long)0xFFFF ), "TextCharAttrib: Expand?!" ); + mnEnd = mnEnd + nDiff; +} + +inline void TextCharAttrib::Collaps( sal_uInt16 nDiff ) +{ + DBG_ASSERT( (long)mnEnd - nDiff >= (long)mnStart, "TextCharAttrib: Collaps?!" ); + mnEnd = mnEnd - nDiff; +} + +inline sal_Bool TextCharAttrib::IsIn( sal_uInt16 nIndex ) +{ + return ( ( mnStart <= nIndex ) && ( mnEnd >= nIndex ) ); +} + +inline sal_Bool TextCharAttrib::IsInside( sal_uInt16 nIndex ) +{ + return ( ( mnStart < nIndex ) && ( mnEnd > nIndex ) ); +} + +inline sal_Bool TextCharAttrib::IsEmpty() +{ + return mnStart == mnEnd; +} + +#endif // _TXTATTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/unohelp.hxx b/include/vcl/unohelp.hxx new file mode 100644 index 000000000000..91168436c3ad --- /dev/null +++ b/include/vcl/unohelp.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 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::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 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/include/vcl/unohelp2.hxx b/include/vcl/unohelp2.hxx new file mode 100644 index 000000000000..138ad507d656 --- /dev/null +++ b/include/vcl/unohelp2.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/vcl/unowrap.hxx b/include/vcl/unowrap.hxx new file mode 100644 index 000000000000..9632728eac6a --- /dev/null +++ b/include/vcl/unowrap.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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 EventList; +class Window; +class OutputDevice; +class MouseEvent; +class CommandEvent; +class KeyEvent; +class Rectangle; +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; + +protected: + ~UnoWrapperBase() {} +}; + +#endif // _VCL_UNOWRAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx new file mode 100644 index 000000000000..e0760b131c01 --- /dev/null +++ b/include/vcl/vclenum.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCL_VCLENUM_HXX +#define _VCL_VCLENUM_HXX + +#include <sal/types.h> +#include <tools/solar.h> +#include <tools/fontenum.hxx> +#include <rsc/rsc-vcl-shared-types.hxx> + +// ------------------------------------------------------------ + +enum ExtTimeFieldFormat { EXTTIMEF_24H_SHORT, EXTTIMEF_24H_LONG, + EXTTIMEF_12H_SHORT, EXTTIMEF_12H_LONG, + EXTTIMEF_DURATION_SHORT, EXTTIMEF_DURATION_LONG }; + +// ------------------------------------------------------------ + +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 }; + +// ------------------------------------------------------------ + +enum GradientStyle +{ + GradientStyle_LINEAR = 0, + GradientStyle_AXIAL = 1, + GradientStyle_RADIAL = 2, + GradientStyle_ELLIPTICAL = 3, + GradientStyle_SQUARE = 4, + GradientStyle_RECT = 5, + GradientStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +// ------------------------------------------------------------ + +// 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 + +enum HatchStyle +{ + HATCH_SINGLE = 0, + HATCH_DOUBLE = 1, + HATCH_TRIPLE = 2, + HatchStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +// ------------------------------------------------------------ + +// 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 + +enum LineStyle +{ + LINE_NONE = 0, + LINE_SOLID = 1, + LINE_DASH = 2, + LineStyle_FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +// ------------------------------------------------------------ + +enum RasterOp { ROP_OVERPAINT, ROP_XOR, ROP_0, ROP_1, ROP_INVERT }; + +// ------------------------------------------------------------ + +enum FontAutoHint { AUTOHINT_DONTKNOW, AUTOHINT_FALSE, AUTOHINT_TRUE }; + +enum FontHinting { HINTING_DONTKNOW, HINTING_FALSE, HINTING_TRUE }; + +enum FontHintStyle { HINT_NONE, HINT_SLIGHT, HINT_MEDIUM, HINT_FULL }; + +// ------------------------------------------------------------ + +typedef sal_uInt32 sal_UCS4; // TODO: this should be moved to rtl + +enum OutDevSupportType { OutDevSupport_TransparentRect, OutDevSupport_B2DClip, OutDevSupport_B2DDraw }; + +struct ItalicMatrix +{ + double xx, xy, yx, yy; + ItalicMatrix() : xx(1), xy(0), yx(0), yy(1) {} +}; + +inline bool operator ==(const ItalicMatrix& a, const ItalicMatrix& b) +{ + return a.xx == b.xx && a.xy == b.xy && a.yx == b.yx && a.yy == b.yy; +} + +inline bool operator !=(const ItalicMatrix& a, const ItalicMatrix& b) +{ + return a.xx != b.xx || a.xy != b.xy || a.yx != b.yx || a.yy != b.yy; +} + +enum VclAlign +{ + VCL_ALIGN_FILL, + VCL_ALIGN_START, + VCL_ALIGN_END, + VCL_ALIGN_CENTER +}; + +enum VclPackType +{ + VCL_PACK_START = 0, + VCL_PACK_END = 1 +}; + +#endif // _VCL_VCLENUM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclevent.hxx b/include/vcl/vclevent.hxx new file mode 100644 index 000000000000..bc4fa01362c2 --- /dev/null +++ b/include/vcl/vclevent.hxx @@ -0,0 +1,289 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#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* +#define VCLEVENT_WINDOW_ZOOM 1023 // pData = ZoomEvent* +#define VCLEVENT_WINDOW_SCROLL 1024 // pData = ScrollEvent* + +// 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 +// #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; } + virtual ~VclSimpleEvent() {} + 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; } + virtual ~VclWindowEvent() {} + TYPEINFO(); + + Window* GetWindow() const { return pWindow; } + void* GetData() const { return pData; } +}; + +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; } + virtual ~VclMenuEvent() {} + 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/include/vcl/vclmain.hxx b/include/vcl/vclmain.hxx new file mode 100644 index 000000000000..1b60cfba42ce --- /dev/null +++ b/include/vcl/vclmain.hxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_VCLMAIN_HXX +#define INCLUDED_VCL_VCLMAIN_HXX + +#include "sal/config.h" + +namespace vclmain { + +// Function called from vclmain's implementation of main, needs to be +// implemented by the application and needs to instantiate a (static, derived) +// instance of Application (where the Application constructor takes care to link +// that instance to ImplSVData.mpApp): +void createApplication(); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx new file mode 100644 index 000000000000..63caa3b4c352 --- /dev/null +++ b/include/vcl/vclmedit.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _VCLMEDIT_HXX +#define _VCLMEDIT_HXX + +#include <tools/wintypes.hxx> +#include <vcl/edit.hxx> +#include <vcl/dllapi.h> + + +class ImpVclMEdit; +class Timer; +class ExtTextEngine; +class ExtTextView; + +class VCL_DLLPUBLIC VclMultiLineEdit : public Edit +{ +private: + ImpVclMEdit* pImpVclMEdit; + + OUString aSaveValue; + Link aModifyHdlLink; + + Timer* pUpdateDataTimer; + Link aUpdateDataHdlLink; + +protected: + + DECL_LINK( ImpUpdateDataHdl, void* ); + void StateChanged( StateChangedType nType ); + void DataChanged( const DataChangedEvent& rDCEvt ); + virtual long PreNotify( NotifyEvent& rNEvt ); + long Notify( NotifyEvent& rNEvt ); + using Control::ImplInitSettings; + void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ); + WinBits ImplInitStyle( WinBits nStyle ); + + ExtTextEngine* GetTextEngine() const; + ExtTextView* GetTextView() const; + ScrollBar* GetVScrollBar() const; + +public: + VclMultiLineEdit( Window* pParent, WinBits nWinStyle = WB_LEFT | WB_BORDER ); + VclMultiLineEdit( Window* pParent, const ResId& rResId ); + virtual ~VclMultiLineEdit(); + + + virtual void Modify(); + virtual void UpdateData(); + + virtual void SetModifyFlag(); + virtual void ClearModifyFlag(); + virtual sal_Bool IsModified() const; + + virtual void EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT ); + virtual void DisableUpdateData() { delete pUpdateDataTimer; pUpdateDataTimer = NULL; } + virtual sal_uLong IsUpdateDataEnabled() const; + + virtual void SetReadOnly( sal_Bool bReadOnly = sal_True ); + virtual sal_Bool IsReadOnly() const; + + void EnableFocusSelectionHide( sal_Bool bHide ); + + virtual void SetMaxTextLen( xub_StrLen nMaxLen = 0 ); + virtual xub_StrLen GetMaxTextLen() const; + + virtual void SetSelection( const Selection& rSelection ); + virtual const Selection& GetSelection() const; + + virtual void ReplaceSelected( const OUString& rStr ); + virtual void DeleteSelected(); + virtual OUString GetSelected() const; + virtual OUString GetSelected( LineEnd aSeparator ) const; + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + + virtual void SetText( const OUString& rStr ); + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) + { SetText( rStr ); SetSelection( rNewSelection ); } + OUString GetText() const; + OUString GetText( LineEnd aSeparator ) const; + String GetTextLines( LineEnd aSeparator ) const; + + void SetRightToLeft( sal_Bool bRightToLeft ); + sal_Bool IsRightToLeft() const; + + void SaveValue() { aSaveValue = GetText(); } + const OUString& GetSavedValue() const { return aSaveValue; } + + void SetModifyHdl( const Link& rLink ) { aModifyHdlLink = rLink; } + const Link& GetModifyHdl() const { return aModifyHdlLink; } + + void SetUpdateDataHdl( const Link& rLink ) { aUpdateDataHdlLink = rLink; } + + virtual void Resize(); + virtual void GetFocus(); + + Size CalcMinimumSize() 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 Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); + + void SetLeftMargin( sal_uInt16 n ); + + void DisableSelectionOnFocus(); + + void SetTextSelectable( sal_Bool bTextSelectable ); + void EnableCursor( sal_Bool bEnable ); + + virtual bool set_property(const OString &rKey, const OString &rValue); +}; + +inline sal_uLong VclMultiLineEdit::IsUpdateDataEnabled() const +{ + return pUpdateDataTimer ? pUpdateDataTimer->GetTimeout() : 0; +} + +#endif //_VCLMEDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx new file mode 100644 index 000000000000..5d8a70e8f3dc --- /dev/null +++ b/include/vcl/virdev.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_VIRDEV_HXX +#define _SV_VIRDEV_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <basebmp/bitmapdevice.hxx> + +// ----------------- +// - VirtualDevice - +// ----------------- + +class SalVirtualDevice; +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 InnerImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer ); + SAL_DLLPRIVATE sal_Bool ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase, const basebmp::RawMemorySharedArray &pBuffer ); + + // 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: + /** Create a virtual device of size 1x1 + + @param nBitCount + Bit depth of the generated virtual device. Use 0 here, to + indicate: take default screen depth. Only 0, 1 and 8 + are allowed here, with 1 denoting binary mask and 8 a graylevel mask. + */ + VirtualDevice( sal_uInt16 nBitCount = 0 ); + + /** Create a virtual device of size 1x1 + + @param rCompDev + The generated vdev will be compatible to this device. + + @param nBitCount + Bit depth of the generated virtual device. Use 0 here, to + indicate: take default screen depth. Only 0 and 1 + are allowed here, with 1 denoting binary mask. + */ + VirtualDevice( const OutputDevice& rCompDev, + sal_uInt16 nBitCount = 0 ); + + /** Create a virtual device of size 1x1 with alpha channel + + @param rCompDev + The generated vdev will be compatible to this device. + + @param nBitCount + Bit depth of the generated virtual device. Use 0 here, to + indicate: take default screen depth. 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. 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 SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer ); + 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_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/include/vcl/waitobj.hxx b/include/vcl/waitobj.hxx new file mode 100644 index 000000000000..d9164a9a61b0 --- /dev/null +++ b/include/vcl/waitobj.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_WAITOBJ_HXX +#define _SV_WAITOBJ_HXX + +#include <tools/solar.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/include/vcl/wall.hxx b/include/vcl/wall.hxx new file mode 100644 index 000000000000..e18adf78f60b --- /dev/null +++ b/include/vcl/wall.hxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_WALL_HXX +#define _SV_WALL_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> +#include <tools/gen.hxx> + +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 ); + BitmapEx GetBitmap() const; + sal_Bool IsBitmap() const; + + void SetGradient( const Gradient& rGradient ); + Gradient GetGradient() const; + sal_Bool IsGradient() const; + + void SetRect( const Rectangle& rRect ); + 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/include/vcl/window.hxx b/include/vcl/window.hxx new file mode 100644 index 000000000000..43e232dab55c --- /dev/null +++ b/include/vcl/window.hxx @@ -0,0 +1,1279 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_WINDOW_HXX +#define _SV_WINDOW_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <tools/resid.hxx> +#include <vcl/pointr.hxx> +#include <tools/wintypes.hxx> +#include <rsc/rsc-vcl-shared-types.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 FixedText; +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; +} + +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_EXTENDEDSTYLE ((StateChangedType)17) +#define STATE_CHANGE_MIRRORING ((StateChangedType)18) +#define STATE_CHANGE_CONTROL_FOCUS ((StateChangedType)20) +#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) + +// 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 + +// ---------- +// - Window - +// ---------- + +#ifdef DBG_UTIL +const char* ImplDbgCheckWindow( const void* pObj ); +#endif + +class Dialog; +class WindowImpl; +class VclBuilder; +class VclSizeGroup; + +struct WindowResHeader +{ + sal_uLong nObjMask; + OString aHelpId; + sal_uLong nRSStyle; +}; + +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; + friend class VclBuilder; + + // 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 WinBits ImplInitRes( const ResId& rResId ); + SAL_DLLPRIVATE WindowResHeader ImplLoadResHeader( const ResId& rResId ); + SAL_DLLPRIVATE void ImplLoadRes( 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(); + 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 sal_Bool ImplIsDockingWindow() const; + SAL_DLLPRIVATE sal_Bool ImplIsFloatingWindow() const; + SAL_DLLPRIVATE sal_Bool ImplIsSplitter() const; + SAL_DLLPRIVATE sal_Bool ImplIsPushButton() const; + SAL_DLLPRIVATE sal_Bool ImplIsOverlapWindow() 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 sal_Bool ImplSysObjClip( const Region* pOldRegion ); + SAL_DLLPRIVATE void ImplUpdateSysObjChildrenClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjOverlapsClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjClip(); + SAL_DLLPRIVATE sal_Bool ImplSetClipFlagChildren( 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 ImplClipChildren( Region& rRegion ); + SAL_DLLPRIVATE void ImplClipAllChildren( 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 bChildren, 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 bChildren ); + SAL_DLLPRIVATE void ImplMoveAllInvalidateRegions( const Rectangle& rRect, long nHorzScroll, long nVertScroll, sal_Bool bChildren ); + 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; } + + /** 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 ImplAlignChildren(); + 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 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( 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 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 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 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(); + + // These eventually are supposed to go when everything is converted to .ui + SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationMemberOf() const; + SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationLabeledBy() const; + SAL_DLLPRIVATE Window* getLegacyNonLayoutAccessibleRelationLabelFor() const; + + // Let Label override the code part of GetAccessibleRelationLabelFor + virtual Window* getAccessibleRelationLabelFor() const; + virtual sal_uInt16 getDefaultAccessibleRole() const; + virtual OUString getDefaultAccessibleName() const; +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( const Link& rLink, void* pCaller = NULL ); + sal_Bool PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller = NULL ); + void RemoveUserEvent( sal_uLong nUserEvent ); + + void IncrementLockCount(); + void DecrementLockCount(); + sal_Bool IsLocked( sal_Bool bChildren = 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; + 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 ); + + 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 ); + + 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 ); + void SetCursorRect( const Rectangle* pRect = NULL, long nExtTextInputWidth = 0 ); + const Rectangle* GetCursorRect() const; + long GetCursorExtTextInputWidth() 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 NotifyAllChildren( 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; + // return the dialog we are contained in or NULL if un-contained + Dialog* GetParentDialog() 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; + 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 ); + + /** 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 working 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; + + /** + * Necessary for calc ref input handling from modal dialogs + */ + bool IsInModalNonRefMode() 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 ); + 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 ); + + 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; + + 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 ); + void SetPointerPosPixel( const Point& rPos ); + Point GetPointerPosPixel(); + Point GetLastPointerPosPixel(); + void ShowPointer( sal_Bool bVisible ); + 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 OUString& rStr ); + virtual OUString GetText() const; + // return the actual text displayed + // this may have e.g. accellerators removed or portions + // replaced by ellipsis + virtual OUString 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 OString& ); + const OString& GetHelpId() const; + + void SetUniqueId( const OString& ); + const OString& GetUniqueId() 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; + + 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 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 to set/query the component interfaces + 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; + + /* records all DrawText operations within the passed rectangle; + * a synchronous paint is sent to achieve this + */ + void RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect ); + + // set and retrieve for Toolkit + VCLXWindow* GetWindowPeer() const; + void SetWindowPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow ); + + // remember if it was generated by Toolkit + 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(); + + // 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 + * + * Retrieves the preferred size of a widget ignoring + * "width-request" and "height-request" properties. + * + * Implement this in sub-classes to tell layout + * the preferred widget size. + */ + virtual Size GetOptimalSize() const; + + /* + * Widgets call this to inform their owner container that the widget wants + * to renegotiate its size. Should be called when a widget has a new size + * request. e.g. a FixedText Control gets a new label. + * + * akin to gtk_widget_queue_resize + */ + void queue_resize(); + + /* + * Sets the "width-request" property + * + * Override for width request of the widget, or -1 if natural request + * should be used. + * + * @see get_preferred_size, set_width_request + */ + void set_height_request(sal_Int32 nHeightRequest); + sal_Int32 get_height_request() const; + + /* + * Sets the "height-request" property + * + * Override for height request of the widget, or -1 if natural request + * should be used. + * + * @see get_preferred_size, set_height_request + */ + void set_width_request(sal_Int32 nWidthRequest); + sal_Int32 get_width_request() const; + + /* + * Retrieves the preferred size of a widget taking + * into account the "width-request" and "height-request" properties. + * + * Overrides the result of GetOptimalSize to honor the + * width-request and height-request properties. + * + * @see GetOptimalSize + * + * akin to gtk_widget_get_preferred_size + */ + Size get_preferred_size() const; + + /* + * How to horizontally align this widget + */ + VclAlign get_halign() const; + void set_halign(VclAlign eAlign); + + /* + * How to vertically align this widget + */ + VclAlign get_valign() const; + void set_valign(VclAlign eAlign); + + /* + * Whether the widget would like to use any available extra horizontal + * space. + */ + bool get_hexpand() const; + void set_hexpand(bool bExpand); + + /* + * Whether the widget would like to use any available extra vertical + * space. + */ + bool get_vexpand() const; + void set_vexpand(bool bExpand); + + /* + * Whether the widget would like to use any available extra space. + */ + bool get_expand() const; + void set_expand(bool bExpand); + + /* + * Whether the widget should receive extra space when the parent grows + */ + bool get_fill() const; + void set_fill(bool bFill); + + void set_border_width(sal_Int32 nBorderWidth); + sal_Int32 get_border_width() const; + + void set_margin_left(sal_Int32 nWidth); + sal_Int32 get_margin_left() const; + + void set_margin_right(sal_Int32 nWidth); + sal_Int32 get_margin_right() const; + + void set_margin_top(sal_Int32 nWidth); + sal_Int32 get_margin_top() const; + + void set_margin_bottom(sal_Int32 nWidth); + sal_Int32 get_margin_bottom() const; + + /* + * How the widget is packed with reference to the start or end of the parent + */ + VclPackType get_pack_type() const; + void set_pack_type(VclPackType ePackType); + + /* + * The extra space to put between the widget and its neighbors + */ + sal_Int32 get_padding() const; + void set_padding(sal_Int32 nPadding); + + /* + * The number of columns that the widget spans + */ + sal_Int32 get_grid_width() const; + void set_grid_width(sal_Int32 nCols); + + /* + * The column number to attach the left side of the widget to + */ + sal_Int32 get_grid_left_attach() const; + void set_grid_left_attach(sal_Int32 nAttach); + + /* + * The number of row that the widget spans + */ + sal_Int32 get_grid_height() const; + void set_grid_height(sal_Int32 nRows); + + /* + * The row number to attach the top side of the widget to + */ + sal_Int32 get_grid_top_attach() const; + void set_grid_top_attach(sal_Int32 nAttach); + + /* + * If true this child appears in a secondary layout group of children + * e.g. help buttons in a buttonbox + */ + bool get_secondary() const; + void set_secondary(bool bSecondary); + + /* + * Sets a widget property + * + * @return false if property is unknown + */ + virtual bool set_property(const OString &rKey, const OString &rValue); + + /* + * Sets a font attribute + * + * @return false if attribute is unknown + */ + bool set_font_attribute(const OString &rKey, const OString &rValue); + + /* + * Adds this widget to the xGroup VclSizeGroup + * + */ + void add_to_size_group(boost::shared_ptr< VclSizeGroup > xGroup); + void remove_from_all_size_groups(); + + /* + * add/remove mnemonic label + */ + void add_mnemonic_label(FixedText *pLabel); + void remove_mnemonic_label(FixedText *pLabel); + std::vector<FixedText*> list_mnemonic_labels() const; + + /* + * Move this widget to be the nNewPosition'd child of its parent + */ + void reorderWithinParent(sal_uInt16 nNewPosition); + + //------------------------------------- + // 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; + + virtual OUString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; +}; + + +#endif // _SV_WINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wmf.hxx b/include/vcl/wmf.hxx new file mode 100644 index 000000000000..ed0b5e27fd50 --- /dev/null +++ b/include/vcl/wmf.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _WMF_HXX +#define _WMF_HXX + +#include <vcl/dllapi.h> + +class FilterConfigItem; +class GDIMetaFile; +class SvStream; + +struct WMF_EXTERNALHEADER +{ + sal_uInt16 xExt; + sal_uInt16 yExt; + + /** One of the following values: + <ul> + <li>MM_TEXT</li> + <li>MM_LOMETRIC</li> + <li>MM_HIMETRIC</li> + <li>MM_LOENGLISH</li> + <li>MM_HIENGLISH</li> + <li>MM_TWIPS</li> + <li>MM_ISOTROPIC</li> + <li>MM_ANISOTROPIC</li> + </ul> + If this value is 0, then no external mapmode has been defined, + the internal one should then be used. + */ + sal_uInt16 mapMode; + + WMF_EXTERNALHEADER() : + xExt( 0 ), + yExt( 0 ), + mapMode( 0 ) + { + } +}; + +sal_Bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL, WMF_EXTERNALHEADER *pExtHeader = NULL ); + +VCL_DLLPUBLIC sal_Bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pConfigItem ); + +VCL_DLLPUBLIC sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pConfigItem = NULL, sal_Bool bPlaceable = sal_True ); + +sal_Bool ConvertGDIMetaFileToEMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pConfigItem = NULL ); + +VCL_DLLPUBLIC sal_Bool WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wrkwin.hxx b/include/vcl/wrkwin.hxx new file mode 100644 index 000000000000..d151d1f12232 --- /dev/null +++ b/include/vcl/wrkwin.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SV_WRKWIN_HXX +#define _SV_WRKWIN_HXX + +#include <tools/solar.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 ImplSetFrameState( sal_uLong aFrameState ); + +public: + 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(); + + void ShowFullScreenMode( sal_Bool bFullScreenMode, + sal_Int32 nDisplayScreen ); + /** + @overload Calls ShowFullScreenMode( bFullScreenMode, GetScreenNumber()). + */ + void ShowFullScreenMode( sal_Bool bFullScreenMode = sal_True ); + void EndFullScreenMode() { ShowFullScreenMode( sal_False ); } + sal_Bool IsFullScreenMode() const { return mbFullScreenMode; } + + void StartPresentationMode( sal_Bool bPresentation, + sal_uInt16 nFlags, + sal_Int32 nDisplayScreen ); + /** + @overload Calls StartPresentationMode( bFullScreenMode, nFlags, GetScreenNumber()). + */ + void StartPresentationMode( sal_Bool bPresentation = sal_True, + sal_uInt16 nFlags = 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/include/vcl/xtextedt.hxx b/include/vcl/xtextedt.hxx new file mode 100644 index 000000000000..b763e37102c7 --- /dev/null +++ b/include/vcl/xtextedt.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _XTEXTEDT_HXX +#define _XTEXTEDT_HXX + +#include <vcl/dllapi.h> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> + +namespace com { +namespace sun { +namespace star { +namespace util { + struct SearchOptions; +}}}} + +class VCL_DLLPUBLIC ExtTextEngine : public TextEngine +{ +private: + String maGroupChars; + +public: + ExtTextEngine(); + ~ExtTextEngine(); + + const String& GetGroupChars() const { return maGroupChars; } + void SetGroupChars( const String& r ) { maGroupChars = r; } + TextSelection MatchGroup( const TextPaM& rCursor ) const; + + sal_Bool Search( TextSelection& rSel, const ::com::sun::star::util::SearchOptions& rSearchOptions, sal_Bool bForward = sal_True ); +}; + +class VCL_DLLPUBLIC ExtTextView : public TextView +{ +protected: + sal_Bool ImpIndentBlock( sal_Bool bRight ); + +public: + ExtTextView( ExtTextEngine* pEng, Window* pWindow ); + ~ExtTextView(); + + sal_Bool MatchGroup(); + + sal_Bool Search( const ::com::sun::star::util::SearchOptions& rSearchOptions, sal_Bool bForward ); + sal_uInt16 Replace( const ::com::sun::star::util::SearchOptions& rSearchOptions, sal_Bool bAll, sal_Bool bForward ); + + sal_Bool IndentBlock(); + sal_Bool UnindentBlock(); +}; + +#endif // _XTEXTEDT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |