1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/dialmgr.hxx>
21 #include <svx/fmshell.hxx>
22 #include <svx/fmmodel.hxx>
23 #include <svx/fmpage.hxx>
24 #include <svx/fmglob.hxx>
25 #include <svx/svditer.hxx>
26 #include <svx/svdogrp.hxx>
27 #include <svx/svdpagv.hxx>
33 #include <svx/strings.hrc>
34 #include <fmshimp.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <tools/diagnose_ex.h>
38 #include <com/sun/star/container/XContainer.hpp>
39 #include <comphelper/types.hxx>
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::lang
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::com::sun::star::form
;
50 using namespace ::com::sun::star::awt
;
51 using namespace ::com::sun::star::container
;
52 using namespace ::com::sun::star::script
;
53 using namespace ::com::sun::star::sdb
;
55 OFormComponentObserver::OFormComponentObserver(NavigatorTreeModel
* _pModel
)
62 // XPropertyChangeListener
64 void SAL_CALL
OFormComponentObserver::disposing(const EventObject
& Source
)
66 Remove( Source
.Source
);
70 void SAL_CALL
OFormComponentObserver::propertyChange(const PropertyChangeEvent
& evt
)
72 if( !m_pNavModel
) return;
73 if( evt
.PropertyName
!= FM_PROP_NAME
) return;
75 Reference
< XFormComponent
> xFormComponent(evt
.Source
, UNO_QUERY
);
76 Reference
< XForm
> xForm(evt
.Source
, UNO_QUERY
);
78 FmEntryData
* pEntryData( nullptr );
80 pEntryData
= m_pNavModel
->FindData( xForm
, m_pNavModel
->GetRootList() );
81 else if( xFormComponent
.is() )
82 pEntryData
= m_pNavModel
->FindData( xFormComponent
, m_pNavModel
->GetRootList() );
86 OUString aNewName
= ::comphelper::getString(evt
.NewValue
);
87 pEntryData
->SetText( aNewName
);
88 FmNavNameChangedHint
aNameChangedHint( pEntryData
, aNewName
);
89 m_pNavModel
->Broadcast( aNameChangedHint
);
95 void SAL_CALL
OFormComponentObserver::elementInserted(const ContainerEvent
& evt
)
97 if (IsLocked() || !m_pNavModel
)
100 // insert no Undoaction
103 Reference
< XInterface
> xTemp
;
104 evt
.Element
>>= xTemp
;
105 Insert(xTemp
, ::comphelper::getINT32(evt
.Accessor
));
111 void OFormComponentObserver::Insert(const Reference
< XInterface
> & xIface
, sal_Int32 nIndex
)
113 Reference
< XForm
> xForm(xIface
, UNO_QUERY
);
116 m_pNavModel
->InsertForm(xForm
, sal_uInt32(nIndex
));
117 Reference
< XIndexContainer
> xContainer(xForm
, UNO_QUERY
);
118 Reference
< XInterface
> xTemp
;
119 for (sal_Int32 i
= 0; i
< xContainer
->getCount(); i
++)
121 xContainer
->getByIndex(i
) >>= xTemp
;
127 Reference
< XFormComponent
> xFormComp(xIface
, UNO_QUERY
);
129 m_pNavModel
->InsertFormComponent(xFormComp
, sal_uInt32(nIndex
));
134 void SAL_CALL
OFormComponentObserver::elementReplaced(const ContainerEvent
& evt
)
136 if (IsLocked() || !m_pNavModel
)
142 Reference
< XFormComponent
> xReplaced
;
143 evt
.ReplacedElement
>>= xReplaced
;
144 FmEntryData
* pEntryData
= m_pNavModel
->FindData(xReplaced
, m_pNavModel
->GetRootList());
147 if (dynamic_cast<const FmControlData
*>( pEntryData
) != nullptr)
149 Reference
< XFormComponent
> xComp
;
150 evt
.Element
>>= xComp
;
151 DBG_ASSERT(xComp
.is(), "OFormComponentObserver::elementReplaced : invalid argument !");
152 // FmControlData should be coupled with XFormComponent
153 m_pNavModel
->ReplaceFormComponent(xReplaced
, xComp
);
155 else if (dynamic_cast<const FmFormData
*>( pEntryData
) != nullptr)
157 OSL_FAIL("replacing forms not implemented yet !");
165 void OFormComponentObserver::Remove( const css::uno::Reference
< css::uno::XInterface
>& _rxElement
)
167 if (IsLocked() || !m_pNavModel
)
174 FmEntryData
* pEntryData
= m_pNavModel
->FindData( _rxElement
, m_pNavModel
->GetRootList() );
176 m_pNavModel
->Remove(pEntryData
);
182 void SAL_CALL
OFormComponentObserver::elementRemoved(const ContainerEvent
& evt
)
184 Reference
< XInterface
> xElement
;
185 evt
.Element
>>= xElement
;
189 NavigatorTreeModel::NavigatorTreeModel()
190 :m_pFormShell(nullptr)
191 ,m_pFormPage(nullptr)
192 ,m_pFormModel(nullptr)
194 m_pPropChangeList
= new OFormComponentObserver(this);
195 m_pRootList
.reset( new FmEntryDataList() );
198 NavigatorTreeModel::~NavigatorTreeModel()
201 // unregister Listener
204 FmFormModel
* pFormModel
= m_pFormShell
->GetFormModel();
205 if( pFormModel
&& IsListening(*pFormModel
))
206 EndListening( *pFormModel
);
208 if (IsListening(*m_pFormShell
))
209 EndListening(*m_pFormShell
);
214 m_pPropChangeList
->ReleaseModel();
218 void NavigatorTreeModel::SetModified()
220 if( !m_pFormShell
) return;
221 SfxObjectShell
* pObjShell
= m_pFormShell
->GetFormModel()->GetObjectShell();
222 if( !pObjShell
) return;
223 pObjShell
->SetModified();
227 void NavigatorTreeModel::Clear()
229 Reference
< css::form::XForms
> xForms( GetForms());
231 xForms
->removeContainerListener(m_pPropChangeList
.get());
235 GetRootList()->clear();
239 FmNavClearedHint aClearedHint
;
240 Broadcast( aClearedHint
);
244 Reference
< css::form::XForms
> NavigatorTreeModel::GetForms() const
246 if( !m_pFormShell
|| !m_pFormShell
->GetCurPage())
249 return m_pFormShell
->GetCurPage()->GetForms();
253 void NavigatorTreeModel::Insert(FmEntryData
* pEntry
, sal_uInt32 nRelPos
, bool bAlterModel
)
255 if (IsListening(*m_pFormModel
))
256 EndListening(*m_pFormModel
);
258 m_pPropChangeList
->Lock();
259 FmFormData
* pFolder
= static_cast<FmFormData
*>( pEntry
->GetParent() );
260 Reference
< XChild
> xElement( pEntry
->GetChildIFace() );
264 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
265 aStr
= SvxResId(RID_STR_FORM
);
267 aStr
= SvxResId(RID_STR_CONTROL
);
269 Reference
< XIndexContainer
> xContainer
;
271 xContainer
.set(pFolder
->GetFormIface(), UNO_QUERY
);
273 xContainer
= GetForms();
275 bool bUndo
= m_pFormModel
->IsUndoEnabled();
279 OUString
aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT
));
280 aUndoStr
= aUndoStr
.replaceFirst("#", aStr
);
281 m_pFormModel
->BegUndo(aUndoStr
);
284 if (nRelPos
>= static_cast<sal_uInt32
>(xContainer
->getCount()))
285 nRelPos
= static_cast<sal_uInt32
>(xContainer
->getCount());
288 if ( bUndo
&& m_pPropChangeList
->CanUndo())
290 m_pFormModel
->AddUndo(std::make_unique
<FmUndoContainerAction
>(*m_pFormModel
,
291 FmUndoContainerAction::Inserted
,
297 // Element has to be of the expected type by the container
298 if (xContainer
->getElementType() ==
299 cppu::UnoType
<XForm
>::get())
302 Reference
< XForm
> xElementAsForm(xElement
, UNO_QUERY
);
303 xContainer
->insertByIndex(nRelPos
, makeAny(xElementAsForm
));
305 else if (xContainer
->getElementType() ==
306 cppu::UnoType
<XFormComponent
>::get())
309 Reference
< XFormComponent
> xElementAsComponent(xElement
, UNO_QUERY
);
310 xContainer
->insertByIndex(nRelPos
, makeAny(xElementAsComponent
));
314 OSL_FAIL("NavigatorTreeModel::Insert : the parent container needs an elementtype I don't know !");
318 m_pFormModel
->EndUndo();
321 // register as PropertyChangeListener
322 Reference
< XPropertySet
> xSet(xElement
, UNO_QUERY
);
324 xSet
->addPropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
.get() );
327 // Remove data from model
328 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
330 Reference
< XContainer
> xContainer(xElement
, UNO_QUERY
);
332 xContainer
->addContainerListener(m_pPropChangeList
.get());
336 pFolder
->GetChildList()->insert( std::unique_ptr
<FmEntryData
>(pEntry
), nRelPos
);
338 GetRootList()->insert( std::unique_ptr
<FmEntryData
>(pEntry
), nRelPos
);
342 FmNavInsertedHint
aInsertedHint( pEntry
, nRelPos
);
343 Broadcast( aInsertedHint
);
345 m_pPropChangeList
->UnLock();
346 if (IsListening(*m_pFormModel
))
347 StartListening(*m_pFormModel
);
351 void NavigatorTreeModel::Remove(FmEntryData
* pEntry
, bool bAlterModel
)
354 // get form and parent
355 if (!pEntry
|| !m_pFormModel
)
358 if (IsListening(*m_pFormModel
))
359 EndListening(*m_pFormModel
);
361 const bool bUndo
= m_pFormModel
->IsUndoEnabled();
363 m_pPropChangeList
->Lock();
364 FmFormData
* pFolder
= static_cast<FmFormData
*>( pEntry
->GetParent() );
365 Reference
< XChild
> xElement ( pEntry
->GetChildIFace() );
369 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
370 aStr
= SvxResId(RID_STR_FORM
);
372 aStr
= SvxResId(RID_STR_CONTROL
);
376 OUString
aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_REMOVE
));
377 aUndoStr
= aUndoStr
.replaceFirst("#", aStr
);
378 m_pFormModel
->BegUndo(aUndoStr
);
382 // now real deletion of data form model
383 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
384 RemoveForm(static_cast<FmFormData
*>(pEntry
));
386 RemoveFormComponent(static_cast<FmControlData
*>(pEntry
));
391 Reference
< XIndexContainer
> xContainer(xElement
->getParent(), UNO_QUERY
);
392 // remove from Container
393 sal_Int32 nContainerIndex
= getElementPos(xContainer
.get(), xElement
);
395 if (nContainerIndex
>= 0)
397 if ( bUndo
&& m_pPropChangeList
->CanUndo())
399 m_pFormModel
->AddUndo(std::make_unique
<FmUndoContainerAction
>(*m_pFormModel
,
400 FmUndoContainerAction::Removed
,
402 xElement
, nContainerIndex
));
404 else if( !m_pPropChangeList
->CanUndo() )
406 FmUndoContainerAction::DisposeElement( xElement
);
409 xContainer
->removeByIndex(nContainerIndex
);
413 m_pFormModel
->EndUndo();
416 // remove from parent
418 pFolder
->GetChildList()->removeNoDelete( pEntry
);
421 GetRootList()->removeNoDelete( pEntry
);
423 // If root has no more form, reset CurForm at shell
424 if ( !GetRootList()->size() )
425 m_pFormShell
->GetImpl()->forgetCurrentForm_Lock();
430 FmNavRemovedHint
aRemovedHint( pEntry
);
431 Broadcast( aRemovedHint
);
436 m_pPropChangeList
->UnLock();
437 StartListening(*m_pFormModel
);
441 void NavigatorTreeModel::RemoveForm(FmFormData
const * pFormData
)
444 // get form and parent
445 if (!pFormData
|| !m_pFormModel
)
448 FmEntryDataList
* pChildList
= pFormData
->GetChildList();
449 for ( size_t i
= pChildList
->size(); i
> 0; )
451 FmEntryData
* pEntryData
= pChildList
->at( --i
);
454 // Child is form -> recursive call
455 if( dynamic_cast<const FmFormData
*>( pEntryData
) != nullptr )
456 RemoveForm( static_cast<FmFormData
*>(pEntryData
));
457 else if( dynamic_cast<const FmControlData
*>( pEntryData
) != nullptr )
458 RemoveFormComponent(static_cast<FmControlData
*>(pEntryData
));
462 // unregister as PropertyChangeListener
463 Reference
< XPropertySet
> xSet( pFormData
->GetPropertySet() );
465 xSet
->removePropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
.get() );
469 void NavigatorTreeModel::RemoveFormComponent(FmControlData
const * pControlData
)
472 // get control and parent
477 // unregister as PropertyChangeListener
478 Reference
< XPropertySet
> xSet( pControlData
->GetPropertySet() );
480 xSet
->removePropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
.get());
484 void NavigatorTreeModel::FillBranch( FmFormData
* pFormData
)
487 // insert forms from root
488 if( pFormData
== nullptr )
490 Reference
< XIndexContainer
> xForms
= GetForms();
494 Reference
< XForm
> xSubForm
;
495 for (sal_Int32 i
=0; i
<xForms
->getCount(); ++i
)
497 DBG_ASSERT( xForms
->getByIndex(i
).getValueType() == cppu::UnoType
<XForm
>::get(),
498 "NavigatorTreeModel::FillBranch : the root container should supply only elements of type XForm");
500 xForms
->getByIndex(i
) >>= xSubForm
;
501 FmFormData
* pSubFormData
= new FmFormData(xSubForm
, pFormData
);
502 Insert( pSubFormData
);
504 // new branch, if SubForm contains Subforms itself
505 FillBranch( pSubFormData
);
513 Reference
< XIndexContainer
> xComponents( GetFormComponents(pFormData
));
514 if( !xComponents
.is() ) return;
516 FmControlData
* pNewControlData
;
517 FmFormData
* pSubFormData
;
519 Reference
< XFormComponent
> xCurrentComponent
;
520 for (sal_Int32 j
=0; j
<xComponents
->getCount(); ++j
)
522 xComponents
->getByIndex(j
) >>= xCurrentComponent
;
523 Reference
< XForm
> xSubForm(xCurrentComponent
, UNO_QUERY
);
526 { // actual component is a form
527 pSubFormData
= new FmFormData(xSubForm
, pFormData
);
528 Insert(pSubFormData
);
531 // new branch, if SubForm contains Subforms itself
532 FillBranch(pSubFormData
);
536 pNewControlData
= new FmControlData(xCurrentComponent
, pFormData
);
537 Insert(pNewControlData
);
544 void NavigatorTreeModel::InsertForm(const Reference
< XForm
> & xForm
, sal_uInt32 nRelPos
)
546 FmFormData
* pFormData
= static_cast<FmFormData
*>(FindData( xForm
, GetRootList() ));
552 Reference
< XInterface
> xIFace( xForm
->getParent());
553 Reference
< XForm
> xParentForm(xIFace
, UNO_QUERY
);
554 FmFormData
* pParentData
= nullptr;
555 if (xParentForm
.is())
556 pParentData
= static_cast<FmFormData
*>(FindData( xParentForm
, GetRootList() ));
558 pFormData
= new FmFormData(xForm
, pParentData
);
559 Insert( pFormData
, nRelPos
);
563 void NavigatorTreeModel::InsertFormComponent(const Reference
< XFormComponent
> & xComp
, sal_uInt32 nRelPos
)
567 Reference
< XInterface
> xIFace( xComp
->getParent());
568 Reference
< XForm
> xForm(xIFace
, UNO_QUERY
);
572 FmFormData
* pParentData
= static_cast<FmFormData
*>(FindData( xForm
, GetRootList() ));
575 pParentData
= new FmFormData(xForm
, nullptr);
576 Insert( pParentData
);
579 if (!FindData(xComp
, pParentData
->GetChildList(),false))
583 FmEntryData
* pNewEntryData
= new FmControlData(xComp
, pParentData
);
586 // insert new EntryData
587 Insert( pNewEntryData
, nRelPos
);
591 void NavigatorTreeModel::ReplaceFormComponent(
592 const Reference
< XFormComponent
> & xOld
,
593 const Reference
< XFormComponent
> & xNew
596 FmEntryData
* pData
= FindData(xOld
, GetRootList());
597 assert(dynamic_cast<const FmControlData
*>( pData
)); //NavigatorTreeModel::ReplaceFormComponent : invalid argument
598 if (!dynamic_cast<const FmControlData
*>( pData
))
600 static_cast<FmControlData
*>(pData
)->ModelReplaced(xNew
);
602 FmNavModelReplacedHint
aReplacedHint( pData
);
603 Broadcast( aReplacedHint
);
606 FmEntryData
* NavigatorTreeModel::FindData(const Reference
< XInterface
> & xElement
, FmEntryDataList
* pDataList
, bool bRecurs
)
609 Reference
< XInterface
> xIFace( xElement
, UNO_QUERY
);
611 for ( size_t i
= 0; i
< pDataList
->size(); i
++ )
613 FmEntryData
* pEntryData
= pDataList
->at( i
);
614 if ( pEntryData
->GetElement().get() == xIFace
.get() )
618 pEntryData
= FindData( xElement
, pEntryData
->GetChildList() );
627 FmEntryData
* NavigatorTreeModel::FindData( const OUString
& rText
, FmFormData
const * pParentData
, bool bRecurs
)
629 FmEntryDataList
* pDataList
;
631 pDataList
= GetRootList();
633 pDataList
= pParentData
->GetChildList();
636 FmEntryData
* pEntryData
;
637 FmEntryData
* pChildData
;
639 for( size_t i
= 0; i
< pDataList
->size(); i
++ )
641 pEntryData
= pDataList
->at( i
);
642 aEntryText
= pEntryData
->GetText();
644 if (rText
== aEntryText
)
647 if (FmFormData
* pFormData
= bRecurs
? dynamic_cast<FmFormData
*>(pEntryData
) : nullptr)
649 pChildData
= FindData(rText
, pFormData
, true);
658 void NavigatorTreeModel::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
660 if (rHint
.GetId() == SfxHintId::ThisIsAnSdrHint
)
662 const SdrHint
* pSdrHint
= static_cast<const SdrHint
*>(&rHint
);
663 switch( pSdrHint
->GetKind() )
665 case SdrHintKind::ObjectInserted
:
666 InsertSdrObj(pSdrHint
->GetObject());
668 case SdrHintKind::ObjectRemoved
:
669 RemoveSdrObj(pSdrHint
->GetObject());
676 else if (rHint
.GetId() == SfxHintId::Dying
)
678 UpdateContent(nullptr);
680 // changed mark of controls?
681 else if (const FmNavViewMarksChanged
* pvmcHint
= dynamic_cast<const FmNavViewMarksChanged
*>(&rHint
))
683 BroadcastMarkedObjects(pvmcHint
->GetAffectedView()->GetMarkedObjectList());
687 void NavigatorTreeModel::InsertSdrObj( const SdrObject
* pObj
)
689 const FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pObj
);
694 Reference
< XFormComponent
> xFormComponent( pFormObject
->GetUnoControlModel(), UNO_QUERY_THROW
);
695 Reference
< XIndexAccess
> xContainer( xFormComponent
->getParent(), UNO_QUERY_THROW
);
697 sal_Int32 nPos
= getElementPos( xContainer
, xFormComponent
);
698 InsertFormComponent( xFormComponent
, nPos
);
700 catch( const Exception
& )
702 DBG_UNHANDLED_EXCEPTION("svx");
705 else if ( pObj
->IsGroupObject() )
707 SdrObjListIter
aIter( pObj
->GetSubList() );
708 while ( aIter
.IsMore() )
709 InsertSdrObj( aIter
.Next() );
714 void NavigatorTreeModel::RemoveSdrObj( const SdrObject
* pObj
)
716 const FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pObj
);
721 Reference
< XFormComponent
> xFormComponent( pFormObject
->GetUnoControlModel(), UNO_QUERY_THROW
);
722 FmEntryData
* pEntryData
= FindData( xFormComponent
, GetRootList() );
724 Remove( pEntryData
);
726 catch( const Exception
& )
728 DBG_UNHANDLED_EXCEPTION("svx");
731 else if ( pObj
->IsGroupObject() )
733 SdrObjListIter
aIter( pObj
->GetSubList() );
734 while ( aIter
.IsMore() )
735 RemoveSdrObj( aIter
.Next() );
739 bool NavigatorTreeModel::InsertFormComponent(FmNavRequestSelectHint
& rHint
, SdrObject
* pObject
)
741 if ( dynamic_cast<const SdrObjGroup
*>( pObject
) != nullptr )
742 { // descend recursively
743 const SdrObjList
*pChildren
= static_cast<SdrObjGroup
*>(pObject
)->GetSubList();
744 for ( size_t i
=0; i
<pChildren
->GetObjCount(); ++i
)
746 SdrObject
* pCurrent
= pChildren
->GetObj(i
);
747 if (!InsertFormComponent(rHint
, pCurrent
))
753 FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pObject
);
759 Reference
< XFormComponent
> xFormViewControl( pFormObject
->GetUnoControlModel(), UNO_QUERY_THROW
);
760 FmEntryData
* pControlData
= FindData( xFormViewControl
, GetRootList() );
764 rHint
.AddItem( pControlData
);
767 catch( const Exception
& )
769 DBG_UNHANDLED_EXCEPTION("svx");
777 void NavigatorTreeModel::BroadcastMarkedObjects(const SdrMarkList
& mlMarked
)
779 // search all objects, which can be handled, out of marked objects
780 FmNavRequestSelectHint rshRequestSelection
;
781 bool bIsMixedSelection
= false;
783 for (size_t i
=0; (i
<mlMarked
.GetMarkCount()) && !bIsMixedSelection
; ++i
)
785 SdrObject
* pobjCurrent
= mlMarked
.GetMark(i
)->GetMarkedSdrObj();
786 bIsMixedSelection
|= !InsertFormComponent(rshRequestSelection
, pobjCurrent
);
787 // if Not-Form-Control, InsertFormComponent returns sal_False !
790 rshRequestSelection
.SetMixedSelection(bIsMixedSelection
);
791 if (bIsMixedSelection
)
792 rshRequestSelection
.ClearItems();
794 Broadcast(rshRequestSelection
);
795 // an empty list causes NavigatorTree to remove his selection
799 void NavigatorTreeModel::UpdateContent( const Reference
< css::form::XForms
> & xForms
)
802 // refill model form root upward
806 xForms
->addContainerListener(m_pPropChangeList
.get());
810 // select same control in tree as in view
811 // (or all of them), if there is one ...
812 if(!m_pFormShell
) return; // no shell
814 FmFormView
* pFormView
= m_pFormShell
->GetFormView();
815 DBG_ASSERT(pFormView
!= nullptr, "NavigatorTreeModel::UpdateContent : no FormView");
816 BroadcastMarkedObjects(pFormView
->GetMarkedObjectList());
821 void NavigatorTreeModel::UpdateContent( FmFormShell
* pShell
)
824 // If shell is unchanged, do nothing
825 FmFormPage
* pNewPage
= pShell
? pShell
->GetCurPage() : nullptr;
826 if ((pShell
== m_pFormShell
) && (m_pFormPage
== pNewPage
))
830 // unregister as Listener
834 EndListening( *m_pFormModel
);
835 m_pFormModel
= nullptr;
836 EndListening( *m_pFormShell
);
842 m_pFormShell
= pShell
;
845 m_pFormPage
= pNewPage
;
846 UpdateContent(m_pFormPage
->GetForms());
848 m_pFormPage
= nullptr;
851 // register as Listener again
854 StartListening( *m_pFormShell
);
855 m_pFormModel
= m_pFormShell
->GetFormModel();
857 StartListening( *m_pFormModel
);
862 Reference
< XIndexContainer
> NavigatorTreeModel::GetFormComponents( FmFormData
const * pFormData
)
865 // get components from form
867 return Reference
< XIndexContainer
> (pFormData
->GetFormIface(), UNO_QUERY
);
869 return Reference
< XIndexContainer
> ();
873 bool NavigatorTreeModel::Rename( FmEntryData
* pEntryData
, const OUString
& rNewText
)
876 // If name already exist, error message
877 pEntryData
->SetText( rNewText
);
881 Reference
< XFormComponent
> xFormComponent
;
883 if( dynamic_cast<const FmFormData
*>( pEntryData
) != nullptr )
885 FmFormData
* pFormData
= static_cast<FmFormData
*>(pEntryData
);
886 xFormComponent
= pFormData
->GetFormIface();
889 if( dynamic_cast<const FmControlData
*>( pEntryData
) != nullptr )
891 FmControlData
* pControlData
= static_cast<FmControlData
*>(pEntryData
);
892 xFormComponent
= pControlData
->GetFormComponent();
895 if( !xFormComponent
.is() ) return false;
896 Reference
< XPropertySet
> xSet(xFormComponent
, UNO_QUERY
);
897 if( !xSet
.is() ) return false;
901 xSet
->setPropertyValue( FM_PROP_NAME
, makeAny(rNewText
) );
909 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */