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