LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/form - navigatortree.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 950 0.1 %
Date: 2013-07-09 Functions: 2 57 3.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10