vcl: move method to the appropriate file, some C++11-ification

Change-Id: If51d16673c8b241487cae5305e293f213b7db5cb
Reviewed-on: https://gerrit.libreoffice.org/30338
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2016-10-27 17:39:45 +02:00
committed by Tomaž Vajngerl
parent 87c518593d
commit f19f88a0d4
2 changed files with 44 additions and 42 deletions

View File

@@ -25,10 +25,18 @@
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <vcl/image.hxx> #include <vcl/image.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/implimagetree.hxx>
#include <image.h> #include <image.h>
#include <memory> #include <memory>
#if OSL_DEBUG_LEVEL > 0
#include <rtl/strbuf.hxx>
#endif
#include <vcl/BitmapProcessor.hxx>
ImageAryData::ImageAryData( const ImageAryData& rData ) : ImageAryData::ImageAryData( const ImageAryData& rData ) :
maName( rData.maName ), maName( rData.maName ),
mnId( rData.mnId ), mnId( rData.mnId ),
@@ -55,4 +63,31 @@ ImageAryData& ImageAryData::operator=( const ImageAryData& rData )
return *this; return *this;
} }
void ImageAryData::Load(const OUString &rPrefix)
{
OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
OUString aFileName = rPrefix;
aFileName += maName;
bool bSuccess = ImplImageTree::get().loadImage(aFileName, aIconTheme, maBitmapEx, true);
if (bSuccess)
{}
#if OSL_DEBUG_LEVEL > 0
else
{
OStringBuffer aMessage;
aMessage.append( "ImageAryData::Load: failed to load image '" );
aMessage.append( OUStringToOString( aFileName, RTL_TEXTENCODING_UTF8 ).getStr() );
aMessage.append( "'" );
aMessage.append( " from icon theme '" );
aMessage.append( OUStringToOString( aIconTheme, RTL_TEXTENCODING_UTF8 ).getStr() );
aMessage.append( "'" );
OSL_FAIL( aMessage.makeStringAndClear().getStr() );
}
#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -33,10 +33,6 @@
#include <vcl/implimagetree.hxx> #include <vcl/implimagetree.hxx>
#include <image.h> #include <image.h>
#if OSL_DEBUG_LEVEL > 0
#include <rtl/strbuf.hxx>
#endif
ImageList::ImageList() : ImageList::ImageList() :
mpImplData( nullptr ) mpImplData( nullptr )
{ {
@@ -122,31 +118,6 @@ void ImageList::ImplInit( sal_uInt16 nItems, const Size &rSize )
mpImplData->maImageSize = rSize; mpImplData->maImageSize = rSize;
} }
void ImageAryData::Load(const OUString &rPrefix)
{
OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
OUString aFileName = rPrefix;
aFileName += maName;
#if OSL_DEBUG_LEVEL > 0
bool bSuccess =
#endif
ImplImageTree::get().loadImage(aFileName, aIconTheme, maBitmapEx, true);
#if OSL_DEBUG_LEVEL > 0
if ( !bSuccess )
{
OStringBuffer aMessage;
aMessage.append( "ImageAryData::Load: failed to load image '" );
aMessage.append( OUStringToOString( aFileName, RTL_TEXTENCODING_UTF8 ).getStr() );
aMessage.append( "'" );
aMessage.append( " from icon theme '" );
aMessage.append( OUStringToOString( aIconTheme, RTL_TEXTENCODING_UTF8 ).getStr() );
aMessage.append( "'" );
OSL_FAIL( aMessage.makeStringAndClear().getStr() );
}
#endif
}
// FIXME: Rather a performance hazard // FIXME: Rather a performance hazard
BitmapEx ImageList::GetAsHorizontalStrip() const BitmapEx ImageList::GetAsHorizontalStrip() const
{ {
@@ -278,21 +249,17 @@ void ImageList::RemoveImage( sal_uInt16 nId )
Image ImageList::GetImage( sal_uInt16 nId ) const Image ImageList::GetImage( sal_uInt16 nId ) const
{ {
Image aRet; Image aRet;
if( mpImplData ) if (mpImplData)
{ {
std::vector<ImageAryData *>::iterator aIter; for (ImageAryData* pImageData : mpImplData->maImages)
for( aIter = mpImplData->maImages.begin();
aIter != mpImplData->maImages.end(); ++aIter)
{ {
if ((*aIter)->mnId == nId) if (pImageData->mnId == nId)
{ {
if( (*aIter)->IsLoadable() ) if (pImageData->IsLoadable())
(*aIter)->Load( mpImplData->maPrefix ); pImageData->Load(mpImplData->maPrefix);
aRet = Image(pImageData->maBitmapEx);
aRet = Image( (*aIter)->maBitmapEx );
} }
} }
} }
@@ -300,9 +267,9 @@ Image ImageList::GetImage( sal_uInt16 nId ) const
if (!aRet) if (!aRet)
{ {
BitmapEx rBitmap; BitmapEx rBitmap;
bool res = vcl::ImageRepository::loadDefaultImage(rBitmap); bool bResult = vcl::ImageRepository::loadDefaultImage(rBitmap);
if (res) if (bResult)
aRet = Image(rBitmap); aRet = Image(rBitmap);
} }
return aRet; return aRet;