diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-07-18 22:07:59 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-07-19 05:58:21 +0000 |
commit | 4306e6600623262964c88c1f8f66188896c3d2a6 (patch) | |
tree | a00a0b7b61c594d92beaa591e5df83263c4b4774 /sc/source | |
parent | d2ab8f8c33f0eb7c49c6ecb03da7b8616fce8db5 (diff) |
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@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/app/drwtrans.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/inc/drwtrans.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/inc/transobj.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 11 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/tabcont.cxx | 6 |
8 files changed, 40 insertions, 27 deletions
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index e602286511ac..b6c1487d021f 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 802533f05e11..4a061f46d627 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 e36303b1834a..dd022218bc83 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 9e2e823bfac5..6c62815e1de7 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 6657e83dfd07..a7446e1c854b 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 0f2a4d4df236..44de2427dd94 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 10759313f1e2..076dd450c7db 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 0f7e43015641..24e96633b76d 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 |