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/ruler.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>
54 #include <strings.hrc>
56 #include <sdundogr.hxx>
57 #include <undopage.hxx>
59 #include <slideshow.hxx>
62 #include <sdresid.hxx>
63 #include <unokywds.hxx>
64 #include <drawview.hxx>
65 #include <drawdoc.hxx>
66 #include <DrawDocShell.hxx>
67 #include <sdabstdlg.hxx>
68 #include <sfx2/ipclient.hxx>
69 #include <tools/diagnose_ex.h>
70 #include <ViewShellBase.hxx>
71 #include <FormShellManager.hxx>
72 #include <LayerTabBar.hxx>
73 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
74 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
75 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
76 #include <com/sun/star/drawing/XShape.hpp>
77 #include <com/sun/star/frame/XFrame.hpp>
78 #include <editeng/lspcitem.hxx>
79 #include <editeng/ulspitem.hxx>
81 #include <comphelper/processfactory.hxx>
82 #include <oox/drawingml/diagram/diagram.hxx>
83 #include <oox/export/drawingml.hxx>
84 #include <oox/shape/ShapeFilterBase.hxx>
86 using namespace ::com::sun::star::uno
;
87 using namespace ::com::sun::star::drawing::framework
;
88 using ::com::sun::star::frame::XFrame
;
89 using ::com::sun::star::frame::XController
;
94 * handle SfxRequests for controller
96 void DrawViewShell::ExecCtrl(SfxRequest
& rReq
)
98 // except a page switch and jumps to bookmarks, nothing is executed during
100 if( HasCurrentFunction(SID_PRESENTATION
) &&
101 rReq
.GetSlot() != SID_SWITCHPAGE
&&
102 rReq
.GetSlot() != SID_JUMPTOMARK
)
107 // End text edit mode for some requests.
108 sal_uInt16 nSlot
= rReq
.GetSlot();
109 bool bAllowFocusChange
= true;
112 case SID_OUTPUT_QUALITY_COLOR
:
113 case SID_OUTPUT_QUALITY_GRAYSCALE
:
114 case SID_OUTPUT_QUALITY_BLACKWHITE
:
115 case SID_OUTPUT_QUALITY_CONTRAST
:
119 if (rReq
.GetArgs() && rReq
.GetArgs()->Count () == 1)
121 const SfxBoolItem
* pAllowFocusChange
= rReq
.GetArg
<SfxBoolItem
>(SID_SWITCHPAGE
);
122 bAllowFocusChange
= pAllowFocusChange
->GetValue();
123 if (!bAllowFocusChange
)
128 if ( mpDrawView
->IsTextEdit() )
130 mpDrawView
->SdrEndTextEdit();
134 // sal_uInt16 nSlot = rReq.GetSlot();
137 case SID_SWITCHPAGE
: // BASIC
139 // switch page in running slide show
140 if(SlideShow::IsRunning(GetViewShellBase()) && rReq
.GetArgs())
142 const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
);
143 SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber(static_cast<sal_Int32
>((pWhatPage
->GetValue()-1)>>1));
147 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
148 sal_uInt16 nSelectedPage
= 0;
150 if (! pArgs
|| pArgs
->Count () == 1)
152 nSelectedPage
= maTabControl
->GetCurPagePos();
154 else if (pArgs
->Count () == 2)
156 const SfxUInt32Item
* pWhatPage
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATPAGE
);
157 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
159 sal_Int32 nWhatPage
= static_cast<sal_Int32
>(pWhatPage
->GetValue ());
160 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue ());
161 if (nWhatKind
< PageKind::Standard
|| nWhatKind
> PageKind::Handout
)
163 #if HAVE_FEATURE_SCRIPTING
164 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
169 else if (meEditMode
!= EditMode::MasterPage
)
171 if (! CHECK_RANGE (0, nWhatPage
, GetDoc()->GetSdPageCount(nWhatKind
)))
173 #if HAVE_FEATURE_SCRIPTING
174 StarBASIC::FatalError (ERRCODE_BASIC_BAD_PROP_VALUE
);
180 nSelectedPage
= static_cast<short>(nWhatPage
);
181 mePageKind
= nWhatKind
;
186 #if HAVE_FEATURE_SCRIPTING
187 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS
);
193 if( GetDocSh() && (GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED
))
194 GetDocSh()->SetModified();
196 SwitchPage(nSelectedPage
, bAllowFocusChange
);
198 if(HasCurrentFunction(SID_BEZIER_EDIT
))
199 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
208 case SID_SWITCHLAYER
: // BASIC
210 const SfxItemSet
*pArgs
= rReq
.GetArgs ();
213 bool bCurPageValid(false);
214 sal_uInt16
nCurPage(0);
216 if(GetLayerTabControl())
218 nCurPage
= GetLayerTabControl()->GetCurPageId();
219 bCurPageValid
= true;
222 if(pArgs
&& 1 == pArgs
->Count())
224 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
228 nCurPage
= static_cast<short>(pWhatLayer
->GetValue());
229 bCurPageValid
= true;
235 OUString
aLayerName( GetLayerTabControl()->GetLayerName(nCurPage
));
236 if (!aLayerName
.isEmpty())
238 mpDrawView
->SetActiveLayer(aLayerName
);
248 case SID_PAGEMODE
: // BASIC
251 const SfxItemSet
*pArgs
= rReq
.GetArgs();
253 if (pArgs
&& pArgs
->Count () == 2)
255 const SfxBoolItem
* pIsActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
);
256 const SfxUInt32Item
* pWhatKind
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATKIND
);
258 PageKind nWhatKind
= static_cast<PageKind
>(pWhatKind
->GetValue());
259 if ( nWhatKind
>= PageKind::Standard
&& nWhatKind
<= PageKind::Handout
)
261 mbIsLayerModeActive
= pIsActive
->GetValue();
262 mePageKind
= nWhatKind
;
266 // turn on default layer of page
267 mpDrawView
->SetActiveLayer(sUNO_LayerName_layout
);
269 ChangeEditMode(EditMode::Page
, mbIsLayerModeActive
);
277 case SID_LAYERMODE
: // BASIC
279 const SfxItemSet
*pArgs
= rReq
.GetArgs();
281 if (pArgs
&& pArgs
->Count() == 2)
283 const SfxUInt32Item
* pWhatLayer
= rReq
.GetArg
<SfxUInt32Item
>(ID_VAL_WHATLAYER
);
284 EditMode nWhatLayer
= static_cast<EditMode
>(pWhatLayer
->GetValue());
285 if (nWhatLayer
== EditMode::Page
|| nWhatLayer
== EditMode::MasterPage
)
287 mbIsLayerModeActive
= rReq
.GetArg
<SfxBoolItem
>(ID_VAL_ISACTIVE
)->GetValue();
288 meEditMode
= nWhatLayer
;
292 ChangeEditMode(meEditMode
, !mbIsLayerModeActive
);
300 case SID_HEADER_AND_FOOTER
:
301 case SID_INSERT_PAGE_NUMBER
:
302 case SID_INSERT_DATE_TIME
:
304 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
305 vcl::Window
* pWin
= GetActiveWindow();
306 VclPtr
<AbstractHeaderFooterDialog
> pDlg(pFact
->CreateHeaderFooterDialog(this, pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), mpActualPage
));
307 auto xRequest
= std::make_shared
<SfxRequest
>(rReq
);
308 rReq
.Ignore(); // the 'old' request is not relevant any more
309 pDlg
->StartExecuteAsync([this, pDlg
, xRequest
](sal_Int32
/*nResult*/){
310 GetActiveWindow()->Invalidate();
311 UpdatePreview( mpActualPage
);
321 case SID_MASTER_LAYOUTS
:
323 SdPage
* pPage
= GetActualPage();
324 if (meEditMode
== EditMode::MasterPage
)
325 // Use the master page of the current page.
326 pPage
= static_cast<SdPage
*>(&pPage
->TRG_GetMasterPage());
328 SdAbstractDialogFactory
* pFact
= SdAbstractDialogFactory::Create();
329 vcl::Window
* pWin
= GetActiveWindow();
330 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateMasterLayoutDialog(pWin
? pWin
->GetFrameWeld() : nullptr, GetDoc(), pPage
));
336 case SID_OBJECTRESIZE
:
338 // The server likes to change the client size
339 OSL_ASSERT (GetViewShell()!=nullptr);
340 SfxInPlaceClient
* pIPClient
= GetViewShell()->GetIPClient();
342 if ( pIPClient
&& pIPClient
->IsObjectInPlaceActive() )
344 const SfxRectangleItem
& rRect
=
345 rReq
.GetArgs()->Get(SID_OBJECTRESIZE
);
346 ::tools::Rectangle
aRect( GetActiveWindow()->PixelToLogic( rRect
.GetValue() ) );
348 if ( mpDrawView
->AreObjectsMarked() )
350 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
352 if (rMarkList
.GetMarkCount() == 1)
354 SdrMark
* pMark
= rMarkList
.GetMark(0);
355 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
357 SdrOle2Obj
* pOle2Obj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
360 if( pOle2Obj
->GetObjRef().is() )
362 pOle2Obj
->SetLogicRect(aRect
);
374 sal_uInt16 nId
= Svx3DChildWindow::GetChildWindowId();
375 SfxViewFrame
* pFrame
= GetViewFrame();
379 Reference
< XFrame
> xFrame( pFrame
->GetFrame().GetFrameInterface(), UNO_SET_THROW
);
381 // Save the current configuration of panes and views.
382 Reference
<XControllerManager
> xControllerManager (
383 GetViewShellBase().GetController(), UNO_QUERY_THROW
);
384 Reference
<XConfigurationController
> xConfigurationController (
385 xControllerManager
->getConfigurationController(), UNO_SET_THROW
);
386 Reference
<XConfiguration
> xConfiguration (
387 xConfigurationController
->getRequestedConfiguration(), UNO_SET_THROW
);
389 SfxChildWindow
* pWindow
= pFrame
->GetChildWindow(nId
);
392 Svx3DWin
* p3DWin
= static_cast<Svx3DWin
*>(pWindow
->GetWindow());
394 p3DWin
->DocumentReload();
397 // normal forwarding to ViewFrame for execution
398 GetViewFrame()->ExecuteSlot(rReq
);
400 // From here on we must cope with this object and the frame already being
401 // deleted. Do not call any methods or use data members.
402 Reference
<XController
> xController( xFrame
->getController(), UNO_SET_THROW
);
404 // Restore the configuration.
405 xControllerManager
.set( xController
, UNO_QUERY_THROW
);
406 xConfigurationController
.set( xControllerManager
->getConfigurationController() );
407 if ( ! xConfigurationController
.is())
408 throw RuntimeException();
409 xConfigurationController
->restoreConfiguration(xConfiguration
);
411 catch (RuntimeException
&)
413 DBG_UNHANDLED_EXCEPTION("sd.view");
416 // We have to return immediately to avoid accessing this object.
424 const SfxStringItem
* pBookmark
= rReq
.GetArg
<SfxStringItem
>(SID_JUMPTOMARK
);
428 OUString
sBookmark(INetURLObject::decode(pBookmark
->GetValue(), INetURLObject::DecodeMechanism::WithCharset
));
430 rtl::Reference
< sd::SlideShow
> xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
431 if(xSlideshow
.is() && xSlideshow
->isRunning())
433 xSlideshow
->jumpToBookmark(sBookmark
);
437 GotoBookmark(sBookmark
);
445 case SID_OUTPUT_QUALITY_COLOR
:
446 case SID_OUTPUT_QUALITY_GRAYSCALE
:
447 case SID_OUTPUT_QUALITY_BLACKWHITE
:
448 case SID_OUTPUT_QUALITY_CONTRAST
:
454 case SID_MAIL_SCROLLBODY_PAGEDOWN
:
460 case SID_ATTR_YEAR2000
:
462 FmFormShell
* pFormShell
= GetViewShellBase().GetFormShellManager()->GetFormShell();
463 if (pFormShell
!= nullptr)
465 const SfxPoolItem
* pItem
;
466 if (rReq
.GetArgs()->GetItemState(
467 SID_ATTR_YEAR2000
, true, &pItem
) == SfxItemState::SET
)
468 pFormShell
->SetY2KState (
469 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
476 case SID_OPT_LOCALE_CHANGED
:
478 GetActiveWindow()->Invalidate();
479 UpdatePreview( mpActualPage
);
484 case SID_REGENERATE_DIAGRAM
:
486 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
487 if (rMarkList
.GetMarkCount() == 1)
489 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
490 Reference
<css::drawing::XShape
> xShape(pObj
->getUnoShape(), UNO_QUERY
);
492 if (oox::drawingml::DrawingML::IsDiagram(xShape
))
494 mpDrawView
->UnmarkAll();
496 css::uno::Reference
<css::uno::XComponentContext
> xContext
497 = comphelper::getProcessComponentContext();
498 rtl::Reference
<oox::shape::ShapeFilterBase
> xFilter(
499 new oox::shape::ShapeFilterBase(xContext
));
500 xFilter
->setTargetDocument(GetDocSh()->GetModel());
501 xFilter
->importTheme();
502 oox::drawingml::reloadDiagram(pObj
, *xFilter
);
504 mpDrawView
->MarkObj(pObj
, mpDrawView
->GetSdrPageView());
512 case SID_EDIT_DIAGRAM
:
514 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
515 if (rMarkList
.GetMarkCount() == 1)
517 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
518 Reference
<css::drawing::XShape
> xShape(pObj
->getUnoShape(), UNO_QUERY
);
520 if (oox::drawingml::DrawingML::IsDiagram(xShape
))
522 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
523 ScopedVclPtr
<VclAbstractDialog
> pDlg
524 = pFact
->CreateDiagramDialog(GetFrameWeld(), pObj
->GetDiagramData());
538 void DrawViewShell::ExecRuler(SfxRequest
& rReq
)
540 // nothing is executed during a slide show!
541 if(HasCurrentFunction(SID_PRESENTATION
))
546 const SfxItemSet
* pArgs
= rReq
.GetArgs();
547 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
548 Size aPageSize
= mpActualPage
->GetSize();
549 Size aViewSize
= GetActiveWindow()->GetViewSize();
551 switch ( rReq
.GetSlot() )
553 case SID_ATTR_LONG_LRSPACE
:
556 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
557 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
559 const SvxLongLRSpaceItem
& rLRSpace
= static_cast<const SvxLongLRSpaceItem
&>(
560 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
)));
562 if( mpDrawView
->IsTextEdit() )
564 ::tools::Rectangle aRect
= maMarkRect
;
565 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
566 aRect
.SetLeft( rLRSpace
.GetLeft() );
567 aRect
.SetRight( aViewSize
.Width() - rLRSpace
.GetRight() );
568 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
569 if ( aRect
!= maMarkRect
)
571 mpDrawView
->SetAllMarkedRect(aRect
);
572 maMarkRect
= mpDrawView
->GetAllMarkedRect();
573 Invalidate( SID_RULER_OBJECT
);
578 ::tools::Long nLeft
= std::max(::tools::Long(0), rLRSpace
.GetLeft() - aPagePos
.X());
579 ::tools::Long nRight
= std::max(::tools::Long(0), rLRSpace
.GetRight() + aPagePos
.X() +
580 aPageSize
.Width() - aViewSize
.Width());
582 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
584 for ( i
= 0; i
< nPageCnt
; i
++)
586 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
587 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
589 pPage
->GetLeftBorder(),
590 pPage
->GetRightBorder(),
592 pUndoGroup
->AddAction(pUndo
);
593 pPage
->SetLeftBorder(nLeft
);
594 pPage
->SetRightBorder(nRight
);
596 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
598 for (i
= 0; i
< nPageCnt
; i
++)
600 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
601 SdUndoAction
* pUndo
= new SdPageLRUndoAction(GetDoc(),
603 pPage
->GetLeftBorder(),
604 pPage
->GetRightBorder(),
606 pUndoGroup
->AddAction(pUndo
);
607 pPage
->SetLeftBorder(nLeft
);
608 pPage
->SetRightBorder(nRight
);
613 // give the undo group to the undo manager
614 GetViewFrame()->GetObjectShell()->GetUndoManager()->
615 AddUndoAction(std::move(pUndoGroup
));
618 case SID_ATTR_LONG_ULSPACE
:
621 std::unique_ptr
<SdUndoGroup
> pUndoGroup(new SdUndoGroup(GetDoc()));
622 pUndoGroup
->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER
));
624 const SvxLongULSpaceItem
& rULSpace
= static_cast<const SvxLongULSpaceItem
&>(
625 pArgs
->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
)));
627 if( mpDrawView
->IsTextEdit() )
629 ::tools::Rectangle aRect
= maMarkRect
;
630 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
631 aRect
.SetTop( rULSpace
.GetUpper() );
632 aRect
.SetBottom( aViewSize
.Height() - rULSpace
.GetLower() );
633 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
635 if ( aRect
!= maMarkRect
)
637 mpDrawView
->SetAllMarkedRect(aRect
);
638 maMarkRect
= mpDrawView
->GetAllMarkedRect();
639 Invalidate( SID_RULER_OBJECT
);
644 ::tools::Long nUpper
= std::max(::tools::Long(0), rULSpace
.GetUpper() - aPagePos
.Y());
645 ::tools::Long nLower
= std::max(::tools::Long(0), rULSpace
.GetLower() + aPagePos
.Y() +
646 aPageSize
.Height() - aViewSize
.Height());
648 sal_uInt16 nPageCnt
= GetDoc()->GetSdPageCount(mePageKind
);
650 for ( i
= 0; i
< nPageCnt
; i
++)
652 SdPage
* pPage
= GetDoc()->GetSdPage(i
, mePageKind
);
653 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
655 pPage
->GetUpperBorder(),
656 pPage
->GetLowerBorder(),
658 pUndoGroup
->AddAction(pUndo
);
659 pPage
->SetUpperBorder(nUpper
);
660 pPage
->SetLowerBorder(nLower
);
662 nPageCnt
= GetDoc()->GetMasterSdPageCount(mePageKind
);
664 for (i
= 0; i
< nPageCnt
; i
++)
666 SdPage
* pPage
= GetDoc()->GetMasterSdPage(i
, mePageKind
);
667 SdUndoAction
* pUndo
= new SdPageULUndoAction(GetDoc(),
669 pPage
->GetUpperBorder(),
670 pPage
->GetLowerBorder(),
672 pUndoGroup
->AddAction(pUndo
);
673 pPage
->SetUpperBorder(nUpper
);
674 pPage
->SetLowerBorder(nLower
);
679 // give the undo group to the undo manager
680 GetViewFrame()->GetObjectShell()->GetUndoManager()->
681 AddUndoAction(std::move(pUndoGroup
));
684 case SID_RULER_OBJECT
:
687 ::tools::Rectangle aRect
= maMarkRect
;
688 aRect
.SetPos(aRect
.TopLeft() + aPagePos
);
690 const SvxObjectItem
& rOI
= static_cast<const SvxObjectItem
&>(
691 pArgs
->Get(GetPool().GetWhich(SID_RULER_OBJECT
)));
693 if ( rOI
.GetStartX() != rOI
.GetEndX() )
695 aRect
.SetLeft( rOI
.GetStartX() );
696 aRect
.SetRight( rOI
.GetEndX() );
698 if ( rOI
.GetStartY() != rOI
.GetEndY() )
700 aRect
.SetTop( rOI
.GetStartY() );
701 aRect
.SetBottom( rOI
.GetEndY() );
703 aRect
.SetPos(aRect
.TopLeft() - aPagePos
);
704 if ( aRect
!= maMarkRect
)
706 mpDrawView
->SetAllMarkedRect(aRect
);
707 maMarkRect
= mpDrawView
->GetAllMarkedRect();
708 Invalidate( SID_RULER_OBJECT
);
712 case SID_ATTR_TABSTOP
:
713 if (pArgs
&& mpDrawView
->IsTextEdit())
715 const SvxTabStopItem
& rItem
= pArgs
->Get( EE_PARA_TABS
);
717 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_TABS
, EE_PARA_TABS
>{} );
719 aEditAttr
.Put( rItem
);
720 mpDrawView
->SetAttributes( aEditAttr
);
722 Invalidate(SID_ATTR_TABSTOP
);
725 case SID_ATTR_PARA_LINESPACE
:
728 SvxLineSpacingItem aParaLineSP
= static_cast<const SvxLineSpacingItem
&>(pArgs
->Get(
729 GetPool().GetWhich(SID_ATTR_PARA_LINESPACE
)));
731 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_SBL
, EE_PARA_SBL
>{} );
732 aParaLineSP
.SetWhich( EE_PARA_SBL
);
734 aEditAttr
.Put( aParaLineSP
);
735 mpDrawView
->SetAttributes( aEditAttr
);
737 Invalidate(SID_ATTR_PARA_LINESPACE
);
740 case SID_ATTR_PARA_ADJUST_LEFT
:
742 SvxAdjustItem
aItem( SvxAdjust::Left
, EE_PARA_JUST
);
743 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_JUST
, EE_PARA_JUST
>{} );
745 aEditAttr
.Put( aItem
);
746 mpDrawView
->SetAttributes( aEditAttr
);
748 Invalidate(SID_ATTR_PARA_ADJUST_LEFT
);
751 case SID_ATTR_PARA_ADJUST_CENTER
:
753 SvxAdjustItem
aItem( SvxAdjust::Center
, EE_PARA_JUST
);
754 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_JUST
, EE_PARA_JUST
>{} );
756 aEditAttr
.Put( aItem
);
757 mpDrawView
->SetAttributes( aEditAttr
);
759 Invalidate(SID_ATTR_PARA_ADJUST_CENTER
);
762 case SID_ATTR_PARA_ADJUST_RIGHT
:
764 SvxAdjustItem
aItem( SvxAdjust::Right
, EE_PARA_JUST
);
765 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_JUST
, EE_PARA_JUST
>{} );
767 aEditAttr
.Put( aItem
);
768 mpDrawView
->SetAttributes( aEditAttr
);
770 Invalidate(SID_ATTR_PARA_ADJUST_RIGHT
);
773 case SID_ATTR_PARA_ADJUST_BLOCK
:
775 SvxAdjustItem
aItem( SvxAdjust::Block
, EE_PARA_JUST
);
776 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_JUST
, EE_PARA_JUST
>{} );
778 aEditAttr
.Put( aItem
);
779 mpDrawView
->SetAttributes( aEditAttr
);
781 Invalidate(SID_ATTR_PARA_ADJUST_BLOCK
);
784 case SID_ATTR_PARA_ULSPACE
:
787 SvxULSpaceItem aULSP
= static_cast<const SvxULSpaceItem
&>(pArgs
->Get(
788 GetPool().GetWhich(SID_ATTR_PARA_ULSPACE
)));
789 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_ULSPACE
, EE_PARA_ULSPACE
>{} );
790 aULSP
.SetWhich( EE_PARA_ULSPACE
);
792 aEditAttr
.Put( aULSP
);
793 mpDrawView
->SetAttributes( aEditAttr
);
795 Invalidate(SID_ATTR_PARA_ULSPACE
);
798 case SID_ATTR_PARA_LRSPACE
:
801 SvxLRSpaceItem aLRSpace
= static_cast<const SvxLRSpaceItem
&>(pArgs
->Get(
802 GetPool().GetWhich(SID_ATTR_PARA_LRSPACE
)));
804 SfxItemSet
aEditAttr( GetPool(), svl::Items
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
>{} );
805 aLRSpace
.SetWhich( EE_PARA_LRSPACE
);
807 aEditAttr
.Put( aLRSpace
);
808 mpDrawView
->SetAttributes( aEditAttr
);
810 Invalidate(SID_ATTR_PARA_LRSPACE
);
813 case SID_ATTR_LRSPACE
:
814 if (pArgs
&& mpDrawView
->IsTextEdit())
816 sal_uInt16 nId
= SID_ATTR_PARA_LRSPACE
;
817 const SvxLRSpaceItem
& rItem
= static_cast<const SvxLRSpaceItem
&>(
820 static const sal_uInt16 aWhichTable
[]=
822 EE_PARA_OUTLLEVEL
, EE_PARA_OUTLLEVEL
,
823 EE_PARA_LRSPACE
, EE_PARA_LRSPACE
,
824 EE_PARA_NUMBULLET
, EE_PARA_NUMBULLET
,
828 SfxItemSet
aEditAttr( GetDoc()->GetPool(),
830 mpDrawView
->GetAttributes( aEditAttr
);
832 nId
= EE_PARA_LRSPACE
;
833 SvxLRSpaceItem
aLRSpaceItem( rItem
.GetLeft(),
834 rItem
.GetRight(), rItem
.GetTextLeft(),
835 rItem
.GetTextFirstLineOffset(), nId
);
837 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
838 const SvxLRSpaceItem
& rOrigLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
839 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
840 if( nOutlineLevel
!= -1 &&
841 rNumBulletItem
.GetNumRule() &&
842 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
844 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
845 SvxNumberFormat
aFormat(rFormat
);
847 // left margin gets distributed onto LRSpace item
848 // and number format AbsLSpace - this fixes
849 // n#707779 (previously, LRSpace left indent could
850 // become negative - EditEngine really does not
852 const auto nAbsLSpace
=aFormat
.GetAbsLSpace();
853 const ::tools::Long nTxtLeft
=rItem
.GetTextLeft();
854 const ::tools::Long nLeftIndent
=std::max(::tools::Long(0),nTxtLeft
- nAbsLSpace
);
855 aLRSpaceItem
.SetTextLeft(nLeftIndent
);
856 // control for clipped left indent - remainder
857 // reduces number format first line indent
858 aFormat
.SetAbsLSpace(nTxtLeft
- nLeftIndent
);
860 // negative first line indent goes to the number
861 // format, positive to the lrSpace item
862 if( rItem
.GetTextFirstLineOffset() < 0 )
864 aFormat
.SetFirstLineOffset(
865 rItem
.GetTextFirstLineOffset()
866 - rOrigLRSpaceItem
.GetTextFirstLineOffset()
867 + aFormat
.GetCharTextDistance());
868 aLRSpaceItem
.SetTextFirstLineOffset(0);
872 aFormat
.SetFirstLineOffset(0);
873 aLRSpaceItem
.SetTextFirstLineOffset(
874 rItem
.GetTextFirstLineOffset()
875 - aFormat
.GetFirstLineOffset() //TODO: overflow
876 + aFormat
.GetCharTextDistance());
879 if( rFormat
!= aFormat
)
882 rNumBulletItem
.GetNumRule()->SetLevel(nOutlineLevel
,aFormat
);
883 aEditAttr
.Put( rNumBulletItem
);
884 aEditAttr
.Put( aLRSpaceItem
);
885 mpDrawView
->SetAttributes( aEditAttr
);
887 Invalidate(SID_ATTR_PARA_LRSPACE
);
892 // only put lrSpace item
893 SfxItemSet
aEditAttrReduced( GetDoc()->GetPool(),
894 svl::Items
<EE_PARA_LRSPACE
, EE_PARA_LRSPACE
>{} );
895 aEditAttrReduced
.Put( aLRSpaceItem
);
896 mpDrawView
->SetAttributes( aEditAttrReduced
);
898 Invalidate(SID_ATTR_PARA_LRSPACE
);
904 void DrawViewShell::GetRulerState(SfxItemSet
& rSet
)
908 if (mpDrawView
->GetSdrPageView())
910 aOrigin
= mpDrawView
->GetSdrPageView()->GetPageOrigin();
913 Size aViewSize
= GetActiveWindow()->GetViewSize();
915 const Point
aPagePos( GetActiveWindow()->GetViewOrigin() );
916 Size aPageSize
= mpActualPage
->GetSize();
918 ::tools::Rectangle
aRect(aPagePos
, Point( aViewSize
.Width() - (aPagePos
.X() + aPageSize
.Width()),
919 aViewSize
.Height() - (aPagePos
.Y() + aPageSize
.Height())));
921 if( mpDrawView
->IsTextEdit() )
923 Point aPnt1
= GetActiveWindow()->GetWinViewPos();
924 ::tools::Rectangle
aMinMaxRect( aPnt1
, Size(-1, -1) );
925 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aMinMaxRect
) );
929 rSet
.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX
, aRect
) );
932 SvxLongLRSpaceItem
aLRSpace(aPagePos
.X() + mpActualPage
->GetLeftBorder(),
933 aRect
.Right() + mpActualPage
->GetRightBorder(),
934 GetPool().GetWhich(SID_ATTR_LONG_LRSPACE
));
935 SvxLongULSpaceItem
aULSpace(aPagePos
.Y() + mpActualPage
->GetUpperBorder(),
936 aRect
.Bottom() + mpActualPage
->GetLowerBorder(),
937 GetPool().GetWhich(SID_ATTR_LONG_ULSPACE
));
938 rSet
.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos
, aViewSize
.Width(),
939 aViewSize
.Height()));
940 SfxPointItem
aPointItem( SID_RULER_NULL_OFFSET
, aPagePos
+ aOrigin
);
942 SvxProtectItem
aProtect( SID_RULER_PROTECT
);
944 maMarkRect
= mpDrawView
->GetAllMarkedRect();
946 const bool bRTL
= GetDoc() && GetDoc()->GetDefaultWritingMode() == css::text::WritingMode_RL_TB
;
947 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, bRTL
));
949 if( mpDrawView
->AreObjectsMarked() )
951 if( mpDrawView
->IsTextEdit() )
953 SdrObject
* pObj
= mpDrawView
->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
954 if( pObj
->GetObjInventor() == SdrInventor::Default
)
956 SfxItemSet
aEditAttr( GetDoc()->GetPool() );
957 mpDrawView
->GetAttributes( aEditAttr
);
958 if( aEditAttr
.GetItemState( EE_PARA_TABS
) >= SfxItemState::DEFAULT
)
960 const SvxTabStopItem
& rItem
= aEditAttr
.Get( EE_PARA_TABS
);
963 const SvxLRSpaceItem
& rLRSpaceItem
= aEditAttr
.Get( EE_PARA_LRSPACE
);
964 SvxLRSpaceItem
aLRSpaceItem( rLRSpaceItem
.GetLeft(),
965 rLRSpaceItem
.GetRight(), rLRSpaceItem
.GetTextLeft(),
966 rLRSpaceItem
.GetTextFirstLineOffset(), SID_ATTR_PARA_LRSPACE
);
968 const sal_Int16 nOutlineLevel
= aEditAttr
.Get( EE_PARA_OUTLLEVEL
).GetValue();
969 const SvxNumBulletItem
& rNumBulletItem
= aEditAttr
.Get( EE_PARA_NUMBULLET
);
970 if( nOutlineLevel
!= -1 &&
971 rNumBulletItem
.GetNumRule() &&
972 rNumBulletItem
.GetNumRule()->GetLevelCount() > nOutlineLevel
)
974 const SvxNumberFormat
& rFormat
= rNumBulletItem
.GetNumRule()->GetLevel(nOutlineLevel
);
975 aLRSpaceItem
.SetTextLeft(rFormat
.GetAbsLSpace() + rLRSpaceItem
.GetTextLeft());
976 aLRSpaceItem
.SetTextFirstLineOffset(
977 rLRSpaceItem
.GetTextFirstLineOffset() + rFormat
.GetFirstLineOffset()
979 - rFormat
.GetCharTextDistance());
982 rSet
.Put( aLRSpaceItem
);
984 Point
aPos( aPagePos
+ maMarkRect
.TopLeft() );
986 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
988 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
989 ::tools::Long nLD
= rTLDItem
.GetValue();
993 aPointItem
.SetValue( aPos
);
995 ::tools::Rectangle
aParaRect(maMarkRect
);
996 if (pObj
->GetObjIdentifier() == OBJ_TABLE
)
998 sdr::table::SdrTableObj
* pTable
= static_cast<sdr::table::SdrTableObj
*>(pObj
);
999 sdr::table::CellPos cellpos
;
1000 pTable
->getActiveCellPos(cellpos
);
1001 pTable
->getCellBounds(cellpos
, aParaRect
);
1004 aLRSpace
.SetLeft(aPagePos
.X() + aParaRect
.Left());
1006 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_LEFTDIST
) == SfxItemState::SET
)
1008 const SdrMetricItem
& rTLDItem
= aEditAttr
.Get( SDRATTR_TEXT_LEFTDIST
);
1009 ::tools::Long nLD
= rTLDItem
.GetValue();
1010 aLRSpace
.SetLeft( aLRSpace
.GetLeft() + nLD
);
1013 aLRSpace
.SetRight(aRect
.Right() + aPageSize
.Width() - aParaRect
.Right());
1015 if ( aEditAttr
.GetItemState( SDRATTR_TEXT_RIGHTDIST
) == SfxItemState::SET
)
1017 const SdrMetricItem
& rTRDItem
= aEditAttr
.Get( SDRATTR_TEXT_RIGHTDIST
);
1018 ::tools::Long nRD
= rTRDItem
.GetValue();
1019 aLRSpace
.SetRight( aLRSpace
.GetRight() + nRD
);
1022 aULSpace
.SetUpper( aPagePos
.Y() + maMarkRect
.Top() );
1023 aULSpace
.SetLower( aRect
.Bottom() + aPageSize
.Height() - maMarkRect
.Bottom() );
1025 rSet
.DisableItem( SID_RULER_OBJECT
);
1027 // lock page margins
1028 aProtect
.SetSizeProtect( true );
1029 aProtect
.SetPosProtect( true );
1032 if( aEditAttr
.GetItemState( EE_PARA_WRITINGDIR
) >= SfxItemState::DEFAULT
)
1034 const SvxFrameDirectionItem
& rItem
= aEditAttr
.Get( EE_PARA_WRITINGDIR
);
1035 rSet
.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT
, rItem
.GetValue() == SvxFrameDirection::Horizontal_RL_TB
));
1041 rSet
.DisableItem( EE_PARA_TABS
);
1042 rSet
.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT
);
1044 if( mpDrawView
->IsResizeAllowed(true) )
1046 ::tools::Rectangle
aResizeRect( maMarkRect
);
1048 aResizeRect
.SetPos(aResizeRect
.TopLeft() + aPagePos
);
1049 SvxObjectItem
aObjItem(aResizeRect
.Left(), aResizeRect
.Right(),
1050 aResizeRect
.Top(), aResizeRect
.Bottom());
1052 rSet
.DisableItem( EE_PARA_TABS
);
1056 rSet
.DisableItem( SID_RULER_OBJECT
);
1062 rSet
.DisableItem( SID_RULER_OBJECT
);
1063 rSet
.DisableItem( EE_PARA_TABS
);
1066 rSet
.Put( aLRSpace
);
1067 rSet
.Put( aULSpace
);
1069 rSet
.Put( aPointItem
);
1070 rSet
.Put( aProtect
);
1073 void DrawViewShell::ExecStatusBar(SfxRequest
& rReq
)
1075 // nothing is executed during a slide show!
1076 if(HasCurrentFunction(SID_PRESENTATION
))
1081 switch ( rReq
.GetSlot() )
1085 GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM
, SfxCallMode::ASYNCHRON
);
1089 case SID_STATUS_LAYOUT
:
1091 GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT
, SfxCallMode::ASYNCHRON
);
1098 * set state of snap object entries in popup
1100 void DrawViewShell::GetSnapItemState( SfxItemSet
&rSet
)
1103 Point aMPos
= GetActiveWindow()->PixelToLogic(maMousePos
);
1104 sal_uInt16 nHitLog
= static_cast<sal_uInt16
>(GetActiveWindow()->PixelToLogic(
1105 Size(FuPoor::HITPIX
,0)).Width());
1106 sal_uInt16 nHelpLine
;
1108 if ( !mpDrawView
->PickHelpLine(aMPos
, nHitLog
, *GetActiveWindow(), nHelpLine
, pPV
) )
1111 const SdrHelpLine
& rHelpLine
= (pPV
->GetHelpLines())[nHelpLine
];
1113 if ( rHelpLine
.GetKind() == SdrHelpLineKind::Point
)
1115 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1116 SdResId( STR_POPUP_EDIT_SNAPPOINT
)) );
1117 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1118 SdResId( STR_POPUP_DELETE_SNAPPOINT
)) );
1122 rSet
.Put( SfxStringItem( SID_SET_SNAPITEM
,
1123 SdResId( STR_POPUP_EDIT_SNAPLINE
)) );
1124 rSet
.Put( SfxStringItem( SID_DELETE_SNAPITEM
,
1125 SdResId( STR_POPUP_DELETE_SNAPLINE
)) );
1129 } // end of namespace sd
1131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */