[Libreoffice-commits] core.git: include/svx svx/inc svx/source
Armin Le Grand
alg at apache.org
Wed Jun 19 02:10:28 PDT 2013
include/svx/galtheme.hxx | 12 +
svx/inc/galobj.hxx | 3
svx/source/gallery2/galctrl.cxx | 410 +++++++++++++++++++++++++++------------
svx/source/gallery2/galobj.cxx | 48 ++++
svx/source/gallery2/galtheme.cxx | 50 ++++
5 files changed, 391 insertions(+), 132 deletions(-)
New commits:
commit 5c346ec8521b0f137273e5055fc19eee37a20169
Author: Armin Le Grand <alg at apache.org>
Date: Tue May 7 13:53:03 2013 +0000
Resolves: #i122231# Buffered content for gallery themes
better graphical preparation (currently BMP_SCALE_BESTQUALITY, but can
be changed in a single place now if wanted)
(cherry picked from commit d32f1d358dcd2574d8ae6cd19da01b7311ef5926)
Conflicts:
svx/inc/svx/galtheme.hxx
svx/source/gallery2/galctrl.cxx
svx/source/gallery2/galtheme.cxx
Change-Id: I80879ca472c784f764126676046c1388e1167652
diff --git a/include/svx/galtheme.hxx b/include/svx/galtheme.hxx
index 8eccc86..25f939a 100644
--- a/include/svx/galtheme.hxx
+++ b/include/svx/galtheme.hxx
@@ -45,7 +45,13 @@ struct GalleryObject
INetURLObject aURL;
sal_uInt32 nOffset;
SgaObjKind eObjKind;
- sal_Bool bDummy;
+ bool mbDelete;
+
+ //UI visualization buffering
+ BitmapEx maPreviewBitmapEx;
+ Size maPreparedSize;
+ String maTitle;
+ String maPath;
};
typedef ::std::vector< GalleryObject* > GalleryObjectList;
@@ -219,6 +225,10 @@ public:
SvStream& WriteData( SvStream& rOut ) const;
SvStream& ReadData( SvStream& rIn );
static SVX_DLLPUBLIC void InsertAllThemes( ListBox& rListBox );
+
+ // for buffering PreviewBitmaps and strings for object and path
+ void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, String& rTitle, String& rPath) const;
+ void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const String& rTitle, const String& rPath);
};
SvStream& operator<<( SvStream& rOut, const GalleryTheme& rTheme );
diff --git a/svx/inc/galobj.hxx b/svx/inc/galobj.hxx
index 09e0382..8712b71 100644
--- a/svx/inc/galobj.hxx
+++ b/svx/inc/galobj.hxx
@@ -71,7 +71,6 @@ protected:
sal_Bool CreateThumb( const Graphic& rGraphic );
public:
-
SgaObject();
virtual ~SgaObject() {};
@@ -89,6 +88,8 @@ public:
friend SvStream& operator<<( SvStream& rOut, const SgaObject& rObj );
friend SvStream& operator>>( SvStream& rIn, SgaObject& rObj );
+
+ BitmapEx createPreviewBitmapEx(const Size& rSizePixel) const;
};
class SgaObjectSound : public SgaObject
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 2aacbaa..3e08539 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -325,82 +325,158 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
if( nId && mpTheme )
{
- SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+ const Rectangle& rRect = rUDEvt.GetRect();
+ const Size aSize(rRect.GetWidth(), rRect.GetHeight());
+ BitmapEx aBitmapEx;
+ Size aPreparedSize;
+ String aItemTextTitle;
+ String aItemTextPath;
- if( pObj )
- {
- const Rectangle& rRect = rUDEvt.GetRect();
- OutputDevice* pDev = rUDEvt.GetDevice();
- Graphic aGraphic;
- bool bTransparent(false);
+ mpTheme->GetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
- if( pObj->IsThumbBitmap() )
- {
- BitmapEx aBitmapEx;
+ bool bNeedToCreate(aBitmapEx.IsEmpty());
- if( pObj->GetObjKind() == SGA_OBJ_SOUND )
- {
- Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
+ if(!bNeedToCreate && !aItemTextTitle.Len())
+ {
+ bNeedToCreate = true;
+ }
- aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
- aBitmapEx = BitmapEx(aTemp);
- }
- else
- {
- aBitmapEx = pObj->GetThumbBmp();
- bTransparent = aBitmapEx.IsTransparent();
- }
+ if(!bNeedToCreate && aPreparedSize != aSize)
+ {
+ bNeedToCreate = true;
+ }
- if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
- {
- aBitmapEx.Dither( BMP_DITHER_FLOYD );
- }
+ if(bNeedToCreate)
+ {
+ SgaObject* pObj = mpTheme->AcquireObject(nId - 1);
- aGraphic = aBitmapEx;
- }
- else
+ if(pObj)
{
- aGraphic = pObj->GetThumbMtf();
- bTransparent = true;
+ aBitmapEx = pObj->createPreviewBitmapEx(aSize);
+ aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
+
+ mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
+ mpTheme->ReleaseObject(pObj);
}
+ }
- Size aSize( aGraphic.GetSizePixel( pDev ) );
+ if(!aBitmapEx.IsEmpty())
+ {
+ const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ const Point aPos(
+ ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ OutputDevice* pDev = rUDEvt.GetDevice();
- if ( aSize.Width() && aSize.Height() )
+ if(aBitmapEx.IsTransparent())
{
- if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
- {
- const double fBmpWH = (double) aSize.Width() / aSize.Height();
- const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
-
- // Bitmap an Thumbgroesse anpassen
- if ( fBmpWH < fThmpWH )
- {
- aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
- aSize.Height()= rRect.GetHeight();
- }
- else
- {
- aSize.Width() = rRect.GetWidth();
- aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
- }
- }
-
- const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
- ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
-
- if(bTransparent)
- {
- // draw checkered background for full rectangle.
- drawTransparenceBackground(*pDev, rRect.TopLeft(), rRect.GetSize());
- }
-
- aGraphic.Draw( pDev, aPos, aSize );
+ // draw checkered background for full rectangle.
+ drawTransparenceBackground(*pDev, rRect.TopLeft(), rRect.GetSize());
}
- SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
- mpTheme->ReleaseObject( pObj );
+ pDev->DrawBitmapEx(aPos, aBitmapEx);
}
+
+ SetItemText(nId, aItemTextTitle);
+
+ //SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+ //
+ //if( pObj )
+ //{
+ // const Rectangle& rRect = rUDEvt.GetRect();
+ // const Size aSize(rRect.GetWidth(), rRect.GetHeight());
+ // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
+ // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ //
+ // if(!aBitmapEx.IsEmpty())
+ // {
+ // const Point aPos(
+ // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ // OutputDevice* pDev = rUDEvt.GetDevice();
+ //
+ // if(aBitmapEx.IsTransparent())
+ // {
+ // // draw checkered background
+ // drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
+ // }
+ //
+ // pDev->DrawBitmapEx(aPos, aBitmapEx);
+ // }
+ //
+ // //const Rectangle& rRect = rUDEvt.GetRect();
+ // //OutputDevice* pDev = rUDEvt.GetDevice();
+ // //Graphic aGraphic;
+ // //bool bTransparent(false);
+ // //
+ // //if( pObj->IsThumbBitmap() )
+ // //{
+ // // BitmapEx aBitmapEx;
+ // //
+ // // if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ // // {
+ // // Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
+ // //
+ // // aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
+ // // aBitmapEx = BitmapEx(aTemp);
+ // // }
+ // // else
+ // // {
+ // // aBitmapEx = pObj->GetThumbBmp();
+ // // bTransparent = aBitmapEx.IsTransparent();
+ // // }
+ // //
+ // // if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
+ // // {
+ // // aBitmapEx.Dither( BMP_DITHER_FLOYD );
+ // // }
+ // //
+ // // aGraphic = aBitmapEx;
+ // //}
+ // //else
+ // //{
+ // // aGraphic = pObj->GetThumbMtf();
+ // // bTransparent = true;
+ // //}
+ // //
+ // //Size aSize( aGraphic.GetSizePixel( pDev ) );
+ // //
+ // //if ( aSize.Width() && aSize.Height() )
+ // //{
+ // // if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
+ // // {
+ // // Point aNewPos;
+ // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ // // const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
+ // //
+ // // // Bitmap an Thumbgroesse anpassen
+ // // if ( fBmpWH < fThmpWH )
+ // // {
+ // // aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
+ // // aSize.Height()= rRect.GetHeight();
+ // // }
+ // // else
+ // // {
+ // // aSize.Width() = rRect.GetWidth();
+ // // aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
+ // // }
+ // // }
+ // //
+ // // const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
+ // // ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
+ // //
+ // // if(bTransparent)
+ // // {
+ // // // draw checkered background
+ // // drawTransparenceBackground(*pDev, aPos, aSize);
+ // // }
+ // //
+ // // aGraphic.Draw( pDev, aPos, aSize );
+ // //}
+ //
+ // SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
+ // mpTheme->ReleaseObject( pObj );
+ //}
}
}
@@ -550,79 +626,171 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa
if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
{
- SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
+ const Size aSize(rRect.GetHeight(), rRect.GetHeight());
+ BitmapEx aBitmapEx;
+ Size aPreparedSize;
+ String aItemTextTitle;
+ String aItemTextPath;
- if( pObj )
+ mpTheme->GetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
+
+ bool bNeedToCreate(aBitmapEx.IsEmpty());
+
+ if(!bNeedToCreate && GALLERY_BRWBOX_TITLE == nColumnId && !aItemTextTitle.Len())
+ {
+ bNeedToCreate = true;
+ }
+
+ if(!bNeedToCreate && GALLERY_BRWBOX_PATH == nColumnId && !aItemTextPath.Len())
+ {
+ bNeedToCreate = true;
+ }
+
+ if(!bNeedToCreate && aPreparedSize != aSize)
{
- const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
+ bNeedToCreate = true;
+ }
- if( GALLERY_BRWBOX_TITLE == nColumnId )
+ if(bNeedToCreate)
+ {
+ SgaObject* pObj = mpTheme->AcquireObject(mnCurRow);
+
+ if(pObj)
{
- Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
- GraphicObject aGrfObj;
- bool bTransparent(false);
+ aBitmapEx = pObj->createPreviewBitmapEx(aSize);
+ aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
+ aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_PATH);
- if( pObj->GetObjKind() == SGA_OBJ_SOUND )
- {
- aGrfObj = Graphic( BitmapEx( GAL_RES( RID_SVXBMP_GALLERY_MEDIA ) ) );
- }
- else if( pObj->IsThumbBitmap() )
- {
- const BitmapEx aBitmapEx(pObj->GetThumbBmp());
+ mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
+ mpTheme->ReleaseObject(pObj);
+ }
+ }
- bTransparent = aBitmapEx.IsTransparent();
- aGrfObj = Graphic(aBitmapEx);
- }
- else
- {
- aGrfObj = Graphic( pObj->GetThumbMtf() );
- bTransparent = true;
- }
+ const long nTextPosY(rRect.Top() + ((rRect.GetHeight() - rDev.GetTextHeight()) >> 1));
- Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+ if(GALLERY_BRWBOX_TITLE == nColumnId)
+ {
+ if(!aBitmapEx.IsEmpty())
+ {
+ const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ const Point aPos(
+ ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
- if( aSize.Width() && aSize.Height() )
+ if(aBitmapEx.IsTransparent())
{
- if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
- {
- const double fBmpWH = (double) aSize.Width() / aSize.Height();
- const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
-
- // Bitmap an Thumbgroesse anpassen
- if ( fBmpWH < fThmpWH )
- {
- aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
- aSize.Height()= aOutputRect.GetHeight();
- }
- else
- {
- aSize.Width() = aOutputRect.GetWidth();
- aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
- }
- }
-
- aSize.Width() = std::max( aSize.Width(), 4L );
- aSize.Height() = std::max( aSize.Height(), 4L );
-
- const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
- ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
-
- if(bTransparent)
- {
- // draw checkered background
- drawTransparenceBackground(rDev, aPos, aSize);
- }
-
- aGrfObj.Draw( &rDev, aPos, aSize );
+ // draw checkered background
+ drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
}
- rDev.DrawText( Point( aOutputRect.Right() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ rDev.DrawBitmapEx(aPos, aBitmapEx);
}
- else if( GALLERY_BRWBOX_PATH == nColumnId )
- rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
- mpTheme->ReleaseObject( pObj );
+ rDev.DrawText(Point(rRect.Left() + rRect.GetHeight() + 6, nTextPosY), aItemTextTitle);
+ }
+ else if(GALLERY_BRWBOX_PATH == nColumnId)
+ {
+ rDev.DrawText(Point(rRect.Left(), nTextPosY), aItemTextPath);
}
+
+
+ //SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
+ //
+ //if( pObj )
+ //{
+ // const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
+ //
+ // if( GALLERY_BRWBOX_TITLE == nColumnId )
+ // {
+ // const Size aSize(rRect.GetHeight(), rRect.GetHeight());
+ // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
+ // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ //
+ // if(!aBitmapEx.IsEmpty())
+ // {
+ // const Point aPos(
+ // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ //
+ // if(aBitmapEx.IsTransparent())
+ // {
+ // // draw checkered background
+ // drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
+ // }
+ //
+ // rDev.DrawBitmapEx(aPos, aBitmapEx);
+ // }
+ //
+ //
+ // //Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
+ // //GraphicObject aGrfObj;
+ // //bool bTransparent(false);
+ // //
+ // //if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ // //{
+ // // aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
+ // //}
+ // //else if( pObj->IsThumbBitmap() )
+ // //{
+ // // const BitmapEx aBitmapEx(pObj->GetThumbBmp());
+ // //
+ // // bTransparent = aBitmapEx.IsTransparent();
+ // // aGrfObj = Graphic(aBitmapEx);
+ // //}
+ // //else
+ // //{
+ // // aGrfObj = Graphic( pObj->GetThumbMtf() );
+ // // bTransparent = true;
+ // //}
+ // //
+ // //Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+ // //
+ // //if( aSize.Width() && aSize.Height() )
+ // //{
+ // // if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
+ // // {
+ // // Point aNewPos;
+ // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ // // const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
+ // //
+ // // // Bitmap an Thumbgroesse anpassen
+ // // if ( fBmpWH < fThmpWH )
+ // // {
+ // // aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
+ // // aSize.Height()= aOutputRect.GetHeight();
+ // // }
+ // // else
+ // // {
+ // // aSize.Width() = aOutputRect.GetWidth();
+ // // aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
+ // // }
+ // // }
+ // //
+ // // aSize.Width() = Max( aSize.Width(), 4L );
+ // // aSize.Height() = Max( aSize.Height(), 4L );
+ // //
+ // // const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
+ // // ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
+ // //
+ // // if(bTransparent)
+ // // {
+ // // // draw checkered background
+ // // drawTransparenceBackground(rDev, aPos, aSize);
+ // // }
+ // //
+ // // aGrfObj.Draw( &rDev, aPos, aSize );
+ // //}
+ //
+ // // aOutputRect.Right() is here rRect.Left() + rRect.GetHeight()
+ // rDev.DrawText( Point( rRect.Left() + rRect.GetHeight() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ // }
+ // else if( GALLERY_BRWBOX_PATH == nColumnId )
+ // {
+ // rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
+ // }
+ //
+ // mpTheme->ReleaseObject( pObj );
+ //}
}
rDev.Pop();
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index eb1b6e4..444c4fe 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -45,12 +45,54 @@ using namespace ::com::sun::star;
// - SgaObject -
// -------------
-SgaObject::SgaObject() :
- bIsValid ( sal_False ),
- bIsThumbBmp ( sal_True )
+SgaObject::SgaObject()
+: bIsValid ( sal_False ),
+ bIsThumbBmp ( sal_True )
{
}
+BitmapEx SgaObject::createPreviewBitmapEx(const Size& rSizePixel) const
+{
+ BitmapEx aRetval;
+
+ if(rSizePixel.Width() && rSizePixel.Height())
+ {
+ if(SGA_OBJ_SOUND == GetObjKind())
+ {
+ aRetval = GAL_RES(RID_SVXBMP_GALLERY_MEDIA);
+ }
+ else if(IsThumbBitmap())
+ {
+ aRetval = GetThumbBmp();
+ }
+ else
+ {
+ const Graphic aGraphic(GetThumbMtf());
+
+ aRetval = aGraphic.GetBitmapEx();
+ }
+
+ if(!aRetval.IsEmpty())
+ {
+ const Size aCurrentSizePixel(aRetval.GetSizePixel());
+ const double fScaleX((double)rSizePixel.Width() / (double)aCurrentSizePixel.Width());
+ const double fScaleY((double)rSizePixel.Height() / (double)aCurrentSizePixel.Height());
+ const double fScale(std::min(fScaleX, fScaleY));
+
+ // only scale when need to decrease, no need to make bigger as original. Also
+ // prevent scaling close to 1.0 which is not needed for pixel graphics
+ if(fScale < 1.0 && fabs(1.0 - fScale) > 0.005)
+ {
+ static sal_uInt32 nScaleFlag = BMP_SCALE_BESTQUALITY;
+
+ aRetval.Scale(fScale, fScale, nScaleFlag);
+ }
+ }
+ }
+
+ return aRetval;
+}
+
// ------------------------------------------------------------------------
sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 54c7067..f2c4c5a 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -444,6 +444,44 @@ SgaObject* GalleryTheme::AcquireObject( size_t nPos )
// ------------------------------------------------------------------------
+void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, String& rTitle, String& rPath) const
+{
+ const GalleryObject* pGalleryObject = nPos < aObjectList.size() ? aObjectList[ nPos ] : NULL;
+
+ if(pGalleryObject)
+ {
+ rBitmapEx = pGalleryObject->maPreviewBitmapEx;
+ rSize = pGalleryObject->maPreparedSize;
+ rTitle = pGalleryObject->maTitle;
+ rPath = pGalleryObject->maPath;
+ }
+ else
+ {
+ OSL_ENSURE(false, "OOps, no GalleryObject at this index (!)");
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const String& rTitle, const String& rPath)
+{
+ GalleryObject* pGalleryObject = nPos < aObjectList.size() ? aObjectList[ nPos ] : NULL;
+
+ if(pGalleryObject)
+ {
+ pGalleryObject->maPreviewBitmapEx = rBitmapEx;
+ pGalleryObject->maPreparedSize = rSize;
+ pGalleryObject->maTitle = rTitle;
+ pGalleryObject->maPath = rPath;
+ }
+ else
+ {
+ OSL_ENSURE(false, "OOps, no GalleryObject at this index (!)");
+ }
+}
+
+// ------------------------------------------------------------------------
+
void GalleryTheme::ReleaseObject( SgaObject* pObject )
{
delete pObject;
@@ -526,7 +564,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
// LoeschFlag zuruecksetzen
for (size_t i = 0; i < nCount; i++)
- aObjectList[ i ]->bDummy = sal_False;
+ aObjectList[ i ]->mbDelete = false;
for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
{
@@ -549,7 +587,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
{
SgaObjectSound aObjSound( aURL );
if( !InsertObject( aObjSound ) )
- pEntry->bDummy = sal_True;
+ pEntry->mbDelete = true;
}
else
{
@@ -567,12 +605,12 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, aURL, aFormat );
if( !InsertObject( *pNewObj ) )
- pEntry->bDummy = sal_True;
+ pEntry->mbDelete = true;
delete pNewObj;
}
else
- pEntry->bDummy = sal_True; // Loesch-Flag setzen
+ pEntry->mbDelete = true; // Loesch-Flag setzen
}
}
else
@@ -589,7 +627,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
if( !InsertObject( aNewObj ) )
- pEntry->bDummy = sal_True;
+ pEntry->mbDelete = true;
pIStm->SetBufferSize( 0L );
}
@@ -601,7 +639,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
for ( size_t i = 0; i < aObjectList.size(); )
{
pEntry = aObjectList[ i ];
- if( pEntry->bDummy )
+ if( pEntry->mbDelete )
{
Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< sal_uLong >( pEntry ) ) );
More information about the Libreoffice-commits
mailing list