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