1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: navigatortree.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/dialmgr.hxx>
34 #include <svx/fmshell.hxx>
35 #include <svx/fmmodel.hxx>
36 #include <svx/fmpage.hxx>
37 #include <svx/svdpagv.hxx>
38 #include "svditer.hxx"
43 #include "fmresids.hrc"
44 #include "fmshimp.hxx"
45 #include "fmservs.hxx"
47 #include "fmpgeimp.hxx"
48 #include "fmitems.hxx"
50 #include <vcl/wrkwin.hxx>
51 #include <sfx2/viewsh.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <comphelper/processfactory.hxx>
55 #include <comphelper/property.hxx>
56 #include <com/sun/star/form/FormComponentType.hpp>
57 #include <com/sun/star/sdb/CommandType.hpp>
58 #include <com/sun/star/beans/PropertyAttribute.hpp>
59 #include <com/sun/star/script/XEventAttacherManager.hpp>
60 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
61 #include <com/sun/star/datatransfer/XTransferable.hpp>
62 #include <sdrpaintwindow.hxx>
64 #include <svx/svxdlg.hxx> //CHINA001
65 #include <svx/dialogs.hrc> //CHINA001
66 #include <rtl/logfile.hxx>
67 //............................................................................
70 //............................................................................
72 #define DROP_ACTION_TIMER_INITIAL_TICKS 10
73 // solange dauert es, bis das Scrollen anspringt
74 #define DROP_ACTION_TIMER_SCROLL_TICKS 3
75 // in diesen Intervallen wird jeweils eine Zeile gescrollt
76 #define DROP_ACTION_TIMER_TICK_BASE 10
77 // das ist die Basis, mit der beide Angaben multipliziert werden (in ms)
79 #define EXPLORER_SYNC_DELAY 200
80 // dieser Betrag an Millisekunden wird gewartet, ehe der Explorer nach einem Select oder Deselect die ::com::sun::star::sdbcx::View synchronisiert
82 using namespace ::com::sun::star::uno
;
83 using namespace ::com::sun::star::lang
;
84 using namespace ::com::sun::star::beans
;
85 using namespace ::com::sun::star::form
;
86 using namespace ::com::sun::star::awt
;
87 using namespace ::com::sun::star::container
;
88 using namespace ::com::sun::star::script
;
89 using namespace ::com::sun::star::datatransfer
;
90 using namespace ::com::sun::star::datatransfer::clipboard
;
91 using namespace ::com::sun::star::sdb
;
93 //========================================================================
95 //========================================================================
97 typedef ::std::map
< Reference
< XInterface
>, SdrObject
*, ::comphelper::OInterfaceCompare
< XInterface
> >
99 typedef MapModelToShape::value_type ModelShapePair
;
101 //------------------------------------------------------------------------
102 void collectShapeModelMapping( SdrPage
* _pPage
, MapModelToShape
& _rMapping
)
104 OSL_ENSURE( _pPage
, "collectShapeModelMapping: invalid arg!" );
108 SdrObjListIter
aIter( *_pPage
);
109 while ( aIter
.IsMore() )
111 SdrObject
* pSdrObject
= aIter
.Next();
112 FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pSdrObject
);
116 Reference
< XInterface
> xNormalizedModel( pFormObject
->GetUnoControlModel(), UNO_QUERY
);
117 // note that this is normalized (i.e. queried for XInterface explicitly)
120 ::std::pair
< MapModelToShape::iterator
, bool > aPos
=
122 _rMapping
.insert( ModelShapePair( xNormalizedModel
, pSdrObject
) );
123 DBG_ASSERT( aPos
.second
, "collectShapeModelMapping: model was already existent!" );
124 // if this asserts, this would mean we have 2 shapes pointing to the same model
128 //------------------------------------------------------------------------
129 sal_Bool
isModelShapeMarked( FmEntryData
* _pEntry
, const MapModelToShape
& _rModelMap
, SdrMarkView
* _pView
)
131 DBG_ASSERT( _pEntry
&& _pView
, "isModelShapeMarked: invalid arguments!" );
132 if ( !_pEntry
|| !_pView
)
135 DBG_ASSERT( _pEntry
->GetElement().get() == Reference
< XInterface
>( _pEntry
->GetElement(), UNO_QUERY
).get(),
136 "isModelShapeMarked: element of the FmEntryData is not normalized!" );
137 // normalization of the XInterface is a prerequisite for properly finding it in the map
139 sal_Bool bIsMarked
= sal_False
;
141 MapModelToShape::const_iterator aPos
= _rModelMap
.find( _pEntry
->GetElement() );
142 if ( _rModelMap
.end() != aPos
)
143 { // there is a shape for this model ....
144 bIsMarked
= _pView
->IsObjMarked( aPos
->second
);
147 // IsObjMarked does not step down grouped objects, so the sal_False we
148 // have is not really reliable (while a sal_True would have been)
149 // Okay, travel the mark list, and see if there is a group marked, and our shape
150 // is a part of this group
151 sal_uInt32 nMarked
= _pView
->GetMarkedObjectList().GetMarkCount();
152 for ( sal_uInt32 i
= 0; (i
<nMarked
) && !bIsMarked
; ++i
)
154 SdrMark
* pMark
= _pView
->GetMarkedObjectList().GetMark( i
);
155 SdrObject
* pObj
= pMark
? pMark
->GetMarkedSdrObj() : NULL
;
156 if ( pObj
&& pObj
->IsGroupObject() )
157 { // the i-th marked shape is a group shape
158 SdrObjListIter
aIter( *pObj
);
159 while ( aIter
.IsMore() )
161 if ( aIter
.Next() == aPos
->second
)
163 bIsMarked
= sal_True
;
175 //========================================================================
176 // class NavigatorTree
177 //========================================================================
179 //------------------------------------------------------------------------
180 NavigatorTree::NavigatorTree( const Reference
< XMultiServiceFactory
>& _xORB
,
182 :SvTreeListBox( pParent
, WB_HASBUTTONS
|WB_HASLINES
|WB_BORDER
|WB_HSCROLL
) // #100258# OJ WB_HSCROLL added
183 ,m_aControlExchange(this)
189 ,m_sdiState(SDI_DIRTY
)
190 ,m_aTimerTriggered(-1,-1)
191 ,m_aDropActionType( DA_SCROLLUP
)
194 ,m_nControlsSelected(0)
195 ,m_nHiddenControls(0)
196 ,m_aTimerCounter( DROP_ACTION_TIMER_INITIAL_TICKS
)
197 ,m_bDragDataDirty(sal_False
)
198 ,m_bPrevSelectionMixed(sal_False
)
199 ,m_bMarkingObjects(sal_False
)
200 ,m_bRootSelected(sal_False
)
201 ,m_bInitialUpdate(sal_True
)
202 ,m_bKeyboardCut( sal_False
)
204 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NavigatorTree" );
205 SetHelpId( HID_FORM_NAVIGATOR
);
207 m_aNavigatorImages
= ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL
) );
208 m_aNavigatorImagesHC
= ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC
) );
211 m_aNavigatorImages
.GetImage( RID_SVXIMG_COLLAPSEDNODE
),
212 m_aNavigatorImages
.GetImage( RID_SVXIMG_EXPANDEDNODE
),
216 m_aNavigatorImagesHC
.GetImage( RID_SVXIMG_COLLAPSEDNODE
),
217 m_aNavigatorImagesHC
.GetImage( RID_SVXIMG_EXPANDEDNODE
),
218 BMP_COLOR_HIGHCONTRAST
221 SetDragDropMode(0xFFFF);
222 EnableInplaceEditing( sal_True
);
223 SetSelectionMode(MULTIPLE_SELECTION
);
225 m_pNavModel
= new NavigatorTreeModel( m_aNavigatorImages
, m_aNavigatorImagesHC
);
228 StartListening( *m_pNavModel
);
230 m_aDropActionTimer
.SetTimeoutHdl(LINK(this, NavigatorTree
, OnDropActionTimer
));
232 m_aSynchronizeTimer
.SetTimeoutHdl(LINK(this, NavigatorTree
, OnSynchronizeTimer
));
233 SetSelectHdl(LINK(this, NavigatorTree
, OnEntrySelDesel
));
234 SetDeselectHdl(LINK(this, NavigatorTree
, OnEntrySelDesel
));
237 //------------------------------------------------------------------------
238 NavigatorTree::~NavigatorTree()
241 Application::RemoveUserEvent( nEditEvent
);
243 if (m_aSynchronizeTimer
.IsActive())
244 m_aSynchronizeTimer
.Stop();
246 DBG_ASSERT(GetNavModel() != NULL
, "NavigatorTree::~NavigatorTree : unerwartet : kein ExplorerModel");
247 EndListening( *m_pNavModel
);
252 //------------------------------------------------------------------------
253 void NavigatorTree::Clear()
255 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Clear" );
256 m_pNavModel
->Clear();
259 //------------------------------------------------------------------------
260 void NavigatorTree::UpdateContent( FmFormShell
* pFormShell
)
262 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UpdateContent" );
263 if (m_bInitialUpdate
)
266 m_bInitialUpdate
= sal_False
;
269 FmFormShell
* pOldShell
= GetNavModel()->GetFormShell();
270 FmFormPage
* pOldPage
= GetNavModel()->GetFormPage();
271 FmFormPage
* pNewPage
= pFormShell
? pFormShell
->GetCurPage() : NULL
;
273 if ((pOldShell
!= pFormShell
) || (pOldPage
!= pNewPage
))
275 // neue Shell, waehrend ich gerade editiere ?
276 if (IsEditingActive())
279 m_bDragDataDirty
= sal_True
; // sicherheitshalber, auch wenn ich gar nicht dragge
281 GetNavModel()->UpdateContent( pFormShell
);
283 // wenn es eine Form gibt, die Root expandieren
284 if (m_pRootEntry
&& !IsExpanded(m_pRootEntry
))
285 Expand(m_pRootEntry
);
286 // wenn es GENAU eine Form gibt, auch diese expandieren
289 SvLBoxEntry
* pFirst
= FirstChild(m_pRootEntry
);
290 if (pFirst
&& !NextSibling(pFirst
))
295 //------------------------------------------------------------------------------
296 sal_Bool
NavigatorTree::implAllowExchange( sal_Int8 _nAction
, sal_Bool
* _pHasNonHidden
)
298 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAllowExchange" );
299 SvLBoxEntry
* pCurEntry
= GetCurEntry();
303 // die Informationen fuer das AcceptDrop und ExecuteDrop
304 CollectSelectionData(SDI_ALL
);
305 if (!m_arrCurrentSelection
.Count())
309 // testen, ob es sich vielleicht ausschliesslich um hidden controls handelt (dann koennte ich pCtrlExch noch ein
310 // zusaetzliches Format geben)
311 sal_Bool bHasNonHidden
= sal_False
;
312 for (sal_Int32 i
=0; i
<m_arrCurrentSelection
.Count(); i
++)
314 FmEntryData
* pCurrent
= static_cast< FmEntryData
* >( m_arrCurrentSelection
[(sal_uInt16
)i
]->GetUserData() );
315 if ( IsHiddenControl( pCurrent
) )
317 bHasNonHidden
= sal_True
;
321 if ( bHasNonHidden
&& ( 0 == ( _nAction
& DND_ACTION_MOVE
) ) )
322 // non-hidden controls need to be moved
325 if ( _pHasNonHidden
)
326 *_pHasNonHidden
= bHasNonHidden
;
331 //------------------------------------------------------------------------------
332 sal_Bool
NavigatorTree::implPrepareExchange( sal_Int8 _nAction
)
334 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implPrepareExchange" );
339 sal_Bool bHasNonHidden
= sal_False
;
340 if ( !implAllowExchange( _nAction
, &bHasNonHidden
) )
343 m_aControlExchange
.prepareDrag();
344 m_aControlExchange
->setFocusEntry( GetCurEntry() );
346 for ( i
= 0; i
< m_arrCurrentSelection
.Count(); ++i
)
347 m_aControlExchange
->addSelectedEntry(m_arrCurrentSelection
[(sal_uInt16
)i
]);
349 m_aControlExchange
->setFormsRoot( GetNavModel()->GetFormPage()->GetForms() );
350 m_aControlExchange
->buildPathFormat( this, m_pRootEntry
);
354 // eine entsprechende Sequenz aufbauen
355 Sequence
< Reference
< XInterface
> > seqIFaces(m_arrCurrentSelection
.Count());
356 Reference
< XInterface
>* pArray
= seqIFaces
.getArray();
357 for (i
=0; i
<m_arrCurrentSelection
.Count(); ++i
, ++pArray
)
358 *pArray
= static_cast< FmEntryData
* >( m_arrCurrentSelection
[(sal_uInt16
)i
]->GetUserData() )->GetElement();
360 // und das neue Format
361 m_aControlExchange
->addHiddenControlsFormat(seqIFaces
);
364 m_bDragDataDirty
= sal_False
;
368 //------------------------------------------------------------------------------
369 void NavigatorTree::StartDrag( sal_Int8
/*nAction*/, const ::Point
& /*rPosPixel*/ )
371 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::StartDrag" );
374 if ( !implPrepareExchange( DND_ACTION_COPYMOVE
) )
375 // nothing to do or something went wrong
378 // jetzt haben wir alle in der aktuelle Situation moeglichen Formate eingesammelt, es kann also losgehen ...
379 m_aControlExchange
.startDrag( DND_ACTION_COPYMOVE
);
382 //------------------------------------------------------------------------------
383 void NavigatorTree::Command( const CommandEvent
& rEvt
)
385 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Command" );
386 sal_Bool bHandled
= sal_False
;
387 switch( rEvt
.GetCommand() )
389 case COMMAND_CONTEXTMENU
:
391 // die Stelle, an der geklickt wurde
393 if (rEvt
.IsMouseEvent())
395 ptWhere
= rEvt
.GetMousePosPixel();
396 SvLBoxEntry
* ptClickedOn
= GetEntry(ptWhere
);
397 if (ptClickedOn
== NULL
)
399 if ( !IsSelected(ptClickedOn
) )
401 SelectAll(sal_False
);
402 Select(ptClickedOn
, sal_True
);
403 SetCurEntry(ptClickedOn
);
408 if (m_arrCurrentSelection
.Count() == 0) // kann nur bei Kontextmenue ueber Tastatur passieren
411 SvLBoxEntry
* pCurrent
= GetCurEntry();
414 ptWhere
= GetEntryPosition(pCurrent
);
417 // meine Selektionsdaten auf den aktuellen Stand
418 CollectSelectionData(SDI_ALL
);
420 // wenn mindestens ein Nicht-Root-Eintrag selektiert ist und die Root auch, dann nehme ich letztere aus der Selektion
422 if ( (m_arrCurrentSelection
.Count() > 1) && m_bRootSelected
)
424 Select( m_pRootEntry
, sal_False
);
425 SetCursor( m_arrCurrentSelection
.GetObject(0), sal_True
);
427 sal_Bool bSingleSelection
= (m_arrCurrentSelection
.Count() == 1);
430 DBG_ASSERT( (m_arrCurrentSelection
.Count() > 0) || m_bRootSelected
, "keine Eintraege selektiert" );
431 // solte nicht passieren, da ich oben bei der IsSelected-Abfrage auf jeden Fall einen selektiert haette,
432 // wenn das vorher nicht der Fall gewesen waere
435 // das Menue zusammenbasteln
436 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
437 FmFormModel
* pFormModel
= pFormShell
? pFormShell
->GetFormModel() : NULL
;
438 if( pFormShell
&& pFormModel
)
440 PopupMenu
aContextMenu(SVX_RES(RID_FMEXPLORER_POPUPMENU
));
441 PopupMenu
* pSubMenuNew
= aContextMenu
.GetPopupMenu( SID_FM_NEW
);
443 // das 'Neu'-Untermenue gibt es nur, wenn genau die Root oder genau ein Formular selektiert sind
444 aContextMenu
.EnableItem( SID_FM_NEW
, bSingleSelection
&& (m_nFormsSelected
|| m_bRootSelected
) );
446 // 'Neu'\'Formular' unter genau den selben Bedingungen
447 pSubMenuNew
->EnableItem( SID_FM_NEW_FORM
, bSingleSelection
&& (m_nFormsSelected
|| m_bRootSelected
) );
448 pSubMenuNew
->SetItemImage(SID_FM_NEW_FORM
, m_aNavigatorImages
.GetImage(RID_SVXIMG_FORM
));
449 pSubMenuNew
->SetItemImage(SID_FM_NEW_HIDDEN
, m_aNavigatorImages
.GetImage(RID_SVXIMG_HIDDEN
));
451 // 'Neu'\'verstecktes...', wenn genau ein Formular selektiert ist
452 pSubMenuNew
->EnableItem( SID_FM_NEW_HIDDEN
, bSingleSelection
&& m_nFormsSelected
);
454 // 'Delete': everything which is not root can be removed
455 aContextMenu
.EnableItem( SID_FM_DELETE
, !m_bRootSelected
);
457 // 'Cut', 'Copy' and 'Paste'
458 aContextMenu
.EnableItem( SID_CUT
, !m_bRootSelected
&& implAllowExchange( DND_ACTION_MOVE
) );
459 aContextMenu
.EnableItem( SID_COPY
, !m_bRootSelected
&& implAllowExchange( DND_ACTION_COPY
) );
460 aContextMenu
.EnableItem( SID_PASTE
, implAcceptPaste( ) );
462 // der TabDialog, wenn es genau ein Formular ist ...
463 aContextMenu
.EnableItem( SID_FM_TAB_DIALOG
, bSingleSelection
&& m_nFormsSelected
);
465 // in XML forms, we don't allow for the properties of a form
466 // #i36484# / 2004-11-04 /- fs@openoffice.org
467 if ( pFormShell
->GetImpl()->isEnhancedForm() && !m_nControlsSelected
)
468 aContextMenu
.RemoveItem( aContextMenu
.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER
) );
470 // if the property browser is already open, we don't allow for the properties, too
471 if( pFormShell
->GetImpl()->IsPropBrwOpen() )
472 aContextMenu
.RemoveItem( aContextMenu
.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER
) );
473 // and finally, if there's a mixed selection of forms and controls, disable the entry, too
475 aContextMenu
.EnableItem( SID_FM_SHOW_PROPERTY_BROWSER
,
476 (m_nControlsSelected
&& !m_nFormsSelected
) || (!m_nControlsSelected
&& m_nFormsSelected
) );
478 // Umbenennen gdw wenn ein Element und nicht die Root
479 aContextMenu
.EnableItem( SID_FM_RENAME_OBJECT
, bSingleSelection
&& !m_bRootSelected
);
481 // der Reandonly-Eintrag ist nur auf der Root erlaubt
482 aContextMenu
.EnableItem( SID_FM_OPEN_READONLY
, m_bRootSelected
);
483 // the same for automatic control focus
484 aContextMenu
.EnableItem( SID_FM_AUTOCONTROLFOCUS
, m_bRootSelected
);
486 // die ConvertTo-Slots sind enabled, wenn genau ein Control selektiert ist, der
487 // dem Control entsprechende Slot ist disabled
488 if (!m_bRootSelected
&& !m_nFormsSelected
&& (m_nControlsSelected
== 1))
490 aContextMenu
.SetPopupMenu( SID_FM_CHANGECONTROLTYPE
, FmXFormShell::GetConversionMenu() );
491 #if OSL_DEBUG_LEVEL > 0
492 FmControlData
* pCurrent
= (FmControlData
*)(m_arrCurrentSelection
[0]->GetUserData());
493 OSL_ENSURE( pFormShell
->GetImpl()->isSolelySelected( pCurrent
->GetFormComponent() ),
494 "NavigatorTree::Command: inconsistency between the navigator selection, and the selection as the shell knows it!" );
497 pFormShell
->GetImpl()->checkControlConversionSlotsForCurrentSelection( *aContextMenu
.GetPopupMenu( SID_FM_CHANGECONTROLTYPE
) );
500 aContextMenu
.EnableItem( SID_FM_CHANGECONTROLTYPE
, sal_False
);
502 // jetzt alles, was disabled wurde, wech
503 aContextMenu
.RemoveDisabledEntries(sal_True
, sal_True
);
504 //////////////////////////////////////////////////////////
505 // OpenReadOnly setzen
507 aContextMenu
.CheckItem( SID_FM_OPEN_READONLY
, pFormModel
->GetOpenInDesignMode() );
508 aContextMenu
.CheckItem( SID_FM_AUTOCONTROLFOCUS
, pFormModel
->GetAutoControlFocus() );
510 sal_uInt16 nSlotId
= aContextMenu
.Execute( this, ptWhere
);
513 case SID_FM_NEW_FORM
:
515 XubString
aStr(SVX_RES(RID_STR_FORM
));
516 XubString
aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT
));
517 aUndoStr
.SearchAndReplace('#', aStr
);
519 pFormModel
->BegUndo(aUndoStr
);
520 // der Slot war nur verfuegbar, wenn es genau einen selektierten Eintrag gibt und dieser die Root
521 // oder ein Formular ist
522 NewForm( m_arrCurrentSelection
.GetObject(0) );
523 pFormModel
->EndUndo();
526 case SID_FM_NEW_HIDDEN
:
528 XubString
aStr(SVX_RES(RID_STR_CONTROL
));
529 XubString
aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT
));
530 aUndoStr
.SearchAndReplace('#', aStr
);
532 pFormModel
->BegUndo(aUndoStr
);
533 // dieser Slot war guletig bei (genau) einem selektierten Formular
534 rtl::OUString fControlName
= FM_COMPONENT_HIDDEN
;
535 NewControl( fControlName
, m_arrCurrentSelection
.GetObject(0) );
536 pFormModel
->EndUndo();
557 case SID_FM_TAB_DIALOG
:
559 // dieser Slot galt bei genau einem selektierten Formular
560 SvLBoxEntry
* pSelectedForm
= m_arrCurrentSelection
.GetObject(0);
561 DBG_ASSERT( IsFormEntry(pSelectedForm
), "NavigatorTree::Command: Dieser Eintrag muss ein FormEntry sein." );
563 FmFormData
* pFormData
= (FmFormData
*)pSelectedForm
->GetUserData();
564 Reference
< XForm
> xForm( pFormData
->GetFormIface());
566 Reference
< XTabControllerModel
> xTabController(xForm
, UNO_QUERY
);
567 if( !xTabController
.is() )
569 GetNavModel()->GetFormShell()->GetImpl()->ExecuteTabOrderDialog( xTabController
);
573 case SID_FM_SHOW_PROPERTY_BROWSER
:
575 ShowSelectionProperties(sal_True
);
578 case SID_FM_RENAME_OBJECT
:
580 // das war bei genau einem Nicht-Root-Eintrag erlaubt
581 EditEntry( m_arrCurrentSelection
.GetObject(0) );
584 case SID_FM_OPEN_READONLY
:
586 pFormModel
->SetOpenInDesignMode( !pFormModel
->GetOpenInDesignMode() );
587 pFormShell
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY
);
590 case SID_FM_AUTOCONTROLFOCUS
:
592 pFormModel
->SetAutoControlFocus( !pFormModel
->GetAutoControlFocus() );
593 pFormShell
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS
);
597 if (pFormShell
->GetImpl()->isControlConversionSlot(nSlotId
))
599 FmControlData
* pCurrent
= (FmControlData
*)(m_arrCurrentSelection
[0]->GetUserData());
600 if ( pFormShell
->GetImpl()->executeControlConversionSlot( pCurrent
->GetFormComponent(), nSlotId
) )
601 ShowSelectionProperties();
610 SvTreeListBox::Command( rEvt
);
613 //------------------------------------------------------------------------
614 sal_Bool
NavigatorTree::IsDeleteAllowed()
616 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsDeleteAllowed" );
617 //////////////////////////////////////////////////////////////////////
618 // Haben wir eine Form...
619 SvLBoxEntry
* pCurEntry
= GetCurEntry();
620 sal_uInt32 nCurEntryPos
= GetModel()->GetAbsPos( pCurEntry
);
622 if( nCurEntryPos
==0 ) // Root kann nicht geloescht werden
625 return IsFormEntry(pCurEntry
) || IsFormComponentEntry(pCurEntry
);
628 //------------------------------------------------------------------------
629 SvLBoxEntry
* NavigatorTree::FindEntry( FmEntryData
* pEntryData
)
631 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::FindEntry" );
632 if( !pEntryData
) return NULL
;
633 SvLBoxEntry
* pCurEntry
= First();
634 FmEntryData
* pCurEntryData
;
637 pCurEntryData
= (FmEntryData
*)pCurEntry
->GetUserData();
638 if( pCurEntryData
&& pCurEntryData
->IsEqualWithoutChilds(pEntryData
) )
641 pCurEntry
= Next( pCurEntry
);
647 //------------------------------------------------------------------------
648 void NavigatorTree::Notify( SfxBroadcaster
& /*rBC*/, const SfxHint
& rHint
)
650 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Notify" );
651 if( rHint
.ISA(FmNavRemovedHint
) )
653 FmNavRemovedHint
* pRemovedHint
= (FmNavRemovedHint
*)&rHint
;
654 FmEntryData
* pEntryData
= pRemovedHint
->GetEntryData();
655 Remove( pEntryData
);
658 else if( rHint
.ISA(FmNavInsertedHint
) )
660 FmNavInsertedHint
* pInsertedHint
= (FmNavInsertedHint
*)&rHint
;
661 FmEntryData
* pEntryData
= pInsertedHint
->GetEntryData();
662 sal_uInt32 nRelPos
= pInsertedHint
->GetRelPos();
663 Insert( pEntryData
, nRelPos
);
666 else if( rHint
.ISA(FmNavModelReplacedHint
) )
668 FmEntryData
* pData
= ((FmNavModelReplacedHint
*)&rHint
)->GetEntryData();
669 SvLBoxEntry
* pEntry
= FindEntry( pData
);
671 { // das Image neu setzen
672 SetCollapsedEntryBmp( pEntry
, pData
->GetNormalImage(), BMP_COLOR_NORMAL
);
673 SetExpandedEntryBmp( pEntry
, pData
->GetNormalImage(), BMP_COLOR_NORMAL
);
675 SetCollapsedEntryBmp( pEntry
, pData
->GetHCImage(), BMP_COLOR_HIGHCONTRAST
);
676 SetExpandedEntryBmp( pEntry
, pData
->GetHCImage(), BMP_COLOR_HIGHCONTRAST
);
680 else if( rHint
.ISA(FmNavNameChangedHint
) )
682 FmNavNameChangedHint
* pNameChangedHint
= (FmNavNameChangedHint
*)&rHint
;
683 SvLBoxEntry
* pEntry
= FindEntry( pNameChangedHint
->GetEntryData() );
684 SetEntryText( pEntry
, pNameChangedHint
->GetNewName() );
687 else if( rHint
.ISA(FmNavClearedHint
) )
689 SvTreeListBox::Clear();
691 //////////////////////////////////////////////////////////////////////
692 // Default-Eintrag "Formulare"
693 Image
aRootImage( m_aNavigatorImages
.GetImage( RID_SVXIMG_FORMS
) );
694 m_pRootEntry
= InsertEntry( SVX_RES(RID_STR_FORMS
), aRootImage
, aRootImage
,
695 NULL
, sal_False
, 0, NULL
);
699 Image
aHCRootImage( m_aNavigatorImagesHC
.GetImage( RID_SVXIMG_FORMS
) );
700 SetExpandedEntryBmp( m_pRootEntry
, aHCRootImage
, BMP_COLOR_HIGHCONTRAST
);
701 SetCollapsedEntryBmp( m_pRootEntry
, aHCRootImage
, BMP_COLOR_HIGHCONTRAST
);
704 else if (!m_bMarkingObjects
&& rHint
.ISA(FmNavRequestSelectHint
))
705 { // wenn m_bMarkingObjects sal_True ist, markiere ich gerade selber Objekte, und da der ganze Mechanismus dahinter synchron ist,
706 // ist das genau der Hint, der durch mein Markieren ausgeloest wird, also kann ich ihn ignorieren
707 FmNavRequestSelectHint
* pershHint
= (FmNavRequestSelectHint
*)&rHint
;
708 FmEntryDataArray
& arredToSelect
= pershHint
->GetItems();
709 SynchronizeSelection(arredToSelect
);
711 if (pershHint
->IsMixedSelection())
712 // in diesem Fall habe ich alles deselektiert, obwohl die View u.U. eine gemischte Markierung hatte
713 // ich muss also im naechsten Select den Navigator an die View anpassen
714 m_bPrevSelectionMixed
= sal_True
;
718 //------------------------------------------------------------------------
719 SvLBoxEntry
* NavigatorTree::Insert( FmEntryData
* pEntryData
, ULONG nRelPos
)
721 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Insert" );
722 //////////////////////////////////////////////////////////////////////
723 // Aktuellen Eintrag einfuegen
724 SvLBoxEntry
* pParentEntry
= FindEntry( pEntryData
->GetParent() );
725 SvLBoxEntry
* pNewEntry
;
728 pNewEntry
= InsertEntry( pEntryData
->GetText(),
729 pEntryData
->GetNormalImage(), pEntryData
->GetNormalImage(),
730 m_pRootEntry
, sal_False
, nRelPos
, pEntryData
);
733 pNewEntry
= InsertEntry( pEntryData
->GetText(),
734 pEntryData
->GetNormalImage(), pEntryData
->GetNormalImage(),
735 pParentEntry
, sal_False
, nRelPos
, pEntryData
);
739 SetExpandedEntryBmp( pNewEntry
, pEntryData
->GetHCImage(), BMP_COLOR_HIGHCONTRAST
);
740 SetCollapsedEntryBmp( pNewEntry
, pEntryData
->GetHCImage(), BMP_COLOR_HIGHCONTRAST
);
743 //////////////////////////////////////////////////////////////////////
744 // Wenn Root-Eintrag Root expandieren
746 Expand( m_pRootEntry
);
748 //////////////////////////////////////////////////////////////////////
750 FmEntryDataList
* pChildList
= pEntryData
->GetChildList();
751 sal_uInt32 nChildCount
= pChildList
->Count();
752 FmEntryData
* pChildData
;
753 for( sal_uInt32 i
=0; i
<nChildCount
; i
++ )
755 pChildData
= pChildList
->GetObject(i
);
756 Insert( pChildData
, LIST_APPEND
);
762 //------------------------------------------------------------------------
763 void NavigatorTree::Remove( FmEntryData
* pEntryData
)
765 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Remove" );
769 // der Entry zu den Daten
770 SvLBoxEntry
* pEntry
= FindEntry( pEntryData
);
774 // Eintrag aus TreeListBox entfernen
775 // ich darf das Select, das ich ausloese, nicht behandeln :
776 // Select aendert die MarkList der View, wenn das gerade auch jemand anders macht und dabei ein Remove
777 // triggert, haben wir mit ziemlicher Sicherheit ein Problem - Paradebeispiel war das Gruppieren von Controls mit
778 // offenem Navigator ...)
779 LockSelectionHandling();
781 // ein kleines Problem : ich merke mir meine selektierten Daten, wenn mir jetzt jemand einen selektierten Eintrag
782 // unter dem Hintern wegschiesst, werde ich inkonsistent ... was schlecht waere
783 Select(pEntry
, sal_False
);
785 // beim eigentlichen Entfernen kann die Selection geaendert werden, da ich aber das SelectionHandling abgeschaltet
786 // habe, muss ich mich hinterher darum kuemmern
787 ULONG nExpectedSelectionCount
= GetSelectionCount();
790 GetModel()->Remove( pEntry
);
792 if (nExpectedSelectionCount
!= GetSelectionCount())
793 SynchronizeSelection();
795 // und standardmaessig behandle ich das Select natuerlich
796 UnlockSelectionHandling();
799 //------------------------------------------------------------------------
800 sal_Bool
NavigatorTree::IsFormEntry( SvLBoxEntry
* pEntry
)
802 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormEntry" );
803 FmEntryData
* pEntryData
= (FmEntryData
*)pEntry
->GetUserData();
804 return !pEntryData
|| pEntryData
->ISA(FmFormData
);
807 //------------------------------------------------------------------------
808 sal_Bool
NavigatorTree::IsFormComponentEntry( SvLBoxEntry
* pEntry
)
810 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormComponentEntry" );
811 FmEntryData
* pEntryData
= (FmEntryData
*)pEntry
->GetUserData();
812 return pEntryData
&& pEntryData
->ISA(FmControlData
);
815 //------------------------------------------------------------------------
816 sal_Bool
NavigatorTree::implAcceptPaste( )
818 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptPaste" );
819 SvLBoxEntry
* pFirstSelected
= FirstSelected();
820 if ( !pFirstSelected
|| NextSelected( pFirstSelected
) )
821 // no selected entry, or at least two selected entries
825 TransferableDataHelper
aClipboardContent( TransferableDataHelper::CreateFromSystemClipboard( this ) );
827 sal_Int8 nAction
= m_aControlExchange
.isClipboardOwner() && doingKeyboardCut( ) ? DND_ACTION_MOVE
: DND_ACTION_COPY
;
828 return ( nAction
== implAcceptDataTransfer( aClipboardContent
.GetDataFlavorExVector(), nAction
, pFirstSelected
, sal_False
) );
831 //------------------------------------------------------------------------
832 sal_Int8
NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector
& _rFlavors
, sal_Int8 _nAction
, const ::Point
& _rDropPos
, sal_Bool _bDnD
)
834 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
835 return implAcceptDataTransfer( _rFlavors
, _nAction
, GetEntry( _rDropPos
), _bDnD
);
838 //------------------------------------------------------------------------
839 sal_Int8
NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector
& _rFlavors
, sal_Int8 _nAction
, SvLBoxEntry
* _pTargetEntry
, sal_Bool _bDnD
)
841 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
842 // no target -> no drop
844 return DND_ACTION_NONE
;
847 sal_Bool bHasDefControlFormat
= OControlExchange::hasFieldExchangeFormat( _rFlavors
);
848 sal_Bool bHasControlPathFormat
= OControlExchange::hasControlPathFormat( _rFlavors
);
849 sal_Bool bHasHiddenControlsFormat
= OControlExchange::hasHiddenControlModelsFormat( _rFlavors
);
850 if (!bHasDefControlFormat
&& !bHasControlPathFormat
&& !bHasHiddenControlsFormat
)
851 return DND_ACTION_NONE
;
853 sal_Bool bSelfSource
= _bDnD
? m_aControlExchange
.isDragSource() : m_aControlExchange
.isClipboardOwner();
855 if ( bHasHiddenControlsFormat
)
856 { // bHasHiddenControlsFormat means that only hidden controls are part of the data
858 // hidden controls can be copied to a form only
859 if ( !_pTargetEntry
|| ( _pTargetEntry
== m_pRootEntry
) || !IsFormEntry( _pTargetEntry
) )
860 return DND_ACTION_NONE
;
862 return bSelfSource
? ( DND_ACTION_COPYMOVE
& _nAction
) : DND_ACTION_COPY
;
867 // DnD or CnP crossing navigator boundaries
868 // The main problem here is that the current API does not allow us to sneak into the content which
869 // is to be inserted. So we have to allow it for the moment, but maybe reject later on (in the real drop).
871 // TODO: this smart behaviour later on ... at the moment, we disallow data transfer crossing navigator
874 return DND_ACTION_NONE
;
877 DBG_ASSERT( _bDnD
? m_aControlExchange
.isDragSource() : m_aControlExchange
.isClipboardOwner(),
878 "NavigatorTree::implAcceptDataTransfer: here only with source=dest!" );
879 // somebody changed the logic of this method ...
881 // from here on, I can work with m_aControlExchange instead of _rData!
883 sal_Bool bForeignCollection
= m_aControlExchange
->getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
884 if ( bForeignCollection
)
886 // crossing shell/page boundaries, we can exchange hidden controls only
887 // But if we survived the checks above, we do not have hidden controls.
888 // -> no data transfer
889 DBG_ASSERT( !bHasHiddenControlsFormat
, "NavigatorTree::implAcceptDataTransfer: still hidden controls format!" );
890 // somebody changed the logic of this method ...
892 return DND_ACTION_COPY
;
895 if (DND_ACTION_MOVE
!= _nAction
) // 'normal' controls within a shell are moved only (never copied)
896 return DND_ACTION_NONE
;
898 if ( m_bDragDataDirty
|| !bHasDefControlFormat
)
900 if (!bHasControlPathFormat
)
901 // ich befinde mich zwar in der Shell/Page, aus der die Controls stammen, habe aber kein Format, das den stattgefundenen
902 // Shell-Wechsel ueberlebt hat (SVX_FM_CONTROLS_AS_PATH)
903 return DND_ACTION_NONE
;
905 // da die Shell waehrend des Draggens umgeschaltet wude, muss ich die Liste des ExchangeObjektes wieder neu aufbauen
906 // (dort stehen SvLBoxEntries drin, und die sind bei der Umschaltung floeten gegangen)
907 m_aControlExchange
->buildListFromPath(this, m_pRootEntry
);
908 m_bDragDataDirty
= sal_False
;
911 // die Liste der gedroppten Eintraege aus dem DragServer
912 const ListBoxEntrySet
& aDropped
= m_aControlExchange
->selected();
913 DBG_ASSERT(aDropped
.size() >= 1, "NavigatorTree::implAcceptDataTransfer: keine Eintraege !");
915 sal_Bool bDropTargetIsComponent
= IsFormComponentEntry( _pTargetEntry
);
916 //SvLBoxEntry* pDropTargetParent = GetParent( _pTargetEntry );
918 // conditions to disallow the drop
919 // 0) the root entry is part of the list (can't DnD the root!)
920 // 1) one of the draged entries is to be dropped onto it's own parent
921 // 2) - " - is to be dropped onto itself
922 // 3) - " - is a Form and to be dropped onto one of it's descendants
923 // 4) one of the entries is a control and to be dropped onto the root
924 // 5) a control or form will be dropped onto a control which is _not_ a sibling (dropping onto a sibling
925 // means moving the control)
927 // collect the ancestors of the drop targte (speeds up 3)
928 SvLBoxEntrySortedArray arrDropAnchestors
;
929 SvLBoxEntry
* pLoop
= _pTargetEntry
;
932 arrDropAnchestors
.Insert(pLoop
);
933 pLoop
= GetParent(pLoop
);
936 for ( ListBoxEntrySet::const_iterator dropped
= aDropped
.begin();
937 dropped
!= aDropped
.end();
941 SvLBoxEntry
* pCurrent
= *dropped
;
942 SvLBoxEntry
* pCurrentParent
= GetParent(pCurrent
);
945 if (pCurrent
== m_pRootEntry
)
946 return DND_ACTION_NONE
;
949 if ( _pTargetEntry
== pCurrentParent
)
950 return DND_ACTION_NONE
;
953 if (pCurrent
== _pTargetEntry
)
954 return DND_ACTION_NONE
;
957 // if ( bDropTargetIsComponent && (pDropTargetParent != pCurrentParent) )
958 if ( bDropTargetIsComponent
) // TODO : die obige Zeile wieder rein, dann muss aber ExecuteDrop das Vertauschen auch beherrschen
959 return DND_ACTION_NONE
;
962 if ( IsFormEntry(pCurrent
) )
964 sal_uInt16 nPosition
;
965 if ( arrDropAnchestors
.Seek_Entry(pCurrent
, &nPosition
) )
966 return DND_ACTION_NONE
;
967 } else if ( IsFormComponentEntry(pCurrent
) )
970 if (_pTargetEntry
== m_pRootEntry
)
971 return DND_ACTION_NONE
;
975 return DND_ACTION_MOVE
;
978 //------------------------------------------------------------------------
979 sal_Int8
NavigatorTree::AcceptDrop( const AcceptDropEvent
& rEvt
)
981 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::AcceptDrop" );
982 ::Point aDropPos
= rEvt
.maPosPixel
;
984 // kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
987 if (m_aDropActionTimer
.IsActive())
988 m_aDropActionTimer
.Stop();
991 sal_Bool bNeedTrigger
= sal_False
;
992 // auf dem ersten Eintrag ?
993 if ((aDropPos
.Y() >= 0) && (aDropPos
.Y() < GetEntryHeight()))
995 m_aDropActionType
= DA_SCROLLUP
;
996 bNeedTrigger
= sal_True
;
998 // auf dem letzten (bzw. in dem Bereich, den ein Eintrag einnehmen wuerde, wenn er unten genau buendig
999 // abschliessen wuerde) ?
1000 if ((aDropPos
.Y() < GetSizePixel().Height()) && (aDropPos
.Y() >= GetSizePixel().Height() - GetEntryHeight()))
1002 m_aDropActionType
= DA_SCROLLDOWN
;
1003 bNeedTrigger
= sal_True
;
1005 { // auf einem Entry mit Childs, der nicht aufgeklappt ist ?
1006 SvLBoxEntry
* pDropppedOn
= GetEntry(aDropPos
);
1007 if (pDropppedOn
&& (GetChildCount(pDropppedOn
) > 0) && !IsExpanded(pDropppedOn
))
1010 m_aDropActionType
= DA_EXPANDNODE
;
1011 bNeedTrigger
= sal_True
;
1015 if (bNeedTrigger
&& (m_aTimerTriggered
!= aDropPos
))
1017 // neu anfangen zu zaehlen
1018 m_aTimerCounter
= DROP_ACTION_TIMER_INITIAL_TICKS
;
1019 // die Pos merken, da ich auch AcceptDrops bekomme, wenn sich die Maus gar nicht bewegt hat
1020 m_aTimerTriggered
= aDropPos
;
1021 // und den Timer los
1022 if (!m_aDropActionTimer
.IsActive()) // gibt es den Timer schon ?
1024 m_aDropActionTimer
.SetTimeout(DROP_ACTION_TIMER_TICK_BASE
);
1025 m_aDropActionTimer
.Start();
1027 } else if (!bNeedTrigger
)
1028 m_aDropActionTimer
.Stop();
1031 return implAcceptDataTransfer( GetDataFlavorExVector(), rEvt
.mnAction
, aDropPos
, sal_True
);
1034 //------------------------------------------------------------------------
1035 sal_Int8
NavigatorTree::implExecuteDataTransfer( const OControlTransferData
& _rData
, sal_Int8 _nAction
, const ::Point
& _rDropPos
, sal_Bool _bDnD
)
1037 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
1038 return implExecuteDataTransfer( _rData
, _nAction
, GetEntry( _rDropPos
), _bDnD
);
1041 //------------------------------------------------------------------------
1042 sal_Int8
NavigatorTree::implExecuteDataTransfer( const OControlTransferData
& _rData
, sal_Int8 _nAction
, SvLBoxEntry
* _pTargetEntry
, sal_Bool _bDnD
)
1044 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
1045 const DataFlavorExVector
& rDataFlavors
= _rData
.GetDataFlavorExVector();
1047 if ( DND_ACTION_NONE
== implAcceptDataTransfer( rDataFlavors
, _nAction
, _pTargetEntry
, _bDnD
) )
1048 // under some platforms, it may happen that ExecuteDrop is called though AcceptDrop returned DND_ACTION_NONE
1049 return DND_ACTION_NONE
;
1051 // ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
1052 if (m_aDropActionTimer
.IsActive())
1053 m_aDropActionTimer
.Stop();
1056 // no target -> no drop
1057 return DND_ACTION_NONE
;
1061 sal_Bool bHasHiddenControlsFormat
= OControlExchange::hasHiddenControlModelsFormat( rDataFlavors
);
1062 sal_Bool bForeignCollection
= _rData
.getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
1063 DBG_ASSERT(!bForeignCollection
|| bHasHiddenControlsFormat
, "NavigatorTree::implExecuteDataTransfer: invalid format (AcceptDrop shouldn't have let this pass) !");
1064 DBG_ASSERT(bForeignCollection
|| !m_bDragDataDirty
, "NavigatorTree::implExecuteDataTransfer: invalid state (shell changed since last exchange resync) !");
1065 // das sollte in AcceptDrop erledigt worden sein : dort wird in _rData die Liste der Controls aufgebaut und m_bDragDataDirty
1069 if ( DND_ACTION_COPY
== _nAction
)
1070 { // bHasHiddenControlsFormat means that only hidden controls are part of the data
1071 DBG_ASSERT( bHasHiddenControlsFormat
, "NavigatorTree::implExecuteDataTransfer: copy allowed for hidden controls only!" );
1072 DBG_ASSERT( _pTargetEntry
&& ( _pTargetEntry
!= m_pRootEntry
) && IsFormEntry( _pTargetEntry
),
1073 "NavigatorTree::implExecuteDataTransfer: should not be here!" );
1074 // implAcceptDataTransfer should have caught both cases
1076 DBG_ASSERT(bHasHiddenControlsFormat
, "NavigatorTree::implExecuteDataTransfer: only copying of hidden controls is supported !");
1077 // das sollte das AcceptDrop abgefangen haben
1079 // da ich gleich die Zielobjekte alle selektieren will (und nur die)
1080 SelectAll(sal_False
);
1082 Sequence
< Reference
< XInterface
> > aControls
= _rData
.hiddenControls();
1083 sal_Int32 nCount
= aControls
.getLength();
1084 const Reference
< XInterface
>* pControls
= aControls
.getConstArray();
1086 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
1087 FmFormModel
* pFormModel
= pFormShell
? pFormShell
->GetFormModel() : NULL
;
1089 // innerhalb eines Undo ...
1092 XubString
aStr(SVX_RES(RID_STR_CONTROL
));
1093 XubString
aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT
));
1094 aUndoStr
.SearchAndReplace('#', aStr
);
1095 pFormModel
->BegUndo(aUndoStr
);
1098 // die Conrtols kopieren
1099 for (sal_Int32 i
=0; i
<nCount
; ++i
)
1101 // neues Control anlegen
1102 rtl::OUString fControlName
= FM_COMPONENT_HIDDEN
;
1103 FmControlData
* pNewControlData
= NewControl( fControlName
, _pTargetEntry
, sal_False
);
1104 Reference
< XPropertySet
> xNewPropSet( pNewControlData
->GetPropertySet() );
1106 // und die Properties des alten in das neue kopieren
1107 Reference
< XPropertySet
> xCurrent(pControls
[i
], UNO_QUERY
);
1108 #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
1109 // nur mal eben sehen, ob das Ding tatsaechlich ein hidden control ist
1110 sal_Int16 nClassId
= ::comphelper::getINT16(xCurrent
->getPropertyValue(FM_PROP_CLASSID
));
1111 OSL_ENSURE(nClassId
== FormComponentType::HIDDENCONTROL
, "NavigatorTree::implExecuteDataTransfer: invalid control in drop list !");
1112 // wenn das SVX_FM_HIDDEN_CONTROLS-Format vorhanden ist, dann sollten wirklich nur hidden controls in der Sequenz
1114 #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
1115 Reference
< XPropertySetInfo
> xPropInfo( xCurrent
->getPropertySetInfo());
1116 Sequence
< Property
> seqAllCurrentProps
= xPropInfo
->getProperties();
1117 Property
* pAllCurrentProps
= seqAllCurrentProps
.getArray();
1118 for (sal_Int32 j
=0; j
<seqAllCurrentProps
.getLength(); ++j
)
1120 ::rtl::OUString sCurrentProp
= pAllCurrentProps
[j
].Name
;
1121 if (((pAllCurrentProps
[j
].Attributes
& PropertyAttribute::READONLY
) == 0) && (sCurrentProp
!= FM_PROP_NAME
))
1122 { // (read-only attribs werden natuerlich nicht gesetzt, dito der Name, den hat das NewControl schon eindeutig
1124 xNewPropSet
->setPropertyValue(sCurrentProp
, xCurrent
->getPropertyValue(sCurrentProp
));
1128 SvLBoxEntry
* pToSelect
= FindEntry(pNewControlData
);
1129 Select(pToSelect
, sal_True
);
1131 SetCurEntry(pToSelect
);
1135 pFormModel
->EndUndo();
1140 if ( !OControlExchange::hasFieldExchangeFormat( _rData
.GetDataFlavorExVector() ) )
1142 // can't do anything without the internal format here ... usually happens when doing DnD or CnP
1143 // over navigator boundaries
1144 return DND_ACTION_NONE
;
1147 // some data for the target
1148 sal_Bool bDropTargetIsForm
= IsFormEntry(_pTargetEntry
);
1149 FmFormData
* pTargetData
= bDropTargetIsForm
? (FmFormData
*)_pTargetEntry
->GetUserData() : NULL
;
1151 DBG_ASSERT( DND_ACTION_COPY
!= _nAction
, "NavigatorTree::implExecuteDataTransfer: somebody changed the logics!" );
1153 // die Liste der gedraggten Eintraege
1154 ListBoxEntrySet aDropped
= _rData
.selected();
1155 DBG_ASSERT(aDropped
.size() >= 1, "NavigatorTree::implExecuteDataTransfer: no entries!");
1157 // die Shell und das Model
1158 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
1159 FmFormModel
* pFormModel
= pFormShell
? pFormShell
->GetFormModel() : NULL
;
1161 return DND_ACTION_NONE
;
1164 const bool bUndo
= pFormModel
->IsUndoEnabled();
1168 XubString
strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE
));
1169 pFormModel
->BegUndo(strUndoDescription
);
1172 // ich nehme vor dem Einfuegen eines Eintrages seine Selection raus, damit die Markierung dabei nicht flackert
1173 // -> das Handeln des Select locken
1174 LockSelectionHandling();
1176 // jetzt durch alle gedroppten Eintraege ...
1177 for ( ListBoxEntrySet::const_iterator dropped
= aDropped
.begin();
1178 dropped
!= aDropped
.end();
1182 // ein paar Daten zum aktuellen Element
1183 SvLBoxEntry
* pCurrent
= *dropped
;
1184 DBG_ASSERT(pCurrent
!= NULL
, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
1185 DBG_ASSERT(GetParent(pCurrent
) != NULL
, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
1186 // die Root darf nicht gedraggt werden
1188 FmEntryData
* pCurrentUserData
= (FmEntryData
*)pCurrent
->GetUserData();
1190 Reference
< XChild
> xCurrentChild(pCurrentUserData
->GetChildIFace(), UNO_QUERY
);
1191 Reference
< XIndexContainer
> xContainer(xCurrentChild
->getParent(), UNO_QUERY
);
1193 FmFormData
* pCurrentParentUserData
= (FmFormData
*)pCurrentUserData
->GetParent();
1194 DBG_ASSERT(pCurrentParentUserData
== NULL
|| pCurrentParentUserData
->ISA(FmFormData
), "NavigatorTree::implExecuteDataTransfer: ungueltiges Parent");
1196 // beim Vater austragen
1197 if (pCurrentParentUserData
)
1198 pCurrentParentUserData
->GetChildList()->Remove(pCurrentUserData
);
1200 GetNavModel()->GetRootList()->Remove(pCurrentUserData
);
1202 // aus dem Container entfernen
1203 sal_Int32 nIndex
= getElementPos(Reference
< XIndexAccess
> (xContainer
, UNO_QUERY
), xCurrentChild
);
1204 GetNavModel()->m_pPropChangeList
->Lock();
1205 // die Undo-Action fuer das Rausnehmen
1206 if ( bUndo
&& GetNavModel()->m_pPropChangeList
->CanUndo())
1208 pFormModel
->AddUndo(new FmUndoContainerAction(*pFormModel
, FmUndoContainerAction::Removed
,
1209 xContainer
, xCurrentChild
, nIndex
));
1211 else if( !GetNavModel()->m_pPropChangeList
->CanUndo() )
1213 FmUndoContainerAction::DisposeElement( xCurrentChild
);
1216 // Events mitkopieren
1217 Reference
< XEventAttacherManager
> xManager(xContainer
, UNO_QUERY
);
1218 Sequence
< ScriptEventDescriptor
> aEvts
;
1220 if (xManager
.is() && nIndex
>= 0)
1221 aEvts
= xManager
->getScriptEvents(nIndex
);
1222 xContainer
->removeByIndex(nIndex
);
1224 // die Selection raus
1225 Select(pCurrent
, sal_False
);
1227 Remove(pCurrentUserData
);
1229 // die Stelle innerhalb des DropParents, an der ich die gedroppten Eintraege einfuegen muss
1231 xContainer
= Reference
< XIndexContainer
> (pTargetData
->GetElement(), UNO_QUERY
);
1233 xContainer
= Reference
< XIndexContainer
> (GetNavModel()->GetForms(), UNO_QUERY
);
1235 // immer ganz hinten einfuegen
1236 nIndex
= xContainer
->getCount();
1238 // UndoAction fuer das Einfuegen
1239 if ( bUndo
&& GetNavModel()->m_pPropChangeList
->CanUndo())
1240 pFormModel
->AddUndo(new FmUndoContainerAction(*pFormModel
, FmUndoContainerAction::Inserted
,
1241 xContainer
, xCurrentChild
, nIndex
));
1243 // einfuegen im neuen Container
1246 // es wird in eine Form eingefuegt, dann brauche ich eine FormComponent
1247 xContainer
->insertByIndex( nIndex
,
1248 makeAny( Reference
< XFormComponent
>( xCurrentChild
, UNO_QUERY
) ) );
1252 xContainer
->insertByIndex( nIndex
,
1253 makeAny( Reference
< XForm
>( xCurrentChild
, UNO_QUERY
) ) );
1256 if (aEvts
.getLength())
1258 xManager
= Reference
< XEventAttacherManager
> (xContainer
, UNO_QUERY
);
1260 xManager
->registerScriptEvents(nIndex
, aEvts
);
1263 GetNavModel()->m_pPropChangeList
->UnLock();
1265 // zuerst dem Eintrag das neue Parent
1266 pCurrentUserData
->SetParent(pTargetData
);
1268 // dann dem Parent das neue Child
1270 pTargetData
->GetChildList()->Insert(pCurrentUserData
, nIndex
);
1272 GetNavModel()->GetRootList()->Insert(pCurrentUserData
, nIndex
);
1274 // dann bei mir selber bekanntgeben und neu selektieren
1275 SvLBoxEntry
* pNew
= Insert( pCurrentUserData
, nIndex
);
1276 if ( ( aDropped
.begin() == dropped
) && pNew
)
1278 SvLBoxEntry
* pParent
= GetParent( pNew
);
1284 UnlockSelectionHandling();
1287 pFormModel
->EndUndo();
1289 // During the move, the markings of the underlying view did not change (because the view is not affected by the logical
1290 // hierarchy of the form/control models. But my selection changed - which means I have to adjust it according to the
1291 // view marks, again.
1292 SynchronizeSelection();
1294 // in addition, with the move of controls such things as "the current form" may have changed - force the shell
1295 // to update itself accordingly
1296 if( pFormShell
&& pFormShell
->GetImpl() && pFormShell
->GetFormView() )
1297 pFormShell
->GetImpl()->DetermineSelection( pFormShell
->GetFormView()->GetMarkedObjectList() );
1299 if ( m_aControlExchange
.isClipboardOwner() && ( DND_ACTION_MOVE
== _nAction
) )
1300 m_aControlExchange
->clear();
1305 //------------------------------------------------------------------------
1306 sal_Int8
NavigatorTree::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
1308 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ExecuteDrop" );
1309 sal_Int8
nResult( DND_ACTION_NONE
);
1311 if ( m_aControlExchange
.isDragSource() )
1312 nResult
= implExecuteDataTransfer( *m_aControlExchange
, rEvt
.mnAction
, rEvt
.maPosPixel
, sal_True
);
1315 OControlTransferData
aDroppedData( rEvt
.maDropEvent
.Transferable
);
1316 nResult
= implExecuteDataTransfer( aDroppedData
, rEvt
.mnAction
, rEvt
.maPosPixel
, sal_True
);
1322 //------------------------------------------------------------------------
1323 void NavigatorTree::doPaste()
1325 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doPaste" );
1328 if ( m_aControlExchange
.isClipboardOwner() )
1330 implExecuteDataTransfer( *m_aControlExchange
, doingKeyboardCut( ) ? DND_ACTION_MOVE
: DND_ACTION_COPY
, FirstSelected(), sal_False
);
1334 // the clipboard content
1335 Reference
< XClipboard
> xClipboard( GetClipboard() );
1336 Reference
< XTransferable
> xTransferable
;
1337 if ( xClipboard
.is() )
1338 xTransferable
= xClipboard
->getContents();
1340 OControlTransferData
aClipboardContent( xTransferable
);
1341 implExecuteDataTransfer( aClipboardContent
, DND_ACTION_COPY
, FirstSelected(), sal_False
);
1344 catch( const Exception
& )
1346 DBG_ERROR( "NavigatorTree::doPaste: caught an exception!" );
1350 //------------------------------------------------------------------------
1351 void NavigatorTree::doCopy()
1353 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCopy" );
1354 if ( implPrepareExchange( DND_ACTION_COPY
) )
1356 m_aControlExchange
.setClipboardListener( LINK( this, NavigatorTree
, OnClipboardAction
) );
1357 m_aControlExchange
.copyToClipboard( );
1361 //------------------------------------------------------------------------
1362 void NavigatorTree::ModelHasRemoved( SvListEntry
* _pEntry
)
1364 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ModelHasRemoved" );
1365 SvLBoxEntry
* pTypedEntry
= static_cast< SvLBoxEntry
* >( _pEntry
);
1366 if ( doingKeyboardCut() )
1367 m_aCutEntries
.erase( pTypedEntry
);
1369 if ( m_aControlExchange
.isDataExchangeActive() )
1371 if ( 0 == m_aControlExchange
->onEntryRemoved( pTypedEntry
) )
1373 // last of the entries which we put into the clipboard has been deleted from the tree.
1374 // Give up the clipboard ownership.
1375 m_aControlExchange
.clear();
1380 //------------------------------------------------------------------------
1381 void NavigatorTree::doCut()
1383 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCut" );
1384 if ( implPrepareExchange( DND_ACTION_MOVE
) )
1386 m_aControlExchange
.setClipboardListener( LINK( this, NavigatorTree
, OnClipboardAction
) );
1387 m_aControlExchange
.copyToClipboard( );
1388 m_bKeyboardCut
= sal_True
;
1390 // mark all the entries we just "cut" into the clipboard as "nearly moved"
1391 for ( sal_Int32 i
=0; i
<m_arrCurrentSelection
.Count(); ++i
)
1393 SvLBoxEntry
* pEntry
= m_arrCurrentSelection
[ (sal_uInt16
)i
];
1396 m_aCutEntries
.insert( pEntry
);
1397 pEntry
->SetFlags( pEntry
->GetFlags() | SV_ENTRYFLAG_SEMITRANSPARENT
);
1398 InvalidateEntry( pEntry
);
1404 //------------------------------------------------------------------------
1405 void NavigatorTree::KeyInput(const ::KeyEvent
& rKEvt
)
1407 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::KeyInput" );
1408 const KeyCode
& rCode
= rKEvt
.GetKeyCode();
1411 if (rKEvt
.GetKeyCode().GetCode() == KEY_DELETE
&& !rKEvt
.GetKeyCode().GetModifier())
1418 switch ( rCode
.GetFunction() )
1425 if ( implAcceptPaste() )
1437 SvTreeListBox::KeyInput(rKEvt
);
1440 //------------------------------------------------------------------------
1441 sal_Bool
NavigatorTree::EditingEntry( SvLBoxEntry
* pEntry
, Selection
& rSelection
)
1443 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditingEntry" );
1444 if (!SvTreeListBox::EditingEntry( pEntry
, rSelection
))
1447 return (pEntry
&& (pEntry
->GetUserData() != NULL
));
1448 // die Wurzel, die ich nicht umbenennen darf, hat als UserData NULL
1451 //------------------------------------------------------------------------
1452 void NavigatorTree::NewForm( SvLBoxEntry
* pParentEntry
)
1454 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewForm" );
1455 //////////////////////////////////////////////////////////////////////
1456 // ParentFormData holen
1457 if( !IsFormEntry(pParentEntry
) )
1460 FmFormData
* pParentFormData
= (FmFormData
*)pParentEntry
->GetUserData();
1462 //////////////////////////////////////////////////////////////////////
1463 // Neue Form erzeugen
1464 Reference
< XForm
> xNewForm(m_xORB
->createInstance(FM_SUN_COMPONENT_FORM
), UNO_QUERY
);
1468 FmFormData
* pNewFormData
= new FmFormData( xNewForm
, m_aNavigatorImages
, m_aNavigatorImagesHC
, pParentFormData
);
1470 //////////////////////////////////////////////////////////////////////
1472 ::rtl::OUString aName
= GenerateName(pNewFormData
);
1473 pNewFormData
->SetText(aName
);
1475 Reference
< XPropertySet
> xPropertySet(xNewForm
, UNO_QUERY
);
1476 if (!xPropertySet
.is())
1480 xPropertySet
->setPropertyValue( FM_PROP_NAME
, makeAny(aName
) );
1481 // a form should always have the command type table as default
1482 xPropertySet
->setPropertyValue( FM_PROP_COMMANDTYPE
, makeAny(sal_Int32(CommandType::TABLE
)));
1484 catch ( const Exception
& )
1486 DBG_ERROR("NavigatorTree::NewForm : could not set esssential properties !");
1490 //////////////////////////////////////////////////////////////////////
1492 GetNavModel()->Insert( pNewFormData
, LIST_APPEND
, sal_True
);
1494 //////////////////////////////////////////////////////////////////////
1495 // Neue Form als aktive Form setzen
1496 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
1499 InterfaceBag aSelection
;
1500 aSelection
.insert( Reference
< XInterface
>( xNewForm
, UNO_QUERY
) );
1501 pFormShell
->GetImpl()->setCurrentSelection( aSelection
);
1503 pFormShell
->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_PROPERTIES
,sal_True
,sal_True
);
1505 GetNavModel()->SetModified();
1507 //////////////////////////////////////////////////////////////////////
1508 // In EditMode schalten
1509 SvLBoxEntry
* pNewEntry
= FindEntry( pNewFormData
);
1510 EditEntry( pNewEntry
);
1513 //------------------------------------------------------------------------
1514 FmControlData
* NavigatorTree::NewControl( const ::rtl::OUString
& rServiceName
, SvLBoxEntry
* pParentEntry
, sal_Bool bEditName
)
1516 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewControl" );
1517 //////////////////////////////////////////////////////////////////////
1519 if (!GetNavModel()->GetFormShell())
1521 if (!IsFormEntry(pParentEntry
))
1524 FmFormData
* pParentFormData
= (FmFormData
*)pParentEntry
->GetUserData();;
1525 Reference
< XForm
> xParentForm( pParentFormData
->GetFormIface());
1527 //////////////////////////////////////////////////////////////////////
1528 // Neue Component erzeugen
1529 Reference
< XFormComponent
> xNewComponent(::comphelper::getProcessServiceFactory()->createInstance(rServiceName
), UNO_QUERY
);
1530 if (!xNewComponent
.is())
1533 FmControlData
* pNewFormControlData
= new FmControlData( xNewComponent
, m_aNavigatorImages
, m_aNavigatorImagesHC
, pParentFormData
);
1535 //////////////////////////////////////////////////////////////////////
1537 FmFormView
* pFormView
= GetNavModel()->GetFormShell()->GetFormView();
1538 SdrPageView
* pPageView
= pFormView
->GetSdrPageView();
1539 FmFormPage
* pPage
= (FmFormPage
*)pPageView
->GetPage();
1541 ::rtl::OUString sName
= pPage
->GetImpl().setUniqueName( xNewComponent
, xParentForm
);
1543 pNewFormControlData
->SetText( sName
);
1545 //////////////////////////////////////////////////////////////////////
1546 // FormComponent einfuegen
1547 GetNavModel()->Insert( pNewFormControlData
, LIST_APPEND
, sal_True
);
1548 GetNavModel()->SetModified();
1552 //////////////////////////////////////////////////////////////////////
1553 // In EditMode schalten
1554 SvLBoxEntry
* pNewEntry
= FindEntry( pNewFormControlData
);
1555 Select( pNewEntry
, sal_True
);
1556 EditEntry( pNewEntry
);
1559 return pNewFormControlData
;
1562 //------------------------------------------------------------------------
1563 ::rtl::OUString
NavigatorTree::GenerateName( FmEntryData
* pEntryData
)
1565 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::GenerateName" );
1566 const sal_uInt16 nMaxCount
= 99;
1567 ::rtl::OUString aNewName
;
1569 //////////////////////////////////////////////////////////////////////
1570 // BasisNamen erzeugen
1571 UniString aBaseName
;
1572 if( pEntryData
->ISA(FmFormData
) )
1573 aBaseName
= SVX_RES( RID_STR_STDFORMNAME
);
1575 else if( pEntryData
->ISA(FmControlData
) )
1576 aBaseName
= SVX_RES( RID_STR_CONTROL
);
1578 //////////////////////////////////////////////////////////////////////
1579 // Neuen Namen erstellen
1580 FmFormData
* pFormParentData
= (FmFormData
*)pEntryData
->GetParent();
1582 for( sal_Int32 i
=0; i
<nMaxCount
; i
++ )
1584 aNewName
= aBaseName
;
1587 aNewName
+= ::rtl::OUString::createFromAscii(" ");
1588 aNewName
+= ::rtl::OUString::valueOf(i
).getStr();
1591 if( GetNavModel()->FindData(aNewName
, pFormParentData
,sal_False
) == NULL
)
1598 //------------------------------------------------------------------------
1599 sal_Bool
NavigatorTree::EditedEntry( SvLBoxEntry
* pEntry
, const XubString
& rNewText
)
1601 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditedEntry" );
1602 if (EditingCanceled())
1606 FmEntryData
* pEntryData
= (FmEntryData
*)pEntry
->GetUserData();
1607 sal_Bool bRes
= GetNavModel()->Rename( pEntryData
, rNewText
);
1610 m_pEditEntry
= pEntry
;
1611 nEditEvent
= Application::PostUserEvent( LINK(this, NavigatorTree
, OnEdit
) );
1613 SetCursor(pEntry
, sal_True
);
1618 //------------------------------------------------------------------------
1619 IMPL_LINK( NavigatorTree
, OnEdit
, void*, EMPTYARG
)
1622 EditEntry( m_pEditEntry
);
1623 m_pEditEntry
= NULL
;
1628 //------------------------------------------------------------------------
1629 IMPL_LINK( NavigatorTree
, OnDropActionTimer
, void*, EMPTYARG
)
1631 if (--m_aTimerCounter
> 0)
1634 switch ( m_aDropActionType
)
1638 SvLBoxEntry
* pToExpand
= GetEntry(m_aTimerTriggered
);
1639 if (pToExpand
&& (GetChildCount(pToExpand
) > 0) && !IsExpanded(pToExpand
))
1640 // tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
1641 // habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
1642 // aber ich denke, die BK sollte es auch so vertragen
1645 // nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
1646 m_aDropActionTimer
.Stop();
1651 ScrollOutputArea( 1 );
1652 m_aTimerCounter
= DROP_ACTION_TIMER_SCROLL_TICKS
;
1655 case DA_SCROLLDOWN
:
1656 ScrollOutputArea( -1 );
1657 m_aTimerCounter
= DROP_ACTION_TIMER_SCROLL_TICKS
;
1665 //------------------------------------------------------------------------
1666 IMPL_LINK(NavigatorTree
, OnEntrySelDesel
, NavigatorTree
*, /*pThis*/)
1668 m_sdiState
= SDI_DIRTY
;
1670 if (IsSelectionHandlingLocked())
1673 if (m_aSynchronizeTimer
.IsActive())
1674 m_aSynchronizeTimer
.Stop();
1676 m_aSynchronizeTimer
.SetTimeout(EXPLORER_SYNC_DELAY
);
1677 m_aSynchronizeTimer
.Start();
1682 //------------------------------------------------------------------------
1683 IMPL_LINK(NavigatorTree
, OnSynchronizeTimer
, void*, EMPTYARG
)
1685 SynchronizeMarkList();
1690 //------------------------------------------------------------------------
1691 IMPL_LINK( NavigatorTree
, OnClipboardAction
, void*, EMPTYARG
)
1693 if ( !m_aControlExchange
.isClipboardOwner() )
1695 if ( doingKeyboardCut() )
1697 for ( ListBoxEntrySet::const_iterator i
= m_aCutEntries
.begin();
1698 i
!= m_aCutEntries
.end();
1702 SvLBoxEntry
* pEntry
= *i
;
1706 pEntry
->SetFlags( pEntry
->GetFlags() & ~SV_ENTRYFLAG_SEMITRANSPARENT
);
1707 InvalidateEntry( pEntry
);
1709 ListBoxEntrySet aEmpty
;
1710 m_aCutEntries
.swap( aEmpty
);
1712 m_bKeyboardCut
= sal_False
;
1718 //------------------------------------------------------------------------
1719 void NavigatorTree::ShowSelectionProperties(sal_Bool bForce
)
1721 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ShowSelectionProperties" );
1722 // zuerst brauche ich die FormShell
1723 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
1725 // keine Shell -> ich koennte kein curObject setzen -> raus
1728 CollectSelectionData(SDI_ALL
);
1729 DBG_ASSERT( m_nFormsSelected
+ m_nControlsSelected
+ (m_bRootSelected
? 1 : 0) == m_arrCurrentSelection
.Count(),
1730 "NavigatorTree::ShowSelectionProperties : selection meta data invalid !");
1733 InterfaceBag aSelection
;
1734 sal_Bool bSetSelectionAsMarkList
= sal_False
;
1736 if (m_bRootSelected
)
1737 ; // no properties for the root, neither for single nor for multi selection
1738 else if ( m_nFormsSelected
+ m_nControlsSelected
== 0 ) // none of the two should be less 0
1739 ; // no selection -> no properties
1740 else if ( m_nFormsSelected
* m_nControlsSelected
!= 0 )
1741 ; // mixed selection -> no properties
1743 { // either only forms, or only controls are selected
1744 if (m_arrCurrentSelection
.Count() == 1)
1746 if (m_nFormsSelected
> 0)
1747 { // es ist genau eine Form selektiert
1748 FmFormData
* pFormData
= (FmFormData
*)m_arrCurrentSelection
.GetObject(0)->GetUserData();
1749 aSelection
.insert( Reference
< XInterface
>( pFormData
->GetFormIface(), UNO_QUERY
) );
1752 { // es ist genau ein Control selektiert (egal ob hidden oder normal)
1753 FmEntryData
* pEntryData
= (FmEntryData
*)m_arrCurrentSelection
.GetObject(0)->GetUserData();
1755 aSelection
.insert( Reference
< XInterface
>( pEntryData
->GetElement(), UNO_QUERY
) );
1759 { // wir haben eine MultiSelection, also muessen wir ein MultiSet dafuer aufbauen
1760 if (m_nFormsSelected
> 0)
1762 // erstmal die PropertySet-Interfaces der Forms einsammeln
1763 for ( sal_Int32 i
= 0; i
< m_nFormsSelected
; ++i
)
1765 FmFormData
* pFormData
= (FmFormData
*)m_arrCurrentSelection
.GetObject((USHORT
)i
)->GetUserData();
1766 aSelection
.insert( pFormData
->GetPropertySet().get() );
1770 { // ... nur Controls
1771 if (m_nHiddenControls
== m_nControlsSelected
)
1772 { // ein MultiSet fuer die Properties der hidden controls
1773 for ( sal_Int32 i
= 0; i
< m_nHiddenControls
; ++i
)
1775 FmEntryData
* pEntryData
= (FmEntryData
*)m_arrCurrentSelection
.GetObject((USHORT
)i
)->GetUserData();
1776 aSelection
.insert( pEntryData
->GetPropertySet().get() );
1779 else if (m_nHiddenControls
== 0)
1780 { // nur normale Controls
1781 bSetSelectionAsMarkList
= sal_True
;
1788 // und dann meine Form und mein SelObject
1789 if ( bSetSelectionAsMarkList
)
1790 pFormShell
->GetImpl()->setCurrentSelectionFromMark( pFormShell
->GetFormView()->GetMarkedObjectList() );
1792 pFormShell
->GetImpl()->setCurrentSelection( aSelection
);
1794 if ( pFormShell
->GetImpl()->IsPropBrwOpen() || bForce
)
1796 // und jetzt kann ich das Ganze dem PropertyBrowser uebergeben
1797 pFormShell
->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER
, SFX_CALLMODE_ASYNCHRON
);
1801 //------------------------------------------------------------------------
1802 void NavigatorTree::DeleteSelection()
1804 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::DeleteSelection" );
1805 // die Root darf ich natuerlich nicht mitloeschen
1806 sal_Bool bRootSelected
= IsSelected(m_pRootEntry
);
1807 ULONG nSelectedEntries
= GetSelectionCount();
1808 if (bRootSelected
&& (nSelectedEntries
> 1)) // die Root plus andere Elemente ?
1809 Select(m_pRootEntry
, sal_False
); // ja -> die Root raus
1811 if ((nSelectedEntries
== 0) || bRootSelected
) // immer noch die Root ?
1812 return; // -> sie ist das einzige selektierte -> raus
1814 DBG_ASSERT(!m_bPrevSelectionMixed
, "NavigatorTree::DeleteSelection() : loeschen nicht erlaubt wenn Markierung und Selektion nciht konsistent");
1816 // ich brauche unten das FormModel ...
1817 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
1820 FmFormModel
* pFormModel
= pFormShell
? pFormShell
->GetFormModel() : NULL
;
1824 // jetzt muss ich noch die DeleteList etwas absichern : wenn man ein Formular und ein abhaengiges
1825 // Element loescht - und zwar in dieser Reihenfolge - dann ist der SvLBoxEntryPtr des abhaengigen Elementes
1826 // natuerlich schon ungueltig, wenn es geloescht werden soll ... diesen GPF, den es dann mit Sicherheit gibt,
1827 // gilt es zu verhindern, also die 'normalisierte' Liste
1828 CollectSelectionData( SDI_NORMALIZED
);
1830 // see below for why we need this mapping from models to shapes
1831 FmFormView
* pFormView
= pFormShell
->GetFormView();
1832 SdrPageView
* pPageView
= pFormView
? pFormView
->GetSdrPageView() : NULL
;
1833 SdrPage
* pPage
= pPageView
? pPageView
->GetPage() : NULL
;
1834 DBG_ASSERT( pPage
, "NavigatorTree::DeleteSelection: invalid form page!" );
1836 MapModelToShape aModelShapes
;
1838 collectShapeModelMapping( pPage
, aModelShapes
);
1840 // problem: we have to use ExplorerModel::Remove, since only this one properly deletes Form objects.
1841 // But, the controls themself must be deleted via DeleteMarked (else, the Writer has some problems
1842 // somewhere). In case I'd first delete the structure, then the controls, the UNDO would not work
1843 // (since UNDO then would mean to first restore the controls, then the structure, means their parent
1844 // form). The other way round, the EntryDatas would be invalid, if I'd first delete the controls and
1845 // then go on to the strucure. This means I have to delete the forms *after* the normal controls, so
1846 // that during UNDO, they're restored in the proper order.
1847 pFormShell
->GetImpl()->EnableTrackProperties(sal_False
);
1849 for (i
= m_arrCurrentSelection
.Count(); i
>0; --i
)
1851 FmEntryData
* pCurrent
= (FmEntryData
*)(m_arrCurrentSelection
.GetObject(i
- 1)->GetUserData());
1854 sal_Bool bIsForm
= pCurrent
->ISA(FmFormData
);
1856 // da ich das Loeschen im folgenden der View ueberlasse und dabei auf deren MarkList aufbaue, im Normalfall aber bei
1857 // einem makierten Formular nur die direkt, nicht die indirekt abhaengigen Controls markiert werden, muss ich das hier
1860 MarkViewObj((FmFormData
*)pCurrent
, sal_True
, sal_True
); // das zweite sal_True heisst "deep"
1862 // ein hidden control ?
1863 sal_Bool bIsHidden
= IsHiddenControl(pCurrent
);
1865 // Forms und hidden Controls muss ich behalten, alles andere nicht
1866 if (!bIsForm
&& !bIsHidden
)
1868 // well, no form and no hidden control -> we can remove it from m_arrCurrentSelection, as it will
1869 // be deleted automatically. This is because for every model (except forms and hidden control models)
1870 // there exist a shape, which is marked _if_and_only_if_ the model is selected in our tree.
1871 if ( aModelShapes
.find( pCurrent
->GetElement() ) != aModelShapes
.end() )
1873 // if there's a shape for the current entry, then either it is marked or it is in a
1874 // hidden layer (#i28502#), or something like this.
1875 // In the first case, it will be deleted below, in the second case, we currently don't
1876 // delete it, as there's no real (working!) API for this, neither in UNO nor in non-UNO.
1877 m_arrCurrentSelection
.Remove( i
- 1, 1 );
1879 // In case there is no shape for the current entry, we keep the entry in m_arrCurrentSelection,
1880 // since then we can definately remove it.
1884 pFormShell
->GetImpl()->EnableTrackProperties(sal_True
);
1886 // let the view delete the marked controls
1887 pFormShell
->GetFormView()->DeleteMarked();
1889 // start UNDO at this point. Unfortunately, this results in 2 UNDO actions, since DeleteMarked is
1890 // creating an own one. However, if we'd move it before DeleteMarked, Writer does not really like
1892 // 2004-07-05 - #i31038# - fs@openoffice.org
1897 if ( m_arrCurrentSelection
.Count() == 1 )
1899 aUndoStr
= SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE
);
1900 if (m_nFormsSelected
)
1901 aUndoStr
.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_FORM
) );
1903 // it must be a control (else the root would be selected, but it cannot be deleted)
1904 aUndoStr
.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_CONTROL
) );
1908 aUndoStr
= SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE_MULTIPLE
);
1909 aUndoStr
.SearchAndReplaceAscii( "#", String::CreateFromInt32( m_arrCurrentSelection
.Count() ) );
1911 pFormModel
->BegUndo(aUndoStr
);
1914 // remove remaining structure
1915 for (i
=0; i
<m_arrCurrentSelection
.Count(); ++i
)
1917 FmEntryData
* pCurrent
= (FmEntryData
*)(m_arrCurrentSelection
.GetObject(i
)->GetUserData());
1919 // if the entry still has children, we skipped deletion of one of those children.
1920 // This may for instance be because the shape is in a hidden layer, where we're unable
1922 if ( pCurrent
->GetChildList()->Count() )
1925 // noch ein kleines Problem, bevor ich das ganz loesche : wenn es eine Form ist und die Shell diese als CurrentObject
1926 // kennt, dann muss ich ihr das natuerlich ausreden
1927 if (pCurrent
->ISA(FmFormData
))
1929 Reference
< XForm
> xCurrentForm( static_cast< FmFormData
* >( pCurrent
)->GetFormIface() );
1930 if ( pFormShell
->GetImpl()->getCurrentForm() == xCurrentForm
) // die Shell kennt die zu loeschende Form ?
1931 pFormShell
->GetImpl()->forgetCurrentForm(); // -> wegnehmen ...
1933 GetNavModel()->Remove(pCurrent
, sal_True
);
1935 pFormModel
->EndUndo();
1938 //------------------------------------------------------------------------
1939 void NavigatorTree::CollectSelectionData(SELDATA_ITEMS sdiHow
)
1941 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::CollectSelectionData" );
1942 DBG_ASSERT(sdiHow
!= SDI_DIRTY
, "NavigatorTree::CollectSelectionData : ever thought about your parameter ? DIRTY ?");
1943 if (sdiHow
== m_sdiState
)
1946 m_arrCurrentSelection
.Remove((sal_uInt16
)0, m_arrCurrentSelection
.Count());
1947 m_nFormsSelected
= m_nControlsSelected
= m_nHiddenControls
= 0;
1948 m_bRootSelected
= sal_False
;
1950 SvLBoxEntry
* pSelectionLoop
= FirstSelected();
1951 while (pSelectionLoop
)
1953 // erst mal die Zaehlung der verschiedenen Elemente
1954 if (pSelectionLoop
== m_pRootEntry
)
1955 m_bRootSelected
= sal_True
;
1958 if (IsFormEntry(pSelectionLoop
))
1962 ++m_nControlsSelected
;
1963 if (IsHiddenControl((FmEntryData
*)(pSelectionLoop
->GetUserData())))
1964 ++m_nHiddenControls
;
1968 if (sdiHow
== SDI_NORMALIZED
)
1970 // alles, was schon einen selektierten Vorfahr hat, nicht mitnehmen
1971 if (pSelectionLoop
== m_pRootEntry
)
1972 m_arrCurrentSelection
.Insert(pSelectionLoop
);
1975 SvLBoxEntry
* pParentLoop
= GetParent(pSelectionLoop
);
1978 // eigentlich muesste ich testen, ob das Parent in der m_arrCurrentSelection steht ...
1979 // Aber wenn es selektiert ist, dann steht es in m_arrCurrentSelection, oder wenigstens einer seiner Vorfahren,
1980 // wenn der auch schon selektiert war. In beiden Faellen reicht also die Abfrage IsSelected
1981 if (IsSelected(pParentLoop
))
1985 if (m_pRootEntry
== pParentLoop
)
1987 // bis (exclusive) zur Root gab es kein selektiertes Parent -> der Eintrag gehoert in die normalisierte Liste
1988 m_arrCurrentSelection
.Insert(pSelectionLoop
);
1992 pParentLoop
= GetParent(pParentLoop
);
1997 else if (sdiHow
== SDI_NORMALIZED_FORMARK
)
1999 SvLBoxEntry
* pParent
= GetParent(pSelectionLoop
);
2000 if (!pParent
|| !IsSelected(pParent
) || IsFormEntry(pSelectionLoop
))
2001 m_arrCurrentSelection
.Insert(pSelectionLoop
);
2004 m_arrCurrentSelection
.Insert(pSelectionLoop
);
2007 pSelectionLoop
= NextSelected(pSelectionLoop
);
2010 m_sdiState
= sdiHow
;
2013 //------------------------------------------------------------------------
2014 void NavigatorTree::SynchronizeSelection(FmEntryDataArray
& arredToSelect
)
2016 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
2017 LockSelectionHandling();
2018 if (arredToSelect
.Count() == 0)
2020 SelectAll(sal_False
);
2024 // erst mal gleiche ich meine aktuelle Selektion mit der geforderten SelectList ab
2025 SvLBoxEntry
* pSelection
= FirstSelected();
2028 FmEntryData
* pCurrent
= (FmEntryData
*)pSelection
->GetUserData();
2029 if (pCurrent
!= NULL
)
2031 sal_uInt16 nPosition
;
2032 if ( arredToSelect
.Seek_Entry(pCurrent
, &nPosition
) )
2033 { // der Entry ist schon selektiert, steht aber auch in der SelectList -> er kann aus letzterer
2035 arredToSelect
.Remove(nPosition
, 1);
2037 { // der Entry ist selektiert, aber steht nicht in der SelectList -> Selektion rausnehmen
2038 Select(pSelection
, sal_False
);
2039 // und sichtbar machen (kann ja sein, dass das die einzige Modifikation ist, die ich hier in dem
2040 // ganzen Handler mache, dann sollte das zu sehen sein)
2041 MakeVisible(pSelection
);
2045 Select(pSelection
, sal_False
);
2047 pSelection
= NextSelected(pSelection
);
2050 // jetzt habe ich in der SelectList genau die Eintraege, die noch selektiert werden muessen
2051 // zwei Moeglichkeiten : 1) ich gehe durch die SelectList, besorge mir zu jedem Eintrag meinen SvLBoxEntry
2052 // und selektiere diesen (waere irgendwie intuitiver ;)) 2) ich gehe durch alle meine SvLBoxEntries und selektiere
2053 // genau die, die ich in der SelectList finde
2054 // 1) braucht O(k*n) (k=Laenge der SelectList, n=Anzahl meiner Entries), plus den Fakt, dass FindEntry nicht den
2055 // Pointer auf die UserDaten vergleicht, sondern ein aufwendigeres IsEqualWithoutChilds durchfuehrt
2056 // 2) braucht O(n*log k), dupliziert aber etwas Code (naemlich den aus FindEntry)
2057 // da das hier eine relativ oft aufgerufenen Stelle sein koennte (bei jeder Aenderung in der Markierung in der View !),
2058 // nehme ich doch lieber letzteres
2059 SvLBoxEntry
* pLoop
= First();
2062 FmEntryData
* pCurEntryData
= (FmEntryData
*)pLoop
->GetUserData();
2063 sal_uInt16 nPosition
;
2064 if ( arredToSelect
.Seek_Entry(pCurEntryData
, &nPosition
) )
2066 Select(pLoop
, sal_True
);
2068 SetCursor(pLoop
, sal_True
);
2071 pLoop
= Next( pLoop
);
2074 UnlockSelectionHandling();
2077 //------------------------------------------------------------------------
2078 void NavigatorTree::SynchronizeSelection()
2080 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
2082 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
2083 if(!pFormShell
) return;
2085 FmFormView
* pFormView
= pFormShell
->GetFormView();
2086 if (!pFormView
) return;
2088 GetNavModel()->BroadcastMarkedObjects(pFormView
->GetMarkedObjectList());
2091 //------------------------------------------------------------------------
2092 void NavigatorTree::SynchronizeMarkList()
2094 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeMarkList" );
2095 // die Shell werde ich brauchen ...
2096 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
2097 if (!pFormShell
) return;
2099 CollectSelectionData(SDI_NORMALIZED_FORMARK
);
2101 // Die View soll jetzt kein Notify bei einer Aenderung der MarkList rauslassen
2102 pFormShell
->GetImpl()->EnableTrackProperties(sal_False
);
2106 for (sal_uInt32 i
=0; i
<m_arrCurrentSelection
.Count(); ++i
)
2108 SvLBoxEntry
* pSelectionLoop
= m_arrCurrentSelection
.GetObject((USHORT
)i
);
2109 // Bei Formselektion alle Controls dieser Form markieren
2110 if (IsFormEntry(pSelectionLoop
) && (pSelectionLoop
!= m_pRootEntry
))
2111 MarkViewObj((FmFormData
*)pSelectionLoop
->GetUserData(), sal_True
, sal_False
);
2113 // Bei Controlselektion Control-SdrObjects markieren
2114 else if (IsFormComponentEntry(pSelectionLoop
))
2116 FmControlData
* pControlData
= (FmControlData
*)pSelectionLoop
->GetUserData();
2119 /////////////////////////////////////////////////////////////////
2120 // Beim HiddenControl kann kein Object selektiert werden
2121 Reference
< XFormComponent
> xFormComponent( pControlData
->GetFormComponent());
2122 if (!xFormComponent
.is())
2124 Reference
< XPropertySet
> xSet(xFormComponent
, UNO_QUERY
);
2128 sal_uInt16 nClassId
= ::comphelper::getINT16(xSet
->getPropertyValue(FM_PROP_CLASSID
));
2129 if (nClassId
!= FormComponentType::HIDDENCONTROL
)
2130 MarkViewObj(pControlData
, sal_True
, sal_True
);
2135 // wenn der PropertyBrowser offen ist, muss ich den entsprechend meiner Selektion anpassen
2136 // (NICHT entsprechend der MarkList der View : wenn ich ein Formular selektiert habe, sind in der
2137 // View alle zugehoerigen Controls markiert, trotzdem moechte ich natuerlich die Formular-Eigenschaften
2139 ShowSelectionProperties(sal_False
);
2141 // Flag an View wieder zuruecksetzen
2142 pFormShell
->GetImpl()->EnableTrackProperties(sal_True
);
2144 // wenn jetzt genau eine Form selektiert ist, sollte die Shell das als CurrentForm mitbekommen
2145 // (wenn SelectionHandling nicht locked ist, kuemmert sich die View eigentlich in MarkListHasChanged drum,
2146 // aber der Mechanismus greift zum Beispiel nicht, wenn die Form leer ist)
2147 if ((m_arrCurrentSelection
.Count() == 1) && (m_nFormsSelected
== 1))
2149 FmFormData
* pSingleSelectionData
= PTR_CAST( FmFormData
, static_cast< FmEntryData
* >( FirstSelected()->GetUserData() ) );
2150 DBG_ASSERT( pSingleSelectionData
, "NavigatorTree::SynchronizeMarkList: invalid selected form!" );
2151 if ( pSingleSelectionData
)
2153 InterfaceBag aSelection
;
2154 aSelection
.insert( Reference
< XInterface
>( pSingleSelectionData
->GetFormIface(), UNO_QUERY
) );
2155 pFormShell
->GetImpl()->setCurrentSelection( aSelection
);
2160 //------------------------------------------------------------------------
2161 sal_Bool
NavigatorTree::IsHiddenControl(FmEntryData
* pEntryData
)
2163 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsHiddenControl" );
2164 if (pEntryData
== NULL
) return sal_False
;
2166 Reference
< XPropertySet
> xProperties( pEntryData
->GetPropertySet() );
2167 if (::comphelper::hasProperty(FM_PROP_CLASSID
, xProperties
))
2169 Any aClassID
= xProperties
->getPropertyValue( FM_PROP_CLASSID
);
2170 return (::comphelper::getINT16(aClassID
) == FormComponentType::HIDDENCONTROL
);
2175 //------------------------------------------------------------------------
2176 sal_Bool
NavigatorTree::Select( SvLBoxEntry
* pEntry
, sal_Bool bSelect
)
2178 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Select" );
2179 if (bSelect
== IsSelected(pEntry
)) // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;)
2182 return SvTreeListBox::Select(pEntry
, bSelect
);
2185 //------------------------------------------------------------------------
2186 void NavigatorTree::UnmarkAllViewObj()
2188 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UnmarkAllViewObj" );
2189 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
2192 FmFormView
* pFormView
= pFormShell
->GetFormView();
2193 pFormView
->UnMarkAll();
2195 //------------------------------------------------------------------------
2196 void NavigatorTree::MarkViewObj(FmFormData
* pFormData
, sal_Bool bMark
, sal_Bool bDeep
)
2198 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
2199 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
2203 // first collect all sdrobjects
2204 ::std::set
< Reference
< XFormComponent
> > aObjects
;
2205 CollectObjects(pFormData
,bDeep
,aObjects
);
2207 //////////////////////////////////////////////////////////////////////
2208 // In der Page das entsprechende SdrObj finden und selektieren
2209 FmFormView
* pFormView
= pFormShell
->GetFormView();
2210 SdrPageView
* pPageView
= pFormView
->GetSdrPageView();
2211 SdrPage
* pPage
= pPageView
->GetPage();
2212 //FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( pPage );
2214 SdrObjListIter
aIter( *pPage
);
2215 while ( aIter
.IsMore() )
2217 SdrObject
* pSdrObject
= aIter
.Next();
2218 FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pSdrObject
);
2222 Reference
< XFormComponent
> xControlModel( pFormObject
->GetUnoControlModel(),UNO_QUERY
);
2223 if ( xControlModel
.is() && aObjects
.find(xControlModel
) != aObjects
.end() && bMark
!= pFormView
->IsObjMarked( pSdrObject
) )
2225 // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
2226 pFormView
->MarkObj( pSdrObject
, pPageView
, !bMark
, sal_False
);
2228 } // while ( aIter.IsMore() )
2231 // make the mark visible
2232 ::Rectangle
aMarkRect( pFormView
->GetAllMarkedRect());
2233 for ( sal_uInt32 i
= 0; i
< pFormView
->PaintWindowCount(); ++i
)
2235 SdrPaintWindow
* pPaintWindow
= pFormView
->GetPaintWindow( i
);
2236 OutputDevice
& rOutDev
= pPaintWindow
->GetOutputDevice();
2237 if ( OUTDEV_WINDOW
== rOutDev
.GetOutDevType() )
2239 pFormView
->MakeVisible( aMarkRect
, (Window
&)rOutDev
);
2241 } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2244 //------------------------------------------------------------------------
2245 void NavigatorTree::CollectObjects(FmFormData
* pFormData
, sal_Bool bDeep
, ::std::set
< Reference
< XFormComponent
> >& _rObjects
)
2247 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
2248 FmEntryDataList
* pChildList
= pFormData
->GetChildList();
2249 FmEntryData
* pEntryData
;
2250 FmControlData
* pControlData
;
2251 for( sal_uInt32 i
=0; i
< pChildList
->Count(); ++i
)
2253 pEntryData
= pChildList
->GetObject(i
);
2254 if( pEntryData
->ISA(FmControlData
) )
2256 pControlData
= (FmControlData
*)pEntryData
;
2257 _rObjects
.insert(pControlData
->GetFormComponent());
2258 } // if( pEntryData->ISA(FmControlData) )
2259 else if (bDeep
&& (pEntryData
->ISA(FmFormData
)))
2260 CollectObjects((FmFormData
*)pEntryData
,bDeep
,_rObjects
);
2261 } // for( sal_uInt32 i=0; i<pChildList->Count(); i++ )
2263 //------------------------------------------------------------------------
2264 void NavigatorTree::MarkViewObj( FmControlData
* pControlData
, sal_Bool bMarkHandles
, sal_Bool bMark
)
2266 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObj" );
2269 FmFormShell
* pFormShell
= GetNavModel()->GetFormShell();
2273 //////////////////////////////////////////////////////////////////////
2274 // In der Page das entsprechende SdrObj finden und selektieren
2275 FmFormView
* pFormView
= pFormShell
->GetFormView();
2276 Reference
< XFormComponent
> xFormComponent( pControlData
->GetFormComponent());
2277 SdrPageView
* pPageView
= pFormView
->GetSdrPageView();
2278 SdrPage
* pPage
= pPageView
->GetPage();
2280 bool bPaint
= false;
2281 SdrObjListIter
aIter( *pPage
);
2282 while ( aIter
.IsMore() )
2284 SdrObject
* pSdrObject
= aIter
.Next();
2285 FmFormObj
* pFormObject
= FmFormObj::GetFormObject( pSdrObject
);
2289 Reference
< XInterface
> xControlModel( pFormObject
->GetUnoControlModel() );
2290 if ( xControlModel
!= xFormComponent
)
2294 if ( bMark
!= pFormView
->IsObjMarked( pSdrObject
) )
2295 // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
2296 pFormView
->MarkObj( pSdrObject
, pPageView
, !bMark
, sal_False
);
2298 if ( !bMarkHandles
|| !bMark
)
2303 } // while ( aIter.IsMore() )
2306 // make the mark visible
2307 ::Rectangle
aMarkRect( pFormView
->GetAllMarkedRect());
2308 for ( sal_uInt32 i
= 0; i
< pFormView
->PaintWindowCount(); ++i
)
2310 SdrPaintWindow
* pPaintWindow
= pFormView
->GetPaintWindow( i
);
2311 OutputDevice
& rOutDev
= pPaintWindow
->GetOutputDevice();
2312 if ( OUTDEV_WINDOW
== rOutDev
.GetOutDevType() )
2314 pFormView
->MakeVisible( aMarkRect
, (Window
&)rOutDev
);
2316 } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
2320 //............................................................................
2321 } // namespace svxform
2322 //............................................................................