1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "DrawViewShell.hxx"
23 #include <sfx2/viewfrm.hxx>
24 #include <editeng/eeitem.hxx>
25 #include <editeng/tstpitem.hxx>
26 #include <editeng/lrspitem.hxx>
27 #include <editeng/protitem.hxx>
28 #include <editeng/frmdiritem.hxx>
29 #include <editeng/adjustitem.hxx>
30 #include <svx/ruler.hxx>
31 #include <editeng/numitem.hxx>
32 #include <svx/rulritem.hxx>
33 #include <sfx2/zoomitem.hxx>
34 #include <svx/svxids.hrc>
35 #include <svx/svdpagv.hxx>
36 #include <sfx2/request.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <tools/urlobj.hxx>
39 #include <svl/aeitem.hxx>
40 #include <svl/eitem.hxx>
41 #include <svl/rectitem.hxx>
42 #include <svl/stritem.hxx>
43 #include <svx/svdoole2.hxx>
44 #include <svl/itempool.hxx>
45 #include <svl/ptitem.hxx>
46 #include <basic/sbstar.hxx>
47 #include <basic/sberrors.hxx>
48 #include <svx/fmshell.hxx>
49 #include <svx/f3dchild.hxx>
50 #include <svx/float3d.hxx>
51 #include "optsitem.hxx"
55 #include "strings.hrc"
56 #include "res_bmp.hrc"
58 #include "sdundogr.hxx"
59 #include "undopage.hxx"
63 #include "slideshow.hxx"
65 #include "FrameView.hxx"
69 #include "sdresid.hxx"
70 #include "drawview.hxx"
71 #include "drawdoc.hxx"
73 #include "DrawDocShell.hxx"
74 #include "headerfooterdlg.hxx"
75 #include "masterlayoutdlg.hxx"
76 #include "sdabstdlg.hxx"
77 #include <sfx2/ipclient.hxx>
78 #include <tools/diagnose_ex.h>
79 #include "ViewShellBase.hxx"
80 #include "FormShellManager.hxx"
81 #include "LayerTabBar.hxx"
82 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
83 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
84 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
85 #include <com/sun/star/frame/XFrame.hpp>
86 #include <editeng/lspcitem.hxx>
87 #include <editeng/ulspitem.hxx>
88 using namespace ::com::sun::star::uno
;
89 using namespace ::com::sun::star::drawing::framework
;
90 using ::com::sun::star::frame::XFrame
;
91 using ::com::sun::star::frame::XController
;
96 * handle SfxRequests for controller
98 void DrawViewShell::ExecCtrl(SfxRequest
& rReq
)
100 // except a page switch and jumps to bookmarks, nothing is executed during
102 if( HasCurrentFunction(SID_PRESENTATION
) &&
103 rReq
.GetSlot() != SID_SWITCHPAGE
&&
104 rReq
.GetSlot() != SID_JUMPTOMARK
)
109 // End text edit mode for some requests.
110 sal_uInt16 nSlot
= rReq
.GetSlot();
113 case SID_OUTPUT_QUALITY_COLOR
:
114 case SID_OUTPUT_QUALITY_GRAYSCALE
:
115 case SID_OUTPUT_QUALITY_BLACKWHITE
:
116 case SID_OUTPUT_QUALITY_CONTRAST
:
120 if ( mpDrawView
->IsTextEdit() )
122 mpDrawView
->SdrEndTextEdit();
126 // sal_uInt16 nSlot = rReq.GetSlot();
129 case SID_SWITCHPAGE
: // BASIC
131 // switch page in running slide show
132 if(SlideShow::IsRunning(GetViewShellBase()) && rReq
.GetArgs())
134 SFX_REQUEST_ARG(rReq
, pWhatPage
, SfxUInt32Item
, ID_VAL_WHATPAGE
, sal_False
);
135 SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber((sal_Int32
)((pWhatPage
->GetValue()-1)>>1));
139 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
140 sal_uInt16 nSelectedPage
= 0;
144 nSelectedPage
= maTabControl
.GetCurPageId() - 1;
146 else if (pArgs
->Count () == 2)
148 SFX_REQUEST_ARG (rReq
, pWhatPage
, SfxUInt32Item
, ID_VAL_WHATPAGE
, sal_False
);
149 SFX_REQUEST_ARG (rReq
, pWhatKind
, SfxUInt32Item
, ID_VAL_WHATKIND
, sal_False
);
151 sal_Int32 nWhatPage
= (sal_Int32
)pWhatPage
->GetValue ();
152 sal_Int32 nWhatKind
= (sal_Int32
)pWhatKind
->GetValue ();
153 if (! CHECK_RANGE (PK_STANDARD
, nWhatKind
, PK_HANDOUT
))
155 #ifndef DISABLE_SCRIPTING
156 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
161 else if (meEditMode
!= EM_MASTERPAGE
)
163 if (! CHECK_RANGE (0, nWhatPage
, GetDoc()->GetSdPageCount((PageKind
)nWhatKind
)))
165 #ifndef DISABLE_SCRIPTING
166 StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
172 nSelectedPage
= (short) nWhatPage
;
173 mePageKind
= (PageKind
) nWhatKind
;
178 #ifndef DISABLE_SCRIPTING
179 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
186 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
))
187 GetDocSh()->SetModified();
189 SwitchPage(nSelectedPage
);
191 if(HasCurrentFunction(SID_BEZIER_EDIT
))
192 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_ASYNCHRON
);
201 case SID_SWITCHLAYER
: // BASIC
203 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
204 sal_uInt16 nCurPage
= GetLayerTabControl()->GetCurPageId ();
206 if( pArgs
&& pArgs
->Count () == 1)
208 SFX_REQUEST_ARG (rReq
, pWhatLayer
, SfxUInt32Item
, ID_VAL_WHATLAYER
, sal_False
);
210 nCurPage
= (short) pWhatLayer
->GetValue ();
213 mpDrawView
->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage
) );
220 case SID_PAGEMODE
: // BASIC
223 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
225 if ( pArgs
&& pArgs
->Count () == 2)
227 SFX_REQUEST_ARG (rReq
, pIsActive
, SfxBoolItem
, ID_VAL_ISACTIVE
, sal_False
);
228 SFX_REQUEST_ARG (rReq
, pWhatKind
, SfxUInt32Item
, ID_VAL_WHATKIND
, sal_False
);
230 sal_Int32 nWhatKind
= (sal_Int32
)pWhatKind
->GetValue ();
231 if (CHECK_RANGE (PK_STANDARD
, nWhatKind
, PK_HANDOUT
))
233 mbIsLayerModeActive
= pIsActive
->GetValue ();
234 mePageKind
= (PageKind
) nWhatKind
;
238 // turn on default layer of page
239 mpDrawView
->SetActiveLayer( String( SdResId(STR_LAYER_LAYOUT
) ) );
241 ChangeEditMode(EM_PAGE
, mbIsLayerModeActive
);
249 case SID_LAYERMODE
: // BASIC
251 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
253 if ( pArgs
&& pArgs
->Count () == 2)
255 SFX_REQUEST_ARG (rReq
, pWhatLayerMode
, SfxBoolItem
, ID_VAL_ISACTIVE
, sal_False
);
256 SFX_REQUEST_ARG (rReq
, pWhatLayer
, SfxUInt32Item
, ID_VAL_WHATLAYER
, sal_False
);
258 sal_Int32 nWhatLayer
= (sal_Int32
)pWhatLayer
->GetValue ();
259 if (CHECK_RANGE (EM_PAGE
, nWhatLayer
, EM_MASTERPAGE
))
261 mbIsLayerModeActive
= pWhatLayerMode
->GetValue ();
262 meEditMode
= (EditMode
) nWhatLayer
;
266 ChangeEditMode(meEditMode
, !mbIsLayerModeActive
);
274 case SID_HEADER_AND_FOOTER
:
275 case SID_INSERT_PAGE_NUMBER
:
276 case SID_INSERT_DATE_TIME
:
278 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
279 AbstractHeaderFooterDialog
* pDlg
= pFact
? pFact
->CreateHeaderFooterDialog( (::ViewShell
*)this, GetActiveWindow(), GetDoc(), mpActualPage
) : 0;
285 GetActiveWindow()->Invalidate();
286 UpdatePreview( mpActualPage
);
295 case SID_MASTER_LAYOUTS
:
297 SdPage
* pPage
= GetActualPage();
298 if (meEditMode
== EM_MASTERPAGE
)
299 // Use the master page of the current page.
300 pPage
= static_cast<SdPage
*>(&pPage
->TRG_GetMasterPage());
302 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
303 VclAbstractDialog
* pDlg
= pFact
? pFact
->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage
) : 0;
313 case SID_OBJECTRESIZE
:
315 // The server likes to change the client size
316 OSL_ASSERT (GetViewShell()!=NULL
);
317 SfxInPlaceClient
* pIPClient
= GetViewShell()->GetIPClient();
319 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
321 const SfxRectangleItem
& rRect
=
322 (SfxRectangleItem
&)rReq
.GetArgs()->Get(SID_OBJECTRESIZE
);
323 Rectangle
aRect( GetActiveWindow()->PixelToLogic( rRect
.GetValue() ) );
325 if ( mpDrawView
->AreObjectsMarked() )
327 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
329 if (rMarkList
.GetMarkCount() == 1)
331 SdrMark
* pMark
= rMarkList
.GetMark(0);
332 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
334 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
337 if( pOle2Obj
->GetObjRef().is() )
339 pOle2Obj
->SetLogicRect(aRect
);
351 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
352 SfxViewFrame
* pFrame
= GetViewFrame();
356 Reference
< XFrame
> xFrame( pFrame
->GetFrame().GetFrameInterface(), UNO_SET_THROW
);
358 // Save the current configuration of panes and views.
359 Reference
<XControllerManager
> xControllerManager (
360 GetViewShellBase().GetController(), UNO_QUERY_THROW
);
361 Reference
<XConfigurationController
> xConfigurationController (
362 xControllerManager
->getConfigurationController(), UNO_QUERY_THROW
);
363 Reference
<XConfiguration
> xConfiguration (
364 xConfigurationController
->getRequestedConfiguration(), UNO_SET_THROW
);
366 SfxChildWindow
* pWindow
= pFrame
->GetChildWindow(nId
);
369 Svx3DWin
* p3DWin
= (Svx3DWin
*)(pWindow
->GetWindow());
371 p3DWin
->DocumentReload();
374 // normal forwarding to ViewFrame for execution
375 GetViewFrame()->ExecuteSlot(rReq
);
377 // From here on we must cope with this object and the frame already being
378 // deleted. Do not call any methods or use data members.
379 Reference
<XController
> xController( xFrame
->getController(), UNO_SET_THROW
);
381 // Restore the configuration.
382 xControllerManager
= Reference
<XControllerManager
>( xController
, UNO_QUERY_THROW
);
383 xConfigurationController
= Reference
<XConfigurationController
>(
384 xControllerManager
->getConfigurationController());
385 if ( ! xConfigurationController
.is())
386 throw RuntimeException();
387 xConfigurationController
->restoreConfiguration(xConfiguration
);
389 catch (RuntimeException
&)
391 DBG_UNHANDLED_EXCEPTION();
394 // We have to return immediately to avoid accessing this object.
402 SFX_REQUEST_ARG(rReq
, pBookmark
, SfxStringItem
, SID_JUMPTOMARK
, sal_False
);
406 OUString
sBookmark(INetURLObject::decode(pBookmark
->GetValue(), '%', INetURLObject::DECODE_WITH_CHARSET
));
408 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
409 if(xSlideshow
.is() && xSlideshow
->isRunning())
411 xSlideshow
->jumpToBookmark(sBookmark
);
415 GotoBookmark(sBookmark
);
423 case SID_OUTPUT_QUALITY_COLOR
:
424 case SID_OUTPUT_QUALITY_GRAYSCALE
:
425 case SID_OUTPUT_QUALITY_BLACKWHITE
:
426 case SID_OUTPUT_QUALITY_CONTRAST
:
432 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
438 case SID_ATTR_YEAR2000
:
440 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
441 if (pFormShell
!= NULL
)
443 const SfxPoolItem
* pItem
;
444 if (rReq
.GetArgs()->GetItemState(
445 SID_ATTR_YEAR2000
, sal_True
, &pItem
) == SFX_ITEM_SET
)
446 pFormShell
->SetY2KState (
447 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
454 case SID_OPT_LOCALE_CHANGED
:
456 GetActiveWindow()->Invalidate();
457 UpdatePreview( mpActualPage
);
467 void DrawViewShell::ExecRuler(SfxRequest
& rReq
)
469 // nothing is executed during a slide show!
470 if(HasCurrentFunction(SID_PRESENTATION
))
475 const SfxItemSet
* pArgs
= rReq
.GetArgs();
476 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
477 Size aPageSize
= mpActualPage
->GetSize();
478 Size aViewSize
= GetActiveWindow()->GetViewSize();
479 SdUndoGroup
* pUndoGroup
= NULL
;
481 if ( rReq
.GetSlot() == SID_ATTR_LONG_LRSPACE
||
482 rReq
.GetSlot() == SID_ATTR_LONG_ULSPACE
)
484 pUndoGroup
= new SdUndoGroup(GetDoc());
485 String
aString(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
486 pUndoGroup
->SetComment(aString
);
489 switch ( rReq
.GetSlot() )
491 case SID_ATTR_LONG_LRSPACE
:
493 const SvxLongLRSpaceItem
& rLRSpace
= (const SvxLongLRSpaceItem
&)
494 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
));
496 if( mpDrawView
->IsTextEdit() )
498 Rectangle aRect
= maMarkRect
;
499 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
500 aRect
.Left() = rLRSpace
.GetLeft();
501 aRect
.Right() = aViewSize
.Width() - rLRSpace
.GetRight();
502 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
503 if ( aRect
!= maMarkRect
)
505 mpDrawView
->SetAllMarkedRect(aRect
);
506 maMarkRect
= mpDrawView
->GetAllMarkedRect();
507 Invalidate( SID_RULER_OBJECT
);
512 long nLeft
= std::max(0L, rLRSpace
.GetLeft() - aPagePos
.X());
513 long nRight
= std::max(0L, rLRSpace
.GetRight() + aPagePos
.X() +
514 aPageSize
.Width() - aViewSize
.Width());
516 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
518 for ( i
= 0; i
< nPageCnt
; i
++)
520 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
521 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
523 pPage
->GetLftBorder(),
524 pPage
->GetRgtBorder(),
526 pUndoGroup
->AddAction(pUndo
);
527 pPage
->SetLftBorder(nLeft
);
528 pPage
->SetRgtBorder(nRight
);
530 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
532 for (i
= 0; i
< nPageCnt
; i
++)
534 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
535 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
537 pPage
->GetLftBorder(),
538 pPage
->GetRgtBorder(),
540 pUndoGroup
->AddAction(pUndo
);
541 pPage
->SetLftBorder(nLeft
);
542 pPage
->SetRgtBorder(nRight
);
548 case SID_ATTR_LONG_ULSPACE
:
550 const SvxLongULSpaceItem
& rULSpace
= (const SvxLongULSpaceItem
&)
551 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
));
553 if( mpDrawView
->IsTextEdit() )
555 Rectangle aRect
= maMarkRect
;
556 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
557 aRect
.Top() = rULSpace
.GetUpper();
558 aRect
.Bottom() = aViewSize
.Height() - rULSpace
.GetLower();
559 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
561 if ( aRect
!= maMarkRect
)
563 mpDrawView
->SetAllMarkedRect(aRect
);
564 maMarkRect
= mpDrawView
->GetAllMarkedRect();
565 Invalidate( SID_RULER_OBJECT
);
570 long nUpper
= std::max(0L, rULSpace
.GetUpper() - aPagePos
.Y());
571 long nLower
= std::max(0L, rULSpace
.GetLower() + aPagePos
.Y() +
572 aPageSize
.Height() - aViewSize
.Height());
574 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
576 for ( i
= 0; i
< nPageCnt
; i
++)
578 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
579 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
581 pPage
->GetUppBorder(),
582 pPage
->GetLwrBorder(),
584 pUndoGroup
->AddAction(pUndo
);
585 pPage
->SetUppBorder(nUpper
);
586 pPage
->SetLwrBorder(nLower
);
588 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
590 for (i
= 0; i
< nPageCnt
; i
++)
592 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
593 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
595 pPage
->GetUppBorder(),
596 pPage
->GetLwrBorder(),
598 pUndoGroup
->AddAction(pUndo
);
599 pPage
->SetUppBorder(nUpper
);
600 pPage
->SetLwrBorder(nLower
);
607 case SID_RULER_OBJECT
:
609 Rectangle aRect
= maMarkRect
;
610 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
612 const SvxObjectItem
& rOI
= (const SvxObjectItem
&)
613 pArgs
->Get(GetPool().GetWhich(SID_RULER_OBJECT
));
615 if ( rOI
.GetStartX() != rOI
.GetEndX() )
617 aRect
.Left() = rOI
.GetStartX();
618 aRect
.Right() = rOI
.GetEndX();
620 if ( rOI
.GetStartY() != rOI
.GetEndY() )
622 aRect
.Top() = rOI
.GetStartY();
623 aRect
.Bottom() = rOI
.GetEndY();
625 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
626 if ( aRect
!= maMarkRect
)
628 mpDrawView
->SetAllMarkedRect(aRect
);
629 maMarkRect
= mpDrawView
->GetAllMarkedRect();
630 Invalidate( SID_RULER_OBJECT
);
635 case SID_ATTR_TABSTOP
:
637 if( mpDrawView
->IsTextEdit() )
639 const SvxTabStopItem
& rItem
= (const SvxTabStopItem
&)
640 pArgs
->Get( EE_PARA_TABS
);
642 SfxItemSet
aEditAttr( GetPool(), EE_PARA_TABS
, EE_PARA_TABS
);
644 aEditAttr
.Put( rItem
);
645 mpDrawView
->SetAttributes( aEditAttr
);
647 Invalidate(SID_ATTR_TABSTOP
);
652 case SID_ATTR_PARA_LINESPACE
:
654 sal_uInt16 nSlot
= SID_ATTR_PARA_LINESPACE
;
655 SvxLineSpacingItem aParaLineSP
= (const SvxLineSpacingItem
&)pArgs
->Get(
656 GetPool().GetWhich(nSlot
));
658 SfxItemSet
aEditAttr( GetPool(), EE_PARA_SBL
, EE_PARA_SBL
);
659 aParaLineSP
.SetWhich( EE_PARA_SBL
);
661 aEditAttr
.Put( aParaLineSP
);
662 mpDrawView
->SetAttributes( aEditAttr
);
664 Invalidate(SID_ATTR_PARA_LINESPACE
);
667 case SID_ATTR_PARA_ADJUST_LEFT
:
669 SvxAdjustItem
aItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
);
670 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
672 aEditAttr
.Put( aItem
);
673 mpDrawView
->SetAttributes( aEditAttr
);
675 Invalidate(SID_ATTR_PARA_ADJUST_LEFT
);
678 case SID_ATTR_PARA_ADJUST_CENTER
:
680 SvxAdjustItem
aItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
);
681 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
683 aEditAttr
.Put( aItem
);
684 mpDrawView
->SetAttributes( aEditAttr
);
686 Invalidate(SID_ATTR_PARA_ADJUST_CENTER
);
689 case SID_ATTR_PARA_ADJUST_RIGHT
:
691 SvxAdjustItem
aItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
);
692 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
694 aEditAttr
.Put( aItem
);
695 mpDrawView
->SetAttributes( aEditAttr
);
697 Invalidate(SID_ATTR_PARA_ADJUST_RIGHT
);
700 case SID_ATTR_PARA_ADJUST_BLOCK
:
702 SvxAdjustItem
aItem( SVX_ADJUST_BLOCK
, EE_PARA_JUST
);
703 SfxItemSet
aEditAttr( GetPool(), EE_PARA_JUST
, EE_PARA_JUST
);
705 aEditAttr
.Put( aItem
);
706 mpDrawView
->SetAttributes( aEditAttr
);
708 Invalidate(SID_ATTR_PARA_ADJUST_BLOCK
);
711 case SID_ATTR_PARA_ULSPACE
:
713 sal_uInt16 nSlot
= SID_ATTR_PARA_ULSPACE
;
714 SvxULSpaceItem aULSP
= (const SvxULSpaceItem
&)pArgs
->Get(
715 GetPool().GetWhich(nSlot
));
716 SfxItemSet
aEditAttr( GetPool(), EE_PARA_ULSPACE
, EE_PARA_ULSPACE
);
717 aULSP
.SetWhich( EE_PARA_ULSPACE
);
719 aEditAttr
.Put( aULSP
);
720 mpDrawView
->SetAttributes( aEditAttr
);
722 Invalidate(SID_ATTR_PARA_ULSPACE
);
726 case SID_ATTR_PARA_LRSPACE
:
728 sal_uInt16 nSlot
= SID_ATTR_PARA_LRSPACE
;
729 SvxLRSpaceItem aLRSpace
= (const SvxLRSpaceItem
&)pArgs
->Get(
730 GetPool().GetWhich(nSlot
));
732 SfxItemSet
aEditAttr( GetPool(), EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
733 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
735 aEditAttr
.Put( aLRSpace
);
736 mpDrawView
->SetAttributes( aEditAttr
);
738 Invalidate(SID_ATTR_PARA_LRSPACE
);
741 case SID_ATTR_LRSPACE
:
743 if( mpDrawView
->IsTextEdit() )
745 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
746 const SvxLRSpaceItem
& rItem
= (const SvxLRSpaceItem
&)
749 static const sal_uInt16 aWhichTable
[]=
751 EE_PARA_OUTLLEVEL
, EE_PARA_OUTLLEVEL
,
752 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
,
753 EE_PARA_NUMBULLET
, EE_PARA_NUMBULLET
,
757 SfxItemSet
aEditAttr( GetDoc()->GetPool(),
759 mpDrawView
->GetAttributes( aEditAttr
);
761 nId
= EE_PARA_LRSPACE
;
762 SvxLRSpaceItem
aLRSpaceItem( rItem
.GetLeft(),
763 rItem
.GetRight(), rItem
.GetTxtLeft(),
764 rItem
.GetTxtFirstLineOfst(), nId
);
766 const sal_Int16 nOutlineLevel
= ((const SfxInt16Item
&)aEditAttr
.Get( EE_PARA_OUTLLEVEL
)).GetValue();
767 const SvxLRSpaceItem
& rOrigLRSpaceItem
= (const SvxLRSpaceItem
&) aEditAttr
.Get( EE_PARA_LRSPACE
);
768 const SvxNumBulletItem
& rNumBulletItem
= (const SvxNumBulletItem
&) aEditAttr
.Get( EE_PARA_NUMBULLET
);
769 if( nOutlineLevel
!= -1 &&
770 rNumBulletItem
.GetNumRule() &&
771 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
773 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
774 SvxNumberFormat
aFormat(rFormat
);
776 // left margin gets distributed onto LRSpace item
777 // and number format AbsLSpace - this fixes
778 // n#707779 (previously, LRSpace left indent could
779 // become negative - EditEngine really does not
781 const short nAbsLSpace
=aFormat
.GetAbsLSpace();
782 const long nTxtLeft
=rItem
.GetTxtLeft();
783 const long nLeftIndent
=std::max(0L,nTxtLeft
- nAbsLSpace
);
784 aLRSpaceItem
.SetTxtLeft(nLeftIndent
);
785 // control for clipped left indent - remainder
786 // reduces number format first line indent
787 aFormat
.SetAbsLSpace(nTxtLeft
- nLeftIndent
);
789 // negative first line indent goes to the number
790 // format, positive to the lrSpace item
791 if( rItem
.GetTxtFirstLineOfst() < 0 )
793 aFormat
.SetFirstLineOffset(
794 rItem
.GetTxtFirstLineOfst()
795 - rOrigLRSpaceItem
.GetTxtFirstLineOfst()
796 + aFormat
.GetCharTextDistance());
797 aLRSpaceItem
.SetTxtFirstLineOfst(0);
801 aFormat
.SetFirstLineOffset(0);
802 aLRSpaceItem
.SetTxtFirstLineOfst(
803 rItem
.GetTxtFirstLineOfst()
804 - aFormat
.GetFirstLineOffset()
805 + aFormat
.GetCharTextDistance());
808 if( rFormat
!= aFormat
)
811 SvxNumBulletItem
aNumBulletItem(rNumBulletItem
);
812 aNumBulletItem
.GetNumRule()->SetLevel(nOutlineLevel
,aFormat
);
813 aEditAttr
.Put( aNumBulletItem
);
814 aEditAttr
.Put( aLRSpaceItem
);
815 mpDrawView
->SetAttributes( aEditAttr
);
817 Invalidate(SID_ATTR_PARA_LRSPACE
);
822 // only put lrSpace item
823 SfxItemSet
aEditAttrReduced( GetDoc()->GetPool(),
824 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
);
825 aEditAttrReduced
.Put( aLRSpaceItem
);
826 mpDrawView
->SetAttributes( aEditAttrReduced
);
828 Invalidate(SID_ATTR_PARA_LRSPACE
);
834 // give the undo group to the undo manager
835 GetViewFrame()->GetObjectShell()->GetUndoManager()->
836 AddUndoAction(pUndoGroup
);
840 void DrawViewShell::GetRulerState(SfxItemSet
& rSet
)
844 if (mpDrawView
->GetSdrPageView())
846 aOrigin
= mpDrawView
->GetSdrPageView()->GetPageOrigin();
849 Size aViewSize
= GetActiveWindow()->GetViewSize();
851 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
852 Size aPageSize
= mpActualPage
->GetSize();
854 Rectangle
aRect(aPagePos
, Point( aViewSize
.Width() - (aPagePos
.X() + aPageSize
.Width()),
855 aViewSize
.Height() - (aPagePos
.Y() + aPageSize
.Height())));
857 if( mpDrawView
->IsTextEdit() )
859 Point aPnt1
= GetActiveWindow()->GetWinViewPos();
860 Rectangle aMinMaxRect
= Rectangle( aPnt1
, Size(ULONG_MAX
, ULONG_MAX
) );
861 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aMinMaxRect
) );
865 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aRect
) );
868 SvxLongLRSpaceItem
aLRSpace(aPagePos
.X() + mpActualPage
->GetLftBorder(),
869 aRect
.Right() + mpActualPage
->GetRgtBorder(),
870 GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
));
871 SvxLongULSpaceItem
aULSpace(aPagePos
.Y() + mpActualPage
->GetUppBorder(),
872 aRect
.Bottom() + mpActualPage
->GetLwrBorder(),
873 GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
));
874 rSet
.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos
, aViewSize
.Width(),
875 aViewSize
.Height()));
876 SfxPointItem
aPointItem( SID_RULER_NULL_OFFSET
, aPagePos
+ aOrigin
);
878 SvxProtectItem
aProtect( SID_RULER_PROTECT
);
880 maMarkRect
= mpDrawView
->GetAllMarkedRect();
882 const sal_Bool bRTL
= GetDoc() && GetDoc()->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB
;
883 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, bRTL
));
885 if( mpDrawView
->AreObjectsMarked() )
887 if( mpDrawView
->IsTextEdit() )
889 SdrObject
* pObj
= mpDrawView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
890 if( pObj
->GetObjInventor() == SdrInventor
)
892 SfxItemSet
aEditAttr( GetDoc()->GetPool() );
893 mpDrawView
->GetAttributes( aEditAttr
);
894 if( aEditAttr
.GetItemState( EE_PARA_TABS
) >= SFX_ITEM_AVAILABLE
)
896 const SvxTabStopItem
& rItem
= (const SvxTabStopItem
&) aEditAttr
.Get( EE_PARA_TABS
);
899 const SvxLRSpaceItem
& rLRSpaceItem
= (const SvxLRSpaceItem
&) aEditAttr
.Get( EE_PARA_LRSPACE
);
900 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
901 SvxLRSpaceItem
aLRSpaceItem( rLRSpaceItem
.GetLeft(),
902 rLRSpaceItem
.GetRight(), rLRSpaceItem
.GetTxtLeft(),
903 rLRSpaceItem
.GetTxtFirstLineOfst(), nId
);
905 const sal_Int16 nOutlineLevel
= ((const SfxInt16Item
&)aEditAttr
.Get( EE_PARA_OUTLLEVEL
)).GetValue();
906 const SvxNumBulletItem
& rNumBulletItem
= (const SvxNumBulletItem
&) aEditAttr
.Get( EE_PARA_NUMBULLET
);
907 if( nOutlineLevel
!= -1 &&
908 rNumBulletItem
.GetNumRule() &&
909 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
911 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
912 aLRSpaceItem
.SetTxtLeft(rFormat
.GetAbsLSpace() + rLRSpaceItem
.GetTxtLeft());
913 aLRSpaceItem
.SetTxtFirstLineOfst(
914 rLRSpaceItem
.GetTxtFirstLineOfst() + rFormat
.GetFirstLineOffset()
915 - rFormat
.GetCharTextDistance());
918 rSet
.Put( aLRSpaceItem
);
920 Point
aPos( aPagePos
+ maMarkRect
.TopLeft() );
922 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SFX_ITEM_ON
)
924 const SdrTextLeftDistItem
& rTLDItem
= (const SdrTextLeftDistItem
&)
925 aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
926 long nLD
= rTLDItem
.GetValue();
930 aPointItem
.SetValue( aPos
);
932 aLRSpace
.SetLeft( aPagePos
.X() + maMarkRect
.Left() );
934 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SFX_ITEM_ON
)
936 const SdrTextLeftDistItem
& rTLDItem
= (const SdrTextLeftDistItem
&)
937 aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
938 long nLD
= rTLDItem
.GetValue();
939 aLRSpace
.SetLeft( aLRSpace
.GetLeft() + nLD
);
942 aLRSpace
.SetRight( aRect
.Right() + aPageSize
.Width() - maMarkRect
.Right() );
943 aULSpace
.SetUpper( aPagePos
.Y() + maMarkRect
.Top() );
944 aULSpace
.SetLower( aRect
.Bottom() + aPageSize
.Height() - maMarkRect
.Bottom() );
946 rSet
.DisableItem( SID_RULER_OBJECT
);
949 aProtect
.SetSizeProtect( sal_True
);
950 aProtect
.SetPosProtect( sal_True
);
953 if( aEditAttr
.GetItemState( EE_PARA_WRITINGDIR
) >= SFX_ITEM_AVAILABLE
)
955 const SvxFrameDirectionItem
& rItem
= (const SvxFrameDirectionItem
&) aEditAttr
.Get( EE_PARA_WRITINGDIR
);
956 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, rItem
.GetValue() == ::com::sun::star::text::WritingMode_RL_TB
));
962 rSet
.DisableItem( EE_PARA_TABS
);
963 rSet
.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT
);
965 if( mpDrawView
->IsResizeAllowed(sal_True
) )
967 Rectangle
aResizeRect( maMarkRect
);
969 aResizeRect
.SetPos(aResizeRect
.TopLeft() + aPagePos
);
970 SvxObjectItem
aObjItem(aResizeRect
.Left(), aResizeRect
.Right(),
971 aResizeRect
.Top(), aResizeRect
.Bottom());
973 rSet
.DisableItem( EE_PARA_TABS
);
977 rSet
.DisableItem( SID_RULER_OBJECT
);
983 rSet
.DisableItem( SID_RULER_OBJECT
);
984 rSet
.DisableItem( EE_PARA_TABS
);
987 rSet
.Put( aLRSpace
);
988 rSet
.Put( aULSpace
);
990 rSet
.Put( aPointItem
);
991 rSet
.Put( aProtect
);
995 void DrawViewShell::ExecStatusBar(SfxRequest
& rReq
)
997 // nothing is executed during a slide show!
998 if(HasCurrentFunction(SID_PRESENTATION
))
1003 switch ( rReq
.GetSlot() )
1007 GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM
, SFX_CALLMODE_ASYNCHRON
);
1011 case SID_STATUS_LAYOUT
:
1013 GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT
, SFX_CALLMODE_ASYNCHRON
);
1020 * set state of snap object entries in popup
1022 void DrawViewShell::GetSnapItemState( SfxItemSet
&rSet
)
1025 Point aMPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
1026 sal_uInt16 nHitLog
= (sal_uInt16
) GetActiveWindow()->PixelToLogic(
1027 Size(FuPoor::HITPIX
,0)).Width();
1028 sal_uInt16 nHelpLine
;
1030 if ( mpDrawView
->PickHelpLine(aMPos
, nHitLog
, *GetActiveWindow(), nHelpLine
, pPV
) )
1032 const SdrHelpLine
& rHelpLine
= (pPV
->GetHelpLines())[nHelpLine
];
1034 if ( rHelpLine
.GetKind() == SDRHELPLINE_POINT
)
1036 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1037 String( SdResId( STR_POPUP_EDIT_SNAPPOINT
))) );
1038 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1039 String( SdResId( STR_POPUP_DELETE_SNAPPOINT
))) );
1043 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1044 String( SdResId( STR_POPUP_EDIT_SNAPLINE
))) );
1045 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1046 String( SdResId( STR_POPUP_DELETE_SNAPLINE
))) );
1051 void DrawViewShell::AddWindow (::sd::Window
* pWin
)
1053 mpDrawView
->AddWindowToPaintView(pWin
);
1056 void DrawViewShell::RemoveWindow(::sd::Window
* pWin
)
1058 mpDrawView
->DeleteWindowFromPaintView(pWin
);
1061 } // end of namespace sd
1063 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */