diff options
-rw-r--r-- | sfx2/inc/sfx2/thumbnailview.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/doc/templatedlg.cxx | 2 |
3 files changed, 31 insertions, 3 deletions
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx index 5058144d2b8e..c46a85444b72 100644 --- a/sfx2/inc/sfx2/thumbnailview.hxx +++ b/sfx2/inc/sfx2/thumbnailview.hxx @@ -273,6 +273,7 @@ protected: using Window::ImplInit; void CalculateItemPositions (); + void MakeItemVisible( sal_uInt16 nId ); SFX2_DLLPRIVATE void ImplInit(); SFX2_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index cc05d70eca7a..400b5ab97b81 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -550,13 +550,40 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt ) Control::KeyInput( rKEvt ); } - if ( pNext && pNext->isVisible() ) + if ( pNext ) { deselectItems(); SelectItem(pNext->mnId); + MakeItemVisible(pNext->mnId); } } +void ThumbnailView::MakeItemVisible( sal_uInt16 nItemId ) +{ + // Get the item row + size_t nPos = 0; + bool bFound = false; + for ( size_t i = 0; !bFound && i < mFilteredItemList.size(); ++i ) + { + ThumbnailViewItem* pItem = mFilteredItemList[i]; + if ( pItem->mnId == nItemId ) + { + nPos = i; + bFound = true; + } + } + sal_uInt16 nRow = nPos / mnCols; + + // Move the visible rows as little as possible to include that one + if ( nRow < mnFirstLine ) + mnFirstLine = nRow; + else if ( nRow > mnFirstLine + mnVisLines ) + mnFirstLine = nRow - mnVisLines; + + CalculateItemPositions(); + Invalidate(); +} + void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt ) { if ( rMEvt.IsLeft() ) @@ -700,11 +727,11 @@ void ThumbnailView::LoseFocus() void ThumbnailView::Resize() { + Control::Resize(); CalculateItemPositions(); if ( IsReallyVisible() && IsUpdateMode() ) Invalidate(); - Control::Resize(); } void ThumbnailView::StateChanged( StateChangedType nType ) diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 5f181095abc9..93740f15fcdf 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -332,7 +332,7 @@ void SfxTemplateManagerDlg::Resize() Point aViewPos = maView->GetPosPixel(); aViewPos.setY(nToolbarsHeight); aViewPos.setX(0); - Size aThumbSize(aWinSize.getWidth(), maTabControl.GetTabPageSizePixel().getWidth() - aViewPos.getY()); + Size aThumbSize(aWinSize.getWidth(), maTabControl.GetTabPageSizePixel().getHeight() - aViewPos.getY()); maView->SetPosSizePixel(aViewPos, aThumbSize); if (aWinSize.getHeight() < aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER) |