/src/libreoffice/sc/source/ui/view/reffact.cxx
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 | | #include <sfx2/basedlgs.hxx> |
21 | | #include <sfx2/bindings.hxx> |
22 | | #include <sfx2/dispatch.hxx> |
23 | | #include <sfx2/viewfrm.hxx> |
24 | | |
25 | | #include <reffact.hxx> |
26 | | #include <tabvwsh.hxx> |
27 | | #include <sc.hrc> |
28 | | #include <acredlin.hxx> |
29 | | #include <simpref.hxx> |
30 | | #include <scmod.hxx> |
31 | | #include <scres.hrc> |
32 | | #include <validate.hxx> |
33 | | |
34 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME) |
35 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME) |
36 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE) |
37 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER) |
38 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) |
39 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE) |
40 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP) |
41 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFilterDlgWrapper, SID_FILTER) |
42 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER) |
43 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME) |
44 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE) |
45 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA) |
46 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES) |
47 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION) |
48 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT) |
49 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW) |
50 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF) |
51 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF) |
52 | | SFX_IMPL_MODELESSDIALOGCONTOLLER_WITHID(ScTableLayoutWrapper, SID_INSERT_CALCTABLE) |
53 | | |
54 | | SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE) |
55 | | |
56 | | SfxChildWinInfo ScValidityRefChildWin::GetInfo() const |
57 | 0 | { |
58 | 0 | SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); |
59 | 0 | return aInfo; |
60 | 0 | } |
61 | | |
62 | | namespace |
63 | | { |
64 | | ScTabViewShell* lcl_GetTabViewShell(const SfxBindings& rBindings); |
65 | | } |
66 | | |
67 | | #define IMPL_CONTROLLER_CHILD_CTOR(Class, sid) \ |
68 | | Class::Class(vcl::Window* pParentP, sal_uInt16 nId, SfxBindings& rBindings, \ |
69 | | SfxChildWinInfo& rInfo) \ |
70 | 0 | : SfxChildWindow(pParentP, nId) \ |
71 | 0 | { \ |
72 | 0 | /************************************************************************************/ \ |
73 | 0 | /* When a new document is creating, the SfxViewFrame may be ready, */ \ |
74 | 0 | /* But the ScTabViewShell may have not been activated yet. In this */ \ |
75 | 0 | /* situation, SfxViewShell::Current() does not get the correct shell, */ \ |
76 | 0 | /* and we should lcl_GetTabViewShell(rBindings) instead of SfxViewShell::Current() */ \ |
77 | 0 | /************************************************************************************/ \ |
78 | 0 | ScTabViewShell* pViewShell = lcl_GetTabViewShell(rBindings); \ |
79 | 0 | if (!pViewShell) \ |
80 | 0 | pViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); \ |
81 | 0 | OSL_ENSURE(pViewShell, "missing view shell :-("); \ |
82 | 0 | SetController(pViewShell ? pViewShell->CreateRefDialogController( \ |
83 | 0 | rBindings, this, rInfo, pParentP->GetFrameWeld(), sid) \ |
84 | 0 | : nullptr); \ |
85 | 0 | if (pViewShell && !GetController()) \ |
86 | 0 | pViewShell->GetViewFrame().SetChildWindow(nId, false); \ |
87 | 0 | } Unexecuted instantiation: ScNameDlgWrapper::ScNameDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScNameDefDlgWrapper::ScNameDefDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScSolverDlgWrapper::ScSolverDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScOptSolverDlgWrapper::ScOptSolverDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScXMLSourceDlgWrapper::ScXMLSourceDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScPivotLayoutWrapper::ScPivotLayoutWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScTabOpDlgWrapper::ScTabOpDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScFilterDlgWrapper::ScFilterDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScSpecialFilterDlgWrapper::ScSpecialFilterDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScDbNameDlgWrapper::ScDbNameDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScColRowNameRangesDlgWrapper::ScColRowNameRangesDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScConsolidateDlgWrapper::ScConsolidateDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScPrintAreasDlgWrapper::ScPrintAreasDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScFormulaDlgWrapper::ScFormulaDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScTableLayoutWrapper::ScTableLayoutWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScHighlightChgDlgWrapper::ScHighlightChgDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) Unexecuted instantiation: ScCondFormatDlgWrapper::ScCondFormatDlgWrapper(vcl::Window*, unsigned short, SfxBindings&, SfxChildWinInfo&) |
88 | | |
89 | | IMPL_CONTROLLER_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME ) |
90 | | |
91 | | IMPL_CONTROLLER_CHILD_CTOR( ScNameDefDlgWrapper, FID_ADD_NAME ) |
92 | | |
93 | | IMPL_CONTROLLER_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE ) |
94 | | |
95 | | IMPL_CONTROLLER_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER ) |
96 | | |
97 | | IMPL_CONTROLLER_CHILD_CTOR( ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE) |
98 | | |
99 | | IMPL_CONTROLLER_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE ) |
100 | | |
101 | | IMPL_CONTROLLER_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP ) |
102 | | |
103 | | IMPL_CONTROLLER_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER ) |
104 | | |
105 | | IMPL_CONTROLLER_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER ) |
106 | | |
107 | | IMPL_CONTROLLER_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME ) |
108 | | |
109 | | IMPL_CONTROLLER_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES ) |
110 | | |
111 | | IMPL_CONTROLLER_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE ) |
112 | | |
113 | | IMPL_CONTROLLER_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA ) |
114 | | |
115 | | IMPL_CONTROLLER_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION ) |
116 | | |
117 | | IMPL_CONTROLLER_CHILD_CTOR( ScTableLayoutWrapper, SID_INSERT_CALCTABLE ) |
118 | | |
119 | | // ScSimpleRefDlgWrapper |
120 | | |
121 | | static bool bScSimpleRefFlag; |
122 | | static tools::Long nScSimpleRefHeight; |
123 | | static tools::Long nScSimpleRefWidth; |
124 | | static tools::Long nScSimpleRefX; |
125 | | static tools::Long nScSimpleRefY; |
126 | | static bool bAutoReOpen = true; |
127 | | |
128 | | ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper(vcl::Window* pParentP, sal_uInt16 nId, |
129 | | SfxBindings& rBindings, SfxChildWinInfo& rInfo) |
130 | 0 | : SfxChildWindow(pParentP, nId) |
131 | 0 | { |
132 | |
|
133 | 0 | ScTabViewShell* pViewShell = nullptr; |
134 | 0 | SfxDispatcher* pDisp = rBindings.GetDispatcher(); |
135 | 0 | if ( pDisp ) |
136 | 0 | { |
137 | 0 | SfxViewFrame* pViewFrm = pDisp->GetFrame(); |
138 | 0 | if ( pViewFrm ) |
139 | 0 | pViewShell = dynamic_cast<ScTabViewShell*>( pViewFrm->GetViewShell() ); |
140 | 0 | } |
141 | |
|
142 | 0 | OSL_ENSURE( pViewShell, "missing view shell :-(" ); |
143 | |
|
144 | 0 | if (bScSimpleRefFlag) |
145 | 0 | { |
146 | 0 | rInfo.aPos.setX(nScSimpleRefX); |
147 | 0 | rInfo.aPos.setY(nScSimpleRefY); |
148 | 0 | rInfo.aSize.setHeight(nScSimpleRefHeight); |
149 | 0 | rInfo.aSize.setWidth(nScSimpleRefWidth); |
150 | 0 | } |
151 | 0 | SetController(nullptr); |
152 | |
|
153 | 0 | if (bAutoReOpen && pViewShell) |
154 | 0 | SetController(pViewShell->CreateRefDialogController( |
155 | 0 | rBindings, this, rInfo, pParentP->GetFrameWeld(), WID_SIMPLE_REF)); |
156 | |
|
157 | 0 | if (!GetController()) |
158 | 0 | { |
159 | 0 | ScModule::get()->SetRefDialog(nId, false); |
160 | 0 | } |
161 | 0 | } |
162 | | |
163 | | void ScSimpleRefDlgWrapper::SetAutoReOpen(bool bFlag) |
164 | 0 | { |
165 | 0 | bAutoReOpen=bFlag; |
166 | 0 | } |
167 | | |
168 | | void ScSimpleRefDlgWrapper::SetRefString(const OUString& rStr) |
169 | 0 | { |
170 | 0 | auto xDlgController = GetController(); |
171 | 0 | if (xDlgController) |
172 | 0 | { |
173 | 0 | static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetRefString(rStr); |
174 | 0 | } |
175 | 0 | } |
176 | | |
177 | | void ScSimpleRefDlgWrapper::SetCloseHdl( const Link<const OUString*,void>& rLink ) |
178 | 0 | { |
179 | 0 | auto xDlgController = GetController(); |
180 | 0 | if (xDlgController) |
181 | 0 | { |
182 | 0 | static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetCloseHdl(rLink); |
183 | 0 | } |
184 | 0 | } |
185 | | |
186 | | void ScSimpleRefDlgWrapper::SetUnoLinks( const Link<const OUString&,void>& rDone, |
187 | | const Link<const OUString&,void>& rAbort, const Link<const OUString&,void>& rChange ) |
188 | 0 | { |
189 | 0 | auto xDlgController = GetController(); |
190 | 0 | if (xDlgController) |
191 | 0 | { |
192 | 0 | static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetUnoLinks( rDone, rAbort, rChange ); |
193 | 0 | } |
194 | 0 | } |
195 | | |
196 | | void ScSimpleRefDlgWrapper::SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection ) |
197 | 0 | { |
198 | 0 | auto xDlgController = GetController(); |
199 | 0 | if (xDlgController) |
200 | 0 | { |
201 | 0 | static_cast<ScSimpleRefDlg*>(xDlgController.get())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection ); |
202 | 0 | } |
203 | 0 | } |
204 | | |
205 | | void ScSimpleRefDlgWrapper::StartRefInput() |
206 | 0 | { |
207 | 0 | auto xDlgController = GetController(); |
208 | 0 | if (xDlgController) |
209 | 0 | { |
210 | 0 | static_cast<ScSimpleRefDlg*>(xDlgController.get())->StartRefInput(); |
211 | 0 | } |
212 | 0 | } |
213 | | |
214 | | // ScAcceptChgDlgWrapper //FIXME: should be moved into ViewShell |
215 | | |
216 | | ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper(vcl::Window* pParentP, sal_uInt16 nId, |
217 | | SfxBindings& rBindings, SfxChildWinInfo& rInfo) |
218 | 0 | : SfxChildWindow(pParentP, nId) |
219 | 0 | { |
220 | 0 | ScTabViewShell* pViewShell = |
221 | 0 | dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
222 | 0 | OSL_ENSURE( pViewShell, "missing view shell :-(" ); |
223 | 0 | if (pViewShell) |
224 | 0 | { |
225 | 0 | auto xDlg = std::make_shared<ScAcceptChgDlg>(&rBindings, this, pParentP->GetFrameWeld(), |
226 | 0 | pViewShell->GetViewData()); |
227 | 0 | SetController(xDlg); |
228 | 0 | rInfo.nFlags = SfxChildWindowFlags::NEVERHIDE; |
229 | 0 | xDlg->Initialize(rInfo); |
230 | 0 | } |
231 | 0 | else |
232 | 0 | SetController( nullptr ); |
233 | 0 | if (pViewShell && !GetController()) |
234 | 0 | pViewShell->GetViewFrame().SetChildWindow( nId, false ); |
235 | 0 | } |
236 | | |
237 | | void ScAcceptChgDlgWrapper::ReInitDlg() |
238 | 0 | { |
239 | 0 | ScTabViewShell* pViewShell = |
240 | 0 | dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
241 | 0 | OSL_ENSURE( pViewShell, "missing view shell :-(" ); |
242 | |
|
243 | 0 | if (GetController() && pViewShell) |
244 | 0 | { |
245 | 0 | static_cast<ScAcceptChgDlg*>(GetController().get())->ReInit(pViewShell->GetViewData()); |
246 | 0 | } |
247 | 0 | } |
248 | | |
249 | | // ScHighlightChgDlgWrapper |
250 | | |
251 | | IMPL_CONTROLLER_CHILD_CTOR(ScHighlightChgDlgWrapper, FID_CHG_SHOW) |
252 | | |
253 | | namespace |
254 | | { |
255 | | ScTabViewShell* lcl_GetTabViewShell(const SfxBindings& rBindings) |
256 | 0 | { |
257 | 0 | if (SfxDispatcher* pDisp = rBindings.GetDispatcher()) |
258 | 0 | if (SfxViewFrame* pFrm = pDisp->GetFrame()) |
259 | 0 | if (SfxViewShell* pViewSh = pFrm->GetViewShell()) |
260 | 0 | return dynamic_cast<ScTabViewShell*>(pViewSh); |
261 | | |
262 | 0 | return nullptr; |
263 | 0 | } |
264 | | } |
265 | | |
266 | | ScValidityRefChildWin::ScValidityRefChildWin(vcl::Window* pParentP, sal_uInt16 nId, |
267 | | const SfxBindings& rBindings, |
268 | | SAL_UNUSED_PARAMETER SfxChildWinInfo& /*rInfo*/) |
269 | 0 | : SfxChildWindow(pParentP, nId) |
270 | 0 | , m_bVisibleLock(false) |
271 | 0 | , m_bFreeWindowLock(false) |
272 | 0 | { |
273 | 0 | SetWantsFocus( false ); |
274 | 0 | std::shared_ptr<SfxDialogController> xDlg(ScValidationDlg::Find1AliveObject(pParentP->GetFrameWeld())); |
275 | 0 | SetController(xDlg); |
276 | 0 | ScTabViewShell* pViewShell; |
277 | 0 | if (xDlg) |
278 | 0 | pViewShell = static_cast<ScValidationDlg*>(xDlg.get())->GetTabViewShell(); |
279 | 0 | else |
280 | 0 | pViewShell = lcl_GetTabViewShell(rBindings); |
281 | 0 | if (!pViewShell) |
282 | 0 | pViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); |
283 | 0 | OSL_ENSURE( pViewShell, "missing view shell :-(" ); |
284 | 0 | if (pViewShell && !xDlg) |
285 | 0 | pViewShell->GetViewFrame().SetChildWindow( nId, false ); |
286 | 0 | } |
287 | | |
288 | | ScValidityRefChildWin::~ScValidityRefChildWin() |
289 | 0 | { |
290 | 0 | if (m_bFreeWindowLock) |
291 | 0 | SetController(nullptr); |
292 | 0 | } |
293 | | |
294 | | IMPL_CONTROLLER_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF ) |
295 | | |
296 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |