xref: /trunk/main/svx/source/form/fmview.cxx (revision cdf0e10c)
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_svx.hxx"
30*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
31*cdf0e10cSrcweir #ifdef REFERENCE
32*cdf0e10cSrcweir #undef REFERENCE
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include <svtools/ehdl.hxx>
35*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
36*cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/uno/XNamingService.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/form/XReset.hpp>
42*cdf0e10cSrcweir #include "fmvwimp.hxx"
43*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
44*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
45*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
46*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
47*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
48*cdf0e10cSrcweir #include <basic/sbuno.hxx>
49*cdf0e10cSrcweir #include <basic/sbx.hxx>
50*cdf0e10cSrcweir #include "fmitems.hxx"
51*cdf0e10cSrcweir #include "fmobj.hxx"
52*cdf0e10cSrcweir #include "svx/svditer.hxx"
53*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
54*cdf0e10cSrcweir #include <svx/svdogrp.hxx>
55*cdf0e10cSrcweir #include <svx/fmview.hxx>
56*cdf0e10cSrcweir #include <svx/fmmodel.hxx>
57*cdf0e10cSrcweir #include <svx/fmpage.hxx>
58*cdf0e10cSrcweir #include <svx/fmshell.hxx>
59*cdf0e10cSrcweir #include "fmpgeimp.hxx"
60*cdf0e10cSrcweir #include "svx/fmtools.hxx"
61*cdf0e10cSrcweir #include "fmshimp.hxx"
62*cdf0e10cSrcweir #include "fmservs.hxx"
63*cdf0e10cSrcweir #include "fmprop.hrc"
64*cdf0e10cSrcweir #include "fmundo.hxx"
65*cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx>
66*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
67*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx>
68*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
69*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
70*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
71*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
72*cdf0e10cSrcweir #include <vcl/svapp.hxx>
73*cdf0e10cSrcweir #include <tools/urlobj.hxx>
74*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
75*cdf0e10cSrcweir #include <vcl/stdtext.hxx>
76*cdf0e10cSrcweir #include <svx/fmglob.hxx>
77*cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx>
78*cdf0e10cSrcweir #include "svx/sdrpaintwindow.hxx"
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir using namespace ::com::sun::star;
81*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
82*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
83*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
84*cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
85*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
86*cdf0e10cSrcweir using namespace ::com::sun::star::container;
87*cdf0e10cSrcweir using namespace ::com::sun::star::form;
88*cdf0e10cSrcweir using namespace ::com::sun::star::util;
89*cdf0e10cSrcweir using namespace ::svxform;
90*cdf0e10cSrcweir using namespace ::svx;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir //========================================================================
93*cdf0e10cSrcweir //------------------------------------------------------------------------
94*cdf0e10cSrcweir TYPEINIT1(FmFormView, E3dView);
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir //------------------------------------------------------------------------
97*cdf0e10cSrcweir FmFormView::FmFormView( FmFormModel* pModel, OutputDevice* pOut )
98*cdf0e10cSrcweir 	:E3dView(pModel,pOut)
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir 	Init();
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir //------------------------------------------------------------------------
104*cdf0e10cSrcweir void FmFormView::Init()
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	pFormShell = NULL;
107*cdf0e10cSrcweir 	pImpl = new FmXFormView(::comphelper::getProcessServiceFactory(),this);
108*cdf0e10cSrcweir 	pImpl->acquire();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
111*cdf0e10cSrcweir 	// Model setzen
112*cdf0e10cSrcweir 	SdrModel* pModel = GetModel();
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	DBG_ASSERT( pModel->ISA(FmFormModel), "Falsches Model" );
115*cdf0e10cSrcweir 	if( !pModel->ISA(FmFormModel) ) return;
116*cdf0e10cSrcweir 	FmFormModel* pFormModel = (FmFormModel*)pModel;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
119*cdf0e10cSrcweir 	// DesignMode vom Model holen
120*cdf0e10cSrcweir 	sal_Bool bInitDesignMode = pFormModel->GetOpenInDesignMode();
121*cdf0e10cSrcweir 	if ( pFormModel->OpenInDesignModeIsDefaulted( ) )
122*cdf0e10cSrcweir 	{	// this means that nobody ever explicitly set this on the model, and the model has never
123*cdf0e10cSrcweir 		// been loaded from a stream.
124*cdf0e10cSrcweir 		// This means this is a newly created document. This means, we want to have it in design
125*cdf0e10cSrcweir 		// mode by default (though a newly created model returns true for GetOpenInDesignMode).
126*cdf0e10cSrcweir 		// We _want_ to have this because it makes a lot of hacks following the original fix
127*cdf0e10cSrcweir 		// for #94595# unnecessary
128*cdf0e10cSrcweir 		// #96399# - 2002-10-11 - fs@openoffice.org
129*cdf0e10cSrcweir 		DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" );
130*cdf0e10cSrcweir 			// if this asserts, either the on-contruction default in the model has changed (then this here
131*cdf0e10cSrcweir 			// may not be necessary anymore), or we're not dealing with a new document ....
132*cdf0e10cSrcweir 		bInitDesignMode = sal_True;
133*cdf0e10cSrcweir 	}
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	SfxObjectShell* pObjShell = pFormModel->GetObjectShell();
136*cdf0e10cSrcweir 	if ( pObjShell && pObjShell->GetMedium() )
137*cdf0e10cSrcweir 	{
138*cdf0e10cSrcweir 		const SfxPoolItem *pItem=0;
139*cdf0e10cSrcweir         if ( pObjShell->GetMedium()->GetItemSet()->GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
140*cdf0e10cSrcweir         {
141*cdf0e10cSrcweir             ::comphelper::NamedValueCollection aComponentData( ((SfxUnoAnyItem*)pItem)->GetValue() );
142*cdf0e10cSrcweir             bInitDesignMode = aComponentData.getOrDefault( "ApplyFormDesignMode", bInitDesignMode );
143*cdf0e10cSrcweir         }
144*cdf0e10cSrcweir 	}
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	if( pObjShell && pObjShell->IsReadOnly() )
147*cdf0e10cSrcweir 		bInitDesignMode = sal_False;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	// dieses wird in der Shell vorgenommen
150*cdf0e10cSrcweir 	// bDesignMode = !bInitDesignMode;	// erzwingt, dass SetDesignMode ausgefuehrt wird
151*cdf0e10cSrcweir 	SetDesignMode( bInitDesignMode );
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir //------------------------------------------------------------------------
155*cdf0e10cSrcweir FmFormView::~FmFormView()
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	if( pFormShell )
158*cdf0e10cSrcweir 		pFormShell->SetView( NULL );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     pImpl->notifyViewDying();
161*cdf0e10cSrcweir 	pImpl->release();
162*cdf0e10cSrcweir     pImpl = NULL;
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir //------------------------------------------------------------------------
166*cdf0e10cSrcweir FmFormPage* FmFormView::GetCurPage()
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 	SdrPageView* pPageView = GetSdrPageView();
169*cdf0e10cSrcweir 	FmFormPage*  pCurPage = pPageView ? PTR_CAST( FmFormPage, pPageView->GetPage() ) : NULL;
170*cdf0e10cSrcweir     return pCurPage;
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir //------------------------------------------------------------------------
174*cdf0e10cSrcweir void FmFormView::MarkListHasChanged()
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir 	E3dView::MarkListHasChanged();
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	if ( pFormShell && IsDesignMode() )
179*cdf0e10cSrcweir 	{
180*cdf0e10cSrcweir 		FmFormObj* pObj = getMarkedGrid();
181*cdf0e10cSrcweir 		if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj )
182*cdf0e10cSrcweir 		{
183*cdf0e10cSrcweir 			pImpl->m_pMarkedGrid = NULL;
184*cdf0e10cSrcweir 			if ( pImpl->m_xWindow.is() )
185*cdf0e10cSrcweir 			{
186*cdf0e10cSrcweir 				pImpl->m_xWindow->removeFocusListener(pImpl);
187*cdf0e10cSrcweir 				pImpl->m_xWindow = NULL;
188*cdf0e10cSrcweir 			}
189*cdf0e10cSrcweir 			SetMoveOutside(sal_False);
190*cdf0e10cSrcweir 			//OLMRefreshAllIAOManagers();
191*cdf0e10cSrcweir 		}
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 		pFormShell->GetImpl()->SetSelectionDelayed();
194*cdf0e10cSrcweir 	}
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir namespace
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir     const SdrPageWindow* findPageWindow( const SdrPaintView* _pView, OutputDevice* _pWindow )
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir 		SdrPageView* pPageView = _pView->GetSdrPageView();
202*cdf0e10cSrcweir 		if(pPageView)
203*cdf0e10cSrcweir         {
204*cdf0e10cSrcweir             for ( sal_uInt32 window = 0; window < pPageView->PageWindowCount(); ++window )
205*cdf0e10cSrcweir 	        {
206*cdf0e10cSrcweir                 const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( window );
207*cdf0e10cSrcweir                 if ( !pPageWindow || &pPageWindow->GetPaintWindow().GetOutputDevice() != _pWindow )
208*cdf0e10cSrcweir                     continue;
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir                 return pPageWindow;
211*cdf0e10cSrcweir             }
212*cdf0e10cSrcweir         }
213*cdf0e10cSrcweir         return NULL;
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir //------------------------------------------------------------------------
218*cdf0e10cSrcweir void FmFormView::AddWindowToPaintView(OutputDevice* pNewWin)
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	E3dView::AddWindowToPaintView(pNewWin);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     if ( !pNewWin )
223*cdf0e10cSrcweir         return;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     // look up the PageViewWindow for the newly inserted window, and care for it
226*cdf0e10cSrcweir     // #i39269# / 2004-12-20 / frank.schoenheit@sun.com
227*cdf0e10cSrcweir     const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin );
228*cdf0e10cSrcweir     if ( pPageWindow )
229*cdf0e10cSrcweir 		pImpl->addWindow( *pPageWindow );
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir //------------------------------------------------------------------------
233*cdf0e10cSrcweir void FmFormView::DeleteWindowFromPaintView(OutputDevice* pNewWin)
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin );
236*cdf0e10cSrcweir     if ( pPageWindow )
237*cdf0e10cSrcweir 		pImpl->removeWindow( pPageWindow->GetControlContainer() );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     E3dView::DeleteWindowFromPaintView(pNewWin);
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir //------------------------------------------------------------------------
243*cdf0e10cSrcweir void FmFormView::ChangeDesignMode(sal_Bool bDesign)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	if (bDesign == IsDesignMode())
246*cdf0e10cSrcweir 		return;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir 	FmFormModel* pModel = PTR_CAST(FmFormModel, GetModel());
249*cdf0e10cSrcweir 	if (pModel)
250*cdf0e10cSrcweir 	{	// fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
251*cdf0e10cSrcweir 		// Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
252*cdf0e10cSrcweir 		// auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
253*cdf0e10cSrcweir 		// FmXEditModel an seinem Control.)
254*cdf0e10cSrcweir 		pModel->GetUndoEnv().Lock();
255*cdf0e10cSrcweir 	}
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     // --- 1. deactivate all controls if we are switching to design mode
258*cdf0e10cSrcweir 	if ( bDesign )
259*cdf0e10cSrcweir 		DeactivateControls( GetSdrPageView() );
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     // --- 2. simulate a deactivation (the shell will handle some things there ...?)
262*cdf0e10cSrcweir 	if ( pFormShell && pFormShell->GetImpl() )
263*cdf0e10cSrcweir 		pFormShell->GetImpl()->viewDeactivated( *this, sal_True );
264*cdf0e10cSrcweir 	else
265*cdf0e10cSrcweir 		pImpl->Deactivate( sal_True );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir     // --- 3. activate all controls, if we're switching to alive mode
268*cdf0e10cSrcweir 	if ( !bDesign )
269*cdf0e10cSrcweir 		ActivateControls( GetSdrPageView() );
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     // --- 4. load resp. unload the forms
272*cdf0e10cSrcweir 	FmFormPage*  pCurPage = GetCurPage();
273*cdf0e10cSrcweir 	if ( pCurPage )
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		if ( pFormShell && pFormShell->GetImpl() )
276*cdf0e10cSrcweir 			pFormShell->GetImpl()->loadForms( pCurPage, ( bDesign ? FORMS_UNLOAD : FORMS_LOAD ) );
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir     // --- 5. base class functionality
280*cdf0e10cSrcweir 	SetDesignMode( bDesign );
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir     // --- 6. simulate a activation (the shell will handle some things there ...?)
283*cdf0e10cSrcweir     OSL_PRECOND( pFormShell && pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" );
284*cdf0e10cSrcweir 	if ( pFormShell && pFormShell->GetImpl() )
285*cdf0e10cSrcweir 		pFormShell->GetImpl()->viewActivated( *this );
286*cdf0e10cSrcweir 	else
287*cdf0e10cSrcweir 		pImpl->Activate();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	if ( pCurPage )
290*cdf0e10cSrcweir 	{
291*cdf0e10cSrcweir 		if ( bDesign )
292*cdf0e10cSrcweir 		{
293*cdf0e10cSrcweir             if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW )
294*cdf0e10cSrcweir             {
295*cdf0e10cSrcweir                 const Window* pWindow = static_cast< const Window* >( GetActualOutDev() );
296*cdf0e10cSrcweir                 const_cast< Window* >( pWindow )->GrabFocus();
297*cdf0e10cSrcweir             }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 			// redraw UNO objects
300*cdf0e10cSrcweir 			if ( GetSdrPageView() )
301*cdf0e10cSrcweir 			{
302*cdf0e10cSrcweir 				SdrObjListIter aIter(*pCurPage);
303*cdf0e10cSrcweir 				while( aIter.IsMore() )
304*cdf0e10cSrcweir 				{
305*cdf0e10cSrcweir 					SdrObject* pObj = aIter.Next();
306*cdf0e10cSrcweir 					if (pObj && pObj->IsUnoObj())
307*cdf0e10cSrcweir 					{
308*cdf0e10cSrcweir 						// For redraw just use ActionChanged()
309*cdf0e10cSrcweir 						// pObj->BroadcastObjectChange();
310*cdf0e10cSrcweir 						pObj->ActionChanged();
311*cdf0e10cSrcweir 					}
312*cdf0e10cSrcweir 				}
313*cdf0e10cSrcweir 			}
314*cdf0e10cSrcweir 		}
315*cdf0e10cSrcweir 		else
316*cdf0e10cSrcweir 		{
317*cdf0e10cSrcweir 			// set the auto focus to the first control (if indicated by the model to do so)
318*cdf0e10cSrcweir 			sal_Bool bForceControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False;
319*cdf0e10cSrcweir 			if (bForceControlFocus)
320*cdf0e10cSrcweir 				pImpl->AutoFocus();
321*cdf0e10cSrcweir 		}
322*cdf0e10cSrcweir 	}
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	// und mein Undo-Environment wieder an
325*cdf0e10cSrcweir 	if (pModel)
326*cdf0e10cSrcweir 		pModel->GetUndoEnv().UnLock();
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir //------------------------------------------------------------------------
330*cdf0e10cSrcweir void FmFormView::GrabFirstControlFocus( sal_Bool _bForceSync )
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 	if ( !IsDesignMode() )
333*cdf0e10cSrcweir 		pImpl->AutoFocus( _bForceSync );
334*cdf0e10cSrcweir }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir //------------------------------------------------------------------------
337*cdf0e10cSrcweir SdrPageView* FmFormView::ShowSdrPage(SdrPage* pPage)
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir 	SdrPageView* pPV = E3dView::ShowSdrPage(pPage);
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	if (pPage)
342*cdf0e10cSrcweir 	{
343*cdf0e10cSrcweir 		if (!IsDesignMode())
344*cdf0e10cSrcweir 		{
345*cdf0e10cSrcweir 			// creating the controllers
346*cdf0e10cSrcweir 			ActivateControls(pPV);
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 			// Alles deselektieren
349*cdf0e10cSrcweir 			UnmarkAll();
350*cdf0e10cSrcweir 		}
351*cdf0e10cSrcweir 		else if ( pFormShell && pFormShell->IsDesignMode() )
352*cdf0e10cSrcweir 		{
353*cdf0e10cSrcweir 			FmXFormShell* pFormShellImpl = pFormShell->GetImpl();
354*cdf0e10cSrcweir             pFormShellImpl->UpdateForms( sal_True );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 			// damit der Formular-Navigator auf den Seitenwechsel reagieren kann
357*cdf0e10cSrcweir 			pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL , sal_True, sal_False);
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 			pFormShellImpl->SetSelection(GetMarkedObjectList());
360*cdf0e10cSrcweir 		}
361*cdf0e10cSrcweir 	}
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	// notify our shell that we have been activated
364*cdf0e10cSrcweir     if ( pFormShell && pFormShell->GetImpl() )
365*cdf0e10cSrcweir 		pFormShell->GetImpl()->viewActivated( *this );
366*cdf0e10cSrcweir 	else
367*cdf0e10cSrcweir 		pImpl->Activate();
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 	return pPV;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir //------------------------------------------------------------------------
373*cdf0e10cSrcweir void FmFormView::HideSdrPage()
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir     // --- 1. deactivate controls
376*cdf0e10cSrcweir 	if ( !IsDesignMode() )
377*cdf0e10cSrcweir 		DeactivateControls(GetSdrPageView());
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     // --- 2. tell the shell the view is (going to be) deactivated
380*cdf0e10cSrcweir 	if ( pFormShell && pFormShell->GetImpl() )
381*cdf0e10cSrcweir 		pFormShell->GetImpl()->viewDeactivated( *this, sal_True );
382*cdf0e10cSrcweir 	else
383*cdf0e10cSrcweir 		pImpl->Deactivate( sal_True );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     // --- 3. base class behavior
386*cdf0e10cSrcweir     E3dView::HideSdrPage();
387*cdf0e10cSrcweir }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir //------------------------------------------------------------------------
390*cdf0e10cSrcweir SdrModel* FmFormView::GetMarkedObjModel() const
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir 	return E3dView::GetMarkedObjModel();
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir //------------------------------------------------------------------------
396*cdf0e10cSrcweir sal_Bool FmFormView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir 	return E3dView::Paste(rMod, rPos, pLst, nOptions);
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir //------------------------------------------------------------------------
402*cdf0e10cSrcweir void FmFormView::ActivateControls(SdrPageView* pPageView)
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir 	if (!pPageView)
405*cdf0e10cSrcweir         return;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i)
408*cdf0e10cSrcweir 	{
409*cdf0e10cSrcweir 		const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
410*cdf0e10cSrcweir         pImpl->addWindow(rPageWindow);
411*cdf0e10cSrcweir 	}
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir //------------------------------------------------------------------------
415*cdf0e10cSrcweir void FmFormView::DeactivateControls(SdrPageView* pPageView)
416*cdf0e10cSrcweir {
417*cdf0e10cSrcweir 	if( !pPageView )
418*cdf0e10cSrcweir         return;
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i)
421*cdf0e10cSrcweir 	{
422*cdf0e10cSrcweir 		const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
423*cdf0e10cSrcweir         pImpl->removeWindow(rPageWindow.GetControlContainer() );
424*cdf0e10cSrcweir 	}
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir //------------------------------------------------------------------------
428*cdf0e10cSrcweir SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
429*cdf0e10cSrcweir {
430*cdf0e10cSrcweir 	return pImpl->implCreateFieldControl( _rColumnDescriptor );
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir //------------------------------------------------------------------------
434*cdf0e10cSrcweir SdrObject* FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	return pImpl->implCreateXFormsControl(_rDesc);
437*cdf0e10cSrcweir }
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir //------------------------------------------------------------------------
440*cdf0e10cSrcweir SdrObject* FmFormView::CreateFieldControl(const UniString& rFieldDesc) const
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	::rtl::OUString sDataSource		= rFieldDesc.GetToken(0,sal_Unicode(11));
443*cdf0e10cSrcweir 	::rtl::OUString sObjectName		= rFieldDesc.GetToken(1,sal_Unicode(11));
444*cdf0e10cSrcweir 	sal_uInt16 nObjectType			= (sal_uInt16)rFieldDesc.GetToken(2,sal_Unicode(11)).ToInt32();
445*cdf0e10cSrcweir 	::rtl::OUString sFieldName		= rFieldDesc.GetToken(3,sal_Unicode(11));
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	if (!sFieldName.getLength() || !sObjectName.getLength() || !sDataSource.getLength())
448*cdf0e10cSrcweir 		return NULL;
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 	ODataAccessDescriptor aColumnDescriptor;
451*cdf0e10cSrcweir 	aColumnDescriptor.setDataSource(sDataSource);
452*cdf0e10cSrcweir 	aColumnDescriptor[ daCommand ]			<<= sObjectName;
453*cdf0e10cSrcweir 	aColumnDescriptor[ daCommandType ]		<<= nObjectType;
454*cdf0e10cSrcweir 	aColumnDescriptor[ daColumnName ]		<<= sFieldName;
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 	return pImpl->implCreateFieldControl( aColumnDescriptor );
457*cdf0e10cSrcweir }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir //------------------------------------------------------------------------
460*cdf0e10cSrcweir void FmFormView::InsertControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC)
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	if( !IsDesignMode() )
463*cdf0e10cSrcweir 	{
464*cdf0e10cSrcweir 		SdrPageView* pPageView = GetSdrPageView();
465*cdf0e10cSrcweir 		if( pPageView )
466*cdf0e10cSrcweir 		{
467*cdf0e10cSrcweir 			for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ )
468*cdf0e10cSrcweir 			{
469*cdf0e10cSrcweir 				const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 				if( rPageWindow.GetControlContainer( false ) == xCC )
472*cdf0e10cSrcweir 				{
473*cdf0e10cSrcweir 					pImpl->addWindow(rPageWindow);
474*cdf0e10cSrcweir 					break;
475*cdf0e10cSrcweir 				}
476*cdf0e10cSrcweir 			}
477*cdf0e10cSrcweir 		}
478*cdf0e10cSrcweir 	}
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir //------------------------------------------------------------------------
482*cdf0e10cSrcweir void FmFormView::RemoveControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC)
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir 	if( !IsDesignMode() )
485*cdf0e10cSrcweir 	{
486*cdf0e10cSrcweir 		pImpl->removeWindow( xCC );
487*cdf0e10cSrcweir 	}
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir // -----------------------------------------------------------------------------
491*cdf0e10cSrcweir SdrPaintWindow* FmFormView::BeginCompleteRedraw(OutputDevice* pOut)
492*cdf0e10cSrcweir {
493*cdf0e10cSrcweir     SdrPaintWindow* pPaintWindow = E3dView::BeginCompleteRedraw( pOut );
494*cdf0e10cSrcweir     pImpl->suspendTabOrderUpdate();
495*cdf0e10cSrcweir     return pPaintWindow;
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir // -----------------------------------------------------------------------------
499*cdf0e10cSrcweir void FmFormView::EndCompleteRedraw( SdrPaintWindow& rPaintWindow, bool bPaintFormLayer )
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir     E3dView::EndCompleteRedraw( rPaintWindow, bPaintFormLayer );
502*cdf0e10cSrcweir     pImpl->resumeTabOrderUpdate();
503*cdf0e10cSrcweir }
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir // -----------------------------------------------------------------------------
506*cdf0e10cSrcweir sal_Bool FmFormView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
507*cdf0e10cSrcweir {
508*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
509*cdf0e10cSrcweir 	const KeyCode& rKeyCode = rKEvt.GetKeyCode();
510*cdf0e10cSrcweir 	if  (   IsDesignMode()
511*cdf0e10cSrcweir 		&&	rKeyCode.GetCode() == KEY_RETURN
512*cdf0e10cSrcweir         )
513*cdf0e10cSrcweir     {
514*cdf0e10cSrcweir         // RETURN alone enters grid controls, for keyboard accessibility
515*cdf0e10cSrcweir 		if  (   pWin
516*cdf0e10cSrcweir 		    &&	!rKeyCode.IsShift()
517*cdf0e10cSrcweir 		    &&	!rKeyCode.IsMod1()
518*cdf0e10cSrcweir 		    &&	!rKeyCode.IsMod2()
519*cdf0e10cSrcweir             )
520*cdf0e10cSrcweir         {
521*cdf0e10cSrcweir             FmFormObj* pObj = getMarkedGrid();
522*cdf0e10cSrcweir             if ( pObj )
523*cdf0e10cSrcweir             {
524*cdf0e10cSrcweir                 Reference< awt::XWindow > xWindow( pObj->GetUnoControl( *this, *pWin ), UNO_QUERY );
525*cdf0e10cSrcweir                 if ( xWindow.is() )
526*cdf0e10cSrcweir                 {
527*cdf0e10cSrcweir                     pImpl->m_pMarkedGrid = pObj;
528*cdf0e10cSrcweir                     pImpl->m_xWindow = xWindow;
529*cdf0e10cSrcweir                     // add as listener to get notified when ESC will be pressed inside the grid
530*cdf0e10cSrcweir                     pImpl->m_xWindow->addFocusListener(pImpl);
531*cdf0e10cSrcweir                     SetMoveOutside(sal_True);
532*cdf0e10cSrcweir 					//OLMRefreshAllIAOManagers();
533*cdf0e10cSrcweir                     xWindow->setFocus();
534*cdf0e10cSrcweir                     bDone = sal_True;
535*cdf0e10cSrcweir                 }
536*cdf0e10cSrcweir             }
537*cdf0e10cSrcweir         }
538*cdf0e10cSrcweir         // Alt-RETURN alone shows the properties of the selection
539*cdf0e10cSrcweir         if  (   pFormShell
540*cdf0e10cSrcweir             &&  pFormShell->GetImpl()
541*cdf0e10cSrcweir             &&  !rKeyCode.IsShift()
542*cdf0e10cSrcweir 		    &&	!rKeyCode.IsMod1()
543*cdf0e10cSrcweir 		    &&	 rKeyCode.IsMod2()
544*cdf0e10cSrcweir             )
545*cdf0e10cSrcweir         {
546*cdf0e10cSrcweir             pFormShell->GetImpl()->handleShowPropertiesRequest();
547*cdf0e10cSrcweir         }
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir     }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	if ( !bDone )
552*cdf0e10cSrcweir 		bDone = E3dView::KeyInput(rKEvt,pWin);
553*cdf0e10cSrcweir 	return bDone;
554*cdf0e10cSrcweir }
555*cdf0e10cSrcweir // -----------------------------------------------------------------------------
556*cdf0e10cSrcweir sal_Bool FmFormView::checkUnMarkAll(const Reference< XInterface >& _xSource)
557*cdf0e10cSrcweir {
558*cdf0e10cSrcweir 	Reference< ::com::sun::star::awt::XControl> xControl(pImpl->m_xWindow,UNO_QUERY);
559*cdf0e10cSrcweir 	sal_Bool bRet = !xControl.is() || !_xSource.is() || _xSource != xControl->getModel();
560*cdf0e10cSrcweir 	if ( bRet )
561*cdf0e10cSrcweir 		UnmarkAll();
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir 	return bRet;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir // -----------------------------------------------------------------------------
567*cdf0e10cSrcweir sal_Bool FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin )
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir     sal_Bool bReturn = E3dView::MouseButtonDown( _rMEvt, _pWin );
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     if ( pFormShell && pFormShell->GetImpl() )
572*cdf0e10cSrcweir     {
573*cdf0e10cSrcweir         SdrViewEvent aViewEvent;
574*cdf0e10cSrcweir         PickAnything( _rMEvt, SDRMOUSEBUTTONDOWN, aViewEvent );
575*cdf0e10cSrcweir         pFormShell->GetImpl()->handleMouseButtonDown( aViewEvent );
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir     return bReturn;
579*cdf0e10cSrcweir }
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir // -----------------------------------------------------------------------------
582*cdf0e10cSrcweir FmFormObj* FmFormView::getMarkedGrid() const
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir 	FmFormObj* pFormObject = NULL;
585*cdf0e10cSrcweir 	const SdrMarkList& rMarkList = GetMarkedObjectList();
586*cdf0e10cSrcweir 	if ( 1 == rMarkList.GetMarkCount() )
587*cdf0e10cSrcweir 	{
588*cdf0e10cSrcweir 		SdrMark* pMark = rMarkList.GetMark(0);
589*cdf0e10cSrcweir 		if ( pMark )
590*cdf0e10cSrcweir 		{
591*cdf0e10cSrcweir             pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() );
592*cdf0e10cSrcweir 			if ( pFormObject )
593*cdf0e10cSrcweir 			{
594*cdf0e10cSrcweir 				Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY );
595*cdf0e10cSrcweir 				if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) )
596*cdf0e10cSrcweir 					pFormObject = NULL;
597*cdf0e10cSrcweir 			}
598*cdf0e10cSrcweir 		}
599*cdf0e10cSrcweir 	}
600*cdf0e10cSrcweir 	return pFormObject;
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir // -----------------------------------------------------------------------------
604*cdf0e10cSrcweir void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
605*cdf0e10cSrcweir 	const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
606*cdf0e10cSrcweir 	sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix, sal_uInt32 _nInventor, sal_uInt16 _nLabelObjectID,
607*cdf0e10cSrcweir 	SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl )
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	FmXFormView::createControlLabelPair(
610*cdf0e10cSrcweir         ::comphelper::getProcessServiceFactory(),
611*cdf0e10cSrcweir         *_pOutDev, _nXOffsetMM, _nYOffsetMM,
612*cdf0e10cSrcweir 	    _rxField, _rxNumberFormats,
613*cdf0e10cSrcweir 	    _nControlObjectID, _rFieldPostfix, _nInventor, _nLabelObjectID,
614*cdf0e10cSrcweir 	    _pLabelPage, _pControlPage, _pModel,
615*cdf0e10cSrcweir 	    _rpLabel, _rpControl
616*cdf0e10cSrcweir     );
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir // -----------------------------------------------------------------------------
619*cdf0e10cSrcweir Reference< runtime::XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir     return pImpl->getFormController( _rxForm, _rDevice );
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir 
624