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