[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sfx2/inc sfx2/source
Cédric Bosdonnat
cedric.bosdonnat at free.fr
Fri Mar 22 10:10:06 PDT 2013
sfx2/inc/sfx2/thumbnailview.hxx | 8 -
sfx2/source/control/thumbnailview.cxx | 125 +++++--------------------------
sfx2/source/control/thumbnailviewacc.cxx | 2
3 files changed, 24 insertions(+), 111 deletions(-)
New commits:
commit e2ce03c2eaf1bdf6a3b736052be8e2ed8ef8c6ca
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date: Thu Mar 21 11:49:01 2013 +0100
Template Manager: removed some dead selection code
(cherry picked from commit bfd1bcb204ed3ca35df1455a346a0ee7254a1191)
Conflicts:
sfx2/source/control/thumbnailview.cxx
Change-Id: Ib5ebcd928e77a115f4f62a50724656c33ae13c61
Reviewed-on: https://gerrit.libreoffice.org/2911
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 8eb9426..efc5e78 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -202,10 +202,7 @@ public:
void SelectItem( sal_uInt16 nItemId );
- sal_uInt16 GetSelectItemId() const { return mnSelItemId; }
-
- bool IsItemSelected( sal_uInt16 nItemId ) const
- { return nItemId == mnSelItemId; }
+ bool IsItemSelected( sal_uInt16 nItemId ) const;
void deselectItem (const sal_uInt16 nItemId);
@@ -258,8 +255,6 @@ protected:
virtual void DataChanged( const DataChangedEvent& rDCEvt );
- virtual bool StartDrag( const CommandEvent& rCEvt, Region& rRegion );
-
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
protected:
@@ -310,7 +305,6 @@ protected:
long mnVisLines;
long mnLines;
sal_uInt16 mnScrBarOffset;
- sal_uInt16 mnSelItemId;
sal_uInt16 mnHighItemId;
sal_uInt16 mnCols;
sal_uInt16 mnFirstLine;
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 57dba07..63ba189 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -92,7 +92,6 @@ void ThumbnailView::ImplInit()
mnLines = 0;
mnFirstLine = 0;
mnScrBarOffset = 1;
- mnSelItemId = 0;
mnHighItemId = 0;
mnCols = 0;
mnSpacing = 0;
@@ -589,11 +588,7 @@ void ThumbnailView::GetFocus()
if ( nSelected == -1 && mItemList.size( ) > 0 )
{
- mItemList[0]->setSelection(true);
- maItemStateHdl.Call(mItemList[0]);
-
- if (IsReallyVisible() && IsUpdateMode())
- Invalidate();
+ SelectItem( 1 );
}
// Tell the accessible object that we got the focus.
@@ -710,10 +705,9 @@ void ThumbnailView::RemoveItem( sal_uInt16 nItemId )
}
// reset variables
- if ( (mnHighItemId == nItemId) || (mnSelItemId == nItemId) )
+ if ( (mnHighItemId == nItemId) )
{
mnHighItemId = 0;
- mnSelItemId = 0;
}
CalculateItemPositions();
@@ -729,7 +723,6 @@ void ThumbnailView::Clear()
// reset variables
mnFirstLine = 0;
mnHighItemId = 0;
- mnSelItemId = 0;
CalculateItemPositions();
@@ -777,19 +770,18 @@ void ThumbnailView::setItemDimensions(long itemWidth, long thumbnailHeight, long
void ThumbnailView::SelectItem( sal_uInt16 nItemId )
{
- size_t nItemPos = 0;
+ size_t nItemPos = GetItemPos( nItemId );
+ if ( nItemPos == THUMBNAILVIEW_ITEM_NOTFOUND )
+ return;
- if ( nItemId )
+ ThumbnailViewItem* pItem = mItemList[nItemPos];
+ if (!pItem->isSelected())
{
- nItemPos = GetItemPos( nItemId );
- if ( nItemPos == THUMBNAILVIEW_ITEM_NOTFOUND )
- return;
- }
+ mItemList[nItemPos]->setSelection(true);
+ maItemStateHdl.Call(mItemList[nItemPos]);
- if ( mnSelItemId != nItemId)
- {
- sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1;
- mnSelItemId = nItemId;
+ if (IsReallyVisible() && IsUpdateMode())
+ Invalidate();
bool bNewOut = IsReallyVisible() && IsUpdateMode();
@@ -815,44 +807,8 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId )
if( ImplHasAccessibleListeners() )
{
- // focus event (deselect)
- if( nOldItem )
- {
- const size_t nPos = GetItemPos( nItemId );
-
- if( nPos != THUMBNAILVIEW_ITEM_NOTFOUND )
- {
- ThumbnailViewAcc* pItemAcc = ThumbnailViewAcc::getImplementation(
- mItemList[nPos]->GetAccessible( mbIsTransientChildrenDisabled ) );
-
- if( pItemAcc )
- {
- ::com::sun::star::uno::Any aOldAny, aNewAny;
- if( !mbIsTransientChildrenDisabled )
- {
- aOldAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
- static_cast< ::cppu::OWeakObject* >( pItemAcc ));
- ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
- }
- else
- {
- aOldAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
- pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
- }
- }
- }
- }
-
// focus event (select)
- const size_t nPos = GetItemPos( mnSelItemId );
-
- ThumbnailViewItem* pItem = NULL;
- if( nPos != THUMBNAILVIEW_ITEM_NOTFOUND )
- pItem = mItemList[nPos];
-
- ThumbnailViewAcc* pItemAcc = NULL;
- if (pItem != NULL)
- pItemAcc = ThumbnailViewAcc::getImplementation( pItem->GetAccessible( mbIsTransientChildrenDisabled ) );
+ ThumbnailViewAcc* pItemAcc = ThumbnailViewAcc::getImplementation( pItem->GetAccessible( mbIsTransientChildrenDisabled ) );
if( pItemAcc )
{
@@ -895,6 +851,16 @@ void ThumbnailView::deselectItem(const sal_uInt16 nItemId)
}
}
+bool ThumbnailView::IsItemSelected( sal_uInt16 nItemId ) const
+{
+ size_t nItemPos = GetItemPos( nItemId );
+ if ( nItemPos == THUMBNAILVIEW_ITEM_NOTFOUND )
+ return false;
+
+ ThumbnailViewItem* pItem = mItemList[nItemPos];
+ return pItem->isSelected();
+}
+
void ThumbnailView::deselectItems()
{
for (size_t i = 0, n = mItemList.size(); i < n; ++i)
@@ -931,53 +897,6 @@ void ThumbnailView::SetColor( const Color& rColor )
Invalidate();
}
-bool ThumbnailView::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
-{
- if ( rCEvt.GetCommand() != COMMAND_STARTDRAG )
- return false;
-
- // if necessary abort an existing action
-
- // Check out if the the clicked on page is selected. If this is not the
- // case set it as the current item. We only check mouse actions since
- // drag-and-drop can also be triggered by the keyboard
- sal_uInt16 nSelId;
- if ( rCEvt.IsMouseEvent() )
- nSelId = GetItemId( rCEvt.GetMousePosPixel() );
- else
- nSelId = mnSelItemId;
-
- // don't activate dragging if no item was clicked on
- if ( !nSelId )
- return false;
-
- // Check out if the page was selected. If not set as current page and
- // call select.
- if ( nSelId != mnSelItemId )
- {
- SelectItem( nSelId );
- Update();
- }
-
- Region aRegion;
-
- // assign region
- rRegion = aRegion;
-
- return true;
-}
-
-long ThumbnailView::GetScrollWidth() const
-{
- if ( GetStyle() & WB_VSCROLL )
- {
- ((ThumbnailView*)this)->ImplInitScrollBar();
- return mpScrBar->GetSizePixel().Width()+mnScrBarOffset;
- }
- else
- return 0;
-}
-
void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func)
{
mnFirstLine = 0; // start at the top of the list instead of the current position
diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx
index 8a7da2b..393bd9e 100644
--- a/sfx2/source/control/thumbnailviewacc.cxx
+++ b/sfx2/source/control/thumbnailviewacc.cxx
@@ -788,7 +788,7 @@ uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ThumbnailViewItemA
// pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
// SELECTED
- if( mpParent->mrParent.GetSelectItemId() == mpParent->mnId )
+ if( mpParent->isSelected() )
{
pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
// pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
More information about the Libreoffice-commits
mailing list