1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <tools/urlobj.hxx>
#include <unotools/localfilehelper.hxx>
#include <sfx2/imgmgr.hxx>
#include <sfx2/fcontnr.hxx>
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
#include <svl/intitem.hxx>
#include <sfx2/dispatch.hxx>
#include <svx/svxids.hrc>
#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/dockwin.hxx>
#include <sfx2/sfxresid.hxx>
#include "pres.hxx"
#include "navigatr.hxx"
#include "navigatr.hrc"
#include "pgjump.hxx"
#include "app.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#include "drawdoc.hxx"
#include "DrawDocShell.hxx"
#include "sdresid.hxx"
#include "ViewShell.hxx"
#include "ViewShellBase.hxx"
#include "DrawViewShell.hxx"
#include "slideshow.hxx"
#include "FrameView.hxx"
#include "helpids.h"
namespace {
static const sal_uInt16 nShowNamedShapesFilter=1;
static const sal_uInt16 nShowAllShapesFilter=2;
}
/**
* SdNavigatorWin - FloatingWindow
*/
SdNavigatorWin::SdNavigatorWin(
vcl::Window* pParent,
::sd::NavigatorChildWindow* pChWinCtxt,
const SdResId& rSdResId,
SfxBindings* pInBindings,
const UpdateRequestFunctor& rUpdateRequest)
: vcl::Window( pParent, rSdResId )
, maToolbox ( this, SdResId( 1 ) )
, maTlbObjects( this, SdResId( TLB_OBJECTS ) )
, maLbDocs ( this, SdResId( LB_DOCS ) )
, mpChildWinContext( pChWinCtxt )
, mbDocImported ( false )
// On changes of the DragType: adjust SelectionMode of TLB!
, meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED )
, mpBindings ( pInBindings )
, maImageList ( SdResId( IL_NAVIGATR ) )
{
maTlbObjects.SetViewFrame( mpBindings->GetDispatcher()->GetFrame() );
FreeResource();
maTlbObjects.SetAccessibleName(SD_RESSTR(STR_OBJECTS_TREE));
mpNavigatorCtrlItem = new SdNavigatorControllerItem( SID_NAVIGATOR_STATE, this, mpBindings, rUpdateRequest);
mpPageNameCtrlItem = new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME, this, mpBindings, rUpdateRequest);
ApplyImageList(); // load images *before* calculating sizes to get something useful !!!
Size aTbxSize( maToolbox.CalcWindowSizePixel() );
maToolbox.SetOutputSizePixel( aTbxSize );
maToolbox.SetSelectHdl( LINK( this, SdNavigatorWin, SelectToolboxHdl ) );
maToolbox.SetClickHdl( LINK( this, SdNavigatorWin, ClickToolboxHdl ) );
maToolbox.SetDropdownClickHdl( LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl) );
maToolbox.SetItemBits( TBI_DRAGTYPE, maToolbox.GetItemBits( TBI_DRAGTYPE ) | ToolBoxItemBits::DROPDOWNONLY );
// Shape filter drop down menu.
maToolbox.SetItemBits(
TBI_SHAPE_FILTER,
maToolbox.GetItemBits(TBI_SHAPE_FILTER) | ToolBoxItemBits::DROPDOWNONLY);
// TreeListBox
// set position below toolbox
long nListboxYPos = maToolbox.GetPosPixel().Y() + maToolbox.GetSizePixel().Height() + 4;
maTlbObjects.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
maTlbObjects.SetDoubleClickHdl( LINK( this, SdNavigatorWin, ClickObjectHdl ) );
maTlbObjects.SetSelectionMode( SINGLE_SELECTION );
// set focus to listbox, otherwise it is in the toolbox which is only useful
// for keyboard navigation
maTlbObjects.GrabFocus();
maTlbObjects.SetSdNavigatorWinFlag(true);
// DragTypeListBox
maLbDocs.SetSelectHdl( LINK( this, SdNavigatorWin, SelectDocumentHdl ) );
// set position below treelistbox
nListboxYPos = maTlbObjects.GetPosPixel().Y() + maTlbObjects.GetSizePixel().Height() + 4;
maLbDocs.setPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y );
// assure that tool box is at least as wide as the tree list box
{
const Size aTlbSize( maTlbObjects.GetOutputSizePixel() );
if ( aTlbSize.Width() > aTbxSize.Width() )
{
maToolbox.setPosSizePixel( 0, 0, aTlbSize.Width(), 0, WINDOW_POSSIZE_WIDTH );
aTbxSize = maToolbox.GetOutputSizePixel();
}
}
// set min outputsize after all sizes are known
const long nFullHeight = nListboxYPos + maLbDocs.GetSizePixel().Height() + 4;
maSize = GetOutputSizePixel();
if( maSize.Height() < nFullHeight )
{
maSize.Height() = nFullHeight;
SetOutputSizePixel( maSize );
}
maMinSize = maSize;
const long nMinWidth = 2*maToolbox.GetPosPixel().X() + aTbxSize.Width(); // never clip the toolbox
if( nMinWidth > maMinSize.Width() )
maMinSize.Width() = nMinWidth;
maMinSize.Height() -= 40;
SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(GetParent());
if (pDockingParent != NULL)
pDockingParent->SetMinOutputSizePixel( maMinSize );
// InitTlb; is initiated over Slot
if (rUpdateRequest)
rUpdateRequest();
}
SdNavigatorWin::~SdNavigatorWin()
{
delete mpNavigatorCtrlItem;
delete mpPageNameCtrlItem;
}
//when object is marked , fresh the corresponding entry tree .
void SdNavigatorWin::FreshTree( const SdDrawDocument* pDoc )
{
SdDrawDocument* pNonConstDoc = const_cast<SdDrawDocument*>(pDoc); // const as const can...
sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
OUString aDocShName( pDocShell->GetName() );
OUString aDocName = pDocShell->GetMedium()->GetName();
maTlbObjects.SetSaveTreeItemStateFlag(true); //Added by yanjun for sym2_6385
maTlbObjects.Clear();
maTlbObjects.Fill( pDoc, false, aDocName ); // Nur normale Seiten
maTlbObjects.SetSaveTreeItemStateFlag(false); //Added by yanjun for sym2_6385
RefreshDocumentLB();
maLbDocs.SelectEntry( aDocShName );
}
void SdNavigatorWin::FreshEntry( )
{
maTlbObjects.FreshCurEntry();
}
void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc )
{
SdDrawDocument* pNonConstDoc = const_cast<SdDrawDocument*>(pDoc); // const as const can...
::sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
OUString aDocShName( pDocShell->GetName() );
::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
// Restore the 'ShowAllShapes' flag from the last time (in this session)
// that the navigator was shown.
if (pViewShell != NULL)
{
::sd::FrameView* pFrameView = pViewShell->GetFrameView();
if (pFrameView != NULL)
maTlbObjects.SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
}
// Disable the shape filter drop down menu when there is a running slide
// show.
if (pViewShell!=NULL && sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ))
maToolbox.EnableItem(TBI_SHAPE_FILTER, false);
else
maToolbox.EnableItem(TBI_SHAPE_FILTER);
if( !maTlbObjects.IsEqualToDoc( pDoc ) )
{
OUString aDocName = pDocShell->GetMedium()->GetName();
maTlbObjects.Clear();
maTlbObjects.Fill( pDoc, false, aDocName ); // only normal pages
RefreshDocumentLB();
maLbDocs.SelectEntry( aDocShName );
}
else
{
maLbDocs.SetNoSelection();
maLbDocs.SelectEntry( aDocShName );
// commented in order to fix 30246
// if( maLbDocs.GetSelectEntryCount() == 0 )
{
RefreshDocumentLB();
maLbDocs.SelectEntry( aDocShName );
}
}
SfxViewFrame* pViewFrame = ( ( pViewShell && pViewShell->GetViewFrame() ) ? pViewShell->GetViewFrame() : SfxViewFrame::Current() );
if( pViewFrame )
pViewFrame->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME, true, true);
}
/**
* DragType is set on dependence if a Drag is even possible. For example,
* under certain circumstances, it is not allowed to drag graphics (#31038#).
*/
NavigatorDragType SdNavigatorWin::GetNavigatorDragType()
{
NavigatorDragType eDT = meDragType;
NavDocInfo* pInfo = GetDocInfo();
if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() ) )
eDT = NAVIGATOR_DRAGTYPE_NONE;
return eDT;
}
//Get SdDrawDocShell
sd::DrawDocShell* SdNavigatorWin::GetDrawDocShell( const SdDrawDocument* pDoc )
{
if( !pDoc )
return NULL; // const as const can...
sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
return pDocShell;
}
IMPL_LINK_NOARG(SdNavigatorWin, SelectToolboxHdl)
{
sal_uInt16 nId = maToolbox.GetCurItemId();
sal_uInt16 nSId = 0;
PageJump ePage = PAGE_NONE;
switch( nId )
{
case TBI_PEN:
{
if( nId == TBI_PEN )
{
nSId = SID_NAVIGATOR_PEN;
}
if( nSId > 0 )
{
SfxBoolItem aItem( nSId, true );
mpBindings->GetDispatcher()->Execute(
nSId, SfxCallMode::SLOT |SfxCallMode::RECORD, &aItem, 0L );
}
}
break;
case TBI_FIRST:
case TBI_PREVIOUS:
case TBI_NEXT:
case TBI_LAST:
{
if( nId == TBI_FIRST )
ePage = PAGE_FIRST;
else if( nId == TBI_PREVIOUS )
ePage = PAGE_PREVIOUS;
else if( nId == TBI_NEXT )
ePage = PAGE_NEXT;
else if( nId == TBI_LAST )
ePage = PAGE_LAST;
if( ePage != PAGE_NONE )
{
SfxUInt16Item aItem( SID_NAVIGATOR_PAGE, (sal_uInt16)ePage );
mpBindings->GetDispatcher()->Execute(
SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
}
}
break;
}
return 0;
}
IMPL_LINK_NOARG(SdNavigatorWin, ClickToolboxHdl)
{
return 0;
}
IMPL_LINK( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox )
{
sal_uInt16 nId = maToolbox.GetCurItemId();
switch( nId )
{
case TBI_DRAGTYPE:
{
// Popup menu is created depending if the document is saved or not
PopupMenu *pMenu = new PopupMenu;
static const char* aHIDs[] =
{
HID_SD_NAVIGATOR_MENU1,
HID_SD_NAVIGATOR_MENU2,
HID_SD_NAVIGATOR_MENU3,
0
};
for( sal_uInt16 nID = NAVIGATOR_DRAGTYPE_URL;
nID < NAVIGATOR_DRAGTYPE_COUNT;
nID++ )
{
sal_uInt16 nRId = GetDragTypeSdResId( (NavigatorDragType)nID );
if( nRId > 0 )
{
DBG_ASSERT(aHIDs[nID-NAVIGATOR_DRAGTYPE_URL],"HelpId not added!");
pMenu->InsertItem( nID, SD_RESSTR( nRId ) );
pMenu->SetHelpId( nID, aHIDs[nID - NAVIGATOR_DRAGTYPE_URL] );
}
}
NavDocInfo* pInfo = GetDocInfo();
if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() )
{
pMenu->EnableItem( NAVIGATOR_DRAGTYPE_LINK, false );
pMenu->EnableItem( NAVIGATOR_DRAGTYPE_URL, false );
meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
}
pMenu->CheckItem( (sal_uInt16)meDragType );
pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, MenuSelectHdl ) );
pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN );
pBox->EndSelection();
delete pMenu;
}
break;
case TBI_SHAPE_FILTER:
{
PopupMenu *pMenu = new PopupMenu;
pMenu->InsertItem(
nShowNamedShapesFilter,
SD_RESSTR(STR_NAVIGATOR_SHOW_NAMED_SHAPES));
pMenu->InsertItem(
nShowAllShapesFilter,
SD_RESSTR(STR_NAVIGATOR_SHOW_ALL_SHAPES));
if (maTlbObjects.GetShowAllShapes())
pMenu->CheckItem(nShowAllShapesFilter);
else
pMenu->CheckItem(nShowNamedShapesFilter);
pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, ShapeFilterCallback ) );
pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN );
pBox->EndSelection();
delete pMenu;
}
break;
}
return 0;
}
IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl)
{
if( !mbDocImported || maLbDocs.GetSelectEntryPos() != 0 )
{
NavDocInfo* pInfo = GetDocInfo();
// if it is the active window, we jump to the page
if( pInfo && pInfo->IsActive() )
{
OUString aStr( maTlbObjects.GetSelectEntry() );
if( !aStr.isEmpty() )
{
SfxStringItem aItem( SID_NAVIGATOR_OBJECT, aStr );
mpBindings->GetDispatcher()->Execute(
SID_NAVIGATOR_OBJECT, SfxCallMode::SLOT | SfxCallMode::RECORD, &aItem, 0L );
//set sign variable
maTlbObjects.MarkCurEntry(aStr);
// moved here from SetGetFocusHdl. Reset the
// focus only if something has been selected in the
// document.
SfxViewShell* pCurSh = SfxViewShell::Current();
if ( pCurSh )
{
vcl::Window* pShellWnd = pCurSh->GetWindow();
if ( pShellWnd )
pShellWnd->GrabFocus();
}
}
}
}
return 0L;
}
IMPL_LINK_NOARG(SdNavigatorWin, SelectDocumentHdl)
{
OUString aStrLb = maLbDocs.GetSelectEntry();
long nPos = maLbDocs.GetSelectEntryPos();
bool bFound = false;
::sd::DrawDocShell* pDocShell = NULL;
NavDocInfo* pInfo = GetDocInfo();
// is it a dragged object?
if( mbDocImported && nPos == 0 )
{
// construct document in TLB
InsertFile( aStrLb );
}
else if (pInfo)
{
pDocShell = pInfo->mpDocShell;
bFound = true;
}
if( bFound )
{
SdDrawDocument* pDoc = pDocShell->GetDoc();
if( !maTlbObjects.IsEqualToDoc( pDoc ) )
{
SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can...
::sd::DrawDocShell* pNCDocShell = pNonConstDoc->GetDocSh();
OUString aDocName = pNCDocShell->GetMedium()->GetName();
maTlbObjects.Clear();
maTlbObjects.Fill( pDoc, false, aDocName ); // only normal pages
}
}
// check if link or url is possible
if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
{
meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
SetDragImage();
}
return 0L;
}
/**
* Set DrageType and set image accordingly to it.
* If the handler is called with NULL, the default (URL) is set.
*/
IMPL_LINK( SdNavigatorWin, MenuSelectHdl, Menu *, pMenu )
{
sal_uInt16 nMenuId;
if( pMenu )
nMenuId = pMenu->GetCurItemId();
else
nMenuId = NAVIGATOR_DRAGTYPE_URL;
if( nMenuId != USHRT_MAX ) // Necessary ?
{
NavigatorDragType eDT = (NavigatorDragType) nMenuId;
if( meDragType != eDT )
{
meDragType = eDT;
SetDragImage();
if( meDragType == NAVIGATOR_DRAGTYPE_URL )
{
// patch, prevents endless loop
if( maTlbObjects.GetSelectionCount() > 1 )
maTlbObjects.SelectAll( false );
maTlbObjects.SetSelectionMode( SINGLE_SELECTION );
}
else
maTlbObjects.SetSelectionMode( MULTIPLE_SELECTION );
}
}
return 0;
}
IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, Menu *, pMenu )
{
if (pMenu != NULL)
{
bool bShowAllShapes (maTlbObjects.GetShowAllShapes());
sal_uInt16 nMenuId (pMenu->GetCurItemId());
switch (nMenuId)
{
case nShowNamedShapesFilter:
bShowAllShapes = false;
break;
case nShowAllShapesFilter:
bShowAllShapes = true;
break;
default:
OSL_FAIL(
"SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
break;
}
maTlbObjects.SetShowAllShapes(bShowAllShapes, true);
// Remember the selection in the FrameView.
NavDocInfo* pInfo = GetDocInfo();
if (pInfo != NULL)
{
::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
if (pDocShell != NULL)
{
::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
if (pViewShell != NULL)
{
::sd::FrameView* pFrameView = pViewShell->GetFrameView();
if (pFrameView != NULL)
{
pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
}
}
}
}
}
return 0;
}
void SdNavigatorWin::Resize()
{
Size aWinSize( GetOutputSizePixel() );
if( aWinSize.Height() >= maMinSize.Height() )
//aWinSize.Width() >= maMinSize.Width() )
{
Size aDiffSize;
aDiffSize.Width() = aWinSize.Width() - maSize.Width();
aDiffSize.Height() = aWinSize.Height() - maSize.Height();
// change size of Toolbox
Size aObjSize( maToolbox.GetOutputSizePixel() );
aObjSize.Width() += aDiffSize.Width();
maToolbox.SetOutputSizePixel( aObjSize );
// change size of TreeLB
aObjSize = maTlbObjects.GetSizePixel();
aObjSize.Width() += aDiffSize.Width();
aObjSize.Height() = maLbDocs.GetPosPixel().Y() + aDiffSize.Height() -
maTlbObjects.GetPosPixel().Y() - 4;
maTlbObjects.SetSizePixel( aObjSize );
Point aPt( 0, aDiffSize.Height() );
// move other controls (DocumentLB)
maLbDocs.Hide();
aObjSize = maLbDocs.GetOutputSizePixel();
aObjSize.Width() += aDiffSize.Width();
maLbDocs.SetPosPixel( maLbDocs.GetPosPixel() + aPt );
maLbDocs.SetOutputSizePixel( aObjSize );
maLbDocs.Show();
maSize = aWinSize;
}
Window::Resize();
}
bool SdNavigatorWin::InsertFile(const OUString& rFileName)
{
INetURLObject aURL( rFileName );
if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
{
OUString aURLStr;
::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName, aURLStr );
aURL = INetURLObject( aURLStr );
}
// get adjusted FileName
OUString aFileName( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
if (aFileName.isEmpty())
{
// show actual document again
maDropFileName = aFileName;
}
else
{
// show dragged-in document
const SfxFilter* pFilter = NULL;
ErrCode nErr = 0;
if (aFileName != maDropFileName)
{
SfxMedium aMed(aFileName, (StreamMode::READ | StreamMode::SHARE_DENYNONE));
SfxFilterMatcher aMatch( OUString("simpress") );
aMed.UseInteractionHandler( true );
nErr = aMatch.GuessFilter(aMed, &pFilter);
}
if ((pFilter && !nErr) || aFileName == maDropFileName)
{
// The medium may be opened with READ/WRITE. Therefore, we first
// check if it contains a Storage.
SfxMedium* pMedium = new SfxMedium( aFileName,
StreamMode::READ | StreamMode::NOCREATE);
if (pMedium->IsStorage())
{
// Now depending on mode:
// maTlbObjects.SetSelectionMode(MULTIPLE_SELECTION);
// handover of ownership of pMedium;
SdDrawDocument* pDropDoc = maTlbObjects.GetBookmarkDoc(pMedium);
if (pDropDoc)
{
maTlbObjects.Clear();
maDropFileName = aFileName;
if( !maTlbObjects.IsEqualToDoc( pDropDoc ) )
{
// only normal pages
maTlbObjects.Fill(pDropDoc, false, maDropFileName);
RefreshDocumentLB( &maDropFileName );
}
}
}
else
{
delete pMedium;
return false;
}
}
else
{
return false;
}
}
return true;
}
void SdNavigatorWin::RefreshDocumentLB( const OUString* pDocName )
{
sal_Int32 nPos = 0;
if( pDocName )
{
if( mbDocImported )
maLbDocs.RemoveEntry( 0 );
maLbDocs.InsertEntry( *pDocName, 0 );
mbDocImported = true;
}
else
{
nPos = maLbDocs.GetSelectEntryPos();
if( nPos == LISTBOX_ENTRY_NOTFOUND )
nPos = 0;
OUString aStr;
if( mbDocImported )
aStr = maLbDocs.GetEntry( 0 );
maLbDocs.Clear();
// delete list of DocInfos
maDocList.clear();
if( mbDocImported )
maLbDocs.InsertEntry( aStr, 0 );
::sd::DrawDocShell* pCurrentDocShell =
PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() );
SfxObjectShell* pSfxDocShell = SfxObjectShell::GetFirst(0, false);
while( pSfxDocShell )
{
::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, pSfxDocShell );
if( pDocShell && !pDocShell->IsInDestruction() && ( pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) )
{
NavDocInfo aInfo ;
aInfo.mpDocShell = pDocShell;
SfxMedium *pMedium = pDocShell->GetMedium();
aStr = pMedium ? pMedium->GetName() : OUString();
if( !aStr.isEmpty() )
aInfo.SetName();
else
aInfo.SetName( false );
// at the moment, we use the name of the shell again (i.e.
// without path) since Koose thinks it is an error if the path
// is shown in url notation!
aStr = pDocShell->GetName();
maLbDocs.InsertEntry( aStr, LISTBOX_APPEND );
if( pDocShell == pCurrentDocShell )
aInfo.SetActive();
else
aInfo.SetActive( false );
maDocList.push_back( aInfo );
}
pSfxDocShell = SfxObjectShell::GetNext( *pSfxDocShell, 0, false );
}
}
maLbDocs.SelectEntryPos( nPos );
}
sal_uInt16 SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT, bool bImage )
{
switch( eDT )
{
case NAVIGATOR_DRAGTYPE_NONE:
return( bImage ? 0 : STR_NONE );
case NAVIGATOR_DRAGTYPE_URL:
return( bImage ? TBI_HYPERLINK : STR_DRAGTYPE_URL );
case NAVIGATOR_DRAGTYPE_EMBEDDED:
return( bImage ? TBI_EMBEDDED : STR_DRAGTYPE_EMBEDDED );
case NAVIGATOR_DRAGTYPE_LINK:
return( bImage ? TBI_LINK : STR_DRAGTYPE_LINK );
default: OSL_FAIL( "No resource for DragType available!" );
}
return 0;
}
NavDocInfo* SdNavigatorWin::GetDocInfo()
{
sal_uInt32 nPos = maLbDocs.GetSelectEntryPos();
if( mbDocImported )
{
if( nPos == 0 )
{
return NULL;
}
nPos--;
}
return nPos < maDocList.size() ? &(maDocList[ nPos ]) : NULL;
}
/**
* PreNotify
*/
bool SdNavigatorWin::Notify(NotifyEvent& rNEvt)
{
const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
bool nOK = false;
if( pKEvt )
{
if( KEY_ESCAPE == pKEvt->GetKeyCode().GetCode() )
{
if( SdPageObjsTLB::IsInDrag() )
{
// during drag'n'drop we just stop the drag but do not close the navigator
nOK = true;
}
else
{
::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame());
if( pBase )
{
sd::SlideShow::Stop( *pBase );
// Stopping the slide show may result in a synchronous
// deletion of the navigator window. Calling the
// parents Notify after this is unsafe. Therefore we
// return now.
return true;
}
}
}
}
if( !nOK )
nOK = Window::Notify( rNEvt );
return nOK;
}
/**
* catch ESCAPE in order to end show
*/
void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt )
{
long nOK = sal_False;
if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
{
if( SdPageObjsTLB::IsInDrag() )
{
// during drag'n'drop we just stop the drag but do not close the navigator
nOK = sal_True;
}
else
{
::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame());
if(pBase)
{
::sd::SlideShow::Stop( *pBase );
}
}
}
if (!nOK)
{
Window::KeyInput(rKEvt);
}
}
void SdNavigatorWin::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
ApplyImageList();
Window::DataChanged( rDCEvt );
}
void SdNavigatorWin::SetDragImage()
{
maToolbox.SetItemImage( TBI_DRAGTYPE, maToolbox.GetImageList().GetImage( GetDragTypeSdResId( meDragType, true ) ) );
}
void SdNavigatorWin::ApplyImageList()
{
maToolbox.SetImageList( maImageList );
maToolbox.SetItemImage(TBI_SHAPE_FILTER, Image(BitmapEx(SdResId(BMP_GRAPHIC))));
SetDragImage();
}
/**
* ControllerItem for Navigator
*/
SdNavigatorControllerItem::SdNavigatorControllerItem(
sal_uInt16 _nId,
SdNavigatorWin* pNavWin,
SfxBindings* _pBindings,
const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest)
: SfxControllerItem( _nId, *_pBindings ),
pNavigatorWin( pNavWin ),
maUpdateRequest(rUpdateRequest)
{
}
void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId,
SfxItemState eState, const SfxPoolItem* pItem )
{
if( eState >= SfxItemState::DEFAULT && nSId == SID_NAVIGATOR_STATE )
{
const SfxUInt32Item* pStateItem = PTR_CAST( SfxUInt32Item, pItem );
DBG_ASSERT( pStateItem, "SfxUInt16Item expected");
sal_uInt32 nState = pStateItem->GetValue();
// pen
if( nState & NAVBTN_PEN_ENABLED &&
!pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) )
pNavigatorWin->maToolbox.EnableItem( TBI_PEN );
if( nState & NAVBTN_PEN_DISABLED &&
pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) )
pNavigatorWin->maToolbox.EnableItem( TBI_PEN, false );
if( nState & NAVBTN_PEN_CHECKED &&
!pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) )
pNavigatorWin->maToolbox.CheckItem( TBI_PEN );
if( nState & NAVBTN_PEN_UNCHECKED &&
pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) )
pNavigatorWin->maToolbox.CheckItem( TBI_PEN, false );
// only if doc in LB is the active
NavDocInfo* pInfo = pNavigatorWin->GetDocInfo();
if( pInfo && pInfo->IsActive() )
{
// First
if( nState & NAVBTN_FIRST_ENABLED &&
!pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) )
pNavigatorWin->maToolbox.EnableItem( TBI_FIRST );
if( nState & NAVBTN_FIRST_DISABLED &&
pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) )
pNavigatorWin->maToolbox.EnableItem( TBI_FIRST, false );
// Prev
if( nState & NAVBTN_PREV_ENABLED &&
!pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) )
pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS );
if( nState & NAVBTN_PREV_DISABLED &&
pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) )
pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS, false );
// Last
if( nState & NAVBTN_LAST_ENABLED &&
!pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) )
pNavigatorWin->maToolbox.EnableItem( TBI_LAST );
if( nState & NAVBTN_LAST_DISABLED &&
pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) )
pNavigatorWin->maToolbox.EnableItem( TBI_LAST, false );
// Next
if( nState & NAVBTN_NEXT_ENABLED &&
!pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) )
pNavigatorWin->maToolbox.EnableItem( TBI_NEXT );
if( nState & NAVBTN_NEXT_DISABLED &&
pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) )
pNavigatorWin->maToolbox.EnableItem( TBI_NEXT, false );
if( nState & NAVTLB_UPDATE )
{
// InitTlb; is initiated by Slot
if (maUpdateRequest)
maUpdateRequest();
}
}
}
}
/**
* ControllerItem for Navigator to show page in TreeLB
*/
SdPageNameControllerItem::SdPageNameControllerItem(
sal_uInt16 _nId,
SdNavigatorWin* pNavWin,
SfxBindings* _pBindings,
const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest)
: SfxControllerItem( _nId, *_pBindings ),
pNavigatorWin( pNavWin ),
maUpdateRequest(rUpdateRequest)
{
}
void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId,
SfxItemState eState, const SfxPoolItem* pItem )
{
if( eState >= SfxItemState::DEFAULT && nSId == SID_NAVIGATOR_PAGENAME )
{
// only if doc in LB is the active
NavDocInfo* pInfo = pNavigatorWin->GetDocInfo();
if( pInfo && pInfo->IsActive() )
{
const SfxStringItem* pStateItem = PTR_CAST( SfxStringItem, pItem );
DBG_ASSERT( pStateItem, "SfxStringItem expected");
OUString aPageName = pStateItem->GetValue();
if( !pNavigatorWin->maTlbObjects.HasSelectedChildren( aPageName ) )
{
if( pNavigatorWin->maTlbObjects.GetSelectionMode() == MULTIPLE_SELECTION )
{
// because otherwise it is always additional select
pNavigatorWin->maTlbObjects.SelectAll( false );
}
pNavigatorWin->maTlbObjects.SelectEntry( aPageName );
}
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|