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