LCOV - code coverage report
Current view: top level - libreoffice/svx/source/inc - fmexch.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 32 0.0 %
Date: 2012-12-27 Functions: 0 27 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef _SVX_FMEXCH_HXX
      20             : #define _SVX_FMEXCH_HXX
      21             : 
      22             : #include <comphelper/stl_types.hxx>
      23             : #include <svtools/transfer.hxx>
      24             : #include <com/sun/star/uno/Sequence.hxx>
      25             : #include <com/sun/star/container/XNameContainer.hpp>
      26             : #include <tools/link.hxx>
      27             : 
      28             : #include <svx/svxdllapi.h>
      29             : 
      30             : class SvTreeListEntry;
      31             : 
      32             : //========================================================================
      33             : class SvTreeListBox;
      34             : 
      35             : //........................................................................
      36             : namespace svxform
      37             : {
      38             : //........................................................................
      39             : 
      40             :     //====================================================================
      41             : 
      42             :     typedef ::std::set< SvTreeListEntry* >  ListBoxEntrySet;
      43             : 
      44             :     //====================================================================
      45             :     //= OLocalExchange
      46             :     //====================================================================
      47           0 :     class SVX_DLLPUBLIC OLocalExchange : public TransferableHelper
      48             :     {
      49             :     private:
      50             :         Link                m_aClipboardListener;
      51             :         sal_Bool            m_bDragging         : 1;
      52             :         sal_Bool            m_bClipboardOwner   : 1;
      53             : 
      54             :     public:
      55             :         class GrantAccess
      56             :         {
      57             :             friend class OLocalExchangeHelper;
      58             :         };
      59             : 
      60             :     public:
      61             :         OLocalExchange( );
      62             : 
      63           0 :         sal_Bool    isDragging() const { return m_bDragging; }
      64           0 :         sal_Bool    isClipboardOwner() const { return m_bClipboardOwner; }
      65             : 
      66             :         void        startDrag( Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
      67             :         void        copyToClipboard( Window* _pWindow, const GrantAccess& );
      68             : 
      69           0 :         void        setClipboardListener( const Link& _rListener ) { m_aClipboardListener = _rListener; }
      70             : 
      71             :         void        clear();
      72             : 
      73             :         static  sal_Bool    hasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId );
      74             : 
      75             :     protected:
      76             :         // XClipboardOwner
      77             :         virtual void SAL_CALL lostOwnership( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& _rxClipboard, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTrans ) throw(::com::sun::star::uno::RuntimeException);
      78             : 
      79             :         // TransferableHelper
      80             :         virtual void        DragFinished( sal_Int8 nDropAction );
      81             :         virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
      82             : 
      83             :     private:
      84           0 :         void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, sal_Int32 nDragPointer = DND_POINTER_NONE, sal_Int32 nDragImage = DND_IMAGE_NONE )
      85             :         {   // don't allow this base class method to be called from outside
      86           0 :             TransferableHelper::StartDrag(pWindow, nDragSourceActions, nDragPointer, nDragImage);
      87           0 :         }
      88             :     };
      89             : 
      90             :     //====================================================================
      91             :     //= OLocalExchangeHelper
      92             :     //====================================================================
      93             :     /// a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
      94             :     class SVX_DLLPUBLIC OLocalExchangeHelper
      95             :     {
      96             :     protected:
      97             :         Window*             m_pDragSource;
      98             :         OLocalExchange*     m_pTransferable;
      99             : 
     100             :     public:
     101             :         OLocalExchangeHelper( Window* _pDragSource );
     102             :         virtual ~OLocalExchangeHelper();
     103             : 
     104             :         void        prepareDrag( );
     105             : 
     106             :         void        startDrag( sal_Int8 nDragSourceActions );
     107             :         void        copyToClipboard( ) const;
     108             : 
     109           0 :         inline  sal_Bool    isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
     110           0 :         inline  sal_Bool    isClipboardOwner() const { return m_pTransferable && m_pTransferable->isClipboardOwner(); }
     111           0 :         inline  sal_Bool    isDataExchangeActive( ) const { return isDragSource() || isClipboardOwner(); }
     112           0 :         inline  void        clear() { if ( isDataExchangeActive() ) m_pTransferable->clear(); }
     113             : 
     114           0 :         SVX_DLLPRIVATE void     setClipboardListener( const Link& _rListener ) { if ( m_pTransferable ) m_pTransferable->setClipboardListener( _rListener ); }
     115             : 
     116             :     protected:
     117             :         SVX_DLLPRIVATE virtual OLocalExchange* createExchange() const = 0;
     118             : 
     119             :     protected:
     120             :         SVX_DLLPRIVATE void implReset();
     121             :     };
     122             : 
     123             :     //====================================================================
     124             :     //= OControlTransferData
     125             :     //====================================================================
     126           0 :     class OControlTransferData
     127             :     {
     128             :     private:
     129             :         typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_uInt32 > > ControlPaths;
     130             : 
     131             :     private:
     132             :         DataFlavorExVector  m_aCurrentFormats;
     133             : 
     134             :     protected:
     135             :         ListBoxEntrySet     m_aSelectedEntries;
     136             :         ControlPaths        m_aControlPaths;
     137             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     138             :                             m_aHiddenControlModels;
     139             : 
     140             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     141             :                             m_xFormsRoot;       // the root of the forms collection where the entries we represent reside
     142             :                                                 // this uniquely identifies the page and the document
     143             : 
     144             :         SvTreeListEntry*        m_pFocusEntry;
     145             : 
     146             :     protected:
     147             :         // updates m_aCurrentFormats with all formats we currently could supply
     148             :         void    updateFormats( );
     149             : 
     150             :     public:
     151             :         OControlTransferData( );
     152             : 
     153             :         // ctor to construct the data from an arbitrary Transferable (usually clipboard data)
     154             :         OControlTransferData(
     155             :             const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTransferable
     156             :         );
     157             : 
     158             :         inline const DataFlavorExVector&    GetDataFlavorExVector() const;
     159             : 
     160             :         void addSelectedEntry( SvTreeListEntry* _pEntry );
     161             :         void setFocusEntry( SvTreeListEntry* _pFocusEntry );
     162             : 
     163             :         /** notifies the data transfer object that a certain entry has been removed from the owning tree
     164             : 
     165             :             In case the removed entry is part of the transfer object's selection, the entry is removed from
     166             :             the selection.
     167             : 
     168             :             @param  _pEntry
     169             :             @return the number of entries remaining in the selection.
     170             :         */
     171             :         size_t  onEntryRemoved( SvTreeListEntry* _pEntry );
     172             : 
     173           0 :         void setFormsRoot(
     174             :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxFormsRoot
     175           0 :             ) { m_xFormsRoot = _rxFormsRoot; }
     176             : 
     177             :         void buildPathFormat(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     178             :             // baut aus m_aSelectedEntries m_aControlPaths auf
     179             :             // (es wird davon ausgegangen, dass die Eintraege in m_aSelectedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
     180             : 
     181             : 
     182             :         void buildListFromPath(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     183             :             // der umgekehrte Weg : wirft alles aus m_aSelectedEntries weg und baut es mittels m_aControlPaths neu auf
     184             : 
     185             :         void addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces);
     186             :             // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
     187             :             // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
     188             :             // Aufrufer sicherstellen)
     189             : 
     190             :         SvTreeListEntry*                focused() const { return m_pFocusEntry; }
     191           0 :         const ListBoxEntrySet&      selected() const { return m_aSelectedEntries; }
     192             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     193           0 :                                     hiddenControls() const { return m_aHiddenControlModels; }
     194             : 
     195             :         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
     196           0 :                                 getFormsRoot() const { return m_xFormsRoot; }
     197             :     };
     198             : 
     199             :     //====================================================================
     200           0 :     inline const DataFlavorExVector& OControlTransferData::GetDataFlavorExVector() const
     201             :     {
     202           0 :         const_cast< OControlTransferData* >( this )->updateFormats( );
     203           0 :         return m_aCurrentFormats;
     204             :     }
     205             : 
     206             :     //====================================================================
     207             :     //= OControlExchange
     208             :     //====================================================================
     209           0 :     class OControlExchange : public OLocalExchange, public OControlTransferData
     210             :     {
     211             :     public:
     212             :         OControlExchange( );
     213             : 
     214             :     public:
     215             :         static sal_uInt32       getFieldExchangeFormatId( );
     216             :         static sal_uInt32       getControlPathFormatId( );
     217             :         static sal_uInt32       getHiddenControlModelsFormatId( );
     218             : 
     219             :         inline static sal_Bool  hasFieldExchangeFormat( const DataFlavorExVector& _rFormats );
     220             :         inline static sal_Bool  hasControlPathFormat( const DataFlavorExVector& _rFormats );
     221             :         inline static sal_Bool  hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats );
     222             : 
     223             :     protected:
     224             :         virtual sal_Bool    GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     225             :         virtual void        AddSupportedFormats();
     226             :     };
     227             : 
     228             :     //====================================================================
     229             :     //= OControlExchangeHelper
     230             :     //====================================================================
     231           0 :     class OControlExchangeHelper : public OLocalExchangeHelper
     232             :     {
     233             :     public:
     234           0 :         OControlExchangeHelper(Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
     235             : 
     236           0 :         OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_pTransferable ); }
     237           0 :         OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_pTransferable ); }
     238             : 
     239             :     protected:
     240             :         virtual OLocalExchange* createExchange() const;
     241             :     };
     242             : 
     243             :     //====================================================================
     244             :     //====================================================================
     245           0 :     inline sal_Bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats )
     246             :     {
     247           0 :         return hasFormat( _rFormats, getFieldExchangeFormatId() );
     248             :     }
     249             : 
     250           0 :     inline sal_Bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats )
     251             :     {
     252           0 :         return hasFormat( _rFormats, getControlPathFormatId() );
     253             :     }
     254             : 
     255           0 :     inline sal_Bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats )
     256             :     {
     257           0 :         return hasFormat( _rFormats, getHiddenControlModelsFormatId() );
     258             :     }
     259             : 
     260             : //........................................................................
     261             : }   // namespace svxform
     262             : //........................................................................
     263             : 
     264             : #endif
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10