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