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