LCOV - code coverage report
Current view: top level - svx/source/inc - filtnav.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 37 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 37 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_FILTNAV_HXX
      20             : #define INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
      21             : 
      22             : #include <com/sun/star/form/XForm.hpp>
      23             : #include <com/sun/star/form/runtime/XFormController.hpp>
      24             : #include <com/sun/star/form/runtime/XFilterController.hpp>
      25             : #include <svl/lstner.hxx>
      26             : #include <svl/SfxBroadcaster.hxx>
      27             : 
      28             : #include <vcl/window.hxx>
      29             : #include <sfx2/childwin.hxx>
      30             : #include <svl/poolitem.hxx>
      31             : #include <sfx2/bindings.hxx>
      32             : #include <sfx2/dockwin.hxx>
      33             : #include <sfx2/ctrlitem.hxx>
      34             : #include <vcl/image.hxx>
      35             : #include <svtools/treelistbox.hxx>
      36             : 
      37             : #include <vcl/dialog.hxx>
      38             : #include <vcl/group.hxx>
      39             : #include <vcl/dockwin.hxx>
      40             : #include "svx/fmtools.hxx"
      41             : #include "fmexch.hxx"
      42             : #include "sqlparserclient.hxx"
      43             : 
      44             : class FmFormShell;
      45             : 
      46             : 
      47             : namespace svxform
      48             : {
      49             : 
      50             : 
      51             : class FmFilterItem;
      52             : class FmFilterItems;
      53             : class FmParentData;
      54             : class FmFilterAdapter;
      55             : 
      56             : 
      57             : // data structure for the filter model
      58             : 
      59             : class FmFilterData
      60             : {
      61             :     FmParentData*           m_pParent;
      62             :     OUString         m_aText;
      63             : 
      64             : public:
      65             :     TYPEINFO();
      66           0 :     FmFilterData(FmParentData* pParent = NULL, const OUString& rText = OUString())
      67             :         :m_pParent( pParent )
      68           0 :         ,m_aText( rText )
      69           0 :     {}
      70           0 :     virtual ~FmFilterData(){}
      71             : 
      72           0 :     void    SetText( const OUString& rText ){ m_aText = rText; }
      73           0 :     OUString  GetText() const { return m_aText; }
      74           0 :     FmParentData* GetParent() const {return m_pParent;}
      75             : 
      76             :     virtual Image GetImage() const;
      77             : };
      78             : 
      79             : 
      80             : class FmParentData : public FmFilterData
      81             : {
      82             : protected:
      83             :     ::std::vector< FmFilterData* >  m_aChildren;
      84             : 
      85             : public:
      86             :     TYPEINFO_OVERRIDE();
      87           0 :     FmParentData(FmParentData* pParent, const OUString& rText)
      88           0 :         : FmFilterData(pParent, rText)
      89           0 :     {}
      90             :     virtual ~FmParentData();
      91             : 
      92           0 :     ::std::vector< FmFilterData* >& GetChildren() { return m_aChildren; }
      93             : };
      94             : 
      95             : 
      96             : // Item representing the forms and subforms
      97           0 : class FmFormItem : public FmParentData
      98             : {
      99             :     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xController;
     100             :     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >  m_xFilterController;
     101             : 
     102             : public:
     103             :     TYPEINFO_OVERRIDE();
     104             : 
     105           0 :     FmFormItem(  FmParentData* _pParent,
     106             :                  const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController,
     107             :                  const OUString& _rText)
     108             :         :FmParentData( _pParent, _rText )
     109             :         ,m_xController( _xController )
     110           0 :         ,m_xFilterController( _xController, ::com::sun::star::uno::UNO_QUERY_THROW )
     111             :     {
     112           0 :     }
     113             : 
     114             :     inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >&
     115           0 :         GetController() { return m_xController; }
     116             : 
     117             :     inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >&
     118           0 :         GetFilterController() { return m_xFilterController; }
     119             : 
     120             :     virtual Image GetImage() const SAL_OVERRIDE;
     121             : };
     122             : 
     123             : 
     124           0 : class FmFilterItems : public FmParentData
     125             : {
     126             : public:
     127             :     TYPEINFO_OVERRIDE();
     128             :     FmFilterItems() : FmParentData(NULL, OUString()) {}
     129           0 :     FmFilterItems(FmFormItem* pParent, const OUString& rText ) : FmParentData(pParent, rText) {}
     130             : 
     131             :     FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const;
     132             :     virtual Image GetImage() const SAL_OVERRIDE;
     133             : };
     134             : 
     135             : 
     136           0 : class FmFilterItem : public FmFilterData
     137             : {
     138             :     OUString     m_aFieldName;
     139             :     const sal_Int32     m_nComponentIndex;
     140             : 
     141             : public:
     142             :     TYPEINFO_OVERRIDE();
     143             :     FmFilterItem(
     144             :         FmFilterItems* pParent,
     145             :         const OUString& aFieldName,
     146             :         const OUString& aCondition,
     147             :         const sal_Int32 _nComponentIndex
     148             :     );
     149             : 
     150           0 :     const OUString& GetFieldName() const {return m_aFieldName;}
     151           0 :     sal_Int32 GetComponentIndex() const { return m_nComponentIndex; }
     152             : 
     153             :     virtual Image GetImage() const SAL_OVERRIDE;
     154             : };
     155             : 
     156             : 
     157             : class FmFilterModel : public FmParentData
     158             :                      ,public SfxBroadcaster
     159             :                      ,public ::svxform::OSQLParserClient
     160             : {
     161             :     friend class FmFilterAdapter;
     162             : 
     163             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >           m_xControllers;
     164             :     ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xController;
     165             :     FmFilterAdapter*        m_pAdapter;
     166             :     FmFilterItems*          m_pCurrentItems;
     167             : 
     168             : public:
     169             :     TYPEINFO_OVERRIDE();
     170             :     FmFilterModel();
     171             :     virtual ~FmFilterModel();
     172             : 
     173             :     void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent);
     174             :     void Clear();
     175             :     bool ValidateText(FmFilterItem* pItem, OUString& rText, OUString& rErrorMsg) const;
     176             :     void Append(FmFilterItems* pItems, FmFilterItem* pFilterItem);
     177             :     void SetTextForItem(FmFilterItem* pItem, const OUString& rText);
     178             : 
     179           0 :     FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? static_cast<FmFormItem*>(m_pCurrentItems->GetParent()) : NULL;}
     180           0 :     FmFilterItems* GetCurrentItems() const {return m_pCurrentItems;}
     181             :     void SetCurrentItems(FmFilterItems* pCurrent);
     182             : 
     183             :     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & GetControllers() const {return m_xControllers;}
     184           0 :     const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetCurrentController() const {return m_xController;}
     185             :     void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController);
     186             : 
     187             :     void Remove(FmFilterData* pFilterItem);
     188             :     static void AppendFilterItems( FmFormItem& _rItem );
     189             :     void EnsureEmptyFilterRows( FmParentData& _rItem );
     190             : 
     191             : protected:
     192             :     void Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pFilterItem);
     193             :     void Remove( const ::std::vector<FmFilterData*>::iterator& rPos );
     194             :     FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const;
     195             :     FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const;
     196             :     void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent);
     197             : };
     198             : 
     199             : 
     200             : 
     201           0 : class OFilterItemExchange : public OLocalExchange
     202             : {
     203             :     ::std::vector<FmFilterItem*>    m_aDraggedEntries;
     204             :     FmFormItem*             m_pFormItem;        // ensure that we drop on the same form
     205             : 
     206             : public:
     207             :     OFilterItemExchange();
     208             : 
     209             :     static SotClipboardFormatId getFormatId( );
     210             :     inline static bool  hasFormat( const DataFlavorExVector& _rFormats );
     211             : 
     212           0 :     const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; }
     213           0 :     void setDraggedEntries(const ::std::vector<FmFilterItem*>& _rList) { m_aDraggedEntries = _rList; }
     214           0 :     FmFormItem* getFormItem() const { return m_pFormItem; }
     215             : 
     216           0 :     void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; }
     217             :     void addSelectedItem( FmFilterItem* _pItem) { m_aDraggedEntries.push_back(_pItem); }
     218             : 
     219             : protected:
     220             :     virtual void AddSupportedFormats() SAL_OVERRIDE;
     221             : };
     222             : 
     223           0 : inline bool OFilterItemExchange::hasFormat( const DataFlavorExVector& _rFormats )
     224             : {
     225           0 :     return OLocalExchange::hasFormat( _rFormats, getFormatId() );
     226             : }
     227             : 
     228           0 : class OFilterExchangeHelper : public OLocalExchangeHelper
     229             : {
     230             : public:
     231           0 :     OFilterExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
     232             : 
     233           0 :     OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_pTransferable); }
     234             : 
     235             : protected:
     236             :     virtual OLocalExchange* createExchange() const SAL_OVERRIDE;
     237             : };
     238             : 
     239             : 
     240             : class FmFilterNavigator : public SvTreeListBox, public SfxListener
     241             : {
     242             :     enum DROP_ACTION{ DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
     243             : 
     244             :     FmFilterModel*          m_pModel;
     245             :     SvTreeListEntry*            m_pEditingCurrently;
     246             :     OFilterExchangeHelper   m_aControlExchange;
     247             : 
     248             : 
     249             :     AutoTimer           m_aDropActionTimer;
     250             :     unsigned short      m_aTimerCounter;
     251             :     Point               m_aTimerTriggered;      // position, where DropTimer was started
     252             :     DROP_ACTION         m_aDropActionType;
     253             : 
     254             : public:
     255             :     FmFilterNavigator( vcl::Window* pParent );
     256             :     virtual ~FmFilterNavigator();
     257             :     virtual void dispose() SAL_OVERRIDE;
     258             : 
     259             :     void UpdateContent(
     260             :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers,
     261             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent
     262             :         );
     263           0 :     const FmFilterModel* GetFilterModel() const {return m_pModel;}
     264             : 
     265             : protected:
     266             :     using Control::Notify;
     267             : 
     268             :     virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     269             :     virtual void Command( const CommandEvent& rEvt ) SAL_OVERRIDE;
     270             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     271             :     virtual void InitEntry(SvTreeListEntry* pEntry, const OUString& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind) SAL_OVERRIDE;
     272             :     virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) SAL_OVERRIDE;
     273             :     virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSelection ) SAL_OVERRIDE;
     274             :     virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
     275             : 
     276             :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     277             :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     278             :     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
     279             : 
     280             :     void DeleteSelection();
     281             :     SvTreeListEntry* FindEntry(const FmFilterData* pItem) const;
     282             :     void Insert(FmFilterData* pItem, sal_uLong nPos);
     283             :     void Remove(FmFilterData* pItem);
     284             : 
     285             :     DECL_LINK(OnRemove, SvTreeListEntry*);
     286             :     DECL_LINK(OnEdited, SvTreeListEntry*);
     287             :     DECL_LINK_TYPED(OnDropActionTimer, Timer*, void);
     288             : 
     289             : private:
     290             :     /** returns the first form item and the selected FilterItems in the vector
     291             :         @param  _rItemList
     292             :             Is filled inside. <OUT/>
     293             :         @return
     294             :             The first form item.
     295             :     */
     296             :     FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
     297             :     /**
     298             :      * inserts the filter items into the tree model and creates new FilterItems if needed.
     299             :      *    @param  _rFilterList
     300             :      *        The items which should be inserted.
     301             :      *    @param  _pTargetItems
     302             :      *        The target where to insert the items.
     303             :      *    @param  _bCopy
     304             :      *        If <TRUE/> the items will not be removed from the model, otherwise they will.
     305             :      */
     306             :     void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy = false);
     307             :     SvTreeListEntry* getPrevEntry(SvTreeListEntry* _pStartWith = NULL);
     308             :     SvTreeListEntry* getNextEntry(SvTreeListEntry* _pStartWith = NULL);
     309             : 
     310             :     using SvTreeListBox::Select;
     311             :     using SvTreeListBox::ExecuteDrop;
     312             :     using SvTreeListBox::Insert;
     313             : };
     314             : 
     315             : 
     316             : class FmFilterNavigatorWin : public SfxDockingWindow, public SfxControllerItem
     317             : {
     318             : private:
     319             :     VclPtr<FmFilterNavigator> m_pNavigator;
     320             : 
     321             : protected:
     322             :     virtual void Resize() SAL_OVERRIDE;
     323             :     virtual bool Close() SAL_OVERRIDE;
     324             :     virtual Size CalcDockingSize( SfxChildAlignment ) SAL_OVERRIDE;
     325             :     virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) SAL_OVERRIDE;
     326             : 
     327             : public:
     328             :     FmFilterNavigatorWin( SfxBindings *pBindings, SfxChildWindow *pMgr,
     329             :                    vcl::Window* pParent );
     330             :     virtual ~FmFilterNavigatorWin();
     331             :     virtual void dispose() SAL_OVERRIDE;
     332             : 
     333             :     void UpdateContent( FmFormShell* pFormShell );
     334             :     void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE;
     335             :     void FillInfo( SfxChildWinInfo& rInfo ) const SAL_OVERRIDE;
     336             : 
     337             :     using SfxDockingWindow::StateChanged;
     338             : 
     339             :     virtual void GetFocus() SAL_OVERRIDE;
     340             : };
     341             : 
     342             : 
     343           0 : class FmFilterNavigatorWinMgr : public SfxChildWindow
     344             : {
     345             : public:
     346             :     FmFilterNavigatorWinMgr( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings,
     347             :                       SfxChildWinInfo *pInfo );
     348             :     SFX_DECL_CHILDWINDOW( FmFilterNavigatorWinMgr );
     349             : };
     350             : 
     351             : 
     352             : }
     353             : 
     354             : 
     355             : #endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
     356             : 
     357             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11