LibreOffice Module sw (master) 1
viewdraw.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
29#include <sfx2/viewfrm.hxx>
30#include <doc.hxx>
32#include <textboxhelper.hxx>
33#include <editeng/langitem.hxx>
34#include <svx/fontworkbar.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>
46
47#include <view.hxx>
48#include <wrtsh.hxx>
49#include <viewopt.hxx>
50#include <cmdid.h>
51#include <drwbassh.hxx>
52#include <beziersh.hxx>
53#include <conrect.hxx>
54#include <conpoly.hxx>
55#include <conarc.hxx>
56#include <conform.hxx>
57#include <concustomshape.hxx>
58#include <dselect.hxx>
59#include <edtwin.hxx>
60
61#include <dcontact.hxx>
62
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>
68
69using namespace ::com::sun::star;
70
71// Execute Drawing-Ids
72
74{
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;
80
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);
84
85 SdrObjKind eNewFormObjKind = SdrObjKind::NONE;
86 if (nSlotId == SID_FM_CREATE_CONTROL)
87 {
88 const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
89 if (pIdentifierItem)
90 eNewFormObjKind = static_cast<SdrObjKind>(pIdentifierItem->GetValue());
91 }
92
93 if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
94 {
95 bDeselect = true;
96 }
97 else if (nSlotId == SID_FM_CREATE_CONTROL)
98 {
99 if (eNewFormObjKind == m_eFormObjKind || eNewFormObjKind == SdrObjKind::NONE)
100 {
101 bDeselect = true;
102 GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
103 }
104 }
105 else if (nSlotId == SID_FM_CREATE_FIELDCONTROL)
106 {
107 FmFormView* pFormView = dynamic_cast<FmFormView*>(pSdrView);
108 if (pFormView)
109 {
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 )
113 {
114 svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
115 rtl::Reference<SdrObject> pObj = pFormView->CreateFieldControl( aDescriptor );
116
117 if ( pObj )
118 {
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() );
126
127 //determine the size of the object
128 if(pObj->IsGroupObject())
129 {
130 const tools::Rectangle& rBoundRect = static_cast<SdrObjGroup*>(pObj.get())->GetCurrentBoundRect();
131 aStartPos.AdjustX( -(rBoundRect.GetWidth()/2) );
132 aStartPos.AdjustY( -(rBoundRect.GetHeight()/2) );
133 }
134
135 // TODO: unmark all other
136 m_pWrtShell->EnterStdMode();
137 m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
138 }
139 }
140 }
141 }
142 else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
143 {
144 vcl::Window& rWin = m_pWrtShell->GetView().GetViewFrame()->GetWindow();
145
146 rWin.EnterWait();
147
148 if( !m_pWrtShell->HasDrawView() )
149 m_pWrtShell->MakeDrawView();
150
151 pSdrView = m_pWrtShell->GetDrawView();
152 if (pSdrView)
153 {
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();
158
159 SdrObject* pObj = pDlg->GetSdrObjectRef();
160 if ( pObj )
161 {
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() );
167
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) );
172
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) );
177
178 m_pWrtShell->EnterStdMode();
179 m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
180 }
181
182 rWin2.LeaveWait();
183 });
184 }
185 else
186 rWin.LeaveWait();
187 }
188 else if ( m_nFormSfxId != USHRT_MAX )
189 GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );
190
191 if( nSlotId == SID_DRAW_CS_ID )
192 {
193 //deselect if same custom shape is selected again
194 SwDrawBase* pFuncPtr = GetDrawFuncPtr();
195 if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
196 {
197 ConstCustomShape* pConstCustomShape = static_cast<ConstCustomShape*>(pFuncPtr);
198 OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
199 const OUString& aOld = pConstCustomShape->GetShapeType();
200 if( aNew == aOld )
201 {
202 bDeselect = true;
203 }
204 }
205 }
206
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) ) )
211 {
212 if (GetDrawFuncPtr())
213 {
215 SetDrawFuncPtr(nullptr);
216 }
217
218 if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
219 m_pWrtShell->EnterSelFrameMode();
221
222 AttrChangedNotify(nullptr);
223 return;
224 }
225
227
228 if (m_pWrtShell->IsFrameSelected())
229 m_pWrtShell->EnterStdMode(); // because bug #45639
230
231 std::unique_ptr<SwDrawBase> pFuncPtr;
232
233 // for LibreOfficeKit - choosing a shape should construct it directly
234 bool bCreateDirectly = false;
235
236 switch (nSlotId)
237 {
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();
243 break;
244
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:
252 case SID_DRAW_LINE:
253 case SID_DRAW_XLINE:
254 case SID_DRAW_MEASURELINE:
255 case SID_DRAW_RECT:
256 case SID_DRAW_ELLIPSE:
257 case SID_DRAW_TEXT:
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();
266 break;
267
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();
279 break;
280
281 case SID_DRAW_ARC:
282 case SID_DRAW_PIE:
283 case SID_DRAW_CIRCLECUT:
284 pFuncPtr.reset( new ConstArc(m_pWrtShell.get(), m_pEditWin, this) );
285 m_nDrawSfxId = nSlotId;
286 m_sDrawCustom.clear();
287 break;
288
289 case SID_FM_CREATE_CONTROL:
290 {
291 pFuncPtr.reset(new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this, eNewFormObjKind));
292 m_nFormSfxId = nSlotId;
293 m_eFormObjKind = eNewFormObjKind;
294 }
295 break;
296
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 :
304 {
305 pFuncPtr.reset( new ConstCustomShape(m_pWrtShell.get(), m_pEditWin, this, rReq ) );
306
307 bCreateDirectly = comphelper::LibreOfficeKit::isActive();
308
309 m_nDrawSfxId = nSlotId;
310 if ( nSlotId != SID_DRAW_CS_ID )
311 {
312 if ( pStringItem )
313 {
314 m_sDrawCustom = pStringItem->GetValue();
316 rBind.Invalidate( nSlotId );
317 rBind.Update( nSlotId );
318 }
319 }
320 }
321 break;
322
323 default:
324 break;
325 }
326
327 GetViewFrame()->GetBindings().Invalidate(SID_ATTRIBUTES_AREA);
328
329 bool bEndTextEdit = true;
330 if (pFuncPtr)
331 {
332 if (GetDrawFuncPtr())
333 {
335 }
336
337 auto pTempFuncPtr = pFuncPtr.get();
338 SetDrawFuncPtr(std::move(pFuncPtr));
339 AttrChangedNotify(nullptr);
340
341 pTempFuncPtr->Activate(nSlotId);
342 NoRotate();
343 if(rReq.GetModifier() == KEY_MOD1 || bCreateDirectly)
344 {
345 if (bCreateDirectly)
346 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
347 if(SID_OBJECT_SELECT == m_nDrawSfxId )
348 {
349 m_pWrtShell->GotoObj(true);
350 }
351 else if (dynamic_cast<ConstCustomShape*>(pTempFuncPtr))
352 {
353 pTempFuncPtr->CreateDefaultObject();
354 }
355 else
356 {
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 ))
367 {
368 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
369 BeginTextEdit(pObj);
370 bEndTextEdit = false;
371 }
372 }
373 }
374 }
375 else
376 {
377 if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
378 m_pWrtShell->EnterSelFrameMode();
379 }
380
381 if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
382 pSdrView->SdrEndTextEdit( true );
383
384 AttrChangedNotify(nullptr);
385}
386
387// End drawing
388
390{
391 NoRotate();
392
393 if(!m_pShell)
394 return;
395
396 // the shell may be invalid at close/reload/SwitchToViewShell
397 SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
398 sal_uInt16 nIdx = 0;
399 SfxShell* pTest = nullptr;
400 do
401 {
402 pTest = pDispatch->GetShell(nIdx++);
403 }
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))
412 return;
413
414 SdrView *pSdrView = m_pWrtShell->GetDrawView();
415
416 if (pSdrView && pSdrView->IsGroupEntered())
417 {
418 pSdrView->LeaveOneGroup();
419 pSdrView->UnmarkAll();
420 GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
421 }
422
423 if (GetDrawFuncPtr())
424 {
425 if (m_pWrtShell->IsSelFrameMode())
426 m_pWrtShell->LeaveSelFrameMode();
428
429 SetDrawFuncPtr(nullptr);
431
432 GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
433 }
434 GetEditWin().SetPointer(PointerStyle::Text);
435}
436
437// Disable rotate mode
438
440{
441 if (IsDrawRotate())
442 {
443 m_pWrtShell->SetDragMode(SdrDragMode::Move);
445
446 const SfxBoolItem aTmp( SID_OBJECT_ROTATE, false );
447 GetViewFrame()->GetBindings().SetState( aTmp );
448 }
449}
450
451// Enable DrawTextEditMode
452
453static bool lcl_isTextBox(SdrObject const * pObject)
454{
455 if (SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pObject->GetUserCall()))
456 {
457 if (SwFrameFormat* pFormat = pDrawContact->GetFormat())
459 }
460 return false;
461}
462
463bool SwView::EnterDrawTextMode(const Point& aDocPos)
464{
465 SwWrtShell *pSh = &GetWrtShell();
466 SdrView *pSdrView = pSh->GetDrawView();
467 OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
468
469 bool bReturn = false;
470
471 sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
472 pSdrView->SetHitTolerancePixel( 2 );
473
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);
478
479 if (pObj)
480 {
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 &&
485 DynCastSdrTextObj( pObj ) != nullptr )
486 {
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 );
490 }
491 }
492
493 pSdrView->SetHitTolerancePixel( nOld );
494
495 return bReturn;
496}
497
499{
500 SdrView* pSdrView = GetWrtShell().GetDrawView();
501 SdrPageView* pPageView = pSdrView->GetSdrPageView();
502 return BeginTextEdit(pObject, pPageView, m_pEditWin);
503}
504
505// Enable DrawTextEditMode
506
508 bool bIsNewObj, bool bSetSelectionToStart)
509{
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() );
514 if (pOutliner)
515 {
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());
521
522 EEControlBits nCntrl = pOutliner->GetControlWord();
523 nCntrl |= EEControlBits::ALLOWBIGOBJS;
524
525 const SwViewOption *pOpt = pSh->GetViewOptions();
526
528 nCntrl |= EEControlBits::MARKFIELDS;
529 else
530 nCntrl &= ~EEControlBits::MARKFIELDS;
531
532 if (pOpt->IsOnlineSpell())
533 nCntrl |= EEControlBits::ONLINESPELLING;
534 else
535 nCntrl &= ~EEControlBits::ONLINESPELLING;
536
537 pOutliner->SetControlWord(nCntrl);
538 const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
539 pOutliner->SetDefaultLanguage(static_cast<const SvxLanguageItem&>(rItem).GetLanguage());
540
541 if( bIsNewObj )
542 pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == m_nDrawSfxId ||
543 SID_DRAW_CAPTION_VERTICAL == m_nDrawSfxId );
544
545 // set default horizontal text direction at outliner
546 EEHorizontalTextDirection aDefHoriTextDir =
547 pSh->IsShapeDefaultHoriTextDirR2L() ? EEHorizontalTextDirection::R2L : EEHorizontalTextDirection::L2R;
548 pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
549 }
550
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;
555
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
559 // OutlinerView.
560 Point aNewTextEditOffset(0, 0);
561
562 if (SwDrawVirtObj* pVirtObj = dynamic_cast<SwDrawVirtObj *>(pObj))
563 {
564 pToBeActivated = &const_cast<SdrObject&>(pVirtObj->GetReferencedObj());
565 aNewTextEditOffset = pVirtObj->GetOffset();
566 }
567
568 // set in each case, thus it will be correct for all objects
569 static_cast<SdrTextObj*>(pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
570
571 bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, true, pOutliner.release(), nullptr, false, false, false ));
572
573 // #i7672#
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.
577 if(bRet)
578 {
579 OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
580
581 if(pView)
582 {
583 Color aBackground(pSh->GetShapeBackground());
584 pView->SetBackgroundColor(aBackground);
585 }
586
587 // editing should start at the end of text, spell checking at the beginning ...
589 if (bSetSelectionToStart)
591 if (pView)
592 {
594
596 {
597 OString sRect = pView->GetOutputArea().toString();
598 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRect);
599 }
600 }
601 }
602
603 return bRet;
604}
605
606// Is a DrawTextObject selected?
608{
610 SdrInventor nInvent;
611 SdrView *pSdrView = GetWrtShell().GetDrawView();
612 OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
613
614 if (pSdrView->IsCreateMode())
615 pSdrView->SetCreateMode(false);
616
617 pSdrView->TakeCurrentObj(nId,nInvent);
618 return nInvent == SdrInventor::Default;
619}
620
622{
623 return GetWrtShell().GetDrawView();
624}
625
627{
628 return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
629}
630
632{
633 if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
634 {
635 return GetDrawFuncPtr()->IsInsertForm();
636 }
637
638 return AreOnlyFormsSelected();
639}
640
641void SwView::SetDrawFuncPtr(std::unique_ptr<SwDrawBase> pFuncPtr)
642{
643 m_pDrawActual = std::move(pFuncPtr);
644}
645
647{
648 m_nDrawSfxId = SID_OBJECT_SELECT;
649 m_sDrawCustom.clear();
650}
651
653{
654 if ( GetWrtShell().IsFrameSelected() )
655 return false;
656
657 bool bForm = true;
658
659 SdrView* pSdrView = GetWrtShell().GetDrawView();
660
661 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
662 const size_t nCount = rMarkList.GetMarkCount();
663
664 if (nCount)
665 {
666 for (size_t i = 0; i < nCount; ++i)
667 {
668 // Except controls, are still normal draw objects selected?
669 SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
670 if (!pSdrObj)
671 continue;
672
673 if (!HasOnlyObj(pSdrObj, SdrInventor::FmForm))
674 {
675 bForm = false;
676 break;
677 }
678 }
679 }
680 else
681 bForm = false;
682
683 return bForm;
684}
685
686bool SwView::HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const
687{
688 bool bRet = false;
689
690 if (pSdrObj->IsGroupObject())
691 {
692 SdrObjList* pList = pSdrObj->GetSubList();
693 const size_t nCnt = pList->GetObjCount();
694
695 for (size_t i = 0; i < nCnt; ++i)
696 {
697 bRet = HasOnlyObj(pList->GetObj(i), eObjInventor);
698 if (!bRet)
699 break;
700 }
701 }
702 else if (eObjInventor == pSdrObj->GetObjInventor())
703 return true;
704
705 return bRet;
706}
707
708//#i87414# mod
709IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo&, rInfo, void)
710{
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 );
715}
716
717bool SwView::ExecDrwTextSpellPopup(const Point& rPt)
718{
719 bool bRet = false;
720 SdrView *pSdrView = m_pWrtShell->GetDrawView();
721 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
722 Point aPos( GetEditWin().LogicToPixel( rPt ) );
723
724 if (pOLV->IsWrongSpelledWordAtPos( aPos ))
725 {
726 bRet = true;
727 Link<SpellCallbackInfo&,void> aLink = LINK(this, SwView, OnlineSpellCallback);
728 pOLV->ExecuteSpellPopup(aPos, aLink);
729 }
730 return bRet;
731}
732
734{
735 SdrView *pSdrView = m_pWrtShell->GetDrawView();
736 bool bHyphenate = false;
737
739 pSdrView->GetAttributes( aNewAttr );
740 if( aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
741 bHyphenate = aNewAttr.Get( EE_PARA_HYPHENATE ).GetValue();
742
743 return bHyphenate;
744}
745
747{
748 SdrView *pSdrView = m_pWrtShell->GetDrawView();
749 bool bHyphenate = IsDrawTextHyphenate();
750
752 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
753 pSdrView->SetAttributes( aSet );
755}
756
757/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define GetWhich(nSlot)
sal_uInt16 GetValue() const
const OUString & GetValue() const
static OUString GetShapeTypeFromRequest(SfxRequest const &rReq)
const OUString & GetShapeType() const
rtl::Reference< SdrObject > CreateFieldControl(std::u16string_view rFieldDesc) const
virtual OutputDevice * getReferenceDevice(bool bCreate) const =0
Returns the current reference device.
void SetSelection(const ESelection &)
bool IsWrongSpelledWordAtPos(const Point &rPosPixel)
void SetBackgroundColor(const Color &rColor)
tools::Rectangle const & GetOutputArea() const
void ExecuteSpellPopup(const Point &rPosPixel, const Link< SpellCallbackInfo &, void > &rCallBack)
void TakeCurrentObj(SdrObjKind &nIdent, SdrInventor &nInvent) const
void SetCreateMode(bool bOn=true)
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrHdl * PickHandle(const Point &rPnt) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
bool IsCreateMode() const
bool IsMarkedHit(const Point &rPnt, short nTol=-2) const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
const OutlinerView * GetTextEditOutlinerView() const
virtual bool IsTextEdit() const final override
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjList * GetSubList() const
bool IsGroupObject() const
virtual const tools::Rectangle & GetLogicRect() const
bool IsGroupEntered() const
void LeaveOneGroup()
sal_uInt16 GetHitTolerancePixel() const
SdrModel * GetModel() const
void SetHitTolerancePixel(sal_uInt16 nVal)
SdrPageView * GetSdrPageView() const
sal_uInt16 getHitTolLog() const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
void UnmarkAll()
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
void SetState(const SfxItemSet &rSet)
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SfxShell * GetShell(sal_uInt16 nIdx) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
sal_uInt16 GetModifier() const
SfxItemPool & GetPool() const
const css::uno::Any & GetValue() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxViewFrame * GetViewFrame() const
vcl::Window * GetWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:664
virtual void Deactivate()
Definition: drawbase.cxx:444
bool IsInsertForm() const
Definition: drawbase.hxx:50
sal_uInt16 GetSlotId() const
Definition: drawbase.hxx:60
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object.
Definition: dcontact.hxx:212
void SetCalcFieldValueHdl(Outliner *pOutliner)
Definition: feshview.cxx:2879
bool IsShapeDefaultHoriTextDirR2L() const
Is default horizontal text direction for selected drawing object right-to-left.
Definition: feshview.cxx:3302
Color GetShapeBackground() const
SwFEShell::GetShapeBackground.
Definition: feshview.cxx:3254
Style of a layout element.
Definition: frmfmt.hxx:62
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
Point Center() const
Definition: swrect.hxx:338
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
static bool IsFieldShadings()
Definition: viewopt.hxx:780
bool IsOnlineSpell() const
Definition: viewopt.hxx:481
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2809
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
SdrView * GetDrawView()
Definition: vnew.cxx:373
Definition: view.hxx:146
std::unique_ptr< SwDrawBase > m_pDrawActual
Definition: view.hxx:212
OUString m_sDrawCustom
Definition: view.hxx:226
bool ExecDrwTextSpellPopup(const Point &rPt)
Definition: viewdraw.cxx:717
SAL_DLLPRIVATE bool IsDrawTextHyphenate()
Definition: viewdraw.cxx:733
bool IsFormMode() const
Definition: viewdraw.cxx:631
void ExecDraw(const SfxRequest &)
Definition: viewdraw.cxx:73
SAL_DLLPRIVATE bool IsTextTool() const
Definition: viewdraw.cxx:607
SwWrtShell & GetWrtShell() const
Definition: view.hxx:421
sal_uInt16 m_nFormSfxId
Definition: view.hxx:227
SfxShell * m_pShell
Definition: view.hxx:197
bool IsBezierEditMode() const
Definition: viewdraw.cxx:626
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:507
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:194
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:621
void NoRotate()
Definition: viewdraw.cxx:439
SAL_DLLPRIVATE void HyphenateDrawText()
Definition: viewdraw.cxx:746
bool IsDrawSelMode() const
Definition: view.hxx:540
VclPtr< SwEditWin > m_pEditWin
Definition: view.hxx:193
bool AreOnlyFormsSelected() const
Definition: viewdraw.cxx:652
bool HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const
Definition: viewdraw.cxx:686
void SetSelDrawSlot()
Definition: viewdraw.cxx:646
bool EnterShapeDrawTextMode(SdrObject *pObject)
Same as EnterDrawTextMode(), but takes an SdrObject instead of guessing it by document position.
Definition: viewdraw.cxx:498
void FlipDrawRotate()
Definition: view.hxx:539
SwDrawBase * GetDrawFuncPtr() const
Definition: view.hxx:535
SwEditWin & GetEditWin()
Definition: view.hxx:424
void SetDrawFuncPtr(std::unique_ptr< SwDrawBase > pFuncPtr)
Definition: viewdraw.cxx:641
void ExitDraw()
Definition: viewdraw.cxx:389
SdrObjKind m_eFormObjKind
Definition: view.hxx:228
sal_uInt16 m_nDrawSfxId
Definition: view.hxx:225
void LeaveDrawCreate()
Definition: view.hxx:547
bool IsDrawRotate() const
Definition: view.hxx:538
bool EnterDrawTextMode(const Point &aDocPos)
Definition: viewdraw.cxx:463
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
void release() const
constexpr tools::Long GetWidth() const
constexpr tools::Long GetHeight() const
rtl::OString toString() const
void LeaveWait()
void SetPointer(PointerStyle)
void EnterWait()
weld::Window * GetFrameWeld() const
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
#define FN_HYPHENATE_OPT_DLG
Definition: cmdid.h:517
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:634
int nCount
ESelection aNewSelection(GetSelection())
#define EE_PARA_NOT_FOUND
#define EE_INDEX_NOT_FOUND
EEHorizontalTextDirection
EEControlBits
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
EmbeddedObjectRef * pObject
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr sal_uInt16 KEY_MOD1
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:390
int i
sal_Int16 nId
SdrInventor
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:52
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
Definition: swtypes.cxx:57
static bool lcl_isTextBox(SdrObject const *pObject)
Definition: viewdraw.cxx:453
IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo &, rInfo, void)
Definition: viewdraw.cxx:709