Kaydet (Commit) d64431ac authored tarafından Mark Page's avatar Mark Page Kaydeden (comit) Noel Grandin

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/25081Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst cffc2471
......@@ -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:
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment