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 : :
30 : : #include <sal/types.h>
31 : : #include <sot/formats.hxx>
32 : : #include <sot/storage.hxx>
33 : : #include <vcl/msgbox.hxx>
34 : : #include <svl/urihelper.hxx>
35 : : #include <svx/svditer.hxx>
36 : : #include <sfx2/docfile.hxx>
37 : : #include <svx/svdoole2.hxx>
38 : : #include <vcl/svapp.hxx>
39 : : #include "cusshow.hxx"
40 : : #include <sfx2/childwin.hxx>
41 : :
42 : : #include <sfx2/viewfrm.hxx>
43 : :
44 : : #include "strmname.h"
45 : : #include "sdtreelb.hxx"
46 : : #include "DrawDocShell.hxx"
47 : : #include "drawdoc.hxx"
48 : : #include "sdpage.hxx"
49 : : #include "sdresid.hxx"
50 : : #include "navigatr.hxx"
51 : : #include "strings.hrc"
52 : : #include "res_bmp.hrc"
53 : : #include "customshowlist.hxx"
54 : :
55 : : #include <com/sun/star/embed/XEmbedPersist.hpp>
56 : : #include <svtools/embedtransfer.hxx>
57 : : #include <tools/diagnose_ex.h>
58 : : #include <comphelper/servicehelper.hxx>
59 : : #include <ViewShell.hxx>
60 : :
61 : : using namespace com::sun::star;
62 : :
63 [ # # ][ # # ]: 0 : class SdPageObjsTLB::IconProvider
[ # # ][ # # ]
[ # # ]
64 : : {
65 : : public:
66 : : IconProvider (void);
67 : :
68 : : // Regular icons.
69 : : Image maImgPage;
70 : : Image maImgPageExcl;
71 : : Image maImgPageObjsExcl;
72 : : Image maImgPageObjs;
73 : : Image maImgObjects;
74 : : Image maImgGroup;
75 : : };
76 : :
77 : :
78 : : sal_Bool SD_DLLPRIVATE SdPageObjsTLB::bIsInDrag = sal_False;
79 : :
80 : 0 : sal_Bool SdPageObjsTLB::IsInDrag()
81 : : {
82 : 0 : return bIsInDrag;
83 : : }
84 : :
85 : : sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = SAL_MAX_UINT32;
86 : :
87 : : // -----------------------------------------
88 : : // - SdPageObjsTLB::SdPageObjsTransferable -
89 : : // -----------------------------------------
90 : :
91 : 0 : SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
92 : : SdPageObjsTLB& rParent,
93 : : const INetBookmark& rBookmark,
94 : : ::sd::DrawDocShell& rDocShell,
95 : : NavigatorDragType eDragType,
96 : : const ::com::sun::star::uno::Any& rTreeListBoxData )
97 : : : SdTransferable(rDocShell.GetDoc(), NULL, sal_True),
98 : : mrParent( rParent ),
99 : : maBookmark( rBookmark ),
100 : : mrDocShell( rDocShell ),
101 : : meDragType( eDragType ),
102 [ # # ]: 0 : maTreeListBoxData( rTreeListBoxData )
103 : : {
104 : 0 : }
105 : :
106 : :
107 : :
108 : :
109 [ # # ]: 0 : SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
110 : : {
111 [ # # ]: 0 : }
112 : :
113 : : // -----------------------------------------------------------------------------
114 : :
115 : 0 : void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats()
116 : : {
117 : 0 : AddFormat(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK);
118 : 0 : AddFormat(SOT_FORMATSTR_ID_TREELISTBOX);
119 : 0 : AddFormat(GetListBoxDropFormatId());
120 : 0 : }
121 : :
122 : : // -----------------------------------------------------------------------------
123 : :
124 : 0 : sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
125 : : {
126 : 0 : sal_uLong nFormatId = SotExchange::GetFormat( rFlavor );
127 [ # # # ]: 0 : switch (nFormatId)
128 : : {
129 : : case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
130 : 0 : SetINetBookmark( maBookmark, rFlavor );
131 : 0 : return sal_True;
132 : :
133 : : case SOT_FORMATSTR_ID_TREELISTBOX:
134 : 0 : SetAny(maTreeListBoxData, rFlavor);
135 : 0 : return sal_True;
136 : :
137 : : default:
138 : 0 : return sal_False;
139 : : }
140 : : }
141 : :
142 : : // -----------------------------------------------------------------------------
143 : :
144 : 0 : void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
145 : : {
146 : 0 : mrParent.OnDragFinished( nDropAction );
147 : 0 : }
148 : :
149 : : // -----------------------------------------------------------------------------
150 : :
151 : 0 : ::sd::DrawDocShell& SdPageObjsTLB::SdPageObjsTransferable::GetDocShell() const
152 : : {
153 : 0 : return mrDocShell;
154 : : }
155 : :
156 : : // -----------------------------------------------------------------------------
157 : :
158 : 0 : NavigatorDragType SdPageObjsTLB::SdPageObjsTransferable::GetDragType() const
159 : : {
160 : 0 : return meDragType;
161 : : }
162 : :
163 : : // -----------------------------------------------------------------------------
164 : :
165 : 0 : sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException )
166 : : {
167 : : sal_Int64 nRet;
168 : :
169 [ # # # # ]: 0 : if( ( rId.getLength() == 16 ) &&
[ # # ]
170 : 0 : ( 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
171 : : {
172 : 0 : nRet = (sal_Int64)(sal_IntPtr)this;
173 : : }
174 : : else
175 : 0 : nRet = SdTransferable::getSomething(rId);
176 : :
177 : 0 : return nRet;
178 : : }
179 : :
180 : : namespace
181 : : {
182 : : class theSdPageObjsTLBUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdPageObjsTLBUnoTunnelId > {};
183 : : }
184 : :
185 : 0 : const ::com::sun::star::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()
186 : : {
187 : 0 : return theSdPageObjsTLBUnoTunnelId::get().getSeq();
188 : : }
189 : :
190 : : // -----------------------------------------------------------------------------
191 : :
192 : 0 : SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData )
193 : : throw()
194 : : {
195 : : try
196 : : {
197 [ # # ]: 0 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, ::com::sun::star::uno::UNO_QUERY_THROW );
198 : :
199 : : return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>(
200 : : sal::static_int_cast<sal_uIntPtr>(
201 [ # # ][ # # ]: 0 : xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) );
[ # # ][ # # ]
202 : : }
203 : 0 : catch( const ::com::sun::star::uno::Exception& )
204 : : {
205 : : }
206 : 0 : return 0;
207 : : }
208 : :
209 : :
210 : 0 : sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void)
211 : : {
212 [ # # ]: 0 : if (mnListBoxDropFormatId == SAL_MAX_UINT32)
213 : : mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType(rtl::OUString(
214 [ # # ][ # # ]: 0 : "application/x-openoffice-treelistbox-moveonly;windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\""));
[ # # ]
215 : 0 : return mnListBoxDropFormatId;
216 : : }
217 : :
218 : : /*************************************************************************
219 : : |*
220 : : |* Ctor1 SdPageObjsTLB
221 : : |*
222 : : \************************************************************************/
223 : :
224 : 0 : SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId )
225 : : : SvTreeListBox ( pParentWin, rSdResId )
226 : : , mpParent ( pParentWin )
227 : : , mpDoc ( NULL )
228 : : , mpBookmarkDoc ( NULL )
229 : : , mpMedium ( NULL )
230 : : , mpOwnMedium ( NULL )
231 : : , maImgOle ( BitmapEx( SdResId( BMP_OLE ) ) )
232 : : , maImgGraphic ( BitmapEx( SdResId( BMP_GRAPHIC ) ) )
233 : : , mbLinkableSelected ( sal_False )
234 : : , mpDropNavWin ( NULL )
235 : : , mbShowAllShapes ( false )
236 [ # # ][ # # ]: 0 : , mbShowAllPages ( false )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
237 : :
238 : : {
239 : : // Tree-ListBox mit Linien versehen
240 [ # # ]: 0 : SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
241 : : WB_HASBUTTONS | // WB_HASLINESATROOT |
242 : : WB_HSCROLL |
243 : : WB_HASBUTTONSATROOT |
244 [ # # ]: 0 : WB_QUICK_SEARCH /* i31275 */ );
245 : : SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ),
246 [ # # ][ # # ]: 0 : Bitmap( SdResId( BMP_COLLAPSE ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
247 : :
248 : : SetDragDropMode(
249 : : SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY |
250 [ # # ]: 0 : SV_DRAGDROP_APP_MOVE | SV_DRAGDROP_APP_COPY | SV_DRAGDROP_APP_DROP );
251 : 0 : }
252 : :
253 : : /*************************************************************************
254 : : |*
255 : : |* Dtor SdPageObjsTLB
256 : : |*
257 : : \************************************************************************/
258 : :
259 [ # # ][ # # ]: 0 : SdPageObjsTLB::~SdPageObjsTLB()
[ # # ][ # # ]
260 : : {
261 [ # # ]: 0 : if ( mpBookmarkDoc )
262 [ # # ]: 0 : CloseBookmarkDoc();
263 : : else
264 : : // no document was created from mpMedium, so this object is still the owner of it
265 [ # # ][ # # ]: 0 : delete mpMedium;
266 [ # # ]: 0 : }
267 : :
268 : : /*************************************************************************
269 : : |*
270 : : |* return name of object
271 : : |*
272 : : \************************************************************************/
273 : :
274 : 0 : String SdPageObjsTLB::GetObjectName(
275 : : const SdrObject* pObject,
276 : : const bool bCreate) const
277 : : {
278 : 0 : String aRet;
279 : :
280 [ # # ]: 0 : if ( pObject )
281 : : {
282 [ # # ][ # # ]: 0 : aRet = pObject->GetName();
283 : :
284 [ # # ][ # # ]: 0 : if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) )
[ # # ][ # # ]
[ # # ]
285 [ # # ][ # # ]: 0 : aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
[ # # ]
286 : : }
287 : :
288 [ # # ]: 0 : if (bCreate
[ # # # # ]
[ # # ][ # # ]
289 : : && mbShowAllShapes
290 : 0 : && aRet.Len() == 0
291 : : && pObject!=NULL)
292 : : {
293 [ # # ][ # # ]: 0 : aRet = SD_RESSTR(STR_NAVIGATOR_SHAPE_BASE_NAME);
[ # # ]
294 [ # # ][ # # ]: 0 : aRet.SearchAndReplaceAscii("%1", String::CreateFromInt32(pObject->GetOrdNum() + 1));
[ # # ][ # # ]
295 : : }
296 : :
297 : 0 : return aRet;
298 : : }
299 : :
300 : : /*************************************************************************
301 : : |*
302 : : |* In TreeLB Eintrag selektieren
303 : : |*
304 : : \************************************************************************/
305 : :
306 : 0 : sal_Bool SdPageObjsTLB::SelectEntry( const String& rName )
307 : : {
308 : 0 : sal_Bool bFound = sal_False;
309 : :
310 [ # # ]: 0 : if( rName.Len() )
311 : : {
312 : 0 : SvLBoxEntry* pEntry = NULL;
313 [ # # ]: 0 : String aTmp;
314 : :
315 [ # # ][ # # ]: 0 : for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
[ # # ][ # # ]
[ # # ]
316 : : {
317 [ # # ][ # # ]: 0 : aTmp = GetEntryText( pEntry );
[ # # ]
318 [ # # ][ # # ]: 0 : if( aTmp == rName )
319 : : {
320 : 0 : bFound = sal_True;
321 [ # # ]: 0 : SetCurEntry( pEntry );
322 : : }
323 [ # # ]: 0 : }
324 : : }
325 : 0 : return( bFound );
326 : : }
327 : :
328 : : /*************************************************************************
329 : : |*
330 : : |* Gibt zurueck, ob Children des uebergebenen Strings selektiert sind
331 : : |*
332 : : \************************************************************************/
333 : :
334 : 0 : sal_Bool SdPageObjsTLB::HasSelectedChildren( const String& rName )
335 : : {
336 : 0 : sal_Bool bFound = sal_False;
337 : 0 : sal_Bool bChildren = sal_False;
338 : :
339 [ # # ]: 0 : if( rName.Len() )
340 : : {
341 : 0 : SvLBoxEntry* pEntry = NULL;
342 [ # # ]: 0 : String aTmp;
343 : :
344 [ # # ][ # # ]: 0 : for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
[ # # ][ # # ]
[ # # ]
345 : : {
346 [ # # ][ # # ]: 0 : aTmp = GetEntryText( pEntry );
[ # # ]
347 [ # # ][ # # ]: 0 : if( aTmp == rName )
348 : : {
349 : 0 : bFound = sal_True;
350 [ # # ]: 0 : sal_Bool bExpanded = IsExpanded( pEntry );
351 [ # # ]: 0 : long nCount = GetChildSelectionCount( pEntry );
352 [ # # ][ # # ]: 0 : if( bExpanded && nCount > 0 )
353 : 0 : bChildren = sal_True;
354 : : }
355 [ # # ]: 0 : }
356 : : }
357 : 0 : return( bChildren );
358 : : }
359 : :
360 : :
361 : : /*************************************************************************
362 : : |*
363 : : |* TreeLB mit Seiten und Objekten fuellen
364 : : |*
365 : : \************************************************************************/
366 : :
367 : 0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages,
368 : : const String& rDocName)
369 : : {
370 [ # # ]: 0 : String aSelection;
371 [ # # ]: 0 : if( GetSelectionCount() > 0 )
372 : : {
373 [ # # ][ # # ]: 0 : aSelection = GetSelectEntry();
[ # # ]
374 [ # # ]: 0 : Clear();
375 : : }
376 : :
377 : 0 : mpDoc = pInDoc;
378 [ # # ]: 0 : maDocName = rDocName;
379 : 0 : mbShowAllPages = (bAllPages == sal_True);
380 : 0 : mpMedium = NULL;
381 : :
382 : 0 : SdPage* pPage = NULL;
383 : :
384 [ # # ]: 0 : IconProvider aIconProvider;
385 : :
386 : : // first insert all pages including objects
387 : 0 : sal_uInt16 nPage = 0;
388 [ # # ]: 0 : const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
389 : :
390 [ # # ]: 0 : while( nPage < nMaxPages )
391 : : {
392 [ # # ]: 0 : pPage = (SdPage*) mpDoc->GetPage( nPage );
393 [ # # ]: 0 : if( (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD)
[ # # # # ]
[ # # ]
394 : 0 : && !(pPage->GetPageKind()==PK_HANDOUT) ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
395 : : {
396 : 0 : sal_Bool bPageExluded = pPage->IsExcluded();
397 : :
398 [ # # ]: 0 : bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
399 : 0 : bPageExluded |= !bPageBelongsToShow;
400 : :
401 [ # # ][ # # ]: 0 : AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider);
[ # # ]
402 : : }
403 : 0 : nPage++;
404 : : }
405 : :
406 : : // dann alle MasterPages incl. Objekte einfuegen
407 [ # # ]: 0 : if( mbShowAllPages )
408 : : {
409 : 0 : nPage = 0;
410 [ # # ]: 0 : const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
411 : :
412 [ # # ]: 0 : while( nPage < nMaxMasterPages )
413 : : {
414 [ # # ]: 0 : pPage = (SdPage*) mpDoc->GetMasterPage( nPage );
415 [ # # ][ # # ]: 0 : AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider);
[ # # ]
416 : 0 : nPage++;
417 : : }
418 : : }
419 [ # # ]: 0 : if( aSelection.Len() )
420 [ # # ][ # # ]: 0 : SelectEntry( aSelection );
[ # # ]
421 : 0 : }
422 : :
423 : : /*************************************************************************
424 : : |*
425 : : |* Es wird nur der erste Eintrag eingefuegt. Children werden OnDemand erzeugt
426 : : |*
427 : : \************************************************************************/
428 : :
429 : 0 : void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
430 : : const String& rDocName )
431 : : {
432 : 0 : mpDoc = pInDoc;
433 : :
434 : : // this object now owns the Medium
435 : 0 : mpMedium = pInMedium;
436 [ # # ]: 0 : maDocName = rDocName;
437 : :
438 [ # # ][ # # ]: 0 : Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) );
[ # # ][ # # ]
439 [ # # ][ # # ]: 0 : Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) );
[ # # ][ # # ]
440 : :
441 : : // Dokumentnamen einfuegen
442 : : InsertEntry( maDocName, aImgDocOpen, aImgDocClosed, NULL, sal_True, LIST_APPEND,
443 : : reinterpret_cast< void* >( 1 )
444 [ # # ][ # # ]: 0 : );
[ # # ]
445 : 0 : }
446 : :
447 : :
448 : :
449 : :
450 : 0 : void SdPageObjsTLB::AddShapeList (
451 : : const SdrObjList& rList,
452 : : SdrObject* pShape,
453 : : const ::rtl::OUString& rsName,
454 : : const bool bIsExcluded,
455 : : SvLBoxEntry* pParentEntry,
456 : : const IconProvider& rIconProvider)
457 : : {
458 [ # # ]: 0 : Image aIcon (rIconProvider.maImgPage);
459 [ # # ]: 0 : if (bIsExcluded)
460 [ # # ]: 0 : aIcon = rIconProvider.maImgPageExcl;
461 [ # # ]: 0 : else if (pShape != NULL)
462 [ # # ]: 0 : aIcon = rIconProvider.maImgGroup;
463 : :
464 : 0 : void* pUserData (reinterpret_cast<void*>(1));
465 [ # # ]: 0 : if (pShape != NULL)
466 : 0 : pUserData = pShape;
467 : :
468 : : SvLBoxEntry* pEntry = InsertEntry(
469 : : rsName,
470 : : aIcon,
471 : : aIcon,
472 : : pParentEntry,
473 : : sal_False,
474 : : LIST_APPEND,
475 [ # # ][ # # ]: 0 : pUserData);
[ # # ]
476 : :
477 : : SdrObjListIter aIter(
478 : : rList,
479 [ # # ]: 0 : !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
480 : : IM_FLAT,
481 [ # # ]: 0 : sal_False /*not reverse*/);
482 : :
483 [ # # ]: 0 : while( aIter.IsMore() )
484 : : {
485 [ # # ]: 0 : SdrObject* pObj = aIter.Next();
486 : : OSL_ASSERT(pObj!=NULL);
487 : :
488 : : // Get the shape name.
489 [ # # ]: 0 : String aStr (GetObjectName( pObj ) );
490 : :
491 [ # # ]: 0 : if( aStr.Len() )
492 : : {
493 [ # # ][ # # ]: 0 : if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
[ # # ][ # # ]
[ # # ]
494 : : {
495 : : InsertEntry(
496 : : aStr,
497 : : maImgOle,
498 : : maImgOle,
499 : : pEntry,
500 : : sal_False,
501 : : LIST_APPEND,
502 : : pObj
503 [ # # ]: 0 : );
504 : : }
505 [ # # ][ # # ]: 0 : else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
[ # # ][ # # ]
[ # # ]
506 : : {
507 : : InsertEntry(
508 : : aStr,
509 : : maImgGraphic,
510 : : maImgGraphic,
511 : : pEntry,
512 : : sal_False,
513 : : LIST_APPEND,
514 : : pObj
515 [ # # ]: 0 : );
516 : : }
517 [ # # ][ # # ]: 0 : else if (pObj->IsGroupObject())
518 : : {
519 : : AddShapeList(
520 [ # # ]: 0 : *pObj->GetSubList(),
521 : : pObj,
522 : : aStr,
523 : : false,
524 : : pEntry,
525 : : rIconProvider
526 [ # # ][ # # ]: 0 : );
527 : : }
528 : : else
529 : : {
530 : : InsertEntry(
531 : : aStr,
532 : : rIconProvider.maImgObjects,
533 : : rIconProvider.maImgObjects,
534 : : pEntry,
535 : : sal_False,
536 : : LIST_APPEND,
537 : : pObj
538 [ # # ]: 0 : );
539 : : }
540 : : }
541 [ # # ]: 0 : }
542 : :
543 [ # # ]: 0 : if( pEntry->HasChildren() )
544 : : {
545 : : SetExpandedEntryBmp(
546 : : pEntry,
547 [ # # ][ # # ]: 0 : bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
548 : : SetCollapsedEntryBmp(
549 : : pEntry,
550 [ # # ][ # # ]: 0 : bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
551 [ # # ]: 0 : }
552 : 0 : }
553 : :
554 : :
555 : :
556 : :
557 : 0 : void SdPageObjsTLB::SetShowAllShapes (
558 : : const bool bShowAllShapes,
559 : : const bool bFillList)
560 : : {
561 : 0 : mbShowAllShapes = bShowAllShapes;
562 [ # # ]: 0 : if (bFillList)
563 : : {
564 [ # # ]: 0 : if (mpMedium == NULL)
565 : 0 : Fill(mpDoc, mbShowAllPages, maDocName);
566 : : else
567 : 0 : Fill(mpDoc, mpMedium, maDocName);
568 : : }
569 : 0 : }
570 : :
571 : :
572 : :
573 : :
574 : 0 : bool SdPageObjsTLB::GetShowAllShapes (void) const
575 : : {
576 : 0 : return mbShowAllShapes;
577 : : }
578 : :
579 : :
580 : :
581 : :
582 : : /*************************************************************************
583 : : |*
584 : : |* Prueft, ob die Seiten (PK_STANDARD) und die darauf befindlichen Objekte
585 : : |* des Docs und der TreeLB identisch sind.
586 : : |* Wird ein Doc uebergeben, wird dieses zum aktuellem Doc (Wichtig bei
587 : : |* mehreren Documenten).
588 : : |*
589 : : \************************************************************************/
590 : :
591 : 0 : sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
592 : : {
593 [ # # ]: 0 : if( pInDoc )
594 : 0 : mpDoc = pInDoc;
595 : :
596 [ # # ]: 0 : if( !mpDoc )
597 : 0 : return( sal_False );
598 : :
599 : 0 : SdrObject* pObj = NULL;
600 : 0 : SdPage* pPage = NULL;
601 [ # # ]: 0 : SvLBoxEntry* pEntry = First();
602 [ # # ]: 0 : String aName;
603 : :
604 : : // Alle Pages incl. Objekte vergleichen
605 : 0 : sal_uInt16 nPage = 0;
606 [ # # ]: 0 : const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
607 : :
608 [ # # ]: 0 : while( nPage < nMaxPages )
609 : : {
610 [ # # ]: 0 : pPage = (SdPage*) mpDoc->GetPage( nPage );
611 [ # # ]: 0 : if( pPage->GetPageKind() == PK_STANDARD )
612 : : {
613 [ # # ]: 0 : if( !pEntry )
614 : 0 : return( sal_False );
615 [ # # ][ # # ]: 0 : aName = GetEntryText( pEntry );
[ # # ]
616 : :
617 [ # # ][ # # ]: 0 : if( pPage->GetName() != aName )
[ # # ]
618 : 0 : return( sal_False );
619 : :
620 [ # # ]: 0 : pEntry = Next( pEntry );
621 : :
622 : : SdrObjListIter aIter(
623 : : *pPage,
624 [ # # ]: 0 : !pPage->HasObjectNavigationOrder() /* use navigation order, if available */,
625 [ # # ]: 0 : IM_DEEPWITHGROUPS );
626 : :
627 [ # # ]: 0 : while( aIter.IsMore() )
628 : : {
629 [ # # ]: 0 : pObj = aIter.Next();
630 : :
631 [ # # ]: 0 : const String aObjectName( GetObjectName( pObj ) );
632 : :
633 [ # # ]: 0 : if( aObjectName.Len() )
634 : : {
635 [ # # ]: 0 : if( !pEntry )
636 : 0 : return( sal_False );
637 : :
638 [ # # ][ # # ]: 0 : aName = GetEntryText( pEntry );
[ # # ]
639 : :
640 [ # # ][ # # ]: 0 : if( aObjectName != aName )
641 : 0 : return( sal_False );
642 : :
643 [ # # ]: 0 : pEntry = Next( pEntry );
644 : : }
645 [ # # ][ # # ]: 0 : }
[ # # ]
646 : : }
647 : 0 : nPage++;
648 : : }
649 : : // Wenn noch Eintraege in der Listbox vorhanden sind, wurden
650 : : // Objekte (mit Namen) oder Seiten geloescht
651 [ # # ]: 0 : return( !pEntry );
652 : : }
653 : :
654 : : /*************************************************************************
655 : : |*
656 : : |* Selectierten String zurueckgeben
657 : : |*
658 : : \************************************************************************/
659 : :
660 : 0 : String SdPageObjsTLB::GetSelectEntry()
661 : : {
662 : 0 : return( GetEntryText( GetCurEntry() ) );
663 : : }
664 : :
665 : 0 : std::vector<rtl::OUString> SdPageObjsTLB::GetSelectEntryList( const sal_uInt16 nDepth ) const
666 : : {
667 : 0 : std::vector<rtl::OUString> aEntries;
668 [ # # ]: 0 : SvLBoxEntry* pEntry = FirstSelected();
669 : :
670 [ # # ]: 0 : while( pEntry )
671 : : {
672 [ # # ]: 0 : sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry );
673 : :
674 [ # # ]: 0 : if( nListDepth == nDepth )
675 [ # # ][ # # ]: 0 : aEntries.push_back(GetEntryText(pEntry));
[ # # ][ # # ]
676 : :
677 [ # # ]: 0 : pEntry = NextSelected( pEntry );
678 : : }
679 : :
680 : 0 : return aEntries;
681 : : }
682 : :
683 : : /*************************************************************************
684 : : |*
685 : : |* Eintraege werden erst auf Anforderung (Doppelklick) eingefuegt
686 : : |*
687 : : \************************************************************************/
688 : :
689 : 0 : void SdPageObjsTLB::RequestingChildren( SvLBoxEntry* pFileEntry )
690 : : {
691 [ # # ]: 0 : if( !pFileEntry->HasChildren() )
692 : : {
693 [ # # ]: 0 : if( GetBookmarkDoc() )
694 : : {
695 : 0 : SdrObject* pObj = NULL;
696 : 0 : SdPage* pPage = NULL;
697 : 0 : SvLBoxEntry* pPageEntry = NULL;
698 : :
699 [ # # ][ # # ]: 0 : Image aImgPage = Image( BitmapEx( SdResId( BMP_PAGE ) ) );
[ # # ][ # # ]
700 [ # # ][ # # ]: 0 : Image aImgPageObjs = Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) );
[ # # ][ # # ]
701 [ # # ][ # # ]: 0 : Image aImgObjects = Image( BitmapEx( SdResId( BMP_OBJECTS ) ) );
[ # # ][ # # ]
702 : :
703 : : // document name already inserted
704 : :
705 : : // only insert all "normal" ? slides with objects
706 : 0 : sal_uInt16 nPage = 0;
707 [ # # ]: 0 : const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
708 : :
709 [ # # ]: 0 : while( nPage < nMaxPages )
710 : : {
711 [ # # ]: 0 : pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage );
712 [ # # ]: 0 : if( pPage->GetPageKind() == PK_STANDARD )
713 : : {
714 [ # # ]: 0 : pPageEntry = InsertEntry( pPage->GetName(),
715 : : aImgPage,
716 : : aImgPage,
717 : : pFileEntry,
718 : : sal_False,
719 : : LIST_APPEND,
720 [ # # ]: 0 : reinterpret_cast< void* >( 1 ) );
721 : :
722 [ # # ]: 0 : SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
723 : :
724 [ # # ]: 0 : while( aIter.IsMore() )
725 : : {
726 [ # # ]: 0 : pObj = aIter.Next();
727 [ # # ]: 0 : String aStr( GetObjectName( pObj ) );
728 [ # # ]: 0 : if( aStr.Len() )
729 : : {
730 [ # # ][ # # ]: 0 : if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 )
[ # # ][ # # ]
[ # # ]
731 : : {
732 [ # # ]: 0 : InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
733 : : }
734 [ # # ][ # # ]: 0 : else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF )
[ # # ][ # # ]
[ # # ]
735 : : {
736 [ # # ]: 0 : InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
737 : : }
738 : : else
739 : : {
740 [ # # ]: 0 : InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
741 : : }
742 : : }
743 [ # # ]: 0 : }
744 [ # # ]: 0 : if( pPageEntry->HasChildren() )
745 : : {
746 [ # # ]: 0 : SetExpandedEntryBmp( pPageEntry, aImgPageObjs );
747 [ # # ]: 0 : SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
748 : 0 : }
749 : : }
750 : 0 : nPage++;
751 [ # # ][ # # ]: 0 : }
[ # # ]
752 : : }
753 : : }
754 : : else
755 : 0 : SvTreeListBox::RequestingChildren( pFileEntry );
756 : 0 : }
757 : :
758 : : /*************************************************************************
759 : : |*
760 : : |* Prueft, ob es sich um eine Draw-Datei handelt und oeffnet anhand des
761 : : |* uebergebenen Docs das BookmarkDoc
762 : : |*
763 : : \************************************************************************/
764 : :
765 : 0 : SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
766 : : {
767 [ # # ][ # # ]: 0 : if (
[ # # # # ]
[ # # ]
768 : 0 : !mpBookmarkDoc ||
769 : 0 : (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
770 : : )
771 : : {
772 : : // create a new BookmarkDoc if now one exists or if a new Medium is provided
773 [ # # ]: 0 : if (mpOwnMedium != pMed)
774 : : {
775 : 0 : CloseBookmarkDoc();
776 : : }
777 : :
778 [ # # ]: 0 : if (pMed)
779 : : {
780 : : // it looks that it is undefined if a Medium was set by Fill() allready
781 : : DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
782 [ # # ]: 0 : delete mpMedium;
783 : 0 : mpMedium = NULL;
784 : :
785 : : // take over this Medium (currently used only be Navigator)
786 : 0 : mpOwnMedium = pMed;
787 : : }
788 : :
789 : : DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
790 : :
791 [ # # ]: 0 : if( pMed )
792 : : {
793 : : // in this mode the document is also owned and controlled by this instance
794 [ # # ]: 0 : mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True);
795 [ # # ]: 0 : if (mxBookmarkDocShRef->DoLoad(pMed))
796 : 0 : mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
797 : : else
798 : 0 : mpBookmarkDoc = NULL;
799 : : }
800 [ # # ]: 0 : else if ( mpMedium )
801 : : // in this mode the document is owned and controlled by the SdDrawDocument
802 : : // it can be released by calling the corresponding CloseBookmarkDoc method
803 : : // successfull creation of a document makes this the owner of the medium
804 : 0 : mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium);
805 : :
806 [ # # ]: 0 : if ( !mpBookmarkDoc )
807 : : {
808 [ # # ][ # # ]: 0 : ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) );
[ # # ][ # # ]
809 [ # # ]: 0 : aErrorBox.Execute();
810 [ # # ]: 0 : mpMedium = 0; //On failure the SfxMedium is invalid
811 : : }
812 : : }
813 : :
814 : 0 : return( mpBookmarkDoc );
815 : : }
816 : :
817 : : /*************************************************************************
818 : : |*
819 : : |* Bookmark-Dokument schlie�en und loeschen
820 : : |*
821 : : \************************************************************************/
822 : :
823 : 0 : void SdPageObjsTLB::CloseBookmarkDoc()
824 : : {
825 [ # # ]: 0 : if (mxBookmarkDocShRef.Is())
826 : : {
827 : 0 : mxBookmarkDocShRef->DoClose();
828 : 0 : mxBookmarkDocShRef.Clear();
829 : :
830 : : // Medium is owned by document, so it's destroyed already
831 : 0 : mpOwnMedium = 0;
832 : : }
833 [ # # ]: 0 : else if ( mpBookmarkDoc )
834 : : {
835 : : DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
836 [ # # ]: 0 : if ( mpDoc )
837 : : {
838 : : // The document owns the Medium, so the Medium will be invalid after closing the document
839 : 0 : ((SdDrawDocument*) mpDoc)->CloseBookmarkDoc();
840 : 0 : mpMedium = 0;
841 : : }
842 : : }
843 : : else
844 : : {
845 : : // perhaps mpOwnMedium provided, but no successfull creation of BookmarkDoc
846 [ # # ]: 0 : delete mpOwnMedium;
847 : 0 : mpOwnMedium = NULL;
848 : : }
849 : :
850 : 0 : mpBookmarkDoc = NULL;
851 : 0 : }
852 : :
853 : 0 : void SdPageObjsTLB::SelectHdl()
854 : : {
855 : 0 : SvLBoxEntry* pEntry = FirstSelected();
856 : :
857 : 0 : mbLinkableSelected = sal_True;
858 : :
859 [ # # ][ # # ]: 0 : while( pEntry && mbLinkableSelected )
[ # # ]
860 : : {
861 [ # # ]: 0 : if( NULL == pEntry->GetUserData() )
862 : 0 : mbLinkableSelected = sal_False;
863 : :
864 : 0 : pEntry = NextSelected( pEntry );
865 : : }
866 : :
867 : 0 : SvTreeListBox::SelectHdl();
868 : 0 : }
869 : :
870 : : /*************************************************************************
871 : : |*
872 : : |* Ueberlaedt RETURN mit der Funktionsweise von DoubleClick
873 : : |*
874 : : \************************************************************************/
875 : :
876 : 0 : void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
877 : : {
878 [ # # ]: 0 : if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
879 : : {
880 : : // Auskommentierter Code aus svtools/source/contnr/svimpbox.cxx
881 : 0 : SvLBoxEntry* pCursor = GetCurEntry();
882 [ # # ][ # # ]: 0 : if( pCursor->HasChildren() || pCursor->HasChildrenOnDemand() )
[ # # ]
883 : : {
884 [ # # ]: 0 : if( IsExpanded( pCursor ) )
885 : 0 : Collapse( pCursor );
886 : : else
887 : 0 : Expand( pCursor );
888 : : }
889 : :
890 : 0 : DoubleClickHdl();
891 : : }
892 : : else
893 : 0 : SvTreeListBox::KeyInput( rKEvt );
894 : 0 : }
895 : :
896 : : /*************************************************************************
897 : : |*
898 : : |* StartDrag-Request
899 : : |*
900 : : \************************************************************************/
901 : :
902 : 0 : void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel)
903 : : {
904 : : (void)nAction;
905 : : (void)rPosPixel;
906 : :
907 : 0 : SdNavigatorWin* pNavWin = NULL;
908 : 0 : SvLBoxEntry* pEntry = GetEntry(rPosPixel);
909 : :
910 [ # # ]: 0 : if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
911 : 0 : pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
912 : :
913 [ # # ][ # # ]: 0 : if (pEntry != NULL
[ # # # # ]
[ # # ]
914 : : && pNavWin !=NULL
915 : : && pNavWin == mpParent
916 : 0 : && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE )
917 : : {
918 : : // Mark only the children of the page under the mouse as drop
919 : : // targets. This prevents moving shapes from one page to another.
920 : :
921 : : // Select all entries and disable them as drop targets.
922 : 0 : SetSelectionMode(MULTIPLE_SELECTION);
923 : 0 : SetCursor(NULL, sal_False);
924 : 0 : SelectAll(sal_True, sal_False);
925 : 0 : EnableSelectionAsDropTarget(sal_False, sal_True);
926 : :
927 : : // Enable only the entries as drop targets that are children of the
928 : : // page under the mouse.
929 : 0 : SvLBoxEntry* pParent = GetRootLevelParent(pEntry);
930 [ # # ]: 0 : if (pParent != NULL)
931 : : {
932 : 0 : SelectAll(sal_False, sal_False);
933 : 0 : Select(pParent, sal_True);
934 : : // for (SvLBoxEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
935 : : // Select(pChild, sal_True);
936 : 0 : EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False);
937 : : }
938 : :
939 : : // Set selection back to the entry under the mouse.
940 : 0 : SelectAll(sal_False,sal_False);
941 : 0 : SetSelectionMode(SINGLE_SELECTION);
942 : 0 : Select(pEntry, sal_True);
943 : :
944 : : // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
945 : : // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
946 : : // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
947 : : // Deshalb Drag&Drop asynchron:
948 [ # # ]: 0 : Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) );
949 : : }
950 : 0 : }
951 : :
952 : : /*************************************************************************
953 : : |*
954 : : |* Begin drag
955 : : |*
956 : : \************************************************************************/
957 : :
958 : 0 : void SdPageObjsTLB::DoDrag()
959 : : {
960 : 0 : mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ?
961 : 0 : (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) :
962 [ # # ]: 0 : NULL;
963 : :
964 [ # # ]: 0 : if( mpDropNavWin )
965 : : {
966 : 0 : ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
967 [ # # ][ # # ]: 0 : String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE );
[ # # ][ # # ]
[ # # ]
968 [ # # ]: 0 : NavigatorDragType eDragType = mpDropNavWin->GetNavigatorDragType();
969 : :
970 [ # # ]: 0 : aURL.Append( '#' );
971 [ # # ][ # # ]: 0 : aURL.Append( GetSelectEntry() );
[ # # ]
972 : :
973 [ # # ][ # # ]: 0 : INetBookmark aBookmark( aURL, GetSelectEntry() );
[ # # ]
974 : 0 : sal_Int8 nDNDActions = DND_ACTION_COPYMOVE;
975 : :
976 [ # # ]: 0 : if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
977 : 0 : nDNDActions = DND_ACTION_LINK; // Either COPY *or* LINK, never both!
978 : :
979 [ # # ]: 0 : SvTreeListBox::ReleaseMouse();
980 : :
981 : 0 : bIsInDrag = sal_True;
982 : :
983 : : SvLBoxDDInfo aDDInfo;
984 : 0 : memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
985 [ # # ]: 0 : aDDInfo.pApp = GetpApp();
986 : 0 : aDDInfo.pSource = this;
987 : : // aDDInfo.pDDStartEntry = pEntry;
988 [ # # ]: 0 : ::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo));
989 [ # # ]: 0 : memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo));
990 [ # # ]: 0 : ::com::sun::star::uno::Any aTreeListBoxData (aSequence);
991 : :
992 : : // object is destroyed by internal reference mechanism
993 : : SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable(
994 [ # # ]: 0 : *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData);
995 : : OSL_TRACE("created new SdPageObjsTransferable at %x", pTransferable);
996 : :
997 : : // Get the view.
998 : 0 : sd::View* pView = NULL;
999 [ # # ]: 0 : if (pDocShell != NULL)
1000 : : {
1001 : 0 : ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
1002 [ # # ]: 0 : if (pViewShell != NULL)
1003 : 0 : pView = pViewShell->GetView();
1004 : : }
1005 [ # # ]: 0 : if (pView == NULL)
1006 : : {
1007 : : OSL_ASSERT(pView!=NULL);
1008 : : return;
1009 : : }
1010 : :
1011 : 0 : SdrObject* pObject = NULL;
1012 [ # # ]: 0 : void* pUserData = GetCurEntry()->GetUserData();
1013 [ # # ][ # # ]: 0 : if (pUserData != NULL && pUserData != (void*)1)
1014 : 0 : pObject = reinterpret_cast<SdrObject*>(pUserData);
1015 [ # # ]: 0 : if (pObject == NULL)
1016 : : return;
1017 : :
1018 : : // For shapes without a user supplied name (the automatically
1019 : : // created name does not count), a different drag and drop technique
1020 : : // is used.
1021 [ # # ][ # # ]: 0 : if (GetObjectName(pObject, false).Len() == 0)
[ # # ]
1022 : : {
1023 [ # # ]: 0 : AddShapeToTransferable(*pTransferable, *pObject);
1024 : 0 : pTransferable->SetView(pView);
1025 [ # # ]: 0 : SD_MOD()->pTransferDrag = pTransferable;
1026 : : }
1027 : :
1028 : : // Unnamed shapes have to be selected to be recognized by the
1029 : : // current drop implementation. In order to have a consistent
1030 : : // behaviour for all shapes, every shape that is to be dragged is
1031 : : // selected first.
1032 : 0 : SdrPageView* pPageView = pView->GetSdrPageView();
1033 [ # # ]: 0 : pView->UnmarkAllObj(pPageView);
1034 [ # # ]: 0 : pView->MarkObj(pObject, pPageView);
1035 : :
1036 [ # # ][ # # ]: 0 : pTransferable->StartDrag( this, nDNDActions );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1037 : : }
1038 : : }
1039 : :
1040 : : /*************************************************************************
1041 : : |*
1042 : : |* Drag finished
1043 : : |*
1044 : : \************************************************************************/
1045 : :
1046 : 0 : void SdPageObjsTLB::OnDragFinished( sal_uInt8 )
1047 : : {
1048 [ # # ]: 0 : if( mpFrame->HasChildWindow( SID_NAVIGATOR ) )
1049 : : {
1050 : 0 : SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) );
1051 : :
1052 [ # # ]: 0 : if( mpDropNavWin == pNewNavWin)
1053 : : {
1054 [ # # ][ # # ]: 0 : MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() );
1055 [ # # ]: 0 : SvTreeListBox::MouseButtonUp( aMEvt );
1056 : : }
1057 : : }
1058 : :
1059 : 0 : mpDropNavWin = NULL;
1060 : 0 : bIsInDrag = sal_False;
1061 : 0 : }
1062 : :
1063 : : /*************************************************************************
1064 : : |*
1065 : : |* AcceptDrop-Event
1066 : : |*
1067 : : \************************************************************************/
1068 : :
1069 : 0 : sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
1070 : : {
1071 : 0 : sal_Int8 nResult (DND_ACTION_NONE);
1072 : :
1073 [ # # ][ # # ]: 0 : if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) )
[ # # ]
1074 : : {
1075 : 0 : nResult = rEvent.mnAction;
1076 : : }
1077 : : else
1078 : : {
1079 : 0 : SvLBoxEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
1080 [ # # ][ # # ]: 0 : if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
[ # # ]
1081 : : {
1082 : 0 : ImplShowTargetEmphasis( pTargetEntry, sal_False );
1083 : : }
1084 [ # # ]: 0 : else if( !nDragDropMode )
1085 : : {
1086 : : SAL_WARN( "sc.ui", "SdPageObjsTLB::AcceptDrop(): no target" );
1087 : : }
1088 [ # # ]: 0 : else if (IsDropAllowed(pEntry))
1089 : : {
1090 : 0 : nResult = DND_ACTION_MOVE;
1091 : :
1092 : : // Draw emphasis.
1093 [ # # ][ # # ]: 0 : if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS))
1094 : : {
1095 : 0 : ImplShowTargetEmphasis( pTargetEntry, sal_False );
1096 : 0 : pTargetEntry = pEntry;
1097 : 0 : ImplShowTargetEmphasis( pTargetEntry, sal_True );
1098 : : }
1099 : : }
1100 : : }
1101 : :
1102 : : // Hide emphasis when there is no valid drop action.
1103 [ # # ]: 0 : if (nResult == DND_ACTION_NONE)
1104 : 0 : ImplShowTargetEmphasis(pTargetEntry, sal_False);
1105 : :
1106 : 0 : return nResult;
1107 : : }
1108 : :
1109 : : /*************************************************************************
1110 : : |*
1111 : : |* ExecuteDrop-Event
1112 : : |*
1113 : : \************************************************************************/
1114 : :
1115 : 0 : sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
1116 : : {
1117 : 0 : sal_Int8 nRet = DND_ACTION_NONE;
1118 : :
1119 : : try
1120 : : {
1121 [ # # ]: 0 : if( !bIsInDrag )
1122 : : {
1123 : 0 : SdNavigatorWin* pNavWin = NULL;
1124 : 0 : sal_uInt16 nId = SID_NAVIGATOR;
1125 : :
1126 [ # # ][ # # ]: 0 : if( mpFrame->HasChildWindow( nId ) )
1127 [ # # ][ # # ]: 0 : pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) );
[ # # ]
1128 : :
1129 [ # # ][ # # ]: 0 : if( pNavWin && ( pNavWin == mpParent ) )
1130 : : {
1131 [ # # ]: 0 : TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable );
1132 [ # # ]: 0 : String aFile;
1133 : :
1134 [ # # ][ # # ]: 0 : if( aDataHelper.GetString( FORMAT_FILE, aFile ) &&
[ # # ][ # # ]
1135 [ # # ]: 0 : ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) )
1136 : : {
1137 : 0 : nRet = rEvt.mnAction;
1138 [ # # ][ # # ]: 0 : }
[ # # ]
1139 : : }
1140 : : }
1141 : : }
1142 : 0 : catch (com::sun::star::uno::Exception&)
1143 : : {
1144 : : DBG_UNHANDLED_EXCEPTION();
1145 : : }
1146 : :
1147 [ # # ]: 0 : if (nRet == DND_ACTION_NONE)
1148 : 0 : SvTreeListBox::ExecuteDrop(rEvt, this);
1149 : :
1150 : :
1151 : 0 : return nRet;
1152 : : }
1153 : :
1154 : : /*************************************************************************
1155 : : |*
1156 : : |* Handler fuers Dragging
1157 : : |*
1158 : : \************************************************************************/
1159 : :
1160 : 0 : IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG)
1161 : : {
1162 : : // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
1163 : : // Navigator geloescht werden darf
1164 : 0 : pThis->DoDrag();
1165 : 0 : return 0;
1166 : : }
1167 : :
1168 : :
1169 : 0 : bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
1170 : : {
1171 : : // Return <TRUE/> as default when there is no custom show or when none
1172 : : // is used. The page does then belong to the standard show.
1173 : 0 : bool bBelongsToShow = true;
1174 : :
1175 [ # # ]: 0 : if (mpDoc->getPresentationSettings().mbCustomShow)
1176 : : {
1177 : : // Get the current custom show.
1178 : 0 : SdCustomShow* pCustomShow = NULL;
1179 : 0 : SdCustomShowList* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
1180 [ # # ]: 0 : if (pShowList != NULL)
1181 : : {
1182 : 0 : sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
1183 : 0 : pCustomShow = (*pShowList)[nCurrentShowIndex];
1184 : : }
1185 : :
1186 : : // Check whether the given page is part of that custom show.
1187 [ # # ]: 0 : if (pCustomShow != NULL)
1188 : : {
1189 : 0 : bBelongsToShow = false;
1190 : 0 : sal_uLong nPageCount = pCustomShow->PagesVector().size();
1191 [ # # ][ # # ]: 0 : for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++)
[ # # ]
1192 [ # # ]: 0 : if (pPage == pCustomShow->PagesVector()[i])
1193 : 0 : bBelongsToShow = true;
1194 : : }
1195 : : }
1196 : :
1197 : 0 : return bBelongsToShow;
1198 : : }
1199 : :
1200 : :
1201 : :
1202 : :
1203 : 0 : sal_Bool SdPageObjsTLB::NotifyMoving(
1204 : : SvLBoxEntry* pTarget,
1205 : : SvLBoxEntry* pEntry,
1206 : : SvLBoxEntry*& rpNewParent,
1207 : : sal_uLong& rNewChildPos)
1208 : : {
1209 : 0 : SvLBoxEntry* pDestination = pTarget;
1210 [ # # ][ # # ]: 0 : while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL)
[ # # ]
1211 : 0 : pDestination = GetParent(pDestination);
1212 : :
1213 : 0 : SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData());
1214 : 0 : SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData());
1215 [ # # ]: 0 : if (pSourceObject == reinterpret_cast<SdrObject*>(1))
1216 : 0 : pSourceObject = NULL;
1217 : :
1218 [ # # ][ # # ]: 0 : if (pTargetObject != NULL && pSourceObject != NULL)
1219 : : {
1220 : 0 : SdrPage* pObjectList = pSourceObject->GetPage();
1221 [ # # ]: 0 : if (pObjectList != NULL)
1222 : : {
1223 : : sal_uInt32 nNewPosition;
1224 [ # # ]: 0 : if (pTargetObject == reinterpret_cast<SdrObject*>(1))
1225 : 0 : nNewPosition = 0;
1226 : : else
1227 : 0 : nNewPosition = pTargetObject->GetNavigationPosition() + 1;
1228 : 0 : pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
1229 : : }
1230 : :
1231 : : // Update the tree list.
1232 [ # # ]: 0 : if (pTarget == NULL)
1233 : : {
1234 : 0 : rpNewParent = 0;
1235 : 0 : rNewChildPos = 0;
1236 : 0 : return sal_True;
1237 : : }
1238 [ # # ]: 0 : else if (GetParent(pDestination) == NULL)
1239 : : {
1240 : 0 : rpNewParent = pDestination;
1241 : 0 : rNewChildPos = 0;
1242 : : }
1243 : : else
1244 : : {
1245 : 0 : rpNewParent = GetParent(pDestination);
1246 : 0 : rNewChildPos = pModel->GetRelPos(pDestination) + 1;
1247 : 0 : rNewChildPos += nCurEntrySelPos;
1248 : 0 : nCurEntrySelPos++;
1249 : : }
1250 : 0 : return sal_True;
1251 : : }
1252 : : else
1253 : 0 : return sal_False;
1254 : : }
1255 : :
1256 : :
1257 : :
1258 : :
1259 : 0 : SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
1260 : : {
1261 : 0 : SvLBoxEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
1262 [ # # ]: 0 : if (pEntry == NULL)
1263 : 0 : return NULL;
1264 : :
1265 : : OSL_TRACE("entry is %s",
1266 : : ::rtl::OUStringToOString(GetEntryText(pEntry), RTL_TEXTENCODING_UTF8).getStr());
1267 [ # # ]: 0 : if (GetParent(pEntry) == NULL)
1268 : : {
1269 : : // Use page entry as insertion position.
1270 : : }
1271 : : else
1272 : : {
1273 : : // Go to second hierarchy level, i.e. top level shapes,
1274 : : // i.e. children of pages.
1275 [ # # ][ # # ]: 0 : while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL)
[ # # ][ # # ]
[ # # ][ # # ]
1276 [ # # ]: 0 : pEntry = GetParent(pEntry);
1277 : :
1278 : : // Advance to next sibling.
1279 : : SvLBoxEntry* pNext;
1280 : 0 : sal_uInt16 nDepth (0);
1281 [ # # ]: 0 : while (pEntry != NULL)
1282 : : {
1283 [ # # ][ # # ]: 0 : pNext = dynamic_cast<SvLBoxEntry*>(NextVisible(pEntry, &nDepth));
1284 [ # # ][ # # ]: 0 : if (pNext != NULL && nDepth > 0 && nDepth!=0xffff)
[ # # ]
1285 : 0 : pEntry = pNext;
1286 : : else
1287 : 0 : break;
1288 : : }
1289 : : OSL_TRACE("returning %s",
1290 : : ::rtl::OUStringToOString(GetEntryText(pEntry), RTL_TEXTENCODING_UTF8).getStr());
1291 : : }
1292 : :
1293 : 0 : return pEntry;
1294 : : }
1295 : :
1296 : :
1297 : :
1298 : :
1299 : 0 : bool SdPageObjsTLB::IsDropAllowed (SvLBoxEntry* pEntry)
1300 : : {
1301 [ # # ]: 0 : if (pEntry == NULL)
1302 : 0 : return false;
1303 : :
1304 [ # # ]: 0 : if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
1305 : 0 : return false;
1306 : :
1307 [ # # ]: 0 : if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0)
1308 : 0 : return false;
1309 : :
1310 : 0 : return true;
1311 : : }
1312 : :
1313 : :
1314 : :
1315 : :
1316 : 0 : void SdPageObjsTLB::AddShapeToTransferable (
1317 : : SdTransferable& rTransferable,
1318 : : SdrObject& rObject) const
1319 : : {
1320 [ # # ]: 0 : TransferableObjectDescriptor aObjectDescriptor;
1321 : 0 : bool bIsDescriptorFillingPending (true);
1322 : :
1323 [ # # ]: 0 : const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
1324 [ # # ][ # # ]: 0 : if (pOleObject != NULL && pOleObject->GetObjRef().is())
[ # # ][ # # ]
[ # # # # ]
1325 : : {
1326 : : // If object has no persistence it must be copied as part of the document
1327 : : try
1328 : : {
1329 [ # # ][ # # ]: 0 : uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY );
1330 [ # # ][ # # ]: 0 : if (xPersObj.is() && xPersObj->hasEntry())
[ # # ][ # # ]
[ # # ]
1331 : : {
1332 : : SvEmbedTransferHelper::FillTransferableObjectDescriptor(
1333 : : aObjectDescriptor,
1334 : : pOleObject->GetObjRef(),
1335 : : pOleObject->GetGraphic(),
1336 [ # # ][ # # ]: 0 : pOleObject->GetAspect());
[ # # ][ # # ]
1337 : 0 : bIsDescriptorFillingPending = false;
1338 [ # # ]: 0 : }
1339 : : }
1340 [ # # ]: 0 : catch( uno::Exception& )
1341 : : {
1342 : : }
1343 : : }
1344 : :
1345 : 0 : ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
1346 [ # # ][ # # ]: 0 : if (bIsDescriptorFillingPending && pDocShell!=NULL)
1347 : : {
1348 : 0 : bIsDescriptorFillingPending = false;
1349 [ # # ]: 0 : pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
1350 : : }
1351 : :
1352 [ # # ][ # # ]: 0 : Point aDragPos (rObject.GetCurrentBoundRect().Center());
1353 : : //Point aDragPos (0,0);
1354 : 0 : aObjectDescriptor.maDragStartPos = aDragPos;
1355 : : // aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
1356 [ # # ]: 0 : if (pDocShell != NULL)
1357 [ # # ][ # # ]: 0 : aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
[ # # ]
1358 : : else
1359 [ # # ][ # # ]: 0 : aObjectDescriptor.maDisplayName = String();
[ # # ]
1360 : 0 : aObjectDescriptor.mbCanLink = sal_False;
1361 : :
1362 : 0 : rTransferable.SetStartPos(aDragPos);
1363 [ # # ][ # # ]: 0 : rTransferable.SetObjectDescriptor( aObjectDescriptor );
1364 : 0 : }
1365 : :
1366 : :
1367 : :
1368 : :
1369 : : //===== IconProvider ==========================================================
1370 : :
1371 : 0 : SdPageObjsTLB::IconProvider::IconProvider (void)
1372 : : : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ),
1373 : : maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ),
1374 : : maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ),
1375 : : maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ),
1376 : : maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ),
1377 [ # # ][ # # ]: 0 : maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1378 : : {
1379 [ + - ][ + - ]: 75 : }
1380 : :
1381 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|