diff options
author | Frank Schönheit <fs@openoffice.org> | 2001-03-26 14:04:35 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2001-03-26 14:04:35 +0000 |
commit | e926c61bdfb81714a1d0b23d017dfd316043333f (patch) | |
tree | a9c20f7a4e8d6d9ee2f4d9fcb51e973cae7d3736 | |
parent | e552f7e35275866573a7b8c1df70f357a898a379 (diff) |
new DnD implementations for the grid control
-rw-r--r-- | svx/source/form/tabwin.cxx | 70 | ||||
-rw-r--r-- | svx/source/inc/tabwin.hxx | 25 |
2 files changed, 46 insertions, 49 deletions
diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx index 6c1ba79ab60c..0590a64309f2 100644 --- a/svx/source/form/tabwin.cxx +++ b/svx/source/form/tabwin.cxx @@ -2,9 +2,9 @@ * * $RCSfile: tabwin.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: fs $ $Date: 2000-12-18 08:28:22 $ + * last change: $Author: fs $ $Date: 2001-03-26 15:04:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,9 @@ #ifndef _SVX_FMSERVS_HXX #include "fmservs.hxx" #endif +#ifndef _SVX_DBAEXCHANGE_HXX_ +#include "dbaexchange.hxx" +#endif #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include <com/sun/star/sdb/CommandType.hpp> @@ -109,9 +112,9 @@ #include "fmshell.hxx" #endif -#ifndef _SVX_FMEXCH_HXX -#include "fmexch.hxx" -#endif +//#ifndef _SVX_FMEXCH_HXX +//#include "fmexch.hxx" +//#endif #ifndef _SVX_FMPAGE_HXX #include "fmpage.hxx" @@ -176,7 +179,10 @@ const long MIN_WIN_SIZE_Y = 50; const long LISTBOX_BORDER = 2; using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::datatransfer; using namespace ::svxform; +using namespace ::svx; //================================================================== // class FmFieldWinListBox @@ -185,18 +191,11 @@ DBG_NAME(FmFieldWinListBox); //------------------------------------------------------------------------------ FmFieldWinListBox::FmFieldWinListBox( FmFieldWin* pParent ) :SvTreeListBox( pParent, WB_HASBUTTONS|WB_BORDER ) + ,DragSourceHelper(this) ,pTabWin( pParent ) { DBG_CTOR(FmFieldWinListBox,NULL); SetHelpId( HID_FIELD_SEL ); - - ::rtl::OUString aString; - for( sal_Int32 i=1; i<11; i++ ) - { - aString = ::rtl::OUString::createFromAscii("Feld "); - aString += ::rtl::OUString::valueOf(i); - InsertEntry( aString ); - } } //------------------------------------------------------------------------------ @@ -206,39 +205,28 @@ FmFieldWinListBox::~FmFieldWinListBox() } //------------------------------------------------------------------------------ -void FmFieldWinListBox::Command(const CommandEvent& rEvt) +void FmFieldWinListBox::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) { - switch (rEvt.GetCommand()) + SvLBoxEntry* pSelected = FirstSelected(); + if (!pSelected) + // no drag without a field + return; + + TransferableHelper* pTransferColumn = new OColumnTransferable( + pTabWin->GetDatabaseName(), + pTabWin->GetObjectType(), + pTabWin->GetObjectName(), + GetEntryText( pSelected), + CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE + ); + Reference< XTransferable> xEnsureDelete = pTransferColumn; + if (pTransferColumn) { - case COMMAND_STARTDRAG: - { - EndSelection(); - Pointer aMovePtr( POINTER_COPYDATA ), - aCopyPtr( POINTER_COPYDATA ), - aLinkPtr( POINTER_LINKDATA ); - - UniString aCopyData = pTabWin->GetDatabaseName(); - aCopyData += sal_Unicode(11); - aCopyData += pTabWin->GetObjectName().getStr(); - aCopyData += sal_Unicode(11); - aCopyData += ::rtl::OUString::valueOf((sal_Int32)pTabWin->GetObjectType()).getStr(); - aCopyData += sal_Unicode(11); - - SvLBoxEntry* pFirstSelected = FirstSelected(); - if( pFirstSelected ) - aCopyData += UniString(GetEntryText( pFirstSelected )); - - SvxFmFieldExchRef xFieldExch = new SvxFmFieldExch(aCopyData); - // TODO make it linkable but when we have a new clipboard format - // where the connection can be transfered as well - DragManager::ExecuteDrag( xFieldExch, DRAG_COPYABLE ); - } break; - default: - Window::Command( rEvt ); + EndSelection(); + pTransferColumn->StartDrag( this, DND_ACTION_COPY ); } } - //======================================================================== // class FmFieldWinData //======================================================================== diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx index ca1d8bc13cda..2e882fbe912d 100644 --- a/svx/source/inc/tabwin.hxx +++ b/svx/source/inc/tabwin.hxx @@ -2,9 +2,9 @@ * * $RCSfile: tabwin.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2000-10-20 14:12:06 $ + * last change: $Author: fs $ $Date: 2001-03-26 15:04:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,15 +92,20 @@ #ifndef _COMPHELPER_PROPERTY_MULTIPLEX_HXX_ #include <comphelper/propmultiplex.hxx> #endif +#ifndef _TRANSFER_HXX +#include <svtools/transfer.hxx> +#endif //================================================================== class FmFieldWin; -class FmFieldWinListBox: public SvTreeListBox +class FmFieldWinListBox + :public SvTreeListBox + ,public DragSourceHelper { FmFieldWin* pTabWin; protected: - virtual void Command( const CommandEvent& rEvt ); +// virtual void Command( const CommandEvent& rEvt ); public: FmFieldWinListBox( FmFieldWin* pParent ); @@ -111,6 +116,10 @@ public: return (!nDragDropMode) ? sal_False : SvTreeListBox::QueryDrop(rDEvt); } // this prevents an assertion the base class makes (unjustified ?) to fail - 67071 - fs - 21.06.99 + +protected: + // DragSourceHelper + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); }; //======================================================================== @@ -123,9 +132,9 @@ public: }; //======================================================================== -class FmFieldWin : public SfxFloatingWindow, - public SfxControllerItem, - public ::comphelper::OPropertyChangeListener +class FmFieldWin :public SfxFloatingWindow + ,public SfxControllerItem + ,public ::comphelper::OPropertyChangeListener { ::osl::Mutex m_aMutex; FmFieldWinListBox* pListBox; @@ -156,9 +165,9 @@ public: const ::rtl::OUString& GetObjectName() const { return m_aObjectName; } sal_Int32 GetObjectType() const { return m_nObjectType; } +protected: // FmXChangeListener virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); - }; //======================================================================== |