Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2911
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/11/2911/1
Template Manager: removed some dead selection code
(cherry picked from commit bfd1bcb204ed3ca35df1455a346a0ee7254a1191)
Conflicts:
sfx2/source/control/thumbnailview.cxx
Change-Id: Ib5ebcd928e77a115f4f62a50724656c33ae13c61
---
M sfx2/inc/sfx2/thumbnailview.hxx
M sfx2/source/control/thumbnailview.cxx
M sfx2/source/control/thumbnailviewacc.cxx
3 files changed, 24 insertions(+), 111 deletions(-)
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 @@
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 @@
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 @@
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 @@
mnLines = 0;
mnFirstLine = 0;
mnScrBarOffset = 1;
- mnSelItemId = 0;
mnHighItemId = 0;
mnCols = 0;
mnSpacing = 0;
@@ -589,11 +588,7 @@
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 @@
}
// reset variables
- if ( (mnHighItemId == nItemId) || (mnSelItemId == nItemId) )
+ if ( (mnHighItemId == nItemId) )
{
mnHighItemId = 0;
- mnSelItemId = 0;
}
CalculateItemPositions();
@@ -729,7 +723,6 @@
// reset variables
mnFirstLine = 0;
mnHighItemId = 0;
- mnSelItemId = 0;
CalculateItemPositions();
@@ -777,19 +770,18 @@
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 @@
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 @@
}
}
+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)
@@ -929,53 +895,6 @@
if ( IsReallyVisible() && IsUpdateMode() )
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)
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 @@
// 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 );
--
To view, visit https://gerrit.libreoffice.org/2911
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5ebcd928e77a115f4f62a50724656c33ae13c61
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Context
- [PATCH libreoffice-4-0] Template Manager: removed some dead selection code · Bosdonnat Cedric (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.