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
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
|
/*************************************************************************
*
* $RCSfile: SdUnoDrawView.cxx,v $
*
* $Revision: 1.24 $
*
* last change: $Author: kz $ $Date: 2005-03-01 17:34:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (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.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "SdUnoDrawView.hxx"
#include <vector>
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _COM_SUN_STAR_VIEW_DOCUMENTZOOMTYPE_HPP_
#include <com/sun/star/view/DocumentZoomType.hpp>
#endif
#ifndef _SVX_UNOSHAPE_HXX
#include <svx/unoshape.hxx>
#endif
#include <svx/svdobj.hxx>
#include <svx/svdpagv.hxx>
#include <svx/unoshcol.hxx>
#ifndef _SVX_ZOOMITEM_HXX
#include <svx/zoomitem.hxx>
#endif
#ifndef _SFX_BINDINGS_HXX
#include <sfx2/bindings.hxx>
#endif
#ifndef _SFXDISPATCH_HXX
#include <sfx2/dispatch.hxx>
#endif
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
#include <toolkit/helper/vclunohelper.hxx>
#endif
#include <sfx2/viewfrm.hxx>
#ifndef SD_WINDOW_HXX
#include "Window.hxx"
#endif
#include "unohelp.hxx"
#include "unopage.hxx"
#include "unomodel.hxx"
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_DRAW_VIEW_SHELL_HXX
#include "DrawViewShell.hxx"
#endif
#include "drawdoc.hxx"
#ifndef SD_DRAW_DOC_SHELL_HXX
#include "DrawDocShell.hxx"
#endif
#ifndef SD_GRAPHIC_VIEW_SHELL_HXX
#include "GraphicViewShell.hxx"
#endif
#ifndef SD_PRESENTATION_VIEW_SHELL_HXX
#include "PresentationViewShell.hxx"
#endif
#include "sdpage.hxx"
#include "unolayer.hxx"
#ifndef SD_DRAW_CONTROLLER_HXX
#include "DrawController.hxx"
#endif
#ifndef SD_VIEW_SHELL_BASE_HXX
#include "ViewShellBase.hxx"
#endif
using namespace ::std;
using namespace ::rtl;
using namespace ::vos;
using namespace ::cppu;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace sd {
SdUnoDrawView::SdUnoDrawView(
ViewShellBase& rBase,
ViewShell& rViewShell,
View& rView) throw()
: DrawController (rBase, rViewShell, rView),
mbOldMasterPageMode(sal_False),
mbOldLayerMode(sal_False),
mpCurrentPage(NULL)
{
}
SdUnoDrawView::~SdUnoDrawView() throw()
{
}
DrawViewShell* SdUnoDrawView::GetDrawViewShell (void) const
{
ThrowIfDisposed();
return static_cast<DrawViewShell*>(mpViewShell);
}
sal_Bool SdUnoDrawView::getMasterPageMode(void) const throw()
{
ThrowIfDisposed();
if (mpViewShell != NULL)
return GetDrawViewShell()->GetEditMode() == EM_MASTERPAGE;
else
return sal_False;
}
void SdUnoDrawView::setMasterPageMode (sal_Bool bMasterPageMode) throw()
{
ThrowIfDisposed();
if (mpViewShell!=NULL
&&(GetDrawViewShell()->GetEditMode() == EM_MASTERPAGE) != bMasterPageMode)
{
GetDrawViewShell()->ChangeEditMode (
bMasterPageMode ? EM_MASTERPAGE : EM_PAGE,
GetDrawViewShell()->IsLayerModeActive());
}
}
sal_Bool SdUnoDrawView::getLayerMode(void) const throw()
{
ThrowIfDisposed();
if (mpViewShell != NULL)
return GetDrawViewShell()->IsLayerModeActive();
else
return sal_False;
}
void SdUnoDrawView::setLayerMode (sal_Bool bLayerMode) throw()
{
ThrowIfDisposed();
if (mpViewShell!=NULL
&& GetDrawViewShell()->IsLayerModeActive() != (bLayerMode==sal_True))
{
GetDrawViewShell()->ChangeEditMode (
GetDrawViewShell()->GetEditMode(),
bLayerMode);
}
}
Reference<drawing::XLayer> SdUnoDrawView::getActiveLayer (void) throw ()
{
ThrowIfDisposed();
OGuard aGuard( Application::GetSolarMutex() );
Reference<drawing::XLayer> xCurrentLayer;
do
{
// Retrieve the layer manager from the model.
SdXImpressDocument* pModel = GetModel();
if (pModel == NULL)
break;
SdDrawDocument* pSdModel = pModel->GetDoc();
if (pSdModel == NULL)
break;
if (mpView == NULL)
break;
// From the model get the current SdrLayer object via the layer admin.
SdrLayerAdmin& rLayerAdmin = pSdModel->GetLayerAdmin ();
SdrLayer* pLayer = rLayerAdmin.GetLayer (mpView->GetActiveLayer(), TRUE);
if (pLayer == NULL)
break;
// Get the corresponding XLayer object from the implementation
// object of the layer manager.
Reference<drawing::XLayerManager> xManager (pModel->getLayerManager(), uno::UNO_QUERY);
SdLayerManager* pManager = SdLayerManager::getImplementation (xManager);
if (pManager != NULL)
xCurrentLayer = pManager->GetLayer (pLayer);
}
while (false);
return xCurrentLayer;
}
void SdUnoDrawView::setActiveLayer (const Reference<drawing::XLayer>& rxLayer) throw ()
{
ThrowIfDisposed();
OGuard aGuard( Application::GetSolarMutex() );
do
{
// Get the SdrLayer object corresponding to the given reference.
if ( ! rxLayer.is())
break;
SdLayer* pLayer = SdLayer::getImplementation (rxLayer);
if (pLayer == NULL)
break;
SdrLayer* pSdrLayer = pLayer->GetSdrLayer();
if (pSdrLayer == NULL)
break;
if (mpView == NULL)
break;
// Set the new active layer and make the change visible.
mpView->SetActiveLayer (pSdrLayer->GetName());
GetDrawViewShell()->ResetActualLayer ();
}
while (false);
}
void SdUnoDrawView::FireChangeEditMode (bool bMasterPageMode) throw()
{
if( bMasterPageMode != mbOldMasterPageMode )
{
Any aNewValue;
aNewValue <<= (sal_Bool)bMasterPageMode;
Any aOldValue;
aOldValue <<= (sal_Bool)mbOldMasterPageMode;
FirePropertyChange(PROPERTY_MASTERPAGEMODE, aNewValue, aOldValue);
mbOldMasterPageMode = bMasterPageMode;
}
}
void SdUnoDrawView::FireChangeLayerMode (bool bLayerMode) throw()
{
if( bLayerMode != mbOldLayerMode )
{
Any aNewValue;
aNewValue <<= (sal_Bool)bLayerMode;
Any aOldValue;
aOldValue <<= (sal_Bool)mbOldLayerMode;
FirePropertyChange (PROPERTY_LAYERMODE, aNewValue, aOldValue);
mbOldLayerMode = bLayerMode;
}
}
void SdUnoDrawView::FireSwitchCurrentPage (SdPage* pCurrentPage) throw()
{
if( pCurrentPage != mpCurrentPage )
{
Reference< drawing::XDrawPage > xNewPage( pCurrentPage->getUnoPage(), UNO_QUERY );
Any aNewValue( makeAny( xNewPage ) );
Any aOldValue;
if( mpCurrentPage )
{
Reference< drawing::XDrawPage > xOldPage( mpCurrentPage->getUnoPage(), UNO_QUERY );
aOldValue <<= xOldPage;
}
FirePropertyChange (PROPERTY_CURRENTPAGE, aNewValue, aOldValue);
mpCurrentPage = pCurrentPage;
}
}
// XTypeProvider
IMPLEMENT_GET_IMPLEMENTATION_ID(SdUnoDrawView);
// XServiceInfo
OUString SAL_CALL SdUnoDrawView::getImplementationName (void)
throw(RuntimeException)
{
ThrowIfDisposed();
return OUString(RTL_CONSTASCII_USTRINGPARAM("SdUnoDrawView"));
}
static sal_Char pImplSdUnoDrawViewService[sizeof("com.sun.star.drawing.DrawingDocumentDrawView")] = "com.sun.star.drawing.DrawingDocumentDrawView";
static sal_Char pImplSdUnoSlideViewService[sizeof("com.sun.star.presentation.SlidesView")] = "com.sun.star.presentation.SlidesView";
static sal_Char pImplSdUnoNotesViewService[sizeof("com.sun.star.presentation.NotesView")] = "com.sun.star.presentation.NotesView";
static sal_Char pImplSdUnoHandoutViewService[sizeof("com.sun.star.presentation.HandoutView")] = "com.sun.star.presentation.HandoutView";
sal_Bool SAL_CALL SdUnoDrawView::supportsService( const OUString& ServiceName )
throw(RuntimeException)
{
ThrowIfDisposed();
sal_Bool bServiceIsSupported = sal_False;
switch (meViewShellType)
{
case ViewShell::ST_NOTES:
bServiceIsSupported = ServiceName.equalsAscii(pImplSdUnoNotesViewService)
|| ServiceName.equalsAscii( pImplSdUnoDrawViewService );
break;
case ViewShell::ST_HANDOUT:
bServiceIsSupported = ServiceName.equalsAscii(pImplSdUnoHandoutViewService )
|| ServiceName.equalsAscii( pImplSdUnoDrawViewService );
break;
case ViewShell::ST_IMPRESS:
case ViewShell::ST_DRAW:
bServiceIsSupported = ServiceName.equalsAscii(pImplSdUnoDrawViewService );
break;
default:
// Shell type is not handled by this object.
bServiceIsSupported = sal_False;
}
return bServiceIsSupported;
}
Sequence<OUString> SAL_CALL SdUnoDrawView::getSupportedServiceNames (void)
throw(RuntimeException)
{
ThrowIfDisposed();
Sequence<OUString> aServices (
(meViewShellType == ViewShell::ST_NOTES)
|| (meViewShellType == ViewShell::ST_HANDOUT)
|| (meViewShellType == ViewShell::ST_PRESENTATION)
? 2 : 1);
int nIndex = 0;
switch (meViewShellType)
{
case ViewShell::ST_NOTES:
aServices[nIndex++] = OUString(
RTL_CONSTASCII_USTRINGPARAM(pImplSdUnoNotesViewService));
break;
case ViewShell::ST_HANDOUT:
aServices[nIndex++] = OUString(
RTL_CONSTASCII_USTRINGPARAM(pImplSdUnoHandoutViewService));
break;
}
switch (meViewShellType)
{
case ViewShell::ST_NOTES:
case ViewShell::ST_HANDOUT:
case ViewShell::ST_IMPRESS:
case ViewShell::ST_DRAW:
aServices[nIndex] = OUString(
RTL_CONSTASCII_USTRINGPARAM(pImplSdUnoDrawViewService));
break;
}
return aServices;
}
// XSelectionSupplier
sal_Bool SAL_CALL SdUnoDrawView::select( const Any& aSelection )
throw(lang::IllegalArgumentException, RuntimeException)
{
ThrowIfDisposed();
OGuard aGuard( Application::GetSolarMutex() );
bool bOk = true;
if (mpViewShell != NULL)
{
vector<SdrObject*> aObjects;
SdrPage* pSdrPage = NULL;
Reference< drawing::XShape > xShape;
aSelection >>= xShape;
if(xShape.is())
{
SvxShape* pShape = SvxShape::getImplementation( xShape );
if( pShape && (pShape->GetSdrObject() != NULL) )
{
SdrObject* pObj = pShape->GetSdrObject();
pSdrPage = pObj->GetPage();
aObjects.push_back( pObj );
}
else
{
bOk = false;
}
}
else
{
Reference< drawing::XShapes > xShapes;
aSelection >>= xShapes;
if( xShapes.is() )
{
const sal_uInt32 nCount = xShapes->getCount();
for( sal_uInt32 i = 0; i < nCount; i++ )
{
xShapes->getByIndex(i) >>= xShape;
if( xShape.is() )
{
SvxShape* pShape = SvxShape::getImplementation(xShape);
if( (pShape == NULL) || (pShape->GetSdrObject() == NULL) )
{
bOk = false;
break;
}
SdrObject* pObj = pShape->GetSdrObject();
if( pSdrPage == NULL )
{
pSdrPage = pObj->GetPage();
}
else if( pSdrPage != pObj->GetPage() )
{
bOk = false;
break;
}
aObjects.push_back( pObj );
}
}
}
}
if( bOk )
{
if( pSdrPage )
{
setMasterPageMode( pSdrPage->IsMasterPage() );
GetDrawViewShell()->SwitchPage( (pSdrPage->GetPageNum() - 1) >> 1 );
GetDrawViewShell()->WriteFrameViewData();
}
SdrPageView *pPV = mpView->GetPageViewPvNum(0);
if(pPV)
{
// first deselect all
mpView->UnmarkAllObj( pPV );
vector<SdrObject*>::iterator aIter( aObjects.begin() );
const vector<SdrObject*>::iterator aEnd( aObjects.end() );
while( aIter != aEnd )
{
SdrObject* pObj = (*aIter++);
mpView->MarkObj( pObj, pPV );
}
}
else
{
bOk = false;
}
}
}
else
bOk = false;
return bOk;
}
//----------------------------------------------------------------------
Any SAL_CALL SdUnoDrawView::getSelection()
throw(RuntimeException)
{
ThrowIfDisposed();
OGuard aGuard( Application::GetSolarMutex() );
Any aAny;
if (mpView != NULL)
{
if( mpView->IsTextEdit() )
mpView->getTextSelection( aAny );
if( !aAny.hasValue() )
{
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
sal_uInt32 nCount = rMarkList.GetMarkCount();
if( nCount )
{
Reference< drawing::XShapes > xShapes( SvxShapeCollection_NewInstance(), UNO_QUERY );
for( sal_uInt32 nNum = 0; nNum < nCount; nNum++)
{
SdrMark *pMark = rMarkList.GetMark(nNum);
if(pMark==NULL)
continue;
SdrObject *pObj = pMark->GetObj();
if(pObj==NULL || pObj->GetPage() == NULL)
continue;
Reference< drawing::XDrawPage > xPage( pObj->GetPage()->getUnoPage(), UNO_QUERY);
if(!xPage.is())
continue;
SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
if(pDrawPage==NULL)
continue;
Reference< drawing::XShape > xShape( pObj->getUnoShape(), UNO_QUERY );
if(xShape.is())
xShapes->add(xShape);
}
aAny <<= xShapes;
}
}
}
return aAny;
/*
SdXImpressDocument* pModel = GetModel();
Reference< drawing::XShapes > xShapes( SvxShapeCollection_NewInstance(), UNO_QUERY );
DBG_ASSERT (&mrView != NULL,
"view is NULL in SdUnoDrawView::getSelection()");
const SdrMarkList& rMarkList = mrView.GetMarkedObjectList();
sal_uInt32 nCount = rMarkList.GetMarkCount();
for( sal_uInt32 nNum = 0; nNum < nCount; nNum++)
{
SdrMark *pMark = rMarkList.GetMark(nNum);
if(pMark==NULL)
continue;
SdrObject *pObj = pMark->GetObj();
if(pObj==NULL || pObj->GetPage() == NULL)
continue;
Reference< drawing::XDrawPage > xPage( pObj->GetPage()->getUnoPage(), UNO_QUERY);
if(!xPage.is())
continue;
SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
if(pDrawPage==NULL)
continue;
Reference< drawing::XShape > xShape( pObj->getUnoShape(), UNO_QUERY );
if(xShape.is())
xShapes->add(xShape);
}
Any aAny;
if( 0 != xShapes->getCount() )
aAny <<= xShapes;
return aAny;
*/
}
//----------------------------------------------------------------------
//------ The Properties of this implementation -------------------------
//----------------------------------------------------------------------
/**
* All Properties of this implementation. Must be sorted by name.
*/
void SdUnoDrawView::FillPropertyTable (
::std::vector<beans::Property>& rProperties)
{
DrawController::FillPropertyTable (rProperties);
static const beans::Property aBasicProps[
PROPERTY__END - PROPERTY__BEGIN] = {
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("CurrentPage") ), PROPERTY_CURRENTPAGE, ::getCppuType((const Reference< drawing::XDrawPage > *)0), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsLayerMode") ), PROPERTY_LAYERMODE, ::getCppuBooleanType(), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("IsMasterPageMode") ), PROPERTY_MASTERPAGEMODE,::getCppuBooleanType(), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ActiveLayer") ), PROPERTY_ACTIVE_LAYER, ::getCppuBooleanType(), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomValue") ), PROPERTY_ZOOMVALUE, ::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ZoomType") ), PROPERTY_ZOOMTYPE, ::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::BOUND ),
beans::Property( OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOffset") ), PROPERTY_VIEWOFFSET, ::getCppuType((const ::com::sun::star::awt::Point*)0), beans::PropertyAttribute::BOUND ),
};
int n = PROPERTY__END - PROPERTY__BEGIN;
for (int i=0; i<n; i++)
rProperties.push_back (aBasicProps[i]);
}
//----------------------------------------------------------------------
//------ XPropertySet & OPropertySetHelper -----------------------------
//----------------------------------------------------------------------
// Return sal_True, value change
sal_Bool SdUnoDrawView::convertFastPropertyValue
(
Any & rConvertedValue,
Any & rOldValue,
sal_Int32 nHandle,
const Any& rValue
) throw ( com::sun::star::lang::IllegalArgumentException)
{
sal_Bool bResult = sal_False;
OGuard aGuard( Application::GetSolarMutex() );
switch( nHandle )
{
case PROPERTY_CURRENTPAGE:
{
Reference< drawing::XDrawPage > xOldPage( getCurrentPage() );
Reference< drawing::XDrawPage > xNewPage;
convertPropertyValue( xNewPage, rValue );
if( xOldPage != xNewPage )
{
rConvertedValue <<= xNewPage;
rOldValue <<= xOldPage;
bResult = sal_True;
}
}
break;
case PROPERTY_MASTERPAGEMODE:
{
sal_Bool bOldValue = getMasterPageMode();
sal_Bool b;
convertPropertyValue( b , rValue );
if( b != bOldValue )
{
rConvertedValue.setValue( &b , ::getCppuBooleanType() );
rOldValue.setValue( & bOldValue , ::getCppuBooleanType() );
bResult = sal_True;
}
}
break;
case PROPERTY_LAYERMODE:
{
sal_Bool bOldValue = getLayerMode();
sal_Bool b;
convertPropertyValue( b , rValue );
if( b != bOldValue )
{
rConvertedValue.setValue( &b , ::getCppuBooleanType() );
rOldValue.setValue( & bOldValue , ::getCppuBooleanType() );
bResult = sal_True;
}
}
break;
case PROPERTY_ACTIVE_LAYER:
{
Reference<drawing::XLayer> xOldLayer (getActiveLayer());
Reference<drawing::XLayer> xNewLayer;
convertPropertyValue (xNewLayer, rValue);
if (xOldLayer != xNewLayer)
{
rConvertedValue <<= xNewLayer;
rOldValue <<= xOldLayer;
bResult = sal_True;
}
}
break;
case PROPERTY_ZOOMVALUE:
{
sal_Int16 nOldZoom = GetZoom();
sal_Int16 nNewZoom;
convertPropertyValue( nNewZoom, rValue );
if( nNewZoom != nOldZoom )
{
rConvertedValue <<= nNewZoom;
rOldValue <<= nOldZoom;
bResult = sal_True;
}
}
break;
case PROPERTY_ZOOMTYPE:
{
sal_Int16 nOldType = com::sun::star::view::DocumentZoomType::BY_VALUE;
sal_Int16 nNewType;
convertPropertyValue( nNewType, rValue );
if( nNewType != nOldType )
{
rConvertedValue <<= nNewType;
rOldValue <<= nOldType;
bResult = sal_True;
}
}
break;
case PROPERTY_VIEWOFFSET:
{
awt::Point aOld( GetViewOffset() );
awt::Point aNew;
convertPropertyValue( aNew, rValue );
if( (aOld.X != aNew.X) && (aOld.Y != aNew.Y) )
{
rConvertedValue <<= aNew;
rOldValue <<= aOld;
bResult = sal_True;
}
}
break;
default:
bResult = DrawController::convertFastPropertyValue
(rConvertedValue, rOldValue, nHandle, rValue);
break;
}
return bResult;
}
//----------------------------------------------------------------------
/**
* only set the value.
*/
void SdUnoDrawView::setFastPropertyValue_NoBroadcast
(
sal_Int32 nHandle,
const Any& rValue
) throw ( com::sun::star::uno::Exception)
{
OGuard aGuard( Application::GetSolarMutex() );
switch( nHandle )
{
case PROPERTY_CURRENTPAGE:
{
Reference< drawing::XDrawPage > xPage;
rValue >>= xPage;
setCurrentPage( xPage );
}
break;
case PROPERTY_MASTERPAGEMODE:
{
sal_Bool bValue;
rValue >>= bValue;
setMasterPageMode( bValue );
}
break;
case PROPERTY_LAYERMODE:
{
sal_Bool bValue;
rValue >>= bValue;
setLayerMode( bValue );
}
case PROPERTY_ACTIVE_LAYER:
{
Reference<drawing::XLayer> xLayer;
rValue >>= xLayer;
setActiveLayer (xLayer);
}
break;
case PROPERTY_ZOOMVALUE:
{
sal_Int16 nZoom;
rValue >>= nZoom;
SetZoom( nZoom );
}
break;
case PROPERTY_ZOOMTYPE:
{
sal_Int16 nType;
rValue >>= nType;
SetZoomType( nType );
}
break;
case PROPERTY_VIEWOFFSET:
{
awt::Point aOffset;
rValue >>= aOffset;
SetViewOffset( aOffset );
}
break;
default:
DrawController::setFastPropertyValue_NoBroadcast (nHandle, rValue);
break;
}
}
//----------------------------------------------------------------------
void SdUnoDrawView::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const
{
OGuard aGuard( Application::GetSolarMutex() );
switch( nHandle )
{
case PROPERTY_CURRENTPAGE:
rRet <<= (const_cast<SdUnoDrawView*>(this))->getCurrentPage();
break;
case PROPERTY_MASTERPAGEMODE:
rRet <<= getMasterPageMode();
break;
case PROPERTY_LAYERMODE:
rRet <<= getLayerMode();
break;
case PROPERTY_ACTIVE_LAYER:
rRet <<= (const_cast<SdUnoDrawView*>(this))->getActiveLayer();
break;
case PROPERTY_ZOOMVALUE:
rRet <<= GetZoom();
break;
case PROPERTY_ZOOMTYPE:
rRet <<= (sal_Int16)com::sun::star::view::DocumentZoomType::BY_VALUE;
break;
case PROPERTY_VIEWOFFSET:
rRet <<= GetViewOffset();
break;
/* case PROPERTY_WORKAREA:
rRet <<= awt::Rectangle(
maLastVisArea.Left(),
maLastVisArea.Top(),
maLastVisArea.GetWidth(),
maLastVisArea.GetHeight());
break;
*/
default:
DrawController::getFastPropertyValue (rRet, nHandle);
}
}
// XDrawView
void SAL_CALL SdUnoDrawView::setCurrentPage (
const Reference< drawing::XDrawPage >& xPage )
throw(RuntimeException)
{
OGuard aGuard( Application::GetSolarMutex() );
DBG_ASSERT (mpView!=NULL, "View is NULL in SdUnoDrawView::setCurrentPage");
if (mpViewShell != NULL)
{
SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xPage );
SdrPage *pSdrPage = pDrawPage ? pDrawPage->GetSdrPage() : NULL;
if(pSdrPage)
{
// End editing of text. Otherwise the edited text object would
// still be visible on the new page.
GetDrawViewShell()->GetView()->EndTextEdit();
setMasterPageMode( pSdrPage->IsMasterPage() );
GetDrawViewShell()->SwitchPage( (pSdrPage->GetPageNum() - 1) >> 1 );
GetDrawViewShell()->WriteFrameViewData();
}
}
}
//----------------------------------------------------------------------
Reference< drawing::XDrawPage > SAL_CALL SdUnoDrawView::getCurrentPage()
throw(RuntimeException)
{
ThrowIfDisposed();
OGuard aGuard( Application::GetSolarMutex() );
Reference< drawing::XDrawPage > xPage;
DBG_ASSERT (mpView!=NULL, "View is NULL in SdUnoDrawView::getCurrentPage");
if (mpView != NULL)
{
SdXImpressDocument* pModel = GetModel();
SdrPageView *pPV = mpView->GetPageViewPvNum(0);
SdrPage* pPage = pPV ? pPV->GetPage() : NULL;
if(pPage)
xPage = Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
}
return xPage;
}
sal_Int16 SdUnoDrawView::GetZoom(void) const
{
if (mpViewShell!=NULL && GetDrawViewShell()->GetActiveWindow() )
{
return (sal_Int16)GetDrawViewShell()->GetActiveWindow()->GetZoom();
}
else
{
return 0;
}
}
void SdUnoDrawView::SetZoom( sal_Int16 nZoom )
{
SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, nZoom );
if (mpViewShell != NULL)
{
SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
if( pViewFrame )
{
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
if( pDispatcher )
{
pDispatcher->Execute(SID_ATTR_ZOOM,SFX_CALLMODE_SYNCHRON,&aZoomItem, 0L);
}
}
}
}
void SdUnoDrawView::SetViewOffset(const awt::Point& rWinPos )
{
DBG_ASSERT (mpViewShell != NULL, "ViewShell is NULL in SdUnoDrawView::SetViewOffset");
if (mpViewShell != NULL)
{
Point aWinPos( rWinPos.X, rWinPos.Y );
aWinPos += mpViewShell->GetViewOrigin();
mpViewShell->SetWinViewPos( aWinPos, true );
}
}
awt::Point SdUnoDrawView::GetViewOffset() const
{
Point aRet;
DBG_ASSERT (mpViewShell!=NULL, "ViewShell is NULL in SdUnoDrawView::GetViewOffset");
if (mpViewShell != NULL)
{
aRet = mpViewShell->GetWinViewPos();
aRet -= mpViewShell->GetViewOrigin();
}
return awt::Point( aRet.X(), aRet.Y() );
}
void SdUnoDrawView::SetZoomType ( sal_Int16 nType )
{
DBG_ASSERT (mpViewShell!= NULL, "ViewShell is NULL in SdUnoDrawView::SetZoomType");
if (mpViewShell != NULL)
{
SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
if( pViewFrame )
{
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
if( pDispatcher )
{
SvxZoomType eZoomType;
switch( nType )
{
case com::sun::star::view::DocumentZoomType::OPTIMAL:
eZoomType = SVX_ZOOM_OPTIMAL;
break;
case com::sun::star::view::DocumentZoomType::PAGE_WIDTH:
case com::sun::star::view::DocumentZoomType::PAGE_WIDTH_EXACT:
eZoomType = SVX_ZOOM_PAGEWIDTH;
break;
case com::sun::star::view::DocumentZoomType::ENTIRE_PAGE:
eZoomType = SVX_ZOOM_WHOLEPAGE;
break;
default:
return;
}
SvxZoomItem aZoomItem( eZoomType );
pDispatcher->Execute(SID_ATTR_ZOOM,SFX_CALLMODE_SYNCHRON,&aZoomItem, 0L);
}
}
}
}
} // end of namespace sd
|