1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX
23 #include <svtools/treelistbox.hxx>
25 #include "address.hxx"
26 #include <tools/solar.h>
27 #include <o3tl/enumarray.hxx>
35 enum class ScContentId
{
36 ROOT
, TABLE
, RANGENAME
, DBAREA
,
37 GRAPHIC
, OLEOBJECT
, NOTE
, AREALINK
,
38 DRAWING
, LAST
= DRAWING
41 const sal_uLong SC_CONTENT_NOCHILD
= ~0UL;
43 class ScContentTree
: public SvTreeListBox
45 VclPtr
<ScNavigatorDlg
> pParentWindow
;
46 ImageList aEntryImages
;
47 o3tl::enumarray
<ScContentId
, SvTreeListEntry
*> pRootNodes
;
48 ScContentId nRootType
; // set as Root
49 OUString aManualDoc
; // Switched in Navigator (Title)
50 bool bHiddenDoc
; // Hidden active?
51 OUString aHiddenName
; // URL to load
52 OUString aHiddenTitle
; // for display
53 ScDocument
* pHiddenDocument
; // temporary
54 bool bisInNavigatoeDlg
;
57 o3tl::enumarray
<ScContentId
, sal_uInt16
> pPosList
; // for the sequence
59 static bool bIsInDrag
; // static, if the Navigator is deleted in ExecuteDrag
61 ScDocShell
* GetManualOrCurrent();
63 void InitRoot(ScContentId nType
);
64 void ClearType(ScContentId nType
);
66 void InsertContent( ScContentId nType
, const OUString
& rValue
);
67 void GetDrawNames( ScContentId nType
);
73 void GetGraphicNames();
75 void GetDrawingNames();
76 void GetNoteStrings();
78 static bool IsPartOfType( ScContentId nContentType
, sal_uInt16 nObjIdentifier
);
80 bool DrawNamesChanged( ScContentId nType
);
81 bool NoteStringsChanged();
83 ScAddress
GetNotePos( sal_uLong nIndex
);
84 const ScAreaLink
* GetLink( sal_uLong nIndex
);
86 /** Returns the indexes of the specified listbox entry.
87 @param rnRootIndex Root index of specified entry is returned.
88 @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root).
89 @param pEntry The entry to examine. */
90 void GetEntryIndexes( ScContentId
& rnRootIndex
, sal_uLong
& rnChildIndex
, SvTreeListEntry
* pEntry
) const;
92 /** Returns the child index of the specified listbox entry.
93 @param pEntry The entry to examine or NULL for the selected entry.
94 @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */
95 sal_uLong
GetChildIndex( SvTreeListEntry
* pEntry
) const;
99 ScDocument
* GetSourceDocument();
101 DECL_LINK_TYPED( ContentDoubleClickHdl
, SvTreeListBox
*, bool );
102 DECL_LINK_TYPED( ExecDragHdl
, void*, void );
104 SvTreeListEntry
* pTmpEntry
;
109 using SvTreeListBox::ExecuteDrop
;
111 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
112 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
113 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
) override
;
114 virtual void DragFinished( sal_Int8 nAction
) override
;
116 virtual void Command( const CommandEvent
& rCEvt
) override
;
117 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
118 virtual void InitEntry(SvTreeListEntry
*,const OUString
&,const Image
&,const Image
&, SvLBoxButtonKind
) override
;
121 ScContentTree( vcl::Window
* pParent
, const ResId
& rResId
);
122 virtual ~ScContentTree();
123 virtual void dispose() override
;
125 OUString
getAltLongDescText(SvTreeListEntry
* pEntry
, bool isAltText
) const;
126 OUString
GetEntryAltText( SvTreeListEntry
* pEntry
) const override
;
127 OUString
GetEntryLongDescription( SvTreeListEntry
* pEntry
) const override
;
129 void ObjectFresh( ScContentId nType
, SvTreeListEntry
* pEntry
= nullptr);
130 void SetNavigatorDlgFlag(bool isInNavigateDlg
){ bisInNavigatoeDlg
=isInNavigateDlg
;};
131 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
132 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
134 void InitWindowBits( bool bButtons
);
136 void Refresh( ScContentId nType
= ScContentId::ROOT
);
139 void SetRootType( ScContentId nNew
);
140 ScContentId
GetRootType() const { return nRootType
; }
142 void ActiveDocChanged();
143 void ResetManualDoc();
144 void SetManualDoc(const OUString
& rName
);
145 bool LoadFile(const OUString
& rUrl
);
146 void SelectDoc(const OUString
& rName
);
148 const OUString
& GetHiddenTitle() const { return aHiddenTitle
; }
150 /** Applies the navigator settings to the listbox. */
151 void ApplyNavigatorSettings();
152 /** Stores the current listbox state in the navigator settings. */
153 void StoreNavigatorSettings() const;
156 #endif // INCLUDED_SC_SOURCE_UI_INC_CONTENT_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */