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/svditer.hxx>
25 #include <svx/svdogrp.hxx>
31 #include <svx/strings.hrc>
32 #include <fmshimp.hxx>
34 #include <o3tl/safeint.hxx>
35 #include <sfx2/objsh.hxx>
36 #include <tools/diagnose_ex.h>
37 #include <com/sun/star/container/XContainer.hpp>
38 #include <comphelper/types.hxx>
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::lang
;
47 using namespace ::com::sun::star::beans
;
48 using namespace ::com::sun::star::form
;
49 using namespace ::com::sun::star::awt
;
50 using namespace ::com::sun::star::container
;
51 using namespace ::com::sun::star::script
;
52 using namespace ::com::sun::star::sdb
;
54 OFormComponentObserver::OFormComponentObserver(NavigatorTreeModel
* _pModel
)
61 // XPropertyChangeListener
63 void SAL_CALL
OFormComponentObserver::disposing(const EventObject
& Source
)
65 Remove( Source
.Source
);
69 void SAL_CALL
OFormComponentObserver::propertyChange(const PropertyChangeEvent
& evt
)
71 if( !m_pNavModel
) return;
72 if( evt
.PropertyName
!= FM_PROP_NAME
) return;
74 Reference
< XFormComponent
> xFormComponent(evt
.Source
, UNO_QUERY
);
75 Reference
< XForm
> xForm(evt
.Source
, UNO_QUERY
);
77 FmEntryData
* pEntryData( nullptr );
79 pEntryData
= m_pNavModel
->FindData( xForm
, m_pNavModel
->GetRootList() );
80 else if( xFormComponent
.is() )
81 pEntryData
= m_pNavModel
->FindData( xFormComponent
, m_pNavModel
->GetRootList() );
85 OUString aNewName
= ::comphelper::getString(evt
.NewValue
);
86 pEntryData
->SetText( aNewName
);
87 FmNavNameChangedHint
aNameChangedHint( pEntryData
, aNewName
);
88 m_pNavModel
->Broadcast( aNameChangedHint
);
94 void SAL_CALL
OFormComponentObserver::elementInserted(const ContainerEvent
& evt
)
96 if (IsLocked() || !m_pNavModel
)
99 // insert no Undoaction
102 Reference
< XInterface
> xTemp
;
103 evt
.Element
>>= xTemp
;
104 Insert(xTemp
, ::comphelper::getINT32(evt
.Accessor
));
110 void OFormComponentObserver::Insert(const Reference
< XInterface
> & xIface
, sal_Int32 nIndex
)
112 Reference
< XForm
> xForm(xIface
, UNO_QUERY
);
115 m_pNavModel
->InsertForm(xForm
, sal_uInt32(nIndex
));
116 Reference
< XIndexContainer
> xContainer(xForm
, UNO_QUERY
);
117 Reference
< XInterface
> xTemp
;
118 for (sal_Int32 i
= 0; i
< xContainer
->getCount(); i
++)
120 xContainer
->getByIndex(i
) >>= xTemp
;
126 Reference
< XFormComponent
> xFormComp(xIface
, UNO_QUERY
);
128 m_pNavModel
->InsertFormComponent(xFormComp
, sal_uInt32(nIndex
));
133 void SAL_CALL
OFormComponentObserver::elementReplaced(const ContainerEvent
& evt
)
135 if (IsLocked() || !m_pNavModel
)
141 Reference
< XFormComponent
> xReplaced
;
142 evt
.ReplacedElement
>>= xReplaced
;
143 FmEntryData
* pEntryData
= m_pNavModel
->FindData(xReplaced
, m_pNavModel
->GetRootList());
146 if (dynamic_cast<const FmControlData
*>( pEntryData
) != nullptr)
148 Reference
< XFormComponent
> xComp
;
149 evt
.Element
>>= xComp
;
150 DBG_ASSERT(xComp
.is(), "OFormComponentObserver::elementReplaced : invalid argument !");
151 // FmControlData should be coupled with XFormComponent
152 m_pNavModel
->ReplaceFormComponent(xReplaced
, xComp
);
154 else if (dynamic_cast<const FmFormData
*>( pEntryData
) != nullptr)
156 OSL_FAIL("replacing forms not implemented yet !");
164 void OFormComponentObserver::Remove( const css::uno::Reference
< css::uno::XInterface
>& _rxElement
)
166 if (IsLocked() || !m_pNavModel
)
173 FmEntryData
* pEntryData
= m_pNavModel
->FindData( _rxElement
, m_pNavModel
->GetRootList() );
175 m_pNavModel
->Remove(pEntryData
);
181 void SAL_CALL
OFormComponentObserver::elementRemoved(const ContainerEvent
& evt
)
183 Reference
< XInterface
> xElement
;
184 evt
.Element
>>= xElement
;
188 NavigatorTreeModel::NavigatorTreeModel()
189 :m_pFormShell(nullptr)
190 ,m_pFormPage(nullptr)
191 ,m_pFormModel(nullptr)
193 m_pPropChangeList
= new OFormComponentObserver(this);
194 m_pRootList
.reset( new FmEntryDataList() );
197 NavigatorTreeModel::~NavigatorTreeModel()
200 // unregister Listener
203 FmFormModel
* pFormModel
= m_pFormShell
->GetFormModel();
204 if( pFormModel
&& IsListening(*pFormModel
))
205 EndListening( *pFormModel
);
207 if (IsListening(*m_pFormShell
))
208 EndListening(*m_pFormShell
);
213 m_pPropChangeList
->ReleaseModel();
217 void NavigatorTreeModel::SetModified()
219 if( !m_pFormShell
) return;
220 SfxObjectShell
* pObjShell
= m_pFormShell
->GetFormModel()->GetObjectShell();
221 if( !pObjShell
) return;
222 pObjShell
->SetModified();
226 void NavigatorTreeModel::Clear()
228 Reference
< css::form::XForms
> xForms( GetForms());
230 xForms
->removeContainerListener(m_pPropChangeList
);
234 GetRootList()->clear();
238 FmNavClearedHint aClearedHint
;
239 Broadcast( aClearedHint
);
243 Reference
< css::form::XForms
> NavigatorTreeModel::GetForms() const
245 if( !m_pFormShell
|| !m_pFormShell
->GetCurPage())
248 return m_pFormShell
->GetCurPage()->GetForms();
252 void NavigatorTreeModel::Insert(FmEntryData
* pEntry
, sal_uInt32 nRelPos
, bool bAlterModel
)
254 if (IsListening(*m_pFormModel
))
255 EndListening(*m_pFormModel
);
257 m_pPropChangeList
->Lock();
258 FmFormData
* pFolder
= static_cast<FmFormData
*>( pEntry
->GetParent() );
259 Reference
< XChild
> xElement( pEntry
->GetChildIFace() );
263 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
264 aStr
= SvxResId(RID_STR_FORM
);
266 aStr
= SvxResId(RID_STR_CONTROL
);
268 Reference
< XIndexContainer
> xContainer
;
270 xContainer
.set(pFolder
->GetFormIface(), UNO_QUERY
);
272 xContainer
= GetForms();
274 bool bUndo
= m_pFormModel
->IsUndoEnabled();
278 OUString
aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT
));
279 aUndoStr
= aUndoStr
.replaceFirst("#", aStr
);
280 m_pFormModel
->BegUndo(aUndoStr
);
283 if (nRelPos
>= o3tl::make_unsigned(xContainer
->getCount()))
284 nRelPos
= static_cast<sal_uInt32
>(xContainer
->getCount());
287 if ( bUndo
&& m_pPropChangeList
->CanUndo())
289 m_pFormModel
->AddUndo(std::make_unique
<FmUndoContainerAction
>(*m_pFormModel
,
290 FmUndoContainerAction::Inserted
,
296 // Element has to be of the expected type by the container
297 if (xContainer
->getElementType() ==
298 cppu::UnoType
<XForm
>::get())
301 Reference
< XForm
> xElementAsForm(xElement
, UNO_QUERY
);
302 xContainer
->insertByIndex(nRelPos
, makeAny(xElementAsForm
));
304 else if (xContainer
->getElementType() ==
305 cppu::UnoType
<XFormComponent
>::get())
308 Reference
< XFormComponent
> xElementAsComponent(xElement
, UNO_QUERY
);
309 xContainer
->insertByIndex(nRelPos
, makeAny(xElementAsComponent
));
313 OSL_FAIL("NavigatorTreeModel::Insert : the parent container needs an elementtype I don't know !");
317 m_pFormModel
->EndUndo();
320 // register as PropertyChangeListener
321 Reference
< XPropertySet
> xSet(xElement
, UNO_QUERY
);
323 xSet
->addPropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
);
326 // Remove data from model
327 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
329 Reference
< XContainer
> xContainer(xElement
, UNO_QUERY
);
331 xContainer
->addContainerListener(m_pPropChangeList
);
335 pFolder
->GetChildList()->insert( std::unique_ptr
<FmEntryData
>(pEntry
), nRelPos
);
337 GetRootList()->insert( std::unique_ptr
<FmEntryData
>(pEntry
), nRelPos
);
341 FmNavInsertedHint
aInsertedHint( pEntry
, nRelPos
);
342 Broadcast( aInsertedHint
);
344 m_pPropChangeList
->UnLock();
345 if (IsListening(*m_pFormModel
))
346 StartListening(*m_pFormModel
);
350 void NavigatorTreeModel::Remove(FmEntryData
* pEntry
, bool bAlterModel
)
353 // get form and parent
354 if (!pEntry
|| !m_pFormModel
)
357 if (IsListening(*m_pFormModel
))
358 EndListening(*m_pFormModel
);
360 const bool bUndo
= m_pFormModel
->IsUndoEnabled();
362 m_pPropChangeList
->Lock();
363 FmFormData
* pFolder
= static_cast<FmFormData
*>( pEntry
->GetParent() );
364 Reference
< XChild
> xElement ( pEntry
->GetChildIFace() );
368 if (dynamic_cast<const FmFormData
*>( pEntry
) != nullptr)
369 aStr
= SvxResId(RID_STR_FORM
);
371 aStr
= SvxResId(RID_STR_CONTROL
);
375 OUString
aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_REMOVE
));
376 aUndoStr
= aUndoStr
.replaceFirst("#", aStr
);
377 m_pFormModel
->BegUndo(aUndoStr
);
381 // now real deletion of data form model
382 if (auto pFormData
= dynamic_cast<FmFormData
*>( pEntry
))
383 RemoveForm(pFormData
);
385 RemoveFormComponent(static_cast<FmControlData
*>(pEntry
));
390 Reference
< XIndexContainer
> xContainer(xElement
->getParent(), UNO_QUERY
);
391 // remove from Container
392 sal_Int32 nContainerIndex
= getElementPos(xContainer
, xElement
);
394 if (nContainerIndex
>= 0)
396 if ( bUndo
&& m_pPropChangeList
->CanUndo())
398 m_pFormModel
->AddUndo(std::make_unique
<FmUndoContainerAction
>(*m_pFormModel
,
399 FmUndoContainerAction::Removed
,
401 xElement
, nContainerIndex
));
403 else if( !m_pPropChangeList
->CanUndo() )
405 FmUndoContainerAction::DisposeElement( xElement
);
408 xContainer
->removeByIndex(nContainerIndex
);
412 m_pFormModel
->EndUndo();
415 // remove from parent
417 pFolder
->GetChildList()->removeNoDelete( pEntry
);
420 GetRootList()->removeNoDelete( pEntry
);
422 // If root has no more form, reset CurForm at shell
423 if ( !GetRootList()->size() )
424 m_pFormShell
->GetImpl()->forgetCurrentForm_Lock();
429 FmNavRemovedHint
aRemovedHint( pEntry
);
430 Broadcast( aRemovedHint
);
435 m_pPropChangeList
->UnLock();
436 StartListening(*m_pFormModel
);
440 void NavigatorTreeModel::RemoveForm(FmFormData
const * pFormData
)
443 // get form and parent
444 if (!pFormData
|| !m_pFormModel
)
447 FmEntryDataList
* pChildList
= pFormData
->GetChildList();
448 for ( size_t i
= pChildList
->size(); i
> 0; )
450 FmEntryData
* pEntryData
= pChildList
->at( --i
);
453 // Child is form -> recursive call
454 if( auto pChildFormData
= dynamic_cast<FmFormData
*>( pEntryData
) )
455 RemoveForm(pChildFormData
);
456 else if( auto pChildControlData
= dynamic_cast<FmControlData
*>( pEntryData
) )
457 RemoveFormComponent(pChildControlData
);
461 // unregister as PropertyChangeListener
462 Reference
< XPropertySet
> xSet( pFormData
->GetPropertySet() );
464 xSet
->removePropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
);
468 void NavigatorTreeModel::RemoveFormComponent(FmControlData
const * pControlData
)
471 // get control and parent
476 // unregister as PropertyChangeListener
477 Reference
< XPropertySet
> xSet( pControlData
->GetPropertySet() );
479 xSet
->removePropertyChangeListener( FM_PROP_NAME
, m_pPropChangeList
);
483 void NavigatorTreeModel::FillBranch( FmFormData
* pFormData
)
486 // insert forms from root
487 if( pFormData
== nullptr )
489 Reference
< XIndexContainer
> xForms
= GetForms();
493 Reference
< XForm
> xSubForm
;
494 for (sal_Int32 i
=0; i
<xForms
->getCount(); ++i
)
496 DBG_ASSERT( xForms
->getByIndex(i
).getValueType() == cppu::UnoType
<XForm
>::get(),
497 "NavigatorTreeModel::FillBranch : the root container should supply only elements of type XForm");
499 xForms
->getByIndex(i
) >>= xSubForm
;
500 FmFormData
* pSubFormData
= new FmFormData(xSubForm
, pFormData
);
501 Insert( pSubFormData
);
503 // new branch, if SubForm contains Subforms itself
504 FillBranch( pSubFormData
);
512 Reference
< XIndexContainer
> xComponents( GetFormComponents(pFormData
));
513 if( !xComponents
.is() ) return;
515 FmControlData
* pNewControlData
;
516 FmFormData
* pSubFormData
;
518 Reference
< XFormComponent
> xCurrentComponent
;
519 for (sal_Int32 j
=0; j
<xComponents
->getCount(); ++j
)
521 xComponents
->getByIndex(j
) >>= xCurrentComponent
;
522 Reference
< XForm
> xSubForm(xCurrentComponent
, UNO_QUERY
);
525 { // actual component is a form
526 pSubFormData
= new FmFormData(xSubForm
, pFormData
);
527 Insert(pSubFormData
);
530 // new branch, if SubForm contains Subforms itself
531 FillBranch(pSubFormData
);
535 pNewControlData
= new FmControlData(xCurrentComponent
, pFormData
);
536 Insert(pNewControlData
);
543 void NavigatorTreeModel::InsertForm(const Reference
< XForm
> & xForm
, sal_uInt32 nRelPos
)
545 FmFormData
* pFormData
= static_cast<FmFormData
*>(FindData( xForm
, GetRootList() ));
551 Reference
< XInterface
> xIFace( xForm
->getParent());
552 Reference
< XForm
> xParentForm(xIFace
, UNO_QUERY
);
553 FmFormData
* pParentData
= nullptr;
554 if (xParentForm
.is())
555 pParentData
= static_cast<FmFormData
*>(FindData( xParentForm
, GetRootList() ));
557 pFormData
= new FmFormData(xForm
, pParentData
);
558 Insert( pFormData
, nRelPos
);
562 void NavigatorTreeModel::InsertFormComponent(const Reference
< XFormComponent
> & xComp
, sal_uInt32 nRelPos
)
566 Reference
< XInterface
> xIFace( xComp
->getParent());
567 Reference
< XForm
> xForm(xIFace
, UNO_QUERY
);
571 FmFormData
* pParentData
= static_cast<FmFormData
*>(FindData( xForm
, GetRootList() ));
574 pParentData
= new FmFormData(xForm
, nullptr);
575 Insert( pParentData
);
578 if (!FindData(xComp
, pParentData
->GetChildList(),false))
582 FmEntryData
* pNewEntryData
= new FmControlData(xComp
, pParentData
);
585 // insert new EntryData
586 Insert( pNewEntryData
, nRelPos
);
590 void NavigatorTreeModel::ReplaceFormComponent(
591 const Reference
< XFormComponent
> & xOld
,
592 const Reference
< XFormComponent
> & xNew
595 FmEntryData
* pData
= FindData(xOld
, GetRootList());
596 assert(dynamic_cast<const FmControlData
*>( pData
)); //NavigatorTreeModel::ReplaceFormComponent : invalid argument
597 auto pControlData
= dynamic_cast<FmControlData
*>( pData
);
600 pControlData
->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 ( auto pObjGroup
= dynamic_cast<const SdrObjGroup
*>( pObject
) )
742 { // descend recursively
743 const SdrObjList
*pChildren
= pObjGroup
->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
807 xForms
->addContainerListener(m_pPropChangeList
);
811 // select same control in tree as in view
812 // (or all of them), if there is one ...
813 if(!m_pFormShell
) return; // no shell
815 FmFormView
* pFormView
= m_pFormShell
->GetFormView();
816 DBG_ASSERT(pFormView
!= nullptr, "NavigatorTreeModel::UpdateContent : no FormView");
817 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( auto pFormData
= dynamic_cast<FmFormData
*>( pEntryData
))
885 xFormComponent
= pFormData
->GetFormIface();
888 if( auto pControlData
= dynamic_cast<FmControlData
*>( pEntryData
) )
890 xFormComponent
= pControlData
->GetFormComponent();
893 if( !xFormComponent
.is() ) return false;
894 Reference
< XPropertySet
> xSet(xFormComponent
, UNO_QUERY
);
895 if( !xSet
.is() ) return false;
899 xSet
->setPropertyValue( FM_PROP_NAME
, makeAny(rNewText
) );
907 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */