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>
24 #include <sfx2/viewfrm.hxx>
25 #include <editeng/eeitem.hxx>
26 #include <editeng/tstpitem.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <editeng/protitem.hxx>
29 #include <editeng/frmdiritem.hxx>
30 #include <editeng/adjustitem.hxx>
31 #include <svx/svdotable.hxx>
32 #include <editeng/numitem.hxx>
33 #include <svx/rulritem.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/eitem.hxx>
40 #include <svl/rectitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <svx/svdoole2.hxx>
43 #include <svl/itempool.hxx>
44 #include <svl/ptitem.hxx>
45 #include <basic/sbstar.hxx>
46 #include <basic/sberrors.hxx>
47 #include <svx/fmshell.hxx>
48 #include <svx/f3dchild.hxx>
49 #include <svx/float3d.hxx>
50 #include <svx/sdmetitm.hxx>
51 #include <svx/svdogrp.hxx>
52 #include <svx/diagram/IDiagramHelper.hxx>
55 #include <strings.hrc>
57 #include <sdundogr.hxx>
58 #include <undopage.hxx>
60 #include <slideshow.hxx>
63 #include <sdresid.hxx>
64 #include <unokywds.hxx>
65 #include <drawview.hxx>
66 #include <drawdoc.hxx>
67 #include <DrawDocShell.hxx>
68 #include <sdabstdlg.hxx>
69 #include <sfx2/ipclient.hxx>
70 #include <comphelper/diagnose_ex.hxx>
71 #include <ViewShellBase.hxx>
72 #include <FormShellManager.hxx>
73 #include <LayerTabBar.hxx>
74 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
75 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
76 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
77 #include <com/sun/star/drawing/XShape.hpp>
78 #include <com/sun/star/frame/XFrame.hpp>
79 #include <editeng/lspcitem.hxx>
80 #include <editeng/ulspitem.hxx>
82 #include <comphelper/processfactory.hxx>
83 #include <oox/drawingml/diagram/diagram.hxx>
84 #include <oox/export/drawingml.hxx>
85 #include <oox/shape/ShapeFilterBase.hxx>
87 using namespace ::com::sun::star::uno
;
88 using namespace ::com::sun::star::drawing::framework
;
89 using ::com::sun::star::frame::XFrame
;
90 using ::com::sun::star::frame::XController
;
95 * handle SfxRequests for controller
97 void DrawViewShell::ExecCtrl(SfxRequest
& rReq
)
99 // except a page switch and jumps to bookmarks, nothing is executed during
101 if( HasCurrentFunction(SID_PRESENTATION
) &&
102 rReq
.GetSlot() != SID_SWITCHPAGE
&&
103 rReq
.GetSlot() != SID_JUMPTOMARK
)
108 // End text edit mode for some requests.
109 sal_uInt16 nSlot
= rReq
.GetSlot();
110 bool bAllowFocusChange
= true;
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 (rReq
.GetArgs() && rReq
.GetArgs()->Count () == 1)
122 const SfxBoolItem
* pAllowFocusChange
= rReq
.GetArg
<SfxBoolItem
>(SID_SWITCHPAGE
);
123 bAllowFocusChange
= pAllowFocusChange
->GetValue();
124 if (!bAllowFocusChange
)
129 if ( mpDrawView
->IsTextEdit() )
131 mpDrawView
->SdrEndTextEdit();
135 // sal_uInt16 nSlot = rReq.GetSlot();
138 case SID_SWITCHPAGE
: // BASIC
140 // switch page in running slide show
141 if(SlideShow::IsRunning(GetViewShellBase()) && rReq
.GetArgs())
143 if (const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
))
144 SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber(static_cast<sal_Int32
>((pWhatPage
->GetValue()-1)>>1));
148 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
149 sal_uInt16 nSelectedPage
= 0;
151 if (! pArgs
|| pArgs
->Count () == 1)
153 nSelectedPage
= maTabControl
->GetCurPagePos();
155 else if (pArgs
->Count () == 2)
157 const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
);
158 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
160 sal_Int32 nWhatPage
= static_cast<sal_Int32
>(pWhatPage
->GetValue ());
161 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue ());
162 if (nWhatKind
< PageKind::Standard
|| nWhatKind
> PageKind::Handout
)
164 #if HAVE_FEATURE_SCRIPTING
165 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
170 else if (meEditMode
!= EditMode::MasterPage
)
172 if (! CHECK_RANGE (0, nWhatPage
, GetDoc()->GetSdPageCount(nWhatKind
)))
174 #if HAVE_FEATURE_SCRIPTING
175 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
181 nSelectedPage
= static_cast<short>(nWhatPage
);
182 mePageKind
= nWhatKind
;
187 #if HAVE_FEATURE_SCRIPTING
188 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS
);
194 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
))
195 GetDocSh()->SetModified();
197 SwitchPage(nSelectedPage
, bAllowFocusChange
);
199 if(HasCurrentFunction(SID_BEZIER_EDIT
))
200 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
209 case SID_SWITCHLAYER
: // BASIC
211 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
214 bool bCurPageValid(false);
215 sal_uInt16
nCurPage(0);
217 if(GetLayerTabControl())
219 nCurPage
= GetLayerTabControl()->GetCurPageId();
220 bCurPageValid
= true;
223 if(pArgs
&& 1 == pArgs
->Count())
225 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
229 nCurPage
= static_cast<short>(pWhatLayer
->GetValue());
230 bCurPageValid
= true;
236 OUString
aLayerName( GetLayerTabControl()->GetLayerName(nCurPage
));
237 if (!aLayerName
.isEmpty())
239 mpDrawView
->SetActiveLayer(aLayerName
);
249 case SID_PAGEMODE
: // BASIC
252 const SfxItemSet
*pArgs
= rReq
.GetArgs();
254 if (pArgs
&& pArgs
->Count () == 2)
256 const SfxBoolItem
* pIsActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
);
257 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
259 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue());
260 if ( nWhatKind
>= PageKind::Standard
&& nWhatKind
<= PageKind::Handout
)
262 mbIsLayerModeActive
= pIsActive
->GetValue();
263 mePageKind
= nWhatKind
;
267 // turn on default layer of page
268 mpDrawView
->SetActiveLayer(sUNO_LayerName_layout
);
270 ChangeEditMode(EditMode::Page
, mbIsLayerModeActive
);
278 case SID_LAYERMODE
: // BASIC
280 const SfxItemSet
*pArgs
= rReq
.GetArgs();
282 if (pArgs
&& pArgs
->Count() == 2)
284 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
285 EditMode nWhatLayer
= static_cast<EditMode
>(pWhatLayer
->GetValue());
286 if (nWhatLayer
== EditMode::Page
|| nWhatLayer
== EditMode::MasterPage
)
288 mbIsLayerModeActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
)->GetValue();
289 meEditMode
= nWhatLayer
;
293 ChangeEditMode(meEditMode
, !mbIsLayerModeActive
);
301 case SID_HEADER_AND_FOOTER
:
302 case SID_INSERT_PAGE_NUMBER
:
303 case SID_INSERT_DATE_TIME
:
305 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
306 vcl::Window
* pWin
= GetActiveWindow();
307 VclPtr
<AbstractHeaderFooterDialog
> pDlg(pFact
->CreateHeaderFooterDialog(this, pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), mpActualPage
));
308 auto xRequest
= std::make_shared
<SfxRequest
>(rReq
);
309 rReq
.Ignore(); // the 'old' request is not relevant any more
310 pDlg
->StartExecuteAsync([this, pDlg
, xRequest
](sal_Int32
/*nResult*/){
311 GetActiveWindow()->Invalidate();
312 UpdatePreview( mpActualPage
);
322 case SID_MASTER_LAYOUTS
:
324 SdPage
* pPage
= GetActualPage();
325 if (meEditMode
== EditMode::MasterPage
)
326 // Use the master page of the current page.
327 pPage
= static_cast<SdPage
*>(&pPage
->TRG_GetMasterPage());
329 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
330 vcl::Window
* pWin
= GetActiveWindow();
331 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateMasterLayoutDialog(pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), pPage
));
337 case SID_OBJECTRESIZE
:
339 // The server likes to change the client size
340 OSL_ASSERT (GetViewShell()!=nullptr);
341 SfxInPlaceClient
* pIPClient
= GetViewShell()->GetIPClient();
343 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
345 const SfxRectangleItem
& rRect
=
346 rReq
.GetArgs()->Get(SID_OBJECTRESIZE
);
347 ::tools::Rectangle
aRect( GetActiveWindow()->PixelToLogic( rRect
.GetValue() ) );
349 if ( mpDrawView
->AreObjectsMarked() )
351 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
353 if (rMarkList
.GetMarkCount() == 1)
355 SdrMark
* pMark
= rMarkList
.GetMark(0);
356 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
358 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
361 if( pOle2Obj
->GetObjRef().is() )
363 pOle2Obj
->SetLogicRect(aRect
);
375 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
376 SfxViewFrame
* pFrame
= GetViewFrame();
380 Reference
< XFrame
> xFrame( pFrame
->GetFrame().GetFrameInterface(), UNO_SET_THROW
);
382 // Save the current configuration of panes and views.
383 Reference
<XControllerManager
> xControllerManager (
384 GetViewShellBase().GetController(), UNO_QUERY_THROW
);
385 Reference
<XConfigurationController
> xConfigurationController (
386 xControllerManager
->getConfigurationController(), UNO_SET_THROW
);
387 Reference
<XConfiguration
> xConfiguration (
388 xConfigurationController
->getRequestedConfiguration(), UNO_SET_THROW
);
390 SfxChildWindow
* pWindow
= pFrame
->GetChildWindow(nId
);
393 Svx3DWin
* p3DWin
= static_cast<Svx3DWin
*>(pWindow
->GetWindow());
395 p3DWin
->DocumentReload();
398 // normal forwarding to ViewFrame for execution
399 GetViewFrame()->ExecuteSlot(rReq
);
401 // From here on we must cope with this object and the frame already being
402 // deleted. Do not call any methods or use data members.
403 Reference
<XController
> xController( xFrame
->getController(), UNO_SET_THROW
);
405 // Restore the configuration.
406 xControllerManager
.set( xController
, UNO_QUERY_THROW
);
407 xConfigurationController
.set( xControllerManager
->getConfigurationController() );
408 if ( ! xConfigurationController
.is())
409 throw RuntimeException();
410 xConfigurationController
->restoreConfiguration(xConfiguration
);
412 catch (RuntimeException
&)
414 DBG_UNHANDLED_EXCEPTION("sd.view");
417 // We have to return immediately to avoid accessing this object.
425 const SfxStringItem
* pBookmark
= rReq
.GetArg
<SfxStringItem
>(SID_JUMPTOMARK
);
429 OUString
sBookmark(INetURLObject::decode(pBookmark
->GetValue(), INetURLObject::DecodeMechanism::WithCharset
));
431 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
432 if(xSlideshow
.is() && xSlideshow
->isRunning())
434 xSlideshow
->jumpToBookmark(sBookmark
);
438 GotoBookmark(sBookmark
);
446 case SID_OUTPUT_QUALITY_COLOR
:
447 case SID_OUTPUT_QUALITY_GRAYSCALE
:
448 case SID_OUTPUT_QUALITY_BLACKWHITE
:
449 case SID_OUTPUT_QUALITY_CONTRAST
:
455 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
461 case SID_ATTR_YEAR2000
:
463 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
464 if (pFormShell
!= nullptr)
466 const SfxPoolItem
* pItem
;
467 if (rReq
.GetArgs()->GetItemState(
468 SID_ATTR_YEAR2000
, true, &pItem
) == SfxItemState::SET
)
469 pFormShell
->SetY2KState (
470 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
477 case SID_OPT_LOCALE_CHANGED
:
479 GetActiveWindow()->Invalidate();
480 UpdatePreview( mpActualPage
);
485 case SID_REGENERATE_DIAGRAM
:
486 case SID_EDIT_DIAGRAM
:
488 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
490 if (1 == rMarkList
.GetMarkCount())
492 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
494 // Support advanced DiagramHelper
495 if(nullptr != pObj
&& pObj
->isDiagram())
497 if(SID_REGENERATE_DIAGRAM
== nSlot
)
499 mpDrawView
->UnmarkAll();
500 pObj
->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup
*>(pObj
));
501 mpDrawView
->MarkObj(pObj
, mpDrawView
->GetSdrPageView());
503 else // SID_EDIT_DIAGRAM
505 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
506 ScopedVclPtr
<VclAbstractDialog
> pDlg
= pFact
->CreateDiagramDialog(
508 *static_cast<SdrObjGroup
*>(pObj
));
523 void DrawViewShell::ExecRuler(SfxRequest
& rReq
)
525 // nothing is executed during a slide show!
526 if(HasCurrentFunction(SID_PRESENTATION
))
531 const SfxItemSet
* pArgs
= rReq
.GetArgs();
532 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
533 Size aPageSize
= mpActualPage
->GetSize();
534 Size aViewSize
= GetActiveWindow()->GetViewSize();
536 switch ( rReq
.GetSlot() )
538 case SID_ATTR_LONG_LRSPACE
:
541 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
542 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
544 const SvxLongLRSpaceItem
& rLRSpace
=
545 pArgs
->Get(SID_ATTR_LONG_LRSPACE
);
547 if( mpDrawView
->IsTextEdit() )
549 ::tools::Rectangle aRect
= maMarkRect
;
550 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
551 aRect
.SetLeft( rLRSpace
.GetLeft() );
552 aRect
.SetRight( aViewSize
.Width() - rLRSpace
.GetRight() );
553 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
554 if ( aRect
!= maMarkRect
)
556 mpDrawView
->SetAllMarkedRect(aRect
);
557 maMarkRect
= mpDrawView
->GetAllMarkedRect();
558 Invalidate( SID_RULER_OBJECT
);
563 ::tools::Long nLeft
= std::max(::tools::Long(0), rLRSpace
.GetLeft() - aPagePos
.X());
564 ::tools::Long nRight
= std::max(::tools::Long(0), rLRSpace
.GetRight() + aPagePos
.X() +
565 aPageSize
.Width() - aViewSize
.Width());
567 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
569 for ( i
= 0; i
< nPageCnt
; i
++)
571 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
572 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
574 pPage
->GetLeftBorder(),
575 pPage
->GetRightBorder(),
577 pUndoGroup
->AddAction(pUndo
);
578 pPage
->SetLeftBorder(nLeft
);
579 pPage
->SetRightBorder(nRight
);
581 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
583 for (i
= 0; i
< nPageCnt
; i
++)
585 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
586 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
588 pPage
->GetLeftBorder(),
589 pPage
->GetRightBorder(),
591 pUndoGroup
->AddAction(pUndo
);
592 pPage
->SetLeftBorder(nLeft
);
593 pPage
->SetRightBorder(nRight
);
598 // give the undo group to the undo manager
599 GetViewFrame()->GetObjectShell()->GetUndoManager()->
600 AddUndoAction(std::move(pUndoGroup
));
603 case SID_ATTR_LONG_ULSPACE
:
606 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
607 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
609 const SvxLongULSpaceItem
& rULSpace
=
610 pArgs
->Get(SID_ATTR_LONG_ULSPACE
);
612 if( mpDrawView
->IsTextEdit() )
614 ::tools::Rectangle aRect
= maMarkRect
;
615 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
616 aRect
.SetTop( rULSpace
.GetUpper() );
617 aRect
.SetBottom( aViewSize
.Height() - rULSpace
.GetLower() );
618 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
620 if ( aRect
!= maMarkRect
)
622 mpDrawView
->SetAllMarkedRect(aRect
);
623 maMarkRect
= mpDrawView
->GetAllMarkedRect();
624 Invalidate( SID_RULER_OBJECT
);
629 ::tools::Long nUpper
= std::max(::tools::Long(0), rULSpace
.GetUpper() - aPagePos
.Y());
630 ::tools::Long nLower
= std::max(::tools::Long(0), rULSpace
.GetLower() + aPagePos
.Y() +
631 aPageSize
.Height() - aViewSize
.Height());
633 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
635 for ( i
= 0; i
< nPageCnt
; i
++)
637 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
638 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
640 pPage
->GetUpperBorder(),
641 pPage
->GetLowerBorder(),
643 pUndoGroup
->AddAction(pUndo
);
644 pPage
->SetUpperBorder(nUpper
);
645 pPage
->SetLowerBorder(nLower
);
647 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
649 for (i
= 0; i
< nPageCnt
; i
++)
651 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
652 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
654 pPage
->GetUpperBorder(),
655 pPage
->GetLowerBorder(),
657 pUndoGroup
->AddAction(pUndo
);
658 pPage
->SetUpperBorder(nUpper
);
659 pPage
->SetLowerBorder(nLower
);
664 // give the undo group to the undo manager
665 GetViewFrame()->GetObjectShell()->GetUndoManager()->
666 AddUndoAction(std::move(pUndoGroup
));
669 case SID_RULER_OBJECT
:
672 ::tools::Rectangle aRect
= maMarkRect
;
673 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
675 const SvxObjectItem
& rOI
= pArgs
->Get(SID_RULER_OBJECT
);
677 if ( rOI
.GetStartX() != rOI
.GetEndX() )
679 aRect
.SetLeft( rOI
.GetStartX() );
680 aRect
.SetRight( rOI
.GetEndX() );
682 if ( rOI
.GetStartY() != rOI
.GetEndY() )
684 aRect
.SetTop( rOI
.GetStartY() );
685 aRect
.SetBottom( rOI
.GetEndY() );
687 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
688 if ( aRect
!= maMarkRect
)
690 mpDrawView
->SetAllMarkedRect(aRect
);
691 maMarkRect
= mpDrawView
->GetAllMarkedRect();
692 Invalidate( SID_RULER_OBJECT
);
696 case SID_ATTR_TABSTOP
:
697 if (pArgs
&& mpDrawView
->IsTextEdit())
699 const SvxTabStopItem
& rItem
= pArgs
->Get( EE_PARA_TABS
);
701 SfxItemSetFixed
<EE_PARA_TABS
, EE_PARA_TABS
> aEditAttr( GetPool() );
703 aEditAttr
.Put( rItem
);
704 mpDrawView
->SetAttributes( aEditAttr
);
706 Invalidate(SID_ATTR_TABSTOP
);
709 case SID_ATTR_PARA_LINESPACE
:
712 SvxLineSpacingItem aParaLineSP
= pArgs
->Get(
713 GetPool().GetWhich(SID_ATTR_PARA_LINESPACE
));
715 SfxItemSetFixed
<EE_PARA_SBL
, EE_PARA_SBL
> aEditAttr( GetPool() );
716 aParaLineSP
.SetWhich( EE_PARA_SBL
);
718 aEditAttr
.Put( aParaLineSP
);
719 mpDrawView
->SetAttributes( aEditAttr
);
721 Invalidate(SID_ATTR_PARA_LINESPACE
);
724 case SID_ATTR_PARA_ADJUST_LEFT
:
726 SvxAdjustItem
aItem( SvxAdjust::Left
, EE_PARA_JUST
);
727 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
729 aEditAttr
.Put( aItem
);
730 mpDrawView
->SetAttributes( aEditAttr
);
732 Invalidate(SID_ATTR_PARA_ADJUST_LEFT
);
735 case SID_ATTR_PARA_ADJUST_CENTER
:
737 SvxAdjustItem
aItem( SvxAdjust::Center
, EE_PARA_JUST
);
738 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
740 aEditAttr
.Put( aItem
);
741 mpDrawView
->SetAttributes( aEditAttr
);
743 Invalidate(SID_ATTR_PARA_ADJUST_CENTER
);
746 case SID_ATTR_PARA_ADJUST_RIGHT
:
748 SvxAdjustItem
aItem( SvxAdjust::Right
, EE_PARA_JUST
);
749 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
751 aEditAttr
.Put( aItem
);
752 mpDrawView
->SetAttributes( aEditAttr
);
754 Invalidate(SID_ATTR_PARA_ADJUST_RIGHT
);
757 case SID_ATTR_PARA_ADJUST_BLOCK
:
759 SvxAdjustItem
aItem( SvxAdjust::Block
, EE_PARA_JUST
);
760 SfxItemSetFixed
<EE_PARA_JUST
, EE_PARA_JUST
> aEditAttr( GetPool() );
762 aEditAttr
.Put( aItem
);
763 mpDrawView
->SetAttributes( aEditAttr
);
765 Invalidate(SID_ATTR_PARA_ADJUST_BLOCK
);
768 case SID_ATTR_PARA_ULSPACE
:
771 SvxULSpaceItem aULSP
= static_cast<const SvxULSpaceItem
&>(pArgs
->Get(
772 SID_ATTR_PARA_ULSPACE
));
773 SfxItemSetFixed
<EE_PARA_ULSPACE
, EE_PARA_ULSPACE
> aEditAttr( GetPool() );
774 aULSP
.SetWhich( EE_PARA_ULSPACE
);
776 aEditAttr
.Put( aULSP
);
777 mpDrawView
->SetAttributes( aEditAttr
);
779 Invalidate(SID_ATTR_PARA_ULSPACE
);
782 case SID_ATTR_PARA_LRSPACE
:
785 SvxLRSpaceItem aLRSpace
= static_cast<const SvxLRSpaceItem
&>(pArgs
->Get(
786 SID_ATTR_PARA_LRSPACE
));
788 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttr( GetPool() );
789 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
791 aEditAttr
.Put( aLRSpace
);
792 mpDrawView
->SetAttributes( aEditAttr
);
794 Invalidate(SID_ATTR_PARA_LRSPACE
);
797 case SID_ATTR_LRSPACE
:
798 if (pArgs
&& mpDrawView
->IsTextEdit())
800 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
801 const SvxLRSpaceItem
& rItem
= static_cast<const SvxLRSpaceItem
&>(
805 EE_PARA_NUMBULLET
, EE_PARA_NUMBULLET
,
806 EE_PARA_OUTLLEVEL
, EE_PARA_OUTLLEVEL
,
807 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttr( GetDoc()->GetPool() );
808 mpDrawView
->GetAttributes( aEditAttr
);
810 nId
= EE_PARA_LRSPACE
;
811 SvxLRSpaceItem
aLRSpaceItem( rItem
.GetLeft(),
813 rItem
.GetTextFirstLineOffset(), nId
);
815 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
816 const SvxLRSpaceItem
& rOrigLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
817 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
818 if( nOutlineLevel
!= -1 &&
819 rNumBulletItem
.GetNumRule().GetLevelCount() > nOutlineLevel
)
821 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule().GetLevel(nOutlineLevel
);
822 SvxNumberFormat
aFormat(rFormat
);
824 // left margin gets distributed onto LRSpace item
825 // and number format AbsLSpace - this fixes
826 // n#707779 (previously, LRSpace left indent could
827 // become negative - EditEngine really does not
829 const auto nAbsLSpace
=aFormat
.GetAbsLSpace();
830 const ::tools::Long nTxtLeft
=rItem
.GetTextLeft();
831 const ::tools::Long nLeftIndent
=std::max(::tools::Long(0),nTxtLeft
- nAbsLSpace
);
832 aLRSpaceItem
.SetTextLeft(nLeftIndent
);
833 // control for clipped left indent - remainder
834 // reduces number format first line indent
835 aFormat
.SetAbsLSpace(nTxtLeft
- nLeftIndent
);
837 // negative first line indent goes to the number
838 // format, positive to the lrSpace item
839 if( rItem
.GetTextFirstLineOffset() < 0 )
841 aFormat
.SetFirstLineOffset(
842 rItem
.GetTextFirstLineOffset()
843 - rOrigLRSpaceItem
.GetTextFirstLineOffset()
844 + aFormat
.GetCharTextDistance());
845 aLRSpaceItem
.SetTextFirstLineOffset(0);
849 aFormat
.SetFirstLineOffset(0);
850 aLRSpaceItem
.SetTextFirstLineOffset(
851 rItem
.GetTextFirstLineOffset()
852 - aFormat
.GetFirstLineOffset() //TODO: overflow
853 + aFormat
.GetCharTextDistance());
856 if( rFormat
!= aFormat
)
859 const_cast<SvxNumRule
&>(rNumBulletItem
.GetNumRule()).SetLevel(nOutlineLevel
,aFormat
);
860 aEditAttr
.Put( rNumBulletItem
);
861 aEditAttr
.Put( aLRSpaceItem
);
862 mpDrawView
->SetAttributes( aEditAttr
);
864 Invalidate(SID_ATTR_PARA_LRSPACE
);
869 // only put lrSpace item
870 SfxItemSetFixed
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
> aEditAttrReduced( GetDoc()->GetPool() );
871 aEditAttrReduced
.Put( aLRSpaceItem
);
872 mpDrawView
->SetAttributes( aEditAttrReduced
);
874 Invalidate(SID_ATTR_PARA_LRSPACE
);
880 void DrawViewShell::GetRulerState(SfxItemSet
& rSet
)
884 if (mpDrawView
->GetSdrPageView())
886 aOrigin
= mpDrawView
->GetSdrPageView()->GetPageOrigin();
889 Size aViewSize
= GetActiveWindow()->GetViewSize();
891 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
892 Size aPageSize
= mpActualPage
->GetSize();
894 ::tools::Rectangle
aRect(aPagePos
, Point( aViewSize
.Width() - (aPagePos
.X() + aPageSize
.Width()),
895 aViewSize
.Height() - (aPagePos
.Y() + aPageSize
.Height())));
897 if( mpDrawView
->IsTextEdit() )
899 Point aPnt1
= GetActiveWindow()->GetWinViewPos();
900 ::tools::Rectangle
aMinMaxRect( aPnt1
, Size(-1, -1) );
901 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aMinMaxRect
) );
905 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aRect
) );
908 SvxLongLRSpaceItem
aLRSpace(aPagePos
.X() + mpActualPage
->GetLeftBorder(),
909 aRect
.Right() + mpActualPage
->GetRightBorder(),
910 SID_ATTR_LONG_LRSPACE
);
911 SvxLongULSpaceItem
aULSpace(aPagePos
.Y() + mpActualPage
->GetUpperBorder(),
912 aRect
.Bottom() + mpActualPage
->GetLowerBorder(),
913 SID_ATTR_LONG_ULSPACE
);
914 rSet
.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos
, aViewSize
.Width(),
915 aViewSize
.Height()));
916 SfxPointItem
aPointItem( SID_RULER_NULL_OFFSET
, aPagePos
+ aOrigin
);
918 SvxProtectItem
aProtect( SID_RULER_PROTECT
);
920 maMarkRect
= mpDrawView
->GetAllMarkedRect();
922 const bool bRTL
= GetDoc() && GetDoc()->GetDefaultWritingMode() == css::text::WritingMode_RL_TB
;
923 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, bRTL
));
925 if( mpDrawView
->AreObjectsMarked() )
927 if( mpDrawView
->IsTextEdit() )
929 SdrObject
* pObj
= mpDrawView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
930 if( pObj
->GetObjInventor() == SdrInventor::Default
)
932 SfxItemSet
aEditAttr( GetDoc()->GetPool() );
933 mpDrawView
->GetAttributes( aEditAttr
);
934 if( aEditAttr
.GetItemState( EE_PARA_TABS
) >= SfxItemState::DEFAULT
)
936 const SvxTabStopItem
& rItem
= aEditAttr
.Get( EE_PARA_TABS
);
939 const SvxLRSpaceItem
& rLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
940 SvxLRSpaceItem
aLRSpaceItem( rLRSpaceItem
.GetLeft(),
941 rLRSpaceItem
.GetRight(),
942 rLRSpaceItem
.GetTextFirstLineOffset(), SID_ATTR_PARA_LRSPACE
);
944 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
945 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
946 if( nOutlineLevel
!= -1 &&
947 rNumBulletItem
.GetNumRule().GetLevelCount() > nOutlineLevel
)
949 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule().GetLevel(nOutlineLevel
);
950 aLRSpaceItem
.SetTextLeft(rFormat
.GetAbsLSpace() + rLRSpaceItem
.GetTextLeft());
951 aLRSpaceItem
.SetTextFirstLineOffset(
952 rLRSpaceItem
.GetTextFirstLineOffset() + rFormat
.GetFirstLineOffset()
954 - rFormat
.GetCharTextDistance());
957 rSet
.Put( aLRSpaceItem
);
959 Point
aPos( aPagePos
+ maMarkRect
.TopLeft() );
961 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
963 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
964 ::tools::Long nLD
= rTLDItem
.GetValue();
968 aPointItem
.SetValue( aPos
);
970 ::tools::Rectangle
aParaRect(maMarkRect
);
971 if (pObj
->GetObjIdentifier() == SdrObjKind::Table
)
973 sdr::table::SdrTableObj
* pTable
= static_cast<sdr::table::SdrTableObj
*>(pObj
);
974 sdr::table::CellPos cellpos
;
975 pTable
->getActiveCellPos(cellpos
);
976 pTable
->getCellBounds(cellpos
, aParaRect
);
979 aLRSpace
.SetLeft(aPagePos
.X() + aParaRect
.Left());
981 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
983 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
984 ::tools::Long nLD
= rTLDItem
.GetValue();
985 aLRSpace
.SetLeft( aLRSpace
.GetLeft() + nLD
);
988 aLRSpace
.SetRight(aRect
.Right() + aPageSize
.Width() - aParaRect
.Right());
990 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_RIGHTDIST
) == SfxItemState::SET
)
992 const SdrMetricItem
& rTRDItem
= aEditAttr
.Get( SDRATTR_TEXT_RIGHTDIST
);
993 ::tools::Long nRD
= rTRDItem
.GetValue();
994 aLRSpace
.SetRight( aLRSpace
.GetRight() + nRD
);
997 aULSpace
.SetUpper( aPagePos
.Y() + maMarkRect
.Top() );
998 aULSpace
.SetLower( aRect
.Bottom() + aPageSize
.Height() - maMarkRect
.Bottom() );
1000 rSet
.DisableItem( SID_RULER_OBJECT
);
1002 // lock page margins
1003 aProtect
.SetSizeProtect( true );
1004 aProtect
.SetPosProtect( true );
1007 if( aEditAttr
.GetItemState( EE_PARA_WRITINGDIR
) >= SfxItemState::DEFAULT
)
1009 const SvxFrameDirectionItem
& rItem
= aEditAttr
.Get( EE_PARA_WRITINGDIR
);
1010 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, rItem
.GetValue() == SvxFrameDirection::Horizontal_RL_TB
));
1016 rSet
.DisableItem( EE_PARA_TABS
);
1017 rSet
.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT
);
1019 if( mpDrawView
->IsResizeAllowed(true) )
1021 ::tools::Rectangle
aResizeRect( maMarkRect
);
1023 aResizeRect
.SetPos(aResizeRect
.TopLeft() + aPagePos
);
1024 SvxObjectItem
aObjItem(aResizeRect
.Left(), aResizeRect
.Right(),
1025 aResizeRect
.Top(), aResizeRect
.Bottom());
1027 rSet
.DisableItem( EE_PARA_TABS
);
1031 rSet
.DisableItem( SID_RULER_OBJECT
);
1037 rSet
.DisableItem( SID_RULER_OBJECT
);
1038 rSet
.DisableItem( EE_PARA_TABS
);
1041 rSet
.Put( aLRSpace
);
1042 rSet
.Put( aULSpace
);
1044 rSet
.Put( aPointItem
);
1045 rSet
.Put( aProtect
);
1048 void DrawViewShell::ExecStatusBar(SfxRequest
& rReq
)
1050 // nothing is executed during a slide show!
1051 if(HasCurrentFunction(SID_PRESENTATION
))
1056 switch ( rReq
.GetSlot() )
1060 GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM
, SfxCallMode::ASYNCHRON
);
1064 case SID_STATUS_LAYOUT
:
1066 GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT
, SfxCallMode::ASYNCHRON
);
1073 * set state of snap object entries in popup
1075 void DrawViewShell::GetSnapItemState( SfxItemSet
&rSet
)
1078 Point aMPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
1079 sal_uInt16 nHitLog
= static_cast<sal_uInt16
>(GetActiveWindow()->PixelToLogic(
1080 Size(FuPoor::HITPIX
,0)).Width());
1081 sal_uInt16 nHelpLine
;
1083 if ( !mpDrawView
->PickHelpLine(aMPos
, nHitLog
, *GetActiveWindow()->GetOutDev(), nHelpLine
, pPV
) )
1086 const SdrHelpLine
& rHelpLine
= (pPV
->GetHelpLines())[nHelpLine
];
1088 if ( rHelpLine
.GetKind() == SdrHelpLineKind::Point
)
1090 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1091 SdResId( STR_POPUP_EDIT_SNAPPOINT
)) );
1092 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1093 SdResId( STR_POPUP_DELETE_SNAPPOINT
)) );
1097 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1098 SdResId( STR_POPUP_EDIT_SNAPLINE
)) );
1099 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1100 SdResId( STR_POPUP_DELETE_SNAPLINE
)) );
1104 } // end of namespace sd
1106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */