summaryrefslogtreecommitdiff
path: root/svx/source/form
diff options
context:
space:
mode:
authorFrank Schönheit <fs@openoffice.org>2001-04-09 10:19:35 +0000
committerFrank Schönheit <fs@openoffice.org>2001-04-09 10:19:35 +0000
commitc9c03a0afa427bc1fe4945484291838ba1a1b831 (patch)
tree77b7084c541b22519918af9ff31759e6f2151380 /svx/source/form
parent4ab675eece9cbcd477fb8eaaf05df35b421169af (diff)
new DnD implementations
Diffstat (limited to 'svx/source/form')
-rw-r--r--svx/source/form/filtnav.cxx178
-rw-r--r--svx/source/form/fmexch.cxx307
-rw-r--r--svx/source/form/fmexpl.cxx295
3 files changed, 431 insertions, 349 deletions
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
index 65c0545a9cae..fce67fe8a9c5 100644
--- a/svx/source/form/filtnav.cxx
+++ b/svx/source/form/filtnav.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: filtnav.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: fs $ $Date: 2000-12-18 07:54:04 $
+ * last change: $Author: fs $ $Date: 2001-04-09 11:19:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -197,18 +197,38 @@ using namespace ::com::sun::star::lang;
using namespace ::svxform;
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
//========================================================================
-SvxFmFilterExch::SvxFmFilterExch(FmFormItem* pFormItem, const ::std::vector<FmFilterItem*>& lstWhich )
- :m_aDraggedEntries(lstWhich)
- ,m_pFormItem(pFormItem)
+OFilterItemExchange::OFilterItemExchange()
{
- m_aDataTypeList.Insert( SvDataType(Exchange::RegisterFormatName(SVX_FM_FILTER_FIELDS)) );
}
//------------------------------------------------------------------------
-sal_Bool SvxFmFilterExch::GetData( SvData* pData )
+void OFilterItemExchange::AddSupportedFormats()
{
- return sal_False;
+ AddFormat(getFormatId());
+}
+
+//------------------------------------------------------------------------
+sal_uInt32 OFilterItemExchange::getFormatId()
+{
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("svxform.FilterControlExchange"));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OFilterExchangeHelper::getFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+}
+
+//------------------------------------------------------------------------
+OLocalExchange* OFilterExchangeHelper::createExchange() const
+{
+ return new OFilterItemExchange;
}
//========================================================================
@@ -530,7 +550,7 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos,
// ::comphelper::getImplementation(pController, Reference<XUnoTunnel>(pFormItem->GetController(),UNO_QUERY));
FmFilterRows& rRows = pController->getFilterRows();
- DBG_ASSERT(nRowPos < rRows.size(), "wrong row pos");
+ DBG_ASSERT(nRowPos < (sal_Int32)rRows.size(), "wrong row pos");
// Suchen der aktuellen Row
FmFilterRow& rRow = rRows[nRowPos];
@@ -839,7 +859,7 @@ void FmFilterModel::AppendFilterItems(FmFormItem* pFormItem)
FmFilterRows& rRows = pController->getFilterRows();
// determine the filter position
- if (nInsertPos >= rRows.size())
+ if (nInsertPos >= (sal_Int32)rRows.size())
rRows.push_back(FmFilterRow());
}
@@ -881,7 +901,7 @@ void FmFilterModel::Remove(FmFilterData* pData)
// how many entries do we have
// it's the last row than we just empty it
- if (nPos == (rRows.size() - 1))
+ if (nPos == (sal_Int32)(rRows.size() - 1))
{
// remove all childs and stay current
::std::vector<FmFilterData*>& rChilds = ((FmFilterItems*)pData)->GetChilds();
@@ -907,7 +927,7 @@ void FmFilterModel::Remove(FmFilterData* pData)
::std::vector<FmFilterData*>::iterator j = i;
// give a new current postion
- if (nPos < (rRows.size() - 1))
+ if (nPos < (sal_Int32)(rRows.size() - 1))
// set it to the next row
++j;
else
@@ -1235,6 +1255,7 @@ void FmFilterString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, S
//========================================================================
FmFilterNavigator::FmFilterNavigator( Window* pParent )
:SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HASBUTTONSATROOT )
+ ,m_aControlExchange(this)
{
SetHelpId( HID_FILTER_NAVIGATOR );
@@ -1427,12 +1448,12 @@ IMPL_LINK( FmFilterNavigator, OnDropActionTimer, void*, EMPTYARG )
//------------------------------------------------------------------------
-sal_Bool FmFilterNavigator::QueryDrop( DropEvent& rDEvt )
+sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt )
{
- Point aDropPos = rDEvt.GetPosPixel();
+ Point aDropPos = rEvt.maPosPixel;
// kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
- if (rDEvt.IsLeaveWindow())
+ if (rEvt.mbLeaving)
{
if (m_aDropActionTimer.IsActive())
m_aDropActionTimer.Stop();
@@ -1485,57 +1506,56 @@ sal_Bool FmFilterNavigator::QueryDrop( DropEvent& rDEvt )
// Hat das Object das richtige Format?
- SvDataObjectRef xDataObj = SvDataObject::PasteDragServer( rDEvt );
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
- const SvDataTypeList& rTypeList = xDataObj->GetTypeList();
- if (!rTypeList.Get(Exchange::RegisterFormatName(SVX_FM_FILTER_FIELDS)))
- return sal_False;
+ if (!m_aControlExchange->hasFormat(GetDataFlavorExVector()))
+ return DND_ACTION_NONE;
- SvxFmFilterExchRef xExch = (SvxFmFilterExch*)&xDataObj;
// do we conain the formitem?
- if (!FindEntry(xExch->GetFormItem()))
- return sal_False;
+ if (!FindEntry(m_aControlExchange->getFormItem()))
+ return DND_ACTION_NONE;
SvLBoxEntry* pDropTarget = GetEntry(aDropPos);
if (!pDropTarget)
- return sal_False;
+ return DND_ACTION_NONE;
FmFilterData* pData = (FmFilterData*)pDropTarget->GetUserData();
FmFormItem* pForm = NULL;
if (pData->ISA(FmFilterItem))
{
pForm = PTR_CAST(FmFormItem,pData->GetParent()->GetParent());
- if (pForm != xExch->GetFormItem())
- return sal_False;
+ if (pForm != m_aControlExchange->getFormItem())
+ return DND_ACTION_NONE;
}
else if (pData->ISA(FmFilterItems))
{
pForm = PTR_CAST(FmFormItem,pData->GetParent());
- if (pForm != xExch->GetFormItem())
- return sal_False;
+ if (pForm != m_aControlExchange->getFormItem())
+ return DND_ACTION_NONE;
}
else
- return sal_False;
+ return DND_ACTION_NONE;
- return sal_True;
+ return rEvt.mnAction;
}
//------------------------------------------------------------------------
-sal_Bool FmFilterNavigator::Drop( const DropEvent& rDEvt )
+sal_Int8 FmFilterNavigator::ExecuteDrop( const ExecuteDropEvent& rEvt )
{
// ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
if (m_aDropActionTimer.IsActive())
m_aDropActionTimer.Stop();
// Format-Ueberpruefung
- SvDataObjectRef xDataObj = SvDataObject::PasteDragServer( rDEvt );
- SvxFmFilterExchRef xExch = (SvxFmFilterExch*)&xDataObj;
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
// das Ziel des Drop sowie einige Daten darueber
- Point aDropPos = rDEvt.GetPosPixel();
+ Point aDropPos = rEvt.maPosPixel;
SvLBoxEntry* pDropTarget = GetEntry( aDropPos );
if (!pDropTarget)
- return sal_False;
+ return DND_ACTION_COPY;
// search the container where to add the items
FmFilterData* pData = (FmFilterData*)pDropTarget->GetUserData();
@@ -1546,8 +1566,8 @@ sal_Bool FmFilterNavigator::Drop( const DropEvent& rDEvt )
Select(pEntry, sal_True);
SetCurEntry(pEntry);
- sal_Bool bCopy = rDEvt.GetAction() == DROP_COPY;
- ::std::vector<FmFilterItem*> aItemList = xExch->GetDraggedEntries();
+ sal_Bool bCopy = rEvt.mnAction == DND_ACTION_COPY;
+ ::std::vector<FmFilterItem*> aItemList = m_aControlExchange->getDraggedEntries();
for (::std::vector<FmFilterItem*>::const_iterator i = aItemList.begin(); i != aItemList.end(); i++)
{
@@ -1706,56 +1726,53 @@ void FmFilterNavigator::Remove(FmFilterData* pItem)
}
//------------------------------------------------------------------------------
-void FmFilterNavigator::Command( const CommandEvent& rEvt )
+void FmFilterNavigator::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
{
- sal_Bool bHandled = sal_False;
- switch (rEvt.GetCommand())
- {
- case COMMAND_STARTDRAG:
- {
- EndSelection();
- Pointer aMovePtr( POINTER_MOVEDATA ),
- aCopyPtr( POINTER_COPYDATA ),
- aLinkPtr( POINTER_COPYDATA );
+ EndSelection();
- // be sure that the data is only used within a only one form!
- ::std::vector<FmFilterItem*> aSelectList;
- FmFormItem* pFirstItem = NULL;
- SvLBoxEntry* pCurEntry = GetCurEntry();
+ // be sure that the data is only used within a only one form!
+ FmFormItem* pFirstItem = NULL;
+ SvLBoxEntry* pCurEntry = GetCurEntry();
- bHandled = sal_True;
- for (SvLBoxEntry* pEntry = FirstSelected();
- bHandled && pEntry != NULL;
- pEntry = NextSelected(pEntry))
- {
- FmFilterItem* pFilter = PTR_CAST(FmFilterItem, (FmFilterData*)pEntry->GetUserData());
- if (pFilter)
- {
- FmFormItem* pForm = PTR_CAST(FmFormItem,pFilter->GetParent()->GetParent());
- if (!pForm)
- bHandled = sal_False;
- else if (!pFirstItem)
- pFirstItem = pForm;
- else if (pFirstItem != pForm)
- bHandled = sal_False;
-
- if (bHandled)
- aSelectList.push_back(pFilter);
- }
- }
- if (!bHandled || aSelectList.empty())
- break;
+ m_aControlExchange.prepareDrag();
- SvxFmFilterExch* pExch = new SvxFmFilterExch(pFirstItem, aSelectList);
- short nDragResult = pExch->ExecuteDrag( this, aMovePtr, aCopyPtr, aLinkPtr, DRAG_MOVEABLE | DRAG_COPYABLE );
- if (nDragResult == DROP_CANCEL)
+ sal_Bool bHandled = sal_True;
+ sal_Bool bFoundSomething = sal_False;
+ for (SvLBoxEntry* pEntry = FirstSelected();
+ bHandled && pEntry != NULL;
+ pEntry = NextSelected(pEntry))
+ {
+ FmFilterItem* pFilter = PTR_CAST(FmFilterItem, (FmFilterData*)pEntry->GetUserData());
+ if (pFilter)
+ {
+ FmFormItem* pForm = PTR_CAST(FmFormItem,pFilter->GetParent()->GetParent());
+ if (!pForm)
+ bHandled = sal_False;
+ else if (!pFirstItem)
+ pFirstItem = pForm;
+ else if (pFirstItem != pForm)
+ bHandled = sal_False;
+
+ if (bHandled)
{
- SetCursor(pCurEntry, sal_True);
- MakeVisible(pCurEntry);
+ m_aControlExchange->addSelectedItem(pFilter);
+ bFoundSomething = sal_True;
}
- bHandled = sal_True;
- break;
}
+ }
+ if (!bHandled || !bFoundSomething)
+ return;
+
+ m_aControlExchange->setFormItem(pFirstItem);
+ m_aControlExchange.startDrag( DND_ACTION_COPYMOVE );
+}
+
+//------------------------------------------------------------------------------
+void FmFilterNavigator::Command( const CommandEvent& rEvt )
+{
+ sal_Bool bHandled = sal_False;
+ switch (rEvt.GetCommand())
+ {
case COMMAND_CONTEXTMENU:
{
// die Stelle, an der geklickt wurde
@@ -2038,3 +2055,6 @@ FmFilterNavigatorWinMgr::FmFilterNavigatorWinMgr( Window *pParent, sal_uInt16 nI
((SfxDockingWindow*)pWindow)->Initialize( pInfo );
}
+//........................................................................
+} // namespace svxform
+//........................................................................
diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx
index 81320acb0e99..5d422ba89f4c 100644
--- a/svx/source/form/fmexch.cxx
+++ b/svx/source/form/fmexch.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fmexch.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: fs $ $Date: 2001-04-06 12:04:28 $
+ * last change: $Author: fs $ $Date: 2001-04-09 11:19:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -92,180 +92,247 @@
static sal_uInt32 nFieldFormat = 0;
static sal_uInt32 nControlFormat = 0;
-//========================================================================
-// class SvxFmExplCtrlExch
-//========================================================================
-
-//------------------------------------------------------------------------
-SvxFmExplCtrlExch::SvxFmExplCtrlExch( const vector<SvLBoxEntry*>& lstWhich, FmFormShell* pShell, FmFormPage* pPage )
- :m_aDraggedEntries(lstWhich)
- ,m_pShell(pShell)
- ,m_pPage(pPage)
-{
- m_aDataTypeList.Insert( SvDataType(Exchange::RegisterFormatName(SVX_FM_CONTROL_EXCH)) );
-}
-
-//------------------------------------------------------------------------
-SvxFmExplCtrlExch::SvxFmExplCtrlExch( SvLBoxEntry* pEntry )
- :m_pShell(NULL)
- ,m_pPage(NULL)
-{
- m_aDataTypeList.Insert( SvDataType(Exchange::RegisterFormatName(SVX_FM_CONTROL_EXCH)) );
-
- AddItem(pEntry);
-}
-
-//------------------------------------------------------------------------
-sal_Bool SvxFmExplCtrlExch::GetData( SvData* pData )
+//........................................................................
+namespace svxform
{
- return sal_False;
-}
+//........................................................................
-//------------------------------------------------------------------------
-void SvxFmExplCtrlExch::BuildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
-{
- if (m_aControlPaths.getLength() == 0)
+ //====================================================================
+ //= OLocalExchange
+ //====================================================================
+ //--------------------------------------------------------------------
+ OLocalExchange::OLocalExchange( )
+ :m_bDragging(sal_False)
{
- // Unterstuetzung des neuen Formats anzeigen
- m_aDataTypeList.Insert( SvDataType(Exchange::RegisterFormatName(SVX_FM_CONTROLS_AS_PATH)) );
}
- m_aControlPaths.realloc(0);
-
- sal_Int32 nEntryCount = m_aDraggedEntries.size();
- if (nEntryCount == 0)
- return;
- m_aControlPaths.realloc(nEntryCount);
- ::com::sun::star::uno::Sequence<sal_uInt32>* pAllPaths = m_aControlPaths.getArray();
- for (sal_Int32 i=0; i<nEntryCount; ++i)
+ //--------------------------------------------------------------------
+ void OLocalExchange::startDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, const GrantAccess& )
{
- // erst mal sammeln wir den Pfad in einem Array ein
- SvULongs arrCurrentPath;
- SvLBoxEntry* pCurrentEntry = m_aDraggedEntries[i];
-
- SvLBoxEntry* pLoop = pCurrentEntry;
- while (pLoop != pRoot)
- {
- arrCurrentPath.Insert(pLoop->GetChildListPos(), arrCurrentPath.Count());
- pLoop = pTreeBox->GetParent(pLoop);
- DBG_ASSERT((pLoop != NULL) || (pRoot == 0), "SvxFmExplCtrlExch::BuildPathFormat : invalid root or entry !");
- // pLoop == NULL heisst, dass ich am oberen Ende angelangt bin, dann sollte das Ganze abbrechen, was nur bei pRoot == NULL der Fall sein wird
- }
-
- // dann koennen wir ihn in die ::com::sun::star::uno::Sequence uebertragen
- ::com::sun::star::uno::Sequence<sal_uInt32>& rCurrentPath = pAllPaths[i];
- sal_Int32 nDepth = arrCurrentPath.Count();
+ m_bDragging = sal_True;
+ StartDrag( _pWindow, _nDragSourceActions );
+ }
- rCurrentPath.realloc(nDepth);
- sal_uInt32* pSeq = rCurrentPath.getArray();
- sal_Int32 j,k;
- for (j = nDepth - 1, k = 0; k<nDepth; --j, ++k)
- {
- pSeq[j] = arrCurrentPath.GetObject(k);
- }
+ //--------------------------------------------------------------------
+ void OLocalExchange::DragFinished( sal_Int8 nDropAction )
+ {
+ TransferableHelper::DragFinished( nDropAction );
+ m_bDragging = sal_False;
}
-}
-//------------------------------------------------------------------------
-void SvxFmExplCtrlExch::BuildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
-{
- m_aDraggedEntries.clear();
+ //--------------------------------------------------------------------
+ sal_Bool OLocalExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& _rFlavor )
+ {
+ return sal_True; // dummy
+ }
- sal_Int32 nControls = m_aControlPaths.getLength();
- const ::com::sun::star::uno::Sequence<sal_uInt32>* pPaths = m_aControlPaths.getConstArray();
- for (sal_Int32 i=0; i<nControls; ++i)
+ //--------------------------------------------------------------------
+ sal_Bool OLocalExchange::implHasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId )
{
- sal_Int32 nThisPatLength = pPaths[i].getLength();
- const sal_uInt32* pThisPath = pPaths[i].getConstArray();
- SvLBoxEntry* pSearch = pRoot;
- for (sal_Int32 j=0; j<nThisPatLength; ++j)
- pSearch = pTreeBox->GetEntry(pSearch, pThisPath[j]);
+ for (DataFlavorExVector::const_iterator aSearch = _rFormats.begin();
+ aSearch != _rFormats.end();
+ ++aSearch)
+ if (aSearch->mnSotId == _nFormatId)
+ return sal_True;
- m_aDraggedEntries.push_back(pSearch);
+ return sal_False;
}
-}
-
-//------------------------------------------------------------------------
-void SvxFmExplCtrlExch::AddHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces)
-{
- m_aDataTypeList.Insert( SvDataType(Exchange::RegisterFormatName(SVX_FM_HIDDEN_CONTROLS)) );
- m_seqControls = seqInterfaces;
-}
-//........................................................................
-namespace svxform
-{
-//........................................................................
+ //====================================================================
+ //= OControlExchange
+ //====================================================================
+ //--------------------------------------------------------------------
+ OControlExchange::OControlExchange( )
+ :m_pFocusEntry(NULL)
+ ,m_pShell(NULL)
+ ,m_pPage(NULL)
+ {
+ }
//--------------------------------------------------------------------
- OFieldNameExchange::OFieldNameExchange( SvLBoxEntry* _pFocusEntry )
+ OControlExchange::OControlExchange( SvLBoxEntry* _pFocusEntry )
:m_pFocusEntry(_pFocusEntry)
- ,m_bDragging(sal_False)
+ ,m_pShell(NULL)
+ ,m_pPage(NULL)
{
}
//--------------------------------------------------------------------
- void OFieldNameExchange::AddSupportedFormats()
+ void OControlExchange::AddSupportedFormats()
{
- AddFormat(getFormatId());
+ if (m_pFocusEntry && m_aSelectedEntries.size())
+ AddFormat(getFieldExchangeFormatId());
+
+ if (m_aControlPaths.getLength())
+ AddFormat(getControlPathFormatId());
+
+ if (m_aHiddenControlModels.getLength())
+ AddFormat(getHiddenControlModelsFormatId());
}
//--------------------------------------------------------------------
- void OFieldNameExchange::addSelectedEntry( SvLBoxEntry* _pEntry )
+ void OControlExchange::addSelectedEntry( SvLBoxEntry* _pEntry )
{
m_aSelectedEntries.push_back(_pEntry);
}
//--------------------------------------------------------------------
- void OFieldNameExchange::startDrag( Window* _pWindow, sal_Int8 _nDragSourceActions )
+ void OControlExchange::setFocusEntry( SvLBoxEntry* _pFocusEntry )
{
- m_bDragging = sal_True;
- StartDrag( _pWindow, _nDragSourceActions );
+ m_pFocusEntry = _pFocusEntry;
}
- //--------------------------------------------------------------------
- void OFieldNameExchange::DragFinished( sal_Int8 nDropAction )
+ //------------------------------------------------------------------------
+ void OControlExchange::addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces)
{
- TransferableHelper::DragFinished( nDropAction );
- m_bDragging = sal_False;
+ m_aHiddenControlModels = seqInterfaces;
}
- //--------------------------------------------------------------------
- sal_Bool OFieldNameExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& _rFlavor )
+ //------------------------------------------------------------------------
+ void OControlExchange::buildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
{
- if (getFormatId() == SotExchange::GetFormat(_rFlavor))
- return sal_True; // dummy
+ m_aControlPaths.realloc(0);
- return sal_False;
+ sal_Int32 nEntryCount = m_aSelectedEntries.size();
+ if (nEntryCount == 0)
+ return;
+
+ m_aControlPaths.realloc(nEntryCount);
+ ::com::sun::star::uno::Sequence<sal_uInt32>* pAllPaths = m_aControlPaths.getArray();
+ for (sal_Int32 i=0; i<nEntryCount; ++i)
+ {
+ // erst mal sammeln wir den Pfad in einem Array ein
+ ::std::vector< sal_uInt32 > aCurrentPath;
+ SvLBoxEntry* pCurrentEntry = m_aSelectedEntries[i];
+
+ SvLBoxEntry* pLoop = pCurrentEntry;
+ while (pLoop != pRoot)
+ {
+ aCurrentPath.push_back(pLoop->GetChildListPos());
+ pLoop = pTreeBox->GetParent(pLoop);
+ DBG_ASSERT((pLoop != NULL) || (pRoot == 0), "OControlExchange::buildPathFormat: invalid root or entry !");
+ // pLoop == NULL heisst, dass ich am oberen Ende angelangt bin, dann sollte das Ganze abbrechen, was nur bei pRoot == NULL der Fall sein wird
+ }
+
+ // dann koennen wir ihn in die ::com::sun::star::uno::Sequence uebertragen
+ ::com::sun::star::uno::Sequence<sal_uInt32>& rCurrentPath = pAllPaths[i];
+ sal_Int32 nDepth = aCurrentPath.size();
+
+ rCurrentPath.realloc(nDepth);
+ sal_uInt32* pSeq = rCurrentPath.getArray();
+ sal_Int32 j,k;
+ for (j = nDepth - 1, k = 0; k<nDepth; --j, ++k)
+ pSeq[j] = aCurrentPath[k];
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OControlExchange::buildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
+ {
+ m_aSelectedEntries.clear();
+
+ sal_Int32 nControls = m_aControlPaths.getLength();
+ const ::com::sun::star::uno::Sequence<sal_uInt32>* pPaths = m_aControlPaths.getConstArray();
+ for (sal_Int32 i=0; i<nControls; ++i)
+ {
+ sal_Int32 nThisPatLength = pPaths[i].getLength();
+ const sal_uInt32* pThisPath = pPaths[i].getConstArray();
+ SvLBoxEntry* pSearch = pRoot;
+ for (sal_Int32 j=0; j<nThisPatLength; ++j)
+ pSearch = pTreeBox->GetEntry(pSearch, pThisPath[j]);
+
+ m_aSelectedEntries.push_back(pSearch);
+ }
}
//--------------------------------------------------------------------
- sal_Bool OFieldNameExchange::canAceept( const DataFlavorExVector& _rFormats )
+ sal_uInt32 OControlExchange::getControlPathFormatId()
{
- sal_uInt32 nRecognizedFormat = getFormatId();
- for (DataFlavorExVector::const_iterator aSearch = _rFormats.begin();
- aSearch != _rFormats.end();
- ++aSearch)
- if (aSearch->mnSotId == nRecognizedFormat)
- return sal_True;
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("svxform.ControlPathExchange"));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getControlPathFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
- return sal_False;
+ //--------------------------------------------------------------------
+ sal_uInt32 OControlExchange::getHiddenControlModelsFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("svxform.HiddenControlModelsExchange"));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getHiddenControlModelsFormatId: bad exchange id!");
+ }
+ return s_nFormat;
}
//--------------------------------------------------------------------
- sal_uInt32 OFieldNameExchange::getFormatId()
+ sal_uInt32 OControlExchange::getFieldExchangeFormatId()
{
static sal_uInt32 s_nFormat = (sal_uInt32)-1;
if ((sal_uInt32)-1 == s_nFormat)
{
s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("svxform.FieldNameExchange"));
- DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OFieldNameExchange::getFormatId: bad exchange id!");
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getFieldExchangeFormatId: bad exchange id!");
}
return s_nFormat;
}
+ //====================================================================
+ //= OControlExchangeHelper
+ //====================================================================
+ OLocalExchange* OControlExchangeHelper::createExchange() const
+ {
+ return new OControlExchange;
+ }
+
+ //====================================================================
+ //= OLocalExchangeHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ OLocalExchangeHelper::OLocalExchangeHelper(Window* _pDragSource)
+ :m_pDragSource(_pDragSource)
+ ,m_pTransferable(NULL)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OLocalExchangeHelper::~OLocalExchangeHelper()
+ {
+ implReset();
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::startDrag( sal_Int8 nDragSourceActions )
+ {
+ DBG_ASSERT(m_pTransferable, "OLocalExchangeHelper::startDrag: not prepared!");
+ m_pTransferable->startDrag( m_pDragSource, nDragSourceActions, OControlExchange::GrantAccess() );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::implReset()
+ {
+ if (m_pTransferable)
+ {
+ m_pTransferable->release();
+ m_pTransferable = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::prepareDrag( )
+ {
+ DBG_ASSERT(!m_pTransferable || !m_pTransferable->isDragging(), "OLocalExchangeHelper::prepareDrag: recursive DnD?");
+
+ implReset();
+ m_pTransferable = createExchange();
+ m_pTransferable->acquire();
+ }
+
//........................................................................
}
//........................................................................
-
diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
index 0dd35c098e48..fe92fce3371c 100644
--- a/svx/source/form/fmexpl.cxx
+++ b/svx/source/form/fmexpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fmexpl.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: fs $ $Date: 2001-01-23 16:14:53 $
+ * last change: $Author: fs $ $Date: 2001-04-09 11:19:35 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -248,8 +248,12 @@
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
using namespace ::svxform;
+using namespace ::com::sun::star::uno;
//========================================================================
@@ -1681,6 +1685,7 @@ SdrObject* FmExplorerModel::Search(SdrObjListIter& rIter, const ::com::sun::star
FmExplorer::FmExplorer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB,
Window* pParent )
:SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER )
+ ,m_aControlExchange(this)
,nEditEvent(0)
,m_pEditEntry(NULL)
,m_nSelectLock(0)
@@ -1781,70 +1786,63 @@ void FmExplorer::Update( FmFormShell* pFormShell )
}
//------------------------------------------------------------------------------
-void FmExplorer::Command( const CommandEvent& rEvt )
+void FmExplorer::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
{
- sal_Bool bHandled = sal_False;
- switch( rEvt.GetCommand() )
- {
- case COMMAND_STARTDRAG:
- {
- EndSelection();
- Pointer aMovePtr( POINTER_COPYDATA ),
- aCopyPtr( POINTER_COPYDATA ),
- aLinkPtr( POINTER_LINKDATA );
+ EndSelection();
- SvLBoxEntry* pCurEntry = GetCurEntry();
+ SvLBoxEntry* pCurEntry = GetCurEntry();
+ if (!pCurEntry)
+ return;
- // die Informationen fuer das QueryDrop und Drop
- CollectSelectionData(SDI_ALL);
- if (!m_arrCurrentSelection.Count())
- // nothing to do
- return;
- vector<SvLBoxEntry*> lstToDrag;
- int i;
- for (i=0; i<m_arrCurrentSelection.Count(); i++)
- lstToDrag.push_back(m_arrCurrentSelection[i]);
- SvxFmExplCtrlExch* pCtrlExch = new SvxFmExplCtrlExch(lstToDrag, GetExplModel()->GetFormShell(), GetExplModel()->GetFormPage());
- pCtrlExch->BuildPathFormat(this, m_pRootEntry);
-
- // testen, ob es sich vielleicht ausschliesslich um hidden controls handelt (dann koennte ich pCtrlExch noch ein
- // zusaetzliches Format geben)
- sal_Bool bHasNonHidden = sal_False;
- for (i=0; i<m_arrCurrentSelection.Count(); i++)
- {
- FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection[i]->GetUserData());
- if (IsHiddenControl(pCurrent))
- continue;
- bHasNonHidden = sal_True;
- break;
- }
- if (!bHasNonHidden)
- {
- // eine entsprechende Sequenz aufbauen
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqIFaces(m_arrCurrentSelection.Count());
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > * pArray = seqIFaces.getArray();
- for (i=0; i<m_arrCurrentSelection.Count(); i++)
- pArray[i] = ((FmEntryData*)(m_arrCurrentSelection[i]->GetUserData()))->GetElement();
-
- // und das neue Format
- pCtrlExch->AddHiddenControlsFormat(seqIFaces);
- }
+ m_aControlExchange.prepareDrag();
+ m_aControlExchange->setFocusEntry( pCurEntry );
- // jetzt haben wir alle in der aktuelle Situation moeglichen Formate eingesammelt, es kann also losgehen ...
- m_bShellOrPageChanged = m_bDragDataDirty = sal_False;
- short nDragResult = pCtrlExch->ExecuteDrag( this, aMovePtr, aCopyPtr, aLinkPtr, DRAG_MOVEABLE | DRAG_COPYABLE );
- if (nDragResult == DROP_CANCEL)
- {
- if (!m_bShellOrPageChanged) // wenn die Shell (oder Page) umgeschaltet wurde, ist pCurEntry nicht mehr gueltig
- {
- SetCursor(pCurEntry, sal_True);
- MakeVisible(pCurEntry);
- }
- }
- bHandled = sal_True;
- break;
- }
+ // die Informationen fuer das AcceptDrop und ExecuteDrop
+ CollectSelectionData(SDI_ALL);
+ if (!m_arrCurrentSelection.Count())
+ // nothing to do
+ return;
+
+ for (sal_Int32 i=0; i<m_arrCurrentSelection.Count(); ++i)
+ m_aControlExchange->addSelectedEntry(m_arrCurrentSelection[i]);
+
+ m_aControlExchange->setShellAndPage( GetExplModel()->GetFormShell(), GetExplModel()->GetFormPage() );
+ m_aControlExchange->buildPathFormat(this, m_pRootEntry);
+
+ // testen, ob es sich vielleicht ausschliesslich um hidden controls handelt (dann koennte ich pCtrlExch noch ein
+ // zusaetzliches Format geben)
+ sal_Bool bHasNonHidden = sal_False;
+ for (i=0; i<m_arrCurrentSelection.Count(); i++)
+ {
+ FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection[i]->GetUserData());
+ if (IsHiddenControl(pCurrent))
+ continue;
+ bHasNonHidden = sal_True;
+ break;
+ }
+ if (!bHasNonHidden)
+ {
+ // eine entsprechende Sequenz aufbauen
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqIFaces(m_arrCurrentSelection.Count());
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > * pArray = seqIFaces.getArray();
+ for (i=0; i<m_arrCurrentSelection.Count(); i++)
+ pArray[i] = ((FmEntryData*)(m_arrCurrentSelection[i]->GetUserData()))->GetElement();
+
+ // und das neue Format
+ m_aControlExchange->addHiddenControlsFormat(seqIFaces);
+ }
+ // jetzt haben wir alle in der aktuelle Situation moeglichen Formate eingesammelt, es kann also losgehen ...
+ m_bShellOrPageChanged = m_bDragDataDirty = sal_False;
+ m_aControlExchange.startDrag( DND_ACTION_COPYMOVE );
+}
+
+//------------------------------------------------------------------------------
+void FmExplorer::Command( const CommandEvent& rEvt )
+{
+ sal_Bool bHandled = sal_False;
+ switch( rEvt.GetCommand() )
+ {
case COMMAND_CONTEXTMENU:
{
// die Stelle, an der geklickt wurde
@@ -2221,12 +2219,12 @@ sal_Bool FmExplorer::IsFormComponentEntry( SvLBoxEntry* pEntry )
}
//------------------------------------------------------------------------
-sal_Bool FmExplorer::QueryDrop( DropEvent& rDEvt )
+sal_Int8 FmExplorer::AcceptDrop( const AcceptDropEvent& rEvt )
{
- Point aDropPos = rDEvt.GetPosPixel();
+ Point aDropPos = rEvt.maPosPixel;
// kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
- if (rDEvt.IsLeaveWindow())
+ if (rEvt.mbLeaving)
{
if (m_aDropActionTimer.IsActive())
m_aDropActionTimer.Stop();
@@ -2260,7 +2258,7 @@ sal_Bool FmExplorer::QueryDrop( DropEvent& rDEvt )
{
// neu anfangen zu zaehlen
m_aTimerCounter = DROP_ACTION_TIMER_INITIAL_TICKS;
- // die Pos merken, da ich auch QueryDrops bekomme, wenn sich die Maus gar nicht bewegt hat
+ // die Pos merken, da ich auch AcceptDrops bekomme, wenn sich die Maus gar nicht bewegt hat
m_aTimerTriggered = aDropPos;
// und den Timer los
if (!m_aDropActionTimer.IsActive()) // gibt es den Timer schon ?
@@ -2275,71 +2273,69 @@ sal_Bool FmExplorer::QueryDrop( DropEvent& rDEvt )
//////////////////////////////////////////////////////////////////////
// Hat das Object das richtige Format?
- SvDataObjectRef xDataObj( SvDataObject::PasteDragServer( rDEvt ));
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
- const SvDataTypeList& rTypeList = xDataObj->GetTypeList();
- sal_Bool bHasDefControlFormat = NULL != rTypeList.Get(Exchange::RegisterFormatName(SVX_FM_CONTROL_EXCH));
- sal_Bool bHasControlPathFormat = NULL != rTypeList.Get(Exchange::RegisterFormatName(SVX_FM_CONTROLS_AS_PATH));
- sal_Bool bHasHiddenControlsFormat = NULL != rTypeList.Get(Exchange::RegisterFormatName(SVX_FM_HIDDEN_CONTROLS));
+ sal_Bool bHasDefControlFormat = m_aControlExchange->hasFieldExchangeFormat(GetDataFlavorExVector());
+ sal_Bool bHasControlPathFormat = m_aControlExchange->hasControlPathFormat(GetDataFlavorExVector());
+ sal_Bool bHasHiddenControlsFormat = m_aControlExchange->hasHiddenControlModelsFormat(GetDataFlavorExVector());
if (!bHasDefControlFormat && !bHasControlPathFormat && !bHasHiddenControlsFormat)
- return sal_False;
+ return DND_ACTION_NONE;
- // die Liste der gedroppten Eintraege aus dem DragServer
- SvxFmExplCtrlExch* xDragExch = (SvxFmExplCtrlExch*)&xDataObj;
-
- sal_Bool bForeignShellOrPage = xDragExch->GetShell() != GetExplModel()->GetFormShell()
- || xDragExch->GetPage() != GetExplModel()->GetFormPage();
- if (bForeignShellOrPage || (bHasHiddenControlsFormat && (rDEvt.GetAction() == DROP_COPY)))
+ sal_Bool bForeignShellOrPage =
+ m_aControlExchange->getShell() != GetExplModel()->GetFormShell()
+ || m_aControlExchange->getPage() != GetExplModel()->GetFormPage();
+ if (bForeignShellOrPage || (bHasHiddenControlsFormat && (DND_ACTION_COPY == rEvt.mnAction)))
{
- // ueber Shells/Pages hinweg kann ich nur hidden Controls austauschen
+ // crossing shell/page boundaries, we can exchange hidden controls only
if (!bHasHiddenControlsFormat)
- return sal_False;
+ return DND_ACTION_NONE;
SvLBoxEntry* pDropTarget = GetEntry(aDropPos);
if (!pDropTarget || (pDropTarget == m_pRootEntry) || !IsFormEntry(pDropTarget))
- return sal_False;
+ return DND_ACTION_NONE;
- rDEvt.SetAction(DROP_COPY); // hidden controls ueber Shell-Grenzen werden nur kopiert, nie verschoben
- return sal_True;
+ return DND_ACTION_COPY;
}
- if (rDEvt.GetAction() != DROP_MOVE) // normale Control innerhalb einer Shell werden nur verschoben
- return sal_False;
+ if (DND_ACTION_MOVE != rEvt.mnAction) // 'normal' controls within a shell are moved only (never copied)
+ return DND_ACTION_NONE;
if (m_bDragDataDirty)
{
if (!bHasControlPathFormat)
// ich befinde mich zwar in der Shell/Page, aus der die Controls stammen, habe aber kein Format, das den stattgefundenen
// Shell-Wechsel ueberlebt hat (SVX_FM_CONTROLS_AS_PATH)
- return sal_False;
+ return DND_ACTION_NONE;
// da die Shell waehrend des Draggens umgeschaltet wude, muss ich die Liste des ExchangeObjektes wieder neu aufbauen
// (dort stehen SvLBoxEntries drin, und die sind bei der Umschaltung floeten gegangen)
- xDragExch->BuildListFromPath(this, m_pRootEntry);
+ m_aControlExchange->buildListFromPath(this, m_pRootEntry);
m_bDragDataDirty = sal_False;
}
// die Liste der gedroppten Eintraege aus dem DragServer
- vector<SvLBoxEntry*> lstDropped = xDragExch->GetDraggedEntries();
- DBG_ASSERT(lstDropped.size() >= 1, "FmExplorer::QueryDrop : keine Eintraege !");
+ ListBoxEntryArray aDropped = m_aControlExchange->selected();
+ DBG_ASSERT(aDropped.size() >= 1, "FmExplorer::AcceptDrop : keine Eintraege !");
// das Ziel des Droppens (plus einige Daten, die ich nicht in jeder Schleife ermitteln will)
SvLBoxEntry* pDropTarget = GetEntry( aDropPos );
if (!pDropTarget)
- return sal_False;
- sal_Bool bDropTargetIsComponent = IsFormComponentEntry(pDropTarget);
+ return DND_ACTION_NONE;
+
+ sal_Bool bDropTargetIsComponent = IsFormComponentEntry( pDropTarget );
SvLBoxEntry* pDropTargetParent = GetParent( pDropTarget );
- // so, folgende Bedingungen, unter denen ich das Drop verbiete :
- // 0) die Root ist in der Liste mit drin
- // 1) einer der zu droppenden Eintraege soll in sein eigenes Parent gedroppt werden
- // 2) - " - wird auf sich selber gezogen
- // 3) - " - ist eine ::com::sun::star::form::Form und wird auf einen unter ihm stehenden Eintrag gezogen
- // 4) einer der Eintraege ist ein Control und wird auf die Root gedroppt
- // 5) ein Control oder Formular wird auf ein Control NICHT auf der selben Hierarchie-Ebene gezogen (auf eines der selben
- // heisst Platz vertauschen, ist also erlaubt)
+ // conditions to disallow the drop
+ // 0) the root entry is part of the list (can't DnD the root!)
+ // 1) one of the draged entries is to be dropped onto it's own parent
+ // 2) - " - is to be dropped onto itself
+ // 3) - " - is a Form and to be dropped onto one of it's descendants
+ // 4) one of the entries is a controls and to be dropped onto the root
+ // 5) a control or form will be dropped onto a control which is _not_ a sibling (dropping onto a sibling
+ // means moving the control)
- // um 3) etwas fixer testen zu koennen, sammle ich ich die Vorfahren des DropTargets ein
+ // collect the ancestors of the drop targte (speeds up 3)
SvLBoxEntrySortedArray arrDropAnchestors;
SvLBoxEntry* pLoop = pDropTarget;
while (pLoop)
@@ -2348,88 +2344,87 @@ sal_Bool FmExplorer::QueryDrop( DropEvent& rDEvt )
pLoop = GetParent(pLoop);
}
- for (size_t i=0; i<lstDropped.size(); i++)
+ for (size_t i=0; i<aDropped.size(); i++)
{
- SvLBoxEntry* pCurrent = lstDropped[i];
+ SvLBoxEntry* pCurrent = aDropped[i];
SvLBoxEntry* pCurrentParent = GetParent(pCurrent);
- // Test auf 0)
+ // test for 0)
if (pCurrent == m_pRootEntry)
- return sal_False;
+ return DND_ACTION_NONE;
- // Test auf 1)
+ // test for 1)
if ( pDropTarget == pCurrentParent )
- return sal_False;
+ return DND_ACTION_NONE;
- // Test auf 2)
+ // test for 2)
if (pCurrent == pDropTarget)
- return sal_False;
+ return DND_ACTION_NONE;
- // Test auf 5)
+ // test for 5)
// if ( bDropTargetIsComponent && (pDropTargetParent != pCurrentParent) )
- if ( bDropTargetIsComponent ) // TODO : die obige Zeile wieder rein, dann muss aber Drop das Vertauschen auch beherrschen
- return sal_False;
+ if ( bDropTargetIsComponent ) // TODO : die obige Zeile wieder rein, dann muss aber ExecuteDrop das Vertauschen auch beherrschen
+ return DND_ACTION_NONE;
- // Test auf 3)
+ // test for 3)
if ( IsFormEntry(pCurrent) )
{
sal_uInt16 nPosition;
if ( arrDropAnchestors.Seek_Entry(pCurrent, &nPosition) )
- return sal_False;
- } else
- if ( IsFormComponentEntry(pCurrent) )
- {
- // Test auf 4)
- if (pDropTarget == m_pRootEntry)
- return sal_False;
- }
+ return DND_ACTION_NONE;
+ } else if ( IsFormComponentEntry(pCurrent) )
+ {
+ // test for 4)
+ if (pDropTarget == m_pRootEntry)
+ return DND_ACTION_NONE;
+ }
}
- return sal_True;
+ return DND_ACTION_MOVE;
}
//------------------------------------------------------------------------
-sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
+sal_Int8 FmExplorer::ExecuteDrop( const ExecuteDropEvent& rEvt )
{
// ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
if (m_aDropActionTimer.IsActive())
m_aDropActionTimer.Stop();
// Format-Ueberpruefung
- SvDataObjectRef xDataObj( SvDataObject::PasteDragServer( rDEvt ));
- SvxFmExplCtrlExchRef xDragExch( (SvxFmExplCtrlExch*)&xDataObj);
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
- sal_Bool bHasHiddenControlsFormat = NULL != xDataObj->GetTypeList().Get(Exchange::RegisterFormatName(SVX_FM_HIDDEN_CONTROLS));
+ sal_Bool bHasHiddenControlsFormat = m_aControlExchange->hasHiddenControlModelsFormat(GetDataFlavorExVector());
#ifdef DBG_UTIL
- sal_Bool bForeignShellOrPage = xDragExch->GetShell() != GetExplModel()->GetFormShell()
- || xDragExch->GetPage() != GetExplModel()->GetFormPage();
- DBG_ASSERT(!bForeignShellOrPage || bHasHiddenControlsFormat, "FmExplorer::Drop : invalid format (QueryDrop shouldn't have let this pass) !");
- DBG_ASSERT(bForeignShellOrPage || !m_bDragDataDirty, "FmExplorer::Drop : invalid state (shell changed since last exchange resync) !");
- // das sollte in QueryDrop erledigt worden sein : dort wird in xDragExch die Liste der Controls aufgebaut und m_bDragDataDirty
+ sal_Bool bForeignShellOrPage =
+ m_aControlExchange->getShell() != GetExplModel()->GetFormShell()
+ || m_aControlExchange->getPage() != GetExplModel()->GetFormPage();
+ DBG_ASSERT(!bForeignShellOrPage || bHasHiddenControlsFormat, "FmExplorer::ExecuteDrop : invalid format (AcceptDrop shouldn't have let this pass) !");
+ DBG_ASSERT(bForeignShellOrPage || !m_bDragDataDirty, "FmExplorer::ExecuteDrop : invalid state (shell changed since last exchange resync) !");
+ // das sollte in AcceptDrop erledigt worden sein : dort wird in m_aControlExchange die Liste der Controls aufgebaut und m_bDragDataDirty
// zurueckgesetzt
#endif
- // das Ziel des Drop sowie einige Daten darueber
- Point aDropPos = rDEvt.GetPosPixel();
+ // das Ziel des ExecuteDrop sowie einige Daten darueber
+ Point aDropPos = rEvt.maPosPixel;
SvLBoxEntry* pDropTarget = GetEntry( aDropPos );
if (!pDropTarget)
- return sal_False;
+ return DND_ACTION_NONE;
-// sal_uInt32 nDropEntryPos = GetModel()->GetRelPos( pDropTarget ); // brauche ich spaeter mal fuer das Verschieben
sal_Bool bDropTargetIsForm = IsFormEntry(pDropTarget);
FmFormData* pTargetData = bDropTargetIsForm ? (FmFormData*)pDropTarget->GetUserData() : NULL;
- if (rDEvt.GetAction() == DROP_COPY)
+ if (DND_ACTION_COPY == rEvt.mnAction)
{
- DBG_ASSERT(bHasHiddenControlsFormat, "FmExplorer::Drop : only copying of hidden controls is supported !");
- // das sollte das QueryDrop abgefangen haben
+ DBG_ASSERT(bHasHiddenControlsFormat, "FmExplorer::ExecuteDrop : only copying of hidden controls is supported !");
+ // das sollte das AcceptDrop abgefangen haben
// da ich gleich die Zielobjekte alle selektieren will (und nur die)
SelectAll(sal_False);
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqControls = xDragExch->GetHiddenControls();
- sal_Int32 nCount = seqControls.getLength();
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > * pControls = seqControls.getConstArray();
+ Sequence< Reference< XInterface > > aControls = m_aControlExchange->hiddenControls();
+ sal_Int32 nCount = aControls.getLength();
+ const Reference< XInterface >* pControls = aControls.getConstArray();
FmFormShell* pFormShell = GetExplModel()->GetFormShell();
FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
@@ -2456,7 +2451,7 @@ sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
#if DEBUG || DBG_UTIL
// nur mal eben sehen, ob das Ding tatsaechlich ein hidden control ist
sal_Int16 nClassId = ::comphelper::getINT16(xCurrent->getPropertyValue(FM_PROP_CLASSID));
- DBG_ASSERT(nClassId == ::com::sun::star::form::FormComponentType::HIDDENCONTROL, "FmExplorer::Drop : invalid control in drop list !");
+ DBG_ASSERT(nClassId == ::com::sun::star::form::FormComponentType::HIDDENCONTROL, "FmExplorer::ExecuteDrop : invalid control in drop list !");
// wenn das SVX_FM_HIDDEN_CONTROLS-Format vorhanden ist, dann sollten wirklich nur hidden controls in der Sequenz
// stecken
#endif // DEBUG || DBG_UTIL
@@ -2481,19 +2476,19 @@ sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
if (pFormModel)
pFormModel->EndUndo();
- return sal_True;
+ return DND_ACTION_COPY;
}
// die Liste der gedraggten Eintraege
- vector<SvLBoxEntry*> lstDropped = xDragExch->GetDraggedEntries();
- DBG_ASSERT(lstDropped.size() >= 1, "FmExplorer::Drop : keine Eintraege !");
+ const ListBoxEntryArray& aDropped = m_aControlExchange->selected();
+ DBG_ASSERT(aDropped.size() >= 1, "FmExplorer::ExecuteDrop : keine Eintraege !");
// die Shell und das Model
FmFormShell* pFormShell = GetExplModel()->GetFormShell();
FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
if (!pFormModel)
- return sal_False;
+ return DND_ACTION_NONE;
// fuer's Undo
XubString strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE));
@@ -2505,12 +2500,12 @@ sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
LockSelectionHandling();
// jetzt durch alle gedroppten Eintraege ...
- for (size_t i=0; i<lstDropped.size(); ++i)
+ for (size_t i=0; i<aDropped.size(); ++i)
{
// ein paar Daten zum aktuellen Element
- SvLBoxEntry* pCurrent = lstDropped[i];
- DBG_ASSERT(pCurrent != NULL, "FmExplorer::Drop : ungueltiger Eintrag");
- DBG_ASSERT(GetParent(pCurrent) != NULL, "FmExplorer::Drop : ungueltiger Eintrag");
+ SvLBoxEntry* pCurrent = aDropped[i];
+ DBG_ASSERT(pCurrent != NULL, "FmExplorer::ExecuteDrop : ungueltiger Eintrag");
+ DBG_ASSERT(GetParent(pCurrent) != NULL, "FmExplorer::ExecuteDrop : ungueltiger Eintrag");
// die Root darf nicht gedraggt werden
FmEntryData* pCurrentUserData = (FmEntryData*)pCurrent->GetUserData();
@@ -2520,7 +2515,7 @@ sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
FmFormData* pCurrentParentUserData = (FmFormData*)pCurrentUserData->GetParent();
- DBG_ASSERT(pCurrentParentUserData == NULL || pCurrentParentUserData->ISA(FmFormData), "FmExplorer::Drop : ungueltiges Parent");
+ DBG_ASSERT(pCurrentParentUserData == NULL || pCurrentParentUserData->ISA(FmFormData), "FmExplorer::ExecuteDrop : ungueltiges Parent");
// beim Vater austragen
if (pCurrentParentUserData)
@@ -2608,7 +2603,7 @@ sal_Bool FmExplorer::Drop( const DropEvent& rDEvt )
// logischen Seite nichts zu tun hat), wohl aber meine Selektion, die ich also wieder an der Markierung ausrichten muss
SynchronizeSelection();
- return sal_True;
+ return rEvt.mnAction;
}
//------------------------------------------------------------------------