Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/dialmgr.hxx>
30 : : #include <svx/fmshell.hxx>
31 : : #include <svx/fmmodel.hxx>
32 : : #include <svx/fmpage.hxx>
33 : : #include <svx/fmglob.hxx>
34 : : #include "svx/svditer.hxx"
35 : : #include <svx/svdogrp.hxx>
36 : : #include <svx/svdpagv.hxx>
37 : :
38 : : #include "fmprop.hrc"
39 : :
40 : : #include "fmundo.hxx"
41 : : #include "fmhelp.hrc"
42 : : #include "fmexpl.hrc"
43 : : #include "fmexpl.hxx"
44 : : #include "svx/fmresids.hrc"
45 : : #include "fmshimp.hxx"
46 : : #include "fmobj.hxx"
47 : : #include <sfx2/objsh.hxx>
48 : : #include <tools/diagnose_ex.h>
49 : : #include <rtl/logfile.hxx>
50 : : #include <com/sun/star/container/XContainer.hpp>
51 : :
52 : : //............................................................................
53 : : namespace svxform
54 : : {
55 : : //............................................................................
56 : :
57 : : using namespace ::com::sun::star::uno;
58 : : using namespace ::com::sun::star::lang;
59 : : using namespace ::com::sun::star::beans;
60 : : using namespace ::com::sun::star::form;
61 : : using namespace ::com::sun::star::awt;
62 : : using namespace ::com::sun::star::container;
63 : : using namespace ::com::sun::star::script;
64 : : using namespace ::com::sun::star::sdb;
65 : :
66 : : //========================================================================
67 : : // class OFormComponentObserver
68 : : //========================================================================
69 : : //------------------------------------------------------------------------
70 : 0 : OFormComponentObserver::OFormComponentObserver(NavigatorTreeModel* _pModel)
71 : : :m_pNavModel(_pModel)
72 : : ,m_nLocks(0)
73 : 0 : ,m_bCanUndo(sal_True)
74 : : {
75 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::OFormComponentObserver" );
76 : 0 : }
77 : :
78 : : // XPropertyChangeListener
79 : : //------------------------------------------------------------------------
80 : 0 : void SAL_CALL OFormComponentObserver::disposing(const EventObject& Source) throw( RuntimeException )
81 : : {
82 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::disposing" );
83 : 0 : Remove( Source.Source );
84 : 0 : }
85 : :
86 : : //------------------------------------------------------------------------
87 : 0 : void SAL_CALL OFormComponentObserver::propertyChange(const PropertyChangeEvent& evt) throw(RuntimeException)
88 : : {
89 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::propertyChange" );
90 [ # # ]: 0 : if( !m_pNavModel ) return;
91 [ # # ][ # # ]: 0 : if( evt.PropertyName != FM_PROP_NAME ) return;
92 : :
93 [ # # ]: 0 : Reference< XFormComponent > xFormComponent(evt.Source, UNO_QUERY);
94 [ # # ]: 0 : Reference< XForm > xForm(evt.Source, UNO_QUERY);
95 : :
96 : 0 : FmEntryData* pEntryData( NULL );
97 [ # # ]: 0 : if( xForm.is() )
98 [ # # ]: 0 : pEntryData = m_pNavModel->FindData( xForm, m_pNavModel->GetRootList() );
99 [ # # ]: 0 : else if( xFormComponent.is() )
100 [ # # ]: 0 : pEntryData = m_pNavModel->FindData( xFormComponent, m_pNavModel->GetRootList() );
101 : :
102 [ # # ]: 0 : if( pEntryData )
103 : : {
104 [ # # ]: 0 : ::rtl::OUString aNewName = ::comphelper::getString(evt.NewValue);
105 : 0 : pEntryData->SetText( aNewName );
106 [ # # ]: 0 : FmNavNameChangedHint aNameChangedHint( pEntryData, aNewName );
107 [ # # ][ # # ]: 0 : m_pNavModel->Broadcast( aNameChangedHint );
108 : 0 : }
109 : : }
110 : :
111 : : // XContainerListener
112 : : //------------------------------------------------------------------------------
113 : 0 : void SAL_CALL OFormComponentObserver::elementInserted(const ContainerEvent& evt) throw(RuntimeException)
114 : : {
115 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementInserted" );
116 [ # # ][ # # ]: 0 : if (IsLocked() || !m_pNavModel)
[ # # ]
117 : 0 : return;
118 : :
119 : : // keine Undoaction einfuegen
120 : 0 : m_bCanUndo = sal_False;
121 : :
122 : 0 : Reference< XInterface > xTemp;
123 [ # # ]: 0 : evt.Element >>= xTemp;
124 [ # # ][ # # ]: 0 : Insert(xTemp, ::comphelper::getINT32(evt.Accessor));
125 : :
126 : 0 : m_bCanUndo = sal_True;
127 : : }
128 : :
129 : : //------------------------------------------------------------------------------
130 : 0 : void OFormComponentObserver::Insert(const Reference< XInterface > & xIface, sal_Int32 nIndex)
131 : : {
132 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::Insert" );
133 [ # # ]: 0 : Reference< XForm > xForm(xIface, UNO_QUERY);
134 [ # # ]: 0 : if (xForm.is())
135 : : {
136 [ # # ]: 0 : m_pNavModel->InsertForm(xForm, sal_uInt32(nIndex));
137 [ # # ]: 0 : Reference< XIndexContainer > xContainer(xForm, UNO_QUERY);
138 : 0 : Reference< XInterface > xTemp;
139 [ # # ][ # # ]: 0 : for (sal_Int32 i = 0; i < xContainer->getCount(); i++)
[ # # ]
140 : : {
141 [ # # ][ # # ]: 0 : xContainer->getByIndex(i) >>= xTemp;
[ # # ]
142 [ # # ]: 0 : Insert(xTemp, i);
143 : 0 : }
144 : : }
145 : : else
146 : : {
147 [ # # ]: 0 : Reference< XFormComponent > xFormComp(xIface, UNO_QUERY);
148 [ # # ]: 0 : if (xFormComp.is())
149 [ # # ]: 0 : m_pNavModel->InsertFormComponent(xFormComp, sal_uInt32(nIndex));
150 : 0 : }
151 : 0 : }
152 : :
153 : : //------------------------------------------------------------------------------
154 : 0 : void SAL_CALL OFormComponentObserver::elementReplaced(const ContainerEvent& evt) throw(RuntimeException)
155 : : {
156 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementReplaced" );
157 [ # # ][ # # ]: 0 : if (IsLocked() || !m_pNavModel)
[ # # ]
158 : 0 : return;
159 : :
160 : 0 : m_bCanUndo = sal_False;
161 : :
162 : : // EntryData loeschen
163 : 0 : Reference< XFormComponent > xReplaced;
164 [ # # ]: 0 : evt.ReplacedElement >>= xReplaced;
165 [ # # ]: 0 : FmEntryData* pEntryData = m_pNavModel->FindData(xReplaced, m_pNavModel->GetRootList(), sal_True);
166 [ # # ]: 0 : if (pEntryData)
167 : : {
168 [ # # ][ # # ]: 0 : if (pEntryData->ISA(FmControlData))
[ # # ]
169 : : {
170 : 0 : Reference< XFormComponent > xComp;
171 [ # # ]: 0 : evt.Element >>= xComp;
172 : : DBG_ASSERT(xComp.is(), "OFormComponentObserver::elementReplaced : invalid argument !");
173 : : // an einer FmControlData sollte eine XFormComponent haengen
174 [ # # ]: 0 : m_pNavModel->ReplaceFormComponent(xReplaced, xComp);
175 : : }
176 [ # # ][ # # ]: 0 : else if (pEntryData->ISA(FmFormData))
177 : : {
178 : : OSL_FAIL("replacing forms not implemented yet !");
179 : : }
180 : : }
181 : :
182 : 0 : m_bCanUndo = sal_True;
183 : : }
184 : :
185 : : //------------------------------------------------------------------------------
186 : 0 : void OFormComponentObserver::Remove( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement )
187 : : {
188 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::Remove" );
189 [ # # ][ # # ]: 0 : if (IsLocked() || !m_pNavModel)
[ # # ]
190 : 0 : return;
191 : :
192 : 0 : m_bCanUndo = sal_False;
193 : :
194 : : //////////////////////////////////////////////////////////
195 : : // EntryData loeschen
196 : 0 : FmEntryData* pEntryData = m_pNavModel->FindData( _rxElement, m_pNavModel->GetRootList(), sal_True );
197 [ # # ]: 0 : if (pEntryData)
198 : 0 : m_pNavModel->Remove(pEntryData);
199 : :
200 : 0 : m_bCanUndo = sal_True;
201 : : }
202 : :
203 : : //------------------------------------------------------------------------------
204 : 0 : void SAL_CALL OFormComponentObserver::elementRemoved(const ContainerEvent& evt) throw(RuntimeException)
205 : : {
206 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementRemoved" );
207 : 0 : Reference< XInterface > xElement;
208 [ # # ]: 0 : evt.Element >>= xElement;
209 [ # # ]: 0 : Remove( xElement );
210 : 0 : }
211 : :
212 : : //========================================================================
213 : : // class NavigatorTreeModel
214 : : //========================================================================
215 : :
216 : : //------------------------------------------------------------------------
217 : 0 : NavigatorTreeModel::NavigatorTreeModel( const ImageList& _rNormalImages )
218 : : :m_pFormShell(NULL)
219 : : ,m_pFormPage(NULL)
220 : : ,m_pFormModel(NULL)
221 [ # # ][ # # ]: 0 : ,m_aNormalImages( _rNormalImages )
222 : : {
223 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::NavigatorTreeModel" );
224 [ # # ]: 0 : m_pPropChangeList = new OFormComponentObserver(this);
225 : 0 : m_pPropChangeList->acquire();
226 [ # # ][ # # ]: 0 : m_pRootList = new FmEntryDataList();
227 : 0 : }
228 : :
229 : : //------------------------------------------------------------------------
230 [ # # ][ # # ]: 0 : NavigatorTreeModel::~NavigatorTreeModel()
231 : : {
232 : : //////////////////////////////////////////////////////////////////////
233 : : // Als Listener abmelden
234 [ # # ]: 0 : if( m_pFormShell)
235 : : {
236 : 0 : FmFormModel* pFormModel = m_pFormShell->GetFormModel();
237 [ # # ][ # # ]: 0 : if( pFormModel && IsListening(*pFormModel))
[ # # ][ # # ]
238 [ # # ]: 0 : EndListening( *pFormModel );
239 : :
240 [ # # ][ # # ]: 0 : if (IsListening(*m_pFormShell))
241 [ # # ]: 0 : EndListening(*m_pFormShell);
242 : : }
243 : :
244 [ # # ]: 0 : Clear();
245 [ # # ][ # # ]: 0 : delete m_pRootList;
246 : 0 : m_pPropChangeList->ReleaseModel();
247 : 0 : m_pPropChangeList->release();
248 [ # # ]: 0 : }
249 : :
250 : :
251 : : //------------------------------------------------------------------------
252 : 0 : void NavigatorTreeModel::SetModified( sal_Bool bMod )
253 : : {
254 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::SetModified" );
255 [ # # ]: 0 : if( !m_pFormShell ) return;
256 : 0 : SfxObjectShell* pObjShell = m_pFormShell->GetFormModel()->GetObjectShell();
257 [ # # ]: 0 : if( !pObjShell ) return;
258 : 0 : pObjShell->SetModified( bMod );
259 : : }
260 : :
261 : : //------------------------------------------------------------------------
262 : 0 : void NavigatorTreeModel::Clear()
263 : : {
264 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Clear" );
265 [ # # ]: 0 : Reference< XNameContainer > xForms( GetForms());
266 [ # # ]: 0 : Reference< XContainer > xContainer(xForms, UNO_QUERY);
267 [ # # ]: 0 : if (xContainer.is())
268 [ # # ][ # # ]: 0 : xContainer->removeContainerListener((XContainerListener*)m_pPropChangeList);
[ # # ][ # # ]
269 : :
270 : : //////////////////////////////////////////////////////////////////////
271 : : // RootList loeschen
272 [ # # ]: 0 : GetRootList()->clear();
273 : :
274 : : //////////////////////////////////////////////////////////////////////
275 : : // UI benachrichtigen
276 [ # # ]: 0 : FmNavClearedHint aClearedHint;
277 [ # # ][ # # ]: 0 : Broadcast( aClearedHint );
278 : 0 : }
279 : :
280 : : //------------------------------------------------------------------------
281 : 0 : Reference< XNameContainer > NavigatorTreeModel::GetForms() const
282 : : {
283 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::GetForms" );
284 [ # # ][ # # ]: 0 : if( !m_pFormShell || !m_pFormShell->GetCurPage())
[ # # ]
285 : 0 : return NULL;
286 : : else
287 : 0 : return m_pFormShell->GetCurPage()->GetForms();
288 : : }
289 : :
290 : : //------------------------------------------------------------------------
291 : 0 : void NavigatorTreeModel::Insert(FmEntryData* pEntry, sal_uLong nRelPos, sal_Bool bAlterModel)
292 : : {
293 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Insert" );
294 [ # # ][ # # ]: 0 : if (IsListening(*m_pFormModel))
295 [ # # ]: 0 : EndListening(*m_pFormModel);
296 : :
297 : 0 : m_pPropChangeList->Lock();
298 : 0 : FmFormData* pFolder = (FmFormData*) pEntry->GetParent();
299 : 0 : Reference< XChild > xElement( pEntry->GetChildIFace() );
300 [ # # ]: 0 : if (bAlterModel)
301 : : {
302 [ # # ]: 0 : XubString aStr;
303 [ # # ][ # # ]: 0 : if (pEntry->ISA(FmFormData))
[ # # ]
304 [ # # ][ # # ]: 0 : aStr = SVX_RESSTR(RID_STR_FORM);
[ # # ]
305 : : else
306 [ # # ][ # # ]: 0 : aStr = SVX_RESSTR(RID_STR_CONTROL);
[ # # ]
307 : :
308 : 0 : Reference< XIndexContainer > xContainer;
309 [ # # ]: 0 : if (pFolder)
310 [ # # ][ # # ]: 0 : xContainer = Reference< XIndexContainer > (pFolder->GetFormIface(), UNO_QUERY);
311 : : else
312 [ # # ][ # # ]: 0 : xContainer = Reference< XIndexContainer > (GetForms(), UNO_QUERY);
[ # # ]
313 : :
314 [ # # ]: 0 : bool bUndo = m_pFormModel->IsUndoEnabled();
315 : :
316 [ # # ]: 0 : if( bUndo )
317 : : {
318 [ # # ][ # # ]: 0 : XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
319 [ # # ][ # # ]: 0 : aUndoStr.SearchAndReplace(rtl::OUString('#'), aStr);
[ # # ]
320 [ # # ][ # # ]: 0 : m_pFormModel->BegUndo(aUndoStr);
321 : : }
322 : :
323 [ # # ][ # # ]: 0 : if (nRelPos >= (sal_uInt32)xContainer->getCount())
[ # # ]
324 [ # # ][ # # ]: 0 : nRelPos = (sal_uInt32)xContainer->getCount();
325 : :
326 : : // UndoAction
327 [ # # ][ # # ]: 0 : if ( bUndo && m_pPropChangeList->CanUndo())
[ # # ]
328 : : {
329 : : m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
330 : : FmUndoContainerAction::Inserted,
331 : : xContainer,
332 : : xElement,
333 [ # # ][ # # ]: 0 : nRelPos));
[ # # ]
334 : : }
335 : :
336 : : // das Element muss den Typ haben, den der Container erwartet
337 [ # # # # ]: 0 : if (xContainer->getElementType() ==
338 [ # # ][ # # ]: 0 : ::getCppuType((const Reference< XForm>*)0))
339 : :
340 : : {
341 [ # # ]: 0 : Reference< XForm > xElementAsForm(xElement, UNO_QUERY);
342 [ # # ][ # # ]: 0 : xContainer->insertByIndex(nRelPos, makeAny(xElementAsForm));
[ # # ]
343 : : }
344 [ # # # # ]: 0 : else if (xContainer->getElementType() ==
345 [ # # ][ # # ]: 0 : ::getCppuType((const Reference< XFormComponent>*)0))
346 : :
347 : : {
348 [ # # ]: 0 : Reference< XFormComponent > xElementAsComponent(xElement, UNO_QUERY);
349 [ # # ][ # # ]: 0 : xContainer->insertByIndex(nRelPos, makeAny(xElementAsComponent));
[ # # ]
350 : : }
351 : : else
352 : : {
353 : : OSL_FAIL("NavigatorTreeModel::Insert : the parent container needs an elementtype I don't know !");
354 : : }
355 : :
356 [ # # ]: 0 : if( bUndo )
357 [ # # ][ # # ]: 0 : m_pFormModel->EndUndo();
358 : : }
359 : :
360 : : //////////////////////////////////////////////////////////////////////
361 : : // Als PropertyChangeListener anmelden
362 [ # # ]: 0 : Reference< XPropertySet > xSet(xElement, UNO_QUERY);
363 [ # # ]: 0 : if( xSet.is() )
364 [ # # ][ # # ]: 0 : xSet->addPropertyChangeListener( FM_PROP_NAME, m_pPropChangeList );
[ # # ][ # # ]
[ # # ]
365 : :
366 : : //////////////////////////////////////////////////////////////////////
367 : : // Daten aus Model entfernen
368 [ # # ][ # # ]: 0 : if (pEntry->ISA(FmFormData))
[ # # ]
369 : : {
370 [ # # ]: 0 : Reference< XContainer > xContainer(xElement, UNO_QUERY);
371 [ # # ]: 0 : if (xContainer.is())
372 [ # # ][ # # ]: 0 : xContainer->addContainerListener((XContainerListener*)m_pPropChangeList);
[ # # ][ # # ]
373 : : }
374 : :
375 [ # # ]: 0 : if (pFolder)
376 [ # # ]: 0 : pFolder->GetChildList()->insert( pEntry, nRelPos );
377 : : else
378 [ # # ]: 0 : GetRootList()->insert( pEntry, nRelPos );
379 : :
380 : : //////////////////////////////////////////////////////////////////////
381 : : // UI benachrichtigen
382 [ # # ]: 0 : FmNavInsertedHint aInsertedHint( pEntry, nRelPos );
383 [ # # ]: 0 : Broadcast( aInsertedHint );
384 : :
385 : 0 : m_pPropChangeList->UnLock();
386 [ # # ][ # # ]: 0 : if (IsListening(*m_pFormModel))
387 [ # # ][ # # ]: 0 : StartListening(*m_pFormModel);
388 : 0 : }
389 : :
390 : : //------------------------------------------------------------------------
391 : 0 : void NavigatorTreeModel::Remove(FmEntryData* pEntry, sal_Bool bAlterModel)
392 : : {
393 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Remove" );
394 : : //////////////////////////////////////////////////////////////////////
395 : : // Form und Parent holen
396 [ # # ][ # # ]: 0 : if (!pEntry || !m_pFormModel)
397 : 0 : return;
398 : :
399 [ # # ][ # # ]: 0 : if (IsListening(*m_pFormModel))
400 [ # # ]: 0 : EndListening(*m_pFormModel);
401 : :
402 [ # # ]: 0 : const bool bUndo = m_pFormModel->IsUndoEnabled();
403 : :
404 : 0 : m_pPropChangeList->Lock();
405 : 0 : FmFormData* pFolder = (FmFormData*) pEntry->GetParent();
406 : 0 : Reference< XChild > xElement ( pEntry->GetChildIFace() );
407 [ # # ]: 0 : if (bAlterModel)
408 : : {
409 [ # # ]: 0 : XubString aStr;
410 [ # # ][ # # ]: 0 : if (pEntry->ISA(FmFormData))
[ # # ]
411 [ # # ][ # # ]: 0 : aStr = SVX_RESSTR(RID_STR_FORM);
[ # # ]
412 : : else
413 [ # # ][ # # ]: 0 : aStr = SVX_RESSTR(RID_STR_CONTROL);
[ # # ]
414 : :
415 [ # # ]: 0 : if( bUndo )
416 : : {
417 [ # # ][ # # ]: 0 : XubString aUndoStr(SVX_RESSTR(RID_STR_UNDO_CONTAINER_REMOVE));
[ # # ]
418 [ # # ][ # # ]: 0 : aUndoStr.SearchAndReplace(rtl::OUString('#'), aStr);
[ # # ]
419 [ # # ][ # # ]: 0 : m_pFormModel->BegUndo(aUndoStr);
420 [ # # ]: 0 : }
421 : : }
422 : :
423 : : // jetzt die eigentliche Entfernung der Daten aus dem Model
424 [ # # ][ # # ]: 0 : if (pEntry->ISA(FmFormData))
[ # # ]
425 [ # # ]: 0 : RemoveForm((FmFormData*)pEntry);
426 : : else
427 [ # # ]: 0 : RemoveFormComponent((FmControlData*)pEntry);
428 : :
429 : :
430 [ # # ]: 0 : if (bAlterModel)
431 : : {
432 [ # # ][ # # ]: 0 : Reference< XIndexContainer > xContainer(xElement->getParent(), UNO_QUERY);
[ # # ]
433 : : // aus dem Container entfernen
434 [ # # ][ # # ]: 0 : sal_Int32 nContainerIndex = getElementPos(xContainer.get(), xElement);
[ # # ]
435 : : // UndoAction
436 [ # # ]: 0 : if (nContainerIndex >= 0)
437 : : {
438 [ # # ][ # # ]: 0 : if ( bUndo && m_pPropChangeList->CanUndo())
[ # # ]
439 : : {
440 : : m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
441 : : FmUndoContainerAction::Removed,
442 : : xContainer,
443 [ # # ][ # # ]: 0 : xElement, nContainerIndex ));
[ # # ]
444 : : }
445 [ # # ]: 0 : else if( !m_pPropChangeList->CanUndo() )
446 : : {
447 [ # # ]: 0 : FmUndoContainerAction::DisposeElement( xElement );
448 : : }
449 : :
450 [ # # ][ # # ]: 0 : xContainer->removeByIndex(nContainerIndex );
451 : : }
452 : :
453 [ # # ]: 0 : if( bUndo )
454 [ # # ]: 0 : m_pFormModel->EndUndo();
455 : : }
456 : :
457 : : // beim Vater austragen
458 [ # # ]: 0 : if (pFolder)
459 [ # # ]: 0 : pFolder->GetChildList()->remove( pEntry );
460 : : else
461 : : {
462 [ # # ]: 0 : GetRootList()->remove( pEntry );
463 : : //////////////////////////////////////////////////////////////////////
464 : : // Wenn keine Form mehr in der Root, an der Shell CurForm zuruecksetzen
465 [ # # ]: 0 : if ( !GetRootList()->size() )
466 [ # # ]: 0 : m_pFormShell->GetImpl()->forgetCurrentForm();
467 : : }
468 : :
469 : : //////////////////////////////////////////////////////////////////////
470 : : // UI benachrichtigen
471 [ # # ]: 0 : FmNavRemovedHint aRemovedHint( pEntry );
472 [ # # ]: 0 : Broadcast( aRemovedHint );
473 : :
474 : : // Eintrag loeschen
475 [ # # ][ # # ]: 0 : delete pEntry;
476 : :
477 : 0 : m_pPropChangeList->UnLock();
478 [ # # ][ # # ]: 0 : StartListening(*m_pFormModel);
479 : : }
480 : :
481 : : //------------------------------------------------------------------------
482 : 0 : void NavigatorTreeModel::RemoveForm(FmFormData* pFormData)
483 : : {
484 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveForm" );
485 : : //////////////////////////////////////////////////////////////////////
486 : : // Form und Parent holen
487 [ # # ][ # # ]: 0 : if (!pFormData || !m_pFormModel)
488 : 0 : return;
489 : :
490 : 0 : FmEntryDataList* pChildList = pFormData->GetChildList();
491 [ # # ]: 0 : for ( size_t i = pChildList->size(); i > 0; )
492 : : {
493 [ # # ]: 0 : FmEntryData* pEntryData = pChildList->at( --i );
494 : :
495 : : //////////////////////////////////////////////////////////////////////
496 : : // Child ist Form -> rekursiver Aufruf
497 [ # # ][ # # ]: 0 : if( pEntryData->ISA(FmFormData) )
[ # # ]
498 [ # # ]: 0 : RemoveForm( (FmFormData*)pEntryData);
499 [ # # ][ # # ]: 0 : else if( pEntryData->ISA(FmControlData) )
[ # # ]
500 [ # # ]: 0 : RemoveFormComponent((FmControlData*) pEntryData);
501 : : }
502 : :
503 : : //////////////////////////////////////////////////////////////////////
504 : : // Als PropertyChangeListener abmelden
505 : 0 : Reference< XPropertySet > xSet( pFormData->GetPropertySet() );
506 [ # # ]: 0 : if ( xSet.is() )
507 [ # # ][ # # ]: 0 : xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList );
[ # # ][ # # ]
[ # # ]
508 : :
509 : 0 : Reference< XContainer > xContainer( pFormData->GetContainer() );
510 [ # # ]: 0 : if (xContainer.is())
511 [ # # ][ # # ]: 0 : xContainer->removeContainerListener((XContainerListener*)m_pPropChangeList);
[ # # ][ # # ]
512 : : }
513 : :
514 : : //------------------------------------------------------------------------
515 : 0 : void NavigatorTreeModel::RemoveFormComponent(FmControlData* pControlData)
516 : : {
517 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveFormComponent" );
518 : : //////////////////////////////////////////////////////////////////////
519 : : // Control und Parent holen
520 [ # # ]: 0 : if (!pControlData)
521 : 0 : return;
522 : :
523 : : //////////////////////////////////////////////////////////////////////
524 : : // Als PropertyChangeListener abmelden
525 : 0 : Reference< XPropertySet > xSet( pControlData->GetPropertySet() );
526 [ # # ]: 0 : if (xSet.is())
527 [ # # ][ # # ]: 0 : xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList);
[ # # ][ # # ]
[ # # ]
528 : : }
529 : :
530 : : //------------------------------------------------------------------------
531 : 0 : void NavigatorTreeModel::ClearBranch( FmFormData* pParentData )
532 : : {
533 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::ClearBranch" );
534 : : //////////////////////////////////////////////////////////////////////
535 : : // Alle Eintraege dieses Zweiges loeschen
536 : 0 : FmEntryDataList* pChildList = pParentData->GetChildList();
537 : :
538 [ # # ]: 0 : for( size_t i = pChildList->size(); i > 0; )
539 : : {
540 : 0 : FmEntryData* pChildData = pChildList->at( --i );
541 [ # # ]: 0 : if( pChildData->ISA(FmFormData) )
542 : 0 : ClearBranch( (FmFormData*)pChildData );
543 : :
544 : 0 : pChildList->remove( pChildData );
545 : : }
546 : 0 : }
547 : :
548 : : //------------------------------------------------------------------------
549 : 0 : void NavigatorTreeModel::FillBranch( FmFormData* pFormData )
550 : : {
551 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FillBranch" );
552 : : //////////////////////////////////////////////////////////////
553 : : // Forms aus der Root einfuegen
554 [ # # ]: 0 : if( pFormData == NULL )
555 : : {
556 [ # # ][ # # ]: 0 : Reference< XIndexContainer > xForms(GetForms(), UNO_QUERY);
557 [ # # ]: 0 : if (!xForms.is())
558 : : return;
559 : :
560 : 0 : Reference< XForm > xSubForm;
561 : : FmFormData* pSubFormData;
562 [ # # ][ # # ]: 0 : for (sal_Int32 i=0; i<xForms->getCount(); ++i)
[ # # ]
563 : : {
564 : : DBG_ASSERT( xForms->getByIndex(i).getValueType() == ::getCppuType((const Reference< XForm>*)NULL),
565 : : "NavigatorTreeModel::FillBranch : the root container should supply only elements of type XForm");
566 : :
567 [ # # ][ # # ]: 0 : xForms->getByIndex(i) >>= xSubForm;
[ # # ]
568 [ # # ][ # # ]: 0 : pSubFormData = new FmFormData( xSubForm, m_aNormalImages, pFormData );
569 [ # # ]: 0 : Insert( pSubFormData, LIST_APPEND );
570 : :
571 : : //////////////////////////////////////////////////////////////
572 : : // Neuer Branch, wenn SubForm wiederum Subforms enthaelt
573 [ # # ]: 0 : FillBranch( pSubFormData );
574 [ # # ]: 0 : }
575 : : }
576 : :
577 : : //////////////////////////////////////////////////////////////
578 : : // Componenten einfuegen
579 : : else
580 : : {
581 [ # # ]: 0 : Reference< XIndexContainer > xComponents( GetFormComponents(pFormData));
582 [ # # ]: 0 : if( !xComponents.is() ) return;
583 : :
584 : 0 : Reference< XInterface > xInterface;
585 : 0 : Reference< XPropertySet > xSet;
586 : : FmControlData* pNewControlData;
587 : : FmFormData* pSubFormData;
588 : :
589 : 0 : Reference< XFormComponent > xCurrentComponent;
590 [ # # ][ # # ]: 0 : for (sal_Int32 j=0; j<xComponents->getCount(); ++j)
[ # # ]
591 : : {
592 [ # # ][ # # ]: 0 : xComponents->getByIndex(j) >>= xCurrentComponent;
[ # # ]
593 [ # # ]: 0 : Reference< XForm > xSubForm(xCurrentComponent, UNO_QUERY);
594 : :
595 [ # # ]: 0 : if (xSubForm.is())
596 : : { // die aktuelle Component ist eine Form
597 [ # # ][ # # ]: 0 : pSubFormData = new FmFormData(xSubForm, m_aNormalImages, pFormData);
598 [ # # ]: 0 : Insert(pSubFormData, LIST_APPEND);
599 : :
600 : : //////////////////////////////////////////////////////////////
601 : : // Neuer Branch, wenn SubForm wiederum Subforms enthaelt
602 [ # # ]: 0 : FillBranch(pSubFormData);
603 : : }
604 : : else
605 : : {
606 [ # # ][ # # ]: 0 : pNewControlData = new FmControlData(xCurrentComponent, m_aNormalImages, pFormData);
607 [ # # ]: 0 : Insert(pNewControlData, LIST_APPEND);
608 : : }
609 [ # # ]: 0 : }
610 : : }
611 : : }
612 : :
613 : : //------------------------------------------------------------------------
614 : 0 : void NavigatorTreeModel::InsertForm(const Reference< XForm > & xForm, sal_uInt32 nRelPos)
615 : : {
616 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertForm" );
617 [ # # ]: 0 : FmFormData* pFormData = (FmFormData*)FindData( xForm, GetRootList() );
618 [ # # ]: 0 : if (pFormData)
619 : 0 : return;
620 : :
621 : : //////////////////////////////////////////////////////////
622 : : // ParentData setzen
623 [ # # ][ # # ]: 0 : Reference< XInterface > xIFace( xForm->getParent());
624 [ # # ]: 0 : Reference< XForm > xParentForm(xIFace, UNO_QUERY);
625 : 0 : FmFormData* pParentData = NULL;
626 [ # # ]: 0 : if (xParentForm.is())
627 [ # # ]: 0 : pParentData = (FmFormData*)FindData( xParentForm, GetRootList() );
628 : :
629 [ # # ][ # # ]: 0 : pFormData = new FmFormData( xForm, m_aNormalImages, pParentData );
630 [ # # ]: 0 : Insert( pFormData, nRelPos );
631 : : }
632 : :
633 : : //------------------------------------------------------------------------
634 : 0 : void NavigatorTreeModel::InsertFormComponent(const Reference< XFormComponent > & xComp, sal_uInt32 nRelPos)
635 : : {
636 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertFormComponent" );
637 : : //////////////////////////////////////////////////////////
638 : : // ParentData setzen
639 [ # # ][ # # ]: 0 : Reference< XInterface > xIFace( xComp->getParent());
640 [ # # ]: 0 : Reference< XForm > xForm(xIFace, UNO_QUERY);
641 [ # # ]: 0 : if (!xForm.is())
642 : 0 : return;
643 : :
644 [ # # ]: 0 : FmFormData* pParentData = (FmFormData*)FindData( xForm, GetRootList() );
645 [ # # ]: 0 : if( !pParentData )
646 : : {
647 [ # # ][ # # ]: 0 : pParentData = new FmFormData( xForm, m_aNormalImages, NULL );
648 [ # # ]: 0 : Insert( pParentData, LIST_APPEND );
649 : : }
650 : :
651 [ # # ][ # # ]: 0 : if (!FindData(xComp, pParentData->GetChildList(),sal_False))
652 : : {
653 : : //////////////////////////////////////////////////////////
654 : : // Neue EntryData setzen
655 [ # # ][ # # ]: 0 : FmEntryData* pNewEntryData = new FmControlData( xComp, m_aNormalImages, pParentData );
656 : :
657 : : //////////////////////////////////////////////////////////
658 : : // Neue EntryData einfuegen
659 [ # # ]: 0 : Insert( pNewEntryData, nRelPos );
660 [ # # ][ # # ]: 0 : }
661 : : }
662 : :
663 : : //------------------------------------------------------------------------
664 : 0 : void NavigatorTreeModel::ReplaceFormComponent(
665 : : const Reference< XFormComponent > & xOld,
666 : : const Reference< XFormComponent > & xNew
667 : : )
668 : : {
669 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::ReplaceFormComponent" );
670 [ # # ]: 0 : FmEntryData* pData = FindData(xOld, GetRootList(), sal_True);
671 : : DBG_ASSERT(pData && pData->ISA(FmControlData), "NavigatorTreeModel::ReplaceFormComponent : invalid argument !");
672 [ # # ]: 0 : ((FmControlData*)pData)->ModelReplaced( xNew, m_aNormalImages );
673 : :
674 [ # # ]: 0 : FmNavModelReplacedHint aReplacedHint( pData );
675 [ # # ][ # # ]: 0 : Broadcast( aReplacedHint );
676 : 0 : }
677 : :
678 : : //------------------------------------------------------------------------
679 : 0 : FmEntryData* NavigatorTreeModel::FindData(const Reference< XInterface > & xElement, FmEntryDataList* pDataList, sal_Bool bRecurs)
680 : : {
681 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FindData" );
682 : : // normalize
683 [ # # ]: 0 : Reference< XInterface > xIFace( xElement, UNO_QUERY );
684 : :
685 [ # # ]: 0 : for ( size_t i = 0; i < pDataList->size(); i++ )
686 : : {
687 [ # # ]: 0 : FmEntryData* pEntryData = pDataList->at( i );
688 [ # # ][ # # ]: 0 : if ( pEntryData->GetElement().get() == xIFace.get() )
[ # # ]
689 : 0 : return pEntryData;
690 [ # # ]: 0 : else if (bRecurs)
691 : : {
692 [ # # ]: 0 : pEntryData = FindData( xElement, pEntryData->GetChildList() );
693 [ # # ]: 0 : if (pEntryData)
694 : 0 : return pEntryData;
695 : : }
696 : : }
697 : 0 : return NULL;
698 : : }
699 : :
700 : : //------------------------------------------------------------------------
701 : 0 : FmEntryData* NavigatorTreeModel::FindData( const ::rtl::OUString& rText, FmFormData* pParentData, sal_Bool bRecurs )
702 : : {
703 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FindData" );
704 : : FmEntryDataList* pDataList;
705 [ # # ]: 0 : if( !pParentData )
706 : 0 : pDataList = GetRootList();
707 : : else
708 : 0 : pDataList = pParentData->GetChildList();
709 : :
710 : 0 : ::rtl::OUString aEntryText;
711 : : FmEntryData* pEntryData;
712 : : FmEntryData* pChildData;
713 : :
714 [ # # ]: 0 : for( size_t i = 0; i < pDataList->size(); i++ )
715 : : {
716 [ # # ]: 0 : pEntryData = pDataList->at( i );
717 : 0 : aEntryText = pEntryData->GetText();
718 : :
719 [ # # ]: 0 : if (rText == aEntryText)
720 : 0 : return pEntryData;
721 : :
722 [ # # ][ # # ]: 0 : if( bRecurs && pEntryData->ISA(FmFormData) )
[ # # ][ # # ]
[ # # ]
723 : : {
724 [ # # ]: 0 : pChildData = FindData( rText, (FmFormData*)pEntryData );
725 [ # # ]: 0 : if( pChildData )
726 : 0 : return pChildData;
727 : : }
728 : : }
729 : :
730 : 0 : return NULL;
731 : : }
732 : :
733 : : //------------------------------------------------------------------------
734 : 0 : void NavigatorTreeModel::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
735 : : {
736 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Notify" );
737 [ # # ]: 0 : if( rHint.ISA(SdrHint) )
738 : : {
739 : 0 : SdrHint* pSdrHint = (SdrHint*)&rHint;
740 [ # # # ]: 0 : switch( pSdrHint->GetKind() )
741 : : {
742 : : case HINT_OBJINSERTED:
743 : 0 : InsertSdrObj(pSdrHint->GetObject());
744 : 0 : break;
745 : : case HINT_OBJREMOVED:
746 : 0 : RemoveSdrObj(pSdrHint->GetObject());
747 : 0 : break;
748 : : default:
749 : 0 : break;
750 : : }
751 : : }
752 : : // hat sich die shell verabschiedet?
753 [ # # ][ # # ]: 0 : else if ( rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
[ # # ]
754 : 0 : UpdateContent((FmFormShell*)NULL);
755 : :
756 : : // hat sich die Markierung der Controls veraendert ?
757 [ # # ]: 0 : else if (rHint.ISA(FmNavViewMarksChanged))
758 : : {
759 : 0 : FmNavViewMarksChanged* pvmcHint = (FmNavViewMarksChanged*)&rHint;
760 : 0 : BroadcastMarkedObjects( pvmcHint->GetAffectedView()->GetMarkedObjectList() );
761 : : }
762 : 0 : }
763 : :
764 : : //------------------------------------------------------------------------
765 : 0 : void NavigatorTreeModel::InsertSdrObj( const SdrObject* pObj )
766 : : {
767 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertSdrObj" );
768 : 0 : const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
769 [ # # ]: 0 : if ( pFormObject )
770 : : {
771 : : try
772 : : {
773 [ # # ][ # # ]: 0 : Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
774 [ # # ][ # # ]: 0 : Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW );
[ # # ]
775 : :
776 [ # # ]: 0 : sal_Int32 nPos = getElementPos( xContainer, xFormComponent );
777 [ # # ][ # # ]: 0 : InsertFormComponent( xFormComponent, nPos );
778 : : }
779 : 0 : catch( const Exception& )
780 : : {
781 : : DBG_UNHANDLED_EXCEPTION();
782 : : }
783 : : }
784 [ # # ]: 0 : else if ( pObj->IsGroupObject() )
785 : : {
786 [ # # ][ # # ]: 0 : SdrObjListIter aIter( *pObj->GetSubList() );
787 [ # # ]: 0 : while ( aIter.IsMore() )
788 [ # # ][ # # ]: 0 : InsertSdrObj( aIter.Next() );
789 : : }
790 : 0 : }
791 : :
792 : : //------------------------------------------------------------------------
793 : 0 : void NavigatorTreeModel::RemoveSdrObj( const SdrObject* pObj )
794 : : {
795 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveSdrObj" );
796 : 0 : const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
797 [ # # ]: 0 : if ( pFormObject )
798 : : {
799 : : try
800 : : {
801 [ # # ][ # # ]: 0 : Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
802 [ # # ]: 0 : FmEntryData* pEntryData = FindData( xFormComponent, GetRootList(), sal_True );
803 [ # # ]: 0 : if ( pEntryData )
804 [ # # ][ # # ]: 0 : Remove( pEntryData );
805 : : }
806 : 0 : catch( const Exception& )
807 : : {
808 : : DBG_UNHANDLED_EXCEPTION();
809 : : }
810 : : }
811 [ # # ]: 0 : else if ( pObj->IsGroupObject() )
812 : : {
813 [ # # ][ # # ]: 0 : SdrObjListIter aIter( *pObj->GetSubList() );
814 [ # # ]: 0 : while ( aIter.IsMore() )
815 [ # # ][ # # ]: 0 : RemoveSdrObj( aIter.Next() );
816 : : }
817 : 0 : }
818 : :
819 : 0 : sal_Bool NavigatorTreeModel::InsertFormComponent(FmNavRequestSelectHint& rHint, SdrObject* pObject)
820 : : {
821 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertFormComponent" );
822 [ # # ]: 0 : if ( pObject->ISA(SdrObjGroup) )
823 : : { // rekursiv absteigen
824 : 0 : const SdrObjList *pChildren = ((SdrObjGroup*)pObject)->GetSubList();
825 [ # # ]: 0 : for ( sal_uInt16 i=0; i<pChildren->GetObjCount(); ++i )
826 : : {
827 : 0 : SdrObject* pCurrent = pChildren->GetObj(i);
828 [ # # ]: 0 : if (!InsertFormComponent(rHint, pCurrent))
829 : 0 : return sal_False;
830 : : }
831 : : }
832 : : else
833 : : {
834 : 0 : FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
835 [ # # ]: 0 : if ( !pFormObject )
836 : 0 : return sal_False;
837 : :
838 : : try
839 : : {
840 [ # # ][ # # ]: 0 : Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
841 [ # # ]: 0 : FmEntryData* pControlData = FindData( xFormViewControl, GetRootList() );
842 [ # # ]: 0 : if ( !pControlData )
843 : 0 : return sal_False;
844 : :
845 [ # # ]: 0 : rHint.AddItem( pControlData );
846 [ # # ]: 0 : return sal_True;
847 : : }
848 : 0 : catch( const Exception& )
849 : : {
850 : : DBG_UNHANDLED_EXCEPTION();
851 : 0 : return sal_False;
852 : : }
853 : : }
854 : :
855 : 0 : return sal_True;
856 : : }
857 : :
858 : 0 : void NavigatorTreeModel::BroadcastMarkedObjects(const SdrMarkList& mlMarked)
859 : : {
860 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::BroadcastMarkedObjects" );
861 : : // gehen wir durch alle markierten Objekte und suchen wir die raus, mit denen ich was anfangen kann
862 [ # # ]: 0 : FmNavRequestSelectHint rshRequestSelection;
863 : 0 : sal_Bool bIsMixedSelection = sal_False;
864 : :
865 [ # # ][ # # ]: 0 : for (sal_uLong i=0; (i<mlMarked.GetMarkCount()) && !bIsMixedSelection; i++)
[ # # ]
866 : : {
867 [ # # ][ # # ]: 0 : SdrObject* pobjCurrent = mlMarked.GetMark(i)->GetMarkedSdrObj();
868 [ # # ]: 0 : bIsMixedSelection |= !InsertFormComponent(rshRequestSelection, pobjCurrent);
869 : : // bei einem Nicht-Form-Control liefert InsertFormComponent sal_False !
870 : : }
871 : :
872 : 0 : rshRequestSelection.SetMixedSelection(bIsMixedSelection);
873 [ # # ]: 0 : if (bIsMixedSelection)
874 : 0 : rshRequestSelection.ClearItems();
875 : :
876 [ # # ][ # # ]: 0 : Broadcast(rshRequestSelection);
877 : : // eine leere Liste interpretiert der NavigatorTree so, dass er seine Selektion komplett rausnimmt
878 : 0 : }
879 : :
880 : : //------------------------------------------------------------------------
881 : 0 : void NavigatorTreeModel::UpdateContent( const Reference< XNameContainer > & xForms )
882 : : {
883 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::UpdateContent" );
884 : : //////////////////////////////////////////////////////////////////////
885 : : // Model von der Root aufwaerts neu fuellen
886 : 0 : Clear();
887 [ # # ]: 0 : if (xForms.is())
888 : : {
889 [ # # ]: 0 : Reference< XContainer > xFormContainer(xForms, UNO_QUERY);
890 [ # # ]: 0 : if (xFormContainer.is())
891 [ # # ][ # # ]: 0 : xFormContainer->addContainerListener((XContainerListener*)m_pPropChangeList);
[ # # ][ # # ]
892 : :
893 [ # # ]: 0 : FillBranch(NULL);
894 : :
895 : : // jetzt in meinem Tree genau die das in meiner View markierte Control selektieren
896 : : // (bzw alle solchen), falls es eines gibt ...
897 [ # # ]: 0 : if(!m_pFormShell) return; // keine Shell -> wech
898 : :
899 : 0 : FmFormView* pFormView = m_pFormShell->GetFormView();
900 : : DBG_ASSERT(pFormView != NULL, "NavigatorTreeModel::UpdateContent : keine FormView");
901 [ # # ][ # # ]: 0 : BroadcastMarkedObjects(pFormView->GetMarkedObjectList());
902 : : }
903 : : }
904 : :
905 : : //------------------------------------------------------------------------
906 : 0 : void NavigatorTreeModel::UpdateContent( FmFormShell* pShell )
907 : : {
908 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::UpdateContent" );
909 : : //////////////////////////////////////////////////////////////////////
910 : : // Wenn Shell sich nicht veraendert hat, nichts machen
911 [ # # ]: 0 : FmFormPage* pNewPage = pShell ? pShell->GetCurPage() : NULL;
912 [ # # ][ # # ]: 0 : if ((pShell == m_pFormShell) && (m_pFormPage == pNewPage))
913 : 0 : return;
914 : :
915 : : //////////////////////////////////////////////////////////////////////
916 : : // Als Listener abmelden
917 [ # # ]: 0 : if( m_pFormShell )
918 : : {
919 [ # # ]: 0 : if (m_pFormModel)
920 : 0 : EndListening( *m_pFormModel );
921 : 0 : m_pFormModel = NULL;
922 : 0 : EndListening( *m_pFormShell );
923 : 0 : Clear();
924 : : }
925 : :
926 : : //////////////////////////////////////////////////////////////////////
927 : : // Vollupdate
928 : 0 : m_pFormShell = pShell;
929 [ # # ]: 0 : if (m_pFormShell)
930 : : {
931 : 0 : m_pFormPage = pNewPage;
932 : 0 : UpdateContent(m_pFormPage->GetForms());
933 : : } else
934 : 0 : m_pFormPage = NULL;
935 : :
936 : : //////////////////////////////////////////////////////////////////////
937 : : // Als Listener neu anmelden
938 [ # # ]: 0 : if( m_pFormShell )
939 : : {
940 : 0 : StartListening( *m_pFormShell );
941 : 0 : m_pFormModel = m_pFormShell->GetFormModel();
942 [ # # ]: 0 : if( m_pFormModel )
943 : 0 : StartListening( *m_pFormModel );
944 : : }
945 : : }
946 : :
947 : : //------------------------------------------------------------------------
948 : 0 : Reference< XIndexContainer > NavigatorTreeModel::GetFormComponents( FmFormData* pFormData )
949 : : {
950 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::GetFormComponents" );
951 : : //////////////////////////////////////////////////////////////////////
952 : : // Von der Form Components holen
953 [ # # ]: 0 : if (pFormData)
954 : 0 : return Reference< XIndexContainer > (pFormData->GetFormIface(), UNO_QUERY);
955 : :
956 : 0 : return Reference< XIndexContainer > ();
957 : : }
958 : :
959 : : //------------------------------------------------------------------------
960 : 0 : sal_Bool NavigatorTreeModel::Rename( FmEntryData* pEntryData, const ::rtl::OUString& rNewText )
961 : : {
962 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Rename" );
963 : : //////////////////////////////////////////////////////////////////////
964 : : // Wenn Name schon vorhanden, Fehlermeldung
965 : 0 : pEntryData->SetText( rNewText );
966 : :
967 : : //////////////////////////////////////////////////////////////////////
968 : : // PropertySet besorgen
969 : 0 : Reference< XFormComponent > xFormComponent;
970 : :
971 [ # # ][ # # ]: 0 : if( pEntryData->ISA(FmFormData) )
[ # # ]
972 : : {
973 : 0 : FmFormData* pFormData = (FmFormData*)pEntryData;
974 : 0 : Reference< XForm > xForm( pFormData->GetFormIface());
975 [ # # ][ # # ]: 0 : xFormComponent = Reference< XFormComponent > (xForm, UNO_QUERY);
976 : : }
977 : :
978 [ # # ][ # # ]: 0 : if( pEntryData->ISA(FmControlData) )
[ # # ]
979 : : {
980 : 0 : FmControlData* pControlData = (FmControlData*)pEntryData;
981 [ # # ]: 0 : xFormComponent = pControlData->GetFormComponent();
982 : : }
983 : :
984 [ # # ]: 0 : if( !xFormComponent.is() ) return sal_False;
985 [ # # ]: 0 : Reference< XPropertySet > xSet(xFormComponent, UNO_QUERY);
986 [ # # ]: 0 : if( !xSet.is() ) return sal_False;
987 : :
988 : : //////////////////////////////////////////////////////////////////////
989 : : // Namen setzen
990 [ # # ][ # # ]: 0 : xSet->setPropertyValue( FM_PROP_NAME, makeAny(rNewText) );
[ # # ][ # # ]
991 : :
992 : 0 : return sal_True;
993 : : }
994 : :
995 : : //------------------------------------------------------------------
996 : 0 : SdrObject* NavigatorTreeModel::Search(SdrObjListIter& rIter, const Reference< XFormComponent > & xComp)
997 : : {
998 : : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Search" );
999 [ # # ]: 0 : while (rIter.IsMore())
1000 : : {
1001 : 0 : SdrObject* pObj = rIter.Next();
1002 : 0 : FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
1003 [ # # ]: 0 : if ( pFormObject )
1004 : : {
1005 [ # # ][ # # ]: 0 : Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY );
1006 [ # # ][ # # ]: 0 : if ( xFormViewControl == xComp )
1007 [ # # ]: 0 : return pObj;
1008 : : }
1009 [ # # ]: 0 : else if ( pObj->IsGroupObject() )
1010 : : {
1011 [ # # ][ # # ]: 0 : SdrObjListIter aIter( *pObj->GetSubList() );
1012 [ # # ]: 0 : pObj = Search( aIter, xComp );
1013 [ # # ]: 0 : if ( pObj )
1014 [ # # ]: 0 : return pObj;
1015 : : }
1016 : : }
1017 : 0 : return NULL;
1018 : : }
1019 : :
1020 : : //............................................................................
1021 : : } // namespace svxform
1022 : : //............................................................................
1023 : :
1024 : :
1025 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|