xref: /trunk/main/sd/source/ui/view/viewshe2.cxx (revision 6f0b96b4)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/chart2/XChartDocument.hpp>
29 #include <com/sun/star/drawing/FillStyle.hpp>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 
32 #include "ViewShell.hxx"
33 #include "ViewShellHint.hxx"
34 
35 #include "ViewShellImplementation.hxx"
36 #include "FactoryIds.hxx"
37 
38 #ifndef _SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
41 #ifndef _SCRBAR_HXX //autogen
42 #include <vcl/scrbar.hxx>
43 #endif
44 #include <svx/svdpagv.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/app.hxx>
47 #include <svx/ruler.hxx>
48 #include <editeng/outliner.hxx>
49 #include <svtools/ehdl.hxx>
50 #include <svx/svdoole2.hxx>
51 #include <svtools/sfxecode.hxx>
52 #include <svx/fmshell.hxx>
53 #include <sfx2/dispatch.hxx>
54 #include <rtl/ustrbuf.hxx>
55 #include <unotools/moduleoptions.hxx>
56 #ifndef _SVX_DIALOGS_HRC
57 #include <svx/dialogs.hrc>
58 #endif
59 #include <sot/clsids.hxx>
60 
61 #include "misc.hxx"
62 #include "strings.hrc"
63 #include "app.hrc"
64 #include "unokywds.hxx"
65 
66 #include "sdundogr.hxx"
67 #include "FrameView.hxx"
68 #include "undopage.hxx"
69 #include "sdresid.hxx"
70 #include "drawdoc.hxx"
71 #include "View.hxx"
72 #include "fupoor.hxx"
73 #include "Client.hxx"
74 #include "DrawDocShell.hxx"
75 #include "fusearch.hxx"
76 #include "slideshow.hxx"
77 #include "sdpage.hxx"
78 #include "DrawViewShell.hxx"
79 #include "ViewShellBase.hxx"
80 
81 #include "Window.hxx"
82 
83 #include <sfx2/viewfrm.hxx>
84 #include <svtools/soerr.hxx>
85 #include <toolkit/helper/vclunohelper.hxx>
86 #include <svx/charthelper.hxx>
87 
88 #ifdef _MSC_VER
89 #pragma optimize ( "", off )
90 #endif
91 
92 using namespace com::sun::star;
93 
94 const String aEmptyStr;
95 
96 namespace sd {
97 
98 /*************************************************************************
99 |*
100 |* Scrollbar-Update: Thumbpos und VisibleSize anpassen
101 |*
102 \************************************************************************/
103 
UpdateScrollBars()104 void ViewShell::UpdateScrollBars()
105 {
106 	if (mpHorizontalScrollBar.get() != NULL)
107 	{
108 		long nW = (long)(mpContentWindow->GetVisibleWidth() * 32000);
109 		long nX = (long)(mpContentWindow->GetVisibleX() * 32000);
110 		mpHorizontalScrollBar->SetVisibleSize(nW);
111 		mpHorizontalScrollBar->SetThumbPos(nX);
112 		nW = 32000 - nW;
113 		long nLine = (long) (mpContentWindow->GetScrlLineWidth() * nW);
114 		long nPage = (long) (mpContentWindow->GetScrlPageWidth() * nW);
115 		mpHorizontalScrollBar->SetLineSize(nLine);
116 		mpHorizontalScrollBar->SetPageSize(nPage);
117 	}
118 
119 	if (mpVerticalScrollBar.get() != NULL)
120 	{
121 		long nH = (long)(mpContentWindow->GetVisibleHeight() * 32000);
122 		long nY = (long)(mpContentWindow->GetVisibleY() * 32000);
123 
124 		if(IsPageFlipMode()) // ie in zoom mode where no panning
125 		{
126 			SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
127 			sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) / 2;
128 			sal_uInt16 nTotalPages = GetDoc()->GetSdPageCount(pPage->GetPageKind());
129 			mpVerticalScrollBar->SetRange(Range(0,256*nTotalPages));
130 			mpVerticalScrollBar->SetVisibleSize(256);
131 			mpVerticalScrollBar->SetThumbPos(256*nCurPage);
132 			mpVerticalScrollBar->SetLineSize(256);
133 			mpVerticalScrollBar->SetPageSize(256);
134 		}
135 		else
136 		{
137 			mpVerticalScrollBar->SetRange(Range(0,32000));
138 			mpVerticalScrollBar->SetVisibleSize(nH);
139 			mpVerticalScrollBar->SetThumbPos(nY);
140 			nH = 32000 - nH;
141 			long nLine = (long) (mpContentWindow->GetScrlLineHeight() * nH);
142 			long nPage = (long) (mpContentWindow->GetScrlPageHeight() * nH);
143 			mpVerticalScrollBar->SetLineSize(nLine);
144 			mpVerticalScrollBar->SetPageSize(nPage);
145 		}
146 	}
147 
148 	if (mbHasRulers)
149 	{
150 		UpdateHRuler();
151 		UpdateVRuler();
152 	}
153 
154 }
155 /*************************************************************************
156 |*
157 |* Handling fuer horizontale Scrollbars
158 |*
159 \************************************************************************/
160 
IMPL_LINK_INLINE_START(ViewShell,HScrollHdl,ScrollBar *,pHScroll)161 IMPL_LINK_INLINE_START(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
162 {
163 	return VirtHScrollHdl(pHScroll);
164 }
IMPL_LINK_INLINE_END(ViewShell,HScrollHdl,ScrollBar *,pHScroll)165 IMPL_LINK_INLINE_END(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
166 
167 /*************************************************************************
168 |*
169 |* virtueller Scroll-Handler fuer horizontale Scrollbars
170 |*
171 \************************************************************************/
172 
173 long ViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
174 {
175 	long nDelta = pHScroll->GetDelta();
176 
177 	if (nDelta != 0)
178 	{
179 		double fX = (double) pHScroll->GetThumbPos() / pHScroll->GetRange().Len();
180 
181 		// alle Fenster der Spalte scrollen
182         ::sd::View* pView = GetView();
183         OutlinerView* pOLV = NULL;
184 
185         if (pView)
186             pOLV = pView->GetTextEditOutlinerView();
187 
188         if (pOLV)
189             pOLV->HideCursor();
190 
191         mpContentWindow->SetVisibleXY(fX, -1);
192 
193         Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
194         Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
195         aVisArea.SetPos(aVisAreaPos);
196         GetDocSh()->SetVisArea(aVisArea);
197 
198         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
199         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
200         VisAreaChanged(aVisAreaWin);
201 
202         if (pView)
203         {
204             pView->VisAreaChanged(GetActiveWindow());
205         }
206 
207         if (pOLV)
208             pOLV->ShowCursor();
209 
210 		if (mbHasRulers)
211 			UpdateHRuler();
212 
213 	}
214 
215 	return 0;
216 }
217 
218 /*************************************************************************
219 |*
220 |* Handling fuer vertikale Scrollbars
221 |*
222 \************************************************************************/
223 
IMPL_LINK_INLINE_START(ViewShell,VScrollHdl,ScrollBar *,pVScroll)224 IMPL_LINK_INLINE_START(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
225 {
226 	return VirtVScrollHdl(pVScroll);
227 }
IMPL_LINK_INLINE_END(ViewShell,VScrollHdl,ScrollBar *,pVScroll)228 IMPL_LINK_INLINE_END(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
229 
230 /*************************************************************************
231 |*
232 |* Handling fuer vertikale Scrollbars
233 |*
234 \************************************************************************/
235 
236 long ViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
237 {
238 	if(IsPageFlipMode())
239 	{
240 		SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
241 		sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) >> 1;
242 		sal_uInt16 nNewPage = (sal_uInt16)pVScroll->GetThumbPos()/256;
243 		if( nCurPage != nNewPage )
244 			static_cast<DrawViewShell*>(this)->SwitchPage(nNewPage);
245 	}
246 	else //panning mode
247 	{
248 		double fY = (double) pVScroll->GetThumbPos() / pVScroll->GetRange().Len();
249 
250         ::sd::View* pView = GetView();
251         OutlinerView* pOLV = NULL;
252 
253         if (pView)
254             pOLV = pView->GetTextEditOutlinerView();
255 
256         if (pOLV)
257             pOLV->HideCursor();
258 
259         mpContentWindow->SetVisibleXY(-1, fY);
260 
261         Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
262         Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
263         aVisArea.SetPos(aVisAreaPos);
264         GetDocSh()->SetVisArea(aVisArea);
265 
266         Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
267         Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
268         VisAreaChanged(aVisAreaWin);
269 
270         if (pView)
271         {
272             pView->VisAreaChanged(GetActiveWindow());
273         }
274 
275         if (pOLV)
276             pOLV->ShowCursor();
277 
278 		if (mbHasRulers)
279 			UpdateVRuler();
280 
281 	}
282 
283 	return 0;
284 }
285 
CreateHRuler(::sd::Window *,sal_Bool)286 SvxRuler* ViewShell::CreateHRuler(::sd::Window* , sal_Bool )
287 {
288 	return NULL;
289 }
290 
CreateVRuler(::sd::Window *)291 SvxRuler* ViewShell::CreateVRuler(::sd::Window* )
292 {
293 	return NULL;
294 }
295 
UpdateHRuler()296 void ViewShell::UpdateHRuler()
297 {
298 }
299 
UpdateVRuler()300 void ViewShell::UpdateVRuler()
301 {
302 }
303 
GetHCtrlWidth()304 long ViewShell::GetHCtrlWidth()
305 {
306 	return 0;
307 }
308 
309 /*************************************************************************
310 |*
311 |* Eine bestimmte Anzahl von Zeilen scrollen (wird beim automatischen
312 |* Scrollen (Zeichen/Draggen) verwendet)
313 |*
314 \************************************************************************/
315 
ScrollLines(long nLinesX,long nLinesY)316 void ViewShell::ScrollLines(long nLinesX, long nLinesY)
317 {
318 	if ( nLinesX )
319 	{
320 		nLinesX *= mpHorizontalScrollBar->GetLineSize();
321 	}
322 	if ( nLinesY )
323 	{
324 		nLinesY *= mpVerticalScrollBar->GetLineSize();
325 	}
326 
327 	Scroll(nLinesX, nLinesY);
328 }
329 
330 /*************************************************************************
331 |*
332 |* Window um nScrollX, nScrollY scrollen
333 |*
334 \************************************************************************/
335 
Scroll(long nScrollX,long nScrollY)336 void ViewShell::Scroll(long nScrollX, long nScrollY)
337 {
338 	if (nScrollX)
339 	{
340 		long nNewThumb = mpHorizontalScrollBar->GetThumbPos() + nScrollX;
341 		mpHorizontalScrollBar->SetThumbPos(nNewThumb);
342 	}
343 	if (nScrollY)
344 	{
345 		long nNewThumb = mpVerticalScrollBar->GetThumbPos() + nScrollY;
346 		mpVerticalScrollBar->SetThumbPos(nNewThumb);
347 	}
348 	double	fX = (double) mpHorizontalScrollBar->GetThumbPos() /
349 							mpHorizontalScrollBar->GetRange().Len();
350 	double	fY = (double) mpVerticalScrollBar->GetThumbPos() /
351 							mpVerticalScrollBar->GetRange().Len();
352 
353 	GetActiveWindow()->SetVisibleXY(fX, fY);
354 
355 	Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
356 	Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
357 	aVisArea.SetPos(aVisAreaPos);
358 	GetDocSh()->SetVisArea(aVisArea);
359 
360 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
361 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
362 	VisAreaChanged(aVisAreaWin);
363 
364 	::sd::View* pView = GetView();
365 	if (pView)
366 	{
367 		pView->VisAreaChanged(GetActiveWindow());
368 	}
369 
370 	if (mbHasRulers)
371 	{
372 		UpdateHRuler();
373 		UpdateVRuler();
374 	}
375 }
376 
377 /*************************************************************************
378 |*
379 |* Den Zoomfaktor fuer alle Split-Windows setzen
380 |*
381 \************************************************************************/
382 
SetZoom(long nZoom)383 void ViewShell::SetZoom(long nZoom)
384 {
385 	Fraction aUIScale(nZoom, 100);
386 	aUIScale *= GetDoc()->GetUIScale();
387 
388     if (mpHorizontalRuler.get() != NULL)
389         mpHorizontalRuler->SetZoom(aUIScale);
390 
391     if (mpVerticalRuler.get() != NULL)
392         mpVerticalRuler->SetZoom(aUIScale);
393 
394     if (mpContentWindow.get() != NULL)
395     {
396         mpContentWindow->SetZoomIntegral(nZoom);
397 
398 		// #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
399 		// of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
400 		// the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
401 		// but does not solve the problem completely. Neet to ask PL.
402         mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
403     }
404 
405 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
406 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
407 	VisAreaChanged(aVisAreaWin);
408 
409 	::sd::View* pView = GetView();
410 	if (pView)
411 	{
412 		pView->VisAreaChanged(GetActiveWindow());
413 	}
414 
415 	UpdateScrollBars();
416 }
417 
418 /*************************************************************************
419 |*
420 |* Zoomrechteck fuer aktives Fenster einstellen und alle Split-Windows
421 |* auf den gleichen Zoomfaktor setzen
422 |*
423 \************************************************************************/
424 
SetZoomRect(const Rectangle & rZoomRect)425 void ViewShell::SetZoomRect(const Rectangle& rZoomRect)
426 {
427 	long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
428 	Fraction aUIScale(nZoom, 100);
429 	aUIScale *= GetDoc()->GetUIScale();
430 
431 	Point aPos = GetActiveWindow()->GetWinViewPos();
432 
433     if (mpHorizontalRuler.get() != NULL)
434         mpHorizontalRuler->SetZoom(aUIScale);
435 
436     if (mpVerticalRuler.get() != NULL)
437         mpVerticalRuler->SetZoom(aUIScale);
438 
439     if (mpContentWindow.get() != NULL)
440     {
441         Point aNewPos = mpContentWindow->GetWinViewPos();
442         aNewPos.X() = aPos.X();
443         aNewPos.Y() = aPos.Y();
444         mpContentWindow->SetZoomIntegral(nZoom);
445         mpContentWindow->SetWinViewPos(aNewPos);
446         mpContentWindow->UpdateMapOrigin();
447 
448 		// #i74769# see above
449         mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
450     }
451 
452 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
453 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
454 	VisAreaChanged(aVisAreaWin);
455 
456 	::sd::View* pView = GetView();
457 	if (pView)
458 	{
459 		pView->VisAreaChanged(GetActiveWindow());
460 	}
461 
462 	UpdateScrollBars();
463 }
464 
465 /*************************************************************************
466 |*
467 |* Abbildungsparameter fuer alle Split-Windows initialisieren
468 |*
469 \************************************************************************/
470 
InitWindows(const Point & rViewOrigin,const Size & rViewSize,const Point & rWinPos,sal_Bool bUpdate)471 void ViewShell::InitWindows(const Point& rViewOrigin, const Size& rViewSize,
472 							  const Point& rWinPos, sal_Bool bUpdate)
473 {
474     if (mpContentWindow.get() != NULL)
475     {
476         mpContentWindow->SetViewOrigin(rViewOrigin);
477         mpContentWindow->SetViewSize(rViewSize);
478         mpContentWindow->SetWinViewPos(rWinPos);
479 
480         if ( bUpdate )
481         {
482             mpContentWindow->UpdateMapOrigin();
483             mpContentWindow->Invalidate();
484         }
485     }
486 
487 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
488 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
489 	VisAreaChanged(aVisAreaWin);
490 
491 	::sd::View* pView = GetView();
492 	if (pView)
493 	{
494 		pView->VisAreaChanged(GetActiveWindow());
495 	}
496 }
497 
498 /*************************************************************************
499 |*
500 |* Alle Split-Windows unter dem uebergebenen Rechteck invalidieren
501 |*
502 \************************************************************************/
503 
InvalidateWindows()504 void ViewShell::InvalidateWindows()
505 {
506     if (mpContentWindow.get() != NULL)
507         mpContentWindow->Invalidate();
508 }
509 
510 
511 /*************************************************************************
512 |*
513 |* Auf allen Split-Windows ein Markierungsrechteck mit dem
514 |* uebergebenen Pen zeichnen
515 |*
516 \************************************************************************/
517 
DrawMarkRect(const Rectangle & rRect) const518 void ViewShell::DrawMarkRect(const Rectangle& rRect) const
519 {
520     if (mpContentWindow.get() != NULL)
521     {
522         mpContentWindow->InvertTracking(rRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW);
523     }
524 }
525 
526 /*************************************************************************
527 |*
528 |* Groesse und Raender aller Seiten setzen
529 |*
530 \************************************************************************/
531 
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)532 void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
533 									   long nLeft, long nRight,
534 									   long nUpper, long nLower, sal_Bool bScaleAll,
535 									   Orientation eOrientation, sal_uInt16 nPaperBin,
536 							           sal_Bool bBackgroundFullSize)
537 {
538 	SdPage* pPage = 0;
539 	SdUndoGroup* pUndoGroup = NULL;
540 	pUndoGroup = new SdUndoGroup(GetDoc());
541 	String aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
542 	pUndoGroup->SetComment(aString);
543     SfxViewShell* pViewShell = GetViewShell();
544     OSL_ASSERT (pViewShell!=NULL);
545 
546 	sal_uInt16 i, nPageCnt = GetDoc()->GetMasterSdPageCount(ePageKind);
547 
548     Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START));
549 
550 	for (i = 0; i < nPageCnt; i++)
551 	{
552 		/**********************************************************************
553 		* Erst alle MasterPages bearbeiten
554 		**********************************************************************/
555 		pPage = GetDoc()->GetMasterSdPage(i, ePageKind);
556 
557 		SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
558 							pPage->GetSize(),
559 							pPage->GetLftBorder(), pPage->GetRgtBorder(),
560 							pPage->GetUppBorder(), pPage->GetLwrBorder(),
561 							pPage->IsScaleObjects(),
562 							pPage->GetOrientation(),
563 							pPage->GetPaperBin(),
564 							pPage->IsBackgroundFullSize(),
565 							rNewSize,
566 							nLeft, nRight,
567 							nUpper, nLower,
568 							bScaleAll,
569 							eOrientation,
570 							nPaperBin,
571 							bBackgroundFullSize);
572 		pUndoGroup->AddAction(pUndo);
573 
574 		if (rNewSize.Width() > 0 ||
575 			nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
576 		{
577 			Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
578 			pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
579 
580 			if (rNewSize.Width() > 0)
581 				pPage->SetSize(rNewSize);
582 		}
583 
584 		if( nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
585 		{
586 			pPage->SetBorder(nLeft, nUpper, nRight, nLower);
587 		}
588 
589 		pPage->SetOrientation(eOrientation);
590 		pPage->SetPaperBin( nPaperBin );
591 		pPage->SetBackgroundFullSize( bBackgroundFullSize );
592 
593 		if ( ePageKind == PK_STANDARD )
594 			GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
595 
596 		pPage->CreateTitleAndLayout();
597 	}
598 
599 	nPageCnt = GetDoc()->GetSdPageCount(ePageKind);
600 
601 	for (i = 0; i < nPageCnt; i++)
602 	{
603 		/**********************************************************************
604 		* Danach alle Pages bearbeiten
605 		**********************************************************************/
606 		pPage = GetDoc()->GetSdPage(i, ePageKind);
607 
608 		SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
609 								pPage->GetSize(),
610 								pPage->GetLftBorder(), pPage->GetRgtBorder(),
611 								pPage->GetUppBorder(), pPage->GetLwrBorder(),
612 								pPage->IsScaleObjects(),
613 								pPage->GetOrientation(),
614 								pPage->GetPaperBin(),
615 								pPage->IsBackgroundFullSize(),
616 								rNewSize,
617 								nLeft, nRight,
618 								nUpper, nLower,
619 								bScaleAll,
620 								eOrientation,
621 								nPaperBin,
622 								bBackgroundFullSize);
623 		pUndoGroup->AddAction(pUndo);
624 
625 		if (rNewSize.Width() > 0 ||
626 			nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
627 		{
628 			Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
629 			pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
630 
631 			if (rNewSize.Width() > 0)
632 				pPage->SetSize(rNewSize);
633 		}
634 
635 		if( nLeft  >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
636 		{
637 			pPage->SetBorder(nLeft, nUpper, nRight, nLower);
638 		}
639 
640 		pPage->SetOrientation(eOrientation);
641 		pPage->SetPaperBin( nPaperBin );
642 		pPage->SetBackgroundFullSize( bBackgroundFullSize );
643 
644 		if ( ePageKind == PK_STANDARD )
645 		{
646 			SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
647 			pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
648 		}
649 
650 		pPage->SetAutoLayout( pPage->GetAutoLayout() );
651 	}
652 
653 	// Handoutseite an neues Format der Standardseiten anpassen
654 	if( (ePageKind == PK_STANDARD) || (ePageKind == PK_HANDOUT) )
655 		GetDoc()->GetSdPage(0, PK_HANDOUT)->CreateTitleAndLayout(sal_True);
656 
657 	// Undo Gruppe dem Undo Manager uebergeben
658 	pViewShell->GetViewFrame()->GetObjectShell()
659         ->GetUndoManager()->AddUndoAction(pUndoGroup);
660 
661 	long nWidth = pPage->GetSize().Width();
662 	long nHeight = pPage->GetSize().Height();
663 
664 	Point aPageOrg = Point(nWidth, nHeight / 2);
665 	Size aViewSize = Size(nWidth * 3, nHeight * 2);
666 
667 	InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
668 
669 	Point aVisAreaPos;
670 
671 	if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
672 	{
673 		aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
674 	}
675 
676 	::sd::View* pView = GetView();
677 	if (pView)
678 	{
679 		pView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize));
680 	}
681 
682 	UpdateScrollBars();
683 
684 	Point aNewOrigin(pPage->GetLftBorder(), pPage->GetUppBorder());
685 
686 	if (pView)
687 	{
688 		pView->GetSdrPageView()->SetPageOrigin(aNewOrigin);
689 	}
690 
691 	pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
692 
693 	// auf (neue) Seitengroesse zoomen
694 	pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
695 			SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
696 
697     Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END));
698 }
699 
700 /*************************************************************************
701 |*
702 |* Zoom-Faktor fuer InPlace einstellen
703 |*
704 \************************************************************************/
705 
SetZoomFactor(const Fraction & rZoomX,const Fraction &)706 void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&)
707 {
708 	long nZoom = (long)((double) rZoomX * 100);
709 	SetZoom(nZoom);
710 }
711 
712 
713 /*************************************************************************
714 |*
715 |* Aktives Fenster setzen
716 |*
717 \************************************************************************/
718 
SetActiveWindow(::sd::Window * pWin)719 void ViewShell::SetActiveWindow (::sd::Window* pWin)
720 {
721     SfxViewShell* pViewShell = GetViewShell();
722     OSL_ASSERT (pViewShell!=NULL);
723 
724     if (pViewShell->GetWindow() != pWin)
725 	{
726 		// #i31551# was wrong, it may have been a problem with the repaint at that time.
727 		// For transparent form controls, it is necessary to have that flag set, all apps
728 		// do set it. Enabling again.
729 		if (pWin)
730 		{
731 			pWin->EnableChildTransparentMode();
732 		}
733 	}
734 
735     if (mpActiveWindow != pWin)
736         mpActiveWindow = pWin;
737 
738     // The rest of this function is not guarded anymore against calling this
739     // method with an already active window because the functions may still
740     // point to the old window when the new one has already been assigned to
741     // pWindow elsewhere.
742     ::sd::View* pView = GetView();
743     if (pView)
744     {
745         pView->SetActualWin(pWin);
746     }
747     if(HasCurrentFunction())
748     {
749         GetCurrentFunction()->SetWindow(pWin);
750     }
751 }
752 
753 
754 
755 /*************************************************************************
756 |*
757 |* RequestHelp event
758 |*
759 \************************************************************************/
760 
RequestHelp(const HelpEvent & rHEvt,::sd::Window *)761 sal_Bool ViewShell::RequestHelp(const HelpEvent& rHEvt, ::sd::Window*)
762 {
763 	sal_Bool bReturn = sal_False;
764 
765 	if (rHEvt.GetMode())
766 	{
767 		if( GetView() )
768 			bReturn = GetView()->getSmartTags().RequestHelp(rHEvt);
769 
770 		if(!bReturn && HasCurrentFunction())
771 		{
772 			bReturn = GetCurrentFunction()->RequestHelp(rHEvt);
773 		}
774 	}
775 
776 	return(bReturn);
777 }
778 
779 
780 
781 
GetFrameView(void)782 FrameView* ViewShell::GetFrameView (void)
783 {
784     return mpFrameView;
785 }
786 
787 
788 
789 
SetFrameView(FrameView * pNewFrameView)790 void ViewShell::SetFrameView (FrameView* pNewFrameView)
791 {
792     mpFrameView = pNewFrameView;
793     ReadFrameViewData (mpFrameView);
794 }
795 
796 
797 
798 
799 /*************************************************************************
800 |*
801 |* Read FrameViews data and set actual views data
802 |*
803 \************************************************************************/
804 
ReadFrameViewData(FrameView *)805 void ViewShell::ReadFrameViewData(FrameView*)
806 {
807 }
808 
809 
810 
811 /*************************************************************************
812 |*
813 |* Write actual views data to FrameView
814 |*
815 \************************************************************************/
816 
WriteFrameViewData()817 void ViewShell::WriteFrameViewData()
818 {
819 }
820 
821 /*************************************************************************
822 |*
823 |* OLE-Object aktivieren
824 |*
825 \************************************************************************/
826 
ActivateObject(SdrOle2Obj * pObj,long nVerb)827 sal_Bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
828 {
829 	ErrCode aErrCode = 0;
830 
831 	SfxErrorContext aEC(ERRCTX_SO_DOVERB, GetActiveWindow(), RID_SO_ERRCTX);
832 	sal_Bool bAbort = sal_False;
833 	GetDocSh()->SetWaitCursor( sal_True );
834     SfxViewShell* pViewShell = GetViewShell();
835     OSL_ASSERT (pViewShell!=NULL);
836     bool bChangeDefaultsForChart = false;
837 
838     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
839     if ( !xObj.is() )
840 	{
841 		/**********************************************************
842 		* Leeres OLE-Objekt mit OLE-Objekt versehen
843 		**********************************************************/
844 		String aName = pObj->GetProgName();
845         ::rtl::OUString aObjName;
846         SvGlobalName aClass;
847 
848         if( aName.EqualsAscii( "StarChart" ) || aName.EqualsAscii("StarOrg") )
849 		{
850 			if( SvtModuleOptions().IsChart() )
851             {
852                 aClass = SvGlobalName( SO3_SCH_CLASSID );
853                 bChangeDefaultsForChart = true;
854             }
855 		}
856 		else if( aName.EqualsAscii( "StarCalc" ))
857 		{
858 			if( SvtModuleOptions().IsCalc() )
859                 aClass = SvGlobalName( SO3_SC_CLASSID );
860 		}
861 		else if( aName.EqualsAscii( "StarMath" ))
862 		{
863 			if( SvtModuleOptions().IsMath() )
864                 aClass = SvGlobalName( SO3_SM_CLASSID );
865 		}
866 
867         if ( aClass != SvGlobalName() )
868             xObj = GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass.GetByteSequence(), aObjName );
869 
870         if( !xObj.is() )
871 		{
872 			aName = String();
873 
874 			// Dialog "OLE-Objekt einfuegen" aufrufen
875 			GetDocSh()->SetWaitCursor( sal_False );
876 			pViewShell->GetViewFrame()->GetDispatcher()->Execute(
877                 SID_INSERT_OBJECT,
878                 SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
879             xObj = pObj->GetObjRef();
880 			GetDocSh()->SetWaitCursor( sal_True );
881 
882             if (!xObj.is())
883 			{
884 				bAbort = sal_True;
885 			}
886 		}
887 
888         if ( xObj.is() )
889 		{
890 			/******************************************************
891 			* OLE-Objekt ist nicht mehr leer
892 			******************************************************/
893 			pObj->SetEmptyPresObj(sal_False);
894 			pObj->SetOutlinerParaObject(NULL);
895 			pObj->SetGraphic(NULL);
896 
897 			/******************************************************
898 			* Das leere OLE-Objekt bekommt ein neues IPObj
899 			******************************************************/
900 			if (aName.Len())
901 			{
902                 pObj->SetObjRef(xObj);
903 				pObj->SetName(aObjName);
904     			pObj->SetPersistName(aObjName);
905 			}
906 			else
907 			{
908 				// Das Einfuegen hat der Dialog schon gemacht
909                 pObj->SetObjRef(xObj);
910 			}
911 
912 			Rectangle aRect = pObj->GetLogicRect();
913 
914 			if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
915 			{
916             	awt::Size aSz;
917             	aSz.Width = aRect.GetWidth();
918             	aSz.Height = aRect.GetHeight();
919             	xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
920 			}
921 
922             GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
923 
924 			nVerb = SVVERB_SHOW;
925 		}
926 		else
927 		{
928 			aErrCode = ERRCODE_SFX_OLEGENERAL;
929 		}
930 	}
931 
932 	if( aErrCode == 0 )
933 	{
934 		::sd::View* pView = GetView();
935 
936 		if (pView->IsTextEdit())
937 		{
938 			pView->SdrEndTextEdit();
939 		}
940 
941         SfxInPlaceClient* pSdClient =
942             static_cast<Client*>(pViewShell->FindIPClient(
943                 pObj->GetObjRef(), GetActiveWindow()));
944 
945         if ( !pSdClient )
946 		{
947 			pSdClient = new Client(pObj, this, GetActiveWindow());
948 		}
949 
950 		Rectangle aRect = pObj->GetLogicRect();
951 
952         {
953             // #i118485# center on BoundRect for activation,
954             // OLE may be sheared/rotated now
955         	const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
956             const Point aDelta(rBoundRect.Center() - aRect.Center());
957             aRect.Move(aDelta.X(), aDelta.Y());
958         }
959 
960         Size aDrawSize = aRect.GetSize();
961 
962 		MapMode aMapMode( GetDoc()->GetScaleUnit() );
963         Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
964         if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
965             aObjAreaSize = aDrawSize;
966 
967         Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
968         Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
969         aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
970         aScaleHeight.ReduceInaccurate(10);
971         pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
972 
973         // sichtbarer Ausschnitt wird nur inplace veraendert!
974         aRect.SetSize(aObjAreaSize);
975 		// the object area size must be set after scaling, since it triggers the resizing
976         pSdClient->SetObjArea(aRect);
977 
978         if( bChangeDefaultsForChart && xObj.is())
979         {
980             ChartHelper::AdaptDefaultsForChart( xObj );
981         }
982 
983         pSdClient->DoVerb(nVerb);   // ErrCode wird ggf. vom Sfx ausgegeben
984 		pViewShell->GetViewFrame()->GetBindings().Invalidate(
985             SID_NAVIGATOR_STATE, sal_True, sal_False);
986 	}
987 
988 	GetDocSh()->SetWaitCursor( sal_False );
989 
990 	if (aErrCode != 0 && !bAbort)
991 	{
992 		ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, String() ) );
993 	}
994 
995 	return aErrCode == 0;
996 }
997 
998 /*************************************************************************
999 |*
1000 |* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
1001 |*
1002 \************************************************************************/
1003 
GetAllWindowRect()1004 const Rectangle& ViewShell::GetAllWindowRect()
1005 {
1006 	maAllWindowRectangle.SetPos(
1007         mpContentWindow->OutputToScreenPixel(Point(0,0)));
1008 	return maAllWindowRectangle;
1009 }
1010 
1011 /*************************************************************************
1012 |*
1013 |* Read user data
1014 |*
1015 \************************************************************************/
ReadUserData(const String &)1016 void ViewShell::ReadUserData(const String&)
1017 {
1018 	// Auf an FrameView gemerkte VisArea zoomen
1019 	GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA,
1020         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1021 }
1022 
1023 /*************************************************************************
1024 |*
1025 |* Write user data
1026 |*
1027 \************************************************************************/
1028 
WriteUserData(String &)1029 void ViewShell::WriteUserData(String&)
1030 {
1031 	// Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
1032 	WriteFrameViewData();
1033 }
1034 
1035 
1036 /*************************************************************************
1037 |*
1038 |* Lineale ein- / ausschalten
1039 |*
1040 \************************************************************************/
1041 
SetRuler(sal_Bool bRuler)1042 void ViewShell::SetRuler(sal_Bool bRuler)
1043 {
1044     mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
1045 
1046     if (mpHorizontalRuler.get() != NULL)
1047     {
1048         if (mbHasRulers)
1049         {
1050             mpHorizontalRuler->Show();
1051         }
1052         else
1053         {
1054             mpHorizontalRuler->Hide();
1055         }
1056     }
1057 
1058     if (mpVerticalRuler.get() != NULL)
1059     {
1060         if (mbHasRulers)
1061         {
1062             mpVerticalRuler->Show();
1063         }
1064         else
1065         {
1066             mpVerticalRuler->Hide();
1067         }
1068     }
1069 
1070     OSL_ASSERT(GetViewShell()!=NULL);
1071     if (IsMainViewShell())
1072         GetViewShell()->InvalidateBorder();
1073 }
1074 
1075 /*************************************************************************
1076 |*
1077 |* AcceptDrop
1078 |*
1079 \************************************************************************/
1080 
AcceptDrop(const AcceptDropEvent & rEvt,DropTargetHelper & rTargetHelper,::sd::Window * pTargetWindow,sal_uInt16 nPage,sal_uInt16 nLayer)1081 sal_Int8 ViewShell::AcceptDrop (
1082     const AcceptDropEvent& rEvt,
1083     DropTargetHelper& rTargetHelper,
1084     ::sd::Window* pTargetWindow,
1085     sal_uInt16 nPage,
1086     sal_uInt16 nLayer)
1087 {
1088 	::sd::View* pView = GetView();
1089 	return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
1090 }
1091 
1092 /*************************************************************************
1093 |*
1094 |* ExecuteDrop
1095 |*
1096 \************************************************************************/
1097 
ExecuteDrop(const ExecuteDropEvent & rEvt,DropTargetHelper & rTargetHelper,::sd::Window * pTargetWindow,sal_uInt16 nPage,sal_uInt16 nLayer)1098 sal_Int8 ViewShell::ExecuteDrop (
1099     const ExecuteDropEvent& rEvt,
1100     DropTargetHelper& rTargetHelper,
1101     ::sd::Window* pTargetWindow,
1102     sal_uInt16 nPage,
1103     sal_uInt16 nLayer)
1104 {
1105 	::sd::View*	pView = GetView();
1106 	return( pView ? pView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
1107 }
1108 
1109 #ifdef _MSC_VER
1110 #pragma optimize ( "", on )
1111 #endif
1112 
WriteUserDataSequence(::com::sun::star::uno::Sequence<::com::sun::star::beans::PropertyValue> & rSequence,sal_Bool bBrowse)1113 void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence <
1114     ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse)
1115 {
1116 	const sal_Int32 nIndex = rSequence.getLength();
1117 	rSequence.realloc( nIndex + 1 );
1118 
1119     OSL_ASSERT (GetViewShell()!=NULL);
1120     // Get the view id from the view shell in the center pane.  This will
1121     // usually be the called view shell, but to be on the safe side we call
1122     // the main view shell explicitly.
1123     sal_uInt16 nViewID (IMPRESS_FACTORY_ID);
1124     if (GetViewShellBase().GetMainViewShell().get() != NULL)
1125         nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
1126 	rSequence[nIndex].Name = rtl::OUString (
1127         RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ViewId ) );
1128 	rtl::OUStringBuffer sBuffer (
1129         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1130 	sBuffer.append( static_cast<sal_Int32>(nViewID));
1131 	rSequence[nIndex].Value <<= sBuffer.makeStringAndClear();
1132 
1133 	mpFrameView->WriteUserDataSequence( rSequence, bBrowse );
1134 }
1135 
1136 
ReadUserDataSequence(const::com::sun::star::uno::Sequence<::com::sun::star::beans::PropertyValue> & rSequence,sal_Bool bBrowse)1137 void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1138 {
1139 	mpFrameView->ReadUserDataSequence( rSequence, bBrowse );
1140 }
1141 
VisAreaChanged(const Rectangle & rRect)1142 void ViewShell::VisAreaChanged(const Rectangle& rRect)
1143 {
1144     OSL_ASSERT (GetViewShell()!=NULL);
1145 	GetViewShell()->VisAreaChanged(rRect);
1146 }
1147 
SetWinViewPos(const Point & rWinPos,bool bUpdate)1148 void ViewShell::SetWinViewPos(const Point& rWinPos, bool bUpdate)
1149 {
1150     if (mpContentWindow.get() != NULL)
1151     {
1152         mpContentWindow->SetWinViewPos(rWinPos);
1153 
1154         if ( bUpdate )
1155         {
1156             mpContentWindow->UpdateMapOrigin();
1157             mpContentWindow->Invalidate();
1158         }
1159     }
1160 
1161 	if (mbHasRulers)
1162 	{
1163 		UpdateHRuler();
1164 		UpdateVRuler();
1165 	}
1166 
1167 	UpdateScrollBars();
1168 
1169 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1170 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
1171 	VisAreaChanged(aVisAreaWin);
1172 
1173 	::sd::View* pView = GetView();
1174 	if (pView)
1175 	{
1176 		pView->VisAreaChanged(GetActiveWindow());
1177 	}
1178 }
1179 
GetWinViewPos() const1180 Point ViewShell::GetWinViewPos() const
1181 {
1182 	return mpContentWindow->GetWinViewPos();
1183 }
1184 
GetViewOrigin() const1185 Point ViewShell::GetViewOrigin() const
1186 {
1187 	return mpContentWindow->GetViewOrigin();
1188 }
1189 
1190 } // end of namespace sd
1191