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

Generated by: LCOV version 1.11