[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - cppuhelper/inc svx/inc svx/source

Herbert Dürr hdu at apache.org
Tue May 7 18:10:06 PDT 2013


 cppuhelper/inc/cppuhelper/propertysetmixin.hxx |   12 
 svx/inc/galobj.hxx                             |    3 
 svx/inc/svx/galtheme.hxx                       |   12 
 svx/source/gallery2/galctrl.cxx                |  412 +++++++++++++++++--------
 svx/source/gallery2/galobj.cxx                 |   48 ++
 svx/source/gallery2/galtheme.cxx               |   50 ++-
 6 files changed, 397 insertions(+), 140 deletions(-)

New commits:
commit 0fabc9a7be629ca150e83b5b69dc5e44b4b2a476
Author: Herbert Dürr <hdu at apache.org>
Date:   Tue May 7 16:15:53 2013 +0000

    fix signatures for copy-construction and assignment for the propertysetmixin classes
    
    the canonic way to disallow copy construction and assignment of an object
    is to declare unimplemented methods for them taking const references.

diff --git a/cppuhelper/inc/cppuhelper/propertysetmixin.hxx b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx
index 92bd5d9..c261381 100644
--- a/cppuhelper/inc/cppuhelper/propertysetmixin.hxx
+++ b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx
@@ -157,8 +157,8 @@ protected:
         void notify() const;
 
     private:
-        BoundListeners(BoundListeners &); // not defined
-        void operator =(BoundListeners); // not defined
+        BoundListeners( const BoundListeners&); // not defined
+        void operator=( const BoundListeners&); // not defined
 
         class Impl;
         Impl * m_impl;
@@ -379,8 +379,8 @@ protected:
             com::sun::star::uno::RuntimeException);
 
 private:
-    PropertySetMixinImpl(PropertySetMixinImpl &); // not defined
-    void operator =(PropertySetMixinImpl &); // not defined
+    PropertySetMixinImpl( const PropertySetMixinImpl&); // not defined
+    void operator=( const PropertySetMixinImpl&); // not defined
 
     PropertySetMixinImpl(
         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
@@ -471,8 +471,8 @@ protected:
     ~PropertySetMixin() {}
 
 private:
-    PropertySetMixin(PropertySetMixin &); // not defined
-    void operator =(PropertySetMixin); // not defined
+    PropertySetMixin( const PropertySetMixin&); // not defined
+    void operator=( const PropertySetMixin&); // not defined
 };
 
 #if defined _MSC_VER
commit d32f1d358dcd2574d8ae6cd19da01b7311ef5926
Author: Armin Le Grand <alg at apache.org>
Date:   Tue May 7 13:53:03 2013 +0000

    i122231 Buffered content for gallery themes, better graphical preparation (currently BMP_SCALE_FASTESTINTERPOLATE, but can be changed in a single place now if wanted)

diff --git a/svx/inc/galobj.hxx b/svx/inc/galobj.hxx
index 8e205d6..41d9ce2 100644
--- a/svx/inc/galobj.hxx
+++ b/svx/inc/galobj.hxx
@@ -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;
 };
 
 // ------------------
diff --git a/svx/inc/svx/galtheme.hxx b/svx/inc/svx/galtheme.hxx
index 337ba9e..82aef8f 100644
--- a/svx/inc/svx/galtheme.hxx
+++ b/svx/inc/svx/galtheme.hxx
@@ -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 );
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 4cbe7cf..6810ca4 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -378,83 +378,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() ) )
-                {
-                    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 );
+                // draw checkered background
+                drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
             }
 
-            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 );
+        //}
     }
 }
 
@@ -637,80 +712,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_RESID( 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() ) )
-                    {
-                        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 );
+                    // 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 3e81b42..4d8b48d 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -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 )
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index 5642f5e..d6af226 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -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 );


More information about the Libreoffice-commits mailing list