Line data Source code
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/app.hxx>
21 : #include <sfx2/basedlgs.hxx>
22 : #include <sfx2/bindings.hxx>
23 : #include <sfx2/dispatch.hxx>
24 : #include <sfx2/viewfrm.hxx>
25 :
26 : #include "reffact.hxx"
27 : #include "tabvwsh.hxx"
28 : #include "sc.hrc"
29 : #include "acredlin.hxx"
30 : #include "simpref.hxx"
31 : #include "scmod.hxx"
32 : #include "validate.hxx"
33 :
34 : // -----------------------------------------------------------------------
35 :
36 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME )
37 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME )
38 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
39 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
40 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
41 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
42 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
43 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScFilterDlgWrapper, SID_FILTER )
44 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
45 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
46 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
47 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
48 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
49 15 : SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
50 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT )
51 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
52 10 : SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
53 10 : SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
54 :
55 0 : SfxChildWinInfo ScValidityRefChildWin::GetInfo() const
56 : {
57 0 : SfxChildWinInfo anInfo = SfxChildWindow::GetInfo();
58 :
59 0 : if( Window *pWnd = GetWindow() )
60 : {
61 0 : anInfo.aSize = pWnd->GetSizePixel();
62 :
63 0 : if( pWnd->IsDialog() )
64 0 : if ( static_cast<Dialog*>(pWnd)->IsRollUp() )
65 0 : anInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
66 : }
67 :
68 0 : return anInfo;
69 : }
70 :
71 : namespace { ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings ); }
72 :
73 : #define IMPL_CHILD_CTOR(Class,sid) \
74 : Class::Class( Window* pParentP, \
75 : sal_uInt16 nId, \
76 : SfxBindings* p, \
77 : SfxChildWinInfo* pInfo ) \
78 : : SfxChildWindow(pParentP, nId) \
79 : { \
80 : /************************************************************************************/\
81 : /* When a new document is creating, the SfxViewFrame may be ready, */\
82 : /* But the ScTabViewShell may have not been activated yet. In this */\
83 : /* situation, SfxViewShell::Current() does not get the correct shell, */\
84 : /* and we should lcl_GetTabViewShell( p ) instead of SfxViewShell::Current() */\
85 : /************************************************************************************/\
86 : ScTabViewShell* pViewShell = lcl_GetTabViewShell( p ); \
87 : if (!pViewShell) \
88 : pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \
89 : OSL_ENSURE( pViewShell, "missing view shell :-(" ); \
90 : pWindow = pViewShell ? \
91 : pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : NULL; \
92 : if (pViewShell && !pWindow) \
93 : pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \
94 : }
95 :
96 :
97 : //=========================================================================
98 :
99 : //-------------------------------------------------------------------------
100 : // ScNameDlgWrapper
101 : //-------------------------------------------------------------------------
102 :
103 0 : IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME )
104 : //
105 : //-------------------------------------------------------------------------
106 : // ScNameDlgWrapper
107 : //-------------------------------------------------------------------------
108 :
109 0 : IMPL_CHILD_CTOR( ScNameDefDlgWrapper, FID_ADD_NAME )
110 :
111 : //-------------------------------------------------------------------------
112 : // ScSolverDlgWrapper
113 : //-------------------------------------------------------------------------
114 :
115 0 : IMPL_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
116 :
117 : //-------------------------------------------------------------------------
118 : // ScOptSolverDlgWrapper
119 : //-------------------------------------------------------------------------
120 :
121 0 : IMPL_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
122 :
123 0 : IMPL_CHILD_CTOR(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
124 :
125 : //-------------------------------------------------------------------------
126 : // ScPivotLayoutWrapper
127 : //-------------------------------------------------------------------------
128 :
129 0 : IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
130 :
131 : //-------------------------------------------------------------------------
132 : // ScTabOpDlgWrapper
133 : //-------------------------------------------------------------------------
134 :
135 0 : IMPL_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
136 :
137 : //-------------------------------------------------------------------------
138 : // ScFilterDlgWrapper
139 : //-------------------------------------------------------------------------
140 :
141 0 : IMPL_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER )
142 :
143 : //-------------------------------------------------------------------------
144 : // ScSpecialFilterDlgWrapper
145 : //-------------------------------------------------------------------------
146 :
147 0 : IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
148 :
149 : //-------------------------------------------------------------------------
150 : // ScDbNameDlgWrapper
151 : //-------------------------------------------------------------------------
152 :
153 0 : IMPL_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
154 :
155 : //-------------------------------------------------------------------------
156 : // ScColRowNameRangesDlgWrapper
157 : //-------------------------------------------------------------------------
158 :
159 0 : IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
160 :
161 : //-------------------------------------------------------------------------
162 : // ScConsolidateDlgWrapper
163 : //-------------------------------------------------------------------------
164 :
165 0 : IMPL_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
166 :
167 : //-------------------------------------------------------------------------
168 : // ScPrintAreasDlgWrapper
169 : //-------------------------------------------------------------------------
170 :
171 0 : IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
172 :
173 : //-------------------------------------------------------------------------
174 : // ScFormulaDlgWrapper
175 : //-------------------------------------------------------------------------
176 :
177 0 : IMPL_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
178 :
179 :
180 : //-------------------------------------------------------------------------
181 : // ScSimpleRefDlgWrapper
182 : //-------------------------------------------------------------------------
183 :
184 : static sal_Bool bScSimpleRefFlag;
185 : static long nScSimpleRefHeight;
186 : static long nScSimpleRefWidth;
187 : static long nScSimpleRefX;
188 : static long nScSimpleRefY;
189 : static sal_Bool bAutoReOpen=sal_True;
190 :
191 0 : ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( Window* pParentP,
192 : sal_uInt16 nId,
193 : SfxBindings* p,
194 : SfxChildWinInfo* pInfo )
195 0 : : SfxChildWindow(pParentP, nId)
196 : {
197 :
198 0 : ScTabViewShell* pViewShell = NULL;
199 0 : SfxDispatcher* pDisp = p->GetDispatcher();
200 0 : if ( pDisp )
201 : {
202 0 : SfxViewFrame* pViewFrm = pDisp->GetFrame();
203 0 : if ( pViewFrm )
204 0 : pViewShell = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
205 : }
206 :
207 : OSL_ENSURE( pViewShell, "missing view shell :-(" );
208 :
209 0 : if(pInfo!=NULL && bScSimpleRefFlag)
210 : {
211 0 : pInfo->aPos.X()=nScSimpleRefX;
212 0 : pInfo->aPos.Y()=nScSimpleRefY;
213 0 : pInfo->aSize.Height()=nScSimpleRefHeight;
214 0 : pInfo->aSize.Width()=nScSimpleRefWidth;
215 : }
216 0 : pWindow = NULL;
217 :
218 0 : if(bAutoReOpen && pViewShell)
219 0 : pWindow = pViewShell->CreateRefDialog( p, this, pInfo, pParentP, WID_SIMPLE_REF);
220 :
221 0 : if (!pWindow)
222 : {
223 0 : SC_MOD()->SetRefDialog( nId, false );
224 : }
225 0 : }
226 :
227 0 : void ScSimpleRefDlgWrapper::SetDefaultPosSize(Point aPos, Size aSize, sal_Bool bSet)
228 : {
229 0 : bScSimpleRefFlag=bSet;
230 0 : if(bScSimpleRefFlag)
231 : {
232 0 : nScSimpleRefX=aPos.X();
233 0 : nScSimpleRefY=aPos.Y();
234 0 : nScSimpleRefHeight=aSize.Height();
235 0 : nScSimpleRefWidth=aSize.Width();
236 : }
237 0 : }
238 :
239 :
240 0 : String ScSimpleRefDlgWrapper::GetRefString()
241 : {
242 0 : String aResult;
243 0 : if(pWindow!=NULL)
244 : {
245 0 : aResult=((ScSimpleRefDlg*)pWindow)->GetRefString();
246 : }
247 0 : return aResult;
248 : }
249 :
250 0 : void ScSimpleRefDlgWrapper::SetAutoReOpen(sal_Bool bFlag)
251 : {
252 0 : bAutoReOpen=bFlag;
253 0 : }
254 :
255 0 : void ScSimpleRefDlgWrapper::SetRefString(const String& rStr)
256 : {
257 0 : if(pWindow!=NULL)
258 : {
259 0 : ((ScSimpleRefDlg*)pWindow)->SetRefString(rStr);
260 : }
261 0 : }
262 :
263 0 : void ScSimpleRefDlgWrapper::SetCloseHdl( const Link& rLink )
264 : {
265 0 : if(pWindow!=NULL)
266 : {
267 0 : ((ScSimpleRefDlg*)pWindow)->SetCloseHdl( rLink );
268 : }
269 0 : }
270 :
271 0 : void ScSimpleRefDlgWrapper::SetUnoLinks( const Link& rDone,
272 : const Link& rAbort, const Link& rChange )
273 : {
274 0 : if(pWindow!=NULL)
275 : {
276 0 : ((ScSimpleRefDlg*)pWindow)->SetUnoLinks( rDone, rAbort, rChange );
277 : }
278 0 : }
279 :
280 0 : void ScSimpleRefDlgWrapper::SetFlags( sal_Bool bCloseOnButtonUp, sal_Bool bSingleCell, sal_Bool bMultiSelection )
281 : {
282 0 : if(pWindow!=NULL)
283 : {
284 0 : ((ScSimpleRefDlg*)pWindow)->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
285 : }
286 0 : }
287 :
288 0 : void ScSimpleRefDlgWrapper::StartRefInput()
289 : {
290 0 : if(pWindow!=NULL)
291 : {
292 0 : ((ScSimpleRefDlg*)pWindow)->StartRefInput();
293 : }
294 0 : }
295 :
296 :
297 :
298 : //-------------------------------------------------------------------------
299 : // ScAcceptChgDlgWrapper //Kommentar: sollte in die ViewShell
300 : //-------------------------------------------------------------------------
301 :
302 0 : ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( Window* pParentP,
303 : sal_uInt16 nId,
304 : SfxBindings* pBindings,
305 : SfxChildWinInfo* pInfo ) :
306 0 : SfxChildWindow( pParentP, nId )
307 : {
308 : ScTabViewShell* pViewShell =
309 0 : PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
310 : OSL_ENSURE( pViewShell, "missing view shell :-(" );
311 : pWindow = pViewShell ?
312 0 : new ScAcceptChgDlg( pBindings, this, pParentP, pViewShell->GetViewData() ) :
313 0 : NULL;
314 0 : if(pWindow!=NULL)
315 : {
316 0 : ((ScAcceptChgDlg*)pWindow)->Initialize( pInfo );
317 : }
318 0 : if (pViewShell && !pWindow)
319 0 : pViewShell->GetViewFrame()->SetChildWindow( nId, false );
320 0 : }
321 :
322 0 : void ScAcceptChgDlgWrapper::ReInitDlg()
323 : {
324 : ScTabViewShell* pViewShell =
325 0 : PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
326 : OSL_ENSURE( pViewShell, "missing view shell :-(" );
327 :
328 0 : if(pWindow!=NULL && pViewShell)
329 : {
330 0 : ((ScAcceptChgDlg*)pWindow)->ReInit(pViewShell->GetViewData());
331 : }
332 0 : }
333 :
334 : //-------------------------------------------------------------------------
335 : // ScHighlightChgDlgWrapper
336 : //-------------------------------------------------------------------------
337 :
338 0 : IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper, FID_CHG_SHOW )
339 :
340 :
341 : namespace
342 : {
343 0 : ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings )
344 : {
345 0 : if( pBindings )
346 0 : if( SfxDispatcher* pDisp = pBindings ->GetDispatcher() )
347 0 : if( SfxViewFrame *pFrm = pDisp->GetFrame() )
348 0 : if( SfxViewShell* pViewSh = pFrm->GetViewShell() )
349 0 : return dynamic_cast<ScTabViewShell*>( pViewSh );
350 :
351 0 : return NULL;
352 : }
353 : }
354 :
355 0 : ScValidityRefChildWin::ScValidityRefChildWin( Window* pParentP, \
356 : sal_uInt16 nId, \
357 : SfxBindings* p, \
358 : SfxChildWinInfo* /*pInfo*/ ) \
359 : : SfxChildWindow(pParentP, nId),
360 : m_bVisibleLock( false ),
361 : m_bFreeWindowLock( false ),
362 0 : m_pSavedWndParent( NULL )
363 : {
364 0 : SetWantsFocus( false );\
365 : ScTabViewShell* pViewShell = \
366 0 : NULL != ( pWindow = ScValidationDlg::Find1AliveObject( pParentP ) ) ? static_cast<ScValidationDlg*>(pWindow)->GetTabViewShell() :
367 0 : lcl_GetTabViewShell( p );
368 0 : if (!pViewShell)
369 0 : pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
370 : OSL_ENSURE( pViewShell, "missing view shell :-(" ); \
371 0 : if (pViewShell && !pWindow) \
372 0 : pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \
373 :
374 0 : if( pWindow ) m_pSavedWndParent = pWindow->GetParent();
375 0 : }
376 :
377 0 : ScValidityRefChildWin::~ScValidityRefChildWin()
378 : {
379 0 : if( pWindow ) pWindow->SetParent( m_pSavedWndParent );
380 :
381 0 : if( m_bFreeWindowLock )
382 0 : pWindow = NULL;
383 15 : }
384 :
385 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|