xref: /aoo41x/main/svx/source/form/navigatortree.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 <svx/dialmgr.hxx>
31*cdf0e10cSrcweir #include <svx/fmshell.hxx>
32*cdf0e10cSrcweir #include <svx/fmmodel.hxx>
33*cdf0e10cSrcweir #include <svx/fmpage.hxx>
34*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
35*cdf0e10cSrcweir #include "svx/svditer.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "fmhelp.hrc"
38*cdf0e10cSrcweir #include "fmexpl.hrc"
39*cdf0e10cSrcweir #include "fmexpl.hxx"
40*cdf0e10cSrcweir #include "svx/fmresids.hrc"
41*cdf0e10cSrcweir #include "fmshimp.hxx"
42*cdf0e10cSrcweir #include "fmservs.hxx"
43*cdf0e10cSrcweir #include "fmundo.hxx"
44*cdf0e10cSrcweir #include "fmpgeimp.hxx"
45*cdf0e10cSrcweir #include "fmitems.hxx"
46*cdf0e10cSrcweir #include "fmobj.hxx"
47*cdf0e10cSrcweir #include "fmprop.hrc"
48*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
49*cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
50*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
51*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
52*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
53*cdf0e10cSrcweir #include <comphelper/property.hxx>
54*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
57*cdf0e10cSrcweir #include <com/sun/star/script/XEventAttacherManager.hpp>
58*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
59*cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
60*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
63*cdf0e10cSrcweir #include <svx/dialogs.hrc> //CHINA001
64*cdf0e10cSrcweir #include <rtl/logfile.hxx>
65*cdf0e10cSrcweir //............................................................................
66*cdf0e10cSrcweir namespace svxform
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir //............................................................................
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	#define DROP_ACTION_TIMER_INITIAL_TICKS     10
71*cdf0e10cSrcweir 		// solange dauert es, bis das Scrollen anspringt
72*cdf0e10cSrcweir 	#define DROP_ACTION_TIMER_SCROLL_TICKS      3
73*cdf0e10cSrcweir 		// in diesen Intervallen wird jeweils eine Zeile gescrollt
74*cdf0e10cSrcweir 	#define DROP_ACTION_TIMER_TICK_BASE         10
75*cdf0e10cSrcweir 		// das ist die Basis, mit der beide Angaben multipliziert werden (in ms)
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	#define EXPLORER_SYNC_DELAY                 200
78*cdf0e10cSrcweir 		// dieser Betrag an Millisekunden wird gewartet, ehe der Explorer nach einem Select oder Deselect die ::com::sun::star::sdbcx::View synchronisiert
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
81*cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
82*cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
83*cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
84*cdf0e10cSrcweir 	using namespace ::com::sun::star::awt;
85*cdf0e10cSrcweir 	using namespace ::com::sun::star::container;
86*cdf0e10cSrcweir 	using namespace ::com::sun::star::script;
87*cdf0e10cSrcweir 	using namespace ::com::sun::star::datatransfer;
88*cdf0e10cSrcweir 	using namespace ::com::sun::star::datatransfer::clipboard;
89*cdf0e10cSrcweir 	using namespace ::com::sun::star::sdb;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	//========================================================================
92*cdf0e10cSrcweir 	// helper
93*cdf0e10cSrcweir 	//========================================================================
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	typedef ::std::map< Reference< XInterface >, SdrObject*, ::comphelper::OInterfaceCompare< XInterface > >
96*cdf0e10cSrcweir 			MapModelToShape;
97*cdf0e10cSrcweir 	typedef MapModelToShape::value_type ModelShapePair;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	//------------------------------------------------------------------------
100*cdf0e10cSrcweir 	void	collectShapeModelMapping( SdrPage* _pPage, MapModelToShape& _rMapping )
101*cdf0e10cSrcweir 	{
102*cdf0e10cSrcweir 		OSL_ENSURE( _pPage, "collectShapeModelMapping: invalid arg!" );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		_rMapping.clear();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 		SdrObjListIter aIter( *_pPage );
107*cdf0e10cSrcweir 		while ( aIter.IsMore() )
108*cdf0e10cSrcweir 		{
109*cdf0e10cSrcweir 			SdrObject* pSdrObject = aIter.Next();
110*cdf0e10cSrcweir             FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
111*cdf0e10cSrcweir             if ( !pFormObject )
112*cdf0e10cSrcweir                 continue;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 			Reference< XInterface > xNormalizedModel( pFormObject->GetUnoControlModel(), UNO_QUERY );
115*cdf0e10cSrcweir 				// note that this is normalized (i.e. queried for XInterface explicitly)
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir #ifdef DBG_UTIL
118*cdf0e10cSrcweir 			::std::pair< MapModelToShape::iterator, bool > aPos =
119*cdf0e10cSrcweir #endif
120*cdf0e10cSrcweir 			_rMapping.insert( ModelShapePair( xNormalizedModel, pSdrObject ) );
121*cdf0e10cSrcweir 			DBG_ASSERT( aPos.second, "collectShapeModelMapping: model was already existent!" );
122*cdf0e10cSrcweir 				// if this asserts, this would mean we have 2 shapes pointing to the same model
123*cdf0e10cSrcweir 		}
124*cdf0e10cSrcweir 	}
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	//------------------------------------------------------------------------
127*cdf0e10cSrcweir 	sal_Bool isModelShapeMarked( FmEntryData* _pEntry, const MapModelToShape& _rModelMap, SdrMarkView* _pView )
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		DBG_ASSERT( _pEntry && _pView, "isModelShapeMarked: invalid arguments!" );
130*cdf0e10cSrcweir 		if ( !_pEntry || !_pView )
131*cdf0e10cSrcweir 			return sal_False;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 		DBG_ASSERT( _pEntry->GetElement().get() == Reference< XInterface >( _pEntry->GetElement(), UNO_QUERY ).get(),
134*cdf0e10cSrcweir 			"isModelShapeMarked: element of the FmEntryData is not normalized!" );
135*cdf0e10cSrcweir 			// normalization of the XInterface is a prerequisite for properly finding it in the map
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 		sal_Bool bIsMarked = sal_False;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		MapModelToShape::const_iterator aPos = _rModelMap.find( _pEntry->GetElement() );
140*cdf0e10cSrcweir 		if ( _rModelMap.end() != aPos )
141*cdf0e10cSrcweir 		{	// there is a shape for this model ....
142*cdf0e10cSrcweir 			bIsMarked = _pView->IsObjMarked( aPos->second );
143*cdf0e10cSrcweir 			if ( !bIsMarked )
144*cdf0e10cSrcweir 			{
145*cdf0e10cSrcweir 				// IsObjMarked does not step down grouped objects, so the sal_False we
146*cdf0e10cSrcweir 				// have is not really reliable (while a sal_True would have been)
147*cdf0e10cSrcweir 				// Okay, travel the mark list, and see if there is a group marked, and our shape
148*cdf0e10cSrcweir 				// is a part of this group
149*cdf0e10cSrcweir 				sal_uInt32 nMarked = _pView->GetMarkedObjectList().GetMarkCount();
150*cdf0e10cSrcweir 				for ( sal_uInt32 i = 0; (i<nMarked ) && !bIsMarked; ++i )
151*cdf0e10cSrcweir 				{
152*cdf0e10cSrcweir 					SdrMark* pMark = _pView->GetMarkedObjectList().GetMark( i );
153*cdf0e10cSrcweir 					SdrObject* pObj = pMark ? pMark->GetMarkedSdrObj() : NULL;
154*cdf0e10cSrcweir 					if ( pObj && pObj->IsGroupObject() )
155*cdf0e10cSrcweir 					{	// the i-th marked shape is a group shape
156*cdf0e10cSrcweir 						SdrObjListIter aIter( *pObj );
157*cdf0e10cSrcweir 						while ( aIter.IsMore() )
158*cdf0e10cSrcweir 						{
159*cdf0e10cSrcweir 							if ( aIter.Next() == aPos->second )
160*cdf0e10cSrcweir 							{
161*cdf0e10cSrcweir 								bIsMarked = sal_True;
162*cdf0e10cSrcweir 								break;
163*cdf0e10cSrcweir 							}
164*cdf0e10cSrcweir 						}
165*cdf0e10cSrcweir 					}
166*cdf0e10cSrcweir 				}
167*cdf0e10cSrcweir 			}
168*cdf0e10cSrcweir 		}
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		return bIsMarked;
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	//========================================================================
174*cdf0e10cSrcweir 	// class NavigatorTree
175*cdf0e10cSrcweir 	//========================================================================
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	//------------------------------------------------------------------------
178*cdf0e10cSrcweir 	NavigatorTree::NavigatorTree( const Reference< XMultiServiceFactory >& _xORB,
179*cdf0e10cSrcweir                            Window* pParent )
180*cdf0e10cSrcweir         :SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HSCROLL ) // #100258# OJ WB_HSCROLL added
181*cdf0e10cSrcweir         ,m_aControlExchange(this)
182*cdf0e10cSrcweir         ,m_xORB(_xORB)
183*cdf0e10cSrcweir         ,m_pNavModel( NULL )
184*cdf0e10cSrcweir         ,m_pRootEntry(NULL)
185*cdf0e10cSrcweir         ,m_pEditEntry(NULL)
186*cdf0e10cSrcweir         ,nEditEvent(0)
187*cdf0e10cSrcweir         ,m_sdiState(SDI_DIRTY)
188*cdf0e10cSrcweir         ,m_aTimerTriggered(-1,-1)
189*cdf0e10cSrcweir         ,m_aDropActionType( DA_SCROLLUP )
190*cdf0e10cSrcweir         ,m_nSelectLock(0)
191*cdf0e10cSrcweir         ,m_nFormsSelected(0)
192*cdf0e10cSrcweir         ,m_nControlsSelected(0)
193*cdf0e10cSrcweir         ,m_nHiddenControls(0)
194*cdf0e10cSrcweir         ,m_aTimerCounter( DROP_ACTION_TIMER_INITIAL_TICKS )
195*cdf0e10cSrcweir         ,m_bDragDataDirty(sal_False)
196*cdf0e10cSrcweir         ,m_bPrevSelectionMixed(sal_False)
197*cdf0e10cSrcweir         ,m_bMarkingObjects(sal_False)
198*cdf0e10cSrcweir         ,m_bRootSelected(sal_False)
199*cdf0e10cSrcweir         ,m_bInitialUpdate(sal_True)
200*cdf0e10cSrcweir         ,m_bKeyboardCut( sal_False )
201*cdf0e10cSrcweir 	{
202*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NavigatorTree" );
203*cdf0e10cSrcweir 		SetHelpId( HID_FORM_NAVIGATOR );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 		m_aNavigatorImages = ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
206*cdf0e10cSrcweir 		m_aNavigatorImagesHC = ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 		SetNodeBitmaps(
209*cdf0e10cSrcweir 			m_aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
210*cdf0e10cSrcweir 			m_aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
211*cdf0e10cSrcweir 			BMP_COLOR_NORMAL
212*cdf0e10cSrcweir 		);
213*cdf0e10cSrcweir 		SetNodeBitmaps(
214*cdf0e10cSrcweir 			m_aNavigatorImagesHC.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
215*cdf0e10cSrcweir 			m_aNavigatorImagesHC.GetImage( RID_SVXIMG_EXPANDEDNODE ),
216*cdf0e10cSrcweir 			BMP_COLOR_HIGHCONTRAST
217*cdf0e10cSrcweir 		);
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 		SetDragDropMode(0xFFFF);
220*cdf0e10cSrcweir 		EnableInplaceEditing( sal_True );
221*cdf0e10cSrcweir 		SetSelectionMode(MULTIPLE_SELECTION);
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 		m_pNavModel = new NavigatorTreeModel( m_aNavigatorImages, m_aNavigatorImagesHC );
224*cdf0e10cSrcweir 		Clear();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		StartListening( *m_pNavModel );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		m_aDropActionTimer.SetTimeoutHdl(LINK(this, NavigatorTree, OnDropActionTimer));
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 		m_aSynchronizeTimer.SetTimeoutHdl(LINK(this, NavigatorTree, OnSynchronizeTimer));
231*cdf0e10cSrcweir 		SetSelectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
232*cdf0e10cSrcweir 		SetDeselectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
233*cdf0e10cSrcweir 	}
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 	//------------------------------------------------------------------------
236*cdf0e10cSrcweir 	NavigatorTree::~NavigatorTree()
237*cdf0e10cSrcweir 	{
238*cdf0e10cSrcweir 		if( nEditEvent )
239*cdf0e10cSrcweir 			Application::RemoveUserEvent( nEditEvent );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir 		if (m_aSynchronizeTimer.IsActive())
242*cdf0e10cSrcweir 			m_aSynchronizeTimer.Stop();
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 		DBG_ASSERT(GetNavModel() != NULL, "NavigatorTree::~NavigatorTree : unerwartet : kein ExplorerModel");
245*cdf0e10cSrcweir 		EndListening( *m_pNavModel );
246*cdf0e10cSrcweir 		Clear();
247*cdf0e10cSrcweir 		delete m_pNavModel;
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 	//------------------------------------------------------------------------
251*cdf0e10cSrcweir 	void NavigatorTree::Clear()
252*cdf0e10cSrcweir 	{
253*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Clear" );
254*cdf0e10cSrcweir 		m_pNavModel->Clear();
255*cdf0e10cSrcweir 	}
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 	//------------------------------------------------------------------------
258*cdf0e10cSrcweir 	void NavigatorTree::UpdateContent( FmFormShell* pFormShell )
259*cdf0e10cSrcweir 	{
260*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UpdateContent" );
261*cdf0e10cSrcweir 		if (m_bInitialUpdate)
262*cdf0e10cSrcweir 		{
263*cdf0e10cSrcweir 			GrabFocus();
264*cdf0e10cSrcweir 			m_bInitialUpdate = sal_False;
265*cdf0e10cSrcweir 		}
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 		FmFormShell* pOldShell = GetNavModel()->GetFormShell();
268*cdf0e10cSrcweir 		FmFormPage* pOldPage = GetNavModel()->GetFormPage();
269*cdf0e10cSrcweir 		FmFormPage* pNewPage = pFormShell ? pFormShell->GetCurPage() : NULL;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 		if ((pOldShell != pFormShell) || (pOldPage != pNewPage))
272*cdf0e10cSrcweir 		{
273*cdf0e10cSrcweir 			// neue Shell, waehrend ich gerade editiere ?
274*cdf0e10cSrcweir 			if (IsEditingActive())
275*cdf0e10cSrcweir 				CancelTextEditing();
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir 			m_bDragDataDirty = sal_True;    // sicherheitshalber, auch wenn ich gar nicht dragge
278*cdf0e10cSrcweir 		}
279*cdf0e10cSrcweir 		GetNavModel()->UpdateContent( pFormShell );
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir 		// wenn es eine Form gibt, die Root expandieren
282*cdf0e10cSrcweir 		if (m_pRootEntry && !IsExpanded(m_pRootEntry))
283*cdf0e10cSrcweir 			Expand(m_pRootEntry);
284*cdf0e10cSrcweir 		// wenn es GENAU eine Form gibt, auch diese expandieren
285*cdf0e10cSrcweir 		if (m_pRootEntry)
286*cdf0e10cSrcweir 		{
287*cdf0e10cSrcweir 			SvLBoxEntry* pFirst = FirstChild(m_pRootEntry);
288*cdf0e10cSrcweir 			if (pFirst && !NextSibling(pFirst))
289*cdf0e10cSrcweir 				Expand(pFirst);
290*cdf0e10cSrcweir 		}
291*cdf0e10cSrcweir 	}
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
294*cdf0e10cSrcweir 	sal_Bool NavigatorTree::implAllowExchange( sal_Int8 _nAction, sal_Bool* _pHasNonHidden )
295*cdf0e10cSrcweir 	{
296*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAllowExchange" );
297*cdf0e10cSrcweir 		SvLBoxEntry* pCurEntry = GetCurEntry();
298*cdf0e10cSrcweir 		if (!pCurEntry)
299*cdf0e10cSrcweir 			return sal_False;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir 		// die Informationen fuer das AcceptDrop und ExecuteDrop
302*cdf0e10cSrcweir 		CollectSelectionData(SDI_ALL);
303*cdf0e10cSrcweir 		if (!m_arrCurrentSelection.Count())
304*cdf0e10cSrcweir 			// nothing to do
305*cdf0e10cSrcweir 			return sal_False;
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 		// testen, ob es sich vielleicht ausschliesslich um hidden controls handelt (dann koennte ich pCtrlExch noch ein
308*cdf0e10cSrcweir 		// zusaetzliches Format geben)
309*cdf0e10cSrcweir 		sal_Bool bHasNonHidden = sal_False;
310*cdf0e10cSrcweir 		for (sal_Int32 i=0; i<m_arrCurrentSelection.Count(); i++)
311*cdf0e10cSrcweir 		{
312*cdf0e10cSrcweir 			FmEntryData* pCurrent = static_cast< FmEntryData* >( m_arrCurrentSelection[(sal_uInt16)i]->GetUserData() );
313*cdf0e10cSrcweir 			if ( IsHiddenControl( pCurrent ) )
314*cdf0e10cSrcweir 				continue;
315*cdf0e10cSrcweir 			bHasNonHidden = sal_True;
316*cdf0e10cSrcweir 			break;
317*cdf0e10cSrcweir 		}
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 		if ( bHasNonHidden && ( 0 == ( _nAction & DND_ACTION_MOVE ) ) )
320*cdf0e10cSrcweir 			// non-hidden controls need to be moved
321*cdf0e10cSrcweir 			return sal_False;
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 		if ( _pHasNonHidden )
324*cdf0e10cSrcweir 			*_pHasNonHidden = bHasNonHidden;
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 		return sal_True;
327*cdf0e10cSrcweir 	}
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
330*cdf0e10cSrcweir 	sal_Bool NavigatorTree::implPrepareExchange( sal_Int8 _nAction )
331*cdf0e10cSrcweir 	{
332*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implPrepareExchange" );
333*cdf0e10cSrcweir 		sal_Int32 i;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 		EndSelection();
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		sal_Bool bHasNonHidden = sal_False;
338*cdf0e10cSrcweir 		if ( !implAllowExchange( _nAction, &bHasNonHidden ) )
339*cdf0e10cSrcweir 			return sal_False;
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 		m_aControlExchange.prepareDrag();
342*cdf0e10cSrcweir 		m_aControlExchange->setFocusEntry( GetCurEntry() );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir 		for ( i = 0; i < m_arrCurrentSelection.Count(); ++i )
345*cdf0e10cSrcweir 			m_aControlExchange->addSelectedEntry(m_arrCurrentSelection[(sal_uInt16)i]);
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 		m_aControlExchange->setFormsRoot( GetNavModel()->GetFormPage()->GetForms() );
348*cdf0e10cSrcweir 		m_aControlExchange->buildPathFormat( this, m_pRootEntry );
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 		if (!bHasNonHidden)
351*cdf0e10cSrcweir 		{
352*cdf0e10cSrcweir 			// eine entsprechende Sequenz aufbauen
353*cdf0e10cSrcweir 			Sequence< Reference< XInterface > > seqIFaces(m_arrCurrentSelection.Count());
354*cdf0e10cSrcweir 			Reference< XInterface >* pArray = seqIFaces.getArray();
355*cdf0e10cSrcweir 			for (i=0; i<m_arrCurrentSelection.Count(); ++i, ++pArray)
356*cdf0e10cSrcweir 				*pArray = static_cast< FmEntryData* >( m_arrCurrentSelection[(sal_uInt16)i]->GetUserData() )->GetElement();
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 			// und das neue Format
359*cdf0e10cSrcweir 			m_aControlExchange->addHiddenControlsFormat(seqIFaces);
360*cdf0e10cSrcweir 		}
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 		m_bDragDataDirty = sal_False;
363*cdf0e10cSrcweir 		return sal_True;
364*cdf0e10cSrcweir 	}
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
367*cdf0e10cSrcweir 	void NavigatorTree::StartDrag( sal_Int8 /*nAction*/, const ::Point& /*rPosPixel*/ )
368*cdf0e10cSrcweir 	{
369*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::StartDrag" );
370*cdf0e10cSrcweir 		EndSelection();
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 		if ( !implPrepareExchange( DND_ACTION_COPYMOVE ) )
373*cdf0e10cSrcweir 			// nothing to do or something went wrong
374*cdf0e10cSrcweir 			return;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir 		// jetzt haben wir alle in der aktuelle Situation moeglichen Formate eingesammelt, es kann also losgehen ...
377*cdf0e10cSrcweir 		m_aControlExchange.startDrag( DND_ACTION_COPYMOVE );
378*cdf0e10cSrcweir 	}
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	//------------------------------------------------------------------------------
381*cdf0e10cSrcweir 	void NavigatorTree::Command( const CommandEvent& rEvt )
382*cdf0e10cSrcweir 	{
383*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Command" );
384*cdf0e10cSrcweir 		sal_Bool bHandled = sal_False;
385*cdf0e10cSrcweir 		switch( rEvt.GetCommand() )
386*cdf0e10cSrcweir 		{
387*cdf0e10cSrcweir 			case COMMAND_CONTEXTMENU:
388*cdf0e10cSrcweir 			{
389*cdf0e10cSrcweir 				// die Stelle, an der geklickt wurde
390*cdf0e10cSrcweir 				::Point ptWhere;
391*cdf0e10cSrcweir 				if (rEvt.IsMouseEvent())
392*cdf0e10cSrcweir 				{
393*cdf0e10cSrcweir 					ptWhere = rEvt.GetMousePosPixel();
394*cdf0e10cSrcweir 					SvLBoxEntry* ptClickedOn = GetEntry(ptWhere);
395*cdf0e10cSrcweir 					if (ptClickedOn == NULL)
396*cdf0e10cSrcweir 						break;
397*cdf0e10cSrcweir 					if ( !IsSelected(ptClickedOn) )
398*cdf0e10cSrcweir 					{
399*cdf0e10cSrcweir 						SelectAll(sal_False);
400*cdf0e10cSrcweir 						Select(ptClickedOn, sal_True);
401*cdf0e10cSrcweir 						SetCurEntry(ptClickedOn);
402*cdf0e10cSrcweir 					}
403*cdf0e10cSrcweir 				}
404*cdf0e10cSrcweir 				else
405*cdf0e10cSrcweir 				{
406*cdf0e10cSrcweir 					if (m_arrCurrentSelection.Count() == 0) // kann nur bei Kontextmenue ueber Tastatur passieren
407*cdf0e10cSrcweir 						break;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 					SvLBoxEntry* pCurrent = GetCurEntry();
410*cdf0e10cSrcweir 					if (!pCurrent)
411*cdf0e10cSrcweir 						break;
412*cdf0e10cSrcweir 					ptWhere = GetEntryPosition(pCurrent);
413*cdf0e10cSrcweir 				}
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 				// meine Selektionsdaten auf den aktuellen Stand
416*cdf0e10cSrcweir 				CollectSelectionData(SDI_ALL);
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 				// wenn mindestens ein Nicht-Root-Eintrag selektiert ist und die Root auch, dann nehme ich letztere aus der Selektion
419*cdf0e10cSrcweir 				// fix wieder raus
420*cdf0e10cSrcweir 				if ( (m_arrCurrentSelection.Count() > 1) && m_bRootSelected )
421*cdf0e10cSrcweir 				{
422*cdf0e10cSrcweir 					Select( m_pRootEntry, sal_False );
423*cdf0e10cSrcweir 					SetCursor( m_arrCurrentSelection.GetObject(0), sal_True);
424*cdf0e10cSrcweir 				}
425*cdf0e10cSrcweir 				sal_Bool bSingleSelection = (m_arrCurrentSelection.Count() == 1);
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir 				DBG_ASSERT( (m_arrCurrentSelection.Count() > 0) || m_bRootSelected, "keine Eintraege selektiert" );
429*cdf0e10cSrcweir 					// solte nicht passieren, da ich oben bei der IsSelected-Abfrage auf jeden Fall einen selektiert haette,
430*cdf0e10cSrcweir 					// wenn das vorher nicht der Fall gewesen waere
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 				// das Menue zusammenbasteln
434*cdf0e10cSrcweir 				FmFormShell* pFormShell = GetNavModel()->GetFormShell();
435*cdf0e10cSrcweir 				FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
436*cdf0e10cSrcweir 				if( pFormShell && pFormModel )
437*cdf0e10cSrcweir 				{
438*cdf0e10cSrcweir 					PopupMenu aContextMenu(SVX_RES(RID_FMEXPLORER_POPUPMENU));
439*cdf0e10cSrcweir 					PopupMenu* pSubMenuNew = aContextMenu.GetPopupMenu( SID_FM_NEW );
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir 					// das 'Neu'-Untermenue gibt es nur, wenn genau die Root oder genau ein Formular selektiert sind
442*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_NEW, bSingleSelection && (m_nFormsSelected || m_bRootSelected) );
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 					// 'Neu'\'Formular' unter genau den selben Bedingungen
445*cdf0e10cSrcweir 					pSubMenuNew->EnableItem( SID_FM_NEW_FORM, bSingleSelection && (m_nFormsSelected || m_bRootSelected) );
446*cdf0e10cSrcweir 					pSubMenuNew->SetItemImage(SID_FM_NEW_FORM, m_aNavigatorImages.GetImage(RID_SVXIMG_FORM));
447*cdf0e10cSrcweir 					pSubMenuNew->SetItemImage(SID_FM_NEW_HIDDEN, m_aNavigatorImages.GetImage(RID_SVXIMG_HIDDEN));
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir 					// 'Neu'\'verstecktes...', wenn genau ein Formular selektiert ist
450*cdf0e10cSrcweir 					pSubMenuNew->EnableItem( SID_FM_NEW_HIDDEN, bSingleSelection && m_nFormsSelected );
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 					// 'Delete': everything which is not root can be removed
453*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_DELETE, !m_bRootSelected );
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 					// 'Cut', 'Copy' and 'Paste'
456*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_CUT, !m_bRootSelected && implAllowExchange( DND_ACTION_MOVE ) );
457*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_COPY, !m_bRootSelected && implAllowExchange( DND_ACTION_COPY ) );
458*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_PASTE, implAcceptPaste( ) );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 					// der TabDialog, wenn es genau ein Formular ist ...
461*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_TAB_DIALOG, bSingleSelection && m_nFormsSelected );
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir                     // in XML forms, we don't allow for the properties of a form
464*cdf0e10cSrcweir                     // #i36484# / 2004-11-04 /- fs@openoffice.org
465*cdf0e10cSrcweir                     if ( pFormShell->GetImpl()->isEnhancedForm() && !m_nControlsSelected )
466*cdf0e10cSrcweir                         aContextMenu.RemoveItem( aContextMenu.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER ) );
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir                     // if the property browser is already open, we don't allow for the properties, too
469*cdf0e10cSrcweir 					if( pFormShell->GetImpl()->IsPropBrwOpen() )
470*cdf0e10cSrcweir 						aContextMenu.RemoveItem( aContextMenu.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER ) );
471*cdf0e10cSrcweir                     // and finally, if there's a mixed selection of forms and controls, disable the entry, too
472*cdf0e10cSrcweir 					else
473*cdf0e10cSrcweir 						aContextMenu.EnableItem( SID_FM_SHOW_PROPERTY_BROWSER,
474*cdf0e10cSrcweir 							(m_nControlsSelected && !m_nFormsSelected) || (!m_nControlsSelected && m_nFormsSelected) );
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir 					// Umbenennen gdw wenn ein Element und nicht die Root
477*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_RENAME_OBJECT, bSingleSelection && !m_bRootSelected );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 					// der Reandonly-Eintrag ist nur auf der Root erlaubt
480*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_OPEN_READONLY, m_bRootSelected );
481*cdf0e10cSrcweir 					// the same for automatic control focus
482*cdf0e10cSrcweir 					aContextMenu.EnableItem( SID_FM_AUTOCONTROLFOCUS, m_bRootSelected );
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir 					// die ConvertTo-Slots sind enabled, wenn genau ein Control selektiert ist, der
485*cdf0e10cSrcweir 					// dem Control entsprechende Slot ist disabled
486*cdf0e10cSrcweir 					if (!m_bRootSelected && !m_nFormsSelected && (m_nControlsSelected == 1))
487*cdf0e10cSrcweir 					{
488*cdf0e10cSrcweir 						aContextMenu.SetPopupMenu( SID_FM_CHANGECONTROLTYPE, FmXFormShell::GetConversionMenu() );
489*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
490*cdf0e10cSrcweir 						FmControlData* pCurrent = (FmControlData*)(m_arrCurrentSelection[0]->GetUserData());
491*cdf0e10cSrcweir                         OSL_ENSURE( pFormShell->GetImpl()->isSolelySelected( pCurrent->GetFormComponent() ),
492*cdf0e10cSrcweir                             "NavigatorTree::Command: inconsistency between the navigator selection, and the selection as the shell knows it!" );
493*cdf0e10cSrcweir #endif
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir                         pFormShell->GetImpl()->checkControlConversionSlotsForCurrentSelection( *aContextMenu.GetPopupMenu( SID_FM_CHANGECONTROLTYPE ) );
496*cdf0e10cSrcweir 					}
497*cdf0e10cSrcweir 					else
498*cdf0e10cSrcweir 						aContextMenu.EnableItem( SID_FM_CHANGECONTROLTYPE, sal_False );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 					// jetzt alles, was disabled wurde, wech
501*cdf0e10cSrcweir 					aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
502*cdf0e10cSrcweir 					//////////////////////////////////////////////////////////
503*cdf0e10cSrcweir 					// OpenReadOnly setzen
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir 					aContextMenu.CheckItem( SID_FM_OPEN_READONLY, pFormModel->GetOpenInDesignMode() );
506*cdf0e10cSrcweir 					aContextMenu.CheckItem( SID_FM_AUTOCONTROLFOCUS, pFormModel->GetAutoControlFocus() );
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir 					sal_uInt16 nSlotId = aContextMenu.Execute( this, ptWhere );
509*cdf0e10cSrcweir 					switch( nSlotId )
510*cdf0e10cSrcweir 					{
511*cdf0e10cSrcweir 						case SID_FM_NEW_FORM:
512*cdf0e10cSrcweir 						{
513*cdf0e10cSrcweir 							XubString aStr(SVX_RES(RID_STR_FORM));
514*cdf0e10cSrcweir 							XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
515*cdf0e10cSrcweir 							aUndoStr.SearchAndReplace('#', aStr);
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 							pFormModel->BegUndo(aUndoStr);
518*cdf0e10cSrcweir 							// der Slot war nur verfuegbar, wenn es genau einen selektierten Eintrag gibt und dieser die Root
519*cdf0e10cSrcweir 							// oder ein Formular ist
520*cdf0e10cSrcweir 							NewForm( m_arrCurrentSelection.GetObject(0) );
521*cdf0e10cSrcweir 							pFormModel->EndUndo();
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 						}   break;
524*cdf0e10cSrcweir 						case SID_FM_NEW_HIDDEN:
525*cdf0e10cSrcweir 						{
526*cdf0e10cSrcweir 							XubString aStr(SVX_RES(RID_STR_CONTROL));
527*cdf0e10cSrcweir 							XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
528*cdf0e10cSrcweir 							aUndoStr.SearchAndReplace('#', aStr);
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 							pFormModel->BegUndo(aUndoStr);
531*cdf0e10cSrcweir 							// dieser Slot war guletig bei (genau) einem selektierten Formular
532*cdf0e10cSrcweir 							rtl::OUString fControlName = FM_COMPONENT_HIDDEN;
533*cdf0e10cSrcweir 							NewControl( fControlName, m_arrCurrentSelection.GetObject(0) );
534*cdf0e10cSrcweir 							pFormModel->EndUndo();
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 						}   break;
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir 						case SID_CUT:
539*cdf0e10cSrcweir 							doCut();
540*cdf0e10cSrcweir 							break;
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 						case SID_COPY:
543*cdf0e10cSrcweir 							doCopy();
544*cdf0e10cSrcweir 							break;
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir 						case SID_PASTE:
547*cdf0e10cSrcweir 							doPaste();
548*cdf0e10cSrcweir 							break;
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 						case SID_FM_DELETE:
551*cdf0e10cSrcweir 						{
552*cdf0e10cSrcweir 							DeleteSelection();
553*cdf0e10cSrcweir 						}
554*cdf0e10cSrcweir 						break;
555*cdf0e10cSrcweir 						case SID_FM_TAB_DIALOG:
556*cdf0e10cSrcweir 						{
557*cdf0e10cSrcweir 							// dieser Slot galt bei genau einem selektierten Formular
558*cdf0e10cSrcweir 							SvLBoxEntry* pSelectedForm = m_arrCurrentSelection.GetObject(0);
559*cdf0e10cSrcweir 							DBG_ASSERT( IsFormEntry(pSelectedForm), "NavigatorTree::Command: Dieser Eintrag muss ein FormEntry sein." );
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 							FmFormData* pFormData = (FmFormData*)pSelectedForm->GetUserData();
562*cdf0e10cSrcweir 							Reference< XForm >  xForm(  pFormData->GetFormIface());
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 							Reference< XTabControllerModel >  xTabController(xForm, UNO_QUERY);
565*cdf0e10cSrcweir 							if( !xTabController.is() )
566*cdf0e10cSrcweir                                 break;
567*cdf0e10cSrcweir                             GetNavModel()->GetFormShell()->GetImpl()->ExecuteTabOrderDialog( xTabController );
568*cdf0e10cSrcweir 						}
569*cdf0e10cSrcweir 						break;
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 						case SID_FM_SHOW_PROPERTY_BROWSER:
572*cdf0e10cSrcweir 						{
573*cdf0e10cSrcweir 							ShowSelectionProperties(sal_True);
574*cdf0e10cSrcweir 						}
575*cdf0e10cSrcweir 						break;
576*cdf0e10cSrcweir 						case SID_FM_RENAME_OBJECT:
577*cdf0e10cSrcweir 						{
578*cdf0e10cSrcweir 							// das war bei genau einem Nicht-Root-Eintrag erlaubt
579*cdf0e10cSrcweir 							EditEntry( m_arrCurrentSelection.GetObject(0) );
580*cdf0e10cSrcweir 						}
581*cdf0e10cSrcweir 						break;
582*cdf0e10cSrcweir 						case SID_FM_OPEN_READONLY:
583*cdf0e10cSrcweir 						{
584*cdf0e10cSrcweir 							pFormModel->SetOpenInDesignMode( !pFormModel->GetOpenInDesignMode() );
585*cdf0e10cSrcweir 							pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
586*cdf0e10cSrcweir 						}
587*cdf0e10cSrcweir 						break;
588*cdf0e10cSrcweir 						case SID_FM_AUTOCONTROLFOCUS:
589*cdf0e10cSrcweir 						{
590*cdf0e10cSrcweir 							pFormModel->SetAutoControlFocus( !pFormModel->GetAutoControlFocus() );
591*cdf0e10cSrcweir 							pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
592*cdf0e10cSrcweir 						}
593*cdf0e10cSrcweir 						break;
594*cdf0e10cSrcweir 						default:
595*cdf0e10cSrcweir 							if (pFormShell->GetImpl()->isControlConversionSlot(nSlotId))
596*cdf0e10cSrcweir 							{
597*cdf0e10cSrcweir 								FmControlData* pCurrent = (FmControlData*)(m_arrCurrentSelection[0]->GetUserData());
598*cdf0e10cSrcweir 								if ( pFormShell->GetImpl()->executeControlConversionSlot( pCurrent->GetFormComponent(), nSlotId ) )
599*cdf0e10cSrcweir 									ShowSelectionProperties();
600*cdf0e10cSrcweir 							}
601*cdf0e10cSrcweir 					}
602*cdf0e10cSrcweir 				}
603*cdf0e10cSrcweir 				bHandled = sal_True;
604*cdf0e10cSrcweir 			} break;
605*cdf0e10cSrcweir 		}
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir 		if (!bHandled)
608*cdf0e10cSrcweir 			SvTreeListBox::Command( rEvt );
609*cdf0e10cSrcweir 	}
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	//------------------------------------------------------------------------
612*cdf0e10cSrcweir 	sal_Bool NavigatorTree::IsDeleteAllowed()
613*cdf0e10cSrcweir 	{
614*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsDeleteAllowed" );
615*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
616*cdf0e10cSrcweir 		// Haben wir eine Form...
617*cdf0e10cSrcweir 		SvLBoxEntry* pCurEntry = GetCurEntry();
618*cdf0e10cSrcweir 		sal_uInt32 nCurEntryPos = GetModel()->GetAbsPos( pCurEntry );
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 		if( nCurEntryPos==0 )           // Root kann nicht geloescht werden
621*cdf0e10cSrcweir 			return sal_False;
622*cdf0e10cSrcweir 		else
623*cdf0e10cSrcweir 			return IsFormEntry(pCurEntry) || IsFormComponentEntry(pCurEntry);
624*cdf0e10cSrcweir 	}
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 	//------------------------------------------------------------------------
627*cdf0e10cSrcweir 	SvLBoxEntry* NavigatorTree::FindEntry( FmEntryData* pEntryData )
628*cdf0e10cSrcweir 	{
629*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::FindEntry" );
630*cdf0e10cSrcweir 		if( !pEntryData ) return NULL;
631*cdf0e10cSrcweir 		SvLBoxEntry* pCurEntry = First();
632*cdf0e10cSrcweir 		FmEntryData* pCurEntryData;
633*cdf0e10cSrcweir 		while( pCurEntry )
634*cdf0e10cSrcweir 		{
635*cdf0e10cSrcweir 			pCurEntryData = (FmEntryData*)pCurEntry->GetUserData();
636*cdf0e10cSrcweir 			if( pCurEntryData && pCurEntryData->IsEqualWithoutChilds(pEntryData) )
637*cdf0e10cSrcweir 				return pCurEntry;
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir 			pCurEntry = Next( pCurEntry );
640*cdf0e10cSrcweir 		}
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 		return NULL;
643*cdf0e10cSrcweir 	}
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	//------------------------------------------------------------------------
646*cdf0e10cSrcweir 	void NavigatorTree::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
647*cdf0e10cSrcweir 	{
648*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Notify" );
649*cdf0e10cSrcweir 		if( rHint.ISA(FmNavRemovedHint) )
650*cdf0e10cSrcweir 		{
651*cdf0e10cSrcweir 			FmNavRemovedHint* pRemovedHint = (FmNavRemovedHint*)&rHint;
652*cdf0e10cSrcweir 			FmEntryData* pEntryData = pRemovedHint->GetEntryData();
653*cdf0e10cSrcweir 			Remove( pEntryData );
654*cdf0e10cSrcweir 		}
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir 		else if( rHint.ISA(FmNavInsertedHint) )
657*cdf0e10cSrcweir 		{
658*cdf0e10cSrcweir 			FmNavInsertedHint* pInsertedHint = (FmNavInsertedHint*)&rHint;
659*cdf0e10cSrcweir 			FmEntryData* pEntryData = pInsertedHint->GetEntryData();
660*cdf0e10cSrcweir 			sal_uInt32 nRelPos = pInsertedHint->GetRelPos();
661*cdf0e10cSrcweir 			Insert( pEntryData, nRelPos );
662*cdf0e10cSrcweir 		}
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir 		else if( rHint.ISA(FmNavModelReplacedHint) )
665*cdf0e10cSrcweir 		{
666*cdf0e10cSrcweir 			FmEntryData* pData = ((FmNavModelReplacedHint*)&rHint)->GetEntryData();
667*cdf0e10cSrcweir 			SvLBoxEntry* pEntry = FindEntry( pData );
668*cdf0e10cSrcweir 			if (pEntry)
669*cdf0e10cSrcweir 			{   // das Image neu setzen
670*cdf0e10cSrcweir 				SetCollapsedEntryBmp( pEntry, pData->GetNormalImage(), BMP_COLOR_NORMAL );
671*cdf0e10cSrcweir 				SetExpandedEntryBmp( pEntry, pData->GetNormalImage(), BMP_COLOR_NORMAL );
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir 				SetCollapsedEntryBmp( pEntry, pData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
674*cdf0e10cSrcweir 				SetExpandedEntryBmp( pEntry, pData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
675*cdf0e10cSrcweir 			}
676*cdf0e10cSrcweir 		}
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 		else if( rHint.ISA(FmNavNameChangedHint) )
679*cdf0e10cSrcweir 		{
680*cdf0e10cSrcweir 			FmNavNameChangedHint* pNameChangedHint = (FmNavNameChangedHint*)&rHint;
681*cdf0e10cSrcweir 			SvLBoxEntry* pEntry = FindEntry( pNameChangedHint->GetEntryData() );
682*cdf0e10cSrcweir 			SetEntryText( pEntry, pNameChangedHint->GetNewName() );
683*cdf0e10cSrcweir 		}
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 		else if( rHint.ISA(FmNavClearedHint) )
686*cdf0e10cSrcweir 		{
687*cdf0e10cSrcweir 			SvTreeListBox::Clear();
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////////////
690*cdf0e10cSrcweir 			// Default-Eintrag "Formulare"
691*cdf0e10cSrcweir 			Image aRootImage( m_aNavigatorImages.GetImage( RID_SVXIMG_FORMS ) );
692*cdf0e10cSrcweir 			m_pRootEntry = InsertEntry( SVX_RES(RID_STR_FORMS), aRootImage, aRootImage,
693*cdf0e10cSrcweir 				NULL, sal_False, 0, NULL );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 			if ( m_pRootEntry )
696*cdf0e10cSrcweir 			{
697*cdf0e10cSrcweir 				Image aHCRootImage( m_aNavigatorImagesHC.GetImage( RID_SVXIMG_FORMS ) );
698*cdf0e10cSrcweir 				SetExpandedEntryBmp( m_pRootEntry, aHCRootImage, BMP_COLOR_HIGHCONTRAST );
699*cdf0e10cSrcweir 				SetCollapsedEntryBmp( m_pRootEntry, aHCRootImage, BMP_COLOR_HIGHCONTRAST );
700*cdf0e10cSrcweir 			}
701*cdf0e10cSrcweir 		}
702*cdf0e10cSrcweir 		else if (!m_bMarkingObjects && rHint.ISA(FmNavRequestSelectHint))
703*cdf0e10cSrcweir 		{   // wenn m_bMarkingObjects sal_True ist, markiere ich gerade selber Objekte, und da der ganze Mechanismus dahinter synchron ist,
704*cdf0e10cSrcweir 			// ist das genau der Hint, der durch mein Markieren ausgeloest wird, also kann ich ihn ignorieren
705*cdf0e10cSrcweir 			FmNavRequestSelectHint* pershHint = (FmNavRequestSelectHint*)&rHint;
706*cdf0e10cSrcweir 			FmEntryDataArray& arredToSelect = pershHint->GetItems();
707*cdf0e10cSrcweir 			SynchronizeSelection(arredToSelect);
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir 			if (pershHint->IsMixedSelection())
710*cdf0e10cSrcweir 				// in diesem Fall habe ich alles deselektiert, obwohl die View u.U. eine gemischte Markierung hatte
711*cdf0e10cSrcweir 				// ich muss also im naechsten Select den Navigator an die View anpassen
712*cdf0e10cSrcweir 				m_bPrevSelectionMixed = sal_True;
713*cdf0e10cSrcweir 		}
714*cdf0e10cSrcweir 	}
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 	//------------------------------------------------------------------------
717*cdf0e10cSrcweir 	SvLBoxEntry* NavigatorTree::Insert( FmEntryData* pEntryData, sal_uIntPtr nRelPos )
718*cdf0e10cSrcweir 	{
719*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Insert" );
720*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
721*cdf0e10cSrcweir 		// Aktuellen Eintrag einfuegen
722*cdf0e10cSrcweir 		SvLBoxEntry* pParentEntry = FindEntry( pEntryData->GetParent() );
723*cdf0e10cSrcweir 		SvLBoxEntry* pNewEntry;
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 		if( !pParentEntry )
726*cdf0e10cSrcweir 			pNewEntry = InsertEntry( pEntryData->GetText(),
727*cdf0e10cSrcweir 				pEntryData->GetNormalImage(), pEntryData->GetNormalImage(),
728*cdf0e10cSrcweir 				m_pRootEntry, sal_False, nRelPos, pEntryData );
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir 		else
731*cdf0e10cSrcweir 			pNewEntry = InsertEntry( pEntryData->GetText(),
732*cdf0e10cSrcweir 				pEntryData->GetNormalImage(), pEntryData->GetNormalImage(),
733*cdf0e10cSrcweir 				pParentEntry, sal_False, nRelPos, pEntryData );
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 		if ( pNewEntry )
736*cdf0e10cSrcweir 		{
737*cdf0e10cSrcweir 			SetExpandedEntryBmp( pNewEntry, pEntryData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
738*cdf0e10cSrcweir 			SetCollapsedEntryBmp( pNewEntry, pEntryData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
739*cdf0e10cSrcweir 		}
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
742*cdf0e10cSrcweir 		// Wenn Root-Eintrag Root expandieren
743*cdf0e10cSrcweir 		if( !pParentEntry )
744*cdf0e10cSrcweir 			Expand( m_pRootEntry );
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
747*cdf0e10cSrcweir 		// Childs einfuegen
748*cdf0e10cSrcweir 		FmEntryDataList* pChildList = pEntryData->GetChildList();
749*cdf0e10cSrcweir 		sal_uInt32 nChildCount = pChildList->Count();
750*cdf0e10cSrcweir 		FmEntryData* pChildData;
751*cdf0e10cSrcweir 		for( sal_uInt32 i=0; i<nChildCount; i++ )
752*cdf0e10cSrcweir 		{
753*cdf0e10cSrcweir 			pChildData = pChildList->GetObject(i);
754*cdf0e10cSrcweir 			Insert( pChildData, LIST_APPEND );
755*cdf0e10cSrcweir 		}
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 		return pNewEntry;
758*cdf0e10cSrcweir 	}
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 	//------------------------------------------------------------------------
761*cdf0e10cSrcweir 	void NavigatorTree::Remove( FmEntryData* pEntryData )
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Remove" );
764*cdf0e10cSrcweir 		if( !pEntryData )
765*cdf0e10cSrcweir 			return;
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 		// der Entry zu den Daten
768*cdf0e10cSrcweir 		SvLBoxEntry* pEntry = FindEntry( pEntryData );
769*cdf0e10cSrcweir 		if (!pEntry)
770*cdf0e10cSrcweir 			return;
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir 		// Eintrag aus TreeListBox entfernen
773*cdf0e10cSrcweir 		// ich darf das Select, das ich ausloese, nicht behandeln :
774*cdf0e10cSrcweir 		// Select aendert die MarkList der View, wenn das gerade auch jemand anders macht und dabei ein Remove
775*cdf0e10cSrcweir 		// triggert, haben wir mit ziemlicher Sicherheit ein Problem - Paradebeispiel war das Gruppieren von Controls mit
776*cdf0e10cSrcweir 		// offenem Navigator ...)
777*cdf0e10cSrcweir 		LockSelectionHandling();
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir 		// ein kleines Problem : ich merke mir meine selektierten Daten, wenn mir jetzt jemand einen selektierten Eintrag
780*cdf0e10cSrcweir 		// unter dem Hintern wegschiesst, werde ich inkonsistent ... was schlecht waere
781*cdf0e10cSrcweir 		Select(pEntry, sal_False);
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 		// beim eigentlichen Entfernen kann die Selection geaendert werden, da ich aber das SelectionHandling abgeschaltet
784*cdf0e10cSrcweir 		// habe, muss ich mich hinterher darum kuemmern
785*cdf0e10cSrcweir 		sal_uIntPtr nExpectedSelectionCount = GetSelectionCount();
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 		if( pEntry )
788*cdf0e10cSrcweir 			GetModel()->Remove( pEntry );
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 		if (nExpectedSelectionCount != GetSelectionCount())
791*cdf0e10cSrcweir 			SynchronizeSelection();
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 		// und standardmaessig behandle ich das Select natuerlich
794*cdf0e10cSrcweir 		UnlockSelectionHandling();
795*cdf0e10cSrcweir 	}
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir 	//------------------------------------------------------------------------
798*cdf0e10cSrcweir 	sal_Bool NavigatorTree::IsFormEntry( SvLBoxEntry* pEntry )
799*cdf0e10cSrcweir 	{
800*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormEntry" );
801*cdf0e10cSrcweir 		FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
802*cdf0e10cSrcweir 		return !pEntryData || pEntryData->ISA(FmFormData);
803*cdf0e10cSrcweir 	}
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir 	//------------------------------------------------------------------------
806*cdf0e10cSrcweir 	sal_Bool NavigatorTree::IsFormComponentEntry( SvLBoxEntry* pEntry )
807*cdf0e10cSrcweir 	{
808*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormComponentEntry" );
809*cdf0e10cSrcweir 		FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
810*cdf0e10cSrcweir 		return pEntryData && pEntryData->ISA(FmControlData);
811*cdf0e10cSrcweir 	}
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir 	//------------------------------------------------------------------------
814*cdf0e10cSrcweir 	sal_Bool NavigatorTree::implAcceptPaste( )
815*cdf0e10cSrcweir 	{
816*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptPaste" );
817*cdf0e10cSrcweir 		SvLBoxEntry* pFirstSelected = FirstSelected();
818*cdf0e10cSrcweir 		if ( !pFirstSelected || NextSelected( pFirstSelected ) )
819*cdf0e10cSrcweir 			// no selected entry, or at least two selected entries
820*cdf0e10cSrcweir 			return sal_False;
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir 		// get the clipboard
823*cdf0e10cSrcweir 		TransferableDataHelper aClipboardContent( TransferableDataHelper::CreateFromSystemClipboard( this ) );
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir 		sal_Int8 nAction = m_aControlExchange.isClipboardOwner() && doingKeyboardCut( ) ? DND_ACTION_MOVE : DND_ACTION_COPY;
826*cdf0e10cSrcweir 		return ( nAction == implAcceptDataTransfer( aClipboardContent.GetDataFlavorExVector(), nAction, pFirstSelected, sal_False ) );
827*cdf0e10cSrcweir 	}
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir 	//------------------------------------------------------------------------
830*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, const ::Point& _rDropPos, sal_Bool _bDnD )
831*cdf0e10cSrcweir 	{
832*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
833*cdf0e10cSrcweir 		return implAcceptDataTransfer( _rFlavors, _nAction, GetEntry( _rDropPos ), _bDnD );
834*cdf0e10cSrcweir 	}
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir 	//------------------------------------------------------------------------
837*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD )
838*cdf0e10cSrcweir 	{
839*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
840*cdf0e10cSrcweir 		// no target -> no drop
841*cdf0e10cSrcweir 		if (!_pTargetEntry)
842*cdf0e10cSrcweir 			return DND_ACTION_NONE;
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 		// format check
845*cdf0e10cSrcweir 		sal_Bool bHasDefControlFormat = OControlExchange::hasFieldExchangeFormat( _rFlavors );
846*cdf0e10cSrcweir 		sal_Bool bHasControlPathFormat = OControlExchange::hasControlPathFormat( _rFlavors );
847*cdf0e10cSrcweir 		sal_Bool bHasHiddenControlsFormat = OControlExchange::hasHiddenControlModelsFormat( _rFlavors );
848*cdf0e10cSrcweir 		if (!bHasDefControlFormat && !bHasControlPathFormat && !bHasHiddenControlsFormat)
849*cdf0e10cSrcweir 			return DND_ACTION_NONE;
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 		sal_Bool bSelfSource = _bDnD ? m_aControlExchange.isDragSource() : m_aControlExchange.isClipboardOwner();
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir 		if ( bHasHiddenControlsFormat )
854*cdf0e10cSrcweir 		{	// bHasHiddenControlsFormat means that only hidden controls are part of the data
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 			// hidden controls can be copied to a form only
857*cdf0e10cSrcweir 			if ( !_pTargetEntry || ( _pTargetEntry == m_pRootEntry ) || !IsFormEntry( _pTargetEntry ) )
858*cdf0e10cSrcweir 				return DND_ACTION_NONE;
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir 			return bSelfSource ? ( DND_ACTION_COPYMOVE & _nAction ) : DND_ACTION_COPY;
861*cdf0e10cSrcweir 		}
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir 		if	( !bSelfSource )
864*cdf0e10cSrcweir 		{
865*cdf0e10cSrcweir 			// DnD or CnP crossing navigator boundaries
866*cdf0e10cSrcweir 			// The main problem here is that the current API does not allow us to sneak into the content which
867*cdf0e10cSrcweir 			// is to be inserted. So we have to allow it for the moment, but maybe reject later on (in the real drop).
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir 			// TODO: this smart behaviour later on ... at the moment, we disallow data transfer crossing navigator
870*cdf0e10cSrcweir 			// boundaries.
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 			return DND_ACTION_NONE;
873*cdf0e10cSrcweir 		}
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir 		DBG_ASSERT( _bDnD ? m_aControlExchange.isDragSource() : m_aControlExchange.isClipboardOwner(),
876*cdf0e10cSrcweir 			"NavigatorTree::implAcceptDataTransfer: here only with source=dest!" );
877*cdf0e10cSrcweir 			// somebody changed the logic of this method ...
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir 		// from here on, I can work with m_aControlExchange instead of _rData!
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 		sal_Bool bForeignCollection = m_aControlExchange->getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
882*cdf0e10cSrcweir 		if ( bForeignCollection )
883*cdf0e10cSrcweir 		{
884*cdf0e10cSrcweir 			// crossing shell/page boundaries, we can exchange hidden controls only
885*cdf0e10cSrcweir 			// But if we survived the checks above, we do not have hidden controls.
886*cdf0e10cSrcweir 			// -> no data transfer
887*cdf0e10cSrcweir 			DBG_ASSERT( !bHasHiddenControlsFormat, "NavigatorTree::implAcceptDataTransfer: still hidden controls format!" );
888*cdf0e10cSrcweir 				// somebody changed the logic of this method ...
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 			return DND_ACTION_COPY;
891*cdf0e10cSrcweir 		}
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 		if (DND_ACTION_MOVE != _nAction) // 'normal' controls within a shell are moved only (never copied)
894*cdf0e10cSrcweir 			return DND_ACTION_NONE;
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir 		if ( m_bDragDataDirty || !bHasDefControlFormat )
897*cdf0e10cSrcweir 		{
898*cdf0e10cSrcweir 			if (!bHasControlPathFormat)
899*cdf0e10cSrcweir 				// ich befinde mich zwar in der Shell/Page, aus der die Controls stammen, habe aber kein Format, das den stattgefundenen
900*cdf0e10cSrcweir 				// Shell-Wechsel ueberlebt hat (SVX_FM_CONTROLS_AS_PATH)
901*cdf0e10cSrcweir 				return DND_ACTION_NONE;
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir 			// da die Shell waehrend des Draggens umgeschaltet wude, muss ich die Liste des ExchangeObjektes wieder neu aufbauen
904*cdf0e10cSrcweir 			// (dort stehen SvLBoxEntries drin, und die sind bei der Umschaltung floeten gegangen)
905*cdf0e10cSrcweir 			m_aControlExchange->buildListFromPath(this, m_pRootEntry);
906*cdf0e10cSrcweir 			m_bDragDataDirty = sal_False;
907*cdf0e10cSrcweir 		}
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir 		// die Liste der gedroppten Eintraege aus dem DragServer
910*cdf0e10cSrcweir         const ListBoxEntrySet& aDropped = m_aControlExchange->selected();
911*cdf0e10cSrcweir 		DBG_ASSERT(aDropped.size() >= 1, "NavigatorTree::implAcceptDataTransfer: keine Eintraege !");
912*cdf0e10cSrcweir 
913*cdf0e10cSrcweir 		sal_Bool bDropTargetIsComponent = IsFormComponentEntry( _pTargetEntry );
914*cdf0e10cSrcweir 		//SvLBoxEntry* pDropTargetParent = GetParent( _pTargetEntry );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 		// conditions to disallow the drop
917*cdf0e10cSrcweir 		// 0) the root entry is part of the list (can't DnD the root!)
918*cdf0e10cSrcweir 		// 1) one of the draged entries is to be dropped onto it's own parent
919*cdf0e10cSrcweir 		// 2) -               "       - is to be dropped onto itself
920*cdf0e10cSrcweir 		// 3) -               "       - is a Form and to be dropped onto one of it's descendants
921*cdf0e10cSrcweir 		// 4) one of the entries is a control and to be dropped onto the root
922*cdf0e10cSrcweir 		// 5) a control or form will be dropped onto a control which is _not_ a sibling (dropping onto a sibling
923*cdf0e10cSrcweir 		//      means moving the control)
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 		// collect the ancestors of the drop targte (speeds up 3)
926*cdf0e10cSrcweir 		SvLBoxEntrySortedArray arrDropAnchestors;
927*cdf0e10cSrcweir 		SvLBoxEntry* pLoop = _pTargetEntry;
928*cdf0e10cSrcweir 		while (pLoop)
929*cdf0e10cSrcweir 		{
930*cdf0e10cSrcweir 			arrDropAnchestors.Insert(pLoop);
931*cdf0e10cSrcweir 			pLoop = GetParent(pLoop);
932*cdf0e10cSrcweir 		}
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir         for (   ListBoxEntrySet::const_iterator dropped = aDropped.begin();
935*cdf0e10cSrcweir                 dropped != aDropped.end();
936*cdf0e10cSrcweir                 ++dropped
937*cdf0e10cSrcweir             )
938*cdf0e10cSrcweir 		{
939*cdf0e10cSrcweir 			SvLBoxEntry* pCurrent = *dropped;
940*cdf0e10cSrcweir 			SvLBoxEntry* pCurrentParent = GetParent(pCurrent);
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir 			// test for 0)
943*cdf0e10cSrcweir 			if (pCurrent == m_pRootEntry)
944*cdf0e10cSrcweir 				return DND_ACTION_NONE;
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 			// test for 1)
947*cdf0e10cSrcweir 			if ( _pTargetEntry == pCurrentParent )
948*cdf0e10cSrcweir 				return DND_ACTION_NONE;
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir 			// test for 2)
951*cdf0e10cSrcweir 			if (pCurrent == _pTargetEntry)
952*cdf0e10cSrcweir 				return DND_ACTION_NONE;
953*cdf0e10cSrcweir 
954*cdf0e10cSrcweir 			// test for 5)
955*cdf0e10cSrcweir 	//      if ( bDropTargetIsComponent && (pDropTargetParent != pCurrentParent) )
956*cdf0e10cSrcweir 				if ( bDropTargetIsComponent )   // TODO : die obige Zeile wieder rein, dann muss aber ExecuteDrop das Vertauschen auch beherrschen
957*cdf0e10cSrcweir 					return DND_ACTION_NONE;
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir 			// test for 3)
960*cdf0e10cSrcweir 			if ( IsFormEntry(pCurrent) )
961*cdf0e10cSrcweir 			{
962*cdf0e10cSrcweir 				sal_uInt16 nPosition;
963*cdf0e10cSrcweir 				if ( arrDropAnchestors.Seek_Entry(pCurrent, &nPosition) )
964*cdf0e10cSrcweir 					return DND_ACTION_NONE;
965*cdf0e10cSrcweir 			} else if ( IsFormComponentEntry(pCurrent) )
966*cdf0e10cSrcweir 			{
967*cdf0e10cSrcweir 				// test for 4)
968*cdf0e10cSrcweir 				if (_pTargetEntry == m_pRootEntry)
969*cdf0e10cSrcweir 					return DND_ACTION_NONE;
970*cdf0e10cSrcweir 			}
971*cdf0e10cSrcweir 		}
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir 		return DND_ACTION_MOVE;
974*cdf0e10cSrcweir 	}
975*cdf0e10cSrcweir 
976*cdf0e10cSrcweir 	//------------------------------------------------------------------------
977*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::AcceptDrop( const AcceptDropEvent& rEvt )
978*cdf0e10cSrcweir 	{
979*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::AcceptDrop" );
980*cdf0e10cSrcweir 		::Point aDropPos = rEvt.maPosPixel;
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir 		// kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
983*cdf0e10cSrcweir 		if (rEvt.mbLeaving)
984*cdf0e10cSrcweir 		{
985*cdf0e10cSrcweir 			if (m_aDropActionTimer.IsActive())
986*cdf0e10cSrcweir 				m_aDropActionTimer.Stop();
987*cdf0e10cSrcweir 		} else
988*cdf0e10cSrcweir 		{
989*cdf0e10cSrcweir 			sal_Bool bNeedTrigger = sal_False;
990*cdf0e10cSrcweir 			// auf dem ersten Eintrag ?
991*cdf0e10cSrcweir 			if ((aDropPos.Y() >= 0) && (aDropPos.Y() < GetEntryHeight()))
992*cdf0e10cSrcweir 			{
993*cdf0e10cSrcweir 				m_aDropActionType = DA_SCROLLUP;
994*cdf0e10cSrcweir 				bNeedTrigger = sal_True;
995*cdf0e10cSrcweir 			} else
996*cdf0e10cSrcweir 				// auf dem letzten (bzw. in dem Bereich, den ein Eintrag einnehmen wuerde, wenn er unten genau buendig
997*cdf0e10cSrcweir 				// abschliessen wuerde) ?
998*cdf0e10cSrcweir 				if ((aDropPos.Y() < GetSizePixel().Height()) && (aDropPos.Y() >= GetSizePixel().Height() - GetEntryHeight()))
999*cdf0e10cSrcweir 				{
1000*cdf0e10cSrcweir 					m_aDropActionType = DA_SCROLLDOWN;
1001*cdf0e10cSrcweir 					bNeedTrigger = sal_True;
1002*cdf0e10cSrcweir 				} else
1003*cdf0e10cSrcweir 				{   // auf einem Entry mit Childs, der nicht aufgeklappt ist ?
1004*cdf0e10cSrcweir 					SvLBoxEntry* pDropppedOn = GetEntry(aDropPos);
1005*cdf0e10cSrcweir 					if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn))
1006*cdf0e10cSrcweir 					{
1007*cdf0e10cSrcweir 						// -> aufklappen
1008*cdf0e10cSrcweir 						m_aDropActionType = DA_EXPANDNODE;
1009*cdf0e10cSrcweir 						bNeedTrigger = sal_True;
1010*cdf0e10cSrcweir 					}
1011*cdf0e10cSrcweir 				}
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir 			if (bNeedTrigger && (m_aTimerTriggered != aDropPos))
1014*cdf0e10cSrcweir 			{
1015*cdf0e10cSrcweir 				// neu anfangen zu zaehlen
1016*cdf0e10cSrcweir 				m_aTimerCounter = DROP_ACTION_TIMER_INITIAL_TICKS;
1017*cdf0e10cSrcweir 				// die Pos merken, da ich auch AcceptDrops bekomme, wenn sich die Maus gar nicht bewegt hat
1018*cdf0e10cSrcweir 				m_aTimerTriggered = aDropPos;
1019*cdf0e10cSrcweir 				// und den Timer los
1020*cdf0e10cSrcweir 				if (!m_aDropActionTimer.IsActive()) // gibt es den Timer schon ?
1021*cdf0e10cSrcweir 				{
1022*cdf0e10cSrcweir 					m_aDropActionTimer.SetTimeout(DROP_ACTION_TIMER_TICK_BASE);
1023*cdf0e10cSrcweir 					m_aDropActionTimer.Start();
1024*cdf0e10cSrcweir 				}
1025*cdf0e10cSrcweir 			} else if (!bNeedTrigger)
1026*cdf0e10cSrcweir 				m_aDropActionTimer.Stop();
1027*cdf0e10cSrcweir 		}
1028*cdf0e10cSrcweir 
1029*cdf0e10cSrcweir 		return implAcceptDataTransfer( GetDataFlavorExVector(), rEvt.mnAction, aDropPos, sal_True );
1030*cdf0e10cSrcweir 	}
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1033*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, const ::Point& _rDropPos, sal_Bool _bDnD )
1034*cdf0e10cSrcweir 	{
1035*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
1036*cdf0e10cSrcweir 		return implExecuteDataTransfer( _rData, _nAction, GetEntry( _rDropPos ), _bDnD );
1037*cdf0e10cSrcweir 	}
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1040*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD )
1041*cdf0e10cSrcweir 	{
1042*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
1043*cdf0e10cSrcweir 		const DataFlavorExVector& rDataFlavors = _rData.GetDataFlavorExVector();
1044*cdf0e10cSrcweir 
1045*cdf0e10cSrcweir 		if ( DND_ACTION_NONE == implAcceptDataTransfer( rDataFlavors, _nAction, _pTargetEntry, _bDnD ) )
1046*cdf0e10cSrcweir 			// under some platforms, it may happen that ExecuteDrop is called though AcceptDrop returned DND_ACTION_NONE
1047*cdf0e10cSrcweir 			return DND_ACTION_NONE;
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir 		// ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
1050*cdf0e10cSrcweir 		if (m_aDropActionTimer.IsActive())
1051*cdf0e10cSrcweir 			m_aDropActionTimer.Stop();
1052*cdf0e10cSrcweir 
1053*cdf0e10cSrcweir 		if (!_pTargetEntry)
1054*cdf0e10cSrcweir 			// no target -> no drop
1055*cdf0e10cSrcweir 			return DND_ACTION_NONE;
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir 		// format checks
1058*cdf0e10cSrcweir #ifdef DBG_UTIL
1059*cdf0e10cSrcweir 		sal_Bool bHasHiddenControlsFormat = OControlExchange::hasHiddenControlModelsFormat( rDataFlavors );
1060*cdf0e10cSrcweir 		sal_Bool bForeignCollection = _rData.getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
1061*cdf0e10cSrcweir 		DBG_ASSERT(!bForeignCollection || bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: invalid format (AcceptDrop shouldn't have let this pass) !");
1062*cdf0e10cSrcweir 		DBG_ASSERT(bForeignCollection || !m_bDragDataDirty, "NavigatorTree::implExecuteDataTransfer: invalid state (shell changed since last exchange resync) !");
1063*cdf0e10cSrcweir 			// das sollte in AcceptDrop erledigt worden sein : dort wird in _rData die Liste der Controls aufgebaut und m_bDragDataDirty
1064*cdf0e10cSrcweir 			// zurueckgesetzt
1065*cdf0e10cSrcweir #endif
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir 		if ( DND_ACTION_COPY == _nAction )
1068*cdf0e10cSrcweir 		{	// bHasHiddenControlsFormat means that only hidden controls are part of the data
1069*cdf0e10cSrcweir 			DBG_ASSERT( bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: copy allowed for hidden controls only!" );
1070*cdf0e10cSrcweir 			DBG_ASSERT( _pTargetEntry && ( _pTargetEntry != m_pRootEntry ) && IsFormEntry( _pTargetEntry ),
1071*cdf0e10cSrcweir 				"NavigatorTree::implExecuteDataTransfer: should not be here!" );
1072*cdf0e10cSrcweir 				// implAcceptDataTransfer should have caught both cases
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir 			DBG_ASSERT(bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: only copying of hidden controls is supported !");
1075*cdf0e10cSrcweir 				// das sollte das AcceptDrop abgefangen haben
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir 			// da ich gleich die Zielobjekte alle selektieren will (und nur die)
1078*cdf0e10cSrcweir 			SelectAll(sal_False);
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir 			Sequence< Reference< XInterface > > aControls = _rData.hiddenControls();
1081*cdf0e10cSrcweir 			sal_Int32 nCount = aControls.getLength();
1082*cdf0e10cSrcweir 			const Reference< XInterface >* pControls = aControls.getConstArray();
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir 			FmFormShell* pFormShell = GetNavModel()->GetFormShell();
1085*cdf0e10cSrcweir 			FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir 			// innerhalb eines Undo ...
1088*cdf0e10cSrcweir 			if (pFormModel)
1089*cdf0e10cSrcweir 			{
1090*cdf0e10cSrcweir 				XubString aStr(SVX_RES(RID_STR_CONTROL));
1091*cdf0e10cSrcweir 				XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
1092*cdf0e10cSrcweir 				aUndoStr.SearchAndReplace('#', aStr);
1093*cdf0e10cSrcweir 				pFormModel->BegUndo(aUndoStr);
1094*cdf0e10cSrcweir 			}
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir 			// die Conrtols kopieren
1097*cdf0e10cSrcweir 			for (sal_Int32 i=0; i<nCount; ++i)
1098*cdf0e10cSrcweir 			{
1099*cdf0e10cSrcweir 				// neues Control anlegen
1100*cdf0e10cSrcweir 				rtl::OUString fControlName = FM_COMPONENT_HIDDEN;
1101*cdf0e10cSrcweir 				FmControlData* pNewControlData = NewControl( fControlName, _pTargetEntry, sal_False);
1102*cdf0e10cSrcweir 				Reference< XPropertySet >  xNewPropSet( pNewControlData->GetPropertySet() );
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir 				// und die Properties des alten in das neue kopieren
1105*cdf0e10cSrcweir 				Reference< XPropertySet >  xCurrent(pControls[i], UNO_QUERY);
1106*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
1107*cdf0e10cSrcweir 				// nur mal eben sehen, ob das Ding tatsaechlich ein hidden control ist
1108*cdf0e10cSrcweir 				sal_Int16 nClassId = ::comphelper::getINT16(xCurrent->getPropertyValue(FM_PROP_CLASSID));
1109*cdf0e10cSrcweir 				OSL_ENSURE(nClassId == FormComponentType::HIDDENCONTROL, "NavigatorTree::implExecuteDataTransfer: invalid control in drop list !");
1110*cdf0e10cSrcweir 					// wenn das SVX_FM_HIDDEN_CONTROLS-Format vorhanden ist, dann sollten wirklich nur hidden controls in der Sequenz
1111*cdf0e10cSrcweir 					// stecken
1112*cdf0e10cSrcweir #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
1113*cdf0e10cSrcweir 				Reference< XPropertySetInfo >  xPropInfo( xCurrent->getPropertySetInfo());
1114*cdf0e10cSrcweir 				Sequence< Property> seqAllCurrentProps = xPropInfo->getProperties();
1115*cdf0e10cSrcweir 				Property* pAllCurrentProps = seqAllCurrentProps.getArray();
1116*cdf0e10cSrcweir 				for (sal_Int32 j=0; j<seqAllCurrentProps.getLength(); ++j)
1117*cdf0e10cSrcweir 				{
1118*cdf0e10cSrcweir 					::rtl::OUString sCurrentProp = pAllCurrentProps[j].Name;
1119*cdf0e10cSrcweir 					if (((pAllCurrentProps[j].Attributes & PropertyAttribute::READONLY) == 0) && (sCurrentProp != FM_PROP_NAME))
1120*cdf0e10cSrcweir 					{   // (read-only attribs werden natuerlich nicht gesetzt, dito der Name, den hat das NewControl schon eindeutig
1121*cdf0e10cSrcweir 						// festgelegt)
1122*cdf0e10cSrcweir 						xNewPropSet->setPropertyValue(sCurrentProp, xCurrent->getPropertyValue(sCurrentProp));
1123*cdf0e10cSrcweir 					}
1124*cdf0e10cSrcweir 				}
1125*cdf0e10cSrcweir 
1126*cdf0e10cSrcweir 				SvLBoxEntry* pToSelect = FindEntry(pNewControlData);
1127*cdf0e10cSrcweir 				Select(pToSelect, sal_True);
1128*cdf0e10cSrcweir 				if (i == 0)
1129*cdf0e10cSrcweir 					SetCurEntry(pToSelect);
1130*cdf0e10cSrcweir 			}
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir 			if (pFormModel)
1133*cdf0e10cSrcweir 				pFormModel->EndUndo();
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir 			return _nAction;
1136*cdf0e10cSrcweir 		}
1137*cdf0e10cSrcweir 
1138*cdf0e10cSrcweir 		if ( !OControlExchange::hasFieldExchangeFormat( _rData.GetDataFlavorExVector() ) )
1139*cdf0e10cSrcweir 		{
1140*cdf0e10cSrcweir 			// can't do anything without the internal format here ... usually happens when doing DnD or CnP
1141*cdf0e10cSrcweir 			// over navigator boundaries
1142*cdf0e10cSrcweir 			return DND_ACTION_NONE;
1143*cdf0e10cSrcweir 		}
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir 		// some data for the target
1146*cdf0e10cSrcweir 		sal_Bool bDropTargetIsForm = IsFormEntry(_pTargetEntry);
1147*cdf0e10cSrcweir 		FmFormData* pTargetData = bDropTargetIsForm ? (FmFormData*)_pTargetEntry->GetUserData() : NULL;
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir 		DBG_ASSERT( DND_ACTION_COPY != _nAction, "NavigatorTree::implExecuteDataTransfer: somebody changed the logics!" );
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir 		// die Liste der gedraggten Eintraege
1152*cdf0e10cSrcweir 		ListBoxEntrySet aDropped = _rData.selected();
1153*cdf0e10cSrcweir 		DBG_ASSERT(aDropped.size() >= 1, "NavigatorTree::implExecuteDataTransfer: no entries!");
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir 		// die Shell und das Model
1156*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
1157*cdf0e10cSrcweir 		FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
1158*cdf0e10cSrcweir 		if (!pFormModel)
1159*cdf0e10cSrcweir 			return DND_ACTION_NONE;
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir 		// fuer's Undo
1162*cdf0e10cSrcweir 		const bool bUndo = pFormModel->IsUndoEnabled();
1163*cdf0e10cSrcweir 
1164*cdf0e10cSrcweir 		if( bUndo )
1165*cdf0e10cSrcweir 		{
1166*cdf0e10cSrcweir 			XubString strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE));
1167*cdf0e10cSrcweir 			pFormModel->BegUndo(strUndoDescription);
1168*cdf0e10cSrcweir 		}
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir 		// ich nehme vor dem Einfuegen eines Eintrages seine Selection raus, damit die Markierung dabei nicht flackert
1171*cdf0e10cSrcweir 		// -> das Handeln des Select locken
1172*cdf0e10cSrcweir 		LockSelectionHandling();
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir 		// jetzt durch alle gedroppten Eintraege ...
1175*cdf0e10cSrcweir         for (   ListBoxEntrySet::const_iterator dropped = aDropped.begin();
1176*cdf0e10cSrcweir                 dropped != aDropped.end();
1177*cdf0e10cSrcweir                 ++dropped
1178*cdf0e10cSrcweir             )
1179*cdf0e10cSrcweir 		{
1180*cdf0e10cSrcweir 			// ein paar Daten zum aktuellen Element
1181*cdf0e10cSrcweir 			SvLBoxEntry* pCurrent = *dropped;
1182*cdf0e10cSrcweir 			DBG_ASSERT(pCurrent != NULL, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
1183*cdf0e10cSrcweir 			DBG_ASSERT(GetParent(pCurrent) != NULL, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
1184*cdf0e10cSrcweir 				// die Root darf nicht gedraggt werden
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir 			FmEntryData* pCurrentUserData = (FmEntryData*)pCurrent->GetUserData();
1187*cdf0e10cSrcweir 
1188*cdf0e10cSrcweir 			Reference< XChild >  xCurrentChild(pCurrentUserData->GetChildIFace(), UNO_QUERY);
1189*cdf0e10cSrcweir 			Reference< XIndexContainer >  xContainer(xCurrentChild->getParent(), UNO_QUERY);
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir 			FmFormData* pCurrentParentUserData = (FmFormData*)pCurrentUserData->GetParent();
1192*cdf0e10cSrcweir 			DBG_ASSERT(pCurrentParentUserData == NULL || pCurrentParentUserData->ISA(FmFormData), "NavigatorTree::implExecuteDataTransfer: ungueltiges Parent");
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir 			// beim Vater austragen
1195*cdf0e10cSrcweir 			if (pCurrentParentUserData)
1196*cdf0e10cSrcweir 				pCurrentParentUserData->GetChildList()->Remove(pCurrentUserData);
1197*cdf0e10cSrcweir 			else
1198*cdf0e10cSrcweir 				GetNavModel()->GetRootList()->Remove(pCurrentUserData);
1199*cdf0e10cSrcweir 
1200*cdf0e10cSrcweir 			// aus dem Container entfernen
1201*cdf0e10cSrcweir 			sal_Int32 nIndex = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xCurrentChild);
1202*cdf0e10cSrcweir 			GetNavModel()->m_pPropChangeList->Lock();
1203*cdf0e10cSrcweir 			// die Undo-Action fuer das Rausnehmen
1204*cdf0e10cSrcweir 			if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
1205*cdf0e10cSrcweir 			{
1206*cdf0e10cSrcweir 				pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Removed,
1207*cdf0e10cSrcweir 															xContainer, xCurrentChild, nIndex));
1208*cdf0e10cSrcweir 			}
1209*cdf0e10cSrcweir 			else if( !GetNavModel()->m_pPropChangeList->CanUndo() )
1210*cdf0e10cSrcweir 			{
1211*cdf0e10cSrcweir 				FmUndoContainerAction::DisposeElement( xCurrentChild );
1212*cdf0e10cSrcweir 			}
1213*cdf0e10cSrcweir 
1214*cdf0e10cSrcweir 			// Events mitkopieren
1215*cdf0e10cSrcweir 			Reference< XEventAttacherManager >  xManager(xContainer, UNO_QUERY);
1216*cdf0e10cSrcweir 			Sequence< ScriptEventDescriptor > aEvts;
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir 			if (xManager.is() && nIndex >= 0)
1219*cdf0e10cSrcweir 				aEvts = xManager->getScriptEvents(nIndex);
1220*cdf0e10cSrcweir 			xContainer->removeByIndex(nIndex);
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir 			// die Selection raus
1223*cdf0e10cSrcweir 			Select(pCurrent, sal_False);
1224*cdf0e10cSrcweir 			// und weg
1225*cdf0e10cSrcweir 			Remove(pCurrentUserData);
1226*cdf0e10cSrcweir 
1227*cdf0e10cSrcweir 			// die Stelle innerhalb des DropParents, an der ich die gedroppten Eintraege einfuegen muss
1228*cdf0e10cSrcweir 			if (pTargetData)
1229*cdf0e10cSrcweir 				xContainer = Reference< XIndexContainer > (pTargetData->GetElement(), UNO_QUERY);
1230*cdf0e10cSrcweir 			else
1231*cdf0e10cSrcweir 				xContainer = Reference< XIndexContainer > (GetNavModel()->GetForms(), UNO_QUERY);
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir 			// immer ganz hinten einfuegen
1234*cdf0e10cSrcweir 			nIndex = xContainer->getCount();
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir 			// UndoAction fuer das Einfuegen
1237*cdf0e10cSrcweir 			if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
1238*cdf0e10cSrcweir 				pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Inserted,
1239*cdf0e10cSrcweir 														 xContainer, xCurrentChild, nIndex));
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir 			// einfuegen im neuen Container
1242*cdf0e10cSrcweir 			if (pTargetData)
1243*cdf0e10cSrcweir 			{
1244*cdf0e10cSrcweir 				 // es wird in eine Form eingefuegt, dann brauche ich eine FormComponent
1245*cdf0e10cSrcweir 				xContainer->insertByIndex( nIndex,
1246*cdf0e10cSrcweir 					makeAny( Reference< XFormComponent >( xCurrentChild, UNO_QUERY ) ) );
1247*cdf0e10cSrcweir 			}
1248*cdf0e10cSrcweir 			else
1249*cdf0e10cSrcweir 			{
1250*cdf0e10cSrcweir 				xContainer->insertByIndex( nIndex,
1251*cdf0e10cSrcweir 					makeAny( Reference< XForm >( xCurrentChild, UNO_QUERY ) ) );
1252*cdf0e10cSrcweir 			}
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir 			if (aEvts.getLength())
1255*cdf0e10cSrcweir 			{
1256*cdf0e10cSrcweir 				xManager = Reference< XEventAttacherManager > (xContainer, UNO_QUERY);
1257*cdf0e10cSrcweir 				if (xManager.is())
1258*cdf0e10cSrcweir 					xManager->registerScriptEvents(nIndex, aEvts);
1259*cdf0e10cSrcweir 			}
1260*cdf0e10cSrcweir 
1261*cdf0e10cSrcweir 			GetNavModel()->m_pPropChangeList->UnLock();
1262*cdf0e10cSrcweir 
1263*cdf0e10cSrcweir 			// zuerst dem Eintrag das neue Parent
1264*cdf0e10cSrcweir 			pCurrentUserData->SetParent(pTargetData);
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir 			// dann dem Parent das neue Child
1267*cdf0e10cSrcweir 			if (pTargetData)
1268*cdf0e10cSrcweir 				pTargetData->GetChildList()->Insert(pCurrentUserData, nIndex);
1269*cdf0e10cSrcweir 			else
1270*cdf0e10cSrcweir 				GetNavModel()->GetRootList()->Insert(pCurrentUserData, nIndex);
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 			// dann bei mir selber bekanntgeben und neu selektieren
1273*cdf0e10cSrcweir 			SvLBoxEntry* pNew = Insert( pCurrentUserData, nIndex );
1274*cdf0e10cSrcweir 			if ( ( aDropped.begin() == dropped ) && pNew )
1275*cdf0e10cSrcweir 			{
1276*cdf0e10cSrcweir 				SvLBoxEntry* pParent = GetParent( pNew );
1277*cdf0e10cSrcweir 				if ( pParent )
1278*cdf0e10cSrcweir 					Expand( pParent );
1279*cdf0e10cSrcweir 			}
1280*cdf0e10cSrcweir 		}
1281*cdf0e10cSrcweir 
1282*cdf0e10cSrcweir 		UnlockSelectionHandling();
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir 		if( bUndo )
1285*cdf0e10cSrcweir 			pFormModel->EndUndo();
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir 		// During the move, the markings of the underlying view did not change (because the view is not affected by the logical
1288*cdf0e10cSrcweir 		// hierarchy of the form/control models. But my selection changed - which means I have to adjust it according to the
1289*cdf0e10cSrcweir 		// view marks, again.
1290*cdf0e10cSrcweir 		SynchronizeSelection();
1291*cdf0e10cSrcweir 
1292*cdf0e10cSrcweir 		// in addition, with the move of controls such things as "the current form" may have changed - force the shell
1293*cdf0e10cSrcweir 		// to update itself accordingly
1294*cdf0e10cSrcweir 		if( pFormShell && pFormShell->GetImpl() && pFormShell->GetFormView() )
1295*cdf0e10cSrcweir 			pFormShell->GetImpl()->DetermineSelection( pFormShell->GetFormView()->GetMarkedObjectList() );
1296*cdf0e10cSrcweir 
1297*cdf0e10cSrcweir 		if ( m_aControlExchange.isClipboardOwner() && ( DND_ACTION_MOVE == _nAction ) )
1298*cdf0e10cSrcweir 			m_aControlExchange->clear();
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir 		return _nAction;
1301*cdf0e10cSrcweir 	}
1302*cdf0e10cSrcweir 
1303*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1304*cdf0e10cSrcweir 	sal_Int8 NavigatorTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
1305*cdf0e10cSrcweir 	{
1306*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ExecuteDrop" );
1307*cdf0e10cSrcweir 		sal_Int8 nResult( DND_ACTION_NONE );
1308*cdf0e10cSrcweir 
1309*cdf0e10cSrcweir 		if ( m_aControlExchange.isDragSource() )
1310*cdf0e10cSrcweir 			nResult = implExecuteDataTransfer( *m_aControlExchange, rEvt.mnAction, rEvt.maPosPixel, sal_True );
1311*cdf0e10cSrcweir 		else
1312*cdf0e10cSrcweir 		{
1313*cdf0e10cSrcweir 			OControlTransferData aDroppedData( rEvt.maDropEvent.Transferable );
1314*cdf0e10cSrcweir 			nResult = implExecuteDataTransfer( aDroppedData, rEvt.mnAction, rEvt.maPosPixel, sal_True );
1315*cdf0e10cSrcweir 		}
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir 		return nResult;
1318*cdf0e10cSrcweir 	}
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1321*cdf0e10cSrcweir 	void NavigatorTree::doPaste()
1322*cdf0e10cSrcweir 	{
1323*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doPaste" );
1324*cdf0e10cSrcweir    		try
1325*cdf0e10cSrcweir     	{
1326*cdf0e10cSrcweir 			if ( m_aControlExchange.isClipboardOwner() )
1327*cdf0e10cSrcweir 			{
1328*cdf0e10cSrcweir 				implExecuteDataTransfer( *m_aControlExchange, doingKeyboardCut( ) ? DND_ACTION_MOVE : DND_ACTION_COPY, FirstSelected(), sal_False );
1329*cdf0e10cSrcweir 			}
1330*cdf0e10cSrcweir 			else
1331*cdf0e10cSrcweir 			{
1332*cdf0e10cSrcweir 				// the clipboard content
1333*cdf0e10cSrcweir 				Reference< XClipboard >	xClipboard( GetClipboard() );
1334*cdf0e10cSrcweir 				Reference< XTransferable > xTransferable;
1335*cdf0e10cSrcweir 				if ( xClipboard.is() )
1336*cdf0e10cSrcweir 	    			xTransferable = xClipboard->getContents();
1337*cdf0e10cSrcweir 
1338*cdf0e10cSrcweir 				OControlTransferData aClipboardContent( xTransferable );
1339*cdf0e10cSrcweir 				implExecuteDataTransfer( aClipboardContent, DND_ACTION_COPY, FirstSelected(), sal_False );
1340*cdf0e10cSrcweir 			}
1341*cdf0e10cSrcweir 		}
1342*cdf0e10cSrcweir 		catch( const Exception& )
1343*cdf0e10cSrcweir 		{
1344*cdf0e10cSrcweir 			DBG_ERROR( "NavigatorTree::doPaste: caught an exception!" );
1345*cdf0e10cSrcweir 		}
1346*cdf0e10cSrcweir 	}
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1349*cdf0e10cSrcweir 	void NavigatorTree::doCopy()
1350*cdf0e10cSrcweir 	{
1351*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCopy" );
1352*cdf0e10cSrcweir 		if ( implPrepareExchange( DND_ACTION_COPY ) )
1353*cdf0e10cSrcweir 		{
1354*cdf0e10cSrcweir 			m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) );
1355*cdf0e10cSrcweir 			m_aControlExchange.copyToClipboard( );
1356*cdf0e10cSrcweir 		}
1357*cdf0e10cSrcweir 	}
1358*cdf0e10cSrcweir 
1359*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1360*cdf0e10cSrcweir 	void NavigatorTree::ModelHasRemoved( SvListEntry* _pEntry )
1361*cdf0e10cSrcweir 	{
1362*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ModelHasRemoved" );
1363*cdf0e10cSrcweir         SvLBoxEntry* pTypedEntry = static_cast< SvLBoxEntry* >( _pEntry );
1364*cdf0e10cSrcweir         if ( doingKeyboardCut() )
1365*cdf0e10cSrcweir             m_aCutEntries.erase( pTypedEntry );
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir         if ( m_aControlExchange.isDataExchangeActive() )
1368*cdf0e10cSrcweir         {
1369*cdf0e10cSrcweir             if ( 0 == m_aControlExchange->onEntryRemoved( pTypedEntry ) )
1370*cdf0e10cSrcweir             {
1371*cdf0e10cSrcweir                 // last of the entries which we put into the clipboard has been deleted from the tree.
1372*cdf0e10cSrcweir                 // Give up the clipboard ownership.
1373*cdf0e10cSrcweir                 m_aControlExchange.clear();
1374*cdf0e10cSrcweir             }
1375*cdf0e10cSrcweir         }
1376*cdf0e10cSrcweir 	}
1377*cdf0e10cSrcweir 
1378*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1379*cdf0e10cSrcweir 	void NavigatorTree::doCut()
1380*cdf0e10cSrcweir 	{
1381*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCut" );
1382*cdf0e10cSrcweir 		if ( implPrepareExchange( DND_ACTION_MOVE ) )
1383*cdf0e10cSrcweir 		{
1384*cdf0e10cSrcweir 			m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) );
1385*cdf0e10cSrcweir 			m_aControlExchange.copyToClipboard( );
1386*cdf0e10cSrcweir 			m_bKeyboardCut = sal_True;
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir 			// mark all the entries we just "cut" into the clipboard as "nearly moved"
1389*cdf0e10cSrcweir 			for ( sal_Int32 i=0; i<m_arrCurrentSelection.Count(); ++i )
1390*cdf0e10cSrcweir 			{
1391*cdf0e10cSrcweir 				SvLBoxEntry* pEntry = m_arrCurrentSelection[ (sal_uInt16)i ];
1392*cdf0e10cSrcweir 				if ( pEntry )
1393*cdf0e10cSrcweir 				{
1394*cdf0e10cSrcweir 					m_aCutEntries.insert( pEntry );
1395*cdf0e10cSrcweir 					pEntry->SetFlags( pEntry->GetFlags() | SV_ENTRYFLAG_SEMITRANSPARENT );
1396*cdf0e10cSrcweir 					InvalidateEntry( pEntry );
1397*cdf0e10cSrcweir 				}
1398*cdf0e10cSrcweir 			}
1399*cdf0e10cSrcweir 		}
1400*cdf0e10cSrcweir 	}
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1403*cdf0e10cSrcweir 	void NavigatorTree::KeyInput(const ::KeyEvent& rKEvt)
1404*cdf0e10cSrcweir 	{
1405*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::KeyInput" );
1406*cdf0e10cSrcweir 		const KeyCode& rCode = rKEvt.GetKeyCode();
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir 		// delete?
1409*cdf0e10cSrcweir 		if (rKEvt.GetKeyCode().GetCode() == KEY_DELETE && !rKEvt.GetKeyCode().GetModifier())
1410*cdf0e10cSrcweir 		{
1411*cdf0e10cSrcweir 			DeleteSelection();
1412*cdf0e10cSrcweir 			return;
1413*cdf0e10cSrcweir 		}
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir 		// copy'n'paste?
1416*cdf0e10cSrcweir 		switch ( rCode.GetFunction() )
1417*cdf0e10cSrcweir 		{
1418*cdf0e10cSrcweir 			case KEYFUNC_CUT:
1419*cdf0e10cSrcweir 				doCut();
1420*cdf0e10cSrcweir 				break;
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir 			case KEYFUNC_PASTE:
1423*cdf0e10cSrcweir 				if ( implAcceptPaste() )
1424*cdf0e10cSrcweir 					doPaste();
1425*cdf0e10cSrcweir 				break;
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir 			case KEYFUNC_COPY:
1428*cdf0e10cSrcweir 				doCopy();
1429*cdf0e10cSrcweir 				break;
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir             default:
1432*cdf0e10cSrcweir                 break;
1433*cdf0e10cSrcweir 		}
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir 		SvTreeListBox::KeyInput(rKEvt);
1436*cdf0e10cSrcweir 	}
1437*cdf0e10cSrcweir 
1438*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1439*cdf0e10cSrcweir 	sal_Bool NavigatorTree::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection )
1440*cdf0e10cSrcweir 	{
1441*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditingEntry" );
1442*cdf0e10cSrcweir 		if (!SvTreeListBox::EditingEntry( pEntry, rSelection ))
1443*cdf0e10cSrcweir 			return sal_False;
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir 		return (pEntry && (pEntry->GetUserData() != NULL));
1446*cdf0e10cSrcweir 			// die Wurzel, die ich nicht umbenennen darf, hat als UserData NULL
1447*cdf0e10cSrcweir 	}
1448*cdf0e10cSrcweir 
1449*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1450*cdf0e10cSrcweir 	void NavigatorTree::NewForm( SvLBoxEntry* pParentEntry )
1451*cdf0e10cSrcweir 	{
1452*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewForm" );
1453*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1454*cdf0e10cSrcweir 		// ParentFormData holen
1455*cdf0e10cSrcweir 		if( !IsFormEntry(pParentEntry) )
1456*cdf0e10cSrcweir 			return;
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir 		FmFormData* pParentFormData = (FmFormData*)pParentEntry->GetUserData();
1459*cdf0e10cSrcweir 
1460*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1461*cdf0e10cSrcweir 		// Neue Form erzeugen
1462*cdf0e10cSrcweir 		Reference< XForm >  xNewForm(m_xORB->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
1463*cdf0e10cSrcweir 		if (!xNewForm.is())
1464*cdf0e10cSrcweir 			return;
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir 		FmFormData* pNewFormData = new FmFormData( xNewForm, m_aNavigatorImages, m_aNavigatorImagesHC, pParentFormData );
1467*cdf0e10cSrcweir 
1468*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1469*cdf0e10cSrcweir 		// Namen setzen
1470*cdf0e10cSrcweir 		::rtl::OUString aName = GenerateName(pNewFormData);
1471*cdf0e10cSrcweir 		pNewFormData->SetText(aName);
1472*cdf0e10cSrcweir 
1473*cdf0e10cSrcweir 		Reference< XPropertySet >  xPropertySet(xNewForm, UNO_QUERY);
1474*cdf0e10cSrcweir 		if (!xPropertySet.is())
1475*cdf0e10cSrcweir 			return;
1476*cdf0e10cSrcweir 		try
1477*cdf0e10cSrcweir 		{
1478*cdf0e10cSrcweir 			xPropertySet->setPropertyValue( FM_PROP_NAME, makeAny(aName) );
1479*cdf0e10cSrcweir 			// a form should always have the command type table as default
1480*cdf0e10cSrcweir 			xPropertySet->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE)));
1481*cdf0e10cSrcweir 		}
1482*cdf0e10cSrcweir 		catch ( const Exception& )
1483*cdf0e10cSrcweir 		{
1484*cdf0e10cSrcweir 			DBG_ERROR("NavigatorTree::NewForm : could not set esssential properties !");
1485*cdf0e10cSrcweir 		}
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1489*cdf0e10cSrcweir 		// Form einfuegen
1490*cdf0e10cSrcweir 		GetNavModel()->Insert( pNewFormData, LIST_APPEND, sal_True );
1491*cdf0e10cSrcweir 
1492*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1493*cdf0e10cSrcweir 		// Neue Form als aktive Form setzen
1494*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
1495*cdf0e10cSrcweir 		if( pFormShell )
1496*cdf0e10cSrcweir 		{
1497*cdf0e10cSrcweir             InterfaceBag aSelection;
1498*cdf0e10cSrcweir             aSelection.insert( Reference< XInterface >( xNewForm, UNO_QUERY ) );
1499*cdf0e10cSrcweir 			pFormShell->GetImpl()->setCurrentSelection( aSelection );
1500*cdf0e10cSrcweir 
1501*cdf0e10cSrcweir 			pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_PROPERTIES,sal_True,sal_True);
1502*cdf0e10cSrcweir 		}
1503*cdf0e10cSrcweir 		GetNavModel()->SetModified();
1504*cdf0e10cSrcweir 
1505*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1506*cdf0e10cSrcweir 		// In EditMode schalten
1507*cdf0e10cSrcweir 		SvLBoxEntry* pNewEntry = FindEntry( pNewFormData );
1508*cdf0e10cSrcweir 		EditEntry( pNewEntry );
1509*cdf0e10cSrcweir 	}
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1512*cdf0e10cSrcweir 	FmControlData* NavigatorTree::NewControl( const ::rtl::OUString& rServiceName, SvLBoxEntry* pParentEntry, sal_Bool bEditName )
1513*cdf0e10cSrcweir 	{
1514*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewControl" );
1515*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1516*cdf0e10cSrcweir 		// ParentForm holen
1517*cdf0e10cSrcweir 		if (!GetNavModel()->GetFormShell())
1518*cdf0e10cSrcweir 			return NULL;
1519*cdf0e10cSrcweir 		if (!IsFormEntry(pParentEntry))
1520*cdf0e10cSrcweir 			return NULL;
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir 		FmFormData* pParentFormData = (FmFormData*)pParentEntry->GetUserData();;
1523*cdf0e10cSrcweir 		Reference< XForm >  xParentForm( pParentFormData->GetFormIface());
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1526*cdf0e10cSrcweir 		// Neue Component erzeugen
1527*cdf0e10cSrcweir 		Reference< XFormComponent >  xNewComponent(::comphelper::getProcessServiceFactory()->createInstance(rServiceName), UNO_QUERY);
1528*cdf0e10cSrcweir 		if (!xNewComponent.is())
1529*cdf0e10cSrcweir 			return NULL;
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir 		FmControlData* pNewFormControlData = new FmControlData( xNewComponent, m_aNavigatorImages, m_aNavigatorImagesHC, pParentFormData );
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1534*cdf0e10cSrcweir 		// Namen setzen
1535*cdf0e10cSrcweir 		FmFormView*     pFormView       = GetNavModel()->GetFormShell()->GetFormView();
1536*cdf0e10cSrcweir 		SdrPageView*    pPageView       = pFormView->GetSdrPageView();
1537*cdf0e10cSrcweir 		FmFormPage*     pPage           = (FmFormPage*)pPageView->GetPage();
1538*cdf0e10cSrcweir 
1539*cdf0e10cSrcweir 		::rtl::OUString sName = pPage->GetImpl().setUniqueName( xNewComponent, xParentForm );
1540*cdf0e10cSrcweir 
1541*cdf0e10cSrcweir 		pNewFormControlData->SetText( sName );
1542*cdf0e10cSrcweir 
1543*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1544*cdf0e10cSrcweir 		// FormComponent einfuegen
1545*cdf0e10cSrcweir 		GetNavModel()->Insert( pNewFormControlData, LIST_APPEND, sal_True );
1546*cdf0e10cSrcweir 		GetNavModel()->SetModified();
1547*cdf0e10cSrcweir 
1548*cdf0e10cSrcweir 		if (bEditName)
1549*cdf0e10cSrcweir 		{
1550*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////////////
1551*cdf0e10cSrcweir 			// In EditMode schalten
1552*cdf0e10cSrcweir 			SvLBoxEntry* pNewEntry = FindEntry( pNewFormControlData );
1553*cdf0e10cSrcweir 			Select( pNewEntry, sal_True );
1554*cdf0e10cSrcweir 			EditEntry( pNewEntry );
1555*cdf0e10cSrcweir 		}
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir 		return pNewFormControlData;
1558*cdf0e10cSrcweir 	}
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1561*cdf0e10cSrcweir 	::rtl::OUString NavigatorTree::GenerateName( FmEntryData* pEntryData )
1562*cdf0e10cSrcweir 	{
1563*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::GenerateName" );
1564*cdf0e10cSrcweir 		const sal_uInt16 nMaxCount = 99;
1565*cdf0e10cSrcweir 		::rtl::OUString aNewName;
1566*cdf0e10cSrcweir 
1567*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1568*cdf0e10cSrcweir 		// BasisNamen erzeugen
1569*cdf0e10cSrcweir 		UniString aBaseName;
1570*cdf0e10cSrcweir 		if( pEntryData->ISA(FmFormData) )
1571*cdf0e10cSrcweir 			aBaseName = SVX_RES( RID_STR_STDFORMNAME );
1572*cdf0e10cSrcweir 
1573*cdf0e10cSrcweir 		else if( pEntryData->ISA(FmControlData) )
1574*cdf0e10cSrcweir 			aBaseName = SVX_RES( RID_STR_CONTROL );
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
1577*cdf0e10cSrcweir 		// Neuen Namen erstellen
1578*cdf0e10cSrcweir 		FmFormData* pFormParentData = (FmFormData*)pEntryData->GetParent();
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir 		for( sal_Int32 i=0; i<nMaxCount; i++ )
1581*cdf0e10cSrcweir 		{
1582*cdf0e10cSrcweir 			aNewName = aBaseName;
1583*cdf0e10cSrcweir 			if( i>0 )
1584*cdf0e10cSrcweir 			{
1585*cdf0e10cSrcweir 				aNewName += ::rtl::OUString::createFromAscii(" ");
1586*cdf0e10cSrcweir 				aNewName += ::rtl::OUString::valueOf(i).getStr();
1587*cdf0e10cSrcweir 			}
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir 			if( GetNavModel()->FindData(aNewName, pFormParentData,sal_False) == NULL )
1590*cdf0e10cSrcweir 				break;
1591*cdf0e10cSrcweir 		}
1592*cdf0e10cSrcweir 
1593*cdf0e10cSrcweir 		return aNewName;
1594*cdf0e10cSrcweir 	}
1595*cdf0e10cSrcweir 
1596*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1597*cdf0e10cSrcweir 	sal_Bool NavigatorTree::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
1598*cdf0e10cSrcweir 	{
1599*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditedEntry" );
1600*cdf0e10cSrcweir 		if (EditingCanceled())
1601*cdf0e10cSrcweir 			return sal_True;
1602*cdf0e10cSrcweir 
1603*cdf0e10cSrcweir 		GrabFocus();
1604*cdf0e10cSrcweir 		FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
1605*cdf0e10cSrcweir 		sal_Bool bRes = GetNavModel()->Rename( pEntryData, rNewText);
1606*cdf0e10cSrcweir 		if( !bRes )
1607*cdf0e10cSrcweir 		{
1608*cdf0e10cSrcweir 			m_pEditEntry = pEntry;
1609*cdf0e10cSrcweir 			nEditEvent = Application::PostUserEvent( LINK(this, NavigatorTree, OnEdit) );
1610*cdf0e10cSrcweir 		} else
1611*cdf0e10cSrcweir 			SetCursor(pEntry, sal_True);
1612*cdf0e10cSrcweir 
1613*cdf0e10cSrcweir 		return bRes;
1614*cdf0e10cSrcweir 	}
1615*cdf0e10cSrcweir 
1616*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1617*cdf0e10cSrcweir 	IMPL_LINK( NavigatorTree, OnEdit, void*, EMPTYARG )
1618*cdf0e10cSrcweir 	{
1619*cdf0e10cSrcweir 		nEditEvent = 0;
1620*cdf0e10cSrcweir 		EditEntry( m_pEditEntry );
1621*cdf0e10cSrcweir 		m_pEditEntry = NULL;
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir 		return 0L;
1624*cdf0e10cSrcweir 	}
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1627*cdf0e10cSrcweir 	IMPL_LINK( NavigatorTree, OnDropActionTimer, void*, EMPTYARG )
1628*cdf0e10cSrcweir 	{
1629*cdf0e10cSrcweir 		if (--m_aTimerCounter > 0)
1630*cdf0e10cSrcweir 			return 0L;
1631*cdf0e10cSrcweir 
1632*cdf0e10cSrcweir         switch ( m_aDropActionType )
1633*cdf0e10cSrcweir         {
1634*cdf0e10cSrcweir         case DA_EXPANDNODE:
1635*cdf0e10cSrcweir 		{
1636*cdf0e10cSrcweir 			SvLBoxEntry* pToExpand = GetEntry(m_aTimerTriggered);
1637*cdf0e10cSrcweir 			if (pToExpand && (GetChildCount(pToExpand) > 0) &&  !IsExpanded(pToExpand))
1638*cdf0e10cSrcweir 				// tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
1639*cdf0e10cSrcweir 				// habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
1640*cdf0e10cSrcweir 				// aber ich denke, die BK sollte es auch so vertragen
1641*cdf0e10cSrcweir 				Expand(pToExpand);
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir 			// nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
1644*cdf0e10cSrcweir 			m_aDropActionTimer.Stop();
1645*cdf0e10cSrcweir 		}
1646*cdf0e10cSrcweir         break;
1647*cdf0e10cSrcweir 
1648*cdf0e10cSrcweir         case DA_SCROLLUP :
1649*cdf0e10cSrcweir 			ScrollOutputArea( 1 );
1650*cdf0e10cSrcweir 			m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
1651*cdf0e10cSrcweir 			break;
1652*cdf0e10cSrcweir 
1653*cdf0e10cSrcweir 		case DA_SCROLLDOWN :
1654*cdf0e10cSrcweir 			ScrollOutputArea( -1 );
1655*cdf0e10cSrcweir 			m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
1656*cdf0e10cSrcweir 			break;
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir 		}
1659*cdf0e10cSrcweir 
1660*cdf0e10cSrcweir 		return 0L;
1661*cdf0e10cSrcweir 	}
1662*cdf0e10cSrcweir 
1663*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1664*cdf0e10cSrcweir 	IMPL_LINK(NavigatorTree, OnEntrySelDesel, NavigatorTree*, /*pThis*/)
1665*cdf0e10cSrcweir 	{
1666*cdf0e10cSrcweir 		m_sdiState = SDI_DIRTY;
1667*cdf0e10cSrcweir 
1668*cdf0e10cSrcweir 		if (IsSelectionHandlingLocked())
1669*cdf0e10cSrcweir 			return 0L;
1670*cdf0e10cSrcweir 
1671*cdf0e10cSrcweir 		if (m_aSynchronizeTimer.IsActive())
1672*cdf0e10cSrcweir 			m_aSynchronizeTimer.Stop();
1673*cdf0e10cSrcweir 
1674*cdf0e10cSrcweir 		m_aSynchronizeTimer.SetTimeout(EXPLORER_SYNC_DELAY);
1675*cdf0e10cSrcweir 		m_aSynchronizeTimer.Start();
1676*cdf0e10cSrcweir 
1677*cdf0e10cSrcweir 		return 0L;
1678*cdf0e10cSrcweir 	}
1679*cdf0e10cSrcweir 
1680*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1681*cdf0e10cSrcweir 	IMPL_LINK(NavigatorTree, OnSynchronizeTimer, void*, EMPTYARG)
1682*cdf0e10cSrcweir 	{
1683*cdf0e10cSrcweir 		SynchronizeMarkList();
1684*cdf0e10cSrcweir 		return 0L;
1685*cdf0e10cSrcweir 	}
1686*cdf0e10cSrcweir 
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1689*cdf0e10cSrcweir 	IMPL_LINK( NavigatorTree, OnClipboardAction, void*, EMPTYARG )
1690*cdf0e10cSrcweir 	{
1691*cdf0e10cSrcweir 		if ( !m_aControlExchange.isClipboardOwner() )
1692*cdf0e10cSrcweir 		{
1693*cdf0e10cSrcweir 			if ( doingKeyboardCut() )
1694*cdf0e10cSrcweir 			{
1695*cdf0e10cSrcweir                 for (   ListBoxEntrySet::const_iterator i = m_aCutEntries.begin();
1696*cdf0e10cSrcweir                         i != m_aCutEntries.end();
1697*cdf0e10cSrcweir                         ++i
1698*cdf0e10cSrcweir                     )
1699*cdf0e10cSrcweir 				{
1700*cdf0e10cSrcweir                     SvLBoxEntry* pEntry = *i;
1701*cdf0e10cSrcweir 					if ( !pEntry )
1702*cdf0e10cSrcweir                         continue;
1703*cdf0e10cSrcweir 
1704*cdf0e10cSrcweir                     pEntry->SetFlags( pEntry->GetFlags() & ~SV_ENTRYFLAG_SEMITRANSPARENT );
1705*cdf0e10cSrcweir 					InvalidateEntry( pEntry );
1706*cdf0e10cSrcweir 				}
1707*cdf0e10cSrcweir                 ListBoxEntrySet aEmpty;
1708*cdf0e10cSrcweir 				m_aCutEntries.swap( aEmpty );
1709*cdf0e10cSrcweir 
1710*cdf0e10cSrcweir 				m_bKeyboardCut = sal_False;
1711*cdf0e10cSrcweir 			}
1712*cdf0e10cSrcweir 		}
1713*cdf0e10cSrcweir 		return 0L;
1714*cdf0e10cSrcweir 	}
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1717*cdf0e10cSrcweir 	void NavigatorTree::ShowSelectionProperties(sal_Bool bForce)
1718*cdf0e10cSrcweir 	{
1719*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ShowSelectionProperties" );
1720*cdf0e10cSrcweir 		// zuerst brauche ich die FormShell
1721*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
1722*cdf0e10cSrcweir 		if (!pFormShell)
1723*cdf0e10cSrcweir 			// keine Shell -> ich koennte kein curObject setzen -> raus
1724*cdf0e10cSrcweir 			return;
1725*cdf0e10cSrcweir 
1726*cdf0e10cSrcweir 		CollectSelectionData(SDI_ALL);
1727*cdf0e10cSrcweir 		DBG_ASSERT( m_nFormsSelected + m_nControlsSelected + (m_bRootSelected ? 1 : 0) == m_arrCurrentSelection.Count(),
1728*cdf0e10cSrcweir 			"NavigatorTree::ShowSelectionProperties : selection meta data invalid !");
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir         InterfaceBag aSelection;
1732*cdf0e10cSrcweir         sal_Bool bSetSelectionAsMarkList = sal_False;
1733*cdf0e10cSrcweir 
1734*cdf0e10cSrcweir 		if (m_bRootSelected)
1735*cdf0e10cSrcweir 			;                                   // no properties for the root, neither for single nor for multi selection
1736*cdf0e10cSrcweir 		else if ( m_nFormsSelected + m_nControlsSelected == 0 )   // none of the two should be less 0
1737*cdf0e10cSrcweir 			;                                   // no selection -> no properties
1738*cdf0e10cSrcweir 		else if ( m_nFormsSelected * m_nControlsSelected != 0 )
1739*cdf0e10cSrcweir 			;                                   // mixed selection -> no properties
1740*cdf0e10cSrcweir 		else
1741*cdf0e10cSrcweir 		{   // either only forms, or only controls are selected
1742*cdf0e10cSrcweir             if (m_arrCurrentSelection.Count() == 1)
1743*cdf0e10cSrcweir 			{
1744*cdf0e10cSrcweir 				if (m_nFormsSelected > 0)
1745*cdf0e10cSrcweir 				{   // es ist genau eine Form selektiert
1746*cdf0e10cSrcweir 					FmFormData* pFormData = (FmFormData*)m_arrCurrentSelection.GetObject(0)->GetUserData();
1747*cdf0e10cSrcweir                     aSelection.insert( Reference< XInterface >( pFormData->GetFormIface(), UNO_QUERY ) );
1748*cdf0e10cSrcweir 				}
1749*cdf0e10cSrcweir                 else
1750*cdf0e10cSrcweir 				{   // es ist genau ein Control selektiert (egal ob hidden oder normal)
1751*cdf0e10cSrcweir 					FmEntryData* pEntryData = (FmEntryData*)m_arrCurrentSelection.GetObject(0)->GetUserData();
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir                     aSelection.insert( Reference< XInterface >( pEntryData->GetElement(), UNO_QUERY ) );
1754*cdf0e10cSrcweir 				}
1755*cdf0e10cSrcweir 			}
1756*cdf0e10cSrcweir             else
1757*cdf0e10cSrcweir 			{   // wir haben eine MultiSelection, also muessen wir ein MultiSet dafuer aufbauen
1758*cdf0e10cSrcweir 				if (m_nFormsSelected > 0)
1759*cdf0e10cSrcweir 				{   // ... nur Forms
1760*cdf0e10cSrcweir 					// erstmal die PropertySet-Interfaces der Forms einsammeln
1761*cdf0e10cSrcweir 					for ( sal_Int32 i = 0; i < m_nFormsSelected; ++i )
1762*cdf0e10cSrcweir 					{
1763*cdf0e10cSrcweir 						FmFormData* pFormData = (FmFormData*)m_arrCurrentSelection.GetObject((sal_uInt16)i)->GetUserData();
1764*cdf0e10cSrcweir                         aSelection.insert( pFormData->GetPropertySet().get() );
1765*cdf0e10cSrcweir 					}
1766*cdf0e10cSrcweir 				}
1767*cdf0e10cSrcweir 				else
1768*cdf0e10cSrcweir 				{   // ... nur Controls
1769*cdf0e10cSrcweir 					if (m_nHiddenControls == m_nControlsSelected)
1770*cdf0e10cSrcweir 					{   // ein MultiSet fuer die Properties der hidden controls
1771*cdf0e10cSrcweir 						for ( sal_Int32 i = 0; i < m_nHiddenControls; ++i )
1772*cdf0e10cSrcweir 						{
1773*cdf0e10cSrcweir 							FmEntryData* pEntryData = (FmEntryData*)m_arrCurrentSelection.GetObject((sal_uInt16)i)->GetUserData();
1774*cdf0e10cSrcweir                             aSelection.insert( pEntryData->GetPropertySet().get() );
1775*cdf0e10cSrcweir 						}
1776*cdf0e10cSrcweir 					}
1777*cdf0e10cSrcweir 					else if (m_nHiddenControls == 0)
1778*cdf0e10cSrcweir 					{   // nur normale Controls
1779*cdf0e10cSrcweir                         bSetSelectionAsMarkList = sal_True;
1780*cdf0e10cSrcweir 					}
1781*cdf0e10cSrcweir 				}
1782*cdf0e10cSrcweir 			}
1783*cdf0e10cSrcweir 
1784*cdf0e10cSrcweir 		}
1785*cdf0e10cSrcweir 
1786*cdf0e10cSrcweir         // und dann meine Form und mein SelObject
1787*cdf0e10cSrcweir         if ( bSetSelectionAsMarkList )
1788*cdf0e10cSrcweir             pFormShell->GetImpl()->setCurrentSelectionFromMark( pFormShell->GetFormView()->GetMarkedObjectList() );
1789*cdf0e10cSrcweir         else
1790*cdf0e10cSrcweir 		    pFormShell->GetImpl()->setCurrentSelection( aSelection );
1791*cdf0e10cSrcweir 
1792*cdf0e10cSrcweir 		if ( pFormShell->GetImpl()->IsPropBrwOpen() || bForce )
1793*cdf0e10cSrcweir 		{
1794*cdf0e10cSrcweir 			// und jetzt kann ich das Ganze dem PropertyBrowser uebergeben
1795*cdf0e10cSrcweir 			pFormShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SFX_CALLMODE_ASYNCHRON );
1796*cdf0e10cSrcweir 		}
1797*cdf0e10cSrcweir 	}
1798*cdf0e10cSrcweir 
1799*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1800*cdf0e10cSrcweir 	void NavigatorTree::DeleteSelection()
1801*cdf0e10cSrcweir 	{
1802*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::DeleteSelection" );
1803*cdf0e10cSrcweir 		// die Root darf ich natuerlich nicht mitloeschen
1804*cdf0e10cSrcweir 		sal_Bool bRootSelected = IsSelected(m_pRootEntry);
1805*cdf0e10cSrcweir 		sal_uIntPtr nSelectedEntries = GetSelectionCount();
1806*cdf0e10cSrcweir 		if (bRootSelected && (nSelectedEntries > 1))     // die Root plus andere Elemente ?
1807*cdf0e10cSrcweir 			Select(m_pRootEntry, sal_False);                // ja -> die Root raus
1808*cdf0e10cSrcweir 
1809*cdf0e10cSrcweir 		if ((nSelectedEntries == 0) || bRootSelected)    // immer noch die Root ?
1810*cdf0e10cSrcweir 			return;                                     // -> sie ist das einzige selektierte -> raus
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir 		DBG_ASSERT(!m_bPrevSelectionMixed, "NavigatorTree::DeleteSelection() : loeschen nicht erlaubt wenn Markierung und Selektion nciht konsistent");
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir 		// ich brauche unten das FormModel ...
1815*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
1816*cdf0e10cSrcweir 		if (!pFormShell)
1817*cdf0e10cSrcweir 			return;
1818*cdf0e10cSrcweir 		FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
1819*cdf0e10cSrcweir 		if (!pFormModel)
1820*cdf0e10cSrcweir 			return;
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir 		// jetzt muss ich noch die DeleteList etwas absichern : wenn man ein Formular und ein abhaengiges
1823*cdf0e10cSrcweir 		// Element loescht - und zwar in dieser Reihenfolge - dann ist der SvLBoxEntryPtr des abhaengigen Elementes
1824*cdf0e10cSrcweir 		// natuerlich schon ungueltig, wenn es geloescht werden soll ... diesen GPF, den es dann mit Sicherheit gibt,
1825*cdf0e10cSrcweir 		// gilt es zu verhindern, also die 'normalisierte' Liste
1826*cdf0e10cSrcweir 		CollectSelectionData( SDI_NORMALIZED );
1827*cdf0e10cSrcweir 
1828*cdf0e10cSrcweir         // see below for why we need this mapping from models to shapes
1829*cdf0e10cSrcweir 		FmFormView*		pFormView		= pFormShell->GetFormView();
1830*cdf0e10cSrcweir 		SdrPageView*	pPageView		= pFormView ? pFormView->GetSdrPageView() : NULL;
1831*cdf0e10cSrcweir 		SdrPage*		pPage			= pPageView ? pPageView->GetPage() : NULL;
1832*cdf0e10cSrcweir 		DBG_ASSERT( pPage, "NavigatorTree::DeleteSelection: invalid form page!" );
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir 		MapModelToShape aModelShapes;
1835*cdf0e10cSrcweir 		if ( pPage )
1836*cdf0e10cSrcweir 			collectShapeModelMapping( pPage, aModelShapes );
1837*cdf0e10cSrcweir 
1838*cdf0e10cSrcweir         // problem: we have to use ExplorerModel::Remove, since only this one properly deletes Form objects.
1839*cdf0e10cSrcweir         // But, the controls themself must be deleted via DeleteMarked (else, the Writer has some problems
1840*cdf0e10cSrcweir         // somewhere). In case I'd first delete the structure, then the controls, the UNDO would not work
1841*cdf0e10cSrcweir         // (since UNDO then would mean to first restore the controls, then the structure, means their parent
1842*cdf0e10cSrcweir         // form). The other way round, the EntryDatas would be invalid, if I'd first delete the controls and
1843*cdf0e10cSrcweir         // then go on to the strucure. This means I have to delete the forms *after* the normal controls, so
1844*cdf0e10cSrcweir         // that during UNDO, they're restored in the proper order.
1845*cdf0e10cSrcweir 		pFormShell->GetImpl()->EnableTrackProperties(sal_False);
1846*cdf0e10cSrcweir 		sal_uInt16 i;
1847*cdf0e10cSrcweir 		for (i = m_arrCurrentSelection.Count(); i>0; --i)
1848*cdf0e10cSrcweir 		{
1849*cdf0e10cSrcweir 			FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection.GetObject(i - 1)->GetUserData());
1850*cdf0e10cSrcweir 
1851*cdf0e10cSrcweir 			// eine Form ?
1852*cdf0e10cSrcweir 			sal_Bool bIsForm = pCurrent->ISA(FmFormData);
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir 			// da ich das Loeschen im folgenden der View ueberlasse und dabei auf deren MarkList aufbaue, im Normalfall aber bei
1855*cdf0e10cSrcweir 			// einem makierten Formular nur die direkt, nicht die indirekt abhaengigen Controls markiert werden, muss ich das hier
1856*cdf0e10cSrcweir 			// noch nachholen
1857*cdf0e10cSrcweir 			if (bIsForm)
1858*cdf0e10cSrcweir 				MarkViewObj((FmFormData*)pCurrent, sal_True, sal_True);     // das zweite sal_True heisst "deep"
1859*cdf0e10cSrcweir 
1860*cdf0e10cSrcweir 			// ein hidden control ?
1861*cdf0e10cSrcweir 			sal_Bool bIsHidden = IsHiddenControl(pCurrent);
1862*cdf0e10cSrcweir 
1863*cdf0e10cSrcweir 			// Forms und hidden Controls muss ich behalten, alles andere nicht
1864*cdf0e10cSrcweir 			if (!bIsForm && !bIsHidden)
1865*cdf0e10cSrcweir 			{
1866*cdf0e10cSrcweir 				// well, no form and no hidden control -> we can remove it from m_arrCurrentSelection, as it will
1867*cdf0e10cSrcweir 				// be deleted automatically. This is because for every model (except forms and hidden control models)
1868*cdf0e10cSrcweir 				// there exist a shape, which is marked _if_and_only_if_ the model is selected in our tree.
1869*cdf0e10cSrcweir                 if ( aModelShapes.find( pCurrent->GetElement() ) != aModelShapes.end() )
1870*cdf0e10cSrcweir                 {
1871*cdf0e10cSrcweir                     // if there's a shape for the current entry, then either it is marked or it is in a
1872*cdf0e10cSrcweir                     // hidden layer (#i28502#), or something like this.
1873*cdf0e10cSrcweir                     // In the first case, it will be deleted below, in the second case, we currently don't
1874*cdf0e10cSrcweir                     // delete it, as there's no real (working!) API for this, neither in UNO nor in non-UNO.
1875*cdf0e10cSrcweir                     m_arrCurrentSelection.Remove( i - 1, 1 );
1876*cdf0e10cSrcweir                 }
1877*cdf0e10cSrcweir                 // In case there is no shape for the current entry, we keep the entry in m_arrCurrentSelection,
1878*cdf0e10cSrcweir                 // since then we can definately remove it.
1879*cdf0e10cSrcweir                 // #103597#
1880*cdf0e10cSrcweir 			}
1881*cdf0e10cSrcweir 		}
1882*cdf0e10cSrcweir 		pFormShell->GetImpl()->EnableTrackProperties(sal_True);
1883*cdf0e10cSrcweir 
1884*cdf0e10cSrcweir 		// let the view delete the marked controls
1885*cdf0e10cSrcweir 		pFormShell->GetFormView()->DeleteMarked();
1886*cdf0e10cSrcweir 
1887*cdf0e10cSrcweir         // start UNDO at this point. Unfortunately, this results in 2 UNDO actions, since DeleteMarked is
1888*cdf0e10cSrcweir         // creating an own one. However, if we'd move it before DeleteMarked, Writer does not really like
1889*cdf0e10cSrcweir         // this ... :(
1890*cdf0e10cSrcweir         // 2004-07-05 - #i31038# - fs@openoffice.org
1891*cdf0e10cSrcweir         {
1892*cdf0e10cSrcweir             // ---------------
1893*cdf0e10cSrcweir 		    // initialize UNDO
1894*cdf0e10cSrcweir             String aUndoStr;
1895*cdf0e10cSrcweir 		    if ( m_arrCurrentSelection.Count() == 1 )
1896*cdf0e10cSrcweir 		    {
1897*cdf0e10cSrcweir 			    aUndoStr = SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE);
1898*cdf0e10cSrcweir 			    if (m_nFormsSelected)
1899*cdf0e10cSrcweir 				    aUndoStr.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_FORM ) );
1900*cdf0e10cSrcweir 			    else
1901*cdf0e10cSrcweir 				    // it must be a control (else the root would be selected, but it cannot be deleted)
1902*cdf0e10cSrcweir 				    aUndoStr.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_CONTROL ) );
1903*cdf0e10cSrcweir 		    }
1904*cdf0e10cSrcweir 		    else
1905*cdf0e10cSrcweir 		    {
1906*cdf0e10cSrcweir 			    aUndoStr = SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE_MULTIPLE);
1907*cdf0e10cSrcweir                 aUndoStr.SearchAndReplaceAscii( "#", String::CreateFromInt32( m_arrCurrentSelection.Count() ) );
1908*cdf0e10cSrcweir 		    }
1909*cdf0e10cSrcweir             pFormModel->BegUndo(aUndoStr);
1910*cdf0e10cSrcweir         }
1911*cdf0e10cSrcweir 
1912*cdf0e10cSrcweir         // remove remaining structure
1913*cdf0e10cSrcweir 		for (i=0; i<m_arrCurrentSelection.Count(); ++i)
1914*cdf0e10cSrcweir 		{
1915*cdf0e10cSrcweir 			FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection.GetObject(i)->GetUserData());
1916*cdf0e10cSrcweir 
1917*cdf0e10cSrcweir             // if the entry still has children, we skipped deletion of one of those children.
1918*cdf0e10cSrcweir             // This may for instance be because the shape is in a hidden layer, where we're unable
1919*cdf0e10cSrcweir             // to remove it
1920*cdf0e10cSrcweir             if ( pCurrent->GetChildList()->Count() )
1921*cdf0e10cSrcweir                 continue;
1922*cdf0e10cSrcweir 
1923*cdf0e10cSrcweir 			// noch ein kleines Problem, bevor ich das ganz loesche : wenn es eine Form ist und die Shell diese als CurrentObject
1924*cdf0e10cSrcweir 			// kennt, dann muss ich ihr das natuerlich ausreden
1925*cdf0e10cSrcweir 			if (pCurrent->ISA(FmFormData))
1926*cdf0e10cSrcweir 			{
1927*cdf0e10cSrcweir 				Reference< XForm >  xCurrentForm( static_cast< FmFormData* >( pCurrent )->GetFormIface() );
1928*cdf0e10cSrcweir 				if ( pFormShell->GetImpl()->getCurrentForm() == xCurrentForm )  // die Shell kennt die zu loeschende Form ?
1929*cdf0e10cSrcweir 					pFormShell->GetImpl()->forgetCurrentForm();                 // -> wegnehmen ...
1930*cdf0e10cSrcweir 			}
1931*cdf0e10cSrcweir 			GetNavModel()->Remove(pCurrent, sal_True);
1932*cdf0e10cSrcweir 		}
1933*cdf0e10cSrcweir 		pFormModel->EndUndo();
1934*cdf0e10cSrcweir 	}
1935*cdf0e10cSrcweir 
1936*cdf0e10cSrcweir 	//------------------------------------------------------------------------
1937*cdf0e10cSrcweir 	void NavigatorTree::CollectSelectionData(SELDATA_ITEMS sdiHow)
1938*cdf0e10cSrcweir 	{
1939*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::CollectSelectionData" );
1940*cdf0e10cSrcweir 		DBG_ASSERT(sdiHow != SDI_DIRTY, "NavigatorTree::CollectSelectionData : ever thought about your parameter ? DIRTY ?");
1941*cdf0e10cSrcweir 		if (sdiHow == m_sdiState)
1942*cdf0e10cSrcweir 			return;
1943*cdf0e10cSrcweir 
1944*cdf0e10cSrcweir 		m_arrCurrentSelection.Remove((sal_uInt16)0, m_arrCurrentSelection.Count());
1945*cdf0e10cSrcweir 		m_nFormsSelected = m_nControlsSelected = m_nHiddenControls = 0;
1946*cdf0e10cSrcweir 		m_bRootSelected = sal_False;
1947*cdf0e10cSrcweir 
1948*cdf0e10cSrcweir 		SvLBoxEntry* pSelectionLoop = FirstSelected();
1949*cdf0e10cSrcweir 		while (pSelectionLoop)
1950*cdf0e10cSrcweir 		{
1951*cdf0e10cSrcweir 			// erst mal die Zaehlung der verschiedenen Elemente
1952*cdf0e10cSrcweir 			if (pSelectionLoop == m_pRootEntry)
1953*cdf0e10cSrcweir 				m_bRootSelected = sal_True;
1954*cdf0e10cSrcweir 			else
1955*cdf0e10cSrcweir 			{
1956*cdf0e10cSrcweir 				if (IsFormEntry(pSelectionLoop))
1957*cdf0e10cSrcweir 					++m_nFormsSelected;
1958*cdf0e10cSrcweir 				else
1959*cdf0e10cSrcweir 				{
1960*cdf0e10cSrcweir 					++m_nControlsSelected;
1961*cdf0e10cSrcweir 					if (IsHiddenControl((FmEntryData*)(pSelectionLoop->GetUserData())))
1962*cdf0e10cSrcweir 						++m_nHiddenControls;
1963*cdf0e10cSrcweir 				}
1964*cdf0e10cSrcweir 			}
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir 			if (sdiHow == SDI_NORMALIZED)
1967*cdf0e10cSrcweir 			{
1968*cdf0e10cSrcweir 				// alles, was schon einen selektierten Vorfahr hat, nicht mitnehmen
1969*cdf0e10cSrcweir 				if (pSelectionLoop == m_pRootEntry)
1970*cdf0e10cSrcweir 					m_arrCurrentSelection.Insert(pSelectionLoop);
1971*cdf0e10cSrcweir 				else
1972*cdf0e10cSrcweir 				{
1973*cdf0e10cSrcweir 					SvLBoxEntry* pParentLoop = GetParent(pSelectionLoop);
1974*cdf0e10cSrcweir 					while (pParentLoop)
1975*cdf0e10cSrcweir 					{
1976*cdf0e10cSrcweir 						// eigentlich muesste ich testen, ob das Parent in der m_arrCurrentSelection steht ...
1977*cdf0e10cSrcweir 						// Aber wenn es selektiert ist, dann steht es in m_arrCurrentSelection, oder wenigstens einer seiner Vorfahren,
1978*cdf0e10cSrcweir 						// wenn der auch schon selektiert war. In beiden Faellen reicht also die Abfrage IsSelected
1979*cdf0e10cSrcweir 						if (IsSelected(pParentLoop))
1980*cdf0e10cSrcweir 							break;
1981*cdf0e10cSrcweir 						else
1982*cdf0e10cSrcweir 						{
1983*cdf0e10cSrcweir 							if (m_pRootEntry == pParentLoop)
1984*cdf0e10cSrcweir 							{
1985*cdf0e10cSrcweir 								// bis (exclusive) zur Root gab es kein selektiertes Parent -> der Eintrag gehoert in die normalisierte Liste
1986*cdf0e10cSrcweir 								m_arrCurrentSelection.Insert(pSelectionLoop);
1987*cdf0e10cSrcweir 								break;
1988*cdf0e10cSrcweir 							}
1989*cdf0e10cSrcweir 							else
1990*cdf0e10cSrcweir 								pParentLoop = GetParent(pParentLoop);
1991*cdf0e10cSrcweir 						}
1992*cdf0e10cSrcweir 					}
1993*cdf0e10cSrcweir 				}
1994*cdf0e10cSrcweir 			}
1995*cdf0e10cSrcweir 			else if (sdiHow == SDI_NORMALIZED_FORMARK)
1996*cdf0e10cSrcweir 			{
1997*cdf0e10cSrcweir 				SvLBoxEntry* pParent = GetParent(pSelectionLoop);
1998*cdf0e10cSrcweir 				if (!pParent || !IsSelected(pParent) || IsFormEntry(pSelectionLoop))
1999*cdf0e10cSrcweir 					m_arrCurrentSelection.Insert(pSelectionLoop);
2000*cdf0e10cSrcweir 			}
2001*cdf0e10cSrcweir 			else
2002*cdf0e10cSrcweir 				m_arrCurrentSelection.Insert(pSelectionLoop);
2003*cdf0e10cSrcweir 
2004*cdf0e10cSrcweir 
2005*cdf0e10cSrcweir 			pSelectionLoop = NextSelected(pSelectionLoop);
2006*cdf0e10cSrcweir 		}
2007*cdf0e10cSrcweir 
2008*cdf0e10cSrcweir 		m_sdiState = sdiHow;
2009*cdf0e10cSrcweir 	}
2010*cdf0e10cSrcweir 
2011*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2012*cdf0e10cSrcweir 	void NavigatorTree::SynchronizeSelection(FmEntryDataArray& arredToSelect)
2013*cdf0e10cSrcweir 	{
2014*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
2015*cdf0e10cSrcweir 		LockSelectionHandling();
2016*cdf0e10cSrcweir 		if (arredToSelect.Count() == 0)
2017*cdf0e10cSrcweir 		{
2018*cdf0e10cSrcweir 			SelectAll(sal_False);
2019*cdf0e10cSrcweir 		}
2020*cdf0e10cSrcweir 		else
2021*cdf0e10cSrcweir 		{
2022*cdf0e10cSrcweir 			// erst mal gleiche ich meine aktuelle Selektion mit der geforderten SelectList ab
2023*cdf0e10cSrcweir 			SvLBoxEntry* pSelection = FirstSelected();
2024*cdf0e10cSrcweir 			while (pSelection)
2025*cdf0e10cSrcweir 			{
2026*cdf0e10cSrcweir 				FmEntryData* pCurrent = (FmEntryData*)pSelection->GetUserData();
2027*cdf0e10cSrcweir 				if (pCurrent != NULL)
2028*cdf0e10cSrcweir 				{
2029*cdf0e10cSrcweir 					sal_uInt16 nPosition;
2030*cdf0e10cSrcweir 					if ( arredToSelect.Seek_Entry(pCurrent, &nPosition) )
2031*cdf0e10cSrcweir 					{   // der Entry ist schon selektiert, steht aber auch in der SelectList -> er kann aus letzterer
2032*cdf0e10cSrcweir 						// raus
2033*cdf0e10cSrcweir 						arredToSelect.Remove(nPosition, 1);
2034*cdf0e10cSrcweir 					} else
2035*cdf0e10cSrcweir 					{   // der Entry ist selektiert, aber steht nicht in der SelectList -> Selektion rausnehmen
2036*cdf0e10cSrcweir 						Select(pSelection, sal_False);
2037*cdf0e10cSrcweir 						// und sichtbar machen (kann ja sein, dass das die einzige Modifikation ist, die ich hier in dem
2038*cdf0e10cSrcweir 						// ganzen Handler mache, dann sollte das zu sehen sein)
2039*cdf0e10cSrcweir 						MakeVisible(pSelection);
2040*cdf0e10cSrcweir 					}
2041*cdf0e10cSrcweir 				}
2042*cdf0e10cSrcweir 				else
2043*cdf0e10cSrcweir 					Select(pSelection, sal_False);
2044*cdf0e10cSrcweir 
2045*cdf0e10cSrcweir 				pSelection = NextSelected(pSelection);
2046*cdf0e10cSrcweir 			}
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir 			// jetzt habe ich in der SelectList genau die Eintraege, die noch selektiert werden muessen
2049*cdf0e10cSrcweir 			// zwei Moeglichkeiten : 1) ich gehe durch die SelectList, besorge mir zu jedem Eintrag meinen SvLBoxEntry
2050*cdf0e10cSrcweir 			// und selektiere diesen (waere irgendwie intuitiver ;)) 2) ich gehe durch alle meine SvLBoxEntries und selektiere
2051*cdf0e10cSrcweir 			// genau die, die ich in der SelectList finde
2052*cdf0e10cSrcweir 			// 1) braucht O(k*n) (k=Laenge der SelectList, n=Anzahl meiner Entries), plus den Fakt, dass FindEntry nicht den
2053*cdf0e10cSrcweir 			// Pointer auf die UserDaten vergleicht, sondern ein aufwendigeres IsEqualWithoutChilds durchfuehrt
2054*cdf0e10cSrcweir 			// 2) braucht O(n*log k), dupliziert aber etwas Code (naemlich den aus FindEntry)
2055*cdf0e10cSrcweir 			// da das hier eine relativ oft aufgerufenen Stelle sein koennte (bei jeder Aenderung in der Markierung in der View !),
2056*cdf0e10cSrcweir 			// nehme ich doch lieber letzteres
2057*cdf0e10cSrcweir 			SvLBoxEntry* pLoop = First();
2058*cdf0e10cSrcweir 			while( pLoop )
2059*cdf0e10cSrcweir 			{
2060*cdf0e10cSrcweir 				FmEntryData* pCurEntryData = (FmEntryData*)pLoop->GetUserData();
2061*cdf0e10cSrcweir 				sal_uInt16 nPosition;
2062*cdf0e10cSrcweir 				if ( arredToSelect.Seek_Entry(pCurEntryData, &nPosition) )
2063*cdf0e10cSrcweir 				{
2064*cdf0e10cSrcweir 					Select(pLoop, sal_True);
2065*cdf0e10cSrcweir 					MakeVisible(pLoop);
2066*cdf0e10cSrcweir 					SetCursor(pLoop, sal_True);
2067*cdf0e10cSrcweir 				}
2068*cdf0e10cSrcweir 
2069*cdf0e10cSrcweir 				pLoop = Next( pLoop );
2070*cdf0e10cSrcweir 			}
2071*cdf0e10cSrcweir 		}
2072*cdf0e10cSrcweir 		UnlockSelectionHandling();
2073*cdf0e10cSrcweir 	}
2074*cdf0e10cSrcweir 
2075*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2076*cdf0e10cSrcweir 	void NavigatorTree::SynchronizeSelection()
2077*cdf0e10cSrcweir 	{
2078*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
2079*cdf0e10cSrcweir 		// Shell und View
2080*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
2081*cdf0e10cSrcweir 		if(!pFormShell) return;
2082*cdf0e10cSrcweir 
2083*cdf0e10cSrcweir 		FmFormView* pFormView = pFormShell->GetFormView();
2084*cdf0e10cSrcweir 		if (!pFormView) return;
2085*cdf0e10cSrcweir 
2086*cdf0e10cSrcweir 		GetNavModel()->BroadcastMarkedObjects(pFormView->GetMarkedObjectList());
2087*cdf0e10cSrcweir 	}
2088*cdf0e10cSrcweir 
2089*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2090*cdf0e10cSrcweir 	void NavigatorTree::SynchronizeMarkList()
2091*cdf0e10cSrcweir 	{
2092*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeMarkList" );
2093*cdf0e10cSrcweir 		// die Shell werde ich brauchen ...
2094*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
2095*cdf0e10cSrcweir 		if (!pFormShell) return;
2096*cdf0e10cSrcweir 
2097*cdf0e10cSrcweir 		CollectSelectionData(SDI_NORMALIZED_FORMARK);
2098*cdf0e10cSrcweir 
2099*cdf0e10cSrcweir 		// Die View soll jetzt kein Notify bei einer Aenderung der MarkList rauslassen
2100*cdf0e10cSrcweir 		pFormShell->GetImpl()->EnableTrackProperties(sal_False);
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir 		UnmarkAllViewObj();
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir 		for (sal_uInt32 i=0; i<m_arrCurrentSelection.Count(); ++i)
2105*cdf0e10cSrcweir 		{
2106*cdf0e10cSrcweir 			SvLBoxEntry* pSelectionLoop = m_arrCurrentSelection.GetObject((sal_uInt16)i);
2107*cdf0e10cSrcweir 			// Bei Formselektion alle Controls dieser Form markieren
2108*cdf0e10cSrcweir 			if (IsFormEntry(pSelectionLoop) && (pSelectionLoop != m_pRootEntry))
2109*cdf0e10cSrcweir 				MarkViewObj((FmFormData*)pSelectionLoop->GetUserData(), sal_True, sal_False);
2110*cdf0e10cSrcweir 
2111*cdf0e10cSrcweir 			// Bei Controlselektion Control-SdrObjects markieren
2112*cdf0e10cSrcweir 			else if (IsFormComponentEntry(pSelectionLoop))
2113*cdf0e10cSrcweir 			{
2114*cdf0e10cSrcweir 				FmControlData* pControlData = (FmControlData*)pSelectionLoop->GetUserData();
2115*cdf0e10cSrcweir 				if (pControlData)
2116*cdf0e10cSrcweir 				{
2117*cdf0e10cSrcweir 					/////////////////////////////////////////////////////////////////
2118*cdf0e10cSrcweir 					// Beim HiddenControl kann kein Object selektiert werden
2119*cdf0e10cSrcweir 					Reference< XFormComponent >  xFormComponent( pControlData->GetFormComponent());
2120*cdf0e10cSrcweir 					if (!xFormComponent.is())
2121*cdf0e10cSrcweir 						continue;
2122*cdf0e10cSrcweir 					Reference< XPropertySet >  xSet(xFormComponent, UNO_QUERY);
2123*cdf0e10cSrcweir 					if (!xSet.is())
2124*cdf0e10cSrcweir 						continue;
2125*cdf0e10cSrcweir 
2126*cdf0e10cSrcweir 					sal_uInt16 nClassId = ::comphelper::getINT16(xSet->getPropertyValue(FM_PROP_CLASSID));
2127*cdf0e10cSrcweir 					if (nClassId != FormComponentType::HIDDENCONTROL)
2128*cdf0e10cSrcweir 						MarkViewObj(pControlData, sal_True, sal_True);
2129*cdf0e10cSrcweir 				}
2130*cdf0e10cSrcweir 			}
2131*cdf0e10cSrcweir 		}
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir 		// wenn der PropertyBrowser offen ist, muss ich den entsprechend meiner Selektion anpassen
2134*cdf0e10cSrcweir 		// (NICHT entsprechend der MarkList der View : wenn ich ein Formular selektiert habe, sind in der
2135*cdf0e10cSrcweir 		// View alle zugehoerigen Controls markiert, trotzdem moechte ich natuerlich die Formular-Eigenschaften
2136*cdf0e10cSrcweir 		// sehen)
2137*cdf0e10cSrcweir 		ShowSelectionProperties(sal_False);
2138*cdf0e10cSrcweir 
2139*cdf0e10cSrcweir 		// Flag an View wieder zuruecksetzen
2140*cdf0e10cSrcweir 		pFormShell->GetImpl()->EnableTrackProperties(sal_True);
2141*cdf0e10cSrcweir 
2142*cdf0e10cSrcweir 		// wenn jetzt genau eine Form selektiert ist, sollte die Shell das als CurrentForm mitbekommen
2143*cdf0e10cSrcweir 		// (wenn SelectionHandling nicht locked ist, kuemmert sich die View eigentlich in MarkListHasChanged drum,
2144*cdf0e10cSrcweir 		// aber der Mechanismus greift zum Beispiel nicht, wenn die Form leer ist)
2145*cdf0e10cSrcweir 		if ((m_arrCurrentSelection.Count() == 1) && (m_nFormsSelected == 1))
2146*cdf0e10cSrcweir 		{
2147*cdf0e10cSrcweir 			FmFormData* pSingleSelectionData = PTR_CAST( FmFormData, static_cast< FmEntryData* >( FirstSelected()->GetUserData() ) );
2148*cdf0e10cSrcweir 			DBG_ASSERT( pSingleSelectionData, "NavigatorTree::SynchronizeMarkList: invalid selected form!" );
2149*cdf0e10cSrcweir 			if ( pSingleSelectionData )
2150*cdf0e10cSrcweir             {
2151*cdf0e10cSrcweir                 InterfaceBag aSelection;
2152*cdf0e10cSrcweir                 aSelection.insert( Reference< XInterface >( pSingleSelectionData->GetFormIface(), UNO_QUERY ) );
2153*cdf0e10cSrcweir 				pFormShell->GetImpl()->setCurrentSelection( aSelection );
2154*cdf0e10cSrcweir             }
2155*cdf0e10cSrcweir 		}
2156*cdf0e10cSrcweir 	}
2157*cdf0e10cSrcweir 
2158*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2159*cdf0e10cSrcweir 	sal_Bool NavigatorTree::IsHiddenControl(FmEntryData* pEntryData)
2160*cdf0e10cSrcweir 	{
2161*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsHiddenControl" );
2162*cdf0e10cSrcweir 		if (pEntryData == NULL) return sal_False;
2163*cdf0e10cSrcweir 
2164*cdf0e10cSrcweir 		Reference< XPropertySet > xProperties( pEntryData->GetPropertySet() );
2165*cdf0e10cSrcweir 		if (::comphelper::hasProperty(FM_PROP_CLASSID, xProperties))
2166*cdf0e10cSrcweir 		{
2167*cdf0e10cSrcweir 			Any aClassID = xProperties->getPropertyValue( FM_PROP_CLASSID );
2168*cdf0e10cSrcweir 			return (::comphelper::getINT16(aClassID) == FormComponentType::HIDDENCONTROL);
2169*cdf0e10cSrcweir 		}
2170*cdf0e10cSrcweir 		return sal_False;
2171*cdf0e10cSrcweir 	}
2172*cdf0e10cSrcweir 
2173*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2174*cdf0e10cSrcweir 	sal_Bool NavigatorTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
2175*cdf0e10cSrcweir 	{
2176*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Select" );
2177*cdf0e10cSrcweir 		if (bSelect == IsSelected(pEntry))  // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;)
2178*cdf0e10cSrcweir 			return sal_True;
2179*cdf0e10cSrcweir 
2180*cdf0e10cSrcweir 		return SvTreeListBox::Select(pEntry, bSelect );
2181*cdf0e10cSrcweir 	}
2182*cdf0e10cSrcweir 
2183*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2184*cdf0e10cSrcweir     void NavigatorTree::UnmarkAllViewObj()
2185*cdf0e10cSrcweir 	{
2186*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UnmarkAllViewObj" );
2187*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
2188*cdf0e10cSrcweir 		if( !pFormShell )
2189*cdf0e10cSrcweir 			return;
2190*cdf0e10cSrcweir 		FmFormView* pFormView = pFormShell->GetFormView();
2191*cdf0e10cSrcweir 		pFormView->UnMarkAll();
2192*cdf0e10cSrcweir 	}
2193*cdf0e10cSrcweir     //------------------------------------------------------------------------
2194*cdf0e10cSrcweir     void NavigatorTree::MarkViewObj(FmFormData* pFormData, sal_Bool bMark, sal_Bool bDeep )
2195*cdf0e10cSrcweir     {
2196*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
2197*cdf0e10cSrcweir         FmFormShell* pFormShell = GetNavModel()->GetFormShell();
2198*cdf0e10cSrcweir 		if( !pFormShell )
2199*cdf0e10cSrcweir             return;
2200*cdf0e10cSrcweir 
2201*cdf0e10cSrcweir         // first collect all sdrobjects
2202*cdf0e10cSrcweir         ::std::set< Reference< XFormComponent > > aObjects;
2203*cdf0e10cSrcweir         CollectObjects(pFormData,bDeep,aObjects);
2204*cdf0e10cSrcweir 
2205*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
2206*cdf0e10cSrcweir         // In der Page das entsprechende SdrObj finden und selektieren
2207*cdf0e10cSrcweir         FmFormView*     pFormView       = pFormShell->GetFormView();
2208*cdf0e10cSrcweir         SdrPageView*    pPageView       = pFormView->GetSdrPageView();
2209*cdf0e10cSrcweir         SdrPage*        pPage           = pPageView->GetPage();
2210*cdf0e10cSrcweir         //FmFormPage*     pFormPage       = dynamic_cast< FmFormPage* >( pPage );
2211*cdf0e10cSrcweir 
2212*cdf0e10cSrcweir         SdrObjListIter aIter( *pPage );
2213*cdf0e10cSrcweir         while ( aIter.IsMore() )
2214*cdf0e10cSrcweir         {
2215*cdf0e10cSrcweir             SdrObject* pSdrObject = aIter.Next();
2216*cdf0e10cSrcweir             FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
2217*cdf0e10cSrcweir             if ( !pFormObject )
2218*cdf0e10cSrcweir                 continue;
2219*cdf0e10cSrcweir 
2220*cdf0e10cSrcweir             Reference< XFormComponent > xControlModel( pFormObject->GetUnoControlModel(),UNO_QUERY );
2221*cdf0e10cSrcweir             if ( xControlModel.is() && aObjects.find(xControlModel) != aObjects.end() && bMark != pFormView->IsObjMarked( pSdrObject ) )
2222*cdf0e10cSrcweir             {
2223*cdf0e10cSrcweir                 // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
2224*cdf0e10cSrcweir                 pFormView->MarkObj( pSdrObject, pPageView, !bMark, sal_False );
2225*cdf0e10cSrcweir             }
2226*cdf0e10cSrcweir         } // while ( aIter.IsMore() )
2227*cdf0e10cSrcweir         if ( bMark )
2228*cdf0e10cSrcweir         {
2229*cdf0e10cSrcweir             // make the mark visible
2230*cdf0e10cSrcweir             ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
2231*cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2232*cdf0e10cSrcweir             {
2233*cdf0e10cSrcweir                 SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i );
2234*cdf0e10cSrcweir                 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
2235*cdf0e10cSrcweir                 if ( ( OUTDEV_WINDOW == rOutDev.GetOutDevType() ) && !aMarkRect.IsEmpty() )
2236*cdf0e10cSrcweir                 {
2237*cdf0e10cSrcweir                     pFormView->MakeVisible( aMarkRect, (Window&)rOutDev );
2238*cdf0e10cSrcweir                 }
2239*cdf0e10cSrcweir             } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2240*cdf0e10cSrcweir         }
2241*cdf0e10cSrcweir     }
2242*cdf0e10cSrcweir     //------------------------------------------------------------------------
2243*cdf0e10cSrcweir     void NavigatorTree::CollectObjects(FmFormData* pFormData, sal_Bool bDeep, ::std::set< Reference< XFormComponent > >& _rObjects)
2244*cdf0e10cSrcweir     {
2245*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
2246*cdf0e10cSrcweir         FmEntryDataList* pChildList = pFormData->GetChildList();
2247*cdf0e10cSrcweir         FmEntryData* pEntryData;
2248*cdf0e10cSrcweir 		FmControlData* pControlData;
2249*cdf0e10cSrcweir 	    for( sal_uInt32 i=0; i < pChildList->Count(); ++i )
2250*cdf0e10cSrcweir 	    {
2251*cdf0e10cSrcweir 		    pEntryData = pChildList->GetObject(i);
2252*cdf0e10cSrcweir 		    if( pEntryData->ISA(FmControlData) )
2253*cdf0e10cSrcweir 		    {
2254*cdf0e10cSrcweir 			    pControlData = (FmControlData*)pEntryData;
2255*cdf0e10cSrcweir                 _rObjects.insert(pControlData->GetFormComponent());
2256*cdf0e10cSrcweir 		    } // if( pEntryData->ISA(FmControlData) )
2257*cdf0e10cSrcweir             else if (bDeep && (pEntryData->ISA(FmFormData)))
2258*cdf0e10cSrcweir                 CollectObjects((FmFormData*)pEntryData,bDeep,_rObjects);
2259*cdf0e10cSrcweir 	    } // for( sal_uInt32 i=0; i<pChildList->Count(); i++ )
2260*cdf0e10cSrcweir     }
2261*cdf0e10cSrcweir 	//------------------------------------------------------------------------
2262*cdf0e10cSrcweir 	void NavigatorTree::MarkViewObj( FmControlData* pControlData, sal_Bool bMarkHandles, sal_Bool bMark)
2263*cdf0e10cSrcweir 	{
2264*cdf0e10cSrcweir         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObj" );
2265*cdf0e10cSrcweir 		if( !pControlData )
2266*cdf0e10cSrcweir             return;
2267*cdf0e10cSrcweir 		FmFormShell* pFormShell = GetNavModel()->GetFormShell();
2268*cdf0e10cSrcweir 		if( !pFormShell )
2269*cdf0e10cSrcweir             return;
2270*cdf0e10cSrcweir 
2271*cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////
2272*cdf0e10cSrcweir         // In der Page das entsprechende SdrObj finden und selektieren
2273*cdf0e10cSrcweir         FmFormView*     pFormView       = pFormShell->GetFormView();
2274*cdf0e10cSrcweir         Reference< XFormComponent >  xFormComponent( pControlData->GetFormComponent());
2275*cdf0e10cSrcweir         SdrPageView*    pPageView       = pFormView->GetSdrPageView();
2276*cdf0e10cSrcweir         SdrPage*        pPage           = pPageView->GetPage();
2277*cdf0e10cSrcweir 
2278*cdf0e10cSrcweir         bool bPaint = false;
2279*cdf0e10cSrcweir         SdrObjListIter aIter( *pPage );
2280*cdf0e10cSrcweir         while ( aIter.IsMore() )
2281*cdf0e10cSrcweir         {
2282*cdf0e10cSrcweir             SdrObject* pSdrObject = aIter.Next();
2283*cdf0e10cSrcweir             FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
2284*cdf0e10cSrcweir             if ( !pFormObject )
2285*cdf0e10cSrcweir                 continue;
2286*cdf0e10cSrcweir 
2287*cdf0e10cSrcweir             Reference< XInterface > xControlModel( pFormObject->GetUnoControlModel() );
2288*cdf0e10cSrcweir             if ( xControlModel != xFormComponent )
2289*cdf0e10cSrcweir                 continue;
2290*cdf0e10cSrcweir 
2291*cdf0e10cSrcweir             // mark the object
2292*cdf0e10cSrcweir             if ( bMark != pFormView->IsObjMarked( pSdrObject ) )
2293*cdf0e10cSrcweir                 // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
2294*cdf0e10cSrcweir                 pFormView->MarkObj( pSdrObject, pPageView, !bMark, sal_False );
2295*cdf0e10cSrcweir 
2296*cdf0e10cSrcweir             if ( !bMarkHandles || !bMark )
2297*cdf0e10cSrcweir                 continue;
2298*cdf0e10cSrcweir 
2299*cdf0e10cSrcweir             bPaint = true;
2300*cdf0e10cSrcweir 
2301*cdf0e10cSrcweir         } // while ( aIter.IsMore() )
2302*cdf0e10cSrcweir         if ( bPaint )
2303*cdf0e10cSrcweir         {
2304*cdf0e10cSrcweir             // make the mark visible
2305*cdf0e10cSrcweir             ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
2306*cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2307*cdf0e10cSrcweir             {
2308*cdf0e10cSrcweir                 SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i );
2309*cdf0e10cSrcweir                 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
2310*cdf0e10cSrcweir                 if ( OUTDEV_WINDOW == rOutDev.GetOutDevType() )
2311*cdf0e10cSrcweir                 {
2312*cdf0e10cSrcweir                     pFormView->MakeVisible( aMarkRect, (Window&)rOutDev );
2313*cdf0e10cSrcweir                 }
2314*cdf0e10cSrcweir             } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2315*cdf0e10cSrcweir         }
2316*cdf0e10cSrcweir     }
2317*cdf0e10cSrcweir 
2318*cdf0e10cSrcweir //............................................................................
2319*cdf0e10cSrcweir }	// namespace svxform
2320*cdf0e10cSrcweir //............................................................................
2321*cdf0e10cSrcweir 
2322*cdf0e10cSrcweir 
2323