[Libreoffice-commits] core.git: sc/inc sc/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Tue Jul 19 05:58:46 UTC 2016


 sc/inc/scmod.hxx                |    5 -----
 sc/source/ui/app/drwtrans.cxx   |    6 +++---
 sc/source/ui/app/transobj.cxx   |    6 +++---
 sc/source/ui/inc/drwtrans.hxx   |    7 ++++---
 sc/source/ui/inc/transobj.hxx   |    7 ++++---
 sc/source/ui/inc/viewdata.hxx   |   11 +++++++++++
 sc/source/ui/navipi/content.cxx |    8 ++++----
 sc/source/ui/view/gridwin.cxx   |   16 ++++++++--------
 sc/source/ui/view/tabcont.cxx   |    6 +++---
 9 files changed, 40 insertions(+), 32 deletions(-)

New commits:
commit 4306e6600623262964c88c1f8f66188896c3d2a6
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Mon Jul 18 22:07:59 2016 +0200

    sc: convert SC_DROP_* defines to typed flags
    
    flags are stored by ScTransferObj and ScDrawTransferObj
    in members nDragSourceFlags, implemented in the same way by both classes.
    set only in ScTabControl::DoDrag() and ScContentTree::DoDrag().
    
    convert to typed_flags ScDragSrc and
    move flags closer to users, from sc/inc/scmod.hxx to
    sc/source/ui/inc/viewdata.hxx
    
    Change-Id: I15f58a5c828e154114971a1fcf941a3e27acbd56
    Reviewed-on: https://gerrit.libreoffice.org/27303
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index e6fa352..bb8df9c 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -73,11 +73,6 @@ class ScMarkData;
 struct ScDragData;
 struct ScClipData;
 
-//      for internal Drag&Drop:
-
-#define SC_DROP_NAVIGATOR       1
-#define SC_DROP_TABLE           2
-
 class ScModule: public SfxModule, public SfxListener, public utl::ConfigurationListener
 {
     Timer               aIdleTimer;
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index e602286..b6c1487 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -83,7 +83,7 @@ ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContain
     bGrIsBit( false ),
     bOleObj( false ),
     pDragSourceView( nullptr ),
-    nDragSourceFlags( 0 ),
+    nDragSourceFlags( ScDragSrc::Undefined ),
     bDragWasInternal( false ),
     nSourceDocID( 0 ),
     maShellID(SfxObjectShell::CreateShellID(pContainerShell))
@@ -599,7 +599,7 @@ void ScDrawTransferObj::ObjectReleased()
 
 void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction )
 {
-    if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
+    if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & ScDragSrc::Navigator) )
     {
         //  move: delete source objects
 
@@ -658,7 +658,7 @@ void ScDrawTransferObj::SetDragSourceObj( SdrObject* pObj, SCTAB nTab )
     //! add as listener with document, delete pDragSourceView if document gone
 }
 
-void ScDrawTransferObj::SetDragSourceFlags( sal_uInt16 nFlags )
+void ScDrawTransferObj::SetDragSourceFlags(ScDragSrc nFlags)
 {
     nDragSourceFlags = nFlags;
 }
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 802533f..4a061f4 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -121,7 +121,7 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDesc
     nDragHandleY( 0 ),
     nSourceCursorX( MAXCOL + 1 ),
     nSourceCursorY( MAXROW + 1 ),
-    nDragSourceFlags( 0 ),
+    nDragSourceFlags( ScDragSrc::Undefined ),
     bDragWasInternal( false ),
     bUsedForLink( false ),
     bUseInApi( false )
@@ -498,7 +498,7 @@ void ScTransferObj::ObjectReleased()
 
 void ScTransferObj::DragFinished( sal_Int8 nDropAction )
 {
-    if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
+    if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & ScDragSrc::Navigator) )
     {
         //  move: delete source data
         ScDocShell* pSourceSh = GetSourceDocShell();
@@ -556,7 +556,7 @@ void ScTransferObj::SetDragSource( ScDocShell* pSourceShell, const ScMarkData& r
     xDragSourceRanges = new ScCellRangesObj( pSourceShell, aRanges );
 }
 
-void ScTransferObj::SetDragSourceFlags( sal_uInt16 nFlags )
+void ScTransferObj::SetDragSourceFlags(ScDragSrc nFlags)
 {
     nDragSourceFlags = nFlags;
 }
diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx
index e36303b..dd02221 100644
--- a/sc/source/ui/inc/drwtrans.hxx
+++ b/sc/source/ui/inc/drwtrans.hxx
@@ -36,6 +36,7 @@ class SdrObject;
 class SdrView;
 class ScDrawView;
 class SdrOle2Obj;
+enum class ScDragSrc;
 
 class ScDrawTransferObj : public TransferableHelper
 {
@@ -55,7 +56,7 @@ private:
                                     // source information for drag&drop:
                                     // (view is needed to handle drawing obejcts)
     SdrView*                        pDragSourceView;
-    sal_uInt16                      nDragSourceFlags;
+    ScDragSrc                       nDragSourceFlags;
     bool                            bDragWasInternal;
 
     sal_uInt32                      nSourceDocID;
@@ -86,13 +87,13 @@ public:
     void                SetDrawPersist( const SfxObjectShellRef& rRef );
     void                SetDragSource( ScDrawView* pView );
     void                SetDragSourceObj( SdrObject* pObj, SCTAB nTab );
-    void                SetDragSourceFlags( sal_uInt16 nFlags );
+    void                SetDragSourceFlags( ScDragSrc nFlags );
     void                SetDragWasInternal();
 
     const OUString& GetShellID() const;
 
     SdrView*            GetDragSourceView()             { return pDragSourceView; }
-    sal_uInt16              GetDragSourceFlags() const      { return nDragSourceFlags; }
+    ScDragSrc           GetDragSourceFlags() const      { return nDragSourceFlags; }
 
     static ScDrawTransferObj* GetOwnClipboard( vcl::Window* pUIWin );
     virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rId ) throw( css::uno::RuntimeException, std::exception ) override;
diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx
index 9e2e823..6c62815 100644
--- a/sc/source/ui/inc/transobj.hxx
+++ b/sc/source/ui/inc/transobj.hxx
@@ -27,6 +27,7 @@
 class ScDocShell;
 class ScMarkData;
 class SfxObjectShell;
+enum class ScDragSrc;
 
 namespace com { namespace sun { namespace star {
     namespace sheet {
@@ -51,7 +52,7 @@ private:
     SCCOL                           nSourceCursorX;
     SCROW                           nSourceCursorY;
     SCTAB                           nVisibleTab;
-    sal_uInt16                      nDragSourceFlags;
+    ScDragSrc                       nDragSourceFlags;
     bool                            bDragWasInternal;
     bool                            bUsedForLink;
     bool                            bHasFiltered;       // if has filtered rows
@@ -88,7 +89,7 @@ public:
     SCCOL               GetSourceCursorX() const  { return nSourceCursorX; }
     SCROW               GetSourceCursorY() const  { return nSourceCursorY; }
     SCTAB               GetVisibleTab() const   { return nVisibleTab; }
-    sal_uInt16          GetDragSourceFlags() const  { return nDragSourceFlags; }
+    ScDragSrc           GetDragSourceFlags() const  { return nDragSourceFlags; }
     bool                HasFilteredRows() const { return bHasFiltered; }
     bool                GetUseInApi() const     { return bUseInApi; }
     ScDocShell*         GetSourceDocShell();
@@ -100,7 +101,7 @@ public:
     void                SetSourceCursorPos( SCCOL nX, SCROW nY );
     void                SetVisibleTab( SCTAB nNew );
     void                SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark );
-    void                SetDragSourceFlags( sal_uInt16 nFlags );
+    void                SetDragSourceFlags( ScDragSrc nFlags );
     void                SetDragWasInternal();
     SC_DLLPUBLIC void   SetUseInApi( bool bSet );
 
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 6657e83..a7446e1 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -26,6 +26,7 @@
 #include "docsh.hxx"
 
 #include <memory>
+#include <o3tl/typed_flags_set.hxx>
 
 #define SC_SIZE_NONE        65535
 const SCCOL SC_TABSTART_NONE = SCCOL_MAX;
@@ -84,6 +85,16 @@ enum ScPasteFlags
     SC_PASTE_BORDER = 2,    // Show a border around the source cells
 };
 
+// for internal Drag&Drop:
+enum class ScDragSrc{
+    Undefined = 0,
+    Navigator = 1,
+    Table     = 2
+};
+namespace o3tl {
+    template<> struct typed_flags<ScDragSrc> : is_typed_flags<ScDragSrc, 0x00000003> {};
+}
+
 class ScDocFunc;
 class ScDocShell;
 class ScDocument;
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 0f2a4d4..44de242 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1246,7 +1246,7 @@ static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScCo
             uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
 
             pTransferObj->SetDragSourceObj( pObject, nTab );
-            pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
+            pTransferObj->SetDragSourceFlags(ScDragSrc::Navigator);
 
             SC_MOD()->SetDragObject( nullptr, pTransferObj );
             pWin->ReleaseMouse();
@@ -1255,7 +1255,7 @@ static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScCo
     }
 }
 
-static void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, sal_uInt16 nFlags, vcl::Window* pWin )
+static void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, ScDragSrc nFlags, vcl::Window* pWin )
 {
     ScMarkData aMark;
     aMark.SelectTable( rRange.aStart.Tab(), true );
@@ -1394,7 +1394,7 @@ void ScContentTree::DoDrag()
                             ScRange aRange;
                             if ( lcl_GetRange( &rSrcDoc, nType, aText, aRange ) )
                             {
-                                lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
+                                lcl_DoDragCells( pSrcShell, aRange, ScDragSrc::Navigator, this );
                             }
                         }
                         else if ( nType == ScContentId::TABLE )
@@ -1403,7 +1403,7 @@ void ScContentTree::DoDrag()
                             if ( rSrcDoc.GetTable( aText, nTab ) )
                             {
                                 ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
-                                lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
+                                lcl_DoDragCells( pSrcShell, aRange, (ScDragSrc::Navigator | ScDragSrc::Table), this );
                             }
                         }
                         else if ( nType == ScContentId::GRAPHIC || nType == ScContentId::OLEOBJECT ||
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 1075931..076dd45 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -3547,7 +3547,7 @@ sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt )
             }
         }
 
-        if ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE )        // whole sheet?
+        if (rData.pCellTransfer->GetDragSourceFlags() & ScDragSrc::Table) // whole sheet?
         {
             bool bOk = pThisDoc->IsDocEditable();
             return bOk ? rEvt.mnAction : 0;                     // don't draw selection frame
@@ -4021,9 +4021,9 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
     ScDocument* pThisDoc   = pViewData->GetDocument();
     ScViewFunc* pView      = pViewData->GetView();
     SCTAB       nThisTab   = pViewData->GetTabNo();
-    sal_uInt16 nFlags = pTransObj->GetDragSourceFlags();
+    ScDragSrc   nFlags     = pTransObj->GetDragSourceFlags();
 
-    bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
+    bool bIsNavi = (nFlags & ScDragSrc::Navigator) == ScDragSrc::Navigator;
     bool bIsMove = ( nDndAction == DND_ACTION_MOVE && !bIsNavi );
 
     // workaround for wrong nDndAction on Windows when pressing solely
@@ -4061,7 +4061,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
     bool bFiltered = (bIsMove && pTransObj->HasFilteredRows());
     if (!bFiltered)
     {
-        if (pSourceDoc != pThisDoc && ((nFlags & SC_DROP_TABLE) ||
+        if (pSourceDoc != pThisDoc && ((nFlags & ScDragSrc::Table) ||
                     (!bIsLink && meDragInsertMode == INS_NONE)))
         {
             // Nothing. Either entire sheet to be dropped, or the one case
@@ -4078,7 +4078,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
 
     if (!bFiltered && pSourceDoc == pThisDoc)
     {
-        if ( nFlags & SC_DROP_TABLE )           // whole sheet?
+        if (nFlags & ScDragSrc::Table) // whole sheet?
         {
             if ( pThisDoc->IsDocEditable() )
             {
@@ -4228,7 +4228,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
     }
     else if ( !bFiltered && pSourceDoc )                        // between documents
     {
-        if ( nFlags & SC_DROP_TABLE )           // copy/link sheets between documents
+        if (nFlags & ScDragSrc::Table)          // copy/link sheets between documents
         {
             if ( pThisDoc->IsDocEditable() )
             {
@@ -4421,9 +4421,9 @@ sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
 
     if (!bIsLink && rData.pDrawTransfer)
     {
-        sal_uInt16 nFlags = rData.pDrawTransfer->GetDragSourceFlags();
+        ScDragSrc nFlags = rData.pDrawTransfer->GetDragSourceFlags();
 
-        bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
+        bool bIsNavi = (nFlags & ScDragSrc::Navigator) == ScDragSrc::Navigator;
         bool bIsMove = ( rEvt.mnAction == DND_ACTION_MOVE && !bIsNavi );
 
         bPasteIsMove = bIsMove;
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
index 0f7e430..24e9663 100644
--- a/sc/source/ui/view/tabcont.cxx
+++ b/sc/source/ui/view/tabcont.cxx
@@ -488,7 +488,7 @@ void ScTabControl::DoDrag( const vcl::Region& /* rRegion */ )
     ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
     css::uno::Reference<css::datatransfer::XTransferable> xTransferable( pTransferObj );
 
-    pTransferObj->SetDragSourceFlags( SC_DROP_TABLE );
+    pTransferObj->SetDragSourceFlags(ScDragSrc::Table);
 
     pTransferObj->SetDragSource( pDocSh, aTabMark );
 
@@ -525,7 +525,7 @@ sal_Int8 ScTabControl::ExecuteDrop( const ExecuteDropEvent& rEvt )
 
     ScDocument* pDoc = pViewData->GetDocument();
     const ScDragData& rData = SC_MOD()->GetDragData();
-    if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
+    if ( rData.pCellTransfer && (rData.pCellTransfer->GetDragSourceFlags() & ScDragSrc::Table) &&
             rData.pCellTransfer->GetSourceDocument() == pDoc )
     {
         // moving of tables within the document
@@ -564,7 +564,7 @@ sal_Int8 ScTabControl::AcceptDrop( const AcceptDropEvent& rEvt )
 
     const ScDocument* pDoc = pViewData->GetDocument();
     const ScDragData& rData = SC_MOD()->GetDragData();
-    if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
+    if ( rData.pCellTransfer && (rData.pCellTransfer->GetDragSourceFlags() & ScDragSrc::Table) &&
             rData.pCellTransfer->GetSourceDocument() == pDoc )
     {
         // moving of tables within the document


More information about the Libreoffice-commits mailing list