Kaydet (Commit) 06ecf7d2 authored tarafından Michael Meeks's avatar Michael Meeks

tdf#91125 - unwind horrendous SvTreeListBox drag&drop code.

This removes a horrible mess of shoving various process pointers into
byte arrays and (potentially) pushing them across a process boundary
in a gross fashion. Killed the SvLBoxDDInfo struct, and its many
un-used members. Instead use the existing (also non-ideal) global
variable to track the relevant state.

Change-Id: I0b694bd530e7019042d22e46db831b5a4aae0e23
üst 0811de12
...@@ -587,6 +587,7 @@ protected: ...@@ -587,6 +587,7 @@ protected:
protected: protected:
void SetupDragOrigin();
void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem, void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
const Selection& ); const Selection& );
void EditedText(const OUString&); void EditedText(const OUString&);
...@@ -817,15 +818,6 @@ public: ...@@ -817,15 +818,6 @@ public:
}; };
#define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT" #define SV_LBOX_DD_FORMAT "SV_LBOX_DD_FORMAT"
struct SvLBoxDDInfo
{
Application* pApp;
VclPtr<SvTreeListBox> pSource;
SvTreeListEntry* pDDStartEntry;
// Relative position in the Entry at DragBeginn (IconView)
long nMouseRelX,nMouseRelY;
sal_uLong nRes1,nRes2,nRes3,nRes4;
};
class SvInplaceEdit2 class SvInplaceEdit2
{ {
......
...@@ -87,15 +87,14 @@ SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable( ...@@ -87,15 +87,14 @@ SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
SdPageObjsTLB& rParent, SdPageObjsTLB& rParent,
const INetBookmark& rBookmark, const INetBookmark& rBookmark,
::sd::DrawDocShell& rDocShell, ::sd::DrawDocShell& rDocShell,
NavigatorDragType eDragType, NavigatorDragType eDragType)
const ::com::sun::star::uno::Any& rTreeListBoxData )
: SdTransferable(rDocShell.GetDoc(), NULL, true), : SdTransferable(rDocShell.GetDoc(), NULL, true),
mrParent( rParent ), mrParent( rParent ),
maBookmark( rBookmark ), maBookmark( rBookmark ),
mrDocShell( rDocShell ), mrDocShell( rDocShell ),
meDragType( eDragType ), meDragType( eDragType )
maTreeListBoxData( rTreeListBoxData )
{ {
rParent.SetupDragOrigin();
} }
VCL_BUILDER_DECL_FACTORY(SdPageObjsTLB) VCL_BUILDER_DECL_FACTORY(SdPageObjsTLB)
...@@ -128,8 +127,11 @@ bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const css::datatransfer::Da ...@@ -128,8 +127,11 @@ bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const css::datatransfer::Da
return true; return true;
case SotClipboardFormatId::TREELISTBOX: case SotClipboardFormatId::TREELISTBOX:
SetAny(maTreeListBoxData, rFlavor); {
css::uno::Any aTreeListBoxData; // empty for now
SetAny(aTreeListBoxData, rFlavor);
return true; return true;
}
default: default:
return false; return false;
...@@ -1204,18 +1206,10 @@ void SdPageObjsTLB::DoDrag() ...@@ -1204,18 +1206,10 @@ void SdPageObjsTLB::DoDrag()
bIsInDrag = true; bIsInDrag = true;
SvLBoxDDInfo aDDInfo;
memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
aDDInfo.pApp = GetpApp();
aDDInfo.pSource = this;
// aDDInfo.pDDStartEntry = pEntry;
::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
memcpy(aSequence.getArray(), &aDDInfo, sizeof(SvLBoxDDInfo));
::com::sun::star::uno::Any aTreeListBoxData (aSequence);
// object is destroyed by internal reference mechanism // object is destroyed by internal reference mechanism
SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable( SdTransferable* pTransferable =
*this, aBookmark, *pDocShell, eDragType, aTreeListBoxData); new SdPageObjsTLB::SdPageObjsTransferable(
*this, aBookmark, *pDocShell, eDragType);
// Get the view. // Get the view.
::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell); ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
......
...@@ -73,8 +73,7 @@ public: ...@@ -73,8 +73,7 @@ public:
SdPageObjsTLB& rParent, SdPageObjsTLB& rParent,
const INetBookmark& rBookmark, const INetBookmark& rBookmark,
::sd::DrawDocShell& rDocShell, ::sd::DrawDocShell& rDocShell,
NavigatorDragType eDragType, NavigatorDragType eDragType );
const ::com::sun::star::uno::Any& rTreeListBoxData );
::sd::DrawDocShell& GetDocShell() const { return mrDocShell;} ::sd::DrawDocShell& GetDocShell() const { return mrDocShell;}
NavigatorDragType GetDragType() const { return meDragType;} NavigatorDragType GetDragType() const { return meDragType;}
...@@ -96,7 +95,6 @@ public: ...@@ -96,7 +95,6 @@ public:
INetBookmark maBookmark; INetBookmark maBookmark;
::sd::DrawDocShell& mrDocShell; ::sd::DrawDocShell& mrDocShell;
NavigatorDragType meDragType; NavigatorDragType meDragType;
const ::com::sun::star::uno::Any maTreeListBoxData;
SAL_DLLPRIVATE virtual ~SdPageObjsTransferable(); SAL_DLLPRIVATE virtual ~SdPageObjsTransferable();
SAL_DLLPRIVATE virtual void AddSupportedFormats() SAL_OVERRIDE; SAL_DLLPRIVATE virtual void AddSupportedFormats() SAL_OVERRIDE;
......
...@@ -1234,27 +1234,19 @@ sal_Int8 SvTreeListBox::AcceptDrop( const AcceptDropEvent& rEvt ) ...@@ -1234,27 +1234,19 @@ sal_Int8 SvTreeListBox::AcceptDrop( const AcceptDropEvent& rEvt )
sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView ) sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView )
{ {
sal_Int8 nRet = DND_ACTION_NONE;
DBG_ASSERT( pSourceView, "SvTreeListBox::ExecuteDrop(): no source view" ); DBG_ASSERT( pSourceView, "SvTreeListBox::ExecuteDrop(): no source view" );
pSourceView->EnableSelectionAsDropTarget( true, true ); pSourceView->EnableSelectionAsDropTarget( true, true );
ImplShowTargetEmphasis( pTargetEntry, false ); ImplShowTargetEmphasis( pTargetEntry, false );
pDDTarget = this; pDDTarget = this;
SvLBoxDDInfo aDDInfo;
memset( &aDDInfo, 0, sizeof(SvLBoxDDInfo) );
TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
sal_Int8 nRet;
if( aData.HasFormat( SotClipboardFormatId::TREELISTBOX )) if( aData.HasFormat( SotClipboardFormatId::TREELISTBOX ))
{ nRet = rEvt.mnAction;
css::uno::Sequence<sal_Int8> aSeq = aData.GetSequence(SotClipboardFormatId::TREELISTBOX, OUString()); else
if (sizeof(SvLBoxDDInfo) == aSeq.getLength()) nRet = DND_ACTION_NONE;
{
memcpy( &aDDInfo, aSeq.getConstArray(), sizeof(SvLBoxDDInfo) );
nRet = rEvt.mnAction;
}
}
if( DND_ACTION_NONE != nRet ) if( DND_ACTION_NONE != nRet )
{ {
...@@ -1262,20 +1254,19 @@ sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox ...@@ -1262,20 +1254,19 @@ sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox
SvTreeListEntry* pTarget = pTargetEntry; // may be 0! SvTreeListEntry* pTarget = pTargetEntry; // may be 0!
if( DND_ACTION_COPY == rEvt.mnAction ) if( DND_ACTION_COPY == rEvt.mnAction )
{ {
if ( CopySelection( aDDInfo.pSource, pTarget ) ) if ( CopySelection( pDDSource, pTarget ) )
nRet = rEvt.mnAction; nRet = rEvt.mnAction;
} }
else if( DND_ACTION_MOVE == rEvt.mnAction ) else if( DND_ACTION_MOVE == rEvt.mnAction )
{ {
if ( MoveSelection( aDDInfo.pSource, pTarget ) ) if ( MoveSelection( pDDSource, pTarget ) )
nRet = rEvt.mnAction; nRet = rEvt.mnAction;
} }
else if( DND_ACTION_COPYMOVE == rEvt.mnAction ) else if( DND_ACTION_COPYMOVE == rEvt.mnAction )
{ {
if ( MoveSelectionCopyFallbackPossible( aDDInfo.pSource, pTarget, true ) ) if ( MoveSelectionCopyFallbackPossible( pDDSource, pTarget, true ) )
nRet = rEvt.mnAction; nRet = rEvt.mnAction;
} }
} }
...@@ -1287,6 +1278,16 @@ sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt ) ...@@ -1287,6 +1278,16 @@ sal_Int8 SvTreeListBox::ExecuteDrop( const ExecuteDropEvent& rEvt )
return ExecuteDrop( rEvt, GetSourceView() ); return ExecuteDrop( rEvt, GetSourceView() );
} }
/**
* This sets the global variables used to determine the
* in-process drag source.
*/
void SvTreeListBox::SetupDragOrigin()
{
pDDSource = this;
pDDTarget = 0;
}
void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel ) void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
{ {
...@@ -1310,25 +1311,20 @@ void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel ) ...@@ -1310,25 +1311,20 @@ void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
TransferDataContainer* pContainer = new TransferDataContainer; TransferDataContainer* pContainer = new TransferDataContainer;
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::datatransfer::XTransferable > xRef( pContainer ); ::com::sun::star::datatransfer::XTransferable > xRef( pContainer );
nDragDropMode = NotifyStartDrag( *pContainer, pEntry ); nDragDropMode = NotifyStartDrag( *pContainer, pEntry );
if( nDragDropMode == DragDropMode::NONE || 0 == GetSelectionCount() ) if( nDragDropMode == DragDropMode::NONE || 0 == GetSelectionCount() )
{ {
nDragDropMode = nOldDragMode; nDragDropMode = nOldDragMode;
DragFinished( DND_ACTION_NONE ); DragFinished( DND_ACTION_NONE );
delete pContainer;
return; return;
} }
SvLBoxDDInfo aDDInfo; SetupDragOrigin();
memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
aDDInfo.pApp = GetpApp();
aDDInfo.pSource = this;
aDDInfo.pDDStartEntry = pEntry;
// apparently some (unused) content is needed
pContainer->CopyAnyData( SotClipboardFormatId::TREELISTBOX, pContainer->CopyAnyData( SotClipboardFormatId::TREELISTBOX,
reinterpret_cast<char*>(&aDDInfo), sizeof(SvLBoxDDInfo) ); "unused", SAL_N_ELEMENTS("unused") );
pDDSource = this;
pDDTarget = 0;
bool bOldUpdateMode = Control::IsUpdateMode(); bool bOldUpdateMode = Control::IsUpdateMode();
Control::SetUpdateMode( true ); Control::SetUpdateMode( true );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment