1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef _CONTTREE_HXX 28*cdf0e10cSrcweir #define _CONTTREE_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 31*cdf0e10cSrcweir #include "swcont.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir class SwWrtShell; 34*cdf0e10cSrcweir class SwContentType; 35*cdf0e10cSrcweir class SwNavigationPI; 36*cdf0e10cSrcweir class SwNavigationConfig; 37*cdf0e10cSrcweir class Menu; 38*cdf0e10cSrcweir class ToolBox; 39*cdf0e10cSrcweir class SwGlblDocContents; 40*cdf0e10cSrcweir class SwGlblDocContent; 41*cdf0e10cSrcweir class SfxObjectShell; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #define EDIT_MODE_EDIT 0 45*cdf0e10cSrcweir #define EDIT_MODE_UPD_IDX 1 46*cdf0e10cSrcweir #define EDIT_MODE_RMV_IDX 2 47*cdf0e10cSrcweir #define EDIT_UNPROTECT_TABLE 3 48*cdf0e10cSrcweir #define EDIT_MODE_DELETE 4 49*cdf0e10cSrcweir #define EDIT_MODE_RENAME 5 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir //---------------------------------------------------------------------------- 52*cdf0e10cSrcweir //---------------------------------------------------------------------------- 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir class SwContentTree : public SvTreeListBox 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir ImageList aEntryImages; 57*cdf0e10cSrcweir String sSpace; 58*cdf0e10cSrcweir AutoTimer aUpdTimer; 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir SwContentType* aActiveContentArr[CONTENT_TYPE_MAX]; 61*cdf0e10cSrcweir SwContentType* aHiddenContentArr[CONTENT_TYPE_MAX]; 62*cdf0e10cSrcweir String aContextStrings[CONTEXT_COUNT + 1]; 63*cdf0e10cSrcweir String sRemoveIdx; 64*cdf0e10cSrcweir String sUpdateIdx; 65*cdf0e10cSrcweir String sUnprotTbl; 66*cdf0e10cSrcweir String sRename; 67*cdf0e10cSrcweir String sReadonlyIdx; 68*cdf0e10cSrcweir String sInvisible; 69*cdf0e10cSrcweir String sPostItShow; 70*cdf0e10cSrcweir String sPostItHide; 71*cdf0e10cSrcweir String sPostItDelete; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir SwWrtShell* pHiddenShell; // gedropptes Doc 74*cdf0e10cSrcweir SwWrtShell* pActiveShell; // die aktive oder eine konst. offene View 75*cdf0e10cSrcweir SwNavigationConfig* pConfig; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir sal_Int32 nActiveBlock; 78*cdf0e10cSrcweir sal_uInt16 nHiddenBlock; 79*cdf0e10cSrcweir sal_uInt16 nRootType; 80*cdf0e10cSrcweir sal_uInt16 nLastSelType; 81*cdf0e10cSrcweir sal_uInt8 nOutlineLevel; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir sal_Bool bIsActive :1; 84*cdf0e10cSrcweir sal_Bool bIsConstant :1; 85*cdf0e10cSrcweir sal_Bool bIsHidden :1; 86*cdf0e10cSrcweir sal_Bool bDocChgdInDragging :1; 87*cdf0e10cSrcweir sal_Bool bIsInternalDrag :1; 88*cdf0e10cSrcweir sal_Bool bIsRoot :1; 89*cdf0e10cSrcweir sal_Bool bIsIdleClear :1; 90*cdf0e10cSrcweir sal_Bool bIsLastReadOnly :1; 91*cdf0e10cSrcweir sal_Bool bIsOutlineMoveable :1; 92*cdf0e10cSrcweir sal_Bool bViewHasChanged :1; 93*cdf0e10cSrcweir sal_Bool bIsImageListInitialized : 1; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir static sal_Bool bIsInDrag; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir void FindActiveTypeAndRemoveUserData(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir using SvLBox::ExecuteDrop; 100*cdf0e10cSrcweir using SvTreeListBox::EditEntry; 101*cdf0e10cSrcweir using SvListView::Expand; 102*cdf0e10cSrcweir using SvListView::Collapse; 103*cdf0e10cSrcweir using SvListView::Select; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir protected: 106*cdf0e10cSrcweir // virtual void Command( const CommandEvent& rCEvt ); 107*cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 108*cdf0e10cSrcweir virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind); 109*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir SwNavigationPI* GetParentWindow(){return 112*cdf0e10cSrcweir (SwNavigationPI*)Window::GetParent();} 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 115*cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 116*cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sal_Bool FillTransferData( TransferDataContainer& rTransfer, 121*cdf0e10cSrcweir sal_Int8& rDragMode ); 122*cdf0e10cSrcweir sal_Bool HasContentChanged(); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, 125*cdf0e10cSrcweir SvLBoxEntry* ); 126*cdf0e10cSrcweir virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, 129*cdf0e10cSrcweir SvLBoxEntry* pEntry, 130*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 131*cdf0e10cSrcweir sal_uLong& rNewChildPos 132*cdf0e10cSrcweir ); 133*cdf0e10cSrcweir virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, 134*cdf0e10cSrcweir SvLBoxEntry* pEntry, 135*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 136*cdf0e10cSrcweir sal_uLong& rNewChildPos 137*cdf0e10cSrcweir ); 138*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void EditEntry( SvLBoxEntry* pEntry, sal_uInt8 nMode ); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir void GotoContent(SwContent* pCnt); 143*cdf0e10cSrcweir static void SetInDrag(sal_Bool bSet) {bIsInDrag = bSet;} 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 146*cdf0e10cSrcweir virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir public: 149*cdf0e10cSrcweir SwContentTree(Window* pParent, const ResId& rResId); 150*cdf0e10cSrcweir ~SwContentTree(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir sal_Bool ToggleToRoot(); 153*cdf0e10cSrcweir sal_Bool IsRoot() const {return bIsRoot;} 154*cdf0e10cSrcweir sal_uInt16 GetRootType() const {return nRootType;} 155*cdf0e10cSrcweir void SetRootType(sal_uInt16 nType); 156*cdf0e10cSrcweir void Display( sal_Bool bActiveView ); 157*cdf0e10cSrcweir void Clear(); 158*cdf0e10cSrcweir void SetHiddenShell(SwWrtShell* pSh); 159*cdf0e10cSrcweir void ShowHiddenShell(); 160*cdf0e10cSrcweir void ShowActualView(); 161*cdf0e10cSrcweir void SetActiveShell(SwWrtShell* pSh); 162*cdf0e10cSrcweir void SetConstantShell(SwWrtShell* pSh); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir SwWrtShell* GetWrtShell() 165*cdf0e10cSrcweir {return bIsActive||bIsConstant ? 166*cdf0e10cSrcweir pActiveShell : 167*cdf0e10cSrcweir pHiddenShell;} 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir static sal_Bool IsInDrag() {return bIsInDrag;} 170*cdf0e10cSrcweir sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;} 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir sal_Int32 GetActiveBlock() const {return nActiveBlock;} 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir sal_uInt8 GetOutlineLevel()const {return nOutlineLevel;} 175*cdf0e10cSrcweir void SetOutlineLevel(sal_uInt8 nSet); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir sal_Bool Expand( SvLBoxEntry* pParent ); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_Bool Collapse( SvLBoxEntry* pParent ); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void ShowTree(); 184*cdf0e10cSrcweir void HideTree(); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir sal_Bool IsConstantView() {return bIsConstant;} 187*cdf0e10cSrcweir sal_Bool IsActiveView() {return bIsActive;} 188*cdf0e10cSrcweir sal_Bool IsHiddenView() {return bIsHidden;} 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir const SwWrtShell* GetActiveWrtShell() {return pActiveShell;} 191*cdf0e10cSrcweir SwWrtShell* GetHiddenWrtShell() {return pHiddenShell;} 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir DECL_LINK( ContentDoubleClickHdl, SwContentTree * ); 194*cdf0e10cSrcweir // DECL_LINK( PopupHdl, Menu* ); 195*cdf0e10cSrcweir DECL_LINK( TimerUpdate, Timer * ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* ); 198*cdf0e10cSrcweir virtual void RequestingChilds( SvLBoxEntry* pParent ); 199*cdf0e10cSrcweir virtual void GetFocus(); 200*cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rKEvt); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True ); 203*cdf0e10cSrcweir }; 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir //---------------------------------------------------------------------------- 207*cdf0e10cSrcweir // TreeListBox fuer Globaldokumente 208*cdf0e10cSrcweir //---------------------------------------------------------------------------- 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir class SwLBoxString : public SvLBoxString 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir public: 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir SwLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, 215*cdf0e10cSrcweir const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 220*cdf0e10cSrcweir SvLBoxEntry* pEntry); 221*cdf0e10cSrcweir }; 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir namespace sfx2 { class DocumentInserter; } 224*cdf0e10cSrcweir namespace sfx2 { class FileDialogHelper; } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir class SwGlobalTree : public SvTreeListBox 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir private: 229*cdf0e10cSrcweir AutoTimer aUpdateTimer; 230*cdf0e10cSrcweir String aContextStrings[GLOBAL_CONTEXT_COUNT]; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir ImageList aEntryImages; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir SwWrtShell* pActiveShell; // 235*cdf0e10cSrcweir SvLBoxEntry* pEmphasisEntry; // Drag'n Drop-Emphasis 236*cdf0e10cSrcweir SvLBoxEntry* pDDSource; // Quelle beim DnD 237*cdf0e10cSrcweir SwGlblDocContents* pSwGlblDocContents; // Array mit sortierten Inhalten 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir Window* pDefParentWin; 240*cdf0e10cSrcweir SwGlblDocContent* pDocContent; 241*cdf0e10cSrcweir sfx2::DocumentInserter* pDocInserter; 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir sal_Bool bIsInternalDrag :1; 244*cdf0e10cSrcweir sal_Bool bLastEntryEmphasis :1; // Drag'n Drop 245*cdf0e10cSrcweir sal_Bool bIsImageListInitialized : 1; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir static const SfxObjectShell* pShowShell; 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir void InsertRegion( const SwGlblDocContent* _pContent, 250*cdf0e10cSrcweir const com::sun::star::uno::Sequence< ::rtl::OUString >& _rFiles ); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir using SvLBox::DoubleClickHdl; 255*cdf0e10cSrcweir using SvLBox::ExecuteDrop; 256*cdf0e10cSrcweir using Window::Update; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir protected: 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir virtual long GetTabPos( SvLBoxEntry*, SvLBoxTab* ); 269*cdf0e10cSrcweir virtual sal_Bool NotifyMoving( SvLBoxEntry* pTarget, 270*cdf0e10cSrcweir SvLBoxEntry* pEntry, 271*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 272*cdf0e10cSrcweir sal_uLong& rNewChildPos 273*cdf0e10cSrcweir ); 274*cdf0e10cSrcweir virtual sal_Bool NotifyCopying( SvLBoxEntry* pTarget, 275*cdf0e10cSrcweir SvLBoxEntry* pEntry, 276*cdf0e10cSrcweir SvLBoxEntry*& rpNewParent, 277*cdf0e10cSrcweir sal_uLong& rNewChildPos 278*cdf0e10cSrcweir ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 281*cdf0e10cSrcweir virtual void DragFinished( sal_Int8 ); 282*cdf0e10cSrcweir virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData, 283*cdf0e10cSrcweir SvLBoxEntry* ); 284*cdf0e10cSrcweir virtual sal_Bool NotifyAcceptDrop( SvLBoxEntry* ); 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 287*cdf0e10cSrcweir virtual void KeyInput(const KeyEvent& rKEvt); 288*cdf0e10cSrcweir virtual void GetFocus(); 289*cdf0e10cSrcweir virtual void SelectHdl(); 290*cdf0e10cSrcweir virtual void DeselectHdl(); 291*cdf0e10cSrcweir virtual void InitEntry(SvLBoxEntry*,const XubString&,const Image&,const Image&,SvLBoxButtonKind); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir void Clear(); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir DECL_LINK( PopupHdl, Menu* ); 296*cdf0e10cSrcweir DECL_LINK( Timeout, Timer* ); 297*cdf0e10cSrcweir DECL_LINK( DoubleClickHdl, SwGlobalTree * ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir sal_Bool IsInternalDrag() const {return bIsInternalDrag != 0;} 300*cdf0e10cSrcweir SwNavigationPI* GetParentWindow() 301*cdf0e10cSrcweir { return (SwNavigationPI*)Window::GetParent(); } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir void OpenDoc(const SwGlblDocContent*); 304*cdf0e10cSrcweir void GotoContent(const SwGlblDocContent*); 305*cdf0e10cSrcweir sal_uInt16 GetEnableFlags() const; 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir static const SfxObjectShell* GetShowShell() {return pShowShell;} 308*cdf0e10cSrcweir static void SetShowShell(const SfxObjectShell*pSet) {pShowShell = pSet;} 309*cdf0e10cSrcweir DECL_STATIC_LINK(SwGlobalTree, ShowFrameHdl, SwGlobalTree*); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir virtual PopupMenu* CreateContextMenu( void ); 312*cdf0e10cSrcweir virtual void ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir public: 315*cdf0e10cSrcweir SwGlobalTree(Window* pParent, const ResId& rResId); 316*cdf0e10cSrcweir virtual ~SwGlobalTree(); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir void TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox); 319*cdf0e10cSrcweir void InsertRegion( const SwGlblDocContent* pCont, 320*cdf0e10cSrcweir const String* pFileName = 0 ); 321*cdf0e10cSrcweir void EditContent(const SwGlblDocContent* pCont ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir void ShowTree(); 324*cdf0e10cSrcweir void HideTree(); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir void ExecCommand(sal_uInt16 nCmd); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir void Display(sal_Bool bOnlyUpdateUserData = sal_False); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir sal_Bool Update(sal_Bool bHard); 331*cdf0e10cSrcweir }; 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir #endif 334*cdf0e10cSrcweir 335