fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / reffact.cxx
blob75c69b1aea168f329952beb5833c9d66a71cd0a3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
28 #include "sc.hrc"
29 #include "acredlin.hxx"
30 #include "simpref.hxx"
31 #include "scmod.hxx"
32 #include "validate.hxx"
34 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME )
35 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME )
36 SFX_IMPL_MODELESSDIALOG_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
37 SFX_IMPL_MODELESSDIALOG_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
38 SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
39 SFX_IMPL_MODELESSDIALOG_WITHID(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
40 SFX_IMPL_MODELESSDIALOG_WITHID(ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
41 SFX_IMPL_MODELESSDIALOG_WITHID(ScFilterDlgWrapper, SID_FILTER )
42 SFX_IMPL_MODELESSDIALOG_WITHID(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
43 SFX_IMPL_MODELESSDIALOG_WITHID(ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
44 SFX_IMPL_MODELESSDIALOG_WITHID(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
45 SFX_IMPL_MODELESSDIALOG_WITHID(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
46 SFX_IMPL_MODELESSDIALOG_WITHID(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
47 SFX_IMPL_MODELESSDIALOG_WITHID(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
48 SFX_IMPL_MODELESSDIALOG_WITHID(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT )
49 SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
50 SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
51 SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDlgWrapper, WID_CONDFRMT_REF )
53 SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
55 SfxChildWinInfo ScValidityRefChildWin::GetInfo() const
57 SfxChildWinInfo anInfo = SfxChildWindow::GetInfo();
59 if( vcl::Window *pWnd = GetWindow() )
61 anInfo.aSize = pWnd->GetSizePixel();
63 if( pWnd->IsDialog() )
64 if ( static_cast<Dialog*>(pWnd)->IsRollUp() )
65 anInfo.nFlags |= SfxChildWindowFlags::ZOOMIN;
68 return anInfo;
71 namespace
73 ScTabViewShell* lcl_GetTabViewShell( SfxBindings* pBindings );
76 #define IMPL_CHILD_CTOR(Class,sid) \
77 Class::Class( vcl::Window* pParentP, \
78 sal_uInt16 nId, \
79 SfxBindings* p, \
80 SfxChildWinInfo* pInfo ) \
81 : SfxChildWindow(pParentP, nId) \
82 { \
83 /************************************************************************************/\
84 /* When a new document is creating, the SfxViewFrame may be ready, */\
85 /* But the ScTabViewShell may have not been activated yet. In this */\
86 /* situation, SfxViewShell::Current() does not get the correct shell, */\
87 /* and we should lcl_GetTabViewShell( p ) instead of SfxViewShell::Current() */\
88 /************************************************************************************/\
89 ScTabViewShell* pViewShell = lcl_GetTabViewShell( p ); \
90 if (!pViewShell) \
91 pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \
92 OSL_ENSURE( pViewShell, "missing view shell :-(" ); \
93 pWindow = pViewShell ? \
94 pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : nullptr; \
95 if (pViewShell && !pWindow) \
96 pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \
99 IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME )
101 IMPL_CHILD_CTOR( ScNameDefDlgWrapper, FID_ADD_NAME )
103 IMPL_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
105 IMPL_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
107 IMPL_CHILD_CTOR( ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
109 IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
111 IMPL_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
113 IMPL_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER )
115 IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
117 IMPL_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
119 IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
121 IMPL_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
123 IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
125 IMPL_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
127 // ScSimpleRefDlgWrapper
129 static bool bScSimpleRefFlag;
130 static long nScSimpleRefHeight;
131 static long nScSimpleRefWidth;
132 static long nScSimpleRefX;
133 static long nScSimpleRefY;
134 static bool bAutoReOpen = true;
136 ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( vcl::Window* pParentP,
137 sal_uInt16 nId,
138 SfxBindings* p,
139 SfxChildWinInfo* pInfo )
140 : SfxChildWindow(pParentP, nId)
143 ScTabViewShell* pViewShell = NULL;
144 SfxDispatcher* pDisp = p->GetDispatcher();
145 if ( pDisp )
147 SfxViewFrame* pViewFrm = pDisp->GetFrame();
148 if ( pViewFrm )
149 pViewShell = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
152 OSL_ENSURE( pViewShell, "missing view shell :-(" );
154 if(pInfo!=NULL && bScSimpleRefFlag)
156 pInfo->aPos.X()=nScSimpleRefX;
157 pInfo->aPos.Y()=nScSimpleRefY;
158 pInfo->aSize.Height()=nScSimpleRefHeight;
159 pInfo->aSize.Width()=nScSimpleRefWidth;
161 pWindow = NULL;
163 if(bAutoReOpen && pViewShell)
164 pWindow = pViewShell->CreateRefDialog( p, this, pInfo, pParentP, WID_SIMPLE_REF);
166 if (!pWindow)
168 SC_MOD()->SetRefDialog( nId, false );
172 void ScSimpleRefDlgWrapper::SetDefaultPosSize(Point aPos, Size aSize, bool bSet)
174 bScSimpleRefFlag=bSet;
175 if(bScSimpleRefFlag)
177 nScSimpleRefX=aPos.X();
178 nScSimpleRefY=aPos.Y();
179 nScSimpleRefHeight=aSize.Height();
180 nScSimpleRefWidth=aSize.Width();
184 void ScSimpleRefDlgWrapper::SetAutoReOpen(bool bFlag)
186 bAutoReOpen=bFlag;
189 void ScSimpleRefDlgWrapper::SetRefString(const OUString& rStr)
191 if(pWindow!=nullptr)
193 static_cast<ScSimpleRefDlg*>(pWindow.get())->SetRefString(rStr);
197 void ScSimpleRefDlgWrapper::SetCloseHdl( const Link<>& rLink )
199 if(pWindow!=nullptr)
201 static_cast<ScSimpleRefDlg*>(pWindow.get())->SetCloseHdl( rLink );
205 void ScSimpleRefDlgWrapper::SetUnoLinks( const Link<>& rDone,
206 const Link<>& rAbort, const Link<>& rChange )
208 if(pWindow!=nullptr)
210 static_cast<ScSimpleRefDlg*>(pWindow.get())->SetUnoLinks( rDone, rAbort, rChange );
214 void ScSimpleRefDlgWrapper::SetFlags( bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection )
216 if(pWindow!=nullptr)
218 static_cast<ScSimpleRefDlg*>(pWindow.get())->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
222 void ScSimpleRefDlgWrapper::StartRefInput()
224 if(pWindow!=nullptr)
226 static_cast<ScSimpleRefDlg*>(pWindow.get())->StartRefInput();
230 // ScAcceptChgDlgWrapper //FIXME: should be moved into ViewShell
232 ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( vcl::Window* pParentP,
233 sal_uInt16 nId,
234 SfxBindings* pBindings,
235 SfxChildWinInfo* pInfo ) :
236 SfxChildWindow( pParentP, nId )
238 ScTabViewShell* pViewShell =
239 PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
240 OSL_ENSURE( pViewShell, "missing view shell :-(" );
241 if (pViewShell)
242 pWindow = VclPtr<ScAcceptChgDlg>::Create( pBindings, this, pParentP, &pViewShell->GetViewData() );
243 else
244 pWindow = NULL;
245 if(pWindow!=nullptr)
247 static_cast<ScAcceptChgDlg*>(pWindow.get())->Initialize( pInfo );
249 if (pViewShell && !pWindow)
250 pViewShell->GetViewFrame()->SetChildWindow( nId, false );
253 void ScAcceptChgDlgWrapper::ReInitDlg()
255 ScTabViewShell* pViewShell =
256 PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
257 OSL_ENSURE( pViewShell, "missing view shell :-(" );
259 if(pWindow!=nullptr && pViewShell)
261 static_cast<ScAcceptChgDlg*>(pWindow.get())->ReInit(&pViewShell->GetViewData());
265 // ScHighlightChgDlgWrapper
267 IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper, FID_CHG_SHOW )
269 namespace
271 ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings )
273 if( pBindings )
274 if( SfxDispatcher* pDisp = pBindings ->GetDispatcher() )
275 if( SfxViewFrame *pFrm = pDisp->GetFrame() )
276 if( SfxViewShell* pViewSh = pFrm->GetViewShell() )
277 return dynamic_cast<ScTabViewShell*>( pViewSh );
279 return NULL;
283 ScValidityRefChildWin::ScValidityRefChildWin( vcl::Window* pParentP,
284 sal_uInt16 nId,
285 SfxBindings* p,
286 SfxChildWinInfo* /*pInfo*/ )
287 : SfxChildWindow(pParentP, nId),
288 m_bVisibleLock( false ),
289 m_bFreeWindowLock( false ),
290 m_pSavedWndParent( NULL )
292 SetWantsFocus( false );
293 ScTabViewShell* pViewShell =
294 nullptr != ( pWindow = ScValidationDlg::Find1AliveObject( pParentP ) ) ? static_cast<ScValidationDlg*>(pWindow.get())->GetTabViewShell() :
295 lcl_GetTabViewShell( p );
296 if (!pViewShell)
297 pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
298 OSL_ENSURE( pViewShell, "missing view shell :-(" );
299 if (pViewShell && !pWindow)
300 pViewShell->GetViewFrame()->SetChildWindow( nId, false );
302 if( pWindow ) m_pSavedWndParent = pWindow->GetParent();
305 ScValidityRefChildWin::~ScValidityRefChildWin()
307 if( pWindow ) pWindow->SetParent( m_pSavedWndParent );
309 if( m_bFreeWindowLock )
310 pWindow = NULL;
313 IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, WID_CONDFRMT_REF )
315 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */