LCOV - code coverage report
Current view: top level - svx/source/inc - filtnav.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 37 0.0 %
Date: 2014-11-03 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             :     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 sal_uInt32       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;      // die Position, an der der DropTimer angeschaltet wurde
     252             :     DROP_ACTION         m_aDropActionType;
     253             : 
     254             : public:
     255             :     FmFilterNavigator( vcl::Window* pParent );
     256             :     virtual ~FmFilterNavigator();
     257             : 
     258             :     void UpdateContent(
     259             :             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers,
     260             :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent
     261             :         );
     262           0 :     const FmFilterModel* GetFilterModel() const {return m_pModel;}
     263             : 
     264             : protected:
     265             :     using Control::Notify;
     266             : 
     267             :     virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
     268             :     virtual void Command( const CommandEvent& rEvt ) SAL_OVERRIDE;
     269             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     270             :     virtual void InitEntry(SvTreeListEntry* pEntry, const OUString& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind) SAL_OVERRIDE;
     271             :     virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) SAL_OVERRIDE;
     272             :     virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSelection ) SAL_OVERRIDE;
     273             :     virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
     274             : 
     275             :     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     276             :     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     277             :     virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
     278             : 
     279             :     void DeleteSelection();
     280             :     SvTreeListEntry* FindEntry(const FmFilterData* pItem) const;
     281             :     void Insert(FmFilterData* pItem, sal_uLong nPos);
     282             :     void Remove(FmFilterData* pItem);
     283             : 
     284             :     DECL_LINK(OnRemove, SvTreeListEntry*);
     285             :     DECL_LINK(OnEdited, SvTreeListEntry*);
     286             :     DECL_LINK(OnDropActionTimer, void*);
     287             : 
     288             : private:
     289             :     /** returns the first form item and the selected FilterItems in the vector
     290             :         @param  _rItemList
     291             :             Is filled inside. <OUT/>
     292             :         @return
     293             :             The first form item.
     294             :     */
     295             :     FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
     296             :     /**
     297             :      * inserts the filter items into the tree model and creates new FilterItems if needed.
     298             :      *    @param  _rFilterList
     299             :      *        The items which should be inserted.
     300             :      *    @param  _pTargetItems
     301             :      *        The target where to insert the items.
     302             :      *    @param  _bCopy
     303             :      *        If <TRUE/> the items will not be removed from the model, otherwise they will.
     304             :      */
     305             :     void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy = false);
     306             :     SvTreeListEntry* getPrevEntry(SvTreeListEntry* _pStartWith = NULL);
     307             :     SvTreeListEntry* getNextEntry(SvTreeListEntry* _pStartWith = NULL);
     308             : 
     309             :     using SvTreeListBox::Select;
     310             :     using SvTreeListBox::ExecuteDrop;
     311             :     using SvTreeListBox::Insert;
     312             : };
     313             : 
     314             : 
     315             : class FmFilterNavigatorWin : public SfxDockingWindow, public SfxControllerItem
     316             : {
     317             : private:
     318             :     FmFilterNavigator* m_pNavigator;
     319             : 
     320             : protected:
     321             :     virtual void Resize() SAL_OVERRIDE;
     322             :     virtual bool Close() SAL_OVERRIDE;
     323             :     virtual Size CalcDockingSize( SfxChildAlignment ) SAL_OVERRIDE;
     324             :     virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) SAL_OVERRIDE;
     325             : 
     326             : public:
     327             :     FmFilterNavigatorWin( SfxBindings *pBindings, SfxChildWindow *pMgr,
     328             :                    vcl::Window* pParent );
     329             :     virtual ~FmFilterNavigatorWin();
     330             : 
     331             :     void UpdateContent( FmFormShell* pFormShell );
     332             :     void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE;
     333             :     void FillInfo( SfxChildWinInfo& rInfo ) const SAL_OVERRIDE;
     334             : 
     335             :     using SfxDockingWindow::StateChanged;
     336             : 
     337             :     virtual void GetFocus() SAL_OVERRIDE;
     338             : };
     339             : 
     340             : 
     341           0 : class FmFilterNavigatorWinMgr : public SfxChildWindow
     342             : {
     343             : public:
     344             :     FmFilterNavigatorWinMgr( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings,
     345             :                       SfxChildWinInfo *pInfo );
     346             :     SFX_DECL_CHILDWINDOW( FmFilterNavigatorWinMgr );
     347             : };
     348             : 
     349             : 
     350             : }   // namespace svxform
     351             : 
     352             : 
     353             : #endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
     354             : 
     355             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10