diff options
author | Mark Page <aptitude@btconnect.com> | 2016-05-18 08:33:33 +0100 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-23 11:30:15 +0000 |
commit | d64431ac5a7bede7661c64e0bd6d46805841e704 (patch) | |
tree | 8c2428460af63e2417d36508d8ea5ce3e1a45d96 /include/vcl/gfxlink.hxx | |
parent | cffc2471bc7d08f27a995e4e0f6fcf49d74d0f5a (diff) |
Simplify GfxLink using std::shared_ptr to clarify ownership
The functionality has not changed in this class, however the ABI
has changed (this class is DLL Public)
Change-Id: I11005f03e747d56cb59550e071755429390db7a7
Reviewed-on: https://gerrit.libreoffice.org/25081
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'include/vcl/gfxlink.hxx')
-rw-r--r-- | include/vcl/gfxlink.hxx | 98 |
1 files changed, 30 insertions, 68 deletions
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx index 3bdb4b79595a..aa0e8fea37a2 100644 --- a/include/vcl/gfxlink.hxx +++ b/include/vcl/gfxlink.hxx @@ -25,56 +25,10 @@ #include <tools/solar.h> #include <vcl/dllapi.h> #include <vcl/mapmod.hxx> +#include <memory> class SvStream; - -struct ImpBuffer -{ - sal_uLong mnRefCount; - sal_uInt8* mpBuffer; - - ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; } - - ~ImpBuffer() { delete[] mpBuffer; } -}; - - -struct ImpSwap -{ - OUString maURL; - sal_uLong mnDataSize; - sal_uLong mnRefCount; - - ImpSwap( sal_uInt8* pData, sal_uLong nDataSize ); - ~ImpSwap(); - - sal_uInt8* GetData() const; - - bool IsSwapped() const { return maURL.getLength() > 0; } - - void WriteTo( SvStream& rOStm ) const; -}; - - -struct ImpGfxLink -{ - MapMode maPrefMapMode; - Size maPrefSize; - bool mbPrefMapModeValid; - bool mbPrefSizeValid; - - ImpGfxLink() : - maPrefMapMode(), - maPrefSize(), - mbPrefMapModeValid( false ), - mbPrefSizeValid( false ) - {} -}; - -//#endif // __PRIVATE - - enum GfxLinkType { GFX_LINK_TYPE_NONE = 0, @@ -88,7 +42,6 @@ enum GfxLinkType 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_NATIVE_MOV = 10, // Don't forget to update the following defines - // #i15508# added BMP type support GFX_LINK_TYPE_NATIVE_BMP = 11, // Don't forget to update the following defines GFX_LINK_TYPE_USER = 0xffff }; @@ -96,49 +49,58 @@ enum GfxLinkType #define GFX_LINK_FIRST_NATIVE_ID GFX_LINK_TYPE_NATIVE_GIF #define GFX_LINK_LAST_NATIVE_ID GFX_LINK_TYPE_NATIVE_BMP - -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; + struct SwapOutData + { + SwapOutData(const OUString &aURL); + ~SwapOutData(); - SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink ); + OUString maURL; // File is removed in the destructor + }; + + GfxLinkType meType = GFX_LINK_TYPE_NONE; + sal_uInt32 mnUserId = 0; + + std::shared_ptr<sal_uInt8> mpSwapInData; + std::shared_ptr<SwapOutData> mpSwapOutData; + + sal_uInt32 mnSwapInDataSize = 0; + MapMode maPrefMapMode; + Size maPrefSize; + bool mbPrefMapModeValid = false; + bool mbPrefSizeValid = false; + + SAL_DLLPRIVATE std::shared_ptr<sal_uInt8> GetSwapInData() const; public: GfxLink(); - GfxLink( const GfxLink& ); + + // pBuff = The Graphic data. This class takes ownership of this GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType ); ~GfxLink(); - GfxLink& operator=( const GfxLink& ); - bool IsEqual( const GfxLink& ) const; + bool IsEqual( const GfxLink& ) const; GfxLinkType GetType() const { return meType;} void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } sal_uInt32 GetUserId() const { return mnUserId; } - sal_uInt32 GetDataSize() const { return mnBufSize;} + sal_uInt32 GetDataSize() const { return mnSwapInDataSize;} const sal_uInt8* GetData() const; - const Size& GetPrefSize() const { return mpImpData->maPrefSize;} + const Size& GetPrefSize() const { return maPrefSize;} void SetPrefSize( const Size& rPrefSize ); - bool IsPrefSizeValid() { return mpImpData->mbPrefSizeValid;} + bool IsPrefSizeValid() { return mbPrefSizeValid;} - const MapMode& GetPrefMapMode() const { return mpImpData->maPrefMapMode;} + const MapMode& GetPrefMapMode() const { return maPrefMapMode;} void SetPrefMapMode( const MapMode& rPrefMapMode ); - bool IsPrefMapModeValid() { return mpImpData->mbPrefMapModeValid;} + bool IsPrefMapModeValid() { return mbPrefMapModeValid;} bool IsNative() const; @@ -148,7 +110,7 @@ public: void SwapOut(); void SwapIn(); - bool IsSwappedOut() const { return( mpSwap != nullptr ); } + bool IsSwappedOut() const { return( bool(mpSwapOutData) ); } public: |