LCOV - code coverage report
Current view: top level - svx/source/inc - fmexch.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 32 0.0 %
Date: 2014-04-14 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 INCLUDED_SVX_SOURCE_INC_FMEXCH_HXX
      20             : #define INCLUDED_SVX_SOURCE_INC_FMEXCH_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <set>
      25             : 
      26             : #include <svtools/transfer.hxx>
      27             : #include <com/sun/star/uno/Sequence.hxx>
      28             : #include <com/sun/star/container/XNameContainer.hpp>
      29             : #include <com/sun/star/form/XForms.hpp>
      30             : #include <tools/link.hxx>
      31             : 
      32             : #include <svx/svxdllapi.h>
      33             : 
      34             : class SvTreeListEntry;
      35             : 
      36             : 
      37             : class SvTreeListBox;
      38             : 
      39             : 
      40             : namespace svxform
      41             : {
      42             : 
      43             : 
      44             : 
      45             : 
      46             :     typedef ::std::set< SvTreeListEntry* >  ListBoxEntrySet;
      47             : 
      48             : 
      49             :     //= OLocalExchange
      50             : 
      51           0 :     class SVX_DLLPUBLIC OLocalExchange : public TransferableHelper
      52             :     {
      53             :     private:
      54             :         Link                m_aClipboardListener;
      55             :         sal_Bool            m_bDragging         : 1;
      56             :         sal_Bool            m_bClipboardOwner   : 1;
      57             : 
      58             :     public:
      59             :         class GrantAccess
      60             :         {
      61             :             friend class OLocalExchangeHelper;
      62             :         };
      63             : 
      64             :     public:
      65             :         OLocalExchange( );
      66             : 
      67           0 :         sal_Bool    isDragging() const { return m_bDragging; }
      68           0 :         sal_Bool    isClipboardOwner() const { return m_bClipboardOwner; }
      69             : 
      70             :         void        startDrag( Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
      71             :         void        copyToClipboard( Window* _pWindow, const GrantAccess& );
      72             : 
      73           0 :         void        setClipboardListener( const Link& _rListener ) { m_aClipboardListener = _rListener; }
      74             : 
      75             :         void        clear();
      76             : 
      77             :         static  sal_Bool    hasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId );
      78             : 
      79             :     protected:
      80             :         // XClipboardOwner
      81             :         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, std::exception) SAL_OVERRIDE;
      82             : 
      83             :         // TransferableHelper
      84             :         virtual void        DragFinished( sal_Int8 nDropAction ) SAL_OVERRIDE;
      85             :         virtual bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
      86             : 
      87             :     private:
      88           0 :         void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, sal_Int32 nDragPointer = DND_POINTER_NONE, sal_Int32 nDragImage = DND_IMAGE_NONE )
      89             :         {   // don't allow this base class method to be called from outside
      90           0 :             TransferableHelper::StartDrag(pWindow, nDragSourceActions, nDragPointer, nDragImage);
      91           0 :         }
      92             :     };
      93             : 
      94             : 
      95             :     //= OLocalExchangeHelper
      96             : 
      97             :     /// a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
      98             :     class SVX_DLLPUBLIC OLocalExchangeHelper
      99             :     {
     100             :     protected:
     101             :         Window*             m_pDragSource;
     102             :         OLocalExchange*     m_pTransferable;
     103             : 
     104             :     public:
     105             :         OLocalExchangeHelper( Window* _pDragSource );
     106             :         virtual ~OLocalExchangeHelper();
     107             : 
     108             :         void        prepareDrag( );
     109             : 
     110             :         void        startDrag( sal_Int8 nDragSourceActions );
     111             :         void        copyToClipboard( ) const;
     112             : 
     113           0 :         inline  sal_Bool    isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
     114           0 :         inline  sal_Bool    isClipboardOwner() const { return m_pTransferable && m_pTransferable->isClipboardOwner(); }
     115           0 :         inline  sal_Bool    isDataExchangeActive( ) const { return isDragSource() || isClipboardOwner(); }
     116           0 :         inline  void        clear() { if ( isDataExchangeActive() ) m_pTransferable->clear(); }
     117             : 
     118           0 :         SVX_DLLPRIVATE void     setClipboardListener( const Link& _rListener ) { if ( m_pTransferable ) m_pTransferable->setClipboardListener( _rListener ); }
     119             : 
     120             :     protected:
     121             :         SVX_DLLPRIVATE virtual OLocalExchange* createExchange() const = 0;
     122             : 
     123             :     protected:
     124             :         SVX_DLLPRIVATE void implReset();
     125             :     };
     126             : 
     127             : 
     128             :     //= OControlTransferData
     129             : 
     130           0 :     class OControlTransferData
     131             :     {
     132             :     private:
     133             :         typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_uInt32 > > ControlPaths;
     134             : 
     135             :     private:
     136             :         DataFlavorExVector  m_aCurrentFormats;
     137             : 
     138             :     protected:
     139             :         ListBoxEntrySet     m_aSelectedEntries;
     140             :         ControlPaths        m_aControlPaths;
     141             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     142             :                             m_aHiddenControlModels;
     143             : 
     144             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >
     145             :                             m_xFormsRoot;       // the root of the forms collection where the entries we represent reside
     146             :                                                 // this uniquely identifies the page and the document
     147             : 
     148             :         SvTreeListEntry*        m_pFocusEntry;
     149             : 
     150             :     protected:
     151             :         // updates m_aCurrentFormats with all formats we currently could supply
     152             :         void    updateFormats( );
     153             : 
     154             :     public:
     155             :         OControlTransferData( );
     156             : 
     157             :         // ctor to construct the data from an arbitrary Transferable (usually clipboard data)
     158             :         OControlTransferData(
     159             :             const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTransferable
     160             :         );
     161             : 
     162             :         inline const DataFlavorExVector&    GetDataFlavorExVector() const;
     163             : 
     164             :         void addSelectedEntry( SvTreeListEntry* _pEntry );
     165             :         void setFocusEntry( SvTreeListEntry* _pFocusEntry );
     166             : 
     167             :         /** notifies the data transfer object that a certain entry has been removed from the owning tree
     168             : 
     169             :             In case the removed entry is part of the transfer object's selection, the entry is removed from
     170             :             the selection.
     171             : 
     172             :             @param  _pEntry
     173             :             @return the number of entries remaining in the selection.
     174             :         */
     175             :         size_t  onEntryRemoved( SvTreeListEntry* _pEntry );
     176             : 
     177           0 :         void setFormsRoot(
     178             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >& _rxFormsRoot
     179           0 :             ) { m_xFormsRoot = _rxFormsRoot; }
     180             : 
     181             :         void buildPathFormat(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     182             :             // baut aus m_aSelectedEntries m_aControlPaths auf
     183             :             // (es wird davon ausgegangen, dass die Eintraege in m_aSelectedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
     184             : 
     185             : 
     186             :         void buildListFromPath(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     187             :             // der umgekehrte Weg : wirft alles aus m_aSelectedEntries weg und baut es mittels m_aControlPaths neu auf
     188             : 
     189             :         void addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces);
     190             :             // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
     191             :             // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
     192             :             // Aufrufer sicherstellen)
     193             : 
     194             :         SvTreeListEntry*                focused() const { return m_pFocusEntry; }
     195           0 :         const ListBoxEntrySet&      selected() const { return m_aSelectedEntries; }
     196             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     197           0 :                                     hiddenControls() const { return m_aHiddenControlModels; }
     198             : 
     199             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >
     200           0 :                                 getFormsRoot() const { return m_xFormsRoot; }
     201             :     };
     202             : 
     203             : 
     204           0 :     inline const DataFlavorExVector& OControlTransferData::GetDataFlavorExVector() const
     205             :     {
     206           0 :         const_cast< OControlTransferData* >( this )->updateFormats( );
     207           0 :         return m_aCurrentFormats;
     208             :     }
     209             : 
     210             : 
     211             :     //= OControlExchange
     212             : 
     213           0 :     class OControlExchange : public OLocalExchange, public OControlTransferData
     214             :     {
     215             :     public:
     216             :         OControlExchange( );
     217             : 
     218             :     public:
     219             :         static sal_uInt32       getFieldExchangeFormatId( );
     220             :         static sal_uInt32       getControlPathFormatId( );
     221             :         static sal_uInt32       getHiddenControlModelsFormatId( );
     222             : 
     223             :         inline static sal_Bool  hasFieldExchangeFormat( const DataFlavorExVector& _rFormats );
     224             :         inline static sal_Bool  hasControlPathFormat( const DataFlavorExVector& _rFormats );
     225             :         inline static sal_Bool  hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats );
     226             : 
     227             :     protected:
     228             :         virtual bool        GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) SAL_OVERRIDE;
     229             :         virtual void        AddSupportedFormats() SAL_OVERRIDE;
     230             :     };
     231             : 
     232             : 
     233             :     //= OControlExchangeHelper
     234             : 
     235           0 :     class OControlExchangeHelper : public OLocalExchangeHelper
     236             :     {
     237             :     public:
     238           0 :         OControlExchangeHelper(Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
     239             : 
     240           0 :         OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_pTransferable ); }
     241           0 :         OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_pTransferable ); }
     242             : 
     243             :     protected:
     244             :         virtual OLocalExchange* createExchange() const SAL_OVERRIDE;
     245             :     };
     246             : 
     247             : 
     248             : 
     249           0 :     inline sal_Bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats )
     250             :     {
     251           0 :         return hasFormat( _rFormats, getFieldExchangeFormatId() );
     252             :     }
     253             : 
     254           0 :     inline sal_Bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats )
     255             :     {
     256           0 :         return hasFormat( _rFormats, getControlPathFormatId() );
     257             :     }
     258             : 
     259           0 :     inline sal_Bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats )
     260             :     {
     261           0 :         return hasFormat( _rFormats, getHiddenControlModelsFormatId() );
     262             :     }
     263             : 
     264             : 
     265             : }   // namespace svxform
     266             : 
     267             : 
     268             : #endif
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10