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

Generated by: LCOV version 1.11