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
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include "ViewShell.hxx"
#include "ViewShellHint.hxx"
#include "ViewShellImplementation.hxx"
#include "FactoryIds.hxx"
#include <svx/svxids.hrc>
#include <vcl/scrbar.hxx>
#include <svx/svdpagv.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/app.hxx>
#include <svx/ruler.hxx>
#include <editeng/outliner.hxx>
#include <svtools/ehdl.hxx>
#include <svx/svdoole2.hxx>
#include <svtools/sfxecode.hxx>
#include <svx/fmshell.hxx>
#include <rtl/ustrbuf.hxx>
#include <unotools/moduleoptions.hxx>
#include <svx/dialogs.hrc>
#include <sot/clsids.hxx>
#include "strings.hrc"
#include "app.hrc"
#include "unokywds.hxx"
#include "sdundogr.hxx"
#include "FrameView.hxx"
#include "undopage.hxx"
#include "sdresid.hxx"
#include "drawdoc.hxx"
#include "View.hxx"
#include "fupoor.hxx"
#include "Client.hxx"
#include "DrawDocShell.hxx"
#include "fusearch.hxx"
#include "slideshow.hxx"
#include "sdpage.hxx"
#include "DrawViewShell.hxx"
#include "ViewShellBase.hxx"
#include "Window.hxx"
#include <sfx2/viewfrm.hxx>
#include <svtools/soerr.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#ifdef _MSC_VER
#pragma optimize ( "", off )
#endif
using namespace com::sun::star;
const String aEmptyStr;
namespace sd {
/*************************************************************************
|*
|* Scrollbar-Update: Thumbpos und VisibleSize anpassen
|*
\************************************************************************/
void ViewShell::UpdateScrollBars()
{
if (mpHorizontalScrollBar.get() != NULL)
{
long nW = (long)(mpContentWindow->GetVisibleWidth() * 32000);
long nX = (long)(mpContentWindow->GetVisibleX() * 32000);
mpHorizontalScrollBar->SetVisibleSize(nW);
mpHorizontalScrollBar->SetThumbPos(nX);
nW = 32000 - nW;
long nLine = (long) (mpContentWindow->GetScrlLineWidth() * nW);
long nPage = (long) (mpContentWindow->GetScrlPageWidth() * nW);
mpHorizontalScrollBar->SetLineSize(nLine);
mpHorizontalScrollBar->SetPageSize(nPage);
}
if (mpVerticalScrollBar.get() != NULL)
{
long nH = (long)(mpContentWindow->GetVisibleHeight() * 32000);
long nY = (long)(mpContentWindow->GetVisibleY() * 32000);
if(IsPageFlipMode()) // ie in zoom mode where no panning
{
SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) / 2;
sal_uInt16 nTotalPages = GetDoc()->GetSdPageCount(pPage->GetPageKind());
mpVerticalScrollBar->SetRange(Range(0,256*nTotalPages));
mpVerticalScrollBar->SetVisibleSize(256);
mpVerticalScrollBar->SetThumbPos(256*nCurPage);
mpVerticalScrollBar->SetLineSize(256);
mpVerticalScrollBar->SetPageSize(256);
}
else
{
mpVerticalScrollBar->SetRange(Range(0,32000));
mpVerticalScrollBar->SetVisibleSize(nH);
mpVerticalScrollBar->SetThumbPos(nY);
nH = 32000 - nH;
long nLine = (long) (mpContentWindow->GetScrlLineHeight() * nH);
long nPage = (long) (mpContentWindow->GetScrlPageHeight() * nH);
mpVerticalScrollBar->SetLineSize(nLine);
mpVerticalScrollBar->SetPageSize(nPage);
}
}
if (mbHasRulers)
{
UpdateHRuler();
UpdateVRuler();
}
}
/*************************************************************************
|*
|* Handling fuer horizontale Scrollbars
|*
\************************************************************************/
IMPL_LINK_INLINE_START(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
{
return VirtHScrollHdl(pHScroll);
}
IMPL_LINK_INLINE_END(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
/*************************************************************************
|*
|* virtueller Scroll-Handler fuer horizontale Scrollbars
|*
\************************************************************************/
long ViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
{
long nDelta = pHScroll->GetDelta();
if (nDelta != 0)
{
double fX = (double) pHScroll->GetThumbPos() / pHScroll->GetRange().Len();
// alle Fenster der Spalte scrollen
::sd::View* pView = GetView();
OutlinerView* pOLV = NULL;
if (pView)
pOLV = pView->GetTextEditOutlinerView();
if (pOLV)
pOLV->HideCursor();
mpContentWindow->SetVisibleXY(fX, -1);
Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
aVisArea.SetPos(aVisAreaPos);
GetDocSh()->SetVisArea(aVisArea);
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
if (pOLV)
pOLV->ShowCursor();
if (mbHasRulers)
UpdateHRuler();
}
return 0;
}
/*************************************************************************
|*
|* Handling fuer vertikale Scrollbars
|*
\************************************************************************/
IMPL_LINK_INLINE_START(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
{
return VirtVScrollHdl(pVScroll);
}
IMPL_LINK_INLINE_END(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
/*************************************************************************
|*
|* Handling fuer vertikale Scrollbars
|*
\************************************************************************/
long ViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
{
if(IsPageFlipMode())
{
SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) >> 1;
sal_uInt16 nNewPage = (sal_uInt16)pVScroll->GetThumbPos()/256;
if( nCurPage != nNewPage )
static_cast<DrawViewShell*>(this)->SwitchPage(nNewPage);
}
else //panning mode
{
double fY = (double) pVScroll->GetThumbPos() / pVScroll->GetRange().Len();
::sd::View* pView = GetView();
OutlinerView* pOLV = NULL;
if (pView)
pOLV = pView->GetTextEditOutlinerView();
if (pOLV)
pOLV->HideCursor();
mpContentWindow->SetVisibleXY(-1, fY);
Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
aVisArea.SetPos(aVisAreaPos);
GetDocSh()->SetVisArea(aVisArea);
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
if (pOLV)
pOLV->ShowCursor();
if (mbHasRulers)
UpdateVRuler();
}
return 0;
}
SvxRuler* ViewShell::CreateHRuler(::sd::Window* , sal_Bool )
{
return NULL;
}
SvxRuler* ViewShell::CreateVRuler(::sd::Window* )
{
return NULL;
}
void ViewShell::UpdateHRuler()
{
}
void ViewShell::UpdateVRuler()
{
}
long ViewShell::GetHCtrlWidth()
{
return 0;
}
/*************************************************************************
|*
|* Eine bestimmte Anzahl von Zeilen scrollen (wird beim automatischen
|* Scrollen (Zeichen/Draggen) verwendet)
|*
\************************************************************************/
void ViewShell::ScrollLines(long nLinesX, long nLinesY)
{
if ( nLinesX )
{
nLinesX *= mpHorizontalScrollBar->GetLineSize();
}
if ( nLinesY )
{
nLinesY *= mpVerticalScrollBar->GetLineSize();
}
Scroll(nLinesX, nLinesY);
}
/*************************************************************************
|*
|* Window um nScrollX, nScrollY scrollen
|*
\************************************************************************/
void ViewShell::Scroll(long nScrollX, long nScrollY)
{
if (nScrollX)
{
long nNewThumb = mpHorizontalScrollBar->GetThumbPos() + nScrollX;
mpHorizontalScrollBar->SetThumbPos(nNewThumb);
}
if (nScrollY)
{
long nNewThumb = mpVerticalScrollBar->GetThumbPos() + nScrollY;
mpVerticalScrollBar->SetThumbPos(nNewThumb);
}
double fX = (double) mpHorizontalScrollBar->GetThumbPos() /
mpHorizontalScrollBar->GetRange().Len();
double fY = (double) mpVerticalScrollBar->GetThumbPos() /
mpVerticalScrollBar->GetRange().Len();
GetActiveWindow()->SetVisibleXY(fX, fY);
Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
aVisArea.SetPos(aVisAreaPos);
GetDocSh()->SetVisArea(aVisArea);
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
::sd::View* pView = GetView();
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
if (mbHasRulers)
{
UpdateHRuler();
UpdateVRuler();
}
}
/*************************************************************************
|*
|* Den Zoomfaktor fuer alle Split-Windows setzen
|*
\************************************************************************/
void ViewShell::SetZoom(long nZoom)
{
Fraction aUIScale(nZoom, 100);
aUIScale *= GetDoc()->GetUIScale();
if (mpHorizontalRuler.get() != NULL)
mpHorizontalRuler->SetZoom(aUIScale);
if (mpVerticalRuler.get() != NULL)
mpVerticalRuler->SetZoom(aUIScale);
if (mpContentWindow.get() != NULL)
{
mpContentWindow->SetZoomIntegral(nZoom);
// #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
// of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
// the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
// but does not solve the problem completely. Neet to ask PL.
mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
}
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
::sd::View* pView = GetView();
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
UpdateScrollBars();
}
/*************************************************************************
|*
|* Zoomrechteck fuer aktives Fenster einstellen und alle Split-Windows
|* auf den gleichen Zoomfaktor setzen
|*
\************************************************************************/
void ViewShell::SetZoomRect(const Rectangle& rZoomRect)
{
long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
Fraction aUIScale(nZoom, 100);
aUIScale *= GetDoc()->GetUIScale();
Point aPos = GetActiveWindow()->GetWinViewPos();
if (mpHorizontalRuler.get() != NULL)
mpHorizontalRuler->SetZoom(aUIScale);
if (mpVerticalRuler.get() != NULL)
mpVerticalRuler->SetZoom(aUIScale);
if (mpContentWindow.get() != NULL)
{
Point aNewPos = mpContentWindow->GetWinViewPos();
aNewPos.X() = aPos.X();
aNewPos.Y() = aPos.Y();
mpContentWindow->SetZoomIntegral(nZoom);
mpContentWindow->SetWinViewPos(aNewPos);
mpContentWindow->UpdateMapOrigin();
// #i74769# see above
mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
}
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
::sd::View* pView = GetView();
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
UpdateScrollBars();
}
/*************************************************************************
|*
|* Abbildungsparameter fuer alle Split-Windows initialisieren
|*
\************************************************************************/
void ViewShell::InitWindows(const Point& rViewOrigin, const Size& rViewSize,
const Point& rWinPos, sal_Bool bUpdate)
{
if (mpContentWindow.get() != NULL)
{
mpContentWindow->SetViewOrigin(rViewOrigin);
mpContentWindow->SetViewSize(rViewSize);
mpContentWindow->SetWinViewPos(rWinPos);
if ( bUpdate )
{
mpContentWindow->UpdateMapOrigin();
mpContentWindow->Invalidate();
}
}
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
::sd::View* pView = GetView();
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
}
/*************************************************************************
|*
|* Alle Split-Windows unter dem uebergebenen Rechteck invalidieren
|*
\************************************************************************/
void ViewShell::InvalidateWindows()
{
if (mpContentWindow.get() != NULL)
mpContentWindow->Invalidate();
}
/*************************************************************************
|*
|* Auf allen Split-Windows ein Markierungsrechteck mit dem
|* uebergebenen Pen zeichnen
|*
\************************************************************************/
void ViewShell::DrawMarkRect(const Rectangle& rRect) const
{
if (mpContentWindow.get() != NULL)
{
mpContentWindow->InvertTracking(rRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW);
}
}
/*************************************************************************
|*
|* Groesse und Raender aller Seiten setzen
|*
\************************************************************************/
void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
long nLeft, long nRight,
long nUpper, long nLower, sal_Bool bScaleAll,
Orientation eOrientation, sal_uInt16 nPaperBin,
sal_Bool bBackgroundFullSize)
{
SdPage* pPage = 0;
SdUndoGroup* pUndoGroup = NULL;
pUndoGroup = new SdUndoGroup(GetDoc());
String aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
pUndoGroup->SetComment(aString);
SfxViewShell* pViewShell = GetViewShell();
OSL_ASSERT (pViewShell!=NULL);
sal_uInt16 i, nPageCnt = GetDoc()->GetMasterSdPageCount(ePageKind);
Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START));
for (i = 0; i < nPageCnt; i++)
{
/**********************************************************************
* Erst alle MasterPages bearbeiten
**********************************************************************/
pPage = GetDoc()->GetMasterSdPage(i, ePageKind);
SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
pPage->GetSize(),
pPage->GetLftBorder(), pPage->GetRgtBorder(),
pPage->GetUppBorder(), pPage->GetLwrBorder(),
pPage->IsScaleObjects(),
pPage->GetOrientation(),
pPage->GetPaperBin(),
pPage->IsBackgroundFullSize(),
rNewSize,
nLeft, nRight,
nUpper, nLower,
bScaleAll,
eOrientation,
nPaperBin,
bBackgroundFullSize);
pUndoGroup->AddAction(pUndo);
if (rNewSize.Width() > 0 ||
nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
{
Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
if (rNewSize.Width() > 0)
pPage->SetSize(rNewSize);
}
if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
{
pPage->SetBorder(nLeft, nUpper, nRight, nLower);
}
pPage->SetOrientation(eOrientation);
pPage->SetPaperBin( nPaperBin );
pPage->SetBackgroundFullSize( bBackgroundFullSize );
if ( ePageKind == PK_STANDARD )
GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
pPage->CreateTitleAndLayout();
}
nPageCnt = GetDoc()->GetSdPageCount(ePageKind);
for (i = 0; i < nPageCnt; i++)
{
/**********************************************************************
* Danach alle Pages bearbeiten
**********************************************************************/
pPage = GetDoc()->GetSdPage(i, ePageKind);
SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
pPage->GetSize(),
pPage->GetLftBorder(), pPage->GetRgtBorder(),
pPage->GetUppBorder(), pPage->GetLwrBorder(),
pPage->IsScaleObjects(),
pPage->GetOrientation(),
pPage->GetPaperBin(),
pPage->IsBackgroundFullSize(),
rNewSize,
nLeft, nRight,
nUpper, nLower,
bScaleAll,
eOrientation,
nPaperBin,
bBackgroundFullSize);
pUndoGroup->AddAction(pUndo);
if (rNewSize.Width() > 0 ||
nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
{
Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
if (rNewSize.Width() > 0)
pPage->SetSize(rNewSize);
}
if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
{
pPage->SetBorder(nLeft, nUpper, nRight, nLower);
}
pPage->SetOrientation(eOrientation);
pPage->SetPaperBin( nPaperBin );
pPage->SetBackgroundFullSize( bBackgroundFullSize );
if ( ePageKind == PK_STANDARD )
{
SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
}
pPage->SetAutoLayout( pPage->GetAutoLayout() );
}
// Handoutseite an neues Format der Standardseiten anpassen
if( (ePageKind == PK_STANDARD) || (ePageKind == PK_HANDOUT) )
GetDoc()->GetSdPage(0, PK_HANDOUT)->CreateTitleAndLayout(sal_True);
// Undo Gruppe dem Undo Manager uebergeben
pViewShell->GetViewFrame()->GetObjectShell()
->GetUndoManager()->AddUndoAction(pUndoGroup);
long nWidth = pPage->GetSize().Width();
long nHeight = pPage->GetSize().Height();
Point aPageOrg = Point(nWidth, nHeight / 2);
Size aViewSize = Size(nWidth * 3, nHeight * 2);
InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
Point aVisAreaPos;
if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
{
aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
}
::sd::View* pView = GetView();
if (pView)
{
pView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize));
}
UpdateScrollBars();
Point aNewOrigin(pPage->GetLftBorder(), pPage->GetUppBorder());
if (pView)
{
pView->GetSdrPageView()->SetPageOrigin(aNewOrigin);
}
pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
// auf (neue) Seitengroesse zoomen
pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END));
}
/*************************************************************************
|*
|* Zoom-Faktor fuer InPlace einstellen
|*
\************************************************************************/
void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&)
{
long nZoom = (long)((double) rZoomX * 100);
SetZoom(nZoom);
}
/*************************************************************************
|*
|* Aktives Fenster setzen
|*
\************************************************************************/
void ViewShell::SetActiveWindow (::sd::Window* pWin)
{
SfxViewShell* pViewShell = GetViewShell();
OSL_ASSERT (pViewShell!=NULL);
if (pViewShell->GetWindow() != pWin)
{
// #i31551# was wrong, it may have been a problem with the repaint at that time.
// For transparent form controls, it is necessary to have that flag set, all apps
// do set it. Enabling again.
if (pWin)
{
pWin->EnableChildTransparentMode();
}
}
if (mpActiveWindow != pWin)
mpActiveWindow = pWin;
// The rest of this function is not guarded anymore against calling this
// method with an already active window because the functions may still
// point to the old window when the new one has already been assigned to
// pWindow elsewhere.
::sd::View* pView = GetView();
if (pView)
{
pView->SetActualWin(pWin);
}
if(HasCurrentFunction())
{
GetCurrentFunction()->SetWindow(pWin);
}
}
/*************************************************************************
|*
|* RequestHelp event
|*
\************************************************************************/
sal_Bool ViewShell::RequestHelp(const HelpEvent& rHEvt, ::sd::Window*)
{
sal_Bool bReturn = sal_False;
if (rHEvt.GetMode())
{
if( GetView() )
bReturn = GetView()->getSmartTags().RequestHelp(rHEvt);
if(!bReturn && HasCurrentFunction())
{
bReturn = GetCurrentFunction()->RequestHelp(rHEvt);
}
}
return(bReturn);
}
FrameView* ViewShell::GetFrameView (void)
{
return mpFrameView;
}
void ViewShell::SetFrameView (FrameView* pNewFrameView)
{
mpFrameView = pNewFrameView;
ReadFrameViewData (mpFrameView);
}
/*************************************************************************
|*
|* Read FrameViews data and set actual views data
|*
\************************************************************************/
void ViewShell::ReadFrameViewData(FrameView*)
{
}
/*************************************************************************
|*
|* Write actual views data to FrameView
|*
\************************************************************************/
void ViewShell::WriteFrameViewData()
{
}
/*************************************************************************
|*
|* OLE-Object aktivieren
|*
\************************************************************************/
sal_Bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
{
ErrCode aErrCode = 0;
SfxErrorContext aEC(ERRCTX_SO_DOVERB, GetActiveWindow(), RID_SO_ERRCTX);
sal_Bool bAbort = sal_False;
GetDocSh()->SetWaitCursor( sal_True );
SfxViewShell* pViewShell = GetViewShell();
OSL_ASSERT (pViewShell!=NULL);
bool bChangeDefaultsForChart = false;
rtl::OUString aName;
uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
if ( !xObj.is() )
{
/**********************************************************
* Leeres OLE-Objekt mit OLE-Objekt versehen
**********************************************************/
aName = pObj->GetProgName();
::rtl::OUString aObjName;
SvGlobalName aClass;
if( aName == "StarChart" || aName == "StarOrg" )
{
if( SvtModuleOptions().IsChart() )
{
aClass = SvGlobalName( SO3_SCH_CLASSID );
bChangeDefaultsForChart = true;
}
}
else if( aName == "StarCalc" )
{
if( SvtModuleOptions().IsCalc() )
aClass = SvGlobalName( SO3_SC_CLASSID );
}
else if( aName == "StarMath" )
{
if( SvtModuleOptions().IsMath() )
aClass = SvGlobalName( SO3_SM_CLASSID );
}
if ( aClass != SvGlobalName() )
xObj = GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass.GetByteSequence(), aObjName );
if( !xObj.is() )
{
aName = "";
// Dialog "OLE-Objekt einfuegen" aufrufen
GetDocSh()->SetWaitCursor( sal_False );
pViewShell->GetViewFrame()->GetDispatcher()->Execute(
SID_INSERT_OBJECT,
SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
xObj = pObj->GetObjRef();
GetDocSh()->SetWaitCursor( sal_True );
if (!xObj.is())
{
bAbort = sal_True;
}
}
if ( xObj.is() )
{
/******************************************************
* OLE-Objekt ist nicht mehr leer
******************************************************/
pObj->SetEmptyPresObj(sal_False);
pObj->SetOutlinerParaObject(NULL);
pObj->SetGraphic(NULL);
/******************************************************
* Das leere OLE-Objekt bekommt ein neues IPObj
******************************************************/
if (!aName.isEmpty())
{
pObj->SetObjRef(xObj);
pObj->SetName(aObjName);
pObj->SetPersistName(aObjName);
}
else
{
// Das Einfuegen hat der Dialog schon gemacht
pObj->SetObjRef(xObj);
}
Rectangle aRect = pObj->GetLogicRect();
if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
{
awt::Size aSz;
aSz.Width = aRect.GetWidth();
aSz.Height = aRect.GetHeight();
xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
}
GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
nVerb = SVVERB_SHOW;
}
else
{
aErrCode = ERRCODE_SFX_OLEGENERAL;
}
}
if( aErrCode == 0 )
{
::sd::View* pView = GetView();
if (pView->IsTextEdit())
{
pView->SdrEndTextEdit();
}
SfxInPlaceClient* pSdClient =
static_cast<Client*>(pViewShell->FindIPClient(
pObj->GetObjRef(), GetActiveWindow()));
if ( !pSdClient )
{
pSdClient = new Client(pObj, this, GetActiveWindow());
}
Rectangle aRect = pObj->GetLogicRect();
Size aDrawSize = aRect.GetSize();
MapMode aMapMode( GetDoc()->GetScaleUnit() );
Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
aObjAreaSize = aDrawSize;
Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
aScaleHeight.ReduceInaccurate(10);
pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
// sichtbarer Ausschnitt wird nur inplace veraendert!
aRect.SetSize(aObjAreaSize);
// the object area size must be set after scaling, since it triggers the resizing
pSdClient->SetObjArea(aRect);
if( bChangeDefaultsForChart && xObj.is())
{
AdaptDefaultsForChart( xObj );
}
pSdClient->DoVerb(nVerb); // ErrCode wird ggf. vom Sfx ausgegeben
pViewShell->GetViewFrame()->GetBindings().Invalidate(
SID_NAVIGATOR_STATE, sal_True, sal_False);
}
GetDocSh()->SetWaitCursor( sal_False );
if (aErrCode != 0 && !bAbort)
{
ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, String() ) );
}
return aErrCode == 0;
}
/*************************************************************************
|*
|* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
|*
\************************************************************************/
const Rectangle& ViewShell::GetAllWindowRect()
{
maAllWindowRectangle.SetPos(
mpContentWindow->OutputToScreenPixel(Point(0,0)));
return maAllWindowRectangle;
}
/*************************************************************************
|*
|* Read user data
|*
\************************************************************************/
void ViewShell::ReadUserData(const String&)
{
// Auf an FrameView gemerkte VisArea zoomen
GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
}
/*************************************************************************
|*
|* Write user data
|*
\************************************************************************/
void ViewShell::WriteUserData(String&)
{
// Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
WriteFrameViewData();
}
/*************************************************************************
|*
|* Lineale ein- / ausschalten
|*
\************************************************************************/
void ViewShell::SetRuler(sal_Bool bRuler)
{
mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
if (mpHorizontalRuler.get() != NULL)
{
if (mbHasRulers)
{
mpHorizontalRuler->Show();
}
else
{
mpHorizontalRuler->Hide();
}
}
if (mpVerticalRuler.get() != NULL)
{
if (mbHasRulers)
{
mpVerticalRuler->Show();
}
else
{
mpVerticalRuler->Hide();
}
}
OSL_ASSERT(GetViewShell()!=NULL);
if (IsMainViewShell())
GetViewShell()->InvalidateBorder();
}
/*************************************************************************
|*
|* AcceptDrop
|*
\************************************************************************/
sal_Int8 ViewShell::AcceptDrop (
const AcceptDropEvent& rEvt,
DropTargetHelper& rTargetHelper,
::sd::Window* pTargetWindow,
sal_uInt16 nPage,
sal_uInt16 nLayer)
{
::sd::View* pView = GetView();
return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
}
/*************************************************************************
|*
|* ExecuteDrop
|*
\************************************************************************/
sal_Int8 ViewShell::ExecuteDrop (
const ExecuteDropEvent& rEvt,
DropTargetHelper& rTargetHelper,
::sd::Window* pTargetWindow,
sal_uInt16 nPage,
sal_uInt16 nLayer)
{
::sd::View* pView = GetView();
return( pView ? pView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
}
#ifdef _MSC_VER
#pragma optimize ( "", on )
#endif
void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence <
::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse)
{
const sal_Int32 nIndex = rSequence.getLength();
rSequence.realloc( nIndex + 1 );
OSL_ASSERT (GetViewShell()!=NULL);
// Get the view id from the view shell in the center pane. This will
// usually be the called view shell, but to be on the safe side we call
// the main view shell explicitly.
sal_uInt16 nViewID (IMPRESS_FACTORY_ID);
if (GetViewShellBase().GetMainViewShell().get() != NULL)
nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
rSequence[nIndex].Name = rtl::OUString( sUNO_View_ViewId );
rtl::OUStringBuffer sBuffer( "view" );
sBuffer.append( static_cast<sal_Int32>(nViewID));
rSequence[nIndex].Value <<= sBuffer.makeStringAndClear();
mpFrameView->WriteUserDataSequence( rSequence, bBrowse );
}
void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
{
mpFrameView->ReadUserDataSequence( rSequence, bBrowse );
}
void ViewShell::VisAreaChanged(const Rectangle& rRect)
{
OSL_ASSERT (GetViewShell()!=NULL);
GetViewShell()->VisAreaChanged(rRect);
}
void ViewShell::SetWinViewPos(const Point& rWinPos, bool bUpdate)
{
if (mpContentWindow.get() != NULL)
{
mpContentWindow->SetWinViewPos(rWinPos);
if ( bUpdate )
{
mpContentWindow->UpdateMapOrigin();
mpContentWindow->Invalidate();
}
}
if (mbHasRulers)
{
UpdateHRuler();
UpdateVRuler();
}
UpdateScrollBars();
Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
VisAreaChanged(aVisAreaWin);
::sd::View* pView = GetView();
if (pView)
{
pView->VisAreaChanged(GetActiveWindow());
}
}
Point ViewShell::GetWinViewPos() const
{
return mpContentWindow->GetWinViewPos();
}
Point ViewShell::GetViewOrigin() const
{
return mpContentWindow->GetViewOrigin();
}
void ViewShell::AdaptDefaultsForChart(
const uno::Reference < embed::XEmbeddedObject > & xEmbObj )
{
if( xEmbObj.is())
{
uno::Reference< chart2::XChartDocument > xChartDoc( xEmbObj->getComponent(), uno::UNO_QUERY );
OSL_ENSURE( xChartDoc.is(), "Trying to set chart property to non-chart OLE" );
if( !xChartDoc.is())
return;
try
{
// set background to transparent (none)
uno::Reference< beans::XPropertySet > xPageProp( xChartDoc->getPageBackground());
if( xPageProp.is())
xPageProp->setPropertyValue( "FillStyle" , uno::makeAny( drawing::FillStyle_NONE ));
// set no border
if( xPageProp.is())
xPageProp->setPropertyValue( "LineStyle" , uno::makeAny( drawing::LineStyle_NONE ));
}
catch( const uno::Exception & )
{
OSL_FAIL( "Exception caught in AdaptDefaultsForChart" );
}
}
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|