Kaydet (Commit) 5c346ec8 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

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 d32f1d35)

Conflicts:
	svx/inc/svx/galtheme.hxx
	svx/source/gallery2/galctrl.cxx
	svx/source/gallery2/galtheme.cxx

Change-Id: I80879ca472c784f764126676046c1388e1167652
üst 0b9bf62d
......@@ -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 );
......
......@@ -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
......
This diff is collapsed.
......@@ -45,12 +45,54 @@ using namespace ::com::sun::star;
// - SgaObject -
// -------------
SgaObject::SgaObject() :
bIsValid ( sal_False ),
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 )
......
......@@ -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 ) ) );
......
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