[Libreoffice-commits] core.git: include/vcl vcl/source

Stephan Bergmann sbergman at redhat.com
Tue Mar 14 14:35:17 UTC 2017


 include/vcl/toolbox.hxx       |    2 
 vcl/source/window/toolbox.cxx |  273 ++----------------------------------------
 2 files changed, 17 insertions(+), 258 deletions(-)

New commits:
commit 62b50cb69cbf2cb6b99da3b6ff78435af4927b77
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Mar 14 15:26:43 2017 +0100

    ToolBox: Remove dead drag'n'drop "customization" support
    
    There was support for an MOD2+drag operation in ToolBox, apparently intended to
    allow customization by re-arranging items.  However, in
    ImplTBDragMgr::EndDragging that operation would always have ended in doing
    nothing:  Ever since at least 8ab086b6cc054501bfbf7ef6fa509c393691e860 "initial
    import", what happened was a call to virtual ToolBox::Customize, but which had
    an empty body and wasn't overridden anywhere (and has since been cleaned away
    over a series of commits).
    
    Change-Id: I8c5962d7b29506dc7dc8d803f49847f30fb93ea1

diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index 17c31cb..864f3ab 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -132,7 +132,6 @@ private:
     ImplToolItems::size_type mnVisLines; // number of visible lines (for scrolling)
     ImplToolItems::size_type mnFloatLines; // number of lines during floating mode
     ImplToolItems::size_type mnDockLines;
-    sal_uInt16          mnConfigItem;
     sal_uInt16          mnMouseClicks;
     sal_uInt16          mnMouseModifier;
     bool                mbDrag:1,
@@ -255,7 +254,6 @@ public:
     SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines( long nToolSize ) const;
     SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( const Point& rPos ) const;
     SAL_DLLPRIVATE void ImplLineSizing( const Point& rPos, Rectangle& rRect, sal_uInt16 nLineMode );
-    SAL_DLLPRIVATE sal_uInt16 ImplFindItemPos( const Point& rPos ) const;
     static SAL_DLLPRIVATE ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList );
     SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight);
     SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow);
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 02f8ee4..9614d22 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -66,7 +66,6 @@
 #define TB_SPIN_OFFSET          2
 #define TB_BORDER_OFFSET1       4
 #define TB_BORDER_OFFSET2       2
-#define TB_CUSTOMIZE_OFFSET     2
 #define TB_MAXLINES             5
 #define TB_MAXNOSCROLL          32765
 
@@ -86,14 +85,9 @@
 #define DOCK_LINETOP            ((sal_uInt16)0x8000)
 #define DOCK_LINEOFFSET         3
 
-typedef ::std::vector< VclPtr<ToolBox> > ImplTBList;
-
-
 class ImplTBDragMgr
 {
 private:
-    std::unique_ptr<ImplTBList>
-                    mpBoxList;
     VclPtr<ToolBox> mpDragBox;
     Point           maMouseOff;
     Rectangle       maRect;
@@ -101,7 +95,6 @@ private:
     Accelerator     maAccel;
     sal_uInt16      mnLineMode;
     ToolBox::ImplToolItems::size_type mnStartLines;
-    void*           mpCustomizeData;
     bool            mbShowDragRect;
 
     ImplTBDragMgr(const ImplTBDragMgr&) = delete;
@@ -110,27 +103,9 @@ private:
 public:
                     ImplTBDragMgr();
 
-    void            push_back( ToolBox* pBox )
-                        { mpBoxList->push_back( pBox ); }
-    void            erase( ToolBox* pBox )
-                    {
-                        for ( ImplTBList::iterator it = mpBoxList->begin(); it != mpBoxList->end(); ++it ) {
-                            if ( *it == pBox ) {
-                                mpBoxList->erase( it );
-                                break;
-                            }
-                        }
-                    }
-    size_t          size() const
-                    { return mpBoxList->size(); }
-
-    ToolBox*        FindToolBox( const Rectangle& rRect );
-
     void            StartDragging( ToolBox* pDragBox, const Point& rPos, const Rectangle& rRect, sal_uInt16 nLineMode );
     void            Dragging( const Point& rPos );
     void            EndDragging( bool bOK = true );
-    void            HideDragRect() { if ( mbShowDragRect ) mpDragBox->HideTracking(); }
-    void            UpdateDragRect();
     DECL_LINK( SelectHdl, Accelerator&, void );
 };
 
@@ -1059,74 +1034,10 @@ void ToolBox::ImplLineSizing( const Point& rPos, Rectangle& rRect, sal_uInt16 nL
     mnDockLines = i;
 }
 
-sal_uInt16 ToolBox::ImplFindItemPos( const Point& rPos ) const
-{
-    sal_uInt16  nPos = 0;
-    long    nLast = 0;
-    Point   aPos = rPos;
-    Size    aSize( mnDX, mnDY );
-
-    if ( aPos.X() > aSize.Width()-TB_BORDER_OFFSET1 )
-        aPos.X() = aSize.Width()-TB_BORDER_OFFSET1;
-    if ( aPos.Y() > aSize.Height()-TB_BORDER_OFFSET1 )
-        aPos.Y() = aSize.Height()-TB_BORDER_OFFSET1;
-
-    // Item suchen, das geklickt wurde
-    ImplToolItems::const_iterator it = mpData->m_aItems.begin();
-    while ( it != mpData->m_aItems.end() )
-    {
-        if ( it->mbVisible )
-        {
-            if ( nLast || !it->maRect.IsEmpty() )
-            {
-                if ( mbHorz )
-                {
-                    if ( nLast &&
-                         ((nLast < it->maRect.Top()) || it->maRect.IsEmpty()) )
-                        return nPos;
-
-                    if ( aPos.Y() <= it->maRect.Bottom() )
-                    {
-                        if ( aPos.X() < it->maRect.Left() )
-                            return nPos;
-                        else if ( aPos.X() < it->maRect.Right() )
-                            return nPos+1;
-                        else if ( !nLast )
-                            nLast = it->maRect.Bottom();
-                    }
-                }
-                else
-                {
-                    if ( nLast &&
-                         ((nLast < it->maRect.Left()) || it->maRect.IsEmpty()) )
-                        return nPos;
-
-                    if ( aPos.X() <= it->maRect.Right() )
-                    {
-                        if ( aPos.Y() < it->maRect.Top() )
-                            return nPos;
-                        else if ( aPos.Y() < it->maRect.Bottom() )
-                            return nPos+1;
-                        else if ( !nLast )
-                            nLast = it->maRect.Right();
-                    }
-                }
-            }
-        }
-
-        nPos++;
-        ++it;
-    }
-
-    return nPos;
-}
-
 ImplTBDragMgr::ImplTBDragMgr()
-    : mpBoxList(new ImplTBList)
-    , mpDragBox(nullptr)
+    : mpDragBox(nullptr)
     , mnLineMode(0)
     , mnStartLines(0)
-    , mpCustomizeData(nullptr)
     , mbShowDragRect(false)
 {
     maAccel.InsertItem( KEY_RETURN, vcl::KeyCode( KEY_RETURN ) );
@@ -1134,35 +1045,6 @@ ImplTBDragMgr::ImplTBDragMgr()
     maAccel.SetSelectHdl( LINK( this, ImplTBDragMgr, SelectHdl ) );
 }
 
-ToolBox* ImplTBDragMgr::FindToolBox( const Rectangle& rRect )
-{
-    for (VclPtr<ToolBox> & i : *mpBoxList)
-    {
-        ToolBox* pBox = i;
-        /*
-         *  FIXME: since we can have multiple frames now we cannot
-         *  find the drag target by its position alone.
-         *  As long as the toolbar config dialogue is not a system window
-         *  this works in one frame only anyway. If the dialogue
-         *  changes to a system window, we need a new implementation here
-         */
-        if (  pBox->IsReallyVisible()
-           && pBox->ImplGetWindowImpl()->mpFrame == mpDragBox->ImplGetWindowImpl()->mpFrame
-        ) {
-            if ( !pBox->ImplIsFloatingMode() )
-            {
-                Point aPos = pBox->GetPosPixel();
-                aPos = pBox->GetParent()->OutputToScreenPixel( aPos );
-                Rectangle aTempRect( aPos, pBox->GetSizePixel() );
-                if ( aTempRect.IsOver( rRect ) )
-                    return pBox;
-            }
-        }
-    }
-
-    return nullptr;
-}
-
 void ImplTBDragMgr::StartDragging( ToolBox* pToolBox,
                                    const Point& rPos, const Rectangle& rRect,
                                    sal_uInt16 nDragLineMode )
@@ -1172,19 +1054,8 @@ void ImplTBDragMgr::StartDragging( ToolBox* pToolBox,
     pToolBox->mbDragging = true;
     Application::InsertAccel( &maAccel );
 
-    if ( nDragLineMode )
-    {
-        mnLineMode = nDragLineMode;
-        mnStartLines = pToolBox->mnDockLines;
-    }
-    else
-    {
-        mpCustomizeData = nullptr;
-        pToolBox->Activate();
-        pToolBox->mnCurItemId = pToolBox->mnConfigItem;
-        pToolBox->Highlight();
-        pToolBox->mnCurItemId = 0;
-    }
+    mnLineMode = nDragLineMode;
+    mnStartLines = pToolBox->mnDockLines;
 
     // MouseOffset berechnen
     maMouseOff.X() = rRect.Left() - rPos.X();
@@ -1197,21 +1068,12 @@ void ImplTBDragMgr::StartDragging( ToolBox* pToolBox,
 
 void ImplTBDragMgr::Dragging( const Point& rPos )
 {
-    if ( mnLineMode )
-    {
-        mpDragBox->ImplLineSizing( rPos, maRect, mnLineMode );
-        Point aOff = mpDragBox->OutputToScreenPixel( Point() );
-        maRect.Move( aOff.X(), aOff.Y() );
-        mpDragBox->Docking( rPos, maRect );
-        maRect.Move( -aOff.X(), -aOff.Y() );
-        mpDragBox->ShowTracking( maRect );
-    }
-    else
-    {
-        maRect.SetPos( rPos );
-        maRect.Move( maMouseOff.X(), maMouseOff.Y() );
-        mpDragBox->ShowTracking( maRect );
-    }
+    mpDragBox->ImplLineSizing( rPos, maRect, mnLineMode );
+    Point aOff = mpDragBox->OutputToScreenPixel( Point() );
+    maRect.Move( aOff.X(), aOff.Y() );
+    mpDragBox->Docking( rPos, maRect );
+    maRect.Move( -aOff.X(), -aOff.Y() );
+    mpDragBox->ShowTracking( maRect );
 }
 
 void ImplTBDragMgr::EndDragging( bool bOK )
@@ -1223,68 +1085,18 @@ void ImplTBDragMgr::EndDragging( bool bOK )
     mbShowDragRect = false;
     Application::RemoveAccel( &maAccel );
 
-    if ( mnLineMode )
+    if ( !bOK )
     {
-        if ( !bOK )
-        {
-            mpDragBox->mnDockLines = mnStartLines;
-            mpDragBox->EndDocking( maStartRect, false );
-        }
-        else
-            mpDragBox->EndDocking( maRect, false );
-        mnLineMode = 0;
-        mnStartLines = 0;
+        mpDragBox->mnDockLines = mnStartLines;
+        mpDragBox->EndDocking( maStartRect, false );
     }
     else
-    {
-        sal_uInt16 nTempItem = mpDragBox->mnConfigItem;
-        if ( nTempItem )
-        {
-            mpDragBox->mnConfigItem = 0;
-            mpDragBox->Invalidate( mpDragBox->GetItemRect( nTempItem ) );
-        }
-
-        if ( bOK && (maRect != maStartRect) )
-        {
-            Point aOff = mpDragBox->OutputToScreenPixel( Point() );
-            Rectangle aScreenRect( maRect );
-            aScreenRect.Move( aOff.X(), aOff.Y() );
-            ToolBox* pDropBox = FindToolBox( aScreenRect );
-            if ( pDropBox )
-            {
-                // Determine search position
-                Point aPos;
-                if ( pDropBox->mbHorz )
-                {
-                    aPos.X() = aScreenRect.Left()-TB_CUSTOMIZE_OFFSET;
-                    aPos.Y() = aScreenRect.Center().Y();
-                }
-                else
-                {
-                    aPos.X() = aScreenRect.Center().X();
-                    aPos.Y() = aScreenRect.Top()-TB_CUSTOMIZE_OFFSET;
-                }
-
-                aPos = pDropBox->ScreenToOutputPixel( aPos );
-                pDropBox->ImplFindItemPos( aPos );
-            }
-        }
-        mpCustomizeData = nullptr;
-        mpDragBox->Deactivate();
-    }
+        mpDragBox->EndDocking( maRect, false );
+    mnStartLines = 0;
 
     mpDragBox = nullptr;
 }
 
-void ImplTBDragMgr::UpdateDragRect()
-{
-    // Only update if we're already dragging
-    if ( !mbShowDragRect )
-        return;
-
-    mpDragBox->ShowTracking( maRect );
-}
-
 IMPL_LINK( ImplTBDragMgr, SelectHdl, Accelerator&, rAccel, void )
 {
     if ( rAccel.GetCurItemId() == KEY_ESCAPE )
@@ -1320,7 +1132,6 @@ void ToolBox::ImplInitToolBoxData()
     mnVisLines        = 1;
     mnFloatLines      = 0;
     mnDockLines       = 0;
-    mnConfigItem      = 0;
     mnMouseClicks     = 0;
     mnMouseModifier   = 0;
     mbDrag            = false;
@@ -1558,21 +1369,9 @@ void ToolBox::dispose()
     delete mpData;
     mpData = nullptr;
 
-    // remove the lists when there are no more toolbox references to
-    // the lists
     ImplSVData* pSVData = ImplGetSVData();
-    if ( pSVData->maCtrlData.mpTBDragMgr )
-    {
-        // remove if in TBDrag-Manager
-        if ( mbCustomize )
-            pSVData->maCtrlData.mpTBDragMgr->erase( this );
-
-        if ( !pSVData->maCtrlData.mpTBDragMgr->size() )
-        {
-            delete pSVData->maCtrlData.mpTBDragMgr;
-            pSVData->maCtrlData.mpTBDragMgr = nullptr;
-        }
-    }
+    delete pSVData->maCtrlData.mpTBDragMgr;
+    pSVData->maCtrlData.mpTBDragMgr = nullptr;
 
     if (mpStatusListener.is())
         mpStatusListener->dispose();
@@ -2993,16 +2792,6 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si
     if ( (pItem->meType != ToolBoxItemType::BUTTON) || pItem->mbShowWindow )
         return;
 
-    // we need a TBDragMananger to draw the configuration item
-    ImplTBDragMgr* pMgr;
-    if ( pItem->mnId == mnConfigItem )
-    {
-        pMgr = ImplGetTBDragMgr();
-        pMgr->HideDragRect();
-    }
-    else
-        pMgr = nullptr;
-
     if ( pItem->meState == TRISTATE_TRUE )
     {
         nStyle |= DrawButtonFlags::Checked;
@@ -3195,10 +2984,6 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::si
         }
         ImplDrawDropdownArrow(rRenderContext, aDropDownRect, bSetColor, bRotate);
     }
-
-    // draw config-frame if required
-    if (pMgr)
-        pMgr->UpdateDragRect();
 }
 
 void ToolBox::ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem* pItem)
@@ -3722,21 +3507,6 @@ void ToolBox::MouseButtonDown( const MouseEvent& rMEvt )
         // item found
         if ( nNewPos != ITEM_NOTFOUND )
         {
-            if ( mbCustomize )
-            {
-                if ( rMEvt.IsMod2() )
-                {
-                    Deactivate();
-
-                    ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
-                    Rectangle aItemRect = GetItemRect( it->mnId );
-                    mnConfigItem = it->mnId;
-
-                    pMgr->StartDragging( this, aMousePos, aItemRect, 0 );
-                    return;
-                }
-            }
-
             if ( !it->mbEnabled )
             {
                 Deactivate();
@@ -4784,16 +4554,7 @@ Size ToolBox::CalcMinimumWindowSizePixel()
 
 void ToolBox::EnableCustomize( bool bEnable )
 {
-    if ( bEnable != mbCustomize )
-    {
-        mbCustomize = bEnable;
-
-        ImplTBDragMgr* pMgr = ImplGetTBDragMgr();
-        if ( bEnable )
-            pMgr->push_back( this );
-        else
-            pMgr->erase( this );
-    }
+    mbCustomize = bEnable;
 }
 
 void ToolBox::LoseFocus()


More information about the Libreoffice-commits mailing list