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