summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2018-11-26 16:59:42 +0000
committerAndras Timar <andras.timar@collabora.com>2018-12-06 10:51:34 +0100
commitca936bb8b1728f470028e5ae0c55a808210f2b0c (patch)
treedefc6a2d3c3336488b950848304fc3bba39b3361 /framework
parent190fad517d66be7891d54d0731cecb148aff357d (diff)
Use lazy-loading stock Image to simplify framework image lists.
Project stock names through XGraphic via origin URL. Change-Id: Ib445694f7c142a163ef7e7bc0beea39b88b99e14 (cherry picked from commit 77b88eebaadebb626108172e4f2de36c60960051)
Diffstat (limited to 'framework')
-rw-r--r--framework/source/uiconfiguration/ImageArrayData.cxx22
-rw-r--r--framework/source/uiconfiguration/ImageList.cxx37
-rw-r--r--framework/source/uiconfiguration/ImplImageList.cxx9
-rw-r--r--framework/source/uiconfiguration/image.h11
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.cxx2
5 files changed, 26 insertions, 55 deletions
diff --git a/framework/source/uiconfiguration/ImageArrayData.cxx b/framework/source/uiconfiguration/ImageArrayData.cxx
index 508f79105d98..076cbcefb6dd 100644
--- a/framework/source/uiconfiguration/ImageArrayData.cxx
+++ b/framework/source/uiconfiguration/ImageArrayData.cxx
@@ -38,13 +38,13 @@
ImageAryData::ImageAryData( const ImageAryData& rData ) :
maName( rData.maName ),
mnId( rData.mnId ),
- maBitmapEx( rData.maBitmapEx )
+ maImage( rData.maImage )
{
}
ImageAryData::ImageAryData( const OUString &aName,
- sal_uInt16 nId, const BitmapEx &aBitmap )
- : maName( aName ), mnId( nId ), maBitmapEx( aBitmap )
+ sal_uInt16 nId, const Image &aImage )
+ : maName( aName ), mnId( nId ), maImage( aImage )
{
}
@@ -56,23 +56,9 @@ ImageAryData& ImageAryData::operator=( const ImageAryData& rData )
{
maName = rData.maName;
mnId = rData.mnId;
- maBitmapEx = rData.maBitmapEx;
+ maImage = rData.maImage;
return *this;
}
-void ImageAryData::Load(const OUString &rPrefix)
-{
- OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
-
- OUString aFileName = rPrefix;
- aFileName += maName;
-
- bool bSuccess = ImageTree::get().loadImage(aFileName, aIconTheme, maBitmapEx, true);
-
- SAL_WARN_IF(!bSuccess, "fwk.uiconfiguration", "Failed to load image '" << aFileName
- << "' from icon theme '" << aIconTheme << "'");
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/ImageList.cxx b/framework/source/uiconfiguration/ImageList.cxx
index dbdb9459440f..57cbe28b10e7 100644
--- a/framework/source/uiconfiguration/ImageList.cxx
+++ b/framework/source/uiconfiguration/ImageList.cxx
@@ -44,9 +44,7 @@ ImageList::ImageList(const std::vector< OUString >& rNameVector,
mpImplData->maPrefix = rPrefix;
for( size_t i = 0; i < rNameVector.size(); ++i )
- {
- mpImplData->AddImage( rNameVector[ i ], static_cast< sal_uInt16 >( i ) + 1, BitmapEx() );
- }
+ mpImplData->AddImage( rPrefix, rNameVector[ i ], static_cast< sal_uInt16 >( i ) + 1, Image() );
}
void ImageList::ImplInit( sal_uInt16 nItems, const Size &rSize )
@@ -65,15 +63,7 @@ BitmapEx ImageList::GetAsHorizontalStrip() const
return BitmapEx();
aSize.Width() *= nCount;
- // Load any stragglers
- for (sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++)
- {
- ImageAryData *pData = mpImplData->maImages[ nIdx ];
- if( pData->IsLoadable() )
- pData->Load( mpImplData->maPrefix );
- }
-
- BitmapEx aTempl = mpImplData->maImages[ 0 ]->maBitmapEx;
+ BitmapEx aTempl = mpImplData->maImages[ 0 ]->maImage.GetBitmapEx();
BitmapEx aResult;
Bitmap aPixels( aSize, aTempl.GetBitmap().GetBitCount() );
if( aTempl.IsAlpha() )
@@ -87,9 +77,10 @@ BitmapEx ImageList::GetAsHorizontalStrip() const
for (sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++)
{
tools::Rectangle aDestRect( Point( nIdx * mpImplData->maImageSize.Width(), 0 ),
- mpImplData->maImageSize );
+ mpImplData->maImageSize );
ImageAryData *pData = mpImplData->maImages[ nIdx ];
- aResult.CopyPixel( aDestRect, aSrcRect, &pData->maBitmapEx);
+ BitmapEx aTmp = pData->maImage.GetBitmapEx();
+ aResult.CopyPixel( aDestRect, aSrcRect, &aTmp );
}
return aResult;
@@ -112,7 +103,7 @@ void ImageList::InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
for (sal_uInt16 nIdx = 0; nIdx < nItems; nIdx++)
{
BitmapEx aBitmap( rBitmapEx, Point( nIdx * aSize.Width(), 0 ), aSize );
- mpImplData->AddImage( rNameVector[ nIdx ], nIdx + 1, aBitmap );
+ mpImplData->AddImage( mpImplData->maPrefix, rNameVector[ nIdx ], nIdx + 1, Image( aBitmap ) );
}
}
@@ -132,8 +123,7 @@ void ImageList::AddImage( const OUString& rImageName, const Image& rImage )
if( !mpImplData )
ImplInit( 0, rImage.GetSizePixel() );
- mpImplData->AddImage( rImageName, GetImageCount() + 1,
- rImage.GetBitmapEx() );
+ mpImplData->AddImage( mpImplData->maPrefix, rImageName, GetImageCount() + 1, rImage );
}
void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
@@ -142,10 +132,10 @@ void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
if( nId )
{
- //Just replace the bitmap rather than doing RemoveImage / AddImage
- //which breaks index-based iteration.
+ // Just replace the bitmap rather than doing RemoveImage / AddImage
+ // which breaks index-based iteration.
ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
- pImg->maBitmapEx = rImage.GetBitmapEx();
+ pImg->maImage = rImage;
}
}
@@ -166,13 +156,8 @@ Image ImageList::GetImage( const OUString& rImageName ) const
if( mpImplData )
{
ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
-
if( pImg )
- {
- if( pImg->IsLoadable() )
- pImg->Load( mpImplData->maPrefix );
- return Image( pImg->maBitmapEx );
- }
+ return pImg->maImage;
}
return Image();
diff --git a/framework/source/uiconfiguration/ImplImageList.cxx b/framework/source/uiconfiguration/ImplImageList.cxx
index 19bb1e8a1266..a349a865bcde 100644
--- a/framework/source/uiconfiguration/ImplImageList.cxx
+++ b/framework/source/uiconfiguration/ImplImageList.cxx
@@ -53,10 +53,13 @@ ImplImageList::~ImplImageList()
delete *aIt;
}
-void ImplImageList::AddImage( const OUString &aName,
- sal_uInt16 nId, const BitmapEx &aBitmapEx )
+void ImplImageList::AddImage( const OUString &aPrefix, const OUString &aName,
+ sal_uInt16 nId, const Image &aImage )
{
- ImageAryData *pImg = new ImageAryData( aName, nId, aBitmapEx );
+ Image aInsert = aImage;
+ if (!aInsert)
+ aInsert = Image( "private:graphicrepository/" + aPrefix + aName );
+ ImageAryData *pImg = new ImageAryData( aName, nId, aInsert );
maImages.push_back( pImg );
if( !aName.isEmpty() )
maNameHash [ aName ] = pImg;
diff --git a/framework/source/uiconfiguration/image.h b/framework/source/uiconfiguration/image.h
index 1005fc39cdf1..4e903cc9b743 100644
--- a/framework/source/uiconfiguration/image.h
+++ b/framework/source/uiconfiguration/image.h
@@ -30,16 +30,13 @@ struct ImageAryData
OUString maName;
// Images identified by either name, or by id
sal_uInt16 mnId;
- BitmapEx maBitmapEx;
+ Image maImage;
ImageAryData( const OUString &aName,
- sal_uInt16 nId, const BitmapEx &aBitmap );
+ sal_uInt16 nId, const Image &aImage );
ImageAryData( const ImageAryData& rData );
~ImageAryData();
- bool IsLoadable() { return maBitmapEx.IsEmpty() && !maName.isEmpty(); }
- void Load(const OUString &rPrefix);
-
ImageAryData& operator=( const ImageAryData& rData );
};
@@ -57,8 +54,8 @@ struct ImplImageList
ImplImageList( const ImplImageList &aSrc );
~ImplImageList();
- void AddImage( const OUString &aName,
- sal_uInt16 nId, const BitmapEx &aBitmapEx );
+ void AddImage( const OUString &aPrefix, const OUString &aName,
+ sal_uInt16 nId, const Image &aImage );
void RemoveImage( sal_uInt16 nPos );
};
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index ded9db11ee2e..6c5a627bbe94 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -722,7 +722,7 @@ namespace
{
css::uno::Reference< css::graphic::XGraphic > GetXGraphic(const Image &rImage)
{
- return Graphic(rImage.GetBitmapEx()).GetXGraphic();
+ return Graphic(rImage).GetXGraphic();
}
}