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