summaryrefslogtreecommitdiff
path: root/svx/source/inc/fmexch.hxx
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/inc/fmexch.hxx
parent4ab675eece9cbcd477fb8eaaf05df35b421169af (diff)
new DnD implementations
Diffstat (limited to 'svx/source/inc/fmexch.hxx')
-rw-r--r--svx/source/inc/fmexch.hxx189
1 files changed, 130 insertions, 59 deletions
diff --git a/svx/source/inc/fmexch.hxx b/svx/source/inc/fmexch.hxx
index 3d4b94a0c6ab..18f916a4e7b7 100644
--- a/svx/source/inc/fmexch.hxx
+++ b/svx/source/inc/fmexch.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fmexch.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: fs $ $Date: 2001-04-06 12:04:19 $
+ * last change: $Author: fs $ $Date: 2001-04-09 11:19:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,93 +94,164 @@ class SvLBoxEntry;
#define SVX_FM_FILTER_FIELDS String("SvxFilterFieldExchange", sizeof("SvxFilterFieldExchange"))
//========================================================================
-
-typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<sal_uInt32> > FmControlPaths;
-
-//========================================================================
class SvTreeListBox;
-class SvxFmExplCtrlExch : public SvDataObject
+
+//........................................................................
+namespace svxform
{
- FmFormShell* m_pShell;
- FmFormPage* m_pPage;
+//........................................................................
- SvDataTypeList m_aDataTypeList;
+ //====================================================================
- std::vector<SvLBoxEntry*> m_aDraggedEntries;
- FmControlPaths m_aControlPaths;
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > m_seqControls;
+ typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence<sal_uInt32> > FmControlPaths;
-public:
- SvxFmExplCtrlExch( const std::vector<SvLBoxEntry*>& lstWhich, FmFormShell* pShell, FmFormPage* pPage );
- SvxFmExplCtrlExch( SvLBoxEntry* pEntry );
+ DECLARE_STL_VECTOR( SvLBoxEntry*, ListBoxEntryArray );
- virtual const SvDataTypeList& GetTypeList() const { return m_aDataTypeList; }
- virtual sal_Bool GetData( SvData* );
+ //====================================================================
+ //= OLocalExchange
+ //====================================================================
+ class OLocalExchange : public TransferableHelper
+ {
+ private:
+ sal_Bool m_bDragging;
- SvLBoxEntry* GetDragEntry() const { return m_aDraggedEntries.front(); }
- void AddItem(SvLBoxEntry* pNew) { m_aDraggedEntries.push_back( pNew ); }
+ public:
+ class GrantAccess
+ {
+ friend class OLocalExchangeHelper;
+ };
- FmFormShell* GetShell() const { return m_pShell; }
- FmFormPage* GetPage() const { return m_pPage; }
- const ::std::vector<SvLBoxEntry*>& GetDraggedEntries() const { return m_aDraggedEntries; }
- const FmControlPaths GetControlPaths() { return m_aControlPaths; }
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > GetHiddenControls() { return m_seqControls; }
+ public:
+ OLocalExchange( );
- void BuildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
- // baut aus m_aDraggedEntries m_aControlPaths auf
- // (es wird davon ausgegangen, dass die Eintraege in m_aDraggedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
- void BuildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
- // der umgekehrte Weg : wirft alles aus m_aDraggedEntries weg und baut es mittels m_aControlPaths neu auf
+ sal_Bool isDragging() const { return m_bDragging; }
+ void startDrag( Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
- void AddHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces);
- // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
- // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
- // Aufrufer sicherstellen)
-};
+ protected:
+ virtual void DragFinished( sal_Int8 nDropAction );
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
-SV_DECL_IMPL_REF( SvxFmExplCtrlExch );
+ static sal_Bool implHasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId );
-//........................................................................
-namespace svxform
-{
-//........................................................................
+ private:
+ void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, sal_Int32 nDragPointer = DND_POINTER_NONE, sal_Int32 nDragImage = DND_IMAGE_NONE )
+ { // don't allow this base class method to be called from outside
+ TransferableHelper::StartDrag(pWindow, nDragSourceActions, nDragPointer, nDragImage);
+ }
+ };
+
+ //====================================================================
+ //= OLocalExchangeHelper
+ //====================================================================
+ /// a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
+ class OLocalExchangeHelper
+ {
+ protected:
+ Window* m_pDragSource;
+ OLocalExchange* m_pTransferable;
+
+ public:
+ OLocalExchangeHelper(Window* _pDragSource);
+ ~OLocalExchangeHelper();
+
+ void prepareDrag( );
+ void startDrag( sal_Int8 nDragSourceActions );
+ sal_Bool isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
+
+ protected:
+ virtual OLocalExchange* createExchange() const = 0;
+
+ protected:
+ void implReset();
+ };
//====================================================================
- //= OFieldNameExchange
+ //= OControlExchange
//====================================================================
- class OFieldNameExchange : public TransferableHelper
+ class OControlExchange : public OLocalExchange
{
protected:
- ::std::vector< SvLBoxEntry* > m_aSelectedEntries;
- SvLBoxEntry* m_pFocusEntry;
- sal_Bool m_bDragging;
+ ListBoxEntryArray m_aSelectedEntries;
+ FmControlPaths m_aControlPaths;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ m_aHiddenControlModels;
+ SvLBoxEntry* m_pFocusEntry;
+ FmFormShell* m_pShell;
+ FmFormPage* m_pPage;
public:
- OFieldNameExchange( SvLBoxEntry* _pFocusEntry );
+ OControlExchange( );
+ OControlExchange( SvLBoxEntry* _pFocusEntry );
void addSelectedEntry( SvLBoxEntry* _pEntry );
+ void setFocusEntry( SvLBoxEntry* _pFocusEntry );
- static sal_uInt32 getFormatId( );
- static sal_Bool canAceept( const DataFlavorExVector& _rFormats );
+ void setShellAndPage( FmFormShell* _pShell, FmFormPage* _pPage ) { m_pShell = _pShell; m_pPage = _pPage; }
- sal_Bool isDragging() const { return m_bDragging; }
- void startDrag( Window* pWindow, sal_Int8 nDragSourceActions );
+ void buildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
+ // baut aus m_aSelectedEntries m_aControlPaths auf
+ // (es wird davon ausgegangen, dass die Eintraege in m_aSelectedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
+
+
+ void buildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
+ // der umgekehrte Weg : wirft alles aus m_aSelectedEntries weg und baut es mittels m_aControlPaths neu auf
- SvLBoxEntry* focused() const { return m_pFocusEntry; }
- const ::std::vector< SvLBoxEntry* >&
- selected() const { return m_aSelectedEntries; }
+ void addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces);
+ // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
+ // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
+ // Aufrufer sicherstellen)
+
+ static sal_uInt32 getFieldExchangeFormatId( );
+ static sal_uInt32 getControlPathFormatId( );
+ static sal_uInt32 getHiddenControlModelsFormatId( );
+
+ inline static sal_Bool hasFieldExchangeFormat( const DataFlavorExVector& _rFormats );
+ inline static sal_Bool hasControlPathFormat( const DataFlavorExVector& _rFormats );
+ inline static sal_Bool hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats );
+
+ SvLBoxEntry* focused() const { return m_pFocusEntry; }
+ const ListBoxEntryArray& selected() const { return m_aSelectedEntries; }
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ hiddenControls() const { return m_aHiddenControlModels; }
+
+ FmFormShell* getShell() const { return m_pShell; }
+ FmFormPage* getPage() const { return m_pPage; }
protected:
virtual void AddSupportedFormats();
- virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
- virtual void DragFinished( sal_Int8 nDropAction );
+ };
- void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, sal_Int32 nDragPointer = DND_POINTER_NONE, sal_Int32 nDragImage = DND_IMAGE_NONE )
- { // don't allow this base class method to be called from outside
- TransferableHelper::StartDrag(pWindow, nDragSourceActions, nDragPointer, nDragImage);
- }
+ //====================================================================
+ //= OControlExchangeHelper
+ //====================================================================
+ class OControlExchangeHelper : public OLocalExchangeHelper
+ {
+ public:
+ OControlExchangeHelper(Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
+
+ OControlExchange* operator->() const { return static_cast<OControlExchange*>(m_pTransferable); }
+
+ protected:
+ virtual OLocalExchange* createExchange() const;
};
+ //====================================================================
+ //====================================================================
+ inline sal_Bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats )
+ {
+ return implHasFormat( _rFormats, getFieldExchangeFormatId() );
+ }
+
+ inline sal_Bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats )
+ {
+ return implHasFormat( _rFormats, getControlPathFormatId() );
+ }
+
+ inline sal_Bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats )
+ {
+ return implHasFormat( _rFormats, getHiddenControlModelsFormatId() );
+ }
+
//........................................................................
} // namespace svxform
//........................................................................