openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1479910 - in /openoffice/trunk/main/svx: inc/galobj.hxx inc/svx/galtheme.hxx source/gallery2/galctrl.cxx source/gallery2/galobj.cxx source/gallery2/galtheme.cxx
Date Tue, 07 May 2013 13:53:03 GMT
Author: alg
Date: Tue May  7 13:53:03 2013
New Revision: 1479910

URL: http://svn.apache.org/r1479910
Log:
i122231 Buffered content for gallery themes, better graphical preparation (currently BMP_SCALE_FASTESTINTERPOLATE,
but can be changed in a single place now if wanted)

Modified:
    openoffice/trunk/main/svx/inc/galobj.hxx
    openoffice/trunk/main/svx/inc/svx/galtheme.hxx
    openoffice/trunk/main/svx/source/gallery2/galctrl.cxx
    openoffice/trunk/main/svx/source/gallery2/galobj.cxx
    openoffice/trunk/main/svx/source/gallery2/galtheme.cxx

Modified: openoffice/trunk/main/svx/inc/galobj.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/galobj.hxx?rev=1479910&r1=1479909&r2=1479910&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/galobj.hxx (original)
+++ openoffice/trunk/main/svx/inc/galobj.hxx Tue May  7 13:53:03 2013
@@ -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;
 };
 
 // ------------------

Modified: openoffice/trunk/main/svx/inc/svx/galtheme.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/galtheme.hxx?rev=1479910&r1=1479909&r2=1479910&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/galtheme.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/galtheme.hxx Tue May  7 13:53:03 2013
@@ -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 );

Modified: openoffice/trunk/main/svx/source/gallery2/galctrl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galctrl.cxx?rev=1479910&r1=1479909&r2=1479910&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galctrl.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galctrl.cxx Tue May  7 13:53:03 2013
@@ -376,85 +376,160 @@ void GalleryIconView::UserDraw( const Us
 {
 	const sal_uInt16 nId = rUDEvt.GetItemId();
 
-	if( nId && mpTheme )
-	{
-		SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+    if( nId && mpTheme )
+    {
+        const Rectangle& rRect = rUDEvt.GetRect();
+        const Size aSize(rRect.GetWidth(), rRect.GetHeight());
+        BitmapEx aBitmapEx;
+        Size aPreparedSize;
+        String aItemTextTitle;
+        String aItemTextPath;
+
+        mpTheme->GetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aPreparedSize, aItemTextTitle,
aItemTextPath);
+
+        bool bNeedToCreate(aBitmapEx.IsEmpty());
+
+        if(!bNeedToCreate && !aItemTextTitle.Len())
+        {
+            bNeedToCreate = true;
+        }
+
+        if(!bNeedToCreate && aPreparedSize != aSize)
+        {
+            bNeedToCreate = true;
+        }
+
+        if(bNeedToCreate)
+        {
+            SgaObject* pObj = mpTheme->AcquireObject(nId - 1);
 
-		if( pObj )
-		{
-			const Rectangle&	rRect = rUDEvt.GetRect();
-			OutputDevice*		pDev = rUDEvt.GetDevice();
-			Graphic 			aGraphic;
-            bool bTransparent(false);
-
-			if( pObj->IsThumbBitmap() )
-			{
-				BitmapEx aBitmapEx;
+            if(pObj)
+            {
+                aBitmapEx = pObj->createPreviewBitmapEx(aSize);
+                aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
 
-				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();
-                }
+                mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle,
aItemTextPath);
+                mpTheme->ReleaseObject(pObj);
+            }
+        }
 
-				if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 )
)
-                {
-					aBitmapEx.Dither( BMP_DITHER_FLOYD );
-                }
+        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();
 
-				aGraphic = aBitmapEx;
-			}
-			else
+            if(aBitmapEx.IsTransparent())
             {
-				aGraphic = pObj->GetThumbMtf();
-                bTransparent = true;
+                // draw checkered background
+                drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
             }
 
-			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 );
-					}
-				}
+            pDev->DrawBitmapEx(aPos, aBitmapEx);
+        }
 
-				const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
-								  ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
+        SetItemText(nId, aItemTextTitle);
 
-                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 );
-		}
+		//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 );
+		//}
 	}
 }
 
@@ -637,80 +712,171 @@ void GalleryListView::PaintField( Output
 
 	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;
+
+        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)
+        {
+            bNeedToCreate = true;
+        }
+
+        if(bNeedToCreate)
+        {
+            SgaObject* pObj = mpTheme->AcquireObject(mnCurRow);
 
-		if( pObj )
-		{
-            const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight()
) >> 1 );
-
-            if( GALLERY_BRWBOX_TITLE == nColumnId )
+            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_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;
-                }
+                mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle,
aItemTextPath);
+                mpTheme->ReleaseObject(pObj);
+            }
+        }
 
-			    Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+        const long nTextPosY(rRect.Top() + ((rRect.GetHeight() - rDev.GetTextHeight()) >>
1));
 
-			    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);
-                    }
+        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());
 
-                    aGrfObj.Draw( &rDev, aPos, aSize );
-			    }
+                if(aBitmapEx.IsTransparent())
+                {
+                    // 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();

Modified: openoffice/trunk/main/svx/source/gallery2/galobj.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galobj.cxx?rev=1479910&r1=1479909&r2=1479910&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galobj.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galobj.cxx Tue May  7 13:53:03 2013
@@ -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 )

Modified: openoffice/trunk/main/svx/source/gallery2/galtheme.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/gallery2/galtheme.cxx?rev=1479910&r1=1479909&r2=1479910&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/gallery2/galtheme.cxx (original)
+++ openoffice/trunk/main/svx/source/gallery2/galtheme.cxx Tue May  7 13:53:03 2013
@@ -471,6 +471,44 @@ SgaObject* GalleryTheme::AcquireObject( 
 
 // ------------------------------------------------------------------------
 
+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
 
 		// 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
 				{
 					SgaObjectSound aObjSound( aURL );
 					if( !InsertObject( aObjSound ) )
-						pEntry->bDummy = sal_True;
+						pEntry->mbDelete = true;
 				}
 				else
 				{
@@ -585,12 +623,12 @@ void GalleryTheme::Actualize( const Link
 							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
 						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
 		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 );



Mime
View raw message