xref: /trunk/main/sd/source/ui/view/viewshe2.cxx (revision 5b190011)
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     bool bChangeDefaultsForChart = false;
836 
837     uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
838     if ( !xObj.is() )
839 	{
840 		/**********************************************************
841 		* Leeres OLE-Objekt mit OLE-Objekt versehen
842 		**********************************************************/
843 		String aName = pObj->GetProgName();
844         ::rtl::OUString aObjName;
845         SvGlobalName aClass;
846 
847         if( aName.EqualsAscii( "StarChart" ) || aName.EqualsAscii("StarOrg") )
848 		{
849 			if( SvtModuleOptions().IsChart() )
850             {
851                 aClass = SvGlobalName( SO3_SCH_CLASSID );
852                 bChangeDefaultsForChart = true;
853             }
854 		}
855 		else if( aName.EqualsAscii( "StarCalc" ))
856 		{
857 			if( SvtModuleOptions().IsCalc() )
858                 aClass = SvGlobalName( SO3_SC_CLASSID );
859 		}
860 		else if( aName.EqualsAscii( "StarMath" ))
861 		{
862 			if( SvtModuleOptions().IsMath() )
863                 aClass = SvGlobalName( SO3_SM_CLASSID );
864 		}
865 
866         if ( aClass != SvGlobalName() )
867             xObj = GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass.GetByteSequence(), aObjName );
868 
869         if( !xObj.is() )
870 		{
871 			aName = String();
872 
873 			// Dialog "OLE-Objekt einfuegen" aufrufen
874 			GetDocSh()->SetWaitCursor( sal_False );
875 			pViewShell->GetViewFrame()->GetDispatcher()->Execute(
876                 SID_INSERT_OBJECT,
877                 SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
878             xObj = pObj->GetObjRef();
879 			GetDocSh()->SetWaitCursor( sal_True );
880 
881             if (!xObj.is())
882 			{
883 				bAbort = sal_True;
884 			}
885 		}
886 
887         if ( xObj.is() )
888 		{
889 			/******************************************************
890 			* OLE-Objekt ist nicht mehr leer
891 			******************************************************/
892 			pObj->SetEmptyPresObj(sal_False);
893 			pObj->SetOutlinerParaObject(NULL);
894 			pObj->SetGraphic(NULL);
895 
896 			/******************************************************
897 			* Das leere OLE-Objekt bekommt ein neues IPObj
898 			******************************************************/
899 			if (aName.Len())
900 			{
901                 pObj->SetObjRef(xObj);
902 				pObj->SetName(aObjName);
903     			pObj->SetPersistName(aObjName);
904 			}
905 			else
906 			{
907 				// Das Einfuegen hat der Dialog schon gemacht
908                 pObj->SetObjRef(xObj);
909 			}
910 
911 			Rectangle aRect = pObj->GetLogicRect();
912 
913 			if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
914 			{
915             	awt::Size aSz;
916             	aSz.Width = aRect.GetWidth();
917             	aSz.Height = aRect.GetHeight();
918             	xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
919 			}
920 
921             GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
922 
923 			nVerb = SVVERB_SHOW;
924 		}
925 		else
926 		{
927 			aErrCode = ERRCODE_SFX_OLEGENERAL;
928 		}
929 	}
930 
931 	if( aErrCode == 0 )
932 	{
933 		::sd::View* pView = GetView();
934 
935 		if (pView->IsTextEdit())
936 		{
937 			pView->SdrEndTextEdit();
938 		}
939 
940         SfxInPlaceClient* pSdClient =
941             static_cast<Client*>(pViewShell->FindIPClient(
942                 pObj->GetObjRef(), GetActiveWindow()));
943 
944         if ( !pSdClient )
945 		{
946 			pSdClient = new Client(pObj, this, GetActiveWindow());
947 		}
948 
949 		Rectangle aRect = pObj->GetLogicRect();
950 
951         {
952             // #i118485# center on BoundRect for activation,
953             // OLE may be sheared/rotated now
954         	const Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
955             const Point aDelta(rBoundRect.Center() - aRect.Center());
956             aRect.Move(aDelta.X(), aDelta.Y());
957         }
958 
959         Size aDrawSize = aRect.GetSize();
960 
961 		MapMode aMapMode( GetDoc()->GetScaleUnit() );
962         Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
963         if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
964             aObjAreaSize = aDrawSize;
965 
966         Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
967         Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
968         aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
969         aScaleHeight.ReduceInaccurate(10);
970         pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
971 
972         // sichtbarer Ausschnitt wird nur inplace veraendert!
973         aRect.SetSize(aObjAreaSize);
974 		// the object area size must be set after scaling, since it triggers the resizing
975         pSdClient->SetObjArea(aRect);
976 
977         if( bChangeDefaultsForChart && xObj.is())
978         {
979             AdaptDefaultsForChart( xObj );
980         }
981 
982         pSdClient->DoVerb(nVerb);   // ErrCode wird ggf. vom Sfx ausgegeben
983 		pViewShell->GetViewFrame()->GetBindings().Invalidate(
984             SID_NAVIGATOR_STATE, sal_True, sal_False);
985 	}
986 
987 	GetDocSh()->SetWaitCursor( sal_False );
988 
989 	if (aErrCode != 0 && !bAbort)
990 	{
991 		ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, String() ) );
992 	}
993 
994 	return aErrCode == 0;
995 }
996 
997 /*************************************************************************
998 |*
999 |* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
1000 |*
1001 \************************************************************************/
1002 
1003 const Rectangle& ViewShell::GetAllWindowRect()
1004 {
1005 	maAllWindowRectangle.SetPos(
1006         mpContentWindow->OutputToScreenPixel(Point(0,0)));
1007 	return maAllWindowRectangle;
1008 }
1009 
1010 /*************************************************************************
1011 |*
1012 |* Read user data
1013 |*
1014 \************************************************************************/
1015 void ViewShell::ReadUserData(const String&)
1016 {
1017 	// Auf an FrameView gemerkte VisArea zoomen
1018 	GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA,
1019         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
1020 }
1021 
1022 /*************************************************************************
1023 |*
1024 |* Write user data
1025 |*
1026 \************************************************************************/
1027 
1028 void ViewShell::WriteUserData(String&)
1029 {
1030 	// Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
1031 	WriteFrameViewData();
1032 }
1033 
1034 
1035 /*************************************************************************
1036 |*
1037 |* Lineale ein- / ausschalten
1038 |*
1039 \************************************************************************/
1040 
1041 void ViewShell::SetRuler(sal_Bool bRuler)
1042 {
1043     mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
1044 
1045     if (mpHorizontalRuler.get() != NULL)
1046     {
1047         if (mbHasRulers)
1048         {
1049             mpHorizontalRuler->Show();
1050         }
1051         else
1052         {
1053             mpHorizontalRuler->Hide();
1054         }
1055     }
1056 
1057     if (mpVerticalRuler.get() != NULL)
1058     {
1059         if (mbHasRulers)
1060         {
1061             mpVerticalRuler->Show();
1062         }
1063         else
1064         {
1065             mpVerticalRuler->Hide();
1066         }
1067     }
1068 
1069     OSL_ASSERT(GetViewShell()!=NULL);
1070     if (IsMainViewShell())
1071         GetViewShell()->InvalidateBorder();
1072 }
1073 
1074 /*************************************************************************
1075 |*
1076 |* AcceptDrop
1077 |*
1078 \************************************************************************/
1079 
1080 sal_Int8 ViewShell::AcceptDrop (
1081     const AcceptDropEvent& rEvt,
1082     DropTargetHelper& rTargetHelper,
1083     ::sd::Window* pTargetWindow,
1084     sal_uInt16 nPage,
1085     sal_uInt16 nLayer)
1086 {
1087 	::sd::View* pView = GetView();
1088 	return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
1089 }
1090 
1091 /*************************************************************************
1092 |*
1093 |* ExecuteDrop
1094 |*
1095 \************************************************************************/
1096 
1097 sal_Int8 ViewShell::ExecuteDrop (
1098     const ExecuteDropEvent& rEvt,
1099     DropTargetHelper& rTargetHelper,
1100     ::sd::Window* pTargetWindow,
1101     sal_uInt16 nPage,
1102     sal_uInt16 nLayer)
1103 {
1104 	::sd::View*	pView = GetView();
1105 	return( pView ? pView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
1106 }
1107 
1108 #ifdef _MSC_VER
1109 #pragma optimize ( "", on )
1110 #endif
1111 
1112 void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence <
1113     ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse)
1114 {
1115 	const sal_Int32 nIndex = rSequence.getLength();
1116 	rSequence.realloc( nIndex + 1 );
1117 
1118     OSL_ASSERT (GetViewShell()!=NULL);
1119     // Get the view id from the view shell in the center pane.  This will
1120     // usually be the called view shell, but to be on the safe side we call
1121     // the main view shell explicitly.
1122     sal_uInt16 nViewID (IMPRESS_FACTORY_ID);
1123     if (GetViewShellBase().GetMainViewShell().get() != NULL)
1124         nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
1125 	rSequence[nIndex].Name = rtl::OUString (
1126         RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ViewId ) );
1127 	rtl::OUStringBuffer sBuffer (
1128         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1129 	sBuffer.append( static_cast<sal_Int32>(nViewID));
1130 	rSequence[nIndex].Value <<= sBuffer.makeStringAndClear();
1131 
1132 	mpFrameView->WriteUserDataSequence( rSequence, bBrowse );
1133 }
1134 
1135 
1136 void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1137 {
1138 	mpFrameView->ReadUserDataSequence( rSequence, bBrowse );
1139 }
1140 
1141 void ViewShell::VisAreaChanged(const Rectangle& rRect)
1142 {
1143     OSL_ASSERT (GetViewShell()!=NULL);
1144 	GetViewShell()->VisAreaChanged(rRect);
1145 }
1146 
1147 void ViewShell::SetWinViewPos(const Point& rWinPos, bool bUpdate)
1148 {
1149     if (mpContentWindow.get() != NULL)
1150     {
1151         mpContentWindow->SetWinViewPos(rWinPos);
1152 
1153         if ( bUpdate )
1154         {
1155             mpContentWindow->UpdateMapOrigin();
1156             mpContentWindow->Invalidate();
1157         }
1158     }
1159 
1160 	if (mbHasRulers)
1161 	{
1162 		UpdateHRuler();
1163 		UpdateVRuler();
1164 	}
1165 
1166 	UpdateScrollBars();
1167 
1168 	Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1169 	Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
1170 	VisAreaChanged(aVisAreaWin);
1171 
1172 	::sd::View* pView = GetView();
1173 	if (pView)
1174 	{
1175 		pView->VisAreaChanged(GetActiveWindow());
1176 	}
1177 }
1178 
1179 Point ViewShell::GetWinViewPos() const
1180 {
1181 	return mpContentWindow->GetWinViewPos();
1182 }
1183 
1184 Point ViewShell::GetViewOrigin() const
1185 {
1186 	return mpContentWindow->GetViewOrigin();
1187 }
1188 
1189 void ViewShell::AdaptDefaultsForChart(
1190     const uno::Reference < embed::XEmbeddedObject > & xEmbObj )
1191 {
1192     if( xEmbObj.is())
1193     {
1194         uno::Reference< chart2::XChartDocument > xChartDoc( xEmbObj->getComponent(), uno::UNO_QUERY );
1195         OSL_ENSURE( xChartDoc.is(), "Trying to set chart property to non-chart OLE" );
1196         if( !xChartDoc.is())
1197             return;
1198 
1199         try
1200         {
1201             // set background to transparent (none)
1202             uno::Reference< beans::XPropertySet > xPageProp( xChartDoc->getPageBackground());
1203             if( xPageProp.is())
1204                 xPageProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FillStyle")),
1205                                              uno::makeAny( drawing::FillStyle_NONE ));
1206             // set no border
1207             if( xPageProp.is())
1208                 xPageProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")),
1209                                              uno::makeAny( drawing::LineStyle_NONE ));
1210         }
1211         catch( const uno::Exception & )
1212         {
1213             OSL_ENSURE( false, "Exception caught in AdaptDefaultsForChart" );
1214         }
1215     }
1216 }
1217 
1218 } // end of namespace sd
1219