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