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 <com/sun/star/presentation/XPresentation2.hpp>
23 #include <com/sun/star/form/FormButtonType.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <i18nutil/unicode.hxx>
26 #include <i18nutil/transliteration.hxx>
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/uno/Any.hxx>
30 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
31 #include <comphelper/lok.hxx>
32 #include <comphelper/propertyvalue.hxx>
33 #include <editeng/editstat.hxx>
34 #include <editeng/outlobj.hxx>
35 #include <vcl/svapp.hxx>
36 #include <vcl/weld.hxx>
37 #include <svl/urlbmk.hxx>
38 #include <svx/clipfmtitem.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdopath.hxx>
41 #include <svx/svdundo.hxx>
42 #include <svx/svdorect.hxx>
43 #include <svl/eitem.hxx>
44 #include <svl/intitem.hxx>
45 #include <svl/poolitem.hxx>
46 #include <svl/stritem.hxx>
47 #include <editeng/eeitem.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <sfx2/request.hxx>
51 #include <svx/svxids.hrc>
52 #include <editeng/flditem.hxx>
53 #include <svx/obj3d.hxx>
54 #include <svx/svdobjkind.hxx>
55 #include <svx/svdouno.hxx>
56 #include <svx/dataaccessdescriptor.hxx>
57 #include <tools/urlobj.hxx>
58 #include <sfx2/ipclient.hxx>
59 #include <avmedia/mediawindow.hxx>
60 #include <svl/urihelper.hxx>
61 #include <sfx2/docfile.hxx>
62 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
63 #include <osl/diagnose.h>
65 #include <DrawViewShell.hxx>
66 #include <slideshow.hxx>
67 #include <ViewShellHint.hxx>
68 #include <framework/FrameworkHelper.hxx>
70 #include <strings.hrc>
72 #include <drawdoc.hxx>
75 #include <fuconrec.hxx>
76 #include <fuconcs.hxx>
77 #include <fuconuno.hxx>
78 #include <fuconbez.hxx>
79 #include <fuediglu.hxx>
80 #include <fuconarc.hxx>
81 #include <fucon3d.hxx>
82 #include <sdresid.hxx>
83 #include <unokywds.hxx>
84 #include <Outliner.hxx>
86 #include <FrameView.hxx>
87 #include <zoomlist.hxx>
88 #include <drawview.hxx>
89 #include <DrawDocShell.hxx>
90 #include <ViewShellBase.hxx>
91 #include <ToolBarManager.hxx>
92 #include <anminfo.hxx>
93 #include <optsitem.hxx>
95 #include <fuformatpaintbrush.hxx>
98 #include <basegfx/utils/zoomtools.hxx>
100 using namespace ::com::sun::star
;
101 using namespace ::com::sun::star::uno
;
102 using namespace ::com::sun::star::presentation
;
103 using namespace ::com::sun::star::beans
;
107 // Permanent Functions
109 static void ImpAddPrintableCharactersToTextEdit(SfxRequest
const & rReq
, ::sd::View
* pView
)
111 // evtl. feed characters to activated textedit
112 const SfxItemSet
* pSet
= rReq
.GetArgs();
117 OUString aInputString
;
119 if(SfxItemState::SET
== pSet
->GetItemState(SID_ATTR_CHAR
))
120 aInputString
= pSet
->Get(SID_ATTR_CHAR
).GetValue();
122 if(aInputString
.isEmpty())
125 OutlinerView
* pOLV
= pView
->GetTextEditOutlinerView();
129 for(sal_Int32
a(0); a
< aInputString
.getLength(); a
++)
131 vcl::KeyCode aKeyCode
;
132 // tdf#38669 - create the key event using a Unicode character
133 KeyEvent
aKeyEvent(aInputString
[a
], aKeyCode
);
135 // add actual character
136 pOLV
->PostKeyEvent(aKeyEvent
);
141 void DrawViewShell::FuPermanent(SfxRequest
& rReq
)
143 // We do not execute a thing during a native slide show
145 if (SlideShow::IsRunning(GetViewShellBase()))
148 sal_uInt16 nSId
= rReq
.GetSlot();
150 if( HasCurrentFunction() &&
151 ( nSId
== SID_TEXTEDIT
|| nSId
== SID_ATTR_CHAR
|| nSId
== SID_TEXT_FITTOSIZE
||
152 nSId
== SID_ATTR_CHAR_VERTICAL
|| nSId
== SID_TEXT_FITTOSIZE_VERTICAL
) )
154 rtl::Reference
<FuPoor
> xFunc( GetCurrentFunction() );
156 FuText
* pFuText
= dynamic_cast< FuText
* >( xFunc
.get() );
160 pFuText
->SetPermanent(true);
161 xFunc
->ReceiveRequest( rReq
);
165 // evtl. feed characters to activated textedit
166 if(SID_ATTR_CHAR
== nSId
&& GetView() && GetView()->IsTextEdit())
167 ImpAddPrintableCharactersToTextEdit(rReq
, GetView());
175 sal_uInt16 nOldSId
= 0;
176 bool bPermanent
= false;
181 if(HasCurrentFunction())
183 if( (nSId
== SID_FORMATPAINTBRUSH
) && (GetCurrentFunction()->GetSlotID() == SID_TEXTEDIT
) )
185 // save text edit mode for format paintbrush!
186 SetOldFunction( GetCurrentFunction() );
190 if(GetOldFunction() == GetCurrentFunction())
192 SetOldFunction(nullptr);
196 if ( nSId
!= SID_TEXTEDIT
&& nSId
!= SID_ATTR_CHAR
&& nSId
!= SID_TEXT_FITTOSIZE
&&
197 nSId
!= SID_ATTR_CHAR_VERTICAL
&& nSId
!= SID_TEXT_FITTOSIZE_VERTICAL
&&
198 nSId
!= SID_FORMATPAINTBRUSH
&&
199 mpDrawView
->IsTextEdit() )
201 mpDrawView
->SdrEndTextEdit();
204 if( HasCurrentFunction() )
206 nOldSId
= GetCurrentFunction()->GetSlotID();
208 if (nOldSId
== nSId
||
209 ((nOldSId
== SID_TEXTEDIT
|| nOldSId
== SID_ATTR_CHAR
|| nOldSId
== SID_TEXT_FITTOSIZE
||
210 nOldSId
== SID_ATTR_CHAR_VERTICAL
|| nOldSId
== SID_TEXT_FITTOSIZE_VERTICAL
) &&
211 (nSId
== SID_TEXTEDIT
|| nSId
== SID_ATTR_CHAR
|| nSId
== SID_TEXT_FITTOSIZE
||
212 nSId
== SID_ATTR_CHAR_VERTICAL
|| nSId
== SID_TEXT_FITTOSIZE_VERTICAL
)))
217 GetCurrentFunction()->Deactivate();
220 SetCurrentFunction(nullptr);
222 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
223 rBind
.Invalidate(nOldSId
);
224 rBind
.Update(nOldSId
);
227 // for LibreOfficeKit - choosing a shape should construct it directly
228 bool bCreateDirectly
= false;
232 case SID_TEXTEDIT
: // BASIC ???
234 case SID_ATTR_CHAR_VERTICAL
:
235 case SID_TEXT_FITTOSIZE
:
236 case SID_TEXT_FITTOSIZE_VERTICAL
:
238 SetCurrentFunction( FuText::Create(this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
) );
239 GetCurrentFunction()->DoExecute(rReq
);
241 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
242 rBindings
.Invalidate( SID_ATTR_CHAR
);
243 rBindings
.Invalidate( SID_ATTR_CHAR_VERTICAL
);
244 rBindings
.Invalidate( SID_TEXT_FITTOSIZE
);
245 rBindings
.Invalidate( SID_TEXT_FITTOSIZE_VERTICAL
);
247 // evtl. feed characters to activated textedit
248 if(SID_ATTR_CHAR
== nSId
&& GetView() && GetView()->IsTextEdit())
249 ImpAddPrintableCharactersToTextEdit(rReq
, GetView());
253 const SfxItemSet
* pArgs
= rReq
.GetArgs();
254 if (pArgs
&& pArgs
->HasItem(FN_PARAM_1
))
255 bCreateDirectly
= static_cast<const SfxBoolItem
&>(pArgs
->Get(FN_PARAM_1
)).GetValue();
259 case SID_FM_CREATE_CONTROL
:
261 SetCurrentFunction( FuConstructUnoControl::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
266 case SID_FM_CREATE_FIELDCONTROL
:
268 const SfxUnoAnyItem
* pDescriptorItem
= rReq
.GetArg
<SfxUnoAnyItem
>(SID_FM_DATACCESS_DESCRIPTOR
);
269 DBG_ASSERT( pDescriptorItem
, "DrawViewShell::FuPermanent(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
274 FmFormView
* pFormView
= mpDrawView
.get();
275 SdrPageView
* pPageView
= pFormView
? pFormView
->GetSdrPageView() : nullptr;
279 svx::ODataAccessDescriptor
aDescriptor(pDescriptorItem
->GetValue());
280 rtl::Reference
<SdrObject
> pNewDBField
= pFormView
->CreateFieldControl(aDescriptor
);
284 ::tools::Rectangle aVisArea
= GetActiveWindow()->PixelToLogic(::tools::Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
285 Point
aObjPos(aVisArea
.Center());
286 Size
aObjSize(pNewDBField
->GetLogicRect().GetSize());
287 aObjPos
.AdjustX( -(aObjSize
.Width() / 2) );
288 aObjPos
.AdjustY( -(aObjSize
.Height() / 2) );
289 ::tools::Rectangle
aNewObjectRectangle(aObjPos
, aObjSize
);
291 pNewDBField
->SetLogicRect(aNewObjectRectangle
);
293 GetView()->InsertObjectAtView(pNewDBField
.get(), *pPageView
);
301 case SID_OBJECT_SELECT
:
302 case SID_OBJECT_ROTATE
:
303 case SID_OBJECT_MIRROR
:
304 case SID_OBJECT_CROP
:
305 case SID_OBJECT_TRANSPARENCE
:
306 case SID_OBJECT_GRADIENT
:
307 case SID_OBJECT_SHEAR
:
308 case SID_OBJECT_CROOK_ROTATE
:
309 case SID_OBJECT_CROOK_SLANT
:
310 case SID_OBJECT_CROOK_STRETCH
:
311 case SID_CONVERT_TO_3D_LATHE
:
313 sal_uInt16 nSlotId
= rReq
.GetSlot();
316 if( nOldSId
== nSlotId
)
318 nSlotId
= SID_OBJECT_SELECT
;
319 rReq
.SetSlot( nSlotId
);
322 if (nSlotId
== SID_OBJECT_CROOK_ROTATE
||
323 nSlotId
== SID_OBJECT_CROOK_SLANT
||
324 nSlotId
== SID_OBJECT_CROOK_STRETCH
)
326 if ( mpDrawView
->GetMarkedObjectList().GetMarkCount() > 0 &&
327 !mpDrawView
->IsCrookAllowed( mpDrawView
->IsCrookNoContortion() ) )
329 if ( mpDrawView
->IsPresObjSelected() )
331 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
332 VclMessageType::Info
, VclButtonsType::Ok
,
333 SdResId(STR_ACTION_NOTPOSSIBLE
)));
338 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
339 VclMessageType::Question
, VclButtonsType::YesNo
,
340 SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER
)));
341 if (xQueryBox
->run() == RET_YES
)
343 // implicit transformation into bezier
344 weld::WaitObject
aWait(GetFrameWeld());
345 mpDrawView
->ConvertMarkedToPathObj(false);
350 else if (nSlotId
== SID_OBJECT_SHEAR
)
353 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
354 const size_t nMarkCnt
= rMarkList
.GetMarkCount();
355 bool b3DObjMarked
= false;
357 while (i
< nMarkCnt
&& !b3DObjMarked
)
359 if (DynCastE3dObject( rMarkList
.GetMark(i
)->GetMarkedSdrObj() ))
369 if ( nMarkCnt
> 0 && !b3DObjMarked
&&
370 (!mpDrawView
->IsShearAllowed() || !mpDrawView
->IsDistortAllowed()) )
372 if ( mpDrawView
->IsPresObjSelected() )
374 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
375 VclMessageType::Info
, VclButtonsType::Ok
,
376 SdResId(STR_ACTION_NOTPOSSIBLE
)));
381 std::unique_ptr
<weld::MessageDialog
> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
382 VclMessageType::Question
, VclButtonsType::YesNo
,
383 SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER
)));
384 if (xQueryBox
->run() == RET_YES
)
386 // implicit transformation into bezier
387 weld::WaitObject
aWait(GetFrameWeld());
388 mpDrawView
->ConvertMarkedToPathObj(false);
394 SetCurrentFunction( FuSelection::Create(this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
) );
396 Invalidate( SID_OBJECT_SELECT
);
402 case SID_DRAW_MEASURELINE
:
403 case SID_LINE_ARROW_START
:
404 case SID_LINE_ARROW_END
:
405 case SID_LINE_ARROWS
:
406 case SID_LINE_ARROW_CIRCLE
:
407 case SID_LINE_CIRCLE_ARROW
:
408 case SID_LINE_ARROW_SQUARE
:
409 case SID_LINE_SQUARE_ARROW
:
412 case SID_DRAW_RECT_NOFILL
:
413 case SID_DRAW_RECT_ROUND
:
414 case SID_DRAW_RECT_ROUND_NOFILL
:
415 case SID_DRAW_SQUARE
:
416 case SID_DRAW_SQUARE_NOFILL
:
417 case SID_DRAW_SQUARE_ROUND
:
418 case SID_DRAW_SQUARE_ROUND_NOFILL
:
419 case SID_DRAW_ELLIPSE
:
420 case SID_DRAW_ELLIPSE_NOFILL
:
421 case SID_DRAW_CIRCLE
:
422 case SID_DRAW_CIRCLE_NOFILL
:
423 case SID_DRAW_CAPTION
:
424 case SID_DRAW_CAPTION_VERTICAL
:
425 case SID_TOOL_CONNECTOR
:
426 case SID_CONNECTOR_ARROW_START
:
427 case SID_CONNECTOR_ARROW_END
:
428 case SID_CONNECTOR_ARROWS
:
429 case SID_CONNECTOR_CIRCLE_START
:
430 case SID_CONNECTOR_CIRCLE_END
:
431 case SID_CONNECTOR_CIRCLES
:
432 case SID_CONNECTOR_LINE
:
433 case SID_CONNECTOR_LINE_ARROW_START
:
434 case SID_CONNECTOR_LINE_ARROW_END
:
435 case SID_CONNECTOR_LINE_ARROWS
:
436 case SID_CONNECTOR_LINE_CIRCLE_START
:
437 case SID_CONNECTOR_LINE_CIRCLE_END
:
438 case SID_CONNECTOR_LINE_CIRCLES
:
439 case SID_CONNECTOR_CURVE
:
440 case SID_CONNECTOR_CURVE_ARROW_START
:
441 case SID_CONNECTOR_CURVE_ARROW_END
:
442 case SID_CONNECTOR_CURVE_ARROWS
:
443 case SID_CONNECTOR_CURVE_CIRCLE_START
:
444 case SID_CONNECTOR_CURVE_CIRCLE_END
:
445 case SID_CONNECTOR_CURVE_CIRCLES
:
446 case SID_CONNECTOR_LINES
:
447 case SID_CONNECTOR_LINES_ARROW_START
:
448 case SID_CONNECTOR_LINES_ARROW_END
:
449 case SID_CONNECTOR_LINES_ARROWS
:
450 case SID_CONNECTOR_LINES_CIRCLE_START
:
451 case SID_CONNECTOR_LINES_CIRCLE_END
:
452 case SID_CONNECTOR_LINES_CIRCLES
:
453 case SID_INSERT_SIGNATURELINE
:
455 bCreateDirectly
= comphelper::LibreOfficeKit::isActive();
456 SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
460 case SID_DRAW_POLYGON
:
461 case SID_DRAW_POLYGON_NOFILL
:
462 case SID_DRAW_XPOLYGON
:
463 case SID_DRAW_XPOLYGON_NOFILL
:
464 case SID_DRAW_FREELINE
:
465 case SID_DRAW_FREELINE_NOFILL
:
466 case SID_DRAW_BEZIER_FILL
: // BASIC
467 case SID_DRAW_BEZIER_NOFILL
: // BASIC
469 SetCurrentFunction( FuConstructBezierPolygon::Create(this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
474 case SID_GLUE_EDITMODE
:
476 if (nOldSId
!= SID_GLUE_EDITMODE
)
478 SetCurrentFunction( FuEditGluePoints::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
482 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
490 case SID_DRAW_CIRCLEARC
:
492 case SID_DRAW_PIE_NOFILL
:
493 case SID_DRAW_CIRCLEPIE
:
494 case SID_DRAW_CIRCLEPIE_NOFILL
:
495 case SID_DRAW_ELLIPSECUT
:
496 case SID_DRAW_ELLIPSECUT_NOFILL
:
497 case SID_DRAW_CIRCLECUT
:
498 case SID_DRAW_CIRCLECUT_NOFILL
:
500 SetCurrentFunction( FuConstructArc::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
509 case SID_3D_HALF_SPHERE
:
510 case SID_3D_CYLINDER
:
514 SetCurrentFunction( FuConstruct3dObject::Create(this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
519 case SID_DRAWTBX_CS_BASIC
:
520 case SID_DRAWTBX_CS_SYMBOL
:
521 case SID_DRAWTBX_CS_ARROW
:
522 case SID_DRAWTBX_CS_FLOWCHART
:
523 case SID_DRAWTBX_CS_CALLOUT
:
524 case SID_DRAWTBX_CS_STAR
:
525 case SID_DRAW_CS_ID
:
527 SetCurrentFunction( FuConstructCustomShape::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
, bPermanent
) );
530 bCreateDirectly
= comphelper::LibreOfficeKit::isActive();
531 const SfxItemSet
* pArgs
= rReq
.GetArgs();
532 if (pArgs
&& pArgs
->HasItem(FN_PARAM_1
))
534 bCreateDirectly
= static_cast<const SfxBoolItem
&>(pArgs
->Get(FN_PARAM_1
)).GetValue();
537 if ( nSId
!= SID_DRAW_CS_ID
)
539 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
540 rBind
.Invalidate( nSId
);
541 rBind
.Update( nSId
);
546 case SID_FORMATPAINTBRUSH
:
548 SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
) );
550 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
551 rBind
.Invalidate( nSId
);
552 rBind
.Update( nSId
);
557 case SID_ZOOM_PANNING
:
561 mbZoomOnPage
= false;
562 SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView
.get(), GetDoc(), rReq
) );
566 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
578 sal_uInt16 nSlotId
= GetOldFunction()->GetSlotID();
580 GetOldFunction()->Deactivate();
581 SetOldFunction(nullptr);
583 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
584 rBind
.Invalidate( nSlotId
);
585 rBind
.Update( nSlotId
);
588 if(HasCurrentFunction())
590 GetCurrentFunction()->Activate();
591 SetOldFunction( GetCurrentFunction() );
594 // invalidate shell, is faster than every individually (says MI)
595 // now explicit the last slot incl. Update()
598 // CTRL-SID_OBJECT_SELECT -> select first draw object if none is selected yet
599 if(SID_OBJECT_SELECT
== nSId
&& HasCurrentFunction() && (rReq
.GetModifier() & KEY_MOD1
))
601 if(!GetView()->AreObjectsMarked())
603 // select first object
604 GetView()->UnmarkAllObj();
605 GetView()->MarkNextObj(true);
607 // ...and make it visible
608 if(GetView()->AreObjectsMarked())
609 GetView()->MakeVisible(GetView()->GetAllMarkedRect(), *GetActiveWindow());
613 // with qualifier construct directly
614 if(!(HasCurrentFunction() && ((rReq
.GetModifier() & KEY_MOD1
) || bCreateDirectly
)))
617 // disable interactive drawing for LOK
619 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
622 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
623 sal_uInt32
nDefaultObjectSizeWidth(pOptions
->GetDefaultObjectSizeWidth());
624 sal_uInt32
nDefaultObjectSizeHeight(pOptions
->GetDefaultObjectSizeHeight());
626 // calc position and size
627 ::tools::Rectangle aVisArea
= GetActiveWindow()->PixelToLogic(::tools::Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
628 if (comphelper::LibreOfficeKit::isActive())
630 // aVisArea is nonsensical in the LOK case, use the slide size
631 aVisArea
= ::tools::Rectangle(Point(), getCurrentPage()->GetSize());
634 Point aPagePos
= aVisArea
.Center();
635 aPagePos
.AdjustX( -sal_Int32(nDefaultObjectSizeWidth
/ 2) );
636 aPagePos
.AdjustY( -sal_Int32(nDefaultObjectSizeHeight
/ 2) );
637 ::tools::Rectangle
aNewObjectRectangle(aPagePos
, Size(nDefaultObjectSizeWidth
, nDefaultObjectSizeHeight
));
638 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
643 // create the default object
644 rtl::Reference
<SdrObject
> pObj
= GetCurrentFunction()->CreateDefaultObject(nSId
, aNewObjectRectangle
);
649 auto pObjTmp
= pObj
.get();
651 GetView()->InsertObjectAtView(pObj
.get(), *pPageView
);
653 // Now that pFuActual has done what it was created for we
654 // can switch on the edit mode for callout objects.
657 case SID_DRAW_CAPTION
:
658 case SID_DRAW_CAPTION_VERTICAL
:
660 // Make FuText the current function.
661 SfxUInt16Item
aItem (SID_TEXTEDIT
, 1);
662 GetViewFrame()->GetDispatcher()->
663 ExecuteList(SID_TEXTEDIT
, SfxCallMode::SYNCHRON
|
664 SfxCallMode::RECORD
, { &aItem
});
665 // Put text object into edit mode.
666 GetView()->SdrBeginTextEdit(static_cast<SdrTextObj
*>(pObjTmp
), pPageView
);
672 void DrawViewShell::FuDeleteSelectedObjects()
677 bool bConsumed
= false;
679 //if any placeholders are selected
680 if (mpDrawView
->IsPresObjSelected(false))
682 //If there are placeholders in the list which can be toggled
683 //off in edit->master->master elements then do that here,
684 std::vector
<SdrObject
*> aPresMarksToRemove
;
685 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
686 for (size_t i
=0; i
< rMarkList
.GetMarkCount(); ++i
)
688 SdrObject
* pObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
689 SdPage
* pPage
= static_cast<SdPage
*>(pObj
->getSdrPageFromSdrObject());
690 PresObjKind eKind
= pPage
->GetPresObjKind(pObj
);
691 if (eKind
== PresObjKind::Footer
|| eKind
== PresObjKind::Header
||
692 eKind
== PresObjKind::DateTime
|| eKind
== PresObjKind::SlideNumber
)
694 aPresMarksToRemove
.push_back(pObj
);
698 for (SdrObject
* pObj
: aPresMarksToRemove
)
701 mpDrawView
->MarkObj(pObj
, mpDrawView
->GetSdrPageView(), true);
702 SdPage
* pPage
= static_cast<SdPage
*>(pObj
->getSdrPageFromSdrObject());
703 //remove placeholder from master page
704 pPage
->DestroyDefaultPresObj(pPage
->GetPresObjKind(pObj
));
710 // placeholders which cannot be deleted selected
711 if (mpDrawView
->IsPresObjSelected(false, true, false, true))
713 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
714 VclMessageType::Info
, VclButtonsType::Ok
,
715 SdResId(STR_ACTION_NOTPOSSIBLE
)));
723 vcl::KeyCode
aKCode(KEY_DELETE
);
724 KeyEvent
aKEvt( 0, aKCode
);
726 bConsumed
= mpDrawView
->getSmartTags().KeyInput( aKEvt
);
728 if (!bConsumed
&& HasCurrentFunction())
729 bConsumed
= GetCurrentFunction()->KeyInput(aKEvt
);
732 mpDrawView
->DeleteMarked();
735 void DrawViewShell::FuSupport(SfxRequest
& rReq
)
737 if( rReq
.GetSlot() == SID_STYLE_FAMILY
&& rReq
.GetArgs())
738 GetDocSh()->SetStyleFamily(static_cast<SfxStyleFamily
>(rReq
.GetArgs()->Get( SID_STYLE_FAMILY
).GetValue()));
740 // We do not execute a thing during a native slide show
741 if(SlideShow::IsRunning(GetViewShellBase()) &&
742 (rReq
.GetSlot() != SID_PRESENTATION_END
&&
743 rReq
.GetSlot() != SID_SIZE_PAGE
))
751 sal_uInt16 nSId
= rReq
.GetSlot();
755 case SID_CLEAR_UNDO_STACK
:
757 GetDocSh()->ClearUndoBuffer();
762 case SID_PRESENTATION
:
763 case SID_PRESENTATION_CURRENT_SLIDE
:
764 case SID_REHEARSE_TIMINGS
:
766 slideshowhelp::ShowSlideShow(rReq
, *GetDoc());
771 case SID_PRESENTATION_END
:
779 case SID_BEZIER_EDIT
:
781 mpDrawView
->SetFrameDragSingles(!mpDrawView
->IsFrameDragSingles());
783 /******************************************************************
785 ******************************************************************/
786 if( dynamic_cast< FuSelection
* >( GetCurrentFunction().get() ) || dynamic_cast< FuConstructBezierPolygon
* >( GetCurrentFunction().get() ) )
788 // Tell the tool bar manager about the context change.
789 GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView
);
792 Invalidate(SID_BEZIER_EDIT
);
797 case SID_OBJECT_CLOSE
:
799 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
800 if ( rMarkList
.GetMark(0) && !mpDrawView
->IsAction() )
802 SdrPathObj
* pPathObj
= static_cast<SdrPathObj
*>( rMarkList
.GetMark(0)->GetMarkedSdrObj());
803 const bool bUndo
= mpDrawView
->IsUndoEnabled();
805 mpDrawView
->BegUndo(SdResId(STR_UNDO_BEZCLOSE
));
807 mpDrawView
->UnmarkAllPoints();
810 mpDrawView
->AddUndo(std::make_unique
<SdrUndoGeoObj
>(*pPathObj
));
812 pPathObj
->ToggleClosed();
815 mpDrawView
->EndUndo();
823 if ( mpDrawView
->IsPresObjSelected(false, true, false, true) )
825 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
826 VclMessageType::Info
, VclButtonsType::Ok
,
827 SdResId(STR_ACTION_NOTPOSSIBLE
)));
832 //tdf#126197: EndTextEdit in all views if current one is not in TextEdit
833 if ( !mpDrawView
->IsTextEdit() )
834 mpDrawView
->EndTextEditAllViews();
836 if(HasCurrentFunction())
838 GetCurrentFunction()->DoCut();
851 if ( mpDrawView
->IsPresObjSelected(false, true, false, true) )
853 std::unique_ptr
<weld::MessageDialog
> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
854 VclMessageType::Info
, VclButtonsType::Ok
,
855 SdResId(STR_ACTION_NOTPOSSIBLE
)));
860 if(HasCurrentFunction())
862 GetCurrentFunction()->DoCopy();
864 else if( mpDrawView
)
866 mpDrawView
->DoCopy();
875 weld::WaitObject
aWait(GetFrameWeld());
877 if(HasCurrentFunction())
879 GetCurrentFunction()->DoPaste();
883 mpDrawView
->DoPaste();
890 case SID_UNICODE_NOTATION_TOGGLE
:
892 if( mpDrawView
->IsTextEdit() )
894 OutlinerView
* pOLV
= mpDrawView
->GetTextEditOutlinerView();
897 OUString sInput
= pOLV
->GetSurroundingText();
898 ESelection
aSel( pOLV
->GetSelection() );
899 if( aSel
.nStartPos
> aSel
.nEndPos
)
900 aSel
.nEndPos
= aSel
.nStartPos
;
902 //calculate a valid end-position by reading logical characters
903 sal_Int32 nUtf16Pos
=0;
904 while( (nUtf16Pos
< sInput
.getLength()) && (nUtf16Pos
< aSel
.nEndPos
) )
906 sInput
.iterateCodePoints(&nUtf16Pos
);
907 //The mouse can set the cursor in the middle of a multi-unit character,
908 // so reset to the proper end of the logical characters
909 if( nUtf16Pos
> aSel
.nEndPos
)
910 aSel
.nEndPos
= nUtf16Pos
;
913 ToggleUnicodeCodepoint aToggle
;
914 while( nUtf16Pos
&& aToggle
.AllowMoreInput( sInput
[nUtf16Pos
-1]) )
916 OUString sReplacement
= aToggle
.ReplacementString();
917 if( !sReplacement
.isEmpty() )
919 OUString sStringToReplace
= aToggle
.StringToReplace();
920 mpDrawView
->BegUndo(sStringToReplace
+"->"+ sReplacement
);
921 aSel
.nStartPos
= aSel
.nEndPos
- sStringToReplace
.getLength();
922 pOLV
->SetSelection( aSel
);
923 pOLV
->InsertText(sReplacement
, true);
924 mpDrawView
->EndUndo();
931 case SID_PASTE_UNFORMATTED
:
933 weld::WaitObject
aWait(GetFrameWeld());
935 if(HasCurrentFunction())
937 GetCurrentFunction()->DoPasteUnformatted();
941 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
942 if (aDataHelper
.GetTransferable().is())
944 sal_Int8 nAction
= DND_ACTION_COPY
;
945 mpDrawView
->InsertData( aDataHelper
,
946 GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
947 nAction
, false, SotClipboardFormatId::STRING
);
955 case SID_CLIPBOARD_FORMAT_ITEMS
:
957 weld::WaitObject
aWait(GetFrameWeld());
958 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
959 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
960 SotClipboardFormatId nFormat
= SotClipboardFormatId::NONE
;
964 const SfxUInt32Item
* pIsActive
= rReq
.GetArg
<SfxUInt32Item
>(SID_CLIPBOARD_FORMAT_ITEMS
);
965 nFormat
= static_cast<SotClipboardFormatId
>(pIsActive
->GetValue());
968 if( nFormat
!= SotClipboardFormatId::NONE
&& aDataHelper
.GetTransferable().is() )
970 sal_Int8 nAction
= DND_ACTION_COPY
;
972 if( !mpDrawView
->InsertData( aDataHelper
,
973 GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
974 nAction
, false, nFormat
) )
976 INetBookmark
aINetBookmark( "", "" );
978 if( ( aDataHelper
.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK
) &&
979 aDataHelper
.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK
, aINetBookmark
) ) ||
980 ( aDataHelper
.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR
) &&
981 aDataHelper
.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR
, aINetBookmark
) ) ||
982 ( aDataHelper
.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR
) &&
983 aDataHelper
.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR
, aINetBookmark
) ) )
985 InsertURLField( aINetBookmark
.GetURL(), aINetBookmark
.GetDescription(), "" );
994 if ( mpDrawView
->IsTextEdit() )
996 OutlinerView
* pOLV
= mpDrawView
->GetTextEditOutlinerView();
1000 vcl::KeyCode
aKCode(KEY_DELETE
);
1001 KeyEvent
aKEvt( 0, aKCode
);
1002 // We use SdrObjEditView to handle DEL for underflow handling
1003 (void)mpDrawView
->KeyInput(aKEvt
, nullptr);
1008 mpDrawView
->EndTextEditAllViews();
1009 FuDeleteSelectedObjects();
1015 case SID_NOTES_MODE
:
1016 case SID_SLIDE_MASTER_MODE
:
1017 case SID_NOTES_MASTER_MODE
:
1018 case SID_HANDOUT_MASTER_MODE
:
1020 // AutoLayouts have to be ready.
1021 GetDoc()->StopWorkStartupDelay();
1024 case SID_DRAWINGMODE
:
1025 case SID_SLIDE_SORTER_MODE
:
1026 case SID_OUTLINE_MODE
:
1027 // Let the sub-shell manager handle the slot handling.
1028 framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
1034 case SID_MASTERPAGE
: // BASIC
1036 if (comphelper::LibreOfficeKit::isActive())
1037 GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED
,
1038 ".uno:SlideMasterPage=true");
1040 // AutoLayouts needs to be finished
1041 GetDoc()->StopWorkStartupDelay();
1043 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1047 const SfxBoolItem
* pIsActive
= rReq
.GetArg
<SfxBoolItem
>(SID_MASTERPAGE
);
1048 mbIsLayerModeActive
= pIsActive
->GetValue ();
1052 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START
));
1054 // turn on default layer of MasterPage
1055 mpDrawView
->SetActiveLayer(sUNO_LayerName_background_objects
);
1057 ChangeEditMode(EditMode::MasterPage
, mbIsLayerModeActive
);
1059 if(HasCurrentFunction(SID_BEZIER_EDIT
))
1060 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
1063 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END
));
1065 InvalidateWindows();
1072 case SID_CLOSE_MASTER_VIEW
:
1074 // Notify of disabling master view, which is enabled in DrawViewShell::ChangeEditMode.
1075 if (comphelper::LibreOfficeKit::isActive())
1076 GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED
,
1077 ".uno:SlideMasterPage=false");
1080 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START
));
1082 // Switch page back to the first one. Not doing so leads to a
1083 // crash. This seems to be some bug in the edit mode switching
1084 // and page switching methods.
1086 ChangeEditMode(EditMode::Page
, IsLayerModeActive());
1088 ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END
));
1090 if(HasCurrentFunction(SID_BEZIER_EDIT
))
1092 GetViewFrame()->GetDispatcher()->Execute(
1094 SfxCallMode::ASYNCHRON
);
1103 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
1105 // Remember old ruler state
1106 bool bOldHasRuler(HasRuler());
1110 const SfxBoolItem
* pIsActive
= rReq
.GetArg
<SfxBoolItem
>(SID_RULER
);
1111 SetRuler (pIsActive
->GetValue ());
1113 else SetRuler (!HasRuler());
1115 // Did ruler state change? Tell that to SdOptions, too.
1116 bool bHasRuler(HasRuler());
1118 if(bOldHasRuler
!= bHasRuler
)
1120 SdOptions
* pOptions
= SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
1122 if(pOptions
&& pOptions
->IsRulerVisible() != bHasRuler
)
1124 pOptions
->SetRulerVisible(bHasRuler
);
1128 Invalidate (SID_RULER
);
1135 case SID_SIZE_PAGE_WIDTH
: // BASIC
1137 mbZoomOnPage
= ( rReq
.GetSlot() == SID_SIZE_PAGE
);
1139 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
1143 Point
aPagePos(0, 0); // = pPageView->GetOffset();
1144 Size aPageSize
= pPageView
->GetPage()->GetSize();
1146 aPagePos
.AdjustX(aPageSize
.Width() / 2 );
1147 aPageSize
.setWidth( static_cast<::tools::Long
>(aPageSize
.Width() * 1.03) );
1149 if( rReq
.GetSlot() == SID_SIZE_PAGE
)
1151 aPagePos
.AdjustY(aPageSize
.Height() / 2 );
1152 aPageSize
.setHeight( static_cast<::tools::Long
>(aPageSize
.Height() * 1.03) );
1153 aPagePos
.AdjustY( -(aPageSize
.Height() / 2) );
1157 Point aPt
= GetActiveWindow()->PixelToLogic( Point( 0, GetActiveWindow()->GetSizePixel().Height() / 2 ) );
1158 aPagePos
.AdjustY(aPt
.Y() );
1159 aPageSize
.setHeight( 2 );
1162 aPagePos
.AdjustX( -(aPageSize
.Width() / 2) );
1164 SetZoomRect( ::tools::Rectangle( aPagePos
, aPageSize
) );
1166 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1167 GetActiveWindow()->GetOutputSizePixel()) );
1168 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1170 Invalidate( SID_ZOOM_IN
);
1171 Invalidate( SID_ZOOM_OUT
);
1172 Invalidate( SID_ZOOM_PANNING
);
1177 case SID_SIZE_REAL
: // BASIC
1179 mbZoomOnPage
= false;
1181 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1182 GetActiveWindow()->GetOutputSizePixel()) );
1183 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1184 Invalidate( SID_ZOOM_IN
);
1185 Invalidate( SID_ZOOM_OUT
);
1186 Invalidate( SID_ZOOM_PANNING
);
1191 case SID_ZOOM_OUT
: // BASIC
1193 const sal_uInt16 nOldZoom
= GetActiveWindow()->GetZoom();
1194 const sal_uInt16 nNewZoom
= basegfx::zoomtools::zoomOut(nOldZoom
);
1197 mbZoomOnPage
= false;
1198 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1199 GetActiveWindow()->GetOutputSizePixel()) );
1200 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1201 Invalidate( SID_ZOOM_IN
);
1202 Invalidate( SID_ZOOM_OUT
);
1203 Invalidate( SID_ZOOM_PANNING
);
1210 const sal_uInt16 nOldZoom
= GetActiveWindow()->GetZoom();
1211 const sal_uInt16 nNewZoom
= basegfx::zoomtools::zoomIn(nOldZoom
);
1214 mbZoomOnPage
= false;
1215 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1216 GetActiveWindow()->GetOutputSizePixel()) );
1217 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1218 Invalidate( SID_ZOOM_IN
);
1219 Invalidate(SID_ZOOM_OUT
);
1220 Invalidate( SID_ZOOM_PANNING
);
1225 case SID_SIZE_VISAREA
:
1227 ::tools::Rectangle aVisArea
= mpFrameView
->GetVisArea();
1228 Size aVisAreaSize
= aVisArea
.GetSize();
1230 if (!aVisAreaSize
.IsEmpty())
1232 mbZoomOnPage
= false;
1233 SetZoomRect(aVisArea
);
1234 Invalidate( SID_ZOOM_IN
);
1235 Invalidate( SID_ZOOM_OUT
);
1236 Invalidate( SID_ZOOM_PANNING
);
1242 // name confusion: SID_SIZE_OPTIMAL -> Zoom onto selected objects
1243 // --> Is offered as object zoom in program
1244 case SID_SIZE_OPTIMAL
: // BASIC
1246 mbZoomOnPage
= false;
1247 if ( mpDrawView
->AreObjectsMarked() )
1249 maMarkRect
= mpDrawView
->GetAllMarkedRect();
1250 ::tools::Long nW
= static_cast<::tools::Long
>(maMarkRect
.GetWidth() * 1.03);
1251 ::tools::Long nH
= static_cast<::tools::Long
>(maMarkRect
.GetHeight() * 1.03);
1252 Point aPos
= maMarkRect
.Center();
1253 aPos
.AdjustX( -(nW
/ 2) );
1254 aPos
.AdjustY( -(nH
/ 2) );
1257 SetZoomRect(::tools::Rectangle(aPos
, Size(nW
, nH
)));
1259 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1260 GetActiveWindow()->GetOutputSizePixel()) );
1261 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1264 Invalidate( SID_ZOOM_IN
);
1265 Invalidate( SID_ZOOM_OUT
);
1266 Invalidate( SID_ZOOM_PANNING
);
1271 // name confusion: SID_SIZE_ALL -> Zoom onto all objects
1272 // --> Is offered as optimal in program
1273 case SID_SIZE_ALL
: // BASIC
1275 mbZoomOnPage
= false;
1276 SdrPageView
* pPageView
= mpDrawView
->GetSdrPageView();
1280 ::tools::Rectangle
aBoundRect( pPageView
->GetObjList()->GetAllObjBoundRect() );
1282 ::tools::Long nW
= static_cast<::tools::Long
>(aBoundRect
.GetWidth() * 1.03);
1283 ::tools::Long nH
= static_cast<::tools::Long
>(aBoundRect
.GetHeight() * 1.03);
1284 Point aPos
= aBoundRect
.Center();
1285 aPos
.AdjustX( -(nW
/ 2) );
1286 aPos
.AdjustY( -(nH
/ 2) );
1289 SetZoomRect( ::tools::Rectangle( aPos
, Size( nW
, nH
) ) );
1291 ::tools::Rectangle aVisAreaWin
= GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0),
1292 GetActiveWindow()->GetOutputSizePixel()) );
1293 mpZoomList
->InsertZoomRect(aVisAreaWin
);
1296 Invalidate( SID_ZOOM_IN
);
1297 Invalidate( SID_ZOOM_OUT
);
1298 Invalidate( SID_ZOOM_PANNING
);
1306 if (mpDrawView
->IsTextEdit())
1308 mpDrawView
->SdrEndTextEdit();
1311 if (mpZoomList
->IsPreviousPossible())
1313 // set previous ZoomRect
1314 SetZoomRect(mpZoomList
->GetPreviousZoomRect());
1322 if (mpDrawView
->IsTextEdit())
1324 mpDrawView
->SdrEndTextEdit();
1327 if (mpZoomList
->IsNextPossible())
1329 // set next ZoomRect
1330 SetZoomRect(mpZoomList
->GetNextZoomRect());
1336 case SID_GLUE_INSERT_POINT
:
1337 case SID_GLUE_PERCENT
:
1338 case SID_GLUE_ESCDIR
:
1339 case SID_GLUE_ESCDIR_LEFT
:
1340 case SID_GLUE_ESCDIR_RIGHT
:
1341 case SID_GLUE_ESCDIR_TOP
:
1342 case SID_GLUE_ESCDIR_BOTTOM
:
1343 case SID_GLUE_HORZALIGN_CENTER
:
1344 case SID_GLUE_HORZALIGN_LEFT
:
1345 case SID_GLUE_HORZALIGN_RIGHT
:
1346 case SID_GLUE_VERTALIGN_CENTER
:
1347 case SID_GLUE_VERTALIGN_TOP
:
1348 case SID_GLUE_VERTALIGN_BOTTOM
:
1350 rtl::Reference
<FuPoor
> xFunc( GetCurrentFunction() );
1351 FuEditGluePoints
* pFunc
= dynamic_cast< FuEditGluePoints
* >( xFunc
.get() );
1354 pFunc
->ReceiveRequest(rReq
);
1360 case SID_AUTOSPELL_CHECK
:
1363 const SfxPoolItem
* pItem
;
1365 if (rReq
.GetArgs()->HasItem(FN_PARAM_1
, &pItem
))
1366 bOnlineSpell
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1368 bOnlineSpell
= !GetDoc()->GetOnlineSpell();
1370 GetDoc()->SetOnlineSpell(bOnlineSpell
);
1372 ::Outliner
* pOL
= mpDrawView
->GetTextEditOutliner();
1376 EEControlBits nCntrl
= pOL
->GetControlWord();
1379 nCntrl
|= EEControlBits::ONLINESPELLING
;
1381 nCntrl
&= ~EEControlBits::ONLINESPELLING
;
1383 pOL
->SetControlWord(nCntrl
);
1386 GetActiveWindow()->Invalidate();
1391 case SID_TRANSLITERATE_SENTENCE_CASE
:
1392 case SID_TRANSLITERATE_TITLE_CASE
:
1393 case SID_TRANSLITERATE_TOGGLE_CASE
:
1394 case SID_TRANSLITERATE_UPPER
:
1395 case SID_TRANSLITERATE_LOWER
:
1396 case SID_TRANSLITERATE_HALFWIDTH
:
1397 case SID_TRANSLITERATE_FULLWIDTH
:
1398 case SID_TRANSLITERATE_HIRAGANA
:
1399 case SID_TRANSLITERATE_KATAKANA
:
1401 OutlinerView
* pOLV
= GetView()->GetTextEditOutlinerView();
1404 TransliterationFlags nType
= TransliterationFlags::NONE
;
1408 case SID_TRANSLITERATE_SENTENCE_CASE
:
1409 nType
= TransliterationFlags::SENTENCE_CASE
;
1411 case SID_TRANSLITERATE_TITLE_CASE
:
1412 nType
= TransliterationFlags::TITLE_CASE
;
1414 case SID_TRANSLITERATE_TOGGLE_CASE
:
1415 nType
= TransliterationFlags::TOGGLE_CASE
;
1417 case SID_TRANSLITERATE_UPPER
:
1418 nType
= TransliterationFlags::LOWERCASE_UPPERCASE
;
1420 case SID_TRANSLITERATE_LOWER
:
1421 nType
= TransliterationFlags::UPPERCASE_LOWERCASE
;
1423 case SID_TRANSLITERATE_HALFWIDTH
:
1424 nType
= TransliterationFlags::FULLWIDTH_HALFWIDTH
;
1426 case SID_TRANSLITERATE_FULLWIDTH
:
1427 nType
= TransliterationFlags::HALFWIDTH_FULLWIDTH
;
1429 case SID_TRANSLITERATE_HIRAGANA
:
1430 nType
= TransliterationFlags::KATAKANA_HIRAGANA
;
1432 case SID_TRANSLITERATE_KATAKANA
:
1433 nType
= TransliterationFlags::HIRAGANA_KATAKANA
;
1437 pOLV
->TransliterateText( nType
);
1447 // moved implementation to BaseClass
1453 // moved implementation to BaseClass
1463 void DrawViewShell::FuSupportRotate(SfxRequest
const &rReq
)
1465 if( rReq
.GetSlot() != SID_TRANSLITERATE_ROTATE_CASE
)
1468 ::sd::View
* pView
= GetView();
1473 OutlinerView
* pOLV
= pView
->GetTextEditOutlinerView();
1478 pOLV
->TransliterateText( m_aRotateCase
.getNextMode() );
1481 void DrawViewShell::InsertURLField(const OUString
& rURL
, const OUString
& rText
,
1482 const OUString
& rTarget
)
1484 OutlinerView
* pOLV
= mpDrawView
->GetTextEditOutlinerView();
1488 ESelection
aSel( pOLV
->GetSelection() );
1489 SvxFieldItem
aURLItem( SvxURLField( rURL
, rText
, SvxURLFormat::Repr
), EE_FEATURE_FIELD
);
1490 pOLV
->InsertField( aURLItem
);
1491 if ( aSel
.nStartPos
<= aSel
.nEndPos
)
1492 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
1494 aSel
.nStartPos
= aSel
.nEndPos
+ 1;
1495 pOLV
->SetSelection( aSel
);
1499 Outliner
* pOutl
= GetDoc()->GetInternalOutliner();
1500 pOutl
->Init( OutlinerMode::TextObject
);
1501 OutlinerMode nOutlMode
= pOutl
->GetOutlinerMode();
1503 SvxURLField
aURLField(rURL
, rText
, SvxURLFormat::Repr
);
1504 aURLField
.SetTargetFrame(rTarget
);
1505 SvxFieldItem
aURLItem(aURLField
, EE_FEATURE_FIELD
);
1506 pOutl
->QuickInsertField( aURLItem
, ESelection() );
1507 std::optional
<OutlinerParaObject
> pOutlParaObject
= pOutl
->CreateParaObject();
1509 rtl::Reference
<SdrRectObj
> pRectObj
= new SdrRectObj(
1510 GetView()->getSdrModelFromSdrView(),
1513 pOutl
->UpdateFields();
1514 pOutl
->SetUpdateLayout( true );
1515 Size
aSize(pOutl
->CalcTextSize());
1516 pOutl
->SetUpdateLayout( false );
1519 ::tools::Rectangle
aRect(aPos
, GetActiveWindow()->GetOutputSizePixel() );
1520 aPos
= aRect
.Center();
1521 aPos
= GetActiveWindow()->PixelToLogic(aPos
);
1523 if (aPos
.getX() - (aSize
.Width() / 2) >= 0)
1524 aPos
.AdjustX( -(aSize
.Width() / 2) );
1525 if (aPos
.getY() - (aSize
.Height() / 2) >= 0)
1526 aPos
.AdjustY( -(aSize
.Height() / 2) );
1528 ::tools::Rectangle
aLogicRect(aPos
, aSize
);
1529 pRectObj
->SetLogicRect(aLogicRect
);
1530 pRectObj
->SetOutlinerParaObject( std::move(pOutlParaObject
) );
1531 mpDrawView
->InsertObjectAtView(pRectObj
.get(), *mpDrawView
->GetSdrPageView());
1532 pOutl
->Init( nOutlMode
);
1536 void DrawViewShell::InsertURLButton(const OUString
& rURL
, const OUString
& rText
,
1537 const OUString
& rTarget
, const Point
* pPos
)
1539 bool bNewObj
= true;
1541 const OUString
sTargetURL( ::URIHelper::SmartRel2Abs( INetURLObject( GetDocSh()->GetMedium()->GetBaseURL() ), rURL
, URIHelper::GetMaybeFileHdl(), true, false,
1542 INetURLObject::EncodeMechanism::WasEncoded
,
1543 INetURLObject::DecodeMechanism::Unambiguous
) );
1544 if (mpDrawView
->GetMarkedObjectList().GetMarkCount() > 0)
1546 SdrObject
* pMarkedObj
= mpDrawView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
1547 if( pMarkedObj
) try
1549 // change first marked object
1550 if( SdrInventor::FmForm
== pMarkedObj
->GetObjInventor() && pMarkedObj
->GetObjIdentifier() == SdrObjKind::FormButton
)
1554 SdrUnoObj
* pUnoCtrl
= static_cast< SdrUnoObj
* >( pMarkedObj
);
1556 Reference
< awt::XControlModel
> xControlModel( pUnoCtrl
->GetUnoControlModel(), UNO_SET_THROW
);
1557 Reference
< beans::XPropertySet
> xPropSet( xControlModel
, UNO_QUERY_THROW
);
1559 xPropSet
->setPropertyValue("Label" , Any( rText
) );
1560 xPropSet
->setPropertyValue("TargetURL" , Any( sTargetURL
) );
1562 if( !rTarget
.isEmpty() )
1563 xPropSet
->setPropertyValue("TargetFrame" , Any( rTarget
) );
1565 xPropSet
->setPropertyValue( "ButtonType" , Any( form::FormButtonType_URL
) );
1566 #if HAVE_FEATURE_AVMEDIA
1567 if ( ::avmedia::MediaWindow::isMediaURL( rURL
, ""/*TODO?*/ ) )
1569 xPropSet
->setPropertyValue( "DispatchURLInternal" , Any( true ) );
1575 // add url as interaction for first selected shape
1578 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(*pMarkedObj
, true);
1579 pInfo
->meClickAction
= presentation::ClickAction_DOCUMENT
;
1580 pInfo
->SetBookmark( sTargetURL
);
1583 catch( uno::Exception
& )
1593 rtl::Reference
<SdrUnoObj
> pUnoCtrl
= static_cast< SdrUnoObj
* >(
1594 SdrObjFactory::MakeNewObject(
1595 GetView()->getSdrModelFromSdrView(),
1596 SdrInventor::FmForm
,
1597 SdrObjKind::FormButton
).get()); //,
1598 //mpDrawView->GetSdrPageView()->GetPage()));
1600 Reference
< awt::XControlModel
> xControlModel( pUnoCtrl
->GetUnoControlModel(), uno::UNO_SET_THROW
);
1601 Reference
< beans::XPropertySet
> xPropSet( xControlModel
, uno::UNO_QUERY_THROW
);
1603 xPropSet
->setPropertyValue( "Label" , Any( rText
) );
1604 xPropSet
->setPropertyValue( "TargetURL" , Any( sTargetURL
) );
1606 if( !rTarget
.isEmpty() )
1607 xPropSet
->setPropertyValue( "TargetFrame" , Any( rTarget
) );
1609 xPropSet
->setPropertyValue( "ButtonType" , Any( form::FormButtonType_URL
) );
1610 #if HAVE_FEATURE_AVMEDIA
1611 if ( ::avmedia::MediaWindow::isMediaURL( rURL
, ""/*TODO?*/ ) )
1612 xPropSet
->setPropertyValue( "DispatchURLInternal" , Any( true ) );
1623 aPos
= ::tools::Rectangle(aPos
, GetActiveWindow()->GetOutputSizePixel()).Center();
1624 aPos
= GetActiveWindow()->PixelToLogic(aPos
);
1627 Size
aSize(4000, 1000);
1628 aPos
.AdjustX( -(aSize
.Width() / 2) );
1629 aPos
.AdjustY( -(aSize
.Height() / 2) );
1630 pUnoCtrl
->SetLogicRect(::tools::Rectangle(aPos
, aSize
));
1632 SdrInsertFlags nOptions
= SdrInsertFlags::SETDEFLAYER
;
1634 OSL_ASSERT (GetViewShell()!=nullptr);
1635 SfxInPlaceClient
* pIpClient
= GetViewShell()->GetIPClient();
1636 if (pIpClient
!=nullptr && pIpClient
->IsObjectInPlaceActive())
1638 nOptions
|= SdrInsertFlags::DONTMARK
;
1641 mpDrawView
->InsertObjectAtView(pUnoCtrl
.get(), *mpDrawView
->GetSdrPageView(), nOptions
);
1648 void DrawViewShell::ShowUIControls (bool bVisible
)
1650 ViewShell::ShowUIControls (bVisible
);
1651 maTabControl
->Show (bVisible
);
1654 namespace slideshowhelp
1656 void ShowSlideShow(SfxRequest
const & rReq
, SdDrawDocument
&rDoc
)
1658 Reference
< XPresentation2
> xPresentation( rDoc
.getPresentation() );
1659 if( !xPresentation
.is() )
1662 sfx2::SfxNotebookBar::LockNotebookBar();
1663 if (SID_REHEARSE_TIMINGS
== rReq
.GetSlot())
1664 xPresentation
->rehearseTimings();
1665 else if (rDoc
.getPresentationSettings().mbCustomShow
)
1667 //fdo#69975 if a custom show has been set, then
1668 //use it whether or not we've been asked to
1669 //start from the current or first slide
1670 xPresentation
->start();
1672 // if the custom show not set by default, only show it.
1673 if (rDoc
.getPresentationSettings().mbStartCustomShow
)
1674 rDoc
.getPresentationSettings().mbCustomShow
= false;
1676 else if (SID_PRESENTATION_CURRENT_SLIDE
== rReq
.GetSlot())
1678 //If there is no custom show set, start will automatically
1679 //start at the current page
1680 xPresentation
->start();
1684 //Start at page 0, this would blow away any custom
1685 //show settings if any were set
1686 Sequence
< PropertyValue
> aArguments
{ comphelper::makePropertyValue("FirstPage",
1688 xPresentation
->startWithArguments( aArguments
);
1690 sfx2::SfxNotebookBar::UnlockNotebookBar();
1694 void DrawViewShell::StopSlideShow()
1696 Reference
< XPresentation2
> xPresentation( GetDoc()->getPresentation() );
1697 if(xPresentation
.is() && xPresentation
->isRunning())
1699 if( mpDrawView
->IsTextEdit() )
1700 mpDrawView
->SdrEndTextEdit();
1702 xPresentation
->end();
1706 } // end of namespace sd
1708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */