xref: /aoo41x/main/sd/source/ui/view/drviews3.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "DrawViewShell.hxx"
32 
33 #include <sfx2/viewfrm.hxx>
34 #include <editeng/eeitem.hxx>
35 #include <editeng/tstpitem.hxx>
36 #include <editeng/lrspitem.hxx>
37 #include <editeng/protitem.hxx>
38 #include <editeng/frmdiritem.hxx>
39 #include <svx/ruler.hxx>
40 #ifndef _SVX_RULERITEM_HXX
41 #include <svx/rulritem.hxx>
42 #endif
43 #include <svx/zoomitem.hxx>
44 #ifndef _SVXIDS_HRC
45 #include <svx/svxids.hrc>
46 #endif
47 #include <svx/svdpagv.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/dispatch.hxx>
50 #include <tools/urlobj.hxx>
51 #include <svl/aeitem.hxx>
52 #include <svl/eitem.hxx>
53 #include <svl/rectitem.hxx>
54 #include <svl/stritem.hxx>
55 #include <svx/svdoole2.hxx>
56 #include <svl/itempool.hxx>
57 #include <svl/ptitem.hxx>
58 #include <basic/sbstar.hxx>
59 #include <basic/sberrors.hxx>
60 #include <svx/fmshell.hxx>
61 #include <svx/f3dchild.hxx>
62 #include <svx/float3d.hxx>
63 #include "optsitem.hxx"
64 
65 #include "app.hrc"
66 #include "glob.hrc"
67 #include "strings.hrc"
68 #include "res_bmp.hrc"
69 
70 #include "sdundogr.hxx"
71 #include "undopage.hxx"
72 #include "glob.hxx"
73 #include "app.hxx"
74 #include "fupoor.hxx"
75 #include "slideshow.hxx"
76 #ifndef SD_FRAME_VIEW
77 #include "FrameView.hxx"
78 #endif
79 #include "sdpage.hxx"
80 #include "Window.hxx"
81 #include "sdresid.hxx"
82 #include "drawview.hxx"
83 #include "drawdoc.hxx"
84 #include "DrawViewShell.hxx"
85 #include "Ruler.hxx"
86 #include "DrawDocShell.hxx"
87 #include "headerfooterdlg.hxx"
88 #include "masterlayoutdlg.hxx"
89 #include "Ruler.hxx"
90 #include "DrawDocShell.hxx"
91 #include "sdabstdlg.hxx"
92 #include <sfx2/ipclient.hxx>
93 #include <tools/diagnose_ex.h>
94 #include "ViewShellBase.hxx"
95 #include "FormShellManager.hxx"
96 #include "LayerTabBar.hxx"
97 #include "sdabstdlg.hxx"
98 #include "sdpage.hxx"
99 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
100 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
101 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
102 #include <com/sun/star/frame/XFrame.hpp>
103 
104 using namespace ::com::sun::star::uno;
105 using namespace ::com::sun::star::drawing::framework;
106 using ::com::sun::star::frame::XFrame;
107 using ::com::sun::star::frame::XController;
108 
109 namespace sd {
110 
111 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
112 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
113 SO2_DECL_REF(SvInPlaceObject)
114 #endif
115 
116 
117 
118 /*************************************************************************
119 |*
120 |* SfxRequests fuer Controller bearbeiten
121 |*
122 \************************************************************************/
123 
124 void  DrawViewShell::ExecCtrl(SfxRequest& rReq)
125 {
126 	// waehrend einer Diashow wird nichts ausser dem Seitenwechsel und dem
127 	// Sprung zur Bookmark ausgefuehrt!
128 	if( HasCurrentFunction(SID_PRESENTATION) &&
129 		rReq.GetSlot() != SID_SWITCHPAGE &&
130 		rReq.GetSlot() != SID_JUMPTOMARK)
131 		return;
132 
133 	CheckLineTo (rReq);
134 
135     // End text edit mode for some requests.
136 	sal_uInt16 nSlot = rReq.GetSlot();
137     switch (nSlot)
138     {
139 		case SID_OUTPUT_QUALITY_COLOR:
140 		case SID_OUTPUT_QUALITY_GRAYSCALE:
141 		case SID_OUTPUT_QUALITY_BLACKWHITE:
142 		case SID_OUTPUT_QUALITY_CONTRAST:
143             // Do nothing.
144             break;
145         default:
146             if ( mpDrawView->IsTextEdit() )
147             {
148                 mpDrawView->SdrEndTextEdit();
149             }
150     }
151 
152     //	sal_uInt16 nSlot = rReq.GetSlot();
153 	switch (nSlot)
154 	{
155 		case SID_SWITCHPAGE:  // BASIC
156 		{
157 			sal_Bool bWasBasic = sal_False;
158 
159 			// switch page in running slide show
160 			if(SlideShow::IsRunning(GetViewShellBase()) && rReq.GetArgs())
161 			{
162 				SFX_REQUEST_ARG(rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, sal_False);
163 				SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber((sal_Int32)((pWhatPage->GetValue()-1)>>1));
164 			}
165 			else
166 			{
167 				const SfxItemSet *pArgs = rReq.GetArgs ();
168 				sal_uInt16 nSelectedPage = 0;
169 
170 				if (! pArgs)
171 				{
172 					nSelectedPage = maTabControl.GetCurPageId() - 1;
173 				}
174 				else if (pArgs->Count () == 2)
175 				{
176 					SFX_REQUEST_ARG (rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, sal_False);
177 					SFX_REQUEST_ARG (rReq, pWhatKind, SfxUInt32Item, ID_VAL_WHATKIND, sal_False);
178 
179 					sal_Int32 nWhatPage = (sal_Int32)pWhatPage->GetValue ();
180 					sal_Int32 nWhatKind = (sal_Int32)pWhatKind->GetValue ();
181 					if (! CHECK_RANGE (PK_STANDARD, nWhatKind, PK_HANDOUT))
182 					{
183 						StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
184 						rReq.Ignore ();
185 						break;
186 					}
187 					else if (meEditMode != EM_MASTERPAGE)
188 					{
189 						if (! CHECK_RANGE (0, nWhatPage, GetDoc()->GetSdPageCount((PageKind)nWhatKind)))
190 						{
191 							StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
192 							rReq.Ignore ();
193 							break;
194 						}
195 
196 						nSelectedPage = (short) nWhatPage;
197 						mePageKind	  = (PageKind) nWhatKind;
198 						bWasBasic	  = sal_True;
199 					}
200 				}
201 				else
202 				{
203 					StarBASIC::FatalError (SbERR_WRONG_ARGS);
204 					rReq.Ignore ();
205 					break;
206 				}
207 
208 
209 				if( GetDocSh() && (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED))
210 					GetDocSh()->SetModified();
211 
212 				SwitchPage(nSelectedPage);
213 
214 				if(HasCurrentFunction(SID_BEZIER_EDIT))
215 					GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
216 
217 				Invalidate();
218 				InvalidateWindows();
219 				rReq.Done ();
220 			}
221 			break;
222 		}
223 
224 		case SID_SWITCHLAYER:  // BASIC
225 		{
226 			const SfxItemSet *pArgs = rReq.GetArgs ();
227 			sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId ();
228 
229 			if( pArgs && pArgs->Count () == 1)
230 			{
231 				SFX_REQUEST_ARG (rReq, pWhatLayer, SfxUInt32Item, ID_VAL_WHATLAYER, sal_False);
232 				if( pWhatLayer )
233 					nCurPage = (short) pWhatLayer->GetValue ();
234 			}
235 
236 			mpDrawView->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage) );
237 			Invalidate();
238 			rReq.Done ();
239 
240 			break;
241 		}
242 
243 		case SID_PAGEMODE:	// BASIC
244 		{
245 
246 			const SfxItemSet *pArgs = rReq.GetArgs ();
247 
248 			if ( pArgs && pArgs->Count () == 2)
249 			{
250 				SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, ID_VAL_ISACTIVE, sal_False);
251 				SFX_REQUEST_ARG (rReq, pWhatKind, SfxUInt32Item, ID_VAL_WHATKIND, sal_False);
252 
253 				sal_Int32 nWhatKind = (sal_Int32)pWhatKind->GetValue ();
254 				if (CHECK_RANGE (PK_STANDARD, nWhatKind, PK_HANDOUT))
255 				{
256 					mbIsLayerModeActive = pIsActive->GetValue ();
257 					mePageKind = (PageKind) nWhatKind;
258 				}
259 			}
260 
261 			// Default-Layer der Page einschalten
262 			mpDrawView->SetActiveLayer( String( SdResId(STR_LAYER_LAYOUT) ) );
263 
264 			ChangeEditMode(EM_PAGE, mbIsLayerModeActive);
265 
266 			Invalidate();
267 			rReq.Done ();
268 
269 			break;
270 		}
271 
272 		case SID_LAYERMODE:  // BASIC
273 		{
274 			const SfxItemSet *pArgs = rReq.GetArgs ();
275 
276 			if ( pArgs && pArgs->Count () == 2)
277 			{
278 				SFX_REQUEST_ARG (rReq, pWhatLayerMode, SfxBoolItem, ID_VAL_ISACTIVE, sal_False);
279 				SFX_REQUEST_ARG (rReq, pWhatLayer, SfxUInt32Item, ID_VAL_WHATLAYER, sal_False);
280 
281 				sal_Int32 nWhatLayer = (sal_Int32)pWhatLayer->GetValue ();
282 				if (CHECK_RANGE (EM_PAGE, nWhatLayer, EM_MASTERPAGE))
283 				{
284 					mbIsLayerModeActive = pWhatLayerMode->GetValue ();
285 					meEditMode = (EditMode) nWhatLayer;
286 				}
287 			}
288 
289 			ChangeEditMode(meEditMode, !mbIsLayerModeActive);
290 
291 			Invalidate();
292 			rReq.Done ();
293 
294 			break;
295 		}
296 
297 		case SID_HEADER_AND_FOOTER:
298 		case SID_INSERT_PAGE_NUMBER:
299 		case SID_INSERT_DATE_TIME:
300 		{
301 			SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
302 			AbstractHeaderFooterDialog* pDlg = pFact ? pFact->CreateHeaderFooterDialog( (::ViewShell*)this, GetActiveWindow(), GetDoc(), mpActualPage ) : 0;
303 			if( pDlg )
304 			{
305 				pDlg->Execute();
306 				delete pDlg;
307 
308 				GetActiveWindow()->Invalidate();
309 				UpdatePreview( mpActualPage );
310 			}
311 
312 			Invalidate();
313 			rReq.Done ();
314 
315 			break;
316 		}
317 
318 		case SID_MASTER_LAYOUTS:
319 		{
320 			SdPage* pPage = GetActualPage();
321             if (meEditMode == EM_MASTERPAGE)
322                 // Use the master page of the current page.
323                 pPage = static_cast<SdPage*>(&pPage->TRG_GetMasterPage());
324 
325 			SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
326 			VclAbstractDialog* pDlg = pFact ? pFact->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage ) : 0;
327 			if( pDlg )
328 			{
329 				pDlg->Execute();
330 				delete pDlg;
331 				Invalidate();
332 			}
333 			rReq.Done ();
334 			break;
335 		}
336 		case SID_OBJECTRESIZE:
337 		{
338 			/******************************************************************
339 			* Der Server moechte die Clientgrosse verandern
340 			******************************************************************/
341             OSL_ASSERT (GetViewShell()!=NULL);
342             SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
343 
344             if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
345 			{
346 				const SfxRectangleItem& rRect =
347 					(SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
348 				Rectangle aRect( GetActiveWindow()->PixelToLogic( rRect.GetValue() ) );
349 
350 				if ( mpDrawView->AreObjectsMarked() )
351 				{
352 					const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
353 
354 					if (rMarkList.GetMarkCount() == 1)
355 					{
356 						SdrMark* pMark = rMarkList.GetMark(0);
357 						SdrObject* pObj = pMark->GetMarkedSdrObj();
358 
359 						SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( pObj );
360 						if(pOle2Obj)
361                         {
362                             if( pOle2Obj->GetObjRef().is() )
363                             {
364                                 pOle2Obj->SetLogicRect(aRect);
365                             }
366 						}
367 					}
368 				}
369             }
370 			rReq.Ignore ();
371 			break;
372 		}
373 
374 		case SID_RELOAD:
375 		{
376 			// #83951#
377 			sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
378             SfxViewFrame* pFrame = GetViewFrame();
379 
380             try
381             {
382                 Reference< XFrame > xFrame( pFrame->GetFrame().GetFrameInterface(), UNO_SET_THROW );
383 
384                 // Save the current configuration of panes and views.
385                 Reference<XControllerManager> xControllerManager (
386                     GetViewShellBase().GetController(), UNO_QUERY_THROW);
387                 Reference<XConfigurationController> xConfigurationController (
388                     xControllerManager->getConfigurationController(), UNO_QUERY_THROW );
389                 Reference<XConfiguration> xConfiguration (
390                     xConfigurationController->getRequestedConfiguration(), UNO_SET_THROW );
391 
392                 SfxChildWindow* pWindow = pFrame->GetChildWindow(nId);
393                 if(pWindow)
394                 {
395                     Svx3DWin* p3DWin = (Svx3DWin*)(pWindow->GetWindow());
396                     if(p3DWin)
397                         p3DWin->DocumentReload();
398                 }
399 
400                 // Normale Weiterleitung an ViewFrame zur Ausfuehrung
401                 GetViewFrame()->ExecuteSlot(rReq);
402 
403                 // From here on we must cope with this object and the frame already being
404                 // deleted.  Do not call any methods or use data members.
405                 Reference<XController> xController( xFrame->getController(), UNO_SET_THROW );
406 
407                 // Restore the configuration.
408                 xControllerManager = Reference<XControllerManager>( xController, UNO_QUERY_THROW);
409                 xConfigurationController = Reference<XConfigurationController>(
410                     xControllerManager->getConfigurationController());
411                 if ( ! xConfigurationController.is())
412                     throw RuntimeException();
413                 xConfigurationController->restoreConfiguration(xConfiguration);
414             }
415             catch (RuntimeException&)
416             {
417                 DBG_UNHANDLED_EXCEPTION();
418             }
419 
420 			// We have to return immediately to avoid accessing this object.
421 			return;
422 		}
423 
424 		case SID_JUMPTOMARK:
425 		{
426 			if( rReq.GetArgs() )
427 			{
428 				SFX_REQUEST_ARG(rReq, pBookmark, SfxStringItem, SID_JUMPTOMARK, sal_False);
429 
430 				if (pBookmark)
431 				{
432 					UniString sBookmark( INetURLObject::decode( pBookmark->GetValue(), '%', INetURLObject::DECODE_WITH_CHARSET ) );
433 
434 					rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
435 					if(xSlideshow.is() && xSlideshow->isRunning())
436 					{
437 						xSlideshow->jumpToBookmark(sBookmark);
438 					}
439 					else
440 					{
441 						GotoBookmark( sBookmark );
442 					}
443 				}
444 			}
445 			rReq.Done();
446 			break;
447 		}
448 
449 		case SID_OUTPUT_QUALITY_COLOR:
450 		case SID_OUTPUT_QUALITY_GRAYSCALE:
451 		case SID_OUTPUT_QUALITY_BLACKWHITE:
452 		case SID_OUTPUT_QUALITY_CONTRAST:
453 		{
454             ExecReq( rReq );
455 			break;
456 		}
457 
458 		case SID_MAIL_SCROLLBODY_PAGEDOWN:
459 		{
460             ExecReq( rReq );
461 			break;
462 		}
463 
464 		case SID_ATTR_YEAR2000:
465 		{
466             FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
467             if (pFormShell != NULL)
468             {
469                 const SfxPoolItem* pItem;
470                 if (rReq.GetArgs()->GetItemState(
471                     SID_ATTR_YEAR2000, sal_True, &pItem) == SFX_ITEM_SET)
472 					pFormShell->SetY2KState (
473                         static_cast<const SfxUInt16Item*>(pItem)->GetValue());
474             }
475 
476 			rReq.Done();
477 		}
478 		break;
479 
480 		case SID_OPT_LOCALE_CHANGED:
481 		{
482 			GetActiveWindow()->Invalidate();
483 			UpdatePreview( mpActualPage );
484 			rReq.Done();
485 		}
486 
487 		default:
488 		break;
489 	}
490 }
491 
492 /*************************************************************************
493 |*
494 |* SfxRequests fuer Lineale bearbeiten
495 |*
496 \************************************************************************/
497 
498 void  DrawViewShell::ExecRuler(SfxRequest& rReq)
499 {
500 	// waehrend einer Diashow wird nichts ausgefuehrt!
501 	if(HasCurrentFunction(SID_PRESENTATION))
502 		return;
503 
504 	CheckLineTo (rReq);
505 
506 	const SfxItemSet* pArgs = rReq.GetArgs();
507 	const Point aPagePos( GetActiveWindow()->GetViewOrigin() );
508 	Size aPageSize = mpActualPage->GetSize();
509 	Size aViewSize = GetActiveWindow()->GetViewSize();
510 	SdUndoGroup* pUndoGroup = NULL;
511 
512 	if ( rReq.GetSlot() == SID_ATTR_LONG_LRSPACE ||
513 		 rReq.GetSlot() == SID_ATTR_LONG_ULSPACE )
514 	{
515 		pUndoGroup = new SdUndoGroup(GetDoc());
516 		String aString(SdResId(STR_UNDO_CHANGE_PAGEBORDER));
517 		pUndoGroup->SetComment(aString);
518 	}
519 
520 	switch ( rReq.GetSlot() )
521 	{
522 		case SID_ATTR_LONG_LRSPACE:
523 		{
524 			const SvxLongLRSpaceItem& rLRSpace = (const SvxLongLRSpaceItem&)
525 					pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE));
526 
527 			if( mpDrawView->IsTextEdit() )
528 			{
529 				Rectangle aRect = maMarkRect;
530 				aRect.SetPos(aRect.TopLeft() + aPagePos);
531 				aRect.Left()  = rLRSpace.GetLeft();
532 				aRect.Right() = aViewSize.Width() - rLRSpace.GetRight();
533 				aRect.SetPos(aRect.TopLeft() - aPagePos);
534 				if ( aRect != maMarkRect)
535 				{
536 					mpDrawView->SetAllMarkedRect(aRect);
537 					maMarkRect = mpDrawView->GetAllMarkedRect();
538 					Invalidate( SID_RULER_OBJECT );
539 				}
540 			}
541 			else
542 			{
543 				long nLeft = Max(0L, rLRSpace.GetLeft() - aPagePos.X());
544 				long nRight = Max(0L, rLRSpace.GetRight() + aPagePos.X() +
545 								  	aPageSize.Width() - aViewSize.Width());
546 
547 				sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
548 				sal_uInt16 i;
549 				for ( i = 0; i < nPageCnt; i++)
550 				{
551 					SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
552 					SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(),
553 											pPage,
554 											pPage->GetLftBorder(),
555 											pPage->GetRgtBorder(),
556 											nLeft, nRight);
557 					pUndoGroup->AddAction(pUndo);
558 					pPage->SetLftBorder(nLeft);
559 					pPage->SetRgtBorder(nRight);
560 				}
561 				nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
562 
563 				for (i = 0; i < nPageCnt; i++)
564 				{
565 					SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
566 					SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(),
567 											pPage,
568 											pPage->GetLftBorder(),
569 											pPage->GetRgtBorder(),
570 											nLeft, nRight);
571 					pUndoGroup->AddAction(pUndo);
572 					pPage->SetLftBorder(nLeft);
573 					pPage->SetRgtBorder(nRight);
574 				}
575 				InvalidateWindows();
576 			}
577 			break;
578 		}
579 		case SID_ATTR_LONG_ULSPACE:
580 		{
581             const SvxLongULSpaceItem& rULSpace = (const SvxLongULSpaceItem&)
582                     pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE));
583 
584 			if( mpDrawView->IsTextEdit() )
585 			{
586 				Rectangle aRect = maMarkRect;
587 				aRect.SetPos(aRect.TopLeft() + aPagePos);
588                 aRect.Top()  = rULSpace.GetUpper();
589                 aRect.Bottom() = aViewSize.Height() - rULSpace.GetLower();
590 				aRect.SetPos(aRect.TopLeft() - aPagePos);
591 
592                 if ( aRect != maMarkRect)
593 				{
594 					mpDrawView->SetAllMarkedRect(aRect);
595 					maMarkRect = mpDrawView->GetAllMarkedRect();
596 					Invalidate( SID_RULER_OBJECT );
597 				}
598 			}
599 			else
600 			{
601                 long nUpper = Max(0L, rULSpace.GetUpper() - aPagePos.Y());
602                 long nLower = Max(0L, rULSpace.GetLower() + aPagePos.Y() +
603                                       aPageSize.Height() - aViewSize.Height());
604 
605                 sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
606                 sal_uInt16 i;
607                 for ( i = 0; i < nPageCnt; i++)
608                 {
609                     SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
610                     SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(),
611                                             pPage,
612                                             pPage->GetUppBorder(),
613                                             pPage->GetLwrBorder(),
614                                             nUpper, nLower);
615                     pUndoGroup->AddAction(pUndo);
616                     pPage->SetUppBorder(nUpper);
617                     pPage->SetLwrBorder(nLower);
618                 }
619                 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
620 
621                 for (i = 0; i < nPageCnt; i++)
622                 {
623                     SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
624                     SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(),
625                                             pPage,
626                                             pPage->GetUppBorder(),
627                                             pPage->GetLwrBorder(),
628                                             nUpper, nLower);
629                     pUndoGroup->AddAction(pUndo);
630                     pPage->SetUppBorder(nUpper);
631                     pPage->SetLwrBorder(nLower);
632                 }
633                 InvalidateWindows();
634             }
635 			break;
636 		}
637 
638 		case SID_RULER_OBJECT:
639 		{
640 			Rectangle aRect = maMarkRect;
641 			aRect.SetPos(aRect.TopLeft() + aPagePos);
642 
643 			const SvxObjectItem& rOI = (const SvxObjectItem&)
644 					pArgs->Get(GetPool().GetWhich(SID_RULER_OBJECT));
645 
646 			if ( rOI.GetStartX() != rOI.GetEndX() )
647 			{
648 				aRect.Left()  = rOI.GetStartX();
649 				aRect.Right() = rOI.GetEndX();
650 			}
651 			if ( rOI.GetStartY() != rOI.GetEndY() )
652 			{
653 				aRect.Top()    = rOI.GetStartY();
654 				aRect.Bottom() = rOI.GetEndY();
655 			}
656 			aRect.SetPos(aRect.TopLeft() - aPagePos);
657 			if ( aRect != maMarkRect)
658 			{
659 				mpDrawView->SetAllMarkedRect(aRect);
660 				maMarkRect = mpDrawView->GetAllMarkedRect();
661 				Invalidate( SID_RULER_OBJECT );
662 			}
663 			break;
664 		}
665 
666 		case SID_ATTR_TABSTOP:
667 		{
668 			if( mpDrawView->IsTextEdit() )
669 			{
670 				const SvxTabStopItem& rItem = (const SvxTabStopItem&)
671                             pArgs->Get( EE_PARA_TABS );
672 
673                 SfxItemSet aEditAttr( GetPool(), EE_PARA_TABS, EE_PARA_TABS );
674 
675 				aEditAttr.Put( rItem );
676 				mpDrawView->SetAttributes( aEditAttr );
677 
678 				// #91081# Invalidate is missing here
679 				Invalidate(SID_ATTR_TABSTOP);
680 			}
681 			break;
682 		}
683 
684 		case SID_ATTR_PARA_LRSPACE:
685 		{
686 			if( mpDrawView->IsTextEdit() )
687 			{
688 				sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
689 				const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
690 							pArgs->Get( nId );
691 
692                 SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
693 
694                 nId = EE_PARA_LRSPACE;
695 				SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
696 						rItem.GetRight(), rItem.GetTxtLeft(),
697 						rItem.GetTxtFirstLineOfst(), nId );
698 				aEditAttr.Put( aLRSpaceItem );
699 				mpDrawView->SetAttributes( aEditAttr );
700 
701 				// #92557# Invalidate is missing here
702 				Invalidate(SID_ATTR_PARA_LRSPACE);
703 			}
704 			break;
705 		}
706 	}
707 	if ( pUndoGroup )
708 		// Undo Gruppe dem Undo Manager uebergeben
709 		GetViewFrame()->GetObjectShell()->GetUndoManager()->
710 											AddUndoAction(pUndoGroup);
711 }
712 
713 /*************************************************************************
714 |*
715 |* Statuswerte der Lineale bestimmen
716 |*
717 \************************************************************************/
718 void  DrawViewShell::GetRulerState(SfxItemSet& rSet)
719 {
720 	Point aOrigin;
721 
722 	if (mpDrawView->GetSdrPageView())
723 	{
724 		aOrigin = mpDrawView->GetSdrPageView()->GetPageOrigin();
725 	}
726 
727 	Size aViewSize = GetActiveWindow()->GetViewSize();
728 
729 	const Point aPagePos( GetActiveWindow()->GetViewOrigin() );
730 	Size aPageSize = mpActualPage->GetSize();
731 
732 	Rectangle aRect(aPagePos, Point( aViewSize.Width() - (aPagePos.X() + aPageSize.Width()),
733 	        	                     aViewSize.Height() - (aPagePos.Y() + aPageSize.Height())));
734 
735 	if( mpDrawView->IsTextEdit() )
736 	{
737 		Point aPnt1 = GetActiveWindow()->GetWinViewPos();
738 		Point aPnt2 = GetActiveWindow()->GetViewOrigin();
739 		Rectangle aMinMaxRect = Rectangle( aPnt1, Size(ULONG_MAX, ULONG_MAX) );
740 		rSet.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX, aMinMaxRect) );
741 	}
742 	else
743 	{
744 		rSet.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX, aRect) );
745 	}
746 
747     SvxLongLRSpaceItem aLRSpace(aPagePos.X() + mpActualPage->GetLftBorder(),
748 								aRect.Right() + mpActualPage->GetRgtBorder(),
749 								GetPool().GetWhich(SID_ATTR_LONG_LRSPACE));
750 	SvxLongULSpaceItem aULSpace(aPagePos.Y() + mpActualPage->GetUppBorder(),
751 								aRect.Bottom() + mpActualPage->GetLwrBorder(),
752 								GetPool().GetWhich(SID_ATTR_LONG_ULSPACE));
753 	rSet.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos, aViewSize.Width(),
754 													   aViewSize.Height()));
755 	SfxPointItem aPointItem( SID_RULER_NULL_OFFSET, aPagePos + aOrigin );
756 
757 	SvxProtectItem aProtect( SID_RULER_PROTECT );
758 
759 	maMarkRect = mpDrawView->GetAllMarkedRect();
760 
761 	const sal_Bool bRTL = GetDoc() && GetDoc()->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
762 	rSet.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT, bRTL));
763 
764 	if( mpDrawView->AreObjectsMarked() )
765 	{
766 		if( mpDrawView->IsTextEdit() )
767 		{
768 			SdrObject* pObj = mpDrawView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
769 			if( pObj->GetObjInventor() == SdrInventor)
770 			{
771 				SfxItemSet aEditAttr( GetDoc()->GetPool() );
772 				mpDrawView->GetAttributes( aEditAttr );
773                 if( aEditAttr.GetItemState( EE_PARA_TABS ) >= SFX_ITEM_AVAILABLE )
774 				{
775                     const SvxTabStopItem& rItem = (const SvxTabStopItem&) aEditAttr.Get( EE_PARA_TABS );
776 					rSet.Put( rItem );
777 
778 					//Rectangle aRect = maMarkRect;
779 
780                     const SvxLRSpaceItem& rLRSpaceItem = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
781 					sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
782 					SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(),
783 							rLRSpaceItem.GetRight(), rLRSpaceItem.GetTxtLeft(),
784 							rLRSpaceItem.GetTxtFirstLineOfst(), nId );
785 					rSet.Put( aLRSpaceItem );
786 
787 					Point aPos( aPagePos + maMarkRect.TopLeft() );
788 
789 					if ( aEditAttr.GetItemState( SDRATTR_TEXT_LEFTDIST ) == SFX_ITEM_ON )
790 					{
791 						const SdrTextLeftDistItem& rTLDItem = (const SdrTextLeftDistItem&)
792 															  aEditAttr.Get( SDRATTR_TEXT_LEFTDIST );
793 						long nLD = rTLDItem.GetValue();
794 						aPos.X() += nLD;
795 					}
796 
797 					aPointItem.SetValue( aPos );
798 
799 					aLRSpace.SetLeft( aPagePos.X() + maMarkRect.Left() );
800 
801 					if ( aEditAttr.GetItemState( SDRATTR_TEXT_LEFTDIST ) == SFX_ITEM_ON )
802 					{
803 						const SdrTextLeftDistItem& rTLDItem = (const SdrTextLeftDistItem&)
804 															  aEditAttr.Get( SDRATTR_TEXT_LEFTDIST );
805 						long nLD = rTLDItem.GetValue();
806 						aLRSpace.SetLeft( aLRSpace.GetLeft() + nLD );
807 					}
808 
809 					aLRSpace.SetRight( aRect.Right() + aPageSize.Width() - maMarkRect.Right() );
810 					aULSpace.SetUpper( aPagePos.Y() + maMarkRect.Top() );
811 					aULSpace.SetLower( aRect.Bottom() + aPageSize.Height() - maMarkRect.Bottom() );
812 
813 					rSet.DisableItem( SID_RULER_OBJECT );
814 
815 					// Seitenraender werden gelocked
816 					aProtect.SetSizeProtect( sal_True );
817 					aProtect.SetPosProtect( sal_True );
818 				}
819 
820 				if( aEditAttr.GetItemState( EE_PARA_WRITINGDIR ) >= SFX_ITEM_AVAILABLE )
821 				{
822 					const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR );
823 					rSet.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT, rItem.GetValue() == ::com::sun::star::text::WritingMode_RL_TB));
824 				}
825 			}
826 		}
827 		else
828 		{
829             rSet.DisableItem( EE_PARA_TABS );
830 			rSet.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT );
831 
832 			if( mpDrawView->IsResizeAllowed(sal_True) )
833 			{
834 				Rectangle aResizeRect( maMarkRect );
835 
836 				aResizeRect.SetPos(aResizeRect.TopLeft() + aPagePos);
837 				SvxObjectItem aObjItem(aResizeRect.Left(), aResizeRect.Right(),
838 									   aResizeRect.Top(), aResizeRect.Bottom());
839 				rSet.Put(aObjItem);
840                 rSet.DisableItem( EE_PARA_TABS );
841 			}
842 			else
843 			{
844 				rSet.DisableItem( SID_RULER_OBJECT );
845 			}
846 		}
847 	}
848 	else
849 	{
850 		rSet.DisableItem( SID_RULER_OBJECT );
851         rSet.DisableItem( EE_PARA_TABS );
852 //		rSet.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT );
853 	}
854 
855 	rSet.Put( aLRSpace );
856 	rSet.Put( aULSpace );
857 
858 	rSet.Put( aPointItem );
859 	rSet.Put( aProtect );
860 }
861 
862 /*************************************************************************
863 |*
864 |* SfxRequests fuer StatusBar bearbeiten
865 |*
866 \************************************************************************/
867 
868 void  DrawViewShell::ExecStatusBar(SfxRequest& rReq)
869 {
870 	// waehrend einer Diashow wird nichts ausgefuehrt!
871 	if(HasCurrentFunction(SID_PRESENTATION))
872 		return;
873 
874 	CheckLineTo (rReq);
875 
876 	switch ( rReq.GetSlot() )
877 	{
878 		case SID_ATTR_SIZE:
879 		{
880 			GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM, SFX_CALLMODE_ASYNCHRON );
881 		}
882 		break;
883 
884 		case SID_STATUS_LAYOUT:
885 		{
886 			GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT, SFX_CALLMODE_ASYNCHRON );
887 		}
888 		break;
889 	}
890 }
891 
892 /*************************************************************************
893 |*
894 |* Status der Snap-Objekt-Eintraege im Popup setzen
895 |*
896 \************************************************************************/
897 
898 void  DrawViewShell::GetSnapItemState( SfxItemSet &rSet )
899 {
900 	SdrPageView* pPV;
901 	Point	aMPos = GetActiveWindow()->PixelToLogic(maMousePos);
902 	sal_uInt16	nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
903         Size(FuPoor::HITPIX,0)).Width();
904 	sal_uInt16	nHelpLine;
905 
906 	if ( mpDrawView->PickHelpLine(aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
907 	{
908 		const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
909 
910 		if ( rHelpLine.GetKind() == SDRHELPLINE_POINT )
911 		{
912 			rSet.Put( SfxStringItem( SID_SET_SNAPITEM,
913 								String( SdResId( STR_POPUP_EDIT_SNAPPOINT))) );
914 			rSet.Put( SfxStringItem( SID_DELETE_SNAPITEM,
915 								String( SdResId( STR_POPUP_DELETE_SNAPPOINT))) );
916 		}
917 		else
918 		{
919 			rSet.Put( SfxStringItem( SID_SET_SNAPITEM,
920 								String( SdResId( STR_POPUP_EDIT_SNAPLINE))) );
921 			rSet.Put( SfxStringItem( SID_DELETE_SNAPITEM,
922 								String( SdResId( STR_POPUP_DELETE_SNAPLINE))) );
923 		}
924 	}
925 }
926 
927 
928 /*************************************************************************
929 |*
930 |*
931 |*
932 \************************************************************************/
933 
934 void DrawViewShell::AddWindow (::sd::Window* pWin)
935 {
936 	mpDrawView->AddWindowToPaintView(pWin);
937 }
938 
939 /*************************************************************************
940 |*
941 |*
942 |*
943 \************************************************************************/
944 
945 void DrawViewShell::RemoveWindow(::sd::Window* pWin)
946 {
947 	mpDrawView->DeleteWindowFromPaintView(pWin);
948 }
949 
950 } // end of namespace sd
951