xref: /AOO41X/main/dbaccess/source/ui/app/AppView.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
30*cdf0e10cSrcweir #ifndef DBAUI_APPVIEW_HXX
31*cdf0e10cSrcweir #include "AppView.hxx"
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir #ifndef _DBU_APP_HRC_
34*cdf0e10cSrcweir #include "dbu_app.hrc"
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
37*cdf0e10cSrcweir #include <tools/debug.hxx>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
40*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_
43*cdf0e10cSrcweir #include "dbaccess_helpid.hrc"
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir #ifndef _SV_TOOLBOX_HXX
46*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #ifndef _UTL_CONFIGMGR_HXX_
49*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
50*cdf0e10cSrcweir #endif
51*cdf0e10cSrcweir #ifndef _SV_WAITOBJ_HXX
52*cdf0e10cSrcweir #include <vcl/waitobj.hxx>
53*cdf0e10cSrcweir #endif
54*cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
55*cdf0e10cSrcweir #include <comphelper/types.hxx>
56*cdf0e10cSrcweir #endif
57*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_
58*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
59*cdf0e10cSrcweir #endif
60*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
61*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
62*cdf0e10cSrcweir #endif
63*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
64*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
65*cdf0e10cSrcweir #endif
66*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
67*cdf0e10cSrcweir #include <com/sun/star/sdb/XQueriesSupplier.hpp>
68*cdf0e10cSrcweir #endif
69*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
70*cdf0e10cSrcweir #include <unotools/syslocale.hxx>
71*cdf0e10cSrcweir #endif
72*cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
73*cdf0e10cSrcweir #include "UITools.hxx"
74*cdf0e10cSrcweir #endif
75*cdf0e10cSrcweir #ifndef DBAUI_APPDETAILVIEW_HXX
76*cdf0e10cSrcweir #include "AppDetailView.hxx"
77*cdf0e10cSrcweir #endif
78*cdf0e10cSrcweir #ifndef _DBAUI_TABLETREE_HXX_
79*cdf0e10cSrcweir #include "tabletree.hxx"
80*cdf0e10cSrcweir #endif
81*cdf0e10cSrcweir #ifndef DBAUI_APPSWAPWINDOW_HXX
82*cdf0e10cSrcweir #include "AppSwapWindow.hxx"
83*cdf0e10cSrcweir #endif
84*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX //autogen
85*cdf0e10cSrcweir #include <vcl/svapp.hxx>
86*cdf0e10cSrcweir #endif
87*cdf0e10cSrcweir #ifndef DBAUI_APPSWAPWINDOW_HXX
88*cdf0e10cSrcweir #include "AppSwapWindow.hxx"
89*cdf0e10cSrcweir #endif
90*cdf0e10cSrcweir #ifndef DBAUI_TITLE_WINDOW_HXX
91*cdf0e10cSrcweir #include "AppTitleWindow.hxx"
92*cdf0e10cSrcweir #endif
93*cdf0e10cSrcweir #ifndef _DBAUI_DSNTYPES_HXX_
94*cdf0e10cSrcweir #include "dsntypes.hxx"
95*cdf0e10cSrcweir #endif
96*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
97*cdf0e10cSrcweir #include "dbustrings.hrc"
98*cdf0e10cSrcweir #endif
99*cdf0e10cSrcweir #ifndef DBAUI_ICONTROLLER_HXX
100*cdf0e10cSrcweir #include "IController.hxx"
101*cdf0e10cSrcweir #endif
102*cdf0e10cSrcweir #ifndef DBACCESS_UI_BROWSER_ID_HXX
103*cdf0e10cSrcweir #include "browserids.hxx"
104*cdf0e10cSrcweir #endif
105*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_PATHOPTIONS_HXX
106*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
107*cdf0e10cSrcweir #endif
108*cdf0e10cSrcweir #include "IApplicationController.hxx"
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir using namespace ::dbaui;
111*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
112*cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
113*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
114*cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
115*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
116*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
117*cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer::clipboard;
118*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
119*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
120*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
121*cdf0e10cSrcweir using namespace ::com::sun::star::container;
122*cdf0e10cSrcweir using ::com::sun::star::sdb::application::NamedDatabaseObject;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //==================================================================
125*cdf0e10cSrcweir // class OAppBorderWindow
126*cdf0e10cSrcweir DBG_NAME(OAppBorderWindow)
127*cdf0e10cSrcweir //==================================================================
128*cdf0e10cSrcweir OAppBorderWindow::OAppBorderWindow(OApplicationView* _pParent,PreviewMode _ePreviewMode) : Window(_pParent,WB_DIALOGCONTROL)
129*cdf0e10cSrcweir 	,m_pPanel(NULL)
130*cdf0e10cSrcweir     ,m_pDetailView(NULL)
131*cdf0e10cSrcweir 	,m_pView(_pParent)
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     DBG_CTOR(OAppBorderWindow,NULL);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	SetBorderStyle(WINDOW_BORDER_MONO);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	m_pPanel = new OTitleWindow(this,STR_DATABASE,WB_BORDER | WB_DIALOGCONTROL ,sal_False);
138*cdf0e10cSrcweir 	m_pPanel->SetBorderStyle(WINDOW_BORDER_MONO);
139*cdf0e10cSrcweir 	OApplicationSwapWindow* pSwap = new OApplicationSwapWindow( m_pPanel, *this );
140*cdf0e10cSrcweir 	pSwap->Show();
141*cdf0e10cSrcweir 	pSwap->SetUniqueId(UID_APP_SWAP_VIEW);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	m_pPanel->setChildWindow(pSwap);
144*cdf0e10cSrcweir 	m_pPanel->SetUniqueId(UID_APP_DATABASE_VIEW);
145*cdf0e10cSrcweir 	m_pPanel->Show();
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	m_pDetailView = new OApplicationDetailView(*this,_ePreviewMode);
148*cdf0e10cSrcweir 	m_pDetailView->Show();
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	ImplInitSettings();
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir // -----------------------------------------------------------------------------
153*cdf0e10cSrcweir OAppBorderWindow::~OAppBorderWindow()
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
156*cdf0e10cSrcweir 	// Childs zerstoeren
157*cdf0e10cSrcweir 	if ( m_pPanel )
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		m_pPanel->Hide();
160*cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pPanel);
161*cdf0e10cSrcweir 		m_pPanel = NULL;
162*cdf0e10cSrcweir 	}
163*cdf0e10cSrcweir 	if ( m_pDetailView )
164*cdf0e10cSrcweir 	{
165*cdf0e10cSrcweir 		m_pDetailView->Hide();
166*cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pDetailView);
167*cdf0e10cSrcweir 		m_pDetailView = NULL;
168*cdf0e10cSrcweir 	}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     DBG_DTOR(OAppBorderWindow,NULL);
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir // -----------------------------------------------------------------------------
173*cdf0e10cSrcweir void OAppBorderWindow::GetFocus()
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir 	if ( m_pPanel )
176*cdf0e10cSrcweir 		m_pPanel->GrabFocus();
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir // -----------------------------------------------------------------------------
179*cdf0e10cSrcweir void OAppBorderWindow::Resize()
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
182*cdf0e10cSrcweir 	// Abmessungen parent window
183*cdf0e10cSrcweir 	Size aOutputSize( GetOutputSize() );
184*cdf0e10cSrcweir 	long nOutputWidth	= aOutputSize.Width();
185*cdf0e10cSrcweir 	long nOutputHeight	= aOutputSize.Height();
186*cdf0e10cSrcweir 	long nX = 0;
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	Size aFLSize = LogicToPixel( Size( 3, 8 ), MAP_APPFONT );
189*cdf0e10cSrcweir 	if ( m_pPanel )
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		OApplicationSwapWindow* pSwap = getPanel();
192*cdf0e10cSrcweir 		if ( pSwap )
193*cdf0e10cSrcweir 		{
194*cdf0e10cSrcweir 			if ( pSwap->GetEntryCount() != 0 )
195*cdf0e10cSrcweir 				nX = pSwap->GetBoundingBox( pSwap->GetEntry(0) ).GetWidth() + aFLSize.Height();
196*cdf0e10cSrcweir 		}
197*cdf0e10cSrcweir 		nX = ::std::max(m_pPanel->GetWidthPixel() ,nX);
198*cdf0e10cSrcweir 		m_pPanel->SetPosSizePixel(Point(0,0),Size(nX,nOutputHeight));
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	if ( m_pDetailView )
202*cdf0e10cSrcweir 		m_pDetailView->SetPosSizePixel(Point(nX + aFLSize.Width(),0),Size(nOutputWidth - nX - aFLSize.Width(),nOutputHeight));
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir // -----------------------------------------------------------------------------
205*cdf0e10cSrcweir void OAppBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
206*cdf0e10cSrcweir {
207*cdf0e10cSrcweir 	Window::DataChanged( rDCEvt );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
210*cdf0e10cSrcweir 		(rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
211*cdf0e10cSrcweir 		(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
212*cdf0e10cSrcweir 		((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
213*cdf0e10cSrcweir 		(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
214*cdf0e10cSrcweir 	{
215*cdf0e10cSrcweir 		ImplInitSettings();
216*cdf0e10cSrcweir 		Invalidate();
217*cdf0e10cSrcweir 	}
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir // -----------------------------------------------------------------------------
220*cdf0e10cSrcweir void OAppBorderWindow::ImplInitSettings()
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
223*cdf0e10cSrcweir 	if( true )
224*cdf0e10cSrcweir 	{
225*cdf0e10cSrcweir 		Font aFont;
226*cdf0e10cSrcweir 		aFont = rStyleSettings.GetFieldFont();
227*cdf0e10cSrcweir 		aFont.SetColor( rStyleSettings.GetWindowTextColor() );
228*cdf0e10cSrcweir 		SetPointFont( aFont );
229*cdf0e10cSrcweir 	}
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 	if( true )
232*cdf0e10cSrcweir 	{
233*cdf0e10cSrcweir 		SetTextColor( rStyleSettings.GetFieldTextColor() );
234*cdf0e10cSrcweir 		SetTextFillColor();
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 	if( true )
238*cdf0e10cSrcweir 		SetBackground( rStyleSettings.GetDialogColor() );
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 	/*SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
241*cdf0e10cSrcweir 	SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
242*cdf0e10cSrcweir 	SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );*/
243*cdf0e10cSrcweir }
244*cdf0e10cSrcweir // -----------------------------------------------------------------------------
245*cdf0e10cSrcweir OApplicationView* OAppBorderWindow::getView() const
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     return m_pView;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir // -----------------------------------------------------------------------------
251*cdf0e10cSrcweir OApplicationSwapWindow*	OAppBorderWindow::getPanel() const
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir     return static_cast< OApplicationSwapWindow* >( m_pPanel->getChildWindow() );
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir // -----------------------------------------------------------------------------
257*cdf0e10cSrcweir OApplicationDetailView*	OAppBorderWindow::getDetailView() const
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     return m_pDetailView;
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir //==================================================================
263*cdf0e10cSrcweir // class OApplicationView
264*cdf0e10cSrcweir //==================================================================
265*cdf0e10cSrcweir DBG_NAME(OApplicationView);
266*cdf0e10cSrcweir //------------------------------------------------------------------------------
267*cdf0e10cSrcweir OApplicationView::OApplicationView( Window* pParent
268*cdf0e10cSrcweir 									,const Reference< XMultiServiceFactory >& _rxOrb
269*cdf0e10cSrcweir 									,IApplicationController& _rAppController
270*cdf0e10cSrcweir 									,PreviewMode _ePreviewMode
271*cdf0e10cSrcweir 								   ) :
272*cdf0e10cSrcweir 	ODataView( pParent, _rAppController, _rxOrb, WB_DIALOGCONTROL )
273*cdf0e10cSrcweir 	,m_rAppController( _rAppController )
274*cdf0e10cSrcweir 	,m_eChildFocus(NONE)
275*cdf0e10cSrcweir {
276*cdf0e10cSrcweir 	DBG_CTOR(OApplicationView,NULL);
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir 	try
279*cdf0e10cSrcweir 	{
280*cdf0e10cSrcweir 		m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
281*cdf0e10cSrcweir 	}
282*cdf0e10cSrcweir 	catch(Exception&)
283*cdf0e10cSrcweir 	{
284*cdf0e10cSrcweir 	}
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	m_pWin = new OAppBorderWindow(this,_ePreviewMode);
287*cdf0e10cSrcweir 	m_pWin->SetUniqueId(UID_APP_VIEW_BORDER_WIN);
288*cdf0e10cSrcweir 	m_pWin->Show();
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	ImplInitSettings();
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir //------------------------------------------------------------------------------
294*cdf0e10cSrcweir OApplicationView::~OApplicationView()
295*cdf0e10cSrcweir {
296*cdf0e10cSrcweir 	DBG_DTOR(OApplicationView,NULL);
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 	{
299*cdf0e10cSrcweir 		stopComponentListening(m_xObject);
300*cdf0e10cSrcweir 		m_pWin->Hide();
301*cdf0e10cSrcweir 		::std::auto_ptr<Window> aTemp(m_pWin);
302*cdf0e10cSrcweir 		m_pWin = NULL;
303*cdf0e10cSrcweir 	}
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir // -----------------------------------------------------------------------------
306*cdf0e10cSrcweir void OApplicationView::createIconAutoMnemonics( MnemonicGenerator& _rMnemonics )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir     if ( m_pWin && m_pWin->getPanel() )
309*cdf0e10cSrcweir         m_pWin->getPanel()->createIconAutoMnemonics( _rMnemonics );
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir // -----------------------------------------------------------------------------
313*cdf0e10cSrcweir void OApplicationView::setTaskExternalMnemonics( MnemonicGenerator& _rMnemonics )
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir     if ( m_pWin && m_pWin->getDetailView() )
316*cdf0e10cSrcweir         m_pWin->getDetailView()->setTaskExternalMnemonics( _rMnemonics );
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir // -----------------------------------------------------------------------------
320*cdf0e10cSrcweir void OApplicationView::DataChanged( const DataChangedEvent& rDCEvt )
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	ODataView::DataChanged( rDCEvt );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
325*cdf0e10cSrcweir 		(rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
326*cdf0e10cSrcweir 		(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
327*cdf0e10cSrcweir 		((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
328*cdf0e10cSrcweir 		(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
329*cdf0e10cSrcweir 	{
330*cdf0e10cSrcweir 		ImplInitSettings();
331*cdf0e10cSrcweir 		Invalidate();
332*cdf0e10cSrcweir 	}
333*cdf0e10cSrcweir }
334*cdf0e10cSrcweir //------------------------------------------------------------------------------
335*cdf0e10cSrcweir void OApplicationView::resizeDocumentView(Rectangle& _rPlayground)
336*cdf0e10cSrcweir {
337*cdf0e10cSrcweir 	if ( m_pWin && !_rPlayground.IsEmpty() )
338*cdf0e10cSrcweir 	{
339*cdf0e10cSrcweir 		Size aFLSize = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
340*cdf0e10cSrcweir 		_rPlayground.Move( aFLSize.A(),aFLSize.B() );
341*cdf0e10cSrcweir 		Size aOldSize = _rPlayground.GetSize();
342*cdf0e10cSrcweir 		_rPlayground.SetSize( Size(aOldSize.A() - 2*aFLSize.A(), aOldSize.B() - 2*aFLSize.B()) );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 		m_pWin->SetPosSizePixel(_rPlayground.TopLeft() , _rPlayground.GetSize() );
345*cdf0e10cSrcweir 	}
346*cdf0e10cSrcweir 	// just for completeness: there is no space left, we occupied it all ...
347*cdf0e10cSrcweir 	_rPlayground.SetPos( _rPlayground.BottomRight() );
348*cdf0e10cSrcweir 	_rPlayground.SetSize( Size( 0, 0 ) );
349*cdf0e10cSrcweir }
350*cdf0e10cSrcweir //------------------------------------------------------------------------------
351*cdf0e10cSrcweir long OApplicationView::PreNotify( NotifyEvent& rNEvt )
352*cdf0e10cSrcweir {
353*cdf0e10cSrcweir 	switch(rNEvt.GetType())
354*cdf0e10cSrcweir 	{
355*cdf0e10cSrcweir 		case EVENT_GETFOCUS:
356*cdf0e10cSrcweir 			if( m_pWin && getPanel() && getPanel()->HasChildPathFocus() )
357*cdf0e10cSrcweir 				m_eChildFocus = PANELSWAP;
358*cdf0e10cSrcweir 			else if ( m_pWin && getDetailView() && getDetailView()->HasChildPathFocus() )
359*cdf0e10cSrcweir 				m_eChildFocus = DETAIL;
360*cdf0e10cSrcweir 			else
361*cdf0e10cSrcweir 				m_eChildFocus = NONE;
362*cdf0e10cSrcweir 			break;
363*cdf0e10cSrcweir         case EVENT_KEYINPUT:
364*cdf0e10cSrcweir         {
365*cdf0e10cSrcweir             const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
366*cdf0e10cSrcweir             // give the pane the chance to intercept mnemonic accelerators
367*cdf0e10cSrcweir             // #i34790# - 2004-09-30 - fs@openoffice.org
368*cdf0e10cSrcweir             if ( getPanel() && getPanel()->interceptKeyInput( *pKeyEvent ) )
369*cdf0e10cSrcweir                 return 1L;
370*cdf0e10cSrcweir             // and ditto the detail view
371*cdf0e10cSrcweir             // #i72799# - 2006-12-20 / frank.schoenheit@sun.com
372*cdf0e10cSrcweir             if ( getDetailView() && getDetailView()->interceptKeyInput( *pKeyEvent ) )
373*cdf0e10cSrcweir                 return 1L;
374*cdf0e10cSrcweir         }
375*cdf0e10cSrcweir         break;
376*cdf0e10cSrcweir 	}
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 	return ODataView::PreNotify(rNEvt);
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir // -----------------------------------------------------------------------------
381*cdf0e10cSrcweir IClipboardTest* OApplicationView::getActiveChild() const
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 	IClipboardTest* pTest = NULL;
384*cdf0e10cSrcweir 	if ( DETAIL == m_eChildFocus )
385*cdf0e10cSrcweir 		pTest = getDetailView();
386*cdf0e10cSrcweir 	return pTest;
387*cdf0e10cSrcweir }
388*cdf0e10cSrcweir // -----------------------------------------------------------------------------
389*cdf0e10cSrcweir sal_Bool OApplicationView::isCopyAllowed()
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
392*cdf0e10cSrcweir 	return pTest && pTest->isCopyAllowed();
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir // -----------------------------------------------------------------------------
395*cdf0e10cSrcweir sal_Bool OApplicationView::isCutAllowed()
396*cdf0e10cSrcweir {
397*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
398*cdf0e10cSrcweir 	return pTest && pTest->isCutAllowed();
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir // -----------------------------------------------------------------------------
401*cdf0e10cSrcweir sal_Bool OApplicationView::isPasteAllowed()
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
404*cdf0e10cSrcweir 	return pTest && pTest->isPasteAllowed();
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir // -----------------------------------------------------------------------------
407*cdf0e10cSrcweir void OApplicationView::copy()
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
410*cdf0e10cSrcweir 	if ( pTest )
411*cdf0e10cSrcweir 		pTest->copy();
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir // -----------------------------------------------------------------------------
414*cdf0e10cSrcweir void OApplicationView::cut()
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
417*cdf0e10cSrcweir 	if ( pTest )
418*cdf0e10cSrcweir 		pTest->cut();
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir // -----------------------------------------------------------------------------
421*cdf0e10cSrcweir void OApplicationView::paste()
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir 	IClipboardTest* pTest = getActiveChild();
424*cdf0e10cSrcweir 	if ( pTest )
425*cdf0e10cSrcweir 		pTest->paste();
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir // -----------------------------------------------------------------------------
428*cdf0e10cSrcweir ::rtl::OUString OApplicationView::getQualifiedName( SvLBoxEntry* _pEntry ) const
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
431*cdf0e10cSrcweir 	return getDetailView()->getQualifiedName( _pEntry );
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir // -----------------------------------------------------------------------------
434*cdf0e10cSrcweir sal_Bool OApplicationView::isLeaf(SvLBoxEntry* _pEntry) const
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
437*cdf0e10cSrcweir 	return getDetailView()->isLeaf(_pEntry);
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir // -----------------------------------------------------------------------------
440*cdf0e10cSrcweir sal_Bool OApplicationView::isALeafSelected() const
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
443*cdf0e10cSrcweir 	return getDetailView()->isALeafSelected();
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir // -----------------------------------------------------------------------------
446*cdf0e10cSrcweir void OApplicationView::selectAll()
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
449*cdf0e10cSrcweir 	getDetailView()->selectAll();
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir // -----------------------------------------------------------------------------
452*cdf0e10cSrcweir sal_Bool OApplicationView::isSortUp() const
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
455*cdf0e10cSrcweir 	return getDetailView()->isSortUp();
456*cdf0e10cSrcweir }
457*cdf0e10cSrcweir // -----------------------------------------------------------------------------
458*cdf0e10cSrcweir void OApplicationView::sortDown()
459*cdf0e10cSrcweir {
460*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
461*cdf0e10cSrcweir 	getDetailView()->sortDown();
462*cdf0e10cSrcweir }
463*cdf0e10cSrcweir // -----------------------------------------------------------------------------
464*cdf0e10cSrcweir void OApplicationView::sortUp()
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
467*cdf0e10cSrcweir 	getDetailView()->sortUp();
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir // -----------------------------------------------------------------------------
470*cdf0e10cSrcweir sal_Bool OApplicationView::isFilled() const
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
473*cdf0e10cSrcweir 	return getDetailView()->isFilled();
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir // -----------------------------------------------------------------------------
476*cdf0e10cSrcweir ElementType OApplicationView::getElementType() const
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
479*cdf0e10cSrcweir 	return getDetailView()->HasChildPathFocus() ? getDetailView()->getElementType() : getPanel()->getElementType();
480*cdf0e10cSrcweir }
481*cdf0e10cSrcweir // -----------------------------------------------------------------------------
482*cdf0e10cSrcweir sal_Int32 OApplicationView::getSelectionCount()
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
485*cdf0e10cSrcweir 	return getDetailView()->getSelectionCount();
486*cdf0e10cSrcweir }
487*cdf0e10cSrcweir // -----------------------------------------------------------------------------
488*cdf0e10cSrcweir sal_Int32 OApplicationView::getElementCount()
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
491*cdf0e10cSrcweir 	return getDetailView()->getElementCount();
492*cdf0e10cSrcweir }
493*cdf0e10cSrcweir // -----------------------------------------------------------------------------
494*cdf0e10cSrcweir void OApplicationView::getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const
495*cdf0e10cSrcweir {
496*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
497*cdf0e10cSrcweir 	getDetailView()->getSelectionElementNames( _rNames );
498*cdf0e10cSrcweir }
499*cdf0e10cSrcweir // -----------------------------------------------------------------------------
500*cdf0e10cSrcweir void OApplicationView::describeCurrentSelectionForControl( const Control& _rControl, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
503*cdf0e10cSrcweir 	getDetailView()->describeCurrentSelectionForControl( _rControl, _out_rSelectedObjects );
504*cdf0e10cSrcweir }
505*cdf0e10cSrcweir // -----------------------------------------------------------------------------
506*cdf0e10cSrcweir void OApplicationView::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects )
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
509*cdf0e10cSrcweir 	getDetailView()->describeCurrentSelectionForType( _eType, _out_rSelectedObjects );
510*cdf0e10cSrcweir }
511*cdf0e10cSrcweir // -----------------------------------------------------------------------------
512*cdf0e10cSrcweir void OApplicationView::selectElements(const Sequence< ::rtl::OUString>& _aNames)
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir     OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
515*cdf0e10cSrcweir 	getDetailView()->selectElements( _aNames );
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir // -----------------------------------------------------------------------------
518*cdf0e10cSrcweir SvLBoxEntry* OApplicationView::elementAdded(ElementType eType,const ::rtl::OUString& _rName, const Any& _rObject )
519*cdf0e10cSrcweir {
520*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
521*cdf0e10cSrcweir 	return getDetailView()->elementAdded(eType,_rName,_rObject);
522*cdf0e10cSrcweir }
523*cdf0e10cSrcweir // -----------------------------------------------------------------------------
524*cdf0e10cSrcweir void OApplicationView::elementRemoved(ElementType eType,const ::rtl::OUString& _rName )
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
527*cdf0e10cSrcweir 	getDetailView()->elementRemoved(eType,_rName);
528*cdf0e10cSrcweir }
529*cdf0e10cSrcweir // -----------------------------------------------------------------------------
530*cdf0e10cSrcweir void OApplicationView::elementReplaced(ElementType _eType
531*cdf0e10cSrcweir 													,const ::rtl::OUString& _rOldName
532*cdf0e10cSrcweir 													,const ::rtl::OUString& _rNewName )
533*cdf0e10cSrcweir {
534*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
535*cdf0e10cSrcweir 	getDetailView()->elementReplaced(_eType, _rOldName, _rNewName );
536*cdf0e10cSrcweir }
537*cdf0e10cSrcweir // -----------------------------------------------------------------------------
538*cdf0e10cSrcweir void OApplicationView::clearPages(sal_Bool _bTaskAlso)
539*cdf0e10cSrcweir {
540*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView() && getPanel(),"Detail view is NULL! -> GPF");
541*cdf0e10cSrcweir 	getPanel()->clearSelection();
542*cdf0e10cSrcweir 	getDetailView()->clearPages(_bTaskAlso);
543*cdf0e10cSrcweir }
544*cdf0e10cSrcweir // -----------------------------------------------------------------------------
545*cdf0e10cSrcweir void OApplicationView::selectContainer(ElementType _eType)
546*cdf0e10cSrcweir {
547*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getPanel(),"Detail view is NULL! -> GPF");
548*cdf0e10cSrcweir 	WaitObject aWO(this);
549*cdf0e10cSrcweir 	getPanel()->selectContainer(_eType);
550*cdf0e10cSrcweir }
551*cdf0e10cSrcweir // -----------------------------------------------------------------------------
552*cdf0e10cSrcweir SvLBoxEntry* OApplicationView::getEntry( const Point& _aPosPixel ) const
553*cdf0e10cSrcweir {
554*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
555*cdf0e10cSrcweir 	return getDetailView()->getEntry(_aPosPixel);
556*cdf0e10cSrcweir }
557*cdf0e10cSrcweir // -----------------------------------------------------------------------------
558*cdf0e10cSrcweir PreviewMode OApplicationView::getPreviewMode()
559*cdf0e10cSrcweir {
560*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
561*cdf0e10cSrcweir 	return getDetailView()->getPreviewMode();
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir // -----------------------------------------------------------------------------
564*cdf0e10cSrcweir sal_Bool OApplicationView::isPreviewEnabled()
565*cdf0e10cSrcweir {
566*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
567*cdf0e10cSrcweir 	return getDetailView()->isPreviewEnabled();
568*cdf0e10cSrcweir }
569*cdf0e10cSrcweir // -----------------------------------------------------------------------------
570*cdf0e10cSrcweir void OApplicationView::switchPreview(PreviewMode _eMode)
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
573*cdf0e10cSrcweir 	getDetailView()->switchPreview(_eMode);
574*cdf0e10cSrcweir }
575*cdf0e10cSrcweir // -----------------------------------------------------------------------------
576*cdf0e10cSrcweir void OApplicationView::showPreview(const Reference< XContent >& _xContent)
577*cdf0e10cSrcweir {
578*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
579*cdf0e10cSrcweir 	stopComponentListening(m_xObject);
580*cdf0e10cSrcweir 	m_xObject = NULL;
581*cdf0e10cSrcweir 	getDetailView()->showPreview(_xContent);
582*cdf0e10cSrcweir }
583*cdf0e10cSrcweir // -----------------------------------------------------------------------------
584*cdf0e10cSrcweir void OApplicationView::showPreview(	const ::rtl::OUString& _sDataSourceName,
585*cdf0e10cSrcweir 									const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
586*cdf0e10cSrcweir 									const ::rtl::OUString& _sName,
587*cdf0e10cSrcweir 									sal_Bool _bTable)
588*cdf0e10cSrcweir {
589*cdf0e10cSrcweir 	OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF");
590*cdf0e10cSrcweir 	if ( isPreviewEnabled() )
591*cdf0e10cSrcweir 	{
592*cdf0e10cSrcweir 		stopComponentListening(m_xObject);
593*cdf0e10cSrcweir 		m_xObject = NULL;
594*cdf0e10cSrcweir 		try
595*cdf0e10cSrcweir 		{
596*cdf0e10cSrcweir 			Reference<XNameAccess> xNameAccess;
597*cdf0e10cSrcweir 			if ( _bTable )
598*cdf0e10cSrcweir 			{
599*cdf0e10cSrcweir 				Reference<XTablesSupplier> xSup(_xConnection,UNO_QUERY);
600*cdf0e10cSrcweir 				if ( xSup.is() )
601*cdf0e10cSrcweir 					xNameAccess.set(xSup->getTables(),UNO_QUERY);
602*cdf0e10cSrcweir 			}
603*cdf0e10cSrcweir 			else
604*cdf0e10cSrcweir 			{
605*cdf0e10cSrcweir 				Reference<XQueriesSupplier> xSup(_xConnection,UNO_QUERY);
606*cdf0e10cSrcweir 				if ( xSup.is() )
607*cdf0e10cSrcweir 					xNameAccess.set(xSup->getQueries(),UNO_QUERY);
608*cdf0e10cSrcweir 			}
609*cdf0e10cSrcweir 			if ( xNameAccess.is() && xNameAccess->hasByName(_sName) )
610*cdf0e10cSrcweir 				m_xObject.set(xNameAccess->getByName(_sName),UNO_QUERY);
611*cdf0e10cSrcweir 		}
612*cdf0e10cSrcweir 	    catch( const Exception& )
613*cdf0e10cSrcweir 	    {
614*cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
615*cdf0e10cSrcweir 	    }
616*cdf0e10cSrcweir 		if ( m_xObject.is() )
617*cdf0e10cSrcweir 			startComponentListening(m_xObject);
618*cdf0e10cSrcweir 		getDetailView()->showPreview(_sDataSourceName,_sName,_bTable);
619*cdf0e10cSrcweir 	}
620*cdf0e10cSrcweir }
621*cdf0e10cSrcweir // -----------------------------------------------------------------------------
622*cdf0e10cSrcweir void OApplicationView::GetFocus()
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir 	if ( m_eChildFocus == NONE && m_pWin )
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		m_pWin->GrabFocus();
627*cdf0e10cSrcweir 	}
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir // -----------------------------------------------------------------------------
630*cdf0e10cSrcweir void OApplicationView::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir 	if ( m_pWin && getDetailView() )
633*cdf0e10cSrcweir 		showPreview(NULL);
634*cdf0e10cSrcweir }
635*cdf0e10cSrcweir // -----------------------------------------------------------------------------
636*cdf0e10cSrcweir void OApplicationView::ImplInitSettings()
637*cdf0e10cSrcweir {
638*cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
639*cdf0e10cSrcweir 	if( true )
640*cdf0e10cSrcweir 	{
641*cdf0e10cSrcweir 		Font aFont;
642*cdf0e10cSrcweir 		aFont = rStyleSettings.GetFieldFont();
643*cdf0e10cSrcweir 		aFont.SetColor( rStyleSettings.GetWindowTextColor() );
644*cdf0e10cSrcweir 		SetPointFont( aFont );
645*cdf0e10cSrcweir 	}
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 	if( true )
648*cdf0e10cSrcweir 	{
649*cdf0e10cSrcweir 		SetTextColor( rStyleSettings.GetFieldTextColor() );
650*cdf0e10cSrcweir 		SetTextFillColor();
651*cdf0e10cSrcweir 	}
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir 	if( true )
654*cdf0e10cSrcweir 		SetBackground( rStyleSettings.GetFieldColor() );
655*cdf0e10cSrcweir 	/*SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetDialogColor() ) );
656*cdf0e10cSrcweir 	SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
657*cdf0e10cSrcweir 	SetTextFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );*/
658*cdf0e10cSrcweir }
659*cdf0e10cSrcweir //-----------------------------------------------------------------------------
660