Kaydet (Commit) d32f1d35 authored tarafından Armin Le Grand's avatar Armin Le Grand

i122231 Buffered content for gallery themes, better graphical preparation…

i122231 Buffered content for gallery themes, better graphical preparation (currently BMP_SCALE_FASTESTINTERPOLATE, but can be changed in a single place now if wanted)
üst 2b1bd27c
......@@ -88,7 +88,6 @@ protected:
sal_Bool CreateThumb( const Graphic& rGraphic );
public:
SgaObject();
virtual ~SgaObject() {};
......@@ -106,6 +105,8 @@ public:
friend SvStream& operator<<( SvStream& rOut, const SgaObject& rObj );
friend SvStream& operator>>( SvStream& rIn, SgaObject& rObj );
BitmapEx createPreviewBitmapEx(const Size& rSizePixel) const;
};
// ------------------
......
......@@ -52,7 +52,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;
};
DECLARE_LIST( GalleryObjectList, GalleryObject* )
......@@ -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 );
......
This diff is collapsed.
......@@ -52,12 +52,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_RESID(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_FASTESTINTERPOLATE;
aRetval.Scale(fScale, fScale, nScaleFlag);
}
}
}
return aRetval;
}
// ------------------------------------------------------------------------
sal_Bool SgaObject::CreateThumb( const Graphic& rGraphic )
......
......@@ -471,6 +471,44 @@ SgaObject* GalleryTheme::AcquireObject( sal_uIntPtr nPos )
// ------------------------------------------------------------------------
void GalleryTheme::GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, String& rTitle, String& rPath) const
{
const GalleryObject* pGalleryObject = aObjectList.GetObject(nPos);
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 = aObjectList.GetObject(nPos);
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;
......@@ -544,7 +582,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
// LoeschFlag zuruecksetzen
for ( i = 0; i < nCount; i++ )
aObjectList.GetObject( i )->bDummy = sal_False;
aObjectList.GetObject( i )->mbDelete = false;
for( i = 0; ( i < nCount ) && !bAbortActualize; i++ )
{
......@@ -567,7 +605,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
{
SgaObjectSound aObjSound( aURL );
if( !InsertObject( aObjSound ) )
pEntry->bDummy = sal_True;
pEntry->mbDelete = true;
}
else
{
......@@ -585,12 +623,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
......@@ -607,7 +645,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 );
}
......@@ -619,7 +657,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
pEntry = aObjectList.First();
while( pEntry )
{
if( pEntry->bDummy )
if( pEntry->mbDelete )
{
Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< sal_uIntPtr >( pEntry ) ) );
delete aObjectList.Remove( 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