[Libreoffice-commits] .: Branch 'feature/template-dialog' - 10 commits - sfx2/inc sfx2/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Sun Jun 17 19:55:10 PDT 2012


 sfx2/inc/sfx2/thumbnailview.hxx           |    7 
 sfx2/inc/sfx2/thumbnailviewitem.hxx       |   21 +
 sfx2/source/control/thumbnailview.cxx     |  535 ++++++++++++++++--------------
 sfx2/source/control/thumbnailviewacc.cxx  |    4 
 sfx2/source/control/thumbnailviewitem.cxx |   49 ++
 5 files changed, 360 insertions(+), 256 deletions(-)

New commits:
commit e079a0a3c3481de8d547a624c41aac6310618c0d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 22:25:09 2012 -0430

    Fix hiding a selected item checkbox when you disable selection mode.
    
    Change-Id: I1825bfffa06e7bb69f232d9630af3b236023c6e0

diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index b85c726..f5fa81f 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -119,7 +119,9 @@ void ThumbnailViewItem::calculateItemsPosition ()
 void ThumbnailViewItem::setSelectionMode (bool mode)
 {
     mbMode = mode;
-    mpSelectBox->Show(mode);
+
+    if (!mbHover && !mbSelected)
+        mpSelectBox->Show(mode);
 }
 
 void ThumbnailViewItem::setSelectClickHdl (const Link &link)
commit aced0ce4687bb41d1370a7ea69c839f55d000171
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 22:00:59 2012 -0430

    Select item when clicking name while not in selection mode.
    
    Change-Id: I924dc61548490ef2947b82da1f1043257e1cac8d

diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index a43debc..730c4aa 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -83,6 +83,8 @@ struct ThumbnailViewItem
 
     void setSelectClickHdl (const Link &link);
 
+    bool isInsideTitle (const Point &pt) const;
+
 private:
 
     DECL_LINK (OnClick, CheckBox *);
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 16328cf..33f8d13 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -822,6 +822,14 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt )
                     }
                     else
                     {
+                        if (pItem->isInsideTitle(rMEvt.GetPosPixel()))
+                        {
+                            pItem->setSelection(!pItem->isSelected());
+
+                            if (!pItem->isHighlighted())
+                                DrawItem(pItem);
+                        }
+
                         //StartTracking( STARTTRACK_SCROLLREPEAT );
                     }
                 }
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 1d67e51..b85c726 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -127,6 +127,14 @@ void ThumbnailViewItem::setSelectClickHdl (const Link &link)
     maClickHdl = link;
 }
 
+bool ThumbnailViewItem::isInsideTitle (const Point &pt) const
+{
+    Rectangle aRect(Point(maTextPos.X(),mpSelectBox->GetPosPixel().Y()),
+                    Point(maDrawArea.Right(),maDrawArea.Bottom()));
+
+    return aRect.IsInside(pt);
+}
+
 IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, )
 {
     mbSelected = mpSelectBox->GetState() == STATE_CHECK;
commit 5e69dc61933b20e4d1de903a340ad74940145062
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 21:09:55 2012 -0430

    Dont recalculate item layout positions.
    
    Change-Id: I7d0de83e8bbd0475742d32d5f080bfddfb4345a0

diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 481d709..a43debc 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -73,6 +73,12 @@ struct ThumbnailViewItem
 
     void calculateItemsPosition ();
 
+    const Point& getTextPos () const { return maTextPos; }
+
+    const Point& getPrev1Pos () const { return maPrev1Pos; }
+
+    const Point& getPrev2Pos () const { return maPrev2Pos; }
+
     void setSelectionMode (bool mode);
 
     void setSelectClickHdl (const Link &link);
@@ -84,6 +90,9 @@ private:
 private:
 
     bool mbMode;
+    Point maTextPos;
+    Point maPrev1Pos;
+    Point maPrev2Pos;
     Rectangle maDrawArea;
     Link maClickHdl;
     CheckBox *mpSelectBox;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 12582a1..16328cf 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -350,12 +350,8 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem)
                                             aFillColor));
 
         // Draw thumbnail
-        Point aPos = aRect.TopLeft();
+        Point aPos = pItem->getPrev1Pos();
         Size aImageSize = pItem->maPreview1.GetSizePixel();
-        Size aRectSize = aRect.GetSize();
-        aPos.X() = aRect.Left() + (aRectSize.Width()-aImageSize.Width())/2;
-        aPos.Y() = aRect.Top() + (aRectSize.Height()-aImageSize.Height())/2;
-
 
         float fScaleX = 1.0f;
         float fScaleY = 1.0f;
@@ -383,9 +379,7 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem)
                                             ));
 
         // Draw centered text below thumbnail
-        aPos.Y() += aImageSize.Height();
-        aPos.Y() = aPos.Y() + GetTextHeight() + (aRect.Bottom() - aPos.Y() - GetTextHeight())/2;
-        aPos.X() = aRect.Left() + (aRectSize.Width() - GetTextWidth(pItem->maText))/2;
+        aPos = pItem->getTextPos();
 
         // Create the text primitive
         B2DVector aFontSize;
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 0e6c4c3..1d67e51 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -101,11 +101,13 @@ void ThumbnailViewItem::calculateItemsPosition ()
     Point aPos = maDrawArea.TopLeft();
     aPos.X() = maDrawArea.Left() + (aRectSize.Width()-aImageSize.Width())/2;
     aPos.Y() = maDrawArea.Top() + (aRectSize.Height()-aImageSize.Height())/2;
+    maPrev1Pos = aPos;
 
     // Calculate text position
     aPos.Y() += aImageSize.Height();
     aPos.Y() = aPos.Y() + aTextDev.getTextHeight() + (maDrawArea.Bottom() - aPos.Y() - aTextDev.getTextHeight())/2;
     aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,0,maText.getLength()))/2;
+    maTextPos = aPos;
 
     // Calculate checkbox position
     aPos.Y() -= aTextDev.getTextHeight();
commit ed986915694899f24d4a3ac12d563dcbbac7da6f
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 18:05:22 2012 -0430

    Dont set selection box position in constructor.
    
    Change-Id: Ie696820d5610cb91210e2c214705435c9760dbeb

diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index c600b01..0e6c4c3 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -45,7 +45,6 @@ ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, Window *pParent)
     , mbMode(false)
     , mpSelectBox(new CheckBox(pParent,WB_HIDE | WB_NOPOINTERFOCUS))
 {
-    mpSelectBox->SetPosPixel(Point(0,0));
     mpSelectBox->SetSizePixel(Size(20,20));
     mpSelectBox->SetClickHdl(LINK(this,ThumbnailViewItem,OnClick));
 }
commit 3a4b18729a6b7d7a42910882941b1f4934c7032c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 18:04:13 2012 -0430

    Improve calculating positions of item data.
    
    Change-Id: Ie07d9cf522d49bb4c48ba3a8ad937135349721f8

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index f2aee1f..12582a1 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -383,7 +383,8 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem)
                                             ));
 
         // Draw centered text below thumbnail
-        aPos.Y() += 20 + aImageSize.Height();
+        aPos.Y() += aImageSize.Height();
+        aPos.Y() = aPos.Y() + GetTextHeight() + (aRect.Bottom() - aPos.Y() - GetTextHeight())/2;
         aPos.X() = aRect.Left() + (aRectSize.Width() - GetTextWidth(pItem->maText))/2;
 
         // Create the text primitive
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 6b0c026..c600b01 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -28,6 +28,7 @@
 
 #include "thumbnailviewacc.hxx"
 
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
 #include <sfx2/thumbnailviewitem.hxx>
 #include <vcl/button.hxx>
 #include <vcl/svapp.hxx>
@@ -92,6 +93,8 @@ void ThumbnailViewItem::setDrawArea (const Rectangle &area)
 
 void ThumbnailViewItem::calculateItemsPosition ()
 {
+    drawinglayer::primitive2d::TextLayouterDevice aTextDev;
+
     Size aRectSize = maDrawArea.GetSize();
     Size aImageSize = maPreview1.GetSizePixel();
 
@@ -101,11 +104,12 @@ void ThumbnailViewItem::calculateItemsPosition ()
     aPos.Y() = maDrawArea.Top() + (aRectSize.Height()-aImageSize.Height())/2;
 
     // Calculate text position
-    aPos.Y() += 20 + aImageSize.Height();
-    //aPos.X() = aRect.Left() + (aRectSize.Width() - GetTextWidth(pItem->maText))/2;
+    aPos.Y() += aImageSize.Height();
+    aPos.Y() = aPos.Y() + aTextDev.getTextHeight() + (maDrawArea.Bottom() - aPos.Y() - aTextDev.getTextHeight())/2;
+    aPos.X() = maDrawArea.Left() + (aRectSize.Width() - aTextDev.getTextWidth(maText,0,maText.getLength()))/2;
 
     // Calculate checkbox position
-    aPos.Y() -= mpSelectBox->GetTextHeight();
+    aPos.Y() -= aTextDev.getTextHeight();
     aPos.X() = maDrawArea.Left() + 15;
 
     mpSelectBox->SetPosPixel(aPos);
commit 0cb7d3d5491fcbd47f4cf709da5ec01fc6d4382a
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 15:58:57 2012 -0430

    Use parent background color as default in view.
    
    Change-Id: I5871d7e20789c9b6485560b7cab4b674c46b1a2a

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 8b01b5c..f2aee1f 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -189,7 +189,7 @@ BitmapEx lcl_fetchThumbnail (const rtl::OUString &msURL, int width, int height)
 
 ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren)
     : Control( pParent, nWinStyle ),
-    maColor( COL_TRANSPARENT )
+    maColor( pParent->GetBackground().GetColor() )
 {
     ImplInit();
     mbIsTransientChildrenDisabled = bDisableTransientChildren;
@@ -197,7 +197,7 @@ ThumbnailView::ThumbnailView (Window *pParent, WinBits nWinStyle, bool bDisableT
 
 ThumbnailView::ThumbnailView (Window *pParent, const ResId &rResId, bool bDisableTransientChildren)
     : Control( pParent, rResId ),
-    maColor( COL_TRANSPARENT )
+    maColor( pParent->GetBackground().GetColor() )
 {
     ImplInit();
     mbIsTransientChildrenDisabled = bDisableTransientChildren;
commit 4fc040ecd10487b2eb54d3d28e9e9fdb4acafb53
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 09:26:30 2012 -0430

    Display selection boxes under selection mode.
    
    Change-Id: I7a83bb57122912c6f21a78a53b34584410857162

diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 8cf1ee0..481d709 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -73,6 +73,8 @@ struct ThumbnailViewItem
 
     void calculateItemsPosition ();
 
+    void setSelectionMode (bool mode);
+
     void setSelectClickHdl (const Link &link);
 
 private:
@@ -81,6 +83,7 @@ private:
 
 private:
 
+    bool mbMode;
     Rectangle maDrawArea;
     Link maClickHdl;
     CheckBox *mpSelectBox;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index a33a4a1..8b01b5c 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1652,6 +1652,12 @@ long ThumbnailView::GetScrollWidth() const
 void ThumbnailView::setSelectionMode (bool mode)
 {
     mbSelectionMode = mode;
+
+    for (size_t i = 0, n = mItemList.size(); i < n; ++i)
+    {
+        if (mItemList[i]->mbVisible)
+            mItemList[i]->setSelectionMode(mode);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 04d8dc3..6b0c026 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -41,6 +41,7 @@ ThumbnailViewItem::ThumbnailViewItem(ThumbnailView &rView, Window *pParent)
     , mbSelected(false)
     , mbHover(false)
     , mpxAcc(NULL)
+    , mbMode(false)
     , mpSelectBox(new CheckBox(pParent,WB_HIDE | WB_NOPOINTERFOCUS))
 {
     mpSelectBox->SetPosPixel(Point(0,0));
@@ -110,6 +111,12 @@ void ThumbnailViewItem::calculateItemsPosition ()
     mpSelectBox->SetPosPixel(aPos);
 }
 
+void ThumbnailViewItem::setSelectionMode (bool mode)
+{
+    mbMode = mode;
+    mpSelectBox->Show(mode);
+}
+
 void ThumbnailViewItem::setSelectClickHdl (const Link &link)
 {
     maClickHdl = link;
commit b4d7031880369156e08428ff1d9255ea9af0cc36
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 02:45:34 2012 -0430

    Remove GetItemRect and ImplGetItemRect functions.
    
    Change-Id: Id64d46d3cb25a19a1acb5753d7cf4e4e21d29aea

diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 1a96713..1fe45f0 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -180,8 +180,6 @@ public:
 
     sal_uInt16 GetItemId( const Point& rPos ) const;
 
-    Rectangle GetItemRect( sal_uInt16 nItemId ) const;
-
     void SetColCount( sal_uInt16 nNewCols = 1 );
 
     sal_uInt16 GetColCount() const { return mnUserCols; }
@@ -289,7 +287,6 @@ private:
     SVT_DLLPRIVATE sal_uInt16          ImplGetVisibleItemCount() const;
     SVT_DLLPRIVATE ThumbnailViewItem*    ImplGetVisibleItem( sal_uInt16 nVisiblePos );
     SVT_DLLPRIVATE void         ImplInsertItem( ThumbnailViewItem *const pItem, const size_t nPos );
-    SVT_DLLPRIVATE Rectangle    ImplGetItemRect( size_t nPos ) const;
     SVT_DLLPRIVATE void            ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
     SVT_DLLPRIVATE bool         ImplHasAccessibleListeners();
     SVT_DLLPRIVATE void         ImplTracking( const Point& rPos, bool bRepeat );
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 2298eb7..a33a4a1 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -1254,26 +1254,6 @@ void ThumbnailView::ImplInsertItem( ThumbnailViewItem *const pItem, const size_t
         Invalidate();
 }
 
-Rectangle ThumbnailView::ImplGetItemRect( size_t nPos ) const
-{
-    const size_t nVisibleBegin = static_cast<size_t>(mnFirstLine)*mnCols;
-    const size_t nVisibleEnd = nVisibleBegin + static_cast<size_t>(mnVisLines)*mnCols;
-
-    // Check if the item is inside the range of the displayed ones,
-    // taking into account that last row could be incomplete
-    if ( nPos<nVisibleBegin || nPos>=nVisibleEnd || nPos>=mItemList.size() )
-        return Rectangle();
-
-    nPos -= nVisibleBegin;
-
-    const size_t row = nPos/mnCols;
-    const size_t col = nPos%mnCols;
-    const long x = maItemListRect.Left()+col*(mnItemWidth+mnSpacing);
-    const long y = maItemListRect.Top()+row*(mnItemHeight+mnSpacing);
-
-    return Rectangle( Point(x, y), Size(mnItemWidth, mnItemHeight) );
-}
-
 void ThumbnailView::RemoveItem( sal_uInt16 nItemId )
 {
     size_t nPos = GetItemPos( nItemId );
@@ -1347,16 +1327,6 @@ sal_uInt16 ThumbnailView::GetItemId( const Point& rPos ) const
     return 0;
 }
 
-Rectangle ThumbnailView::GetItemRect( sal_uInt16 nItemId ) const
-{
-    const size_t nPos = GetItemPos( nItemId );
-
-    if ( nPos!=THUMBNAILVIEW_ITEM_NOTFOUND && mItemList[nPos]->mbVisible )
-        return ImplGetItemRect( nPos );
-
-    return Rectangle();
-}
-
 void ThumbnailView::SetColCount( sal_uInt16 nNewCols )
 {
     if ( mnUserCols != nNewCols )
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index 8534b5e..680a469 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -910,7 +910,7 @@ awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
 
     if( mpParent )
     {
-        Rectangle   aRect( mpParent->mrParent.GetItemRect(mpParent->mnId) );
+        Rectangle   aRect( mpParent->getDrawArea() );
         Point       aOrigin;
         Rectangle   aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
 
@@ -945,7 +945,7 @@ awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
 
     if( mpParent )
     {
-        const Point aPos = mpParent->mrParent.GetItemRect(mpParent->mnId).TopLeft();
+        const Point aPos = mpParent->getDrawArea().TopLeft();
         const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( aPos ) );
 
         aRet.X = aScreenPos.X();
commit 00c579fd6d331a6868040406d8264b2f545dc151
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Jun 17 02:37:46 2012 -0430

    Use item draw area when drawing.
    
    Change-Id: If94ddf07092e1247800025f9f093a3ae78fa26f4

diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 99a536c..1a96713 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -265,7 +265,7 @@ protected:
 
     // Drawing item related functions, override them to make your own custom ones.
 
-    virtual void DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect);
+    virtual void DrawItem (ThumbnailViewItem *pItem);
 
 private:
 
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 2df59ca..2298eb7 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -323,8 +323,10 @@ void ThumbnailView::ImplInitScrollBar()
     }
 }
 
-void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
+void ThumbnailView::DrawItem (ThumbnailViewItem *pItem)
 {
+    Rectangle aRect = pItem->getDrawArea();
+
     if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
     {
         int nCount = 0;
@@ -800,7 +802,7 @@ void ThumbnailView::ImplEndTracking( const Point& rPos, bool bCancel )
 
 IMPL_LINK (ThumbnailView, OnFolderSelected, ThumbnailViewItem*, pItem)
 {
-    DrawItem(pItem,GetItemRect(pItem->mnId));
+    DrawItem(pItem);
     return 0;
 }
 
@@ -821,7 +823,7 @@ void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt )
                         pItem->setSelection(!pItem->isSelected());
 
                         if (!pItem->isHighlighted())
-                            DrawItem(pItem,GetItemRect(pItem->mnId));
+                            DrawItem(pItem);
                     }
                     else
                     {
@@ -861,14 +863,14 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt )
                 pOld->setHighlight(false);
 
                 if (!pOld->isSelected())
-                    DrawItem(pOld,GetItemRect(pOld->mnId));
+                    DrawItem(pOld);
             }
 
             mnHighItemId = pItem->mnId;
             pItem->setHighlight(true);
 
             if (!pItem->isSelected())
-                DrawItem(pItem,GetItemRect(pItem->mnId));
+                DrawItem(pItem);
         }
     }
     else
@@ -884,7 +886,7 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt )
                 pOld->setHighlight(false);
 
                 if (!pOld->isSelected())
-                    DrawItem(pOld,GetItemRect(pOld->mnId));
+                    DrawItem(pOld);
             }
 
             mnHighItemId = 0;
@@ -1071,7 +1073,7 @@ void ThumbnailView::Paint( const Rectangle& )
 
         if ( (i >= nFirstItem) && (i < nLastItem) )
         {
-            DrawItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) );
+            DrawItem(pItem);
 
             if ( !((i+1) % mnCols) )
             {
@@ -1110,7 +1112,7 @@ void ThumbnailView::LoseFocus()
             pOld->setHighlight(false);
 
             if (!pOld->isSelected())
-                DrawItem(pOld,GetItemRect(pOld->mnId));
+                DrawItem(pOld);
         }
 
         mnHighItemId = 0;
commit 661a98b831f75be225b7d0824b29e481c4208c83
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Jun 16 19:15:23 2012 -0430

    Calculate item positions only when needed instead of every paint.
    
    Change-Id: I8e7e528185624494e8ca9e07a44b90131a1165b9

diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 8b32122..99a536c 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -274,6 +274,8 @@ private:
     using Control::ImplInitSettings;
     using Window::ImplInit;
 
+    void CalculateItemPositions ();
+
     SVT_DLLPRIVATE void         ImplInit();
     SVT_DLLPRIVATE void         ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
     SVT_DLLPRIVATE void         ImplInitScrollBar();
diff --git a/sfx2/inc/sfx2/thumbnailviewitem.hxx b/sfx2/inc/sfx2/thumbnailviewitem.hxx
index 30eb42e..8cf1ee0 100644
--- a/sfx2/inc/sfx2/thumbnailviewitem.hxx
+++ b/sfx2/inc/sfx2/thumbnailviewitem.hxx
@@ -67,7 +67,11 @@ struct ThumbnailViewItem
     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
                         GetAccessible( bool bIsTransientChildrenDisabled );
 
-    void setSelectionBoxPos (const Point &pos);
+    void setDrawArea (const Rectangle &area);
+
+    const Rectangle& getDrawArea () const { return maDrawArea; }
+
+    void calculateItemsPosition ();
 
     void setSelectClickHdl (const Link &link);
 
@@ -77,6 +81,7 @@ private:
 
 private:
 
+    Rectangle maDrawArea;
     Link maClickHdl;
     CheckBox *mpSelectBox;
 };
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 05386f3..2df59ca 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -409,11 +409,6 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
                         *this, aNewViewInfos );
 
         pProcessor->process(aSeq);
-
-        aPos.Y() -= GetTextHeight();
-        aPos.X() = aRect.Left() + 15;
-
-        pItem->setSelectionBoxPos(aPos);
     }
 }
 
@@ -422,6 +417,222 @@ void ThumbnailView::DrawItem (ThumbnailViewItem *pItem, const Rectangle &aRect)
     return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled );
 }
 
+void ThumbnailView::CalculateItemPositions ()
+{
+    Size        aWinSize = GetOutputSizePixel();
+    size_t      nItemCount = mItemList.size();
+    WinBits     nStyle = GetStyle();
+    long        nNoneHeight = 0;
+    long        nNoneSpace = 0;
+    ScrollBar*  pDelScrBar = NULL;
+
+    // consider the scrolling
+    if ( nStyle & WB_VSCROLL )
+        ImplInitScrollBar();
+    else
+    {
+        if ( mpScrBar )
+        {
+            // delete ScrollBar not until later, to prevent recursive calls
+            pDelScrBar = mpScrBar;
+            mpScrBar = NULL;
+        }
+    }
+
+    // calculate ScrollBar width
+    long nScrBarWidth = 0;
+    if ( mpScrBar )
+        nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
+
+    // calculate number of columns
+    if ( !mnUserCols )
+    {
+        if ( mnUserItemWidth )
+        {
+            mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing));
+            if ( !mnCols )
+                mnCols = 1;
+        }
+        else
+            mnCols = 1;
+    }
+    else
+        mnCols = mnUserCols;
+
+    // calculate number of rows
+    mbScroll = false;
+    // Floor( (M+N-1)/N )==Ceiling( M/N )
+    mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols;
+    if ( !mnLines )
+        mnLines = 1;
+
+    long nCalcHeight = aWinSize.Height()-nNoneHeight;
+    if ( mnUserVisLines )
+        mnVisLines = mnUserVisLines;
+    else if ( mnUserItemHeight )
+    {
+        mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing);
+        if ( !mnVisLines )
+            mnVisLines = 1;
+    }
+    else
+        mnVisLines = mnLines;
+    if ( mnLines > mnVisLines )
+        mbScroll = true;
+    if ( mnLines <= mnVisLines )
+        mnFirstLine = 0;
+    else
+    {
+        if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
+            mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
+    }
+
+    // calculate item size
+    const long nColSpace  = (mnCols-1)*mnSpacing;
+    const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace;
+    if ( mnUserItemWidth && !mnUserCols )
+    {
+        mnItemWidth = mnUserItemWidth;
+        if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace )
+            mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace;
+    }
+    else
+        mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols;
+    if ( mnUserItemHeight && !mnUserVisLines )
+    {
+        mnItemHeight = mnUserItemHeight;
+        if ( mnItemHeight > nCalcHeight-nNoneSpace )
+            mnItemHeight = nCalcHeight-nNoneSpace;
+    }
+    else
+    {
+        nCalcHeight -= nLineSpace;
+        mnItemHeight = nCalcHeight / mnVisLines;
+    }
+
+    // nothing is changed in case of too small items
+    if ( (mnItemWidth <= 0) ||
+         (mnItemHeight <= 2) ||
+         !nItemCount )
+    {
+        mbHasVisibleItems = false;
+
+        for ( size_t i = 0; i < nItemCount; i++ )
+        {
+            mItemList[i]->mbVisible = false;
+        }
+
+        if ( mpScrBar )
+            mpScrBar->Hide();
+    }
+    else
+    {
+        mbHasVisibleItems = true;
+
+        // determine Frame-Style
+        mnFrameStyle = FRAME_DRAW_IN;
+
+        // determine selected color and width
+        // if necessary change the colors, to make the selection
+        // better detectable
+        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+        Color aHighColor( rStyleSettings.GetHighlightColor() );
+        if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
+              (aHighColor.GetBlue() > 0x80)) ||
+             ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
+              (aHighColor.GetBlue() == 0x80)) )
+            mbBlackSel = true;
+        else
+            mbBlackSel = false;
+
+        // draw the selection with double width if the items are bigger
+        mbDoubleSel = false;
+
+        // calculate offsets
+        long nStartX = 0;
+        long nStartY = 0;
+
+        // calculate and draw items
+        long x = nStartX;
+        long y = nStartY;
+
+        // draw items
+        sal_uLong nFirstItem = mnFirstLine * mnCols;
+        sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
+
+        maItemListRect.Left() = x;
+        maItemListRect.Top() = y;
+        maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1;
+        maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1;
+
+        // If want also draw parts of items in the last line,
+        // then we add one more line if parts of these line are
+        // visible
+        if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() )
+            nLastItem += mnCols;
+        maItemListRect.Bottom() = aWinSize.Height() - y;
+
+        for ( size_t i = 0; i < nItemCount; i++ )
+        {
+            ThumbnailViewItem *const pItem = mItemList[i];
+
+            if ( (i >= nFirstItem) && (i < nLastItem) )
+            {
+                if( !pItem->mbVisible && ImplHasAccessibleListeners() )
+                {
+                    ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+                    aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                    ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+                }
+
+                pItem->mbVisible = true;
+                pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
+                pItem->calculateItemsPosition();
+
+                if ( !((i+1) % mnCols) )
+                {
+                    x = nStartX;
+                    y += mnItemHeight+mnSpacing;
+                }
+                else
+                    x += mnItemWidth+mnSpacing;
+            }
+            else
+            {
+                if( pItem->mbVisible && ImplHasAccessibleListeners() )
+                {
+                    ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+                    aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                    ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+                }
+
+                pItem->mbVisible = false;
+            }
+        }
+
+        // arrange ScrollBar, set values and show it
+        if ( mpScrBar )
+        {
+            Point   aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 );
+            Size    aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() );
+
+            mpScrBar->SetPosSizePixel( aPos, aSize );
+            mpScrBar->SetRangeMax( mnLines );
+            mpScrBar->SetVisibleSize( mnVisLines );
+            mpScrBar->SetThumbPos( (long)mnFirstLine );
+            long nPageSize = mnVisLines;
+            if ( nPageSize < 1 )
+                nPageSize = 1;
+            mpScrBar->SetPageSize( nPageSize );
+        }
+    }
+
+    // delete ScrollBar
+    delete pDelScrBar;
+}
+
 bool ThumbnailView::ImplScroll( const Point& rPos )
 {
     if ( !mbScroll || !maItemListRect.IsInside(rPos) )
@@ -835,216 +1046,45 @@ void ThumbnailView::Paint( const Rectangle& )
 {
     Size        aWinSize = GetOutputSizePixel();
     size_t      nItemCount = mItemList.size();
-    WinBits     nStyle = GetStyle();
-    long        nNoneHeight = 0;
-    long        nNoneSpace = 0;
-    ScrollBar*  pDelScrBar = NULL;
 
-    // consider the scrolling
-    if ( nStyle & WB_VSCROLL )
-        ImplInitScrollBar();
-    else
-    {
-        if ( mpScrBar )
-        {
-            // delete ScrollBar not until later, to prevent recursive calls
-            pDelScrBar = mpScrBar;
-            mpScrBar = NULL;
-        }
-    }
-
-    // calculate ScrollBar width
-    long nScrBarWidth = 0;
-    if ( mpScrBar )
-        nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
-
-    // calculate number of columns
-    if ( !mnUserCols )
-    {
-        if ( mnUserItemWidth )
-        {
-            mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing));
-            if ( !mnCols )
-                mnCols = 1;
-        }
-        else
-            mnCols = 1;
-    }
-    else
-        mnCols = mnUserCols;
-
-    // calculate number of rows
-    mbScroll = false;
-    // Floor( (M+N-1)/N )==Ceiling( M/N )
-    mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols;
-    if ( !mnLines )
-        mnLines = 1;
-
-    long nCalcHeight = aWinSize.Height()-nNoneHeight;
-    if ( mnUserVisLines )
-        mnVisLines = mnUserVisLines;
-    else if ( mnUserItemHeight )
-    {
-        mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing);
-        if ( !mnVisLines )
-            mnVisLines = 1;
-    }
-    else
-        mnVisLines = mnLines;
-    if ( mnLines > mnVisLines )
-        mbScroll = true;
-    if ( mnLines <= mnVisLines )
-        mnFirstLine = 0;
-    else
-    {
-        if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
-            mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
-    }
+    // calculate offsets
+    long nStartX = 0;
+    long nStartY = 0;
 
-    // calculate item size
-    const long nColSpace  = (mnCols-1)*mnSpacing;
-    const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace;
-    if ( mnUserItemWidth && !mnUserCols )
-    {
-        mnItemWidth = mnUserItemWidth;
-        if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace )
-            mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace;
-    }
-    else
-        mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols;
-    if ( mnUserItemHeight && !mnUserVisLines )
-    {
-        mnItemHeight = mnUserItemHeight;
-        if ( mnItemHeight > nCalcHeight-nNoneSpace )
-            mnItemHeight = nCalcHeight-nNoneSpace;
-    }
-    else
-    {
-        nCalcHeight -= nLineSpace;
-        mnItemHeight = nCalcHeight / mnVisLines;
-    }
+    // calculate and draw items
+    long x = nStartX;
+    long y = nStartY;
 
-    // nothing is changed in case of too small items
-    if ( (mnItemWidth <= 0) ||
-         (mnItemHeight <= 2) ||
-         !nItemCount )
-    {
-        mbHasVisibleItems = false;
+    // draw items
+    sal_uLong nFirstItem = mnFirstLine * mnCols;
+    sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
 
-        for ( size_t i = 0; i < nItemCount; i++ )
-        {
-            mItemList[i]->mbVisible = false;
-        }
+    // If want also draw parts of items in the last line,
+    // then we add one more line if parts of these line are
+    // visible
+    if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() )
+        nLastItem += mnCols;
 
-        if ( mpScrBar )
-            mpScrBar->Hide();
-    }
-    else
+    for ( size_t i = 0; i < nItemCount; i++ )
     {
-        mbHasVisibleItems = true;
-
-        // determine Frame-Style
-        mnFrameStyle = FRAME_DRAW_IN;
-
-        // determine selected color and width
-        // if necessary change the colors, to make the selection
-        // better detectable
-        const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-        Color aHighColor( rStyleSettings.GetHighlightColor() );
-        if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
-              (aHighColor.GetBlue() > 0x80)) ||
-             ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
-              (aHighColor.GetBlue() == 0x80)) )
-            mbBlackSel = true;
-        else
-            mbBlackSel = false;
-
-        // draw the selection with double width if the items are bigger
-        mbDoubleSel = false;
-
-        // calculate offsets
-        long nStartX = 0;
-        long nStartY = 0;
-
-        // calculate and draw items
-        long x = nStartX;
-        long y = nStartY;
-
-        // draw items
-        sal_uLong nFirstItem = mnFirstLine * mnCols;
-        sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
-
-        maItemListRect.Left() = x;
-        maItemListRect.Top() = y;
-        maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1;
-        maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1;
-
-        // If want also draw parts of items in the last line,
-        // then we add one more line if parts of these line are
-        // visible
-        if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() )
-            nLastItem += mnCols;
-        maItemListRect.Bottom() = aWinSize.Height() - y;
+        ThumbnailViewItem *const pItem = mItemList[i];
 
-        for ( size_t i = 0; i < nItemCount; i++ )
+        if ( (i >= nFirstItem) && (i < nLastItem) )
         {
-            ThumbnailViewItem *const pItem = mItemList[i];
+            DrawItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) );
 
-            if ( (i >= nFirstItem) && (i < nLastItem) )
+            if ( !((i+1) % mnCols) )
             {
-                if( !pItem->mbVisible && ImplHasAccessibleListeners() )
-                {
-                    ::com::sun::star::uno::Any aOldAny, aNewAny;
-
-                    aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
-                    ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
-                }
-
-                pItem->mbVisible = true;
-                DrawItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) );
-
-                if ( !((i+1) % mnCols) )
-                {
-                    x = nStartX;
-                    y += mnItemHeight+mnSpacing;
-                }
-                else
-                    x += mnItemWidth+mnSpacing;
+                x = nStartX;
+                y += mnItemHeight+mnSpacing;
             }
             else
-            {
-                if( pItem->mbVisible && ImplHasAccessibleListeners() )
-                {
-                    ::com::sun::star::uno::Any aOldAny, aNewAny;
-
-                    aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
-                    ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
-                }
-
-                pItem->mbVisible = false;
-            }
-        }
-
-        // arrange ScrollBar, set values and show it
-        if ( mpScrBar )
-        {
-            Point   aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 );
-            Size    aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() );
-
-            mpScrBar->SetPosSizePixel( aPos, aSize );
-            mpScrBar->SetRangeMax( mnLines );
-            mpScrBar->SetVisibleSize( mnVisLines );
-            mpScrBar->SetThumbPos( (long)mnFirstLine );
-            long nPageSize = mnVisLines;
-            if ( nPageSize < 1 )
-                nPageSize = 1;
-            mpScrBar->SetPageSize( nPageSize );
-            mpScrBar->Show();
+                x += mnItemWidth+mnSpacing;
         }
     }
 
-    // delete ScrollBar
-    delete pDelScrBar;
+    if ( mpScrBar && mpScrBar->IsVisible() )
+        mpScrBar->Invalidate();
 }
 
 void ThumbnailView::GetFocus()
@@ -1086,6 +1126,8 @@ void ThumbnailView::LoseFocus()
 
 void ThumbnailView::Resize()
 {
+    CalculateItemPositions();
+
     if ( IsReallyVisible() && IsUpdateMode() )
         Invalidate();
     Control::Resize();
@@ -1174,6 +1216,8 @@ void ThumbnailView::Populate ()
         }
     }
 
+    CalculateItemPositions();
+
     if ( IsReallyVisible() && IsUpdateMode() )
         Invalidate();
 }
@@ -1202,6 +1246,8 @@ void ThumbnailView::ImplInsertItem( ThumbnailViewItem *const pItem, const size_t
         mItemList.push_back( pItem );
     }
 
+    CalculateItemPositions();
+
     if ( IsReallyVisible() && IsUpdateMode() )
         Invalidate();
 }
@@ -1248,6 +1294,8 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId )
         mnSelItemId     = 0;
     }
 
+    CalculateItemPositions();
+
     if ( IsReallyVisible() && IsUpdateMode() )
         Invalidate();
 }
@@ -1262,6 +1310,8 @@ void ThumbnailView::Clear()
     mnHighItemId    = 0;
     mnSelItemId     = 0;
 
+    CalculateItemPositions();
+
     if ( IsReallyVisible() && IsUpdateMode() )
         Invalidate();
 }
@@ -1310,6 +1360,9 @@ void ThumbnailView::SetColCount( sal_uInt16 nNewCols )
     if ( mnUserCols != nNewCols )
     {
         mnUserCols = nNewCols;
+
+        CalculateItemPositions();
+
         if ( IsReallyVisible() && IsUpdateMode() )
             Invalidate();
     }
@@ -1320,6 +1373,9 @@ void ThumbnailView::SetLineCount( sal_uInt16 nNewLines )
     if ( mnUserVisLines != nNewLines )
     {
         mnUserVisLines = nNewLines;
+
+        CalculateItemPositions();
+
         if ( IsReallyVisible() && IsUpdateMode() )
             Invalidate();
     }
@@ -1330,6 +1386,9 @@ void ThumbnailView::SetItemWidth( long nNewItemWidth )
     if ( mnUserItemWidth != nNewItemWidth )
     {
         mnUserItemWidth = nNewItemWidth;
+
+        CalculateItemPositions();
+
         if ( IsReallyVisible() && IsUpdateMode() )
             Invalidate();
     }
@@ -1340,6 +1399,9 @@ void ThumbnailView::SetItemHeight( long nNewItemHeight )
     if ( mnUserItemHeight != nNewItemHeight )
     {
         mnUserItemHeight = nNewItemHeight;
+
+        CalculateItemPositions();
+
         if ( IsReallyVisible() && IsUpdateMode() )
             Invalidate();
     }
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index bb47118..04d8dc3 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -84,9 +84,30 @@ uno::Reference< accessibility::XAccessible > ThumbnailViewItem::GetAccessible( b
     return *mpxAcc;
 }
 
-void ThumbnailViewItem::setSelectionBoxPos (const Point &pos)
+void ThumbnailViewItem::setDrawArea (const Rectangle &area)
 {
-    mpSelectBox->SetPosPixel(pos);
+    maDrawArea = area;
+}
+
+void ThumbnailViewItem::calculateItemsPosition ()
+{
+    Size aRectSize = maDrawArea.GetSize();
+    Size aImageSize = maPreview1.GetSizePixel();
+
+    // Calculate thumbnail position
+    Point aPos = maDrawArea.TopLeft();
+    aPos.X() = maDrawArea.Left() + (aRectSize.Width()-aImageSize.Width())/2;
+    aPos.Y() = maDrawArea.Top() + (aRectSize.Height()-aImageSize.Height())/2;
+
+    // Calculate text position
+    aPos.Y() += 20 + aImageSize.Height();
+    //aPos.X() = aRect.Left() + (aRectSize.Width() - GetTextWidth(pItem->maText))/2;
+
+    // Calculate checkbox position
+    aPos.Y() -= mpSelectBox->GetTextHeight();
+    aPos.X() = maDrawArea.Left() + 15;
+
+    mpSelectBox->SetPosPixel(aPos);
 }
 
 void ThumbnailViewItem::setSelectClickHdl (const Link &link)


More information about the Libreoffice-commits mailing list