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