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