LCOV - code coverage report
Current view: top level - svx/source/inc - fmexch.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 32 0.0 %
Date: 2014-11-03 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             :         bool            m_bDragging         : 1;
      56             :         bool            m_bClipboardOwner   : 1;
      57             : 
      58             :     public:
      59             :         class GrantAccess
      60             :         {
      61             :             friend class OLocalExchangeHelper;
      62             :         };
      63             : 
      64             :     public:
      65             :         OLocalExchange( );
      66             : 
      67           0 :         bool        isDragging() const { return m_bDragging; }
      68           0 :         bool        isClipboardOwner() const { return m_bClipboardOwner; }
      69             : 
      70             :         void        startDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
      71             :         void        copyToClipboard( vcl::Window* _pWindow, const GrantAccess& );
      72             : 
      73           0 :         void        setClipboardListener( const Link& _rListener ) { m_aClipboardListener = _rListener; }
      74             : 
      75             :         void        clear();
      76             : 
      77             :         static  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 css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE;
      86             : 
      87             :     private:
      88           0 :         void StartDrag( vcl::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             :         vcl::Window*             m_pDragSource;
     102             :         OLocalExchange*     m_pTransferable;
     103             : 
     104             :     public:
     105             :         OLocalExchangeHelper( vcl::Window* _pDragSource );
     106             :         virtual ~OLocalExchangeHelper();
     107             : 
     108             :         void        prepareDrag( );
     109             : 
     110             :         void        startDrag( sal_Int8 nDragSourceActions );
     111             :         void        copyToClipboard( ) const;
     112             : 
     113           0 :         inline  bool    isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
     114           0 :         inline  bool    isClipboardOwner() const { return m_pTransferable && m_pTransferable->isClipboardOwner(); }
     115           0 :         inline  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           0 :     class OControlTransferData
     128             :     {
     129             :     private:
     130             :         typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_uInt32 > > ControlPaths;
     131             : 
     132             :     private:
     133             :         DataFlavorExVector  m_aCurrentFormats;
     134             : 
     135             :     protected:
     136             :         ListBoxEntrySet     m_aSelectedEntries;
     137             :         ControlPaths        m_aControlPaths;
     138             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     139             :                             m_aHiddenControlModels;
     140             : 
     141             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >
     142             :                             m_xFormsRoot;       // the root of the forms collection where the entries we represent reside
     143             :                                                 // this uniquely identifies the page and the document
     144             : 
     145             :         SvTreeListEntry*        m_pFocusEntry;
     146             : 
     147             :     protected:
     148             :         // updates m_aCurrentFormats with all formats we currently could supply
     149             :         void    updateFormats( );
     150             : 
     151             :     public:
     152             :         OControlTransferData( );
     153             : 
     154             :         // ctor to construct the data from an arbitrary Transferable (usually clipboard data)
     155             :         OControlTransferData(
     156             :             const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTransferable
     157             :         );
     158             : 
     159             :         inline const DataFlavorExVector&    GetDataFlavorExVector() const;
     160             : 
     161             :         void addSelectedEntry( SvTreeListEntry* _pEntry );
     162             :         void setFocusEntry( SvTreeListEntry* _pFocusEntry );
     163             : 
     164             :         /** notifies the data transfer object that a certain entry has been removed from the owning tree
     165             : 
     166             :             In case the removed entry is part of the transfer object's selection, the entry is removed from
     167             :             the selection.
     168             : 
     169             :             @param  _pEntry
     170             :             @return the number of entries remaining in the selection.
     171             :         */
     172             :         size_t  onEntryRemoved( SvTreeListEntry* _pEntry );
     173             : 
     174           0 :         void setFormsRoot(
     175             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >& _rxFormsRoot
     176           0 :             ) { m_xFormsRoot = _rxFormsRoot; }
     177             : 
     178             :         void buildPathFormat(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     179             :             // baut aus m_aSelectedEntries m_aControlPaths auf
     180             :             // (es wird davon ausgegangen, dass die Eintraege in m_aSelectedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
     181             : 
     182             : 
     183             :         void buildListFromPath(SvTreeListBox* pTreeBox, SvTreeListEntry* pRoot);
     184             :             // der umgekehrte Weg : wirft alles aus m_aSelectedEntries weg und baut es mittels m_aControlPaths neu auf
     185             : 
     186             :         void addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& seqInterfaces);
     187             :             // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
     188             :             // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
     189             :             // Aufrufer sicherstellen)
     190             : 
     191             :         SvTreeListEntry*                focused() const { return m_pFocusEntry; }
     192           0 :         const ListBoxEntrySet&      selected() const { return m_aSelectedEntries; }
     193             :         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
     194           0 :                                     hiddenControls() const { return m_aHiddenControlModels; }
     195             : 
     196             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForms >
     197           0 :                                 getFormsRoot() const { return m_xFormsRoot; }
     198             :     };
     199             : 
     200             : 
     201           0 :     inline const DataFlavorExVector& OControlTransferData::GetDataFlavorExVector() const
     202             :     {
     203           0 :         const_cast< OControlTransferData* >( this )->updateFormats( );
     204           0 :         return m_aCurrentFormats;
     205             :     }
     206             : 
     207           0 :     class OControlExchange : public OLocalExchange, public OControlTransferData
     208             :     {
     209             :     public:
     210             :         OControlExchange( );
     211             : 
     212             :     public:
     213             :         static sal_uInt32       getFieldExchangeFormatId( );
     214             :         static sal_uInt32       getControlPathFormatId( );
     215             :         static sal_uInt32       getHiddenControlModelsFormatId( );
     216             : 
     217             :         inline static bool  hasFieldExchangeFormat( const DataFlavorExVector& _rFormats );
     218             :         inline static bool  hasControlPathFormat( const DataFlavorExVector& _rFormats );
     219             :         inline static bool  hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats );
     220             : 
     221             :     protected:
     222             :         virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) SAL_OVERRIDE;
     223             :         virtual void        AddSupportedFormats() SAL_OVERRIDE;
     224             :     };
     225             : 
     226           0 :     class OControlExchangeHelper : public OLocalExchangeHelper
     227             :     {
     228             :     public:
     229           0 :         OControlExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
     230             : 
     231           0 :         OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_pTransferable ); }
     232           0 :         OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_pTransferable ); }
     233             : 
     234             :     protected:
     235             :         virtual OLocalExchange* createExchange() const SAL_OVERRIDE;
     236             :     };
     237             : 
     238             : 
     239             : 
     240           0 :     inline bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats )
     241             :     {
     242           0 :         return hasFormat( _rFormats, getFieldExchangeFormatId() );
     243             :     }
     244             : 
     245           0 :     inline bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats )
     246             :     {
     247           0 :         return hasFormat( _rFormats, getControlPathFormatId() );
     248             :     }
     249             : 
     250           0 :     inline bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats )
     251             :     {
     252           0 :         return hasFormat( _rFormats, getHiddenControlModelsFormatId() );
     253             :     }
     254             : 
     255             : 
     256             : }   // namespace svxform
     257             : 
     258             : 
     259             : #endif
     260             : 
     261             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10