|
|
|
@@ -27,57 +27,32 @@
|
|
|
|
|
#include <wall2.hxx>
|
|
|
|
|
#include <vcl/dibtools.hxx>
|
|
|
|
|
#include <vcl/settings.hxx>
|
|
|
|
|
#include <o3tl/make_unique.hxx>
|
|
|
|
|
|
|
|
|
|
ImplWallpaper::ImplWallpaper() :
|
|
|
|
|
maColor( COL_TRANSPARENT )
|
|
|
|
|
maColor( COL_TRANSPARENT ), meStyle( WallpaperStyle::NONE )
|
|
|
|
|
{
|
|
|
|
|
mpBitmap = nullptr;
|
|
|
|
|
mpCache = nullptr;
|
|
|
|
|
mpGradient = nullptr;
|
|
|
|
|
mpRect = nullptr;
|
|
|
|
|
meStyle = WallpaperStyle::NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImplWallpaper::ImplWallpaper( const ImplWallpaper& rImplWallpaper ) :
|
|
|
|
|
maColor( rImplWallpaper.maColor )
|
|
|
|
|
maColor( rImplWallpaper.maColor ), meStyle(rImplWallpaper.meStyle)
|
|
|
|
|
{
|
|
|
|
|
meStyle = rImplWallpaper.meStyle;
|
|
|
|
|
|
|
|
|
|
if ( rImplWallpaper.mpBitmap )
|
|
|
|
|
mpBitmap = new BitmapEx( *rImplWallpaper.mpBitmap );
|
|
|
|
|
else
|
|
|
|
|
mpBitmap = nullptr;
|
|
|
|
|
mpBitmap = o3tl::make_unique<BitmapEx>( *rImplWallpaper.mpBitmap );
|
|
|
|
|
|
|
|
|
|
if( rImplWallpaper.mpCache )
|
|
|
|
|
mpCache = new BitmapEx( *rImplWallpaper.mpCache );
|
|
|
|
|
else
|
|
|
|
|
mpCache = nullptr;
|
|
|
|
|
mpCache = o3tl::make_unique<BitmapEx>( *rImplWallpaper.mpCache );
|
|
|
|
|
|
|
|
|
|
if ( rImplWallpaper.mpGradient )
|
|
|
|
|
mpGradient = new Gradient( *rImplWallpaper.mpGradient );
|
|
|
|
|
else
|
|
|
|
|
mpGradient = nullptr;
|
|
|
|
|
mpGradient = o3tl::make_unique<Gradient>( *rImplWallpaper.mpGradient );
|
|
|
|
|
|
|
|
|
|
if ( rImplWallpaper.mpRect )
|
|
|
|
|
mpRect = new Rectangle( *rImplWallpaper.mpRect );
|
|
|
|
|
else
|
|
|
|
|
mpRect = nullptr;
|
|
|
|
|
mpRect = o3tl::make_unique<Rectangle>( *rImplWallpaper.mpRect );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImplWallpaper::~ImplWallpaper()
|
|
|
|
|
{
|
|
|
|
|
delete mpBitmap;
|
|
|
|
|
delete mpCache;
|
|
|
|
|
delete mpGradient;
|
|
|
|
|
delete mpRect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ImplWallpaper::operator==( const ImplWallpaper& rImplWallpaper ) const
|
|
|
|
|
{
|
|
|
|
|
if ( meStyle == rImplWallpaper.meStyle &&
|
|
|
|
|
maColor == rImplWallpaper.maColor &&
|
|
|
|
|
mpRect == rImplWallpaper.mpRect &&
|
|
|
|
|
mpBitmap == rImplWallpaper.mpBitmap &&
|
|
|
|
|
mpGradient == rImplWallpaper.mpGradient )
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
|
|
|
@@ -85,14 +60,9 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
|
|
|
|
VersionCompat aCompat( rIStm, StreamMode::READ );
|
|
|
|
|
sal_uInt16 nTmp16;
|
|
|
|
|
|
|
|
|
|
delete rImplWallpaper.mpRect;
|
|
|
|
|
rImplWallpaper.mpRect = nullptr;
|
|
|
|
|
|
|
|
|
|
delete rImplWallpaper.mpGradient;
|
|
|
|
|
rImplWallpaper.mpGradient = nullptr;
|
|
|
|
|
|
|
|
|
|
delete rImplWallpaper.mpBitmap;
|
|
|
|
|
rImplWallpaper.mpBitmap = nullptr;
|
|
|
|
|
rImplWallpaper.mpRect.reset();
|
|
|
|
|
rImplWallpaper.mpGradient.reset();
|
|
|
|
|
rImplWallpaper.mpBitmap.reset();
|
|
|
|
|
|
|
|
|
|
// version 1
|
|
|
|
|
ReadColor( rIStm, rImplWallpaper.maColor );
|
|
|
|
@@ -107,19 +77,19 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
|
|
|
|
|
|
|
|
|
if( bRect )
|
|
|
|
|
{
|
|
|
|
|
rImplWallpaper.mpRect = new Rectangle;
|
|
|
|
|
rImplWallpaper.mpRect = o3tl::make_unique<Rectangle>();
|
|
|
|
|
ReadRectangle( rIStm, *rImplWallpaper.mpRect );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bGrad )
|
|
|
|
|
{
|
|
|
|
|
rImplWallpaper.mpGradient = new Gradient;
|
|
|
|
|
rImplWallpaper.mpGradient = o3tl::make_unique<Gradient>();
|
|
|
|
|
ReadGradient( rIStm, *rImplWallpaper.mpGradient );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bBmp )
|
|
|
|
|
{
|
|
|
|
|
rImplWallpaper.mpBitmap = new BitmapEx;
|
|
|
|
|
rImplWallpaper.mpBitmap = o3tl::make_unique<BitmapEx>();
|
|
|
|
|
ReadDIBBitmapEx(*rImplWallpaper.mpBitmap, rIStm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -136,9 +106,9 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
|
|
|
|
|
SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpaper )
|
|
|
|
|
{
|
|
|
|
|
VersionCompat aCompat( rOStm, StreamMode::WRITE, 3 );
|
|
|
|
|
bool bRect = ( rImplWallpaper.mpRect != nullptr );
|
|
|
|
|
bool bGrad = ( rImplWallpaper.mpGradient != nullptr );
|
|
|
|
|
bool bBmp = ( rImplWallpaper.mpBitmap != nullptr );
|
|
|
|
|
bool bRect = bool(rImplWallpaper.mpRect);
|
|
|
|
|
bool bGrad = bool(rImplWallpaper.mpGradient);
|
|
|
|
|
bool bBmp = bool(rImplWallpaper.mpBitmap);
|
|
|
|
|
bool bDummy = false;
|
|
|
|
|
|
|
|
|
|
// version 1
|
|
|
|
@@ -191,13 +161,13 @@ Wallpaper::Wallpaper( const Color& rColor ) : mpImplWallpaper()
|
|
|
|
|
|
|
|
|
|
Wallpaper::Wallpaper( const BitmapEx& rBmpEx ) : mpImplWallpaper()
|
|
|
|
|
{
|
|
|
|
|
mpImplWallpaper->mpBitmap = new BitmapEx( rBmpEx );
|
|
|
|
|
mpImplWallpaper->mpBitmap = o3tl::make_unique<BitmapEx>( rBmpEx );
|
|
|
|
|
mpImplWallpaper->meStyle = WallpaperStyle::Tile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Wallpaper::Wallpaper( const Gradient& rGradient ) : mpImplWallpaper()
|
|
|
|
|
{
|
|
|
|
|
mpImplWallpaper->mpGradient = new Gradient( rGradient );
|
|
|
|
|
mpImplWallpaper->mpGradient = o3tl::make_unique<Gradient>( rGradient );
|
|
|
|
|
mpImplWallpaper->meStyle = WallpaperStyle::Tile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -208,23 +178,21 @@ Wallpaper::~Wallpaper()
|
|
|
|
|
void Wallpaper::ImplSetCachedBitmap( BitmapEx& rBmp ) const
|
|
|
|
|
{
|
|
|
|
|
if( !mpImplWallpaper->mpCache )
|
|
|
|
|
const_cast< ImplWallpaper* >(mpImplWallpaper.get())->mpCache = new BitmapEx( rBmp );
|
|
|
|
|
const_cast< ImplWallpaper* >(mpImplWallpaper.get())->mpCache = o3tl::make_unique<BitmapEx>( rBmp );
|
|
|
|
|
else
|
|
|
|
|
*const_cast< ImplWallpaper* >(mpImplWallpaper.get())->mpCache = rBmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BitmapEx* Wallpaper::ImplGetCachedBitmap() const
|
|
|
|
|
{
|
|
|
|
|
return mpImplWallpaper->mpCache;
|
|
|
|
|
return mpImplWallpaper->mpCache.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wallpaper::ImplReleaseCachedBitmap() const
|
|
|
|
|
{
|
|
|
|
|
delete mpImplWallpaper->mpCache;
|
|
|
|
|
const_cast< ImplWallpaper* >(mpImplWallpaper.get())->mpCache = nullptr;
|
|
|
|
|
const_cast< ImplWallpaper* >(mpImplWallpaper.get())->mpCache.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Wallpaper::SetColor( const Color& rColor )
|
|
|
|
|
{
|
|
|
|
|
ImplReleaseCachedBitmap();
|
|
|
|
@@ -261,8 +229,7 @@ void Wallpaper::SetBitmap( const BitmapEx& rBitmap )
|
|
|
|
|
if ( mpImplWallpaper->mpBitmap )
|
|
|
|
|
{
|
|
|
|
|
ImplReleaseCachedBitmap();
|
|
|
|
|
delete mpImplWallpaper->mpBitmap;
|
|
|
|
|
mpImplWallpaper->mpBitmap = nullptr;
|
|
|
|
|
mpImplWallpaper->mpBitmap.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@@ -271,7 +238,7 @@ void Wallpaper::SetBitmap( const BitmapEx& rBitmap )
|
|
|
|
|
if ( mpImplWallpaper->mpBitmap )
|
|
|
|
|
*(mpImplWallpaper->mpBitmap) = rBitmap;
|
|
|
|
|
else
|
|
|
|
|
mpImplWallpaper->mpBitmap = new BitmapEx( rBitmap );
|
|
|
|
|
mpImplWallpaper->mpBitmap = o3tl::make_unique<BitmapEx>( rBitmap );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( WallpaperStyle::NONE == mpImplWallpaper->meStyle || WallpaperStyle::ApplicationGradient == mpImplWallpaper->meStyle)
|
|
|
|
@@ -283,15 +250,12 @@ BitmapEx Wallpaper::GetBitmap() const
|
|
|
|
|
if ( mpImplWallpaper->mpBitmap )
|
|
|
|
|
return *(mpImplWallpaper->mpBitmap);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BitmapEx aBmp;
|
|
|
|
|
return aBmp;
|
|
|
|
|
}
|
|
|
|
|
return BitmapEx();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wallpaper::IsBitmap() const
|
|
|
|
|
{
|
|
|
|
|
return (mpImplWallpaper->mpBitmap != nullptr);
|
|
|
|
|
return bool(mpImplWallpaper->mpBitmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wallpaper::SetGradient( const Gradient& rGradient )
|
|
|
|
@@ -301,7 +265,7 @@ void Wallpaper::SetGradient( const Gradient& rGradient )
|
|
|
|
|
if ( mpImplWallpaper->mpGradient )
|
|
|
|
|
*(mpImplWallpaper->mpGradient) = rGradient;
|
|
|
|
|
else
|
|
|
|
|
mpImplWallpaper->mpGradient = new Gradient( rGradient );
|
|
|
|
|
mpImplWallpaper->mpGradient = o3tl::make_unique<Gradient>( rGradient );
|
|
|
|
|
|
|
|
|
|
if( WallpaperStyle::NONE == mpImplWallpaper->meStyle || WallpaperStyle::ApplicationGradient == mpImplWallpaper->meStyle )
|
|
|
|
|
mpImplWallpaper->meStyle = WallpaperStyle::Tile;
|
|
|
|
@@ -314,15 +278,12 @@ Gradient Wallpaper::GetGradient() const
|
|
|
|
|
else if ( mpImplWallpaper->mpGradient )
|
|
|
|
|
return *(mpImplWallpaper->mpGradient);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Gradient aGradient;
|
|
|
|
|
return aGradient;
|
|
|
|
|
}
|
|
|
|
|
return Gradient();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wallpaper::IsGradient() const
|
|
|
|
|
{
|
|
|
|
|
return (mpImplWallpaper->mpGradient != nullptr);
|
|
|
|
|
return bool(mpImplWallpaper->mpGradient);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gradient Wallpaper::ImplGetApplicationGradient()
|
|
|
|
@@ -343,18 +304,14 @@ void Wallpaper::SetRect( const Rectangle& rRect )
|
|
|
|
|
{
|
|
|
|
|
if ( rRect.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
if ( mpImplWallpaper->mpRect )
|
|
|
|
|
{
|
|
|
|
|
delete mpImplWallpaper->mpRect;
|
|
|
|
|
mpImplWallpaper->mpRect = nullptr;
|
|
|
|
|
}
|
|
|
|
|
mpImplWallpaper->mpRect.reset();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( mpImplWallpaper->mpRect )
|
|
|
|
|
*(mpImplWallpaper->mpRect) = rRect;
|
|
|
|
|
else
|
|
|
|
|
mpImplWallpaper->mpRect = new Rectangle( rRect );
|
|
|
|
|
mpImplWallpaper->mpRect = o3tl::make_unique<Rectangle>( rRect );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -363,16 +320,12 @@ Rectangle Wallpaper::GetRect() const
|
|
|
|
|
if ( mpImplWallpaper->mpRect )
|
|
|
|
|
return *(mpImplWallpaper->mpRect);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Rectangle aRect;
|
|
|
|
|
return aRect;
|
|
|
|
|
}
|
|
|
|
|
return Rectangle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wallpaper::IsRect() const
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return (mpImplWallpaper->mpRect != nullptr);
|
|
|
|
|
return bool(mpImplWallpaper->mpRect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Wallpaper::IsFixed() const
|
|
|
|
@@ -409,7 +362,7 @@ Wallpaper& Wallpaper::operator=( Wallpaper&& rWallpaper )
|
|
|
|
|
|
|
|
|
|
bool Wallpaper::operator==( const Wallpaper& rWallpaper ) const
|
|
|
|
|
{
|
|
|
|
|
return mpImplWallpaper == rWallpaper.mpImplWallpaper;
|
|
|
|
|
return mpImplWallpaper.same_object(rWallpaper.mpImplWallpaper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SvStream& ReadWallpaper( SvStream& rIStm, Wallpaper& rWallpaper )
|
|
|
|
|