1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
26 #include "reffact.hxx"
27 #include "tabvwsh.hxx"
29 #include "acredlin.hxx"
30 #include "simpref.hxx"
32 #include "validate.hxx"
34 // -----------------------------------------------------------------------
36 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDlgWrapper
, FID_DEFINE_NAME
)
37 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDefDlgWrapper
, FID_ADD_NAME
)
38 SFX_IMPL_MODELESSDIALOG_WITHID(ScSolverDlgWrapper
, SID_OPENDLG_SOLVE
)
39 SFX_IMPL_MODELESSDIALOG_WITHID(ScOptSolverDlgWrapper
, SID_OPENDLG_OPTSOLVER
)
40 SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper
, SID_MANAGE_XML_SOURCE
)
41 SFX_IMPL_MODELESSDIALOG_WITHID(ScPivotLayoutWrapper
, SID_OPENDLG_PIVOTTABLE
)
42 SFX_IMPL_MODELESSDIALOG_WITHID(ScTabOpDlgWrapper
, SID_OPENDLG_TABOP
)
43 SFX_IMPL_MODELESSDIALOG_WITHID(ScFilterDlgWrapper
, SID_FILTER
)
44 SFX_IMPL_MODELESSDIALOG_WITHID(ScSpecialFilterDlgWrapper
, SID_SPECIAL_FILTER
)
45 SFX_IMPL_MODELESSDIALOG_WITHID(ScDbNameDlgWrapper
, SID_DEFINE_DBNAME
)
46 SFX_IMPL_MODELESSDIALOG_WITHID(ScConsolidateDlgWrapper
, SID_OPENDLG_CONSOLIDATE
)
47 SFX_IMPL_MODELESSDIALOG_WITHID(ScPrintAreasDlgWrapper
, SID_OPENDLG_EDIT_PRINTAREA
)
48 SFX_IMPL_MODELESSDIALOG_WITHID(ScColRowNameRangesDlgWrapper
, SID_DEFINE_COLROWNAMERANGES
)
49 SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper
, SID_OPENDLG_FUNCTION
)
50 SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper
, FID_CHG_ACCEPT
)
51 SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper
, FID_CHG_SHOW
)
52 SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper
, WID_SIMPLE_REF
)
54 SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin
, SID_VALIDITY_REFERENCE
)
56 SfxChildWinInfo
ScValidityRefChildWin::GetInfo() const
58 SfxChildWinInfo anInfo
= SfxChildWindow::GetInfo();
60 if( Window
*pWnd
= GetWindow() )
62 anInfo
.aSize
= pWnd
->GetSizePixel();
64 if( pWnd
->IsDialog() )
65 if ( static_cast<Dialog
*>(pWnd
)->IsRollUp() )
66 anInfo
.nFlags
|= SFX_CHILDWIN_ZOOMIN
;
74 ScTabViewShell
* lcl_GetTabViewShell( SfxBindings
* pBindings
);
77 #define IMPL_CHILD_CTOR(Class,sid) \
78 Class::Class( Window* pParentP, \
81 SfxChildWinInfo* pInfo ) \
82 : SfxChildWindow(pParentP, nId) \
84 /************************************************************************************/\
85 /* When a new document is creating, the SfxViewFrame may be ready, */\
86 /* But the ScTabViewShell may have not been activated yet. In this */\
87 /* situation, SfxViewShell::Current() does not get the correct shell, */\
88 /* and we should lcl_GetTabViewShell( p ) instead of SfxViewShell::Current() */\
89 /************************************************************************************/\
90 ScTabViewShell* pViewShell = lcl_GetTabViewShell( p ); \
92 pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \
93 OSL_ENSURE( pViewShell, "missing view shell :-(" ); \
94 pWindow = pViewShell ? \
95 pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : NULL; \
96 if (pViewShell && !pWindow) \
97 pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \
100 IMPL_CHILD_CTOR( ScNameDlgWrapper
, FID_DEFINE_NAME
)
102 IMPL_CHILD_CTOR( ScNameDefDlgWrapper
, FID_ADD_NAME
)
104 IMPL_CHILD_CTOR( ScSolverDlgWrapper
, SID_OPENDLG_SOLVE
)
106 IMPL_CHILD_CTOR( ScOptSolverDlgWrapper
, SID_OPENDLG_OPTSOLVER
)
108 IMPL_CHILD_CTOR( ScXMLSourceDlgWrapper
, SID_MANAGE_XML_SOURCE
)
110 IMPL_CHILD_CTOR( ScPivotLayoutWrapper
, SID_OPENDLG_PIVOTTABLE
)
112 IMPL_CHILD_CTOR( ScTabOpDlgWrapper
, SID_OPENDLG_TABOP
)
114 IMPL_CHILD_CTOR( ScFilterDlgWrapper
, SID_FILTER
)
116 IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper
, SID_SPECIAL_FILTER
)
118 IMPL_CHILD_CTOR( ScDbNameDlgWrapper
, SID_DEFINE_DBNAME
)
120 IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper
, SID_DEFINE_COLROWNAMERANGES
)
122 IMPL_CHILD_CTOR( ScConsolidateDlgWrapper
, SID_OPENDLG_CONSOLIDATE
)
124 IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper
, SID_OPENDLG_EDIT_PRINTAREA
)
126 IMPL_CHILD_CTOR( ScFormulaDlgWrapper
, SID_OPENDLG_FUNCTION
)
128 //-------------------------------------------------------------------------
129 // ScSimpleRefDlgWrapper
130 //-------------------------------------------------------------------------
132 static sal_Bool bScSimpleRefFlag
;
133 static long nScSimpleRefHeight
;
134 static long nScSimpleRefWidth
;
135 static long nScSimpleRefX
;
136 static long nScSimpleRefY
;
137 static sal_Bool bAutoReOpen
=sal_True
;
139 ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( Window
* pParentP
,
142 SfxChildWinInfo
* pInfo
)
143 : SfxChildWindow(pParentP
, nId
)
146 ScTabViewShell
* pViewShell
= NULL
;
147 SfxDispatcher
* pDisp
= p
->GetDispatcher();
150 SfxViewFrame
* pViewFrm
= pDisp
->GetFrame();
152 pViewShell
= PTR_CAST( ScTabViewShell
, pViewFrm
->GetViewShell() );
155 OSL_ENSURE( pViewShell
, "missing view shell :-(" );
157 if(pInfo
!=NULL
&& bScSimpleRefFlag
)
159 pInfo
->aPos
.X()=nScSimpleRefX
;
160 pInfo
->aPos
.Y()=nScSimpleRefY
;
161 pInfo
->aSize
.Height()=nScSimpleRefHeight
;
162 pInfo
->aSize
.Width()=nScSimpleRefWidth
;
166 if(bAutoReOpen
&& pViewShell
)
167 pWindow
= pViewShell
->CreateRefDialog( p
, this, pInfo
, pParentP
, WID_SIMPLE_REF
);
171 SC_MOD()->SetRefDialog( nId
, false );
175 void ScSimpleRefDlgWrapper::SetDefaultPosSize(Point aPos
, Size aSize
, sal_Bool bSet
)
177 bScSimpleRefFlag
=bSet
;
180 nScSimpleRefX
=aPos
.X();
181 nScSimpleRefY
=aPos
.Y();
182 nScSimpleRefHeight
=aSize
.Height();
183 nScSimpleRefWidth
=aSize
.Width();
188 OUString
ScSimpleRefDlgWrapper::GetRefString()
193 aResult
=((ScSimpleRefDlg
*)pWindow
)->GetRefString();
198 void ScSimpleRefDlgWrapper::SetAutoReOpen(sal_Bool bFlag
)
203 void ScSimpleRefDlgWrapper::SetRefString(const OUString
& rStr
)
207 ((ScSimpleRefDlg
*)pWindow
)->SetRefString(rStr
);
211 void ScSimpleRefDlgWrapper::SetCloseHdl( const Link
& rLink
)
215 ((ScSimpleRefDlg
*)pWindow
)->SetCloseHdl( rLink
);
219 void ScSimpleRefDlgWrapper::SetUnoLinks( const Link
& rDone
,
220 const Link
& rAbort
, const Link
& rChange
)
224 ((ScSimpleRefDlg
*)pWindow
)->SetUnoLinks( rDone
, rAbort
, rChange
);
228 void ScSimpleRefDlgWrapper::SetFlags( sal_Bool bCloseOnButtonUp
, sal_Bool bSingleCell
, sal_Bool bMultiSelection
)
232 ((ScSimpleRefDlg
*)pWindow
)->SetFlags( bCloseOnButtonUp
, bSingleCell
, bMultiSelection
);
236 void ScSimpleRefDlgWrapper::StartRefInput()
240 ((ScSimpleRefDlg
*)pWindow
)->StartRefInput();
246 //-------------------------------------------------------------------------
247 // ScAcceptChgDlgWrapper //FIXME: should be moved into ViewShell
248 //-------------------------------------------------------------------------
250 ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( Window
* pParentP
,
252 SfxBindings
* pBindings
,
253 SfxChildWinInfo
* pInfo
) :
254 SfxChildWindow( pParentP
, nId
)
256 ScTabViewShell
* pViewShell
=
257 PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
258 OSL_ENSURE( pViewShell
, "missing view shell :-(" );
259 pWindow
= pViewShell
?
260 new ScAcceptChgDlg( pBindings
, this, pParentP
, pViewShell
->GetViewData() ) :
264 ((ScAcceptChgDlg
*)pWindow
)->Initialize( pInfo
);
266 if (pViewShell
&& !pWindow
)
267 pViewShell
->GetViewFrame()->SetChildWindow( nId
, false );
270 void ScAcceptChgDlgWrapper::ReInitDlg()
272 ScTabViewShell
* pViewShell
=
273 PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
274 OSL_ENSURE( pViewShell
, "missing view shell :-(" );
276 if(pWindow
!=NULL
&& pViewShell
)
278 ((ScAcceptChgDlg
*)pWindow
)->ReInit(pViewShell
->GetViewData());
282 //-------------------------------------------------------------------------
283 // ScHighlightChgDlgWrapper
284 //-------------------------------------------------------------------------
286 IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper
, FID_CHG_SHOW
)
291 ScTabViewShell
* lcl_GetTabViewShell( SfxBindings
*pBindings
)
294 if( SfxDispatcher
* pDisp
= pBindings
->GetDispatcher() )
295 if( SfxViewFrame
*pFrm
= pDisp
->GetFrame() )
296 if( SfxViewShell
* pViewSh
= pFrm
->GetViewShell() )
297 return dynamic_cast<ScTabViewShell
*>( pViewSh
);
303 ScValidityRefChildWin::ScValidityRefChildWin( Window
* pParentP
, \
306 SfxChildWinInfo
* /*pInfo*/ ) \
307 : SfxChildWindow(pParentP
, nId
),
308 m_bVisibleLock( false ),
309 m_bFreeWindowLock( false ),
310 m_pSavedWndParent( NULL
)
312 SetWantsFocus( false );\
313 ScTabViewShell
* pViewShell
= \
314 NULL
!= ( pWindow
= ScValidationDlg::Find1AliveObject( pParentP
) ) ? static_cast<ScValidationDlg
*>(pWindow
)->GetTabViewShell() :
315 lcl_GetTabViewShell( p
);
317 pViewShell
= PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
318 OSL_ENSURE( pViewShell
, "missing view shell :-(" ); \
319 if (pViewShell
&& !pWindow
) \
320 pViewShell
->GetViewFrame()->SetChildWindow( nId
, false ); \
322 if( pWindow
) m_pSavedWndParent
= pWindow
->GetParent();
325 ScValidityRefChildWin::~ScValidityRefChildWin()
327 if( pWindow
) pWindow
->SetParent( m_pSavedWndParent
);
329 if( m_bFreeWindowLock
)
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */