/src/libreoffice/sc/source/ui/inc/content.hxx
Line | Count | Source |
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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <vcl/weld/TreeView.hxx> |
23 | | #include <vcl/weld/weld.hxx> |
24 | | #include <address.hxx> |
25 | | #include <rtl/ref.hxx> |
26 | | #include <tools/solar.h> |
27 | | #include <o3tl/enumarray.hxx> |
28 | | |
29 | | class ScAreaLink; |
30 | | class ScLinkTransferObj; |
31 | | class ScDocument; |
32 | | class ScDocShell; |
33 | | class ScNavigatorDlg; |
34 | | struct ImplSVEvent; |
35 | | enum class SdrObjKind : sal_uInt16; |
36 | | |
37 | | enum class ScContentId { |
38 | | ROOT, TABLE, RANGENAME, DBAREA, |
39 | | GRAPHIC, OLEOBJECT, NOTE, AREALINK, |
40 | | DRAWING, LAST = DRAWING |
41 | | }; |
42 | | |
43 | | const sal_uLong SC_CONTENT_NOCHILD = ~0UL; |
44 | | |
45 | | class ScContentTree |
46 | | { |
47 | | std::unique_ptr<weld::TreeView> m_xTreeView; |
48 | | std::unique_ptr<weld::TreeIter> m_xScratchIter; |
49 | | rtl::Reference<ScLinkTransferObj> m_xTransferObj; |
50 | | ScNavigatorDlg* pParentWindow; |
51 | | o3tl::enumarray<ScContentId, std::unique_ptr<weld::TreeIter>> m_aRootNodes; |
52 | | ScContentId nRootType; // set as Root |
53 | | OUString aManualDoc; // Switched in Navigator (Title) |
54 | | bool bIsInNavigatorDlg; |
55 | | bool m_bFreeze; |
56 | | ImplSVEvent* m_nAsyncMouseReleaseId; |
57 | | |
58 | | o3tl::enumarray<ScContentId, sal_uInt16> pPosList; // for the sequence |
59 | | |
60 | | std::unique_ptr<std::locale> m_pResLocaleForLOK; //it needed only in case of LOK |
61 | | |
62 | | ScDocShell* GetManualOrCurrent(); |
63 | | |
64 | | void InitRoot(ScContentId nType); |
65 | | void ClearType(ScContentId nType); |
66 | | void ClearAll(); |
67 | | void InsertContent( ScContentId nType, const OUString& rValue ); |
68 | | void GetDrawNames( ScContentId nType ); |
69 | | |
70 | | void GetTableNames(); |
71 | | void GetAreaNames(); |
72 | | void GetDbNames(); |
73 | | void GetLinkNames(); |
74 | | void GetGraphicNames(); |
75 | | void GetOleNames(); |
76 | | void GetDrawingNames(); |
77 | | void GetNoteStrings(); |
78 | | |
79 | | static bool IsPartOfType( ScContentId nContentType, SdrObjKind nObjIdentifier ); |
80 | | |
81 | | bool DrawNamesChanged( ScContentId nType ); |
82 | | bool NoteStringsChanged(); |
83 | | |
84 | | ScAddress GetNotePos( sal_uLong nIndex ); |
85 | | const ScAreaLink* GetLink( sal_uLong nIndex ); |
86 | | |
87 | | /** Returns the indexes of the specified listbox entry. |
88 | | @param rnRootIndex Root index of specified entry is returned. |
89 | | @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root). |
90 | | @param pEntry The entry to examine. */ |
91 | | void GetEntryIndexes(ScContentId& rnRootIndex, sal_uLong& rnChildIndex, const weld::TreeIter* pEntry) const; |
92 | | |
93 | | /** Returns the child index of the specified listbox entry. |
94 | | @param pEntry The entry to examine or NULL for the selected entry. |
95 | | @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */ |
96 | | sal_uLong GetChildIndex(const weld::TreeIter* pEntry) const; |
97 | | |
98 | | ScDocument* GetSourceDocument(); |
99 | | |
100 | | void freeze() |
101 | 0 | { |
102 | 0 | m_xTreeView->freeze(); |
103 | 0 | m_bFreeze = true; |
104 | 0 | } |
105 | | |
106 | | void thaw() |
107 | 0 | { |
108 | 0 | m_xTreeView->thaw(); |
109 | 0 | m_bFreeze = false; |
110 | 0 | } |
111 | | |
112 | | void LaunchAsyncStoreNavigatorSettings(); |
113 | | void ActivateSelectedEntry(); |
114 | | |
115 | | DECL_LINK(ContentDoubleClickHdl, const weld::TreeIter&, bool); |
116 | | DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool); |
117 | | DECL_LINK(KeyInputHdl, const KeyEvent&, bool); |
118 | | DECL_LINK(AsyncStoreNavigatorSettings, void*, void); |
119 | | DECL_LINK(CommandHdl, const CommandEvent&, bool); |
120 | | DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); |
121 | | DECL_LINK(DragBeginHdl, bool&, bool); |
122 | | |
123 | | public: |
124 | | ScContentTree(std::unique_ptr<weld::TreeView> xTreeView, ScNavigatorDlg* pNavigatorDlg); |
125 | | ~ScContentTree(); |
126 | | |
127 | 0 | void SetNavigatorDlgFlag(bool isInNavigateDlg){ bIsInNavigatorDlg=isInNavigateDlg;}; |
128 | | |
129 | | void hide() |
130 | 0 | { |
131 | 0 | m_xTreeView->hide(); |
132 | 0 | } |
133 | | |
134 | | void show() |
135 | 0 | { |
136 | 0 | m_xTreeView->show(); |
137 | 0 | } |
138 | | |
139 | | void Refresh( ScContentId nType = ScContentId::ROOT ); |
140 | | |
141 | | void ToggleRoot(); |
142 | | void SetRootType( ScContentId nNew ); |
143 | 0 | ScContentId GetRootType() const { return nRootType; } |
144 | | |
145 | | // return true if Refresh was called to allow detecting that the navigator |
146 | | // tree is now up to date |
147 | | bool ActiveDocChanged(); |
148 | | void ResetManualDoc(); |
149 | | void SetManualDoc(const OUString& rName); |
150 | | void SelectDoc(const OUString& rName); |
151 | | void SelectEntryByName(const ScContentId nRoot, std::u16string_view rName); |
152 | | void BringCommentToAttention(sal_uInt16 nCommentId); |
153 | | |
154 | | /** Applies the navigator settings to the listbox. */ |
155 | | void ApplyNavigatorSettings(); |
156 | | /** Stores the current listbox state in the navigator settings. */ |
157 | | void StoreNavigatorSettings(); |
158 | | }; |
159 | | |
160 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |