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 .
20 #include <config_features.h>
22 #include <DrawViewShell.hxx>
23 #include <DrawController.hxx>
25 #include <sfx2/viewfrm.hxx>
26 #include <editeng/eeitem.hxx>
27 #include <editeng/tstpitem.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <editeng/protitem.hxx>
30 #include <editeng/frmdiritem.hxx>
31 #include <editeng/adjustitem.hxx>
32 #include <svx/svdotable.hxx>
33 #include <editeng/numitem.hxx>
34 #include <svx/rulritem.hxx>
35 #include <svx/svxids.hrc>
36 #include <svx/svdpagv.hxx>
37 #include <sfx2/request.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <tools/urlobj.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 <svx/sdmetitm.hxx>
52 #include <svx/svdogrp.hxx>
53 #include <svx/diagram/IDiagramHelper.hxx>
56 #include <strings.hrc>
58 #include <sdundogr.hxx>
59 #include <undopage.hxx>
61 #include <slideshow.hxx>
64 #include <sdresid.hxx>
65 #include <unokywds.hxx>
66 #include <drawview.hxx>
67 #include <drawdoc.hxx>
68 #include <DrawDocShell.hxx>
69 #include <sdabstdlg.hxx>
70 #include <sfx2/ipclient.hxx>
71 #include <comphelper/diagnose_ex.hxx>
72 #include <ViewShellBase.hxx>
73 #include <FormShellManager.hxx>
74 #include <LayerTabBar.hxx>
75 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
76 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
77 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
78 #include <com/sun/star/drawing/XShape.hpp>
79 #include <com/sun/star/frame/XFrame.hpp>
80 #include <editeng/lspcitem.hxx>
81 #include <editeng/ulspitem.hxx>
83 #include <comphelper/processfactory.hxx>
84 #include <oox/drawingml/diagram/diagram.hxx>
85 #include <oox/export/drawingml.hxx>
86 #include <oox/shape/ShapeFilterBase.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();
111 bool bAllowFocusChange
= true;
114 case SID_OUTPUT_QUALITY_COLOR
:
115 case SID_OUTPUT_QUALITY_GRAYSCALE
:
116 case SID_OUTPUT_QUALITY_BLACKWHITE
:
117 case SID_OUTPUT_QUALITY_CONTRAST
:
121 if (rReq
.GetArgs() && rReq
.GetArgs()->Count () == 1)
123 const SfxBoolItem
* pAllowFocusChange
= rReq
.GetArg
<SfxBoolItem
>(SID_SWITCHPAGE
);
124 bAllowFocusChange
= pAllowFocusChange
->GetValue();
125 if (!bAllowFocusChange
)
130 if ( mpDrawView
->IsTextEdit() )
132 mpDrawView
->SdrEndTextEdit();
136 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
137 // sal_uInt16 nSlot = rReq.GetSlot();
140 case SID_SWITCHPAGE
: // BASIC
142 // switch page in running slide show
143 if(SlideShow::IsRunning(GetViewShellBase())
144 && !SlideShow::IsInteractiveSlideshow(&GetViewShellBase()) // IASS
147 if (const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
))
148 SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber(static_cast<sal_Int32
>((pWhatPage
->GetValue()-1)>>1));
152 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
153 sal_uInt16 nSelectedPage
= 0;
155 if (! pArgs
|| pArgs
->Count () == 1)
157 nSelectedPage
= maTabControl
->GetCurPagePos();
159 else if (pArgs
->Count () == 2)
161 const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
);
162 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
164 sal_Int32 nWhatPage
= static_cast<sal_Int32
>(pWhatPage
->GetValue ());
165 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue ());
166 if (nWhatKind
< PageKind::Standard
|| nWhatKind
> PageKind::Handout
)
168 #if HAVE_FEATURE_SCRIPTING
169 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
174 else if (meEditMode
!= EditMode::MasterPage
)
176 if (! CHECK_RANGE (0, nWhatPage
, GetDoc()->GetSdPageCount(nWhatKind
)))
178 #if HAVE_FEATURE_SCRIPTING
179 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
185 nSelectedPage
= static_cast<short>(nWhatPage
);
186 mePageKind
= nWhatKind
;
191 #if HAVE_FEATURE_SCRIPTING
192 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS
);
198 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
))
199 GetDocSh()->SetModified();
201 SwitchPage(nSelectedPage
, bAllowFocusChange
);
203 if(HasCurrentFunction(SID_BEZIER_EDIT
))
204 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
213 case SID_SWITCHLAYER
: // BASIC
215 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
218 bool bCurPageValid(false);
219 sal_uInt16
nCurPage(0);
221 if(GetLayerTabControl())
223 nCurPage
= GetLayerTabControl()->GetCurPageId();
224 bCurPageValid
= true;
227 if(pArgs
&& 1 == pArgs
->Count())
229 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
233 nCurPage
= static_cast<short>(pWhatLayer
->GetValue());
234 bCurPageValid
= true;
240 OUString
aLayerName( GetLayerTabControl()->GetLayerName(nCurPage
));
241 if (!aLayerName
.isEmpty())
243 mpDrawView
->SetActiveLayer(aLayerName
);
253 case SID_PAGEMODE
: // BASIC
256 const SfxItemSet
*pArgs
= rReq
.GetArgs();
258 if (pArgs
&& pArgs
->Count () == 2)
260 const SfxBoolItem
* pIsActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
);
261 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
263 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue());
264 if ( nWhatKind
>= PageKind::Standard
&& nWhatKind
<= PageKind::Handout
)
266 mbIsLayerModeActive
= pIsActive
->GetValue();
267 mePageKind
= nWhatKind
;
271 // turn on default layer of page
272 mpDrawView
->SetActiveLayer(sUNO_LayerName_layout
);
274 ChangeEditMode(EditMode::Page
, mbIsLayerModeActive
);
282 case SID_LAYERMODE
: // BASIC
284 const SfxItemSet
*pArgs
= rReq
.GetArgs();
286 if (pArgs
&& pArgs
->Count() == 2)
288 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
289 EditMode nWhatLayer
= static_cast<EditMode
>(pWhatLayer
->GetValue());
290 if (nWhatLayer
== EditMode::Page
|| nWhatLayer
== EditMode::MasterPage
)
292 mbIsLayerModeActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
)->GetValue();
293 meEditMode
= nWhatLayer
;
297 ChangeEditMode(meEditMode
, !mbIsLayerModeActive
);
305 case SID_HEADER_AND_FOOTER
:
306 case SID_INSERT_PAGE_NUMBER
:
307 case SID_INSERT_DATE_TIME
:
309 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
310 vcl::Window
* pWin
= GetActiveWindow();
311 VclPtr
<AbstractHeaderFooterDialog
> pDlg(pFact
->CreateHeaderFooterDialog(this, pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), mpActualPage
));
312 auto xRequest
= std::make_shared
<SfxRequest
>(rReq
);
313 rReq
.Ignore(); // the 'old' request is not relevant any more
314 pDlg
->StartExecuteAsync([this, pDlg
, xRequest
=std::move(xRequest
)](sal_Int32
/*nResult*/){
315 GetActiveWindow()->Invalidate();
316 UpdatePreview( mpActualPage
);
326 case SID_MASTER_LAYOUTS
:
328 SdPage
* pPage
= GetActualPage();
329 if (meEditMode
== EditMode::MasterPage
)
330 // Use the master page of the current page.
331 pPage
= static_cast<SdPage
*>(&pPage
->TRG_GetMasterPage());
333 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
334 vcl::Window
* pWin
= GetActiveWindow();
335 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateMasterLayoutDialog(pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), pPage
));
341 case SID_OBJECTRESIZE
:
343 // The server likes to change the client size
344 OSL_ASSERT (GetViewShell()!=nullptr);
345 SfxInPlaceClient
* pIPClient
= GetViewShell()->GetIPClient();
347 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
349 const SfxRectangleItem
& rRect
=
350 rReq
.GetArgs()->Get(SID_OBJECTRESIZE
);
351 ::tools::Rectangle
aRect( GetActiveWindow()->PixelToLogic( rRect
.GetValue() ) );
353 if ( rMarkList
.GetMarkCount() != 0 )
355 if (rMarkList
.GetMarkCount() == 1)
357 SdrMark
* pMark
= rMarkList
.GetMark(0);
358 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
360 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
363 if( pOle2Obj
->GetObjRef().is() )
365 pOle2Obj
->SetLogicRect(aRect
);
377 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
378 SfxViewFrame
* pFrame
= GetViewFrame();
382 Reference
< XFrame
> xFrame( pFrame
->GetFrame().GetFrameInterface(), UNO_SET_THROW
);
384 // Save the current configuration of panes and views.
385 DrawController
* pDrawController
= GetViewShellBase().GetDrawController();
388 Reference
<XConfigurationController
> xConfigurationController (
389 pDrawController
->getConfigurationController(), UNO_SET_THROW
);
390 Reference
<XConfiguration
> xConfiguration (
391 xConfigurationController
->getRequestedConfiguration(), UNO_SET_THROW
);
393 SfxChildWindow
* pWindow
= pFrame
->GetChildWindow(nId
);
396 Svx3DWin
* p3DWin
= static_cast<Svx3DWin
*>(pWindow
->GetWindow());
398 p3DWin
->DocumentReload();
401 // normal forwarding to ViewFrame for execution
402 GetViewFrame()->ExecuteSlot(rReq
);
404 // From here on we must cope with this object and the frame already being
405 // deleted. Do not call any methods or use data members.
406 Reference
<XController
> xController( xFrame
->getController(), UNO_SET_THROW
);
408 // Restore the configuration.
409 Reference
<XControllerManager
> xControllerManager( xController
, UNO_QUERY_THROW
);
410 xConfigurationController
.set( xControllerManager
->getConfigurationController() );
411 if ( ! xConfigurationController
.is())
412 throw RuntimeException();
413 xConfigurationController
->restoreConfiguration(xConfiguration
);
416 catch (RuntimeException
&)
418 DBG_UNHANDLED_EXCEPTION("sd.view");
421 // We have to return immediately to avoid accessing this object.
429 const SfxStringItem
* pBookmark
= rReq
.GetArg
<SfxStringItem
>(SID_JUMPTOMARK
);
433 OUString
sBookmark(INetURLObject::decode(pBookmark
->GetValue(), INetURLObject::DecodeMechanism::WithCharset
));
435 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
436 if(xSlideshow
.is() && xSlideshow
->isRunning())
438 xSlideshow
->jumpToBookmark(sBookmark
);
442 GotoBookmark(sBookmark
);
450 case SID_OUTPUT_QUALITY_COLOR
:
451 case SID_OUTPUT_QUALITY_GRAYSCALE
:
452 case SID_OUTPUT_QUALITY_BLACKWHITE
:
453 case SID_OUTPUT_QUALITY_CONTRAST
:
459 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
465 case SID_ATTR_YEAR2000
:
467 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
468 if (pFormShell
!= nullptr)
470 const SfxPoolItem
* pItem
;
471 if (rReq
.GetArgs()->GetItemState(
472 SID_ATTR_YEAR2000
, true, &pItem
) == SfxItemState::SET
)
473 pFormShell
->SetY2KState (
474 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
481 case SID_OPT_LOCALE_CHANGED
:
483 GetActiveWindow()->Invalidate();
484 UpdatePreview( mpActualPage
);
489 case SID_REGENERATE_DIAGRAM
:
490 case SID_EDIT_DIAGRAM
:
492 if (1 == rMarkList
.GetMarkCount())
494 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
496 // Support advanced DiagramHelper
497 if(nullptr != pObj
&& pObj
->isDiagram())
499 if(SID_REGENERATE_DIAGRAM
== nSlot
)
501 mpDrawView
->UnmarkAll();
502 pObj
->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup
*>(pObj
));
503 mpDrawView
->MarkObj(pObj
, mpDrawView
->GetSdrPageView());
505 else // SID_EDIT_DIAGRAM
507 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
508 VclPtr
<VclAbstractDialog
> pDlg
= pFact
->CreateDiagramDialog(
510 *static_cast<SdrObjGroup
*>(pObj
));
511 pDlg
->StartExecuteAsync(
512 [pDlg
] (sal_Int32
/*nResult*/)->void
530 void DrawViewShell::ExecRuler(SfxRequest
& rReq
)
532 // nothing is executed during a slide show!
533 if(HasCurrentFunction(SID_PRESENTATION
))
538 const SfxItemSet
* pArgs
= rReq
.GetArgs();
539 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
540 Size aPageSize
= mpActualPage
->GetSize();
541 Size aViewSize
= GetActiveWindow()->GetViewSize();
543 switch ( rReq
.GetSlot() )
545 case SID_ATTR_LONG_LRSPACE
:
548 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
549 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
551 const SvxLongLRSpaceItem
& rLRSpace
=
552 pArgs
->Get(SID_ATTR_LONG_LRSPACE
);
554 if( mpDrawView
->IsTextEdit() )
556 ::tools::Rectangle aRect
= maMarkRect
;
557 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
558 aRect
.SetLeft( rLRSpace
.GetLeft() );
559 aRect
.SetRight( aViewSize
.Width() - rLRSpace
.GetRight() );
560 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
561 if ( aRect
!= maMarkRect
)
563 mpDrawView
->SetAllMarkedRect(aRect
);
564 maMarkRect
= mpDrawView
->GetAllMarkedRect();
565 Invalidate( SID_RULER_OBJECT
);
570 ::tools::Long nLeft
= std::max(::tools::Long(0), rLRSpace
.GetLeft() - aPagePos
.X());
571 ::tools::Long nRight
= std::max(::tools::Long(0), rLRSpace
.GetRight() + aPagePos
.X() +
572 aPageSize
.Width() - aViewSize
.Width());
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 SdPageLRUndoAction(GetDoc(),
581 pPage
->GetLeftBorder(),
582 pPage
->GetRightBorder(),
584 pUndoGroup
->AddAction(pUndo
);
585 pPage
->SetLeftBorder(nLeft
);
586 pPage
->SetRightBorder(nRight
);
588 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
590 for (i
= 0; i
< nPageCnt
; i
++)
592 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
593 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
595 pPage
->GetLeftBorder(),
596 pPage
->GetRightBorder(),
598 pUndoGroup
->AddAction(pUndo
);
599 pPage
->SetLeftBorder(nLeft
);
600 pPage
->SetRightBorder(nRight
);
605 // give the undo group to the undo manager
606 GetViewFrame()->GetObjectShell()->GetUndoManager()->
607 AddUndoAction(std::move(pUndoGroup
));
610 case SID_ATTR_LONG_ULSPACE
:
613 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
614 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
616 const SvxLongULSpaceItem
& rULSpace
=
617 pArgs
->Get(SID_ATTR_LONG_ULSPACE
);
619 if( mpDrawView
->IsTextEdit() )
621 ::tools::Rectangle aRect
= maMarkRect
;
622 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
623 aRect
.SetTop( rULSpace
.GetUpper() );
624 aRect
.SetBottom( aViewSize
.Height() - rULSpace
.GetLower() );
625 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
627 if ( aRect
!= maMarkRect
)
629 mpDrawView
->SetAllMarkedRect(aRect
);
630 maMarkRect
= mpDrawView
->GetAllMarkedRect();
631 Invalidate( SID_RULER_OBJECT
);
636 ::tools::Long nUpper
= std::max(::tools::Long(0), rULSpace
.GetUpper() - aPagePos
.Y());
637 ::tools::Long nLower
= std::max(::tools::Long(0), rULSpace
.GetLower() + aPagePos
.Y() +
638 aPageSize
.Height() - aViewSize
.Height());
640 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
642 for ( i
= 0; i
< nPageCnt
; i
++)
644 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
645 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
647 pPage
->GetUpperBorder(),
648 pPage
->GetLowerBorder(),
650 pUndoGroup
->AddAction(pUndo
);
651 pPage
->SetUpperBorder(nUpper
);
652 pPage
->SetLowerBorder(nLower
);
654 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
656 for (i
= 0; i
< nPageCnt
; i
++)
658 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
659 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
661 pPage
->GetUpperBorder(),
662 pPage
->GetLowerBorder(),
664 pUndoGroup
->AddAction(pUndo
);
665 pPage
->SetUpperBorder(nUpper
);
666 pPage
->SetLowerBorder(nLower
);
671 // give the undo group to the undo manager
672 GetViewFrame()->GetObjectShell()->GetUndoManager()->
673 AddUndoAction(std::move(pUndoGroup
));
676 case SID_RULER_OBJECT
:
679 ::tools::Rectangle aRect
= maMarkRect
;
680 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
682 const SvxObjectItem
& rOI
= pArgs
->Get(SID_RULER_OBJECT
);
684 if ( rOI
.GetStartX() != rOI
.GetEndX() )
686 aRect
.SetLeft( rOI
.GetStartX() );
687 aRect
.SetRight( rOI
.GetEndX() );
689 if ( rOI
.GetStartY() != rOI
.GetEndY() )
691 aRect
.SetTop( rOI
.GetStartY() );
692 aRect
.SetBottom( rOI
.GetEndY() );
694 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
695 if ( aRect
!= maMarkRect
)
697 mpDrawView
->SetAllMarkedRect(aRect
);
698 maMarkRect
= mpDrawView
->GetAllMarkedRect();
699 Invalidate( SID_RULER_OBJECT
);
703 case SID_ATTR_TABSTOP
:
704 if (pArgs
&& mpDrawView
->IsTextEdit())
706 const SvxTabStopItem
& rItem
= pArgs
->Get( EE_PARA_TABS
);
708 SfxItemSetFixed
<EE_PARA_TABS
, EE_PARA_TABS
> aEditAttr( GetPool() );
710 aEditAttr
.Put( rItem
);
711 mpDrawView
->SetAttributes( aEditAttr
);
713 Invalidate(SID_ATTR_TABSTOP
);
716 case SID_ATTR_PARA_LINESPACE
:
719 SvxLineSpacingItem aParaLineSP
= pArgs
->Get(
720 GetPool().GetWhichIDFromSlotID(SID_ATTR_PARA_LINESPACE
));
722 SfxItemSetFixed
<EE_PARA_SBL
, EE_PARA_SBL
> aEditAttr( GetPool() );
723 aParaLineSP
.SetWhich( EE_PARA_SBL
);
725 aEditAttr
.Put( aParaLineSP
);
726 mpDrawView
->SetAttributes( aEditAttr
);
728 Invalidate(SID_ATTR_PARA_LINESPACE
);
731 case SID_ATTR_PARA_ADJUST_LEFT
:
733 SvxAdjustItem
aItem( SvxAdjust::Left
, EE_PARA_JUST
);
734 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
736 aEditAttr
.Put( aItem
);
737 mpDrawView
->SetAttributes( aEditAttr
);
739 Invalidate(SID_ATTR_PARA_ADJUST_LEFT
);
742 case SID_ATTR_PARA_ADJUST_CENTER
:
744 SvxAdjustItem
aItem( SvxAdjust::Center
, EE_PARA_JUST
);
745 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
747 aEditAttr
.Put( aItem
);
748 mpDrawView
->SetAttributes( aEditAttr
);
750 Invalidate(SID_ATTR_PARA_ADJUST_CENTER
);
753 case SID_ATTR_PARA_ADJUST_RIGHT
:
755 SvxAdjustItem
aItem( SvxAdjust::Right
, EE_PARA_JUST
);
756 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
758 aEditAttr
.Put( aItem
);
759 mpDrawView
->SetAttributes( aEditAttr
);
761 Invalidate(SID_ATTR_PARA_ADJUST_RIGHT
);
764 case SID_ATTR_PARA_ADJUST_BLOCK
:
766 SvxAdjustItem
aItem( SvxAdjust::Block
, EE_PARA_JUST
);
767 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
769 aEditAttr
.Put( aItem
);
770 mpDrawView
->SetAttributes( aEditAttr
);
772 Invalidate(SID_ATTR_PARA_ADJUST_BLOCK
);
775 case SID_ATTR_PARA_ULSPACE
:
778 SvxULSpaceItem aULSP
= static_cast<const SvxULSpaceItem
&>(pArgs
->Get(
779 SID_ATTR_PARA_ULSPACE
));
780 SfxItemSetFixed
<EE_PARA_ULSPACE
, EE_PARA_ULSPACE
> aEditAttr( GetPool() );
781 aULSP
.SetWhich( EE_PARA_ULSPACE
);
783 aEditAttr
.Put( aULSP
);
784 mpDrawView
->SetAttributes( aEditAttr
);
786 Invalidate(SID_ATTR_PARA_ULSPACE
);
789 case SID_ATTR_PARA_LRSPACE
:
792 SvxLRSpaceItem aLRSpace
= static_cast<const SvxLRSpaceItem
&>(pArgs
->Get(
793 SID_ATTR_PARA_LRSPACE
));
795 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttr( GetPool() );
796 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
798 aEditAttr
.Put( aLRSpace
);
799 mpDrawView
->SetAttributes( aEditAttr
);
801 Invalidate(SID_ATTR_PARA_LRSPACE
);
804 case SID_ATTR_LRSPACE
:
805 if (pArgs
&& mpDrawView
->IsTextEdit())
807 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
808 const SvxLRSpaceItem
& rItem
= static_cast<const SvxLRSpaceItem
&>(
812 EE_PARA_NUMBULLET
, EE_PARA_NUMBULLET
,
813 EE_PARA_OUTLLEVEL
, EE_PARA_OUTLLEVEL
,
814 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttr( GetDoc()->GetPool() );
815 mpDrawView
->GetAttributes( aEditAttr
);
817 nId
= EE_PARA_LRSPACE
;
818 SvxLRSpaceItem
aLRSpaceItem(rItem
.GetLeft(), rItem
.GetRight(),
819 rItem
.GetTextFirstLineOffset(), nId
);
821 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
822 const SvxLRSpaceItem
& rOrigLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
823 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
824 if( nOutlineLevel
!= -1 &&
825 rNumBulletItem
.GetNumRule().GetLevelCount() > nOutlineLevel
)
827 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule().GetLevel(nOutlineLevel
);
828 SvxNumberFormat
aFormat(rFormat
);
830 // left margin gets distributed onto LRSpace item
831 // and number format AbsLSpace - this fixes
832 // n#707779 (previously, LRSpace left indent could
833 // become negative - EditEngine really does not
835 const auto nAbsLSpace
=aFormat
.GetAbsLSpace();
836 const ::tools::Long nTxtLeft
= rItem
.ResolveTextLeft({});
837 const ::tools::Long nLeftIndent
=std::max(::tools::Long(0),nTxtLeft
- nAbsLSpace
);
838 aLRSpaceItem
.SetTextLeft(SvxIndentValue::twips(nLeftIndent
));
839 // control for clipped left indent - remainder
840 // reduces number format first line indent
841 aFormat
.SetAbsLSpace(nTxtLeft
- nLeftIndent
);
843 // negative first line indent goes to the number
844 // format, positive to the lrSpace item
845 if (rItem
.GetTextFirstLineOffset().m_dValue
< 0.0)
847 aFormat
.SetFirstLineOffset(rItem
.ResolveTextFirstLineOffset({})
848 - rOrigLRSpaceItem
.ResolveTextFirstLineOffset({})
849 + aFormat
.GetCharTextDistance());
850 aLRSpaceItem
.SetTextFirstLineOffset(SvxIndentValue::zero());
854 aFormat
.SetFirstLineOffset(0);
855 aLRSpaceItem
.SetTextFirstLineOffset(SvxIndentValue::twips(
856 rItem
.ResolveTextFirstLineOffset({}) - aFormat
.GetFirstLineOffset()
857 + aFormat
.GetCharTextDistance()));
860 if( rFormat
!= aFormat
)
863 const_cast<SvxNumRule
&>(rNumBulletItem
.GetNumRule()).SetLevel(nOutlineLevel
,aFormat
);
864 aEditAttr
.Put( rNumBulletItem
);
865 aEditAttr
.Put( aLRSpaceItem
);
866 mpDrawView
->SetAttributes( aEditAttr
);
868 Invalidate(SID_ATTR_PARA_LRSPACE
);
873 // only put lrSpace item
874 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttrReduced( GetDoc()->GetPool() );
875 aEditAttrReduced
.Put( aLRSpaceItem
);
876 mpDrawView
->SetAttributes( aEditAttrReduced
);
878 Invalidate(SID_ATTR_PARA_LRSPACE
);
884 void DrawViewShell::GetRulerState(SfxItemSet
& rSet
)
888 if (mpDrawView
->GetSdrPageView())
890 aOrigin
= mpDrawView
->GetSdrPageView()->GetPageOrigin();
893 Size aViewSize
= GetActiveWindow()->GetViewSize();
895 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
896 Size aPageSize
= mpActualPage
->GetSize();
898 ::tools::Rectangle
aRect(aPagePos
, Point( aViewSize
.Width() - (aPagePos
.X() + aPageSize
.Width()),
899 aViewSize
.Height() - (aPagePos
.Y() + aPageSize
.Height())));
901 if( mpDrawView
->IsTextEdit() )
903 Point aPnt1
= GetActiveWindow()->GetWinViewPos();
904 ::tools::Rectangle
aMinMaxRect( aPnt1
, Size(-1, -1) );
905 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aMinMaxRect
) );
909 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aRect
) );
912 SvxLongLRSpaceItem
aLRSpace(aPagePos
.X() + mpActualPage
->GetLeftBorder(),
913 aRect
.Right() + mpActualPage
->GetRightBorder(),
914 SID_ATTR_LONG_LRSPACE
);
915 SvxLongULSpaceItem
aULSpace(aPagePos
.Y() + mpActualPage
->GetUpperBorder(),
916 aRect
.Bottom() + mpActualPage
->GetLowerBorder(),
917 SID_ATTR_LONG_ULSPACE
);
918 rSet
.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos
, aViewSize
.Width(),
919 aViewSize
.Height()));
920 SfxPointItem
aPointItem( SID_RULER_NULL_OFFSET
, aPagePos
+ aOrigin
);
922 SvxProtectItem
aProtect( SID_RULER_PROTECT
);
924 maMarkRect
= mpDrawView
->GetAllMarkedRect();
926 const bool bRTL
= GetDoc() && GetDoc()->GetDefaultWritingMode() == css::text::WritingMode_RL_TB
;
927 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, bRTL
));
928 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
930 if( rMarkList
.GetMarkCount() != 0 )
932 if( mpDrawView
->IsTextEdit() )
934 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
935 if( pObj
->GetObjInventor() == SdrInventor::Default
)
937 SfxItemSet
aEditAttr( GetDoc()->GetPool() );
938 mpDrawView
->GetAttributes( aEditAttr
);
939 if( aEditAttr
.GetItemState( EE_PARA_TABS
) >= SfxItemState::DEFAULT
)
941 const SvxTabStopItem
& rItem
= aEditAttr
.Get( EE_PARA_TABS
);
944 const SvxLRSpaceItem
& rLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
945 SvxLRSpaceItem
aLRSpaceItem(rLRSpaceItem
.GetLeft(), rLRSpaceItem
.GetRight(),
946 rLRSpaceItem
.GetTextFirstLineOffset(),
947 SID_ATTR_PARA_LRSPACE
);
949 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
950 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
951 if( nOutlineLevel
!= -1 &&
952 rNumBulletItem
.GetNumRule().GetLevelCount() > nOutlineLevel
)
954 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule().GetLevel(nOutlineLevel
);
955 aLRSpaceItem
.SetTextLeft(SvxIndentValue::twips(
956 rFormat
.GetAbsLSpace() + rLRSpaceItem
.ResolveTextLeft({})));
957 aLRSpaceItem
.SetTextFirstLineOffset(SvxIndentValue::twips(
958 rLRSpaceItem
.ResolveTextFirstLineOffset({})
959 + rFormat
.GetFirstLineOffset() - rFormat
.GetCharTextDistance()));
962 rSet
.Put( aLRSpaceItem
);
964 Point
aPos( aPagePos
+ maMarkRect
.TopLeft() );
966 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
968 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
969 ::tools::Long nLD
= rTLDItem
.GetValue();
973 aPointItem
.SetValue( aPos
);
975 ::tools::Rectangle
aParaRect(maMarkRect
);
976 if (pObj
->GetObjIdentifier() == SdrObjKind::Table
)
978 sdr::table::SdrTableObj
* pTable
= static_cast<sdr::table::SdrTableObj
*>(pObj
);
979 sdr::table::CellPos cellpos
;
980 pTable
->getActiveCellPos(cellpos
);
981 pTable
->getCellBounds(cellpos
, aParaRect
);
984 aLRSpace
.SetLeft(aPagePos
.X() + aParaRect
.Left());
986 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
988 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
989 ::tools::Long nLD
= rTLDItem
.GetValue();
990 aLRSpace
.SetLeft( aLRSpace
.GetLeft() + nLD
);
993 aLRSpace
.SetRight(aRect
.Right() + aPageSize
.Width() - aParaRect
.Right());
995 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_RIGHTDIST
) == SfxItemState::SET
)
997 const SdrMetricItem
& rTRDItem
= aEditAttr
.Get( SDRATTR_TEXT_RIGHTDIST
);
998 ::tools::Long nRD
= rTRDItem
.GetValue();
999 aLRSpace
.SetRight( aLRSpace
.GetRight() + nRD
);
1002 aULSpace
.SetUpper( aPagePos
.Y() + maMarkRect
.Top() );
1003 aULSpace
.SetLower( aRect
.Bottom() + aPageSize
.Height() - maMarkRect
.Bottom() );
1005 rSet
.DisableItem( SID_RULER_OBJECT
);
1007 // lock page margins
1008 aProtect
.SetSizeProtect( true );
1009 aProtect
.SetPosProtect( true );
1012 if( aEditAttr
.GetItemState( EE_PARA_WRITINGDIR
) >= SfxItemState::DEFAULT
)
1014 const SvxFrameDirectionItem
& rItem
= aEditAttr
.Get( EE_PARA_WRITINGDIR
);
1015 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, rItem
.GetValue() == SvxFrameDirection::Horizontal_RL_TB
));
1021 rSet
.DisableItem( EE_PARA_TABS
);
1022 rSet
.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT
);
1024 if( mpDrawView
->IsResizeAllowed(true) )
1026 ::tools::Rectangle
aResizeRect( maMarkRect
);
1028 aResizeRect
.SetPos(aResizeRect
.TopLeft() + aPagePos
);
1029 SvxObjectItem
aObjItem(aResizeRect
.Left(), aResizeRect
.Right(),
1030 aResizeRect
.Top(), aResizeRect
.Bottom());
1032 rSet
.DisableItem( EE_PARA_TABS
);
1036 rSet
.DisableItem( SID_RULER_OBJECT
);
1042 rSet
.DisableItem( SID_RULER_OBJECT
);
1043 rSet
.DisableItem( EE_PARA_TABS
);
1046 rSet
.Put( aLRSpace
);
1047 rSet
.Put( aULSpace
);
1049 rSet
.Put( aPointItem
);
1050 rSet
.Put( aProtect
);
1053 void DrawViewShell::ExecStatusBar(SfxRequest
& rReq
)
1055 // nothing is executed during a slide show!
1056 if(HasCurrentFunction(SID_PRESENTATION
))
1061 switch ( rReq
.GetSlot() )
1065 GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM
, SfxCallMode::ASYNCHRON
);
1069 case SID_STATUS_LAYOUT
:
1071 GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT
, SfxCallMode::ASYNCHRON
);
1075 case SID_STATUS_PAGE
:
1077 GetViewFrame()->GetDispatcher()->Execute(SID_GO_TO_PAGE
,
1078 SfxCallMode::SYNCHRON
| SfxCallMode::RECORD
);
1085 * set state of snap object entries in popup
1087 void DrawViewShell::GetSnapItemState( SfxItemSet
&rSet
)
1090 Point aMPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
1091 sal_uInt16 nHitLog
= static_cast<sal_uInt16
>(GetActiveWindow()->PixelToLogic(
1092 Size(FuPoor::HITPIX
,0)).Width());
1093 sal_uInt16 nHelpLine
;
1095 if ( !mpDrawView
->PickHelpLine(aMPos
, nHitLog
, *GetActiveWindow()->GetOutDev(), nHelpLine
, pPV
) )
1098 const SdrHelpLine
& rHelpLine
= (pPV
->GetHelpLines())[nHelpLine
];
1100 if ( rHelpLine
.GetKind() == SdrHelpLineKind::Point
)
1102 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1103 SdResId( STR_POPUP_EDIT_SNAPPOINT
)) );
1104 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1105 SdResId( STR_POPUP_DELETE_SNAPPOINT
)) );
1109 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1110 SdResId( STR_POPUP_EDIT_SNAPLINE
)) );
1111 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1112 SdResId( STR_POPUP_DELETE_SNAPLINE
)) );
1116 } // end of namespace sd
1118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */