LCOV - code coverage report
Current view: top level - sw/source/uibase/inc - conttree.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 9 21 42.9 %
Date: 2014-11-03 Functions: 6 16 37.5 %
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_SW_SOURCE_UIBASE_INC_CONTTREE_HXX
      20             : #define INCLUDED_SW_SOURCE_UIBASE_INC_CONTTREE_HXX
      21             : 
      22             : #include <svtools/treelistbox.hxx>
      23             : #include <svtools/svlbitm.hxx>
      24             : #include "swcont.hxx"
      25             : 
      26             : #include <map>
      27             : 
      28             : class SwWrtShell;
      29             : class SwContentType;
      30             : class SwNavigationPI;
      31             : class SwNavigationConfig;
      32             : class Menu;
      33             : class ToolBox;
      34             : class SwGlblDocContents;
      35             : class SwGlblDocContent;
      36             : class SfxObjectShell;
      37             : class SdrObject;
      38             : 
      39             : #define EDIT_MODE_EDIT          0
      40             : #define EDIT_MODE_UPD_IDX       1
      41             : #define EDIT_MODE_RMV_IDX       2
      42             : #define EDIT_UNPROTECT_TABLE    3
      43             : #define EDIT_MODE_DELETE        4
      44             : #define EDIT_MODE_RENAME        5
      45             : 
      46             : class SwContentTree : public SvTreeListBox
      47             : {
      48             :     ImageList           aEntryImages;
      49             :     OUString            sSpace;
      50             :     AutoTimer           aUpdTimer;
      51             : 
      52             :     SwContentType*      aActiveContentArr[CONTENT_TYPE_MAX];
      53             :     SwContentType*      aHiddenContentArr[CONTENT_TYPE_MAX];
      54             :     OUString            aContextStrings[CONTEXT_COUNT + 1];
      55             :     OUString            sRemoveIdx;
      56             :     OUString            sUpdateIdx;
      57             :     OUString            sUnprotTbl;
      58             :     OUString            sRename;
      59             :     OUString            sReadonlyIdx;
      60             :     OUString            sInvisible;
      61             :     OUString            sPostItShow;
      62             :     OUString            sPostItHide;
      63             :     OUString            sPostItDelete;
      64             : 
      65             :     SwWrtShell*         pHiddenShell;   // dropped Doc
      66             :     SwWrtShell*         pActiveShell;   // the active or a const. open view
      67             :     SwNavigationConfig* pConfig;
      68             : 
      69             :     std::map< void*, bool > mOutLineNodeMap;
      70             : 
      71             :     sal_Int32           nActiveBlock;
      72             :     sal_Int32           nHiddenBlock;
      73             :     sal_uInt16              nRootType;
      74             :     sal_uInt16              nLastSelType;
      75             :     sal_uInt8               nOutlineLevel;
      76             : 
      77             :     bool                bIsActive           :1;
      78             :     bool                bIsConstant         :1;
      79             :     bool                bIsHidden           :1;
      80             :     bool                bDocChgdInDragging  :1;
      81             :     bool                bIsInternalDrag     :1;
      82             :     bool                bIsRoot             :1;
      83             :     bool                bIsIdleClear        :1;
      84             :     bool                bIsLastReadOnly     :1;
      85             :     bool                bIsOutlineMoveable  :1;
      86             :     bool                bViewHasChanged     :1;
      87             :     bool                bIsImageListInitialized : 1;
      88             : 
      89             :     static bool         bIsInDrag;
      90             : 
      91             :     bool                bIsKeySpace;
      92             :     Rectangle           oldRectangle;
      93             : 
      94             :     void                FindActiveTypeAndRemoveUserData();
      95             : 
      96             :     using SvTreeListBox::ExecuteDrop;
      97             :     using SvTreeListBox::EditEntry;
      98             : 
      99             : protected:
     100             :     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     101             :     virtual void    InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind) SAL_OVERRIDE;
     102             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     103             : 
     104         699 :     SwNavigationPI* GetParentWindow(){return
     105         699 :                         (SwNavigationPI*)Window::GetParent();}
     106             : 
     107             :     virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
     108             :     virtual void    DragFinished( sal_Int8 ) SAL_OVERRIDE;
     109             :     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     110             : 
     111             :     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     112             : 
     113             :     bool        FillTransferData( TransferDataContainer& rTransfer,
     114             :                                             sal_Int8& rDragMode );
     115             :     bool            HasContentChanged();
     116             : 
     117             :     virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
     118             :                                         SvTreeListEntry* ) SAL_OVERRIDE;
     119             :     virtual bool    NotifyAcceptDrop( SvTreeListEntry* ) SAL_OVERRIDE;
     120             : 
     121             :     virtual TriState NotifyMoving(   SvTreeListEntry*  pTarget,
     122             :                                     SvTreeListEntry*  pEntry,
     123             :                                     SvTreeListEntry*& rpNewParent,
     124             :                                     sal_uLong&        rNewChildPos
     125             :                                 ) SAL_OVERRIDE;
     126             :     virtual TriState NotifyCopying(  SvTreeListEntry*  pTarget,
     127             :                                     SvTreeListEntry*  pEntry,
     128             :                                     SvTreeListEntry*& rpNewParent,
     129             :                                     sal_uLong&        rNewChildPos
     130             :                                 ) SAL_OVERRIDE;
     131             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     132             : 
     133             :     void            EditEntry( SvTreeListEntry* pEntry, sal_uInt8 nMode );
     134             : 
     135             :     void            GotoContent(SwContent* pCnt);
     136           0 :     static void     SetInDrag(bool bSet) {bIsInDrag = bSet;}
     137             : 
     138             :     virtual PopupMenu* CreateContextMenu( void ) SAL_OVERRIDE;
     139             :     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
     140             : 
     141             : public:
     142             :     SwContentTree(vcl::Window* pParent, const ResId& rResId);
     143             :     virtual ~SwContentTree();
     144             :     OUString        GetEntryAltText( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
     145             :     OUString        GetEntryLongDescription( SvTreeListEntry* pEntry ) const SAL_OVERRIDE;
     146             :     SdrObject*      GetDrawingObjectsByContent(const SwContent *pCnt);
     147             : 
     148             :     bool            ToggleToRoot();
     149             :     bool            IsRoot() const {return bIsRoot;}
     150             :     sal_uInt16          GetRootType() const {return nRootType;}
     151             :     void            SetRootType(sal_uInt16 nType);
     152             :     void            Display( bool bActiveView );
     153             :     void            Clear();
     154             :     void            SetHiddenShell(SwWrtShell* pSh);
     155             :     void            ShowHiddenShell();
     156             :     void            ShowActualView();
     157             :     void            SetActiveShell(SwWrtShell* pSh);
     158             :     void            SetConstantShell(SwWrtShell* pSh);
     159             : 
     160         400 :     SwWrtShell*     GetWrtShell()
     161           0 :                         {return bIsActive||bIsConstant ?
     162             :                                     pActiveShell :
     163         800 :                                         pHiddenShell;}
     164             : 
     165           0 :     static bool     IsInDrag() {return bIsInDrag;}
     166             :     bool            IsInternalDrag() const {return bIsInternalDrag;}
     167             : 
     168             :     sal_Int32       GetActiveBlock() const {return nActiveBlock;}
     169             : 
     170           0 :     sal_uInt8           GetOutlineLevel()const {return nOutlineLevel;}
     171             :     void            SetOutlineLevel(sal_uInt8 nSet);
     172             : 
     173             :     virtual bool    Expand( SvTreeListEntry* pParent ) SAL_OVERRIDE;
     174             : 
     175             :     virtual bool    Collapse( SvTreeListEntry* pParent ) SAL_OVERRIDE;
     176             : 
     177             :     void            ExecCommand(sal_uInt16 nCmd, bool bModifier);
     178             : 
     179             :     void            ShowTree();
     180             :     void            HideTree();
     181             : 
     182          62 :     bool            IsConstantView() {return bIsConstant;}
     183          62 :     bool            IsActiveView()   {return bIsActive;}
     184           0 :     bool            IsHiddenView()   {return bIsHidden;}
     185             : 
     186           0 :     const SwWrtShell*   GetActiveWrtShell() {return pActiveShell;}
     187          62 :     SwWrtShell*         GetHiddenWrtShell() {return pHiddenShell;}
     188             : 
     189             :     DECL_LINK( ContentDoubleClickHdl, void * );
     190             :     DECL_LINK( TimerUpdate, void * );
     191             : 
     192             :     virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ) SAL_OVERRIDE;
     193             :     virtual void    RequestingChildren( SvTreeListEntry* pParent ) SAL_OVERRIDE;
     194             :     virtual void    GetFocus() SAL_OVERRIDE;
     195             :     virtual void    KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
     196             : 
     197             :     virtual bool    Select( SvTreeListEntry* pEntry, bool bSelect=true ) SAL_OVERRIDE;
     198             :     virtual sal_Int32  GetEntryRealChildrenNum( SvTreeListEntry* pEntry ) const;
     199             : };
     200             : 
     201             : // TreeListBox for global documents
     202             : 
     203           0 : class SwLBoxString : public SvLBoxString
     204             : {
     205             : public:
     206             : 
     207           0 :     SwLBoxString( SvTreeListEntry* pEntry, sal_uInt16 nFlags,
     208           0 :         const OUString& rStr ) : SvLBoxString(pEntry,nFlags,rStr)
     209             :     {
     210           0 :     }
     211             : 
     212             :     virtual void Paint(
     213             :         const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView,
     214             :         const SvTreeListEntry* pEntry) SAL_OVERRIDE;
     215             : };
     216             : 
     217             : namespace sfx2 { class DocumentInserter; }
     218             : namespace sfx2 { class FileDialogHelper; }
     219             : 
     220             : class SwGlobalTree : public SvTreeListBox
     221             : {
     222             : private:
     223             :     AutoTimer           aUpdateTimer;
     224             :     OUString            aContextStrings[GLOBAL_CONTEXT_COUNT];
     225             : 
     226             :     ImageList           aEntryImages;
     227             : 
     228             :     SwWrtShell*             pActiveShell;
     229             :     SvTreeListEntry*            pEmphasisEntry; // Drag'n Drop emphasis
     230             :     SvTreeListEntry*            pDDSource;      // source for Drag'n Drop
     231             :     SwGlblDocContents*      pSwGlblDocContents; // array with sorted content
     232             : 
     233             :     vcl::Window*                 pDefParentWin;
     234             :     SwGlblDocContent*       pDocContent;
     235             :     sfx2::DocumentInserter* pDocInserter;
     236             : 
     237             :     bool                bIsInternalDrag     :1;
     238             :     bool                bLastEntryEmphasis  :1; // Drag'n Drop
     239             :     bool                bIsImageListInitialized : 1;
     240             : 
     241             :     static const SfxObjectShell* pShowShell;
     242             : 
     243             :     void        InsertRegion( const SwGlblDocContent* _pContent,
     244             :                               const com::sun::star::uno::Sequence< OUString >& _rFiles );
     245             : 
     246             :     DECL_LINK(  DialogClosedHdl, sfx2::FileDialogHelper* );
     247             : 
     248             :     using SvTreeListBox::DoubleClickHdl;
     249             :     using SvTreeListBox::ExecuteDrop;
     250             :     using Window::Update;
     251             : 
     252             : protected:
     253             : 
     254             :     virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
     255             : 
     256             :     virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
     257             : 
     258             :     virtual void    DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     259             : 
     260             :     virtual void    RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
     261             : 
     262             :     virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* ) SAL_OVERRIDE;
     263             :     virtual TriState NotifyMoving(   SvTreeListEntry*  pTarget,
     264             :                                     SvTreeListEntry*  pEntry,
     265             :                                     SvTreeListEntry*& rpNewParent,
     266             :                                     sal_uLong&        rNewChildPos
     267             :                                 ) SAL_OVERRIDE;
     268             :     virtual TriState NotifyCopying(  SvTreeListEntry*  pTarget,
     269             :                                     SvTreeListEntry*  pEntry,
     270             :                                     SvTreeListEntry*& rpNewParent,
     271             :                                     sal_uLong&        rNewChildPos
     272             :                                 ) SAL_OVERRIDE;
     273             : 
     274             :     virtual void    StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
     275             :     virtual void    DragFinished( sal_Int8 ) SAL_OVERRIDE;
     276             :     virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
     277             :                                         SvTreeListEntry* ) SAL_OVERRIDE;
     278             :     virtual bool    NotifyAcceptDrop( SvTreeListEntry* ) SAL_OVERRIDE;
     279             : 
     280             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
     281             :     virtual void    KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
     282             :     virtual void    GetFocus() SAL_OVERRIDE;
     283             :     virtual void    SelectHdl() SAL_OVERRIDE;
     284             :     virtual void    DeselectHdl() SAL_OVERRIDE;
     285             :     virtual void    InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&, SvLBoxButtonKind) SAL_OVERRIDE;
     286             : 
     287             :     void            Clear();
     288             : 
     289             :     DECL_LINK(      PopupHdl, Menu* );
     290             :     DECL_LINK(      Timeout, void* );
     291             :     DECL_LINK(      DoubleClickHdl, void* );
     292             : 
     293             :     bool            IsInternalDrag() const {return bIsInternalDrag;}
     294         120 :     SwNavigationPI* GetParentWindow()
     295         120 :                         { return (SwNavigationPI*)Window::GetParent(); }
     296             : 
     297             :     void            OpenDoc(const SwGlblDocContent*);
     298             :     void            GotoContent(const SwGlblDocContent*);
     299             :     sal_uInt16          GetEnableFlags() const;
     300             : 
     301           0 :     static const SfxObjectShell*    GetShowShell() {return pShowShell;}
     302           0 :     static void     SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;}
     303             :     DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*);
     304             : 
     305             :     virtual PopupMenu* CreateContextMenu( void ) SAL_OVERRIDE;
     306             :     virtual void    ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) SAL_OVERRIDE;
     307             : 
     308             : public:
     309             :     SwGlobalTree(vcl::Window* pParent, const ResId& rResId);
     310             :     virtual ~SwGlobalTree();
     311             : 
     312             :     void                TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox);
     313             :     void                InsertRegion( const SwGlblDocContent* pCont,
     314             :                                         const OUString* pFileName = 0 );
     315             :     void                EditContent(const SwGlblDocContent* pCont );
     316             : 
     317             :     void                ShowTree();
     318             :     void                HideTree();
     319             : 
     320             :     void                ExecCommand(sal_uInt16 nCmd);
     321             : 
     322             :     void                Display(bool bOnlyUpdateUserData = false);
     323             : 
     324             :     bool                Update(bool bHard);
     325             : };
     326             : 
     327             : #endif
     328             : 
     329             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10