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 <hintids.hxx>
21 #include <svl/itempool.hxx>
22 #include <svl/stritem.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdpage.hxx>
26 #include <editeng/outliner.hxx>
27 #include <svx/fmview.hxx>
28 #include <svx/dataaccessdescriptor.hxx>
29 #include <sfx2/viewfrm.hxx>
31 #include <IDocumentDeviceAccess.hxx>
32 #include <textboxhelper.hxx>
33 #include <editeng/langitem.hxx>
34 #include <svx/fontworkbar.hxx>
35 #include <svx/fontworkgallery.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <svx/svdogrp.hxx>
38 #include <svx/svdetc.hxx>
39 #include <editeng/editstat.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <svx/svdoutl.hxx>
44 #include <vcl/ptrstyle.hxx>
45 #include <osl/diagnose.h>
49 #include <viewopt.hxx>
51 #include <drwbassh.hxx>
52 #include <beziersh.hxx>
53 #include <conrect.hxx>
54 #include <conpoly.hxx>
56 #include <conform.hxx>
57 #include <concustomshape.hxx>
58 #include <dselect.hxx>
61 #include <dcontact.hxx>
63 #include <svx/svdpagv.hxx>
64 #include <svx/extrusionbar.hxx>
65 #include <comphelper/lok.hxx>
66 #include <sfx2/lokhelper.hxx>
67 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
69 using namespace ::com::sun::star
;
71 // Execute Drawing-Ids
73 void SwView::ExecDraw(const SfxRequest
& rReq
)
75 const SfxItemSet
*pArgs
= rReq
.GetArgs();
76 const SfxPoolItem
* pItem
;
77 const SfxStringItem
* pStringItem
= nullptr;
78 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
79 bool bDeselect
= false;
81 sal_uInt16 nSlotId
= rReq
.GetSlot();
82 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(GetPool().GetWhich(nSlotId
), false, &pItem
))
83 pStringItem
= dynamic_cast< const SfxStringItem
*>(pItem
);
85 SdrObjKind eNewFormObjKind
= SdrObjKind::NONE
;
86 if (nSlotId
== SID_FM_CREATE_CONTROL
)
88 const SfxUInt16Item
* pIdentifierItem
= rReq
.GetArg
<SfxUInt16Item
>(SID_FM_CONTROL_IDENTIFIER
);
90 eNewFormObjKind
= static_cast<SdrObjKind
>(pIdentifierItem
->GetValue());
93 if (nSlotId
== SID_OBJECT_SELECT
&& m_nFormSfxId
== nSlotId
)
97 else if (nSlotId
== SID_FM_CREATE_CONTROL
)
99 if (eNewFormObjKind
== m_eFormObjKind
|| eNewFormObjKind
== SdrObjKind::NONE
)
102 GetViewFrame().GetDispatcher()->Execute(SID_FM_LEAVE_CREATE
); // Button should popping out
105 else if (nSlotId
== SID_FM_CREATE_FIELDCONTROL
)
107 FmFormView
* pFormView
= dynamic_cast<FmFormView
*>(pSdrView
);
110 const SfxUnoAnyItem
* pDescriptorItem
= rReq
.GetArg
<SfxUnoAnyItem
>(SID_FM_DATACCESS_DESCRIPTOR
);
111 OSL_ENSURE( pDescriptorItem
, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
112 if( pDescriptorItem
)
114 svx::ODataAccessDescriptor
aDescriptor( pDescriptorItem
->GetValue() );
115 rtl::Reference
<SdrObject
> pObj
= pFormView
->CreateFieldControl( aDescriptor
);
119 Size
aDocSize(m_pWrtShell
->GetDocSize());
120 const SwRect
& rVisArea
= m_pWrtShell
->VisArea();
121 Point aStartPos
= rVisArea
.Center();
122 if(rVisArea
.Width() > aDocSize
.Width())
123 aStartPos
.setX( aDocSize
.Width() / 2 + rVisArea
.Left() );
124 if(rVisArea
.Height() > aDocSize
.Height())
125 aStartPos
.setY( aDocSize
.Height() / 2 + rVisArea
.Top() );
127 //determine the size of the object
128 if(pObj
->IsGroupObject())
130 const tools::Rectangle
& rBoundRect
= static_cast<SdrObjGroup
*>(pObj
.get())->GetCurrentBoundRect();
131 aStartPos
.AdjustX( -(rBoundRect
.GetWidth()/2) );
132 aStartPos
.AdjustY( -(rBoundRect
.GetHeight()/2) );
135 // TODO: unmark all other
136 m_pWrtShell
->EnterStdMode();
137 m_pWrtShell
->SwFEShell::InsertDrawObj( *pObj
, aStartPos
);
142 else if ( nSlotId
== SID_FONTWORK_GALLERY_FLOATER
)
144 vcl::Window
& rWin
= m_pWrtShell
->GetView().GetViewFrame().GetWindow();
148 if( !m_pWrtShell
->HasDrawView() )
149 m_pWrtShell
->MakeDrawView();
151 pSdrView
= m_pWrtShell
->GetDrawView();
154 std::shared_ptr
<svx::FontWorkGalleryDialog
> pDlg
= std::make_shared
<svx::FontWorkGalleryDialog
>(rWin
.GetFrameWeld(), *pSdrView
);
155 pDlg
->SetSdrObjectRef(&pSdrView
->GetModel());
156 weld::DialogController::runAsync(pDlg
, [this, pDlg
](int) {
157 vcl::Window
& rWin2
= m_pWrtShell
->GetView().GetViewFrame().GetWindow();
159 SdrObject
* pObj
= pDlg
->GetSdrObjectRef();
162 Size
aDocSize( m_pWrtShell
->GetDocSize() );
163 const SwRect
& rVisArea
= comphelper::LibreOfficeKit::isActive() ?
164 SwRect(m_pWrtShell
->getLOKVisibleArea()) : m_pWrtShell
->VisArea();
165 Point
aPos( rVisArea
.Center() );
166 tools::Rectangle
aObjRect( pObj
->GetLogicRect() );
168 if ( rVisArea
.Width() > aDocSize
.Width())
169 aPos
.setX( aDocSize
.Width() / 2 + rVisArea
.Left() );
170 else if (aPos
.getX() > aObjRect
.GetWidth() / 2)
171 aPos
.AdjustX( -(aObjRect
.GetWidth() / 2) );
173 if (rVisArea
.Height() > aDocSize
.Height())
174 aPos
.setY( aDocSize
.Height() / 2 + rVisArea
.Top() );
175 else if (aPos
.getY() > aObjRect
.GetHeight() / 2)
176 aPos
.AdjustY( -(aObjRect
.GetHeight() / 2) );
178 m_pWrtShell
->EnterStdMode();
179 m_pWrtShell
->SwFEShell::InsertDrawObj( *pObj
, aPos
);
188 else if ( m_nFormSfxId
!= USHRT_MAX
)
189 GetViewFrame().GetDispatcher()->Execute( SID_FM_LEAVE_CREATE
);
191 if( nSlotId
== SID_DRAW_CS_ID
)
193 //deselect if same custom shape is selected again
194 SwDrawBase
* pFuncPtr
= GetDrawFuncPtr();
195 if( pFuncPtr
&& pFuncPtr
->GetSlotId() == SID_DRAW_CS_ID
)
197 ConstCustomShape
* pConstCustomShape
= static_cast<ConstCustomShape
*>(pFuncPtr
);
198 OUString aNew
= ConstCustomShape::GetShapeTypeFromRequest( rReq
);
199 const OUString
& aOld
= pConstCustomShape
->GetShapeType();
207 //deselect if same shape is selected again (but different custom shapes do have same slot id)
208 if ( bDeselect
|| (nSlotId
== m_nDrawSfxId
&&
209 (!pStringItem
|| (pStringItem
->GetValue() == m_sDrawCustom
))
210 && (nSlotId
!= SID_DRAW_CS_ID
) ) )
212 if (GetDrawFuncPtr())
214 GetDrawFuncPtr()->Deactivate();
215 SetDrawFuncPtr(nullptr);
218 if (m_pWrtShell
->IsObjSelected() && !m_pWrtShell
->IsSelFrameMode())
219 m_pWrtShell
->EnterSelFrameMode();
222 AttrChangedNotify(nullptr);
228 if (m_pWrtShell
->IsFrameSelected())
229 m_pWrtShell
->EnterStdMode(); // because bug #45639
231 std::unique_ptr
<SwDrawBase
> pFuncPtr
;
233 // for LibreOfficeKit - choosing a shape should construct it directly
234 bool bCreateDirectly
= false;
238 case SID_OBJECT_SELECT
:
239 case SID_DRAW_SELECT
:
240 pFuncPtr
.reset( new DrawSelection(m_pWrtShell
.get(), m_pEditWin
, this) );
241 m_nDrawSfxId
= m_nFormSfxId
= SID_OBJECT_SELECT
;
242 m_sDrawCustom
.clear();
245 case SID_LINE_ARROW_END
:
246 case SID_LINE_ARROW_CIRCLE
:
247 case SID_LINE_ARROW_SQUARE
:
248 case SID_LINE_ARROW_START
:
249 case SID_LINE_CIRCLE_ARROW
:
250 case SID_LINE_SQUARE_ARROW
:
251 case SID_LINE_ARROWS
:
254 case SID_DRAW_MEASURELINE
:
256 case SID_DRAW_ELLIPSE
:
258 case SID_DRAW_TEXT_VERTICAL
:
259 case SID_DRAW_TEXT_MARQUEE
:
260 case SID_DRAW_CAPTION
:
261 case SID_DRAW_CAPTION_VERTICAL
:
262 pFuncPtr
.reset( new ConstRectangle(m_pWrtShell
.get(), m_pEditWin
, this) );
263 bCreateDirectly
= comphelper::LibreOfficeKit::isActive();
264 m_nDrawSfxId
= nSlotId
;
265 m_sDrawCustom
.clear();
268 case SID_DRAW_XPOLYGON_NOFILL
:
269 case SID_DRAW_XPOLYGON
:
270 case SID_DRAW_POLYGON_NOFILL
:
271 case SID_DRAW_POLYGON
:
272 case SID_DRAW_BEZIER_NOFILL
:
273 case SID_DRAW_BEZIER_FILL
:
274 case SID_DRAW_FREELINE_NOFILL
:
275 case SID_DRAW_FREELINE
:
276 pFuncPtr
.reset( new ConstPolygon(m_pWrtShell
.get(), m_pEditWin
, this) );
277 m_nDrawSfxId
= nSlotId
;
278 m_sDrawCustom
.clear();
283 case SID_DRAW_CIRCLECUT
:
284 pFuncPtr
.reset( new ConstArc(m_pWrtShell
.get(), m_pEditWin
, this) );
285 m_nDrawSfxId
= nSlotId
;
286 m_sDrawCustom
.clear();
289 case SID_FM_CREATE_CONTROL
:
291 pFuncPtr
.reset(new ConstFormControl(m_pWrtShell
.get(), m_pEditWin
, this, eNewFormObjKind
));
292 m_nFormSfxId
= nSlotId
;
293 m_eFormObjKind
= eNewFormObjKind
;
297 case SID_DRAWTBX_CS_BASIC
:
298 case SID_DRAWTBX_CS_SYMBOL
:
299 case SID_DRAWTBX_CS_ARROW
:
300 case SID_DRAWTBX_CS_FLOWCHART
:
301 case SID_DRAWTBX_CS_CALLOUT
:
302 case SID_DRAWTBX_CS_STAR
:
303 case SID_DRAW_CS_ID
:
305 pFuncPtr
.reset( new ConstCustomShape(m_pWrtShell
.get(), m_pEditWin
, this, rReq
) );
307 bCreateDirectly
= comphelper::LibreOfficeKit::isActive();
309 m_nDrawSfxId
= nSlotId
;
310 if ( nSlotId
!= SID_DRAW_CS_ID
)
314 m_sDrawCustom
= pStringItem
->GetValue();
315 SfxBindings
& rBind
= GetViewFrame().GetBindings();
316 rBind
.Invalidate( nSlotId
);
317 rBind
.Update( nSlotId
);
327 GetViewFrame().GetBindings().Invalidate(SID_ATTRIBUTES_AREA
);
329 bool bEndTextEdit
= true;
332 if (GetDrawFuncPtr())
334 GetDrawFuncPtr()->Deactivate();
337 auto pTempFuncPtr
= pFuncPtr
.get();
338 SetDrawFuncPtr(std::move(pFuncPtr
));
339 AttrChangedNotify(nullptr);
341 pTempFuncPtr
->Activate(nSlotId
);
343 if(rReq
.GetModifier() == KEY_MOD1
|| bCreateDirectly
)
346 GetViewFrame().GetDispatcher()->Execute(SID_OBJECT_SELECT
, SfxCallMode::ASYNCHRON
);
347 if(SID_OBJECT_SELECT
== m_nDrawSfxId
)
349 m_pWrtShell
->GotoObj(true);
351 else if (dynamic_cast<ConstCustomShape
*>(pTempFuncPtr
))
353 pTempFuncPtr
->CreateDefaultObject();
357 pTempFuncPtr
->CreateDefaultObject();
358 pTempFuncPtr
->Deactivate();
359 SetDrawFuncPtr(nullptr);
361 m_pWrtShell
->EnterStdMode();
362 SdrView
*pTmpSdrView
= m_pWrtShell
->GetDrawView();
363 const SdrMarkList
& rMarkList
= pTmpSdrView
->GetMarkedObjectList();
364 if(rMarkList
.GetMarkCount() == 1 &&
365 (SID_DRAW_TEXT
== nSlotId
|| SID_DRAW_TEXT_VERTICAL
== nSlotId
||
366 SID_DRAW_TEXT_MARQUEE
== nSlotId
))
368 SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
370 bEndTextEdit
= false;
377 if (m_pWrtShell
->IsObjSelected() && !m_pWrtShell
->IsSelFrameMode())
378 m_pWrtShell
->EnterSelFrameMode();
381 if(bEndTextEdit
&& pSdrView
&& pSdrView
->IsTextEdit())
382 pSdrView
->SdrEndTextEdit( true );
384 AttrChangedNotify(nullptr);
389 void SwView::ExitDraw()
396 // the shell may be invalid at close/reload/SwitchToViewShell
397 SfxDispatcher
* pDispatch
= GetViewFrame().GetDispatcher();
399 SfxShell
* pTest
= nullptr;
402 pTest
= pDispatch
->GetShell(nIdx
++);
404 while( pTest
&& pTest
!= this && pTest
!= m_pShell
);
405 if(!(pTest
== m_pShell
&&
406 // don't call LeaveSelFrameMode() etc. for the below,
407 // because objects may still be selected:
408 dynamic_cast< const SwDrawBaseShell
*>( m_pShell
) == nullptr &&
409 dynamic_cast< const SwBezierShell
*>( m_pShell
) == nullptr &&
410 dynamic_cast< const svx::ExtrusionBar
*>( m_pShell
) == nullptr &&
411 dynamic_cast< const svx::FontworkBar
*>( m_pShell
) == nullptr))
414 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
416 if (pSdrView
&& pSdrView
->IsGroupEntered())
418 pSdrView
->LeaveOneGroup();
419 pSdrView
->UnmarkAll();
420 GetViewFrame().GetBindings().Invalidate(SID_ENTER_GROUP
);
423 if (GetDrawFuncPtr())
425 if (m_pWrtShell
->IsSelFrameMode())
426 m_pWrtShell
->LeaveSelFrameMode();
427 GetDrawFuncPtr()->Deactivate();
429 SetDrawFuncPtr(nullptr);
432 GetViewFrame().GetBindings().Invalidate(SID_INSERT_DRAW
);
434 GetEditWin().SetPointer(PointerStyle::Text
);
437 // Disable rotate mode
439 void SwView::NoRotate()
443 m_pWrtShell
->SetDragMode(SdrDragMode::Move
);
446 const SfxBoolItem
aTmp( SID_OBJECT_ROTATE
, false );
447 GetViewFrame().GetBindings().SetState( aTmp
);
451 // Enable DrawTextEditMode
453 static bool lcl_isTextBox(SdrObject
const * pObject
)
455 if (SwDrawContact
* pDrawContact
= static_cast<SwDrawContact
*>(pObject
->GetUserCall()))
457 if (SwFrameFormat
* pFormat
= pDrawContact
->GetFormat())
458 return SwTextBoxHelper::isTextBox(pFormat
, RES_DRAWFRMFMT
);
463 bool SwView::EnterDrawTextMode(const Point
& aDocPos
)
465 SwWrtShell
*pSh
= &GetWrtShell();
466 SdrView
*pSdrView
= pSh
->GetDrawView();
467 OSL_ENSURE( pSdrView
, "EnterDrawTextMode without DrawView?" );
469 bool bReturn
= false;
471 sal_uInt16 nOld
= pSdrView
->GetHitTolerancePixel();
472 pSdrView
->SetHitTolerancePixel( 2 );
474 SdrObject
* pObj
= nullptr;
475 SdrPageView
* pPV
= nullptr;
476 if (pSdrView
->IsMarkedHit(aDocPos
) && !pSdrView
->PickHandle(aDocPos
) && IsTextTool())
477 pObj
= pSdrView
->PickObj(aDocPos
, pSdrView
->getHitTolLog(), pPV
, SdrSearchOptions::PICKTEXTEDIT
);
481 // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
482 auto pVirtObj
= dynamic_cast<SwDrawVirtObj
*>( pObj
);
483 if ( (pVirtObj
&& DynCastSdrTextObj(&pVirtObj
->GetReferencedObj() ) != nullptr &&
484 m_pWrtShell
->IsSelObjProtected(FlyProtectFlags::Content
) == FlyProtectFlags::NONE
) ||
485 DynCastSdrTextObj( pObj
) != nullptr )
487 // Refuse to edit editeng text of the shape if it has textbox attached.
488 if (!lcl_isTextBox(pObj
))
489 bReturn
= BeginTextEdit( pObj
, pPV
, m_pEditWin
);
493 pSdrView
->SetHitTolerancePixel( nOld
);
498 bool SwView::EnterShapeDrawTextMode(SdrObject
* pObject
)
500 SdrView
* pSdrView
= GetWrtShell().GetDrawView();
501 SdrPageView
* pPageView
= pSdrView
->GetSdrPageView();
502 return BeginTextEdit(pObject
, pPageView
, m_pEditWin
);
505 // Enable DrawTextEditMode
507 bool SwView::BeginTextEdit(SdrObject
* pObj
, SdrPageView
* pPV
, vcl::Window
* pWin
,
508 bool bIsNewObj
, bool bSetSelectionToStart
)
510 SwWrtShell
*pSh
= &GetWrtShell();
511 SdrView
*pSdrView
= pSh
->GetDrawView();
512 std::unique_ptr
<SdrOutliner
> pOutliner
= ::SdrMakeOutliner(OutlinerMode::TextObject
, pSdrView
->GetModel());
513 uno::Reference
< linguistic2::XSpellChecker1
> xSpell( ::GetSpellChecker() );
516 pOutliner
->SetRefDevice(pSh
->getIDocumentDeviceAccess().getReferenceDevice(false));
517 pOutliner
->SetSpeller(xSpell
);
518 uno::Reference
<linguistic2::XHyphenator
> xHyphenator( ::GetHyphenator() );
519 pOutliner
->SetHyphenator( xHyphenator
);
520 pSh
->SetCalcFieldValueHdl(pOutliner
.get());
522 EEControlBits nCntrl
= pOutliner
->GetControlWord();
523 nCntrl
|= EEControlBits::ALLOWBIGOBJS
;
525 const SwViewOption
*pOpt
= pSh
->GetViewOptions();
527 if (pOpt
->IsFieldShadings())
528 nCntrl
|= EEControlBits::MARKFIELDS
;
530 nCntrl
&= ~EEControlBits::MARKFIELDS
;
532 if (pOpt
->IsOnlineSpell())
533 nCntrl
|= EEControlBits::ONLINESPELLING
;
535 nCntrl
&= ~EEControlBits::ONLINESPELLING
;
537 pOutliner
->SetControlWord(nCntrl
);
538 const SfxPoolItem
& rItem
= pSh
->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE
);
539 pOutliner
->SetDefaultLanguage(static_cast<const SvxLanguageItem
&>(rItem
).GetLanguage());
542 pOutliner
->SetVertical( SID_DRAW_TEXT_VERTICAL
== m_nDrawSfxId
||
543 SID_DRAW_CAPTION_VERTICAL
== m_nDrawSfxId
);
545 // set default horizontal text direction at outliner
546 EEHorizontalTextDirection aDefHoriTextDir
=
547 pSh
->IsShapeDefaultHoriTextDirR2L() ? EEHorizontalTextDirection::R2L
: EEHorizontalTextDirection::L2R
;
548 pOutliner
->SetDefaultHorizontalTextDirection( aDefHoriTextDir
);
551 // To allow editing the referenced object from a SwDrawVirtObj here
552 // the original needs to be fetched eventually. This ATM activates the
553 // text edit mode for the original object.
554 SdrObject
* pToBeActivated
= pObj
;
556 // Always the original object is edited. To allow the TextEdit to happen
557 // where the VirtObj is positioned, on demand an occurring offset is set at
558 // the TextEdit object. That offset is used for creating and managing the
560 Point
aNewTextEditOffset(0, 0);
562 if (SwDrawVirtObj
* pVirtObj
= dynamic_cast<SwDrawVirtObj
*>(pObj
))
564 pToBeActivated
= &const_cast<SdrObject
&>(pVirtObj
->GetReferencedObj());
565 aNewTextEditOffset
= pVirtObj
->GetOffset();
568 // set in each case, thus it will be correct for all objects
569 static_cast<SdrTextObj
*>(pToBeActivated
)->SetTextEditOffset(aNewTextEditOffset
);
571 bool bRet(pSdrView
->SdrBeginTextEdit( pToBeActivated
, pPV
, pWin
, true, pOutliner
.release(), nullptr, false, false, false ));
574 // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
575 // sets the background color, an own background color needs to be set
576 // after TextEditing was started. This is now done here.
579 OutlinerView
* pView
= pSdrView
->GetTextEditOutlinerView();
583 Color
aBackground(pSh
->GetShapeBackground());
584 pView
->SetBackgroundColor(aBackground
);
587 // editing should start at the end of text, spell checking at the beginning ...
588 ESelection
aNewSelection(EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
, EE_PARA_NOT_FOUND
, EE_INDEX_NOT_FOUND
);
589 if (bSetSelectionToStart
)
590 aNewSelection
= ESelection();
593 pView
->SetSelection(aNewSelection
);
595 if (comphelper::LibreOfficeKit::isActive())
597 OString sRect
= pView
->GetOutputArea().toString();
598 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_LOCK
, "rectangle", sRect
);
606 // Is a DrawTextObject selected?
607 bool SwView::IsTextTool() const
611 SdrView
*pSdrView
= GetWrtShell().GetDrawView();
612 OSL_ENSURE( pSdrView
, "IsTextTool without DrawView?" );
614 if (pSdrView
->IsCreateMode())
615 pSdrView
->SetCreateMode(false);
617 pSdrView
->TakeCurrentObj(nId
,nInvent
);
618 return nInvent
== SdrInventor::Default
;
621 SdrView
* SwView::GetDrawView() const
623 return GetWrtShell().GetDrawView();
626 bool SwView::IsBezierEditMode() const
628 return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
631 bool SwView::IsFormMode() const
633 if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
635 return GetDrawFuncPtr()->IsInsertForm();
638 return AreOnlyFormsSelected();
641 void SwView::SetDrawFuncPtr(std::unique_ptr
<SwDrawBase
> pFuncPtr
)
643 m_pDrawActual
= std::move(pFuncPtr
);
646 void SwView::SetSelDrawSlot()
648 m_nDrawSfxId
= SID_OBJECT_SELECT
;
649 m_sDrawCustom
.clear();
652 bool SwView::AreOnlyFormsSelected() const
654 if ( GetWrtShell().IsFrameSelected() )
659 SdrView
* pSdrView
= GetWrtShell().GetDrawView();
661 const SdrMarkList
& rMarkList
= pSdrView
->GetMarkedObjectList();
662 const size_t nCount
= rMarkList
.GetMarkCount();
666 for (size_t i
= 0; i
< nCount
; ++i
)
668 // Except controls, are still normal draw objects selected?
669 SdrObject
*pSdrObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
673 if (!HasOnlyObj(pSdrObj
, SdrInventor::FmForm
))
686 bool SwView::HasOnlyObj(SdrObject
const *pSdrObj
, SdrInventor eObjInventor
) const
690 if (pSdrObj
->IsGroupObject())
692 SdrObjList
* pList
= pSdrObj
->GetSubList();
693 const size_t nCnt
= pList
->GetObjCount();
695 for (size_t i
= 0; i
< nCnt
; ++i
)
697 bRet
= HasOnlyObj(pList
->GetObj(i
), eObjInventor
);
702 else if (eObjInventor
== pSdrObj
->GetObjInventor())
709 IMPL_LINK(SwView
, OnlineSpellCallback
, SpellCallbackInfo
&, rInfo
, void)
711 if (rInfo
.nCommand
== SpellCallbackCommand::STARTSPELLDLG
)
712 GetViewFrame().GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG
, SfxCallMode::ASYNCHRON
);
713 else if (rInfo
.nCommand
== SpellCallbackCommand::AUTOCORRECT_OPTIONS
)
714 GetViewFrame().GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG
, SfxCallMode::ASYNCHRON
);
717 bool SwView::ExecDrwTextSpellPopup(const Point
& rPt
)
720 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
721 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
722 Point
aPos( GetEditWin().LogicToPixel( rPt
) );
724 if (pOLV
->IsWrongSpelledWordAtPos( aPos
))
727 Link
<SpellCallbackInfo
&,void> aLink
= LINK(this, SwView
, OnlineSpellCallback
);
728 pOLV
->ExecuteSpellPopup(aPos
, aLink
);
733 bool SwView::IsDrawTextHyphenate()
735 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
736 bool bHyphenate
= false;
738 SfxItemSetFixed
<EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
> aNewAttr( pSdrView
->GetModel().GetItemPool() );
739 pSdrView
->GetAttributes( aNewAttr
);
740 if( aNewAttr
.GetItemState( EE_PARA_HYPHENATE
) >= SfxItemState::DEFAULT
)
741 bHyphenate
= aNewAttr
.Get( EE_PARA_HYPHENATE
).GetValue();
746 void SwView::HyphenateDrawText()
748 SdrView
*pSdrView
= m_pWrtShell
->GetDrawView();
749 bool bHyphenate
= IsDrawTextHyphenate();
751 SfxItemSetFixed
<EE_PARA_HYPHENATE
, EE_PARA_HYPHENATE
> aSet( GetPool() );
752 aSet
.Put( SfxBoolItem( EE_PARA_HYPHENATE
, !bHyphenate
) );
753 pSdrView
->SetAttributes( aSet
);
754 GetViewFrame().GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG
);
757 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */