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>
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 
46 #include <view.hxx>
47 #include <wrtsh.hxx>
48 #include <viewopt.hxx>
49 #include <cmdid.h>
50 #include <drwbassh.hxx>
51 #include <beziersh.hxx>
52 #include <conrect.hxx>
53 #include <conpoly.hxx>
54 #include <conarc.hxx>
55 #include <conform.hxx>
56 #include <concustomshape.hxx>
57 #include <dselect.hxx>
58 #include <edtwin.hxx>
59 
60 #include <dcontact.hxx>
61 
62 #include <svx/svdpagv.hxx>
63 #include <svx/extrusionbar.hxx>
64 #include <comphelper/lok.hxx>
65 #include <sfx2/lokhelper.hxx>
66 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
67 
68 using namespace ::com::sun::star;
69 
70 // Execute Drawing-Ids
71 
73 {
74  const SfxItemSet *pArgs = rReq.GetArgs();
75  const SfxPoolItem* pItem;
76  const SfxStringItem* pStringItem = nullptr;
77  SdrView *pSdrView = m_pWrtShell->GetDrawView();
78  bool bDeselect = false;
79 
80  sal_uInt16 nSlotId = rReq.GetSlot();
81  if(pArgs && SfxItemState::SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), false, &pItem))
82  pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
83 
84  SdrObjKind eNewFormObjKind = OBJ_NONE;
85  if (nSlotId == SID_FM_CREATE_CONTROL)
86  {
87  const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
88  if (pIdentifierItem)
89  eNewFormObjKind = static_cast<SdrObjKind>(pIdentifierItem->GetValue());
90  }
91 
92  if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
93  {
94  bDeselect = true;
95  }
96  else if (nSlotId == SID_FM_CREATE_CONTROL)
97  {
98  if (eNewFormObjKind == m_eFormObjKind || eNewFormObjKind == OBJ_NONE)
99  {
100  bDeselect = true;
101  GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
102  }
103  }
104  else if (nSlotId == SID_FM_CREATE_FIELDCONTROL)
105  {
106  FmFormView* pFormView = dynamic_cast<FmFormView*>(pSdrView);
107  if (pFormView)
108  {
109  const SfxUnoAnyItem* pDescriptorItem = rReq.GetArg<SfxUnoAnyItem>(SID_FM_DATACCESS_DESCRIPTOR);
110  OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
111  if( pDescriptorItem )
112  {
113  svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
114  SdrObjectUniquePtr pObj = pFormView->CreateFieldControl( aDescriptor );
115 
116  if ( pObj )
117  {
118  Size aDocSize(m_pWrtShell->GetDocSize());
119  const SwRect& rVisArea = m_pWrtShell->VisArea();
120  Point aStartPos = rVisArea.Center();
121  if(rVisArea.Width() > aDocSize.Width())
122  aStartPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
123  if(rVisArea.Height() > aDocSize.Height())
124  aStartPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
125 
126  //determine the size of the object
127  if(pObj->IsGroupObject())
128  {
129  const tools::Rectangle& rBoundRect = static_cast<SdrObjGroup*>(pObj.get())->GetCurrentBoundRect();
130  aStartPos.AdjustX( -(rBoundRect.GetWidth()/2) );
131  aStartPos.AdjustY( -(rBoundRect.GetHeight()/2) );
132  }
133 
134  // TODO: unmark all other
135  m_pWrtShell->EnterStdMode();
136  m_pWrtShell->SwFEShell::InsertDrawObj( *(pObj.release()), aStartPos );
137  }
138  }
139  }
140  }
141  else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
142  {
143  vcl::Window& rWin = m_pWrtShell->GetView().GetViewFrame()->GetWindow();
144 
145  rWin.EnterWait();
146 
147  if( !m_pWrtShell->HasDrawView() )
148  m_pWrtShell->MakeDrawView();
149 
150  pSdrView = m_pWrtShell->GetDrawView();
151  if (pSdrView)
152  {
153  SdrObject* pObj = nullptr;
154  svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), *pSdrView);
155  aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
156  aDlg.run();
157  if ( pObj )
158  {
159  Size aDocSize( m_pWrtShell->GetDocSize() );
160  const SwRect& rVisArea = m_pWrtShell->VisArea();
161  Point aPos( rVisArea.Center() );
162  Size aSize;
163  Size aPrefSize( pObj->GetSnapRect().GetSize() );
164 
165  if( rVisArea.Width() > aDocSize.Width())
166  aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
167 
168  if(rVisArea.Height() > aDocSize.Height())
169  aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
170 
171  if( aPrefSize.Width() && aPrefSize.Height() )
172  aSize = rWin.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
173  else
174  aSize = Size( 2835, 2835 );
175 
176  m_pWrtShell->EnterStdMode();
177  m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
178  rReq.Ignore ();
179  }
180  }
181  rWin.LeaveWait();
182  }
183  else if ( m_nFormSfxId != USHRT_MAX )
184  GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );
185 
186  if( nSlotId == SID_DRAW_CS_ID )
187  {
188  //deselect if same custom shape is selected again
189  SwDrawBase* pFuncPtr = GetDrawFuncPtr();
190  if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
191  {
192  ConstCustomShape* pConstCustomShape = static_cast<ConstCustomShape*>(pFuncPtr);
193  OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
194  const OUString& aOld = pConstCustomShape->GetShapeType();
195  if( aNew == aOld )
196  {
197  bDeselect = true;
198  }
199  }
200  }
201 
202  //deselect if same shape is selected again (but different custom shapes do have same slot id)
203  if ( bDeselect || (nSlotId == m_nDrawSfxId &&
204  (!pStringItem || (pStringItem->GetValue() == m_sDrawCustom))
205  && (nSlotId != SID_DRAW_CS_ID) ) )
206  {
207  if (GetDrawFuncPtr())
208  {
210  SetDrawFuncPtr(nullptr);
211  }
212 
213  if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
214  m_pWrtShell->EnterSelFrameMode();
215  LeaveDrawCreate();
216 
217  AttrChangedNotify(nullptr);
218  return;
219  }
220 
221  LeaveDrawCreate();
222 
223  if (m_pWrtShell->IsFrameSelected())
224  m_pWrtShell->EnterStdMode(); // because bug #45639
225 
226  std::unique_ptr<SwDrawBase> pFuncPtr;
227 
228  // for LibreOfficeKit - choosing a shape should construct it directly
229  bool bCreateDirectly = false;
230 
231  switch (nSlotId)
232  {
233  case SID_OBJECT_SELECT:
234  case SID_DRAW_SELECT:
235  pFuncPtr.reset( new DrawSelection(m_pWrtShell.get(), m_pEditWin, this) );
236  m_nDrawSfxId = m_nFormSfxId = SID_OBJECT_SELECT;
237  m_sDrawCustom.clear();
238  break;
239 
240  case SID_LINE_ARROW_END:
241  case SID_LINE_ARROW_CIRCLE:
242  case SID_LINE_ARROW_SQUARE:
243  case SID_LINE_ARROW_START:
244  case SID_LINE_CIRCLE_ARROW:
245  case SID_LINE_SQUARE_ARROW:
246  case SID_LINE_ARROWS:
247  case SID_DRAW_LINE:
248  case SID_DRAW_XLINE:
249  case SID_DRAW_MEASURELINE:
250  case SID_DRAW_RECT:
251  case SID_DRAW_ELLIPSE:
252  case SID_DRAW_TEXT:
253  case SID_DRAW_TEXT_VERTICAL:
254  case SID_DRAW_TEXT_MARQUEE:
255  case SID_DRAW_CAPTION:
256  case SID_DRAW_CAPTION_VERTICAL:
257  pFuncPtr.reset( new ConstRectangle(m_pWrtShell.get(), m_pEditWin, this) );
258  m_nDrawSfxId = nSlotId;
259  m_sDrawCustom.clear();
260  break;
261 
262  case SID_DRAW_XPOLYGON_NOFILL:
263  case SID_DRAW_XPOLYGON:
264  case SID_DRAW_POLYGON_NOFILL:
265  case SID_DRAW_POLYGON:
266  case SID_DRAW_BEZIER_NOFILL:
267  case SID_DRAW_BEZIER_FILL:
268  case SID_DRAW_FREELINE_NOFILL:
269  case SID_DRAW_FREELINE:
270  pFuncPtr.reset( new ConstPolygon(m_pWrtShell.get(), m_pEditWin, this) );
271  m_nDrawSfxId = nSlotId;
272  m_sDrawCustom.clear();
273  break;
274 
275  case SID_DRAW_ARC:
276  case SID_DRAW_PIE:
277  case SID_DRAW_CIRCLECUT:
278  pFuncPtr.reset( new ConstArc(m_pWrtShell.get(), m_pEditWin, this) );
279  m_nDrawSfxId = nSlotId;
280  m_sDrawCustom.clear();
281  break;
282 
283  case SID_FM_CREATE_CONTROL:
284  {
285  pFuncPtr.reset(new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this, eNewFormObjKind));
286  m_nFormSfxId = nSlotId;
287  m_eFormObjKind = eNewFormObjKind;
288  }
289  break;
290 
291  case SID_DRAWTBX_CS_BASIC :
292  case SID_DRAWTBX_CS_SYMBOL :
293  case SID_DRAWTBX_CS_ARROW :
294  case SID_DRAWTBX_CS_FLOWCHART :
295  case SID_DRAWTBX_CS_CALLOUT :
296  case SID_DRAWTBX_CS_STAR :
297  case SID_DRAW_CS_ID :
298  {
299  pFuncPtr.reset( new ConstCustomShape(m_pWrtShell.get(), m_pEditWin, this, rReq ) );
300 
301  bCreateDirectly = comphelper::LibreOfficeKit::isActive();
302 
303  m_nDrawSfxId = nSlotId;
304  if ( nSlotId != SID_DRAW_CS_ID )
305  {
306  if ( pStringItem )
307  {
308  m_sDrawCustom = pStringItem->GetValue();
309  SfxBindings& rBind = GetViewFrame()->GetBindings();
310  rBind.Invalidate( nSlotId );
311  rBind.Update( nSlotId );
312  }
313  }
314  }
315  break;
316 
317  default:
318  break;
319  }
320 
321  GetViewFrame()->GetBindings().Invalidate(SID_ATTRIBUTES_AREA);
322 
323  bool bEndTextEdit = true;
324  if (pFuncPtr)
325  {
326  if (GetDrawFuncPtr())
327  {
329  }
330 
331  auto pTempFuncPtr = pFuncPtr.get();
332  SetDrawFuncPtr(std::move(pFuncPtr));
333  AttrChangedNotify(nullptr);
334 
335  pTempFuncPtr->Activate(nSlotId);
336  NoRotate();
337  if(rReq.GetModifier() == KEY_MOD1 || bCreateDirectly)
338  {
339  if(SID_OBJECT_SELECT == m_nDrawSfxId )
340  {
341  m_pWrtShell->GotoObj(true);
342  }
343  else if (dynamic_cast<ConstCustomShape*>(pTempFuncPtr))
344  {
345  pTempFuncPtr->CreateDefaultObject();
346  }
347  else
348  {
349  pTempFuncPtr->CreateDefaultObject();
350  pTempFuncPtr->Deactivate();
351  SetDrawFuncPtr(nullptr);
352  LeaveDrawCreate();
353  m_pWrtShell->EnterStdMode();
354  SdrView *pTmpSdrView = m_pWrtShell->GetDrawView();
355  const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
356  if(rMarkList.GetMarkCount() == 1 &&
357  (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
358  SID_DRAW_TEXT_MARQUEE == nSlotId ))
359  {
360  SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
361  BeginTextEdit(pObj);
362  bEndTextEdit = false;
363  }
364  }
365  }
366  }
367  else
368  {
369  if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
370  m_pWrtShell->EnterSelFrameMode();
371  }
372 
373  if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
374  pSdrView->SdrEndTextEdit( true );
375 
376  AttrChangedNotify(nullptr);
377 }
378 
379 // End drawing
380 
382 {
383  NoRotate();
384 
385  if(!m_pShell)
386  return;
387 
388  // the shell may be invalid at close/reload/SwitchToViewShell
389  SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
390  sal_uInt16 nIdx = 0;
391  SfxShell* pTest = nullptr;
392  do
393  {
394  pTest = pDispatch->GetShell(nIdx++);
395  }
396  while( pTest && pTest != this && pTest != m_pShell);
397  if(!(pTest == m_pShell &&
398  // don't call LeaveSelFrameMode() etc. for the below,
399  // because objects may still be selected:
400  dynamic_cast< const SwDrawBaseShell *>( m_pShell ) == nullptr &&
401  dynamic_cast< const SwBezierShell *>( m_pShell ) == nullptr &&
402  dynamic_cast< const svx::ExtrusionBar *>( m_pShell ) == nullptr &&
403  dynamic_cast< const svx::FontworkBar *>( m_pShell ) == nullptr))
404  return;
405 
406  SdrView *pSdrView = m_pWrtShell->GetDrawView();
407 
408  if (pSdrView && pSdrView->IsGroupEntered())
409  {
410  pSdrView->LeaveOneGroup();
411  pSdrView->UnmarkAll();
412  GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
413  }
414 
415  if (GetDrawFuncPtr())
416  {
417  if (m_pWrtShell->IsSelFrameMode())
418  m_pWrtShell->LeaveSelFrameMode();
420 
421  SetDrawFuncPtr(nullptr);
422  LeaveDrawCreate();
423 
424  GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
425  }
426  GetEditWin().SetPointer(PointerStyle::Text);
427 }
428 
429 // Disable rotate mode
430 
432 {
433  if (IsDrawRotate())
434  {
435  m_pWrtShell->SetDragMode(SdrDragMode::Move);
436  FlipDrawRotate();
437 
438  const SfxBoolItem aTmp( SID_OBJECT_ROTATE, false );
439  GetViewFrame()->GetBindings().SetState( aTmp );
440  }
441 }
442 
443 // Enable DrawTextEditMode
444 
445 static bool lcl_isTextBox(SdrObject const * pObject)
446 {
447  if (SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pObject->GetUserCall()))
448  {
449  if (SwFrameFormat* pFormat = pDrawContact->GetFormat())
451  }
452  return false;
453 }
454 
455 bool SwView::EnterDrawTextMode(const Point& aDocPos)
456 {
457  SwWrtShell *pSh = &GetWrtShell();
458  SdrView *pSdrView = pSh->GetDrawView();
459  OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
460 
461  bool bReturn = false;
462 
463  sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
464  pSdrView->SetHitTolerancePixel( 2 );
465 
466  SdrObject* pObj = nullptr;
467  SdrPageView* pPV = nullptr;
468  if (pSdrView->IsMarkedHit(aDocPos) && !pSdrView->PickHandle(aDocPos) && IsTextTool())
469  pObj = pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pPV, SdrSearchOptions::PICKTEXTEDIT);
470 
471  if (pObj &&
472  // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
473  ( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ||
474  ( dynamic_cast< const SwDrawVirtObj *>( pObj ) != nullptr &&
475  dynamic_cast< const SdrTextObj *>(&static_cast<SwDrawVirtObj*>(pObj)->GetReferencedObj() ) != nullptr ) ) &&
476 
478  {
479  // Refuse to edit editeng text of the shape if it has textbox attached.
480  if (!lcl_isTextBox(pObj))
481  bReturn = BeginTextEdit( pObj, pPV, m_pEditWin );
482  }
483 
484  pSdrView->SetHitTolerancePixel( nOld );
485 
486  return bReturn;
487 }
488 
490 {
491  SdrView* pSdrView = GetWrtShell().GetDrawView();
492  SdrPageView* pPageView = pSdrView->GetSdrPageView();
493  return BeginTextEdit(pObject, pPageView, m_pEditWin);
494 }
495 
496 // Enable DrawTextEditMode
497 
499  bool bIsNewObj, bool bSetSelectionToStart)
500 {
501  SwWrtShell *pSh = &GetWrtShell();
502  SdrView *pSdrView = pSh->GetDrawView();
503  std::unique_ptr<SdrOutliner> pOutliner = ::SdrMakeOutliner(OutlinerMode::TextObject, *pSdrView->GetModel());
504  uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() );
505  if (pOutliner)
506  {
507  pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess().getReferenceDevice(false));
508  pOutliner->SetSpeller(xSpell);
509  uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
510  pOutliner->SetHyphenator( xHyphenator );
511  pSh->SetCalcFieldValueHdl(pOutliner.get());
512 
513  EEControlBits nCntrl = pOutliner->GetControlWord();
514  nCntrl |= EEControlBits::ALLOWBIGOBJS;
515 
516  const SwViewOption *pOpt = pSh->GetViewOptions();
517 
519  nCntrl |= EEControlBits::MARKFIELDS;
520  else
521  nCntrl &= ~EEControlBits::MARKFIELDS;
522 
523  if (pOpt->IsOnlineSpell())
524  nCntrl |= EEControlBits::ONLINESPELLING;
525  else
526  nCntrl &= ~EEControlBits::ONLINESPELLING;
527 
528  pOutliner->SetControlWord(nCntrl);
529  const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
530  pOutliner->SetDefaultLanguage(static_cast<const SvxLanguageItem&>(rItem).GetLanguage());
531 
532  if( bIsNewObj )
533  pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == m_nDrawSfxId ||
534  SID_DRAW_CAPTION_VERTICAL == m_nDrawSfxId );
535 
536  // set default horizontal text direction at outliner
537  EEHorizontalTextDirection aDefHoriTextDir =
538  pSh->IsShapeDefaultHoriTextDirR2L() ? EEHorizontalTextDirection::R2L : EEHorizontalTextDirection::L2R;
539  pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
540  }
541 
542  // To allow editing the referenced object from a SwDrawVirtObj here
543  // the original needs to be fetched eventually. This ATM activates the
544  // text edit mode for the original object.
545  SdrObject* pToBeActivated = pObj;
546 
547  // Always the original object is edited. To allow the TextEdit to happen
548  // where the VirtObj is positioned, on demand an occurring offset is set at
549  // the TextEdit object. That offset is used for creating and managing the
550  // OutlinerView.
551  Point aNewTextEditOffset(0, 0);
552 
553  if (SwDrawVirtObj* pVirtObj = dynamic_cast<SwDrawVirtObj *>(pObj))
554  {
555  pToBeActivated = &const_cast<SdrObject&>(pVirtObj->GetReferencedObj());
556  aNewTextEditOffset = pVirtObj->GetOffset();
557  }
558 
559  // set in each case, thus it will be correct for all objects
560  static_cast<SdrTextObj*>(pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
561 
562  bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, true, pOutliner.release(), nullptr, false, false, false ));
563 
564  // #i7672#
565  // Since SdrBeginTextEdit actually creates the OutlinerView and thus also
566  // sets the background color, an own background color needs to be set
567  // after TextEditing was started. This is now done here.
568  if(bRet)
569  {
571 
572  if(pView)
573  {
574  Color aBackground(pSh->GetShapeBackgrd());
575  pView->SetBackgroundColor(aBackground);
576  }
577 
578  // editing should start at the end of text, spell checking at the beginning ...
580  if (bSetSelectionToStart)
581  aNewSelection = ESelection();
582  if (pView)
583  {
584  pView->SetSelection(aNewSelection);
585 
587  {
588  OString sRect = pView->GetOutputArea().toString();
589  SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRect);
590  }
591  }
592  }
593 
594  return bRet;
595 }
596 
597 // Is a DrawTextObject selected?
598 bool SwView::IsTextTool() const
599 {
600  SdrObjKind nId;
601  SdrInventor nInvent;
602  SdrView *pSdrView = GetWrtShell().GetDrawView();
603  OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
604 
605  if (pSdrView->IsCreateMode())
606  pSdrView->SetCreateMode(false);
607 
608  pSdrView->TakeCurrentObj(nId,nInvent);
609  return nInvent == SdrInventor::Default;
610 }
611 
613 {
614  return GetWrtShell().GetDrawView();
615 }
616 
618 {
619  return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
620 }
621 
622 bool SwView::IsFormMode() const
623 {
624  if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
625  {
626  return GetDrawFuncPtr()->IsInsertForm();
627  }
628 
629  return AreOnlyFormsSelected();
630 }
631 
632 void SwView::SetDrawFuncPtr(std::unique_ptr<SwDrawBase> pFuncPtr)
633 {
634  m_pDrawActual = std::move(pFuncPtr);
635 }
636 
638 {
639  m_nDrawSfxId = SID_OBJECT_SELECT;
640  m_sDrawCustom.clear();
641 }
642 
644 {
645  if ( GetWrtShell().IsFrameSelected() )
646  return false;
647 
648  bool bForm = true;
649 
650  SdrView* pSdrView = GetWrtShell().GetDrawView();
651 
652  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
653  const size_t nCount = rMarkList.GetMarkCount();
654 
655  if (nCount)
656  {
657  for (size_t i = 0; i < nCount; ++i)
658  {
659  // Except controls, are still normal draw objects selected?
660  SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
661  if (!pSdrObj)
662  continue;
663 
664  if (!HasOnlyObj(pSdrObj, SdrInventor::FmForm))
665  {
666  bForm = false;
667  break;
668  }
669  }
670  }
671  else
672  bForm = false;
673 
674  return bForm;
675 }
676 
677 bool SwView::HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const
678 {
679  bool bRet = false;
680 
681  if (pSdrObj->IsGroupObject())
682  {
683  SdrObjList* pList = pSdrObj->GetSubList();
684  const size_t nCnt = pList->GetObjCount();
685 
686  for (size_t i = 0; i < nCnt; ++i)
687  {
688  bRet = HasOnlyObj(pList->GetObj(i), eObjInventor);
689  if (!bRet)
690  break;
691  }
692  }
693  else if (eObjInventor == pSdrObj->GetObjInventor())
694  return true;
695 
696  return bRet;
697 }
698 
699 //#i87414# mod
700 IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo&, rInfo, void)
701 {
702  if (rInfo.nCommand == SpellCallbackCommand::STARTSPELLDLG)
703  GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON);
704  else if (rInfo.nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
705  GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
706 }
707 
708 bool SwView::ExecDrwTextSpellPopup(const Point& rPt)
709 {
710  bool bRet = false;
711  SdrView *pSdrView = m_pWrtShell->GetDrawView();
712  OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
713  Point aPos( GetEditWin().LogicToPixel( rPt ) );
714 
715  if (pOLV->IsWrongSpelledWordAtPos( aPos ))
716  {
717  bRet = true;
718  Link<SpellCallbackInfo&,void> aLink = LINK(this, SwView, OnlineSpellCallback);
719  pOLV->ExecuteSpellPopup( aPos,&aLink );
720  }
721  return bRet;
722 }
723 
725 {
726  SdrView *pSdrView = m_pWrtShell->GetDrawView();
727  bool bHyphenate = false;
728 
729  SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
731  pSdrView->GetAttributes( aNewAttr );
732  if( aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
733  bHyphenate = aNewAttr.Get( EE_PARA_HYPHENATE ).GetValue();
734 
735  return bHyphenate;
736 }
737 
739 {
740  SdrView *pSdrView = m_pWrtShell->GetDrawView();
741  bool bHyphenate = IsDrawTextHyphenate();
742 
744  aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
745  pSdrView->SetAttributes( aSet );
747 }
748 
749 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
void ExitDraw()
Definition: viewdraw.cxx:381
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void ExecDraw(SfxRequest &)
Definition: viewdraw.cxx:72
SdrObjKind m_eFormObjKind
Definition: view.hxx:217
void SetSdrObjectRef(SdrObject **, SdrModel *pModel)
size_t GetMarkCount() const
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
void ExecuteSpellPopup(const Point &rPosPixel, Link< SpellCallbackInfo &, void > const *pCallBack)
constexpr sal_uInt16 KEY_MOD1
SdrView * GetDrawView()
Definition: vnew.cxx:375
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:498
void SetState(const SfxItemSet &rSet)
bool IsBezierEditMode() const
Definition: viewdraw.cxx:617
bool AreOnlyFormsSelected() const
Definition: viewdraw.cxx:643
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:181
#define FN_HYPHENATE_OPT_DLG
Definition: cmdid.h:487
tools::Rectangle const & GetOutputArea() const
SfxDispatcher * GetDispatcher()
void SetHitTolerancePixel(sal_uInt16 nVal)
void FlipDrawRotate()
Definition: view.hxx:516
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
void EnterWait()
#define EE_INDEX_NOT_FOUND
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:395
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
sal_uInt16 GetValue() const
sal_Int16 nId
tools::Long GetWidth() const
SdrInventor
SwEditWin & GetEditWin()
Definition: view.hxx:402
SdrMark * GetMark(size_t nNum) const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
EEControlBits
bool EnterShapeDrawTextMode(SdrObject *pObject)
Same as EnterDrawTextMode(), but takes an SdrObject instead of guessing it by document position...
Definition: viewdraw.cxx:489
virtual SdrObjList * GetSubList() const
SdrObjKind
SwWrtShell & GetWrtShell() const
Definition: view.hxx:399
virtual const tools::Rectangle & GetSnapRect() const
void SetDrawFuncPtr(std::unique_ptr< SwDrawBase > pFuncPtr)
Definition: viewdraw.cxx:632
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
sal_uInt16 m_nFormSfxId
Definition: view.hxx:216
#define EE_PARA_NOT_FOUND
weld::Window * GetFrameWeld() const
ESelection aNewSelection(GetSelection())
SfxShell * GetShell(sal_uInt16 nIdx) const
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:653
int nCount
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
OUString m_sDrawCustom
Definition: view.hxx:215
bool EnterDrawTextMode(const Point &aDocPos)
Definition: viewdraw.cxx:455
void TakeCurrentObj(SdrObjKind &nIdent, SdrInventor &nInvent) const
SAL_DLLPRIVATE bool IsTextTool() const
Definition: viewdraw.cxx:598
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
const css::uno::Any & GetValue() const
bool IsMarkedHit(const Point &rPnt, short nTol=-2) const
std::unique_ptr< SwDrawBase > m_pDrawActual
Definition: view.hxx:202
void UnmarkAll()
virtual void Deactivate()
Definition: drawbase.cxx:439
SAL_DLLPRIVATE void HyphenateDrawText()
Definition: viewdraw.cxx:738
VclPtr< SwEditWin > m_pEditWin
Definition: view.hxx:180
bool IsDrawSelMode() const
Definition: view.hxx:517
SfxItemPool & GetPool() const
SdrObject * GetMarkedSdrObj() const
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2656
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
bool IsShapeDefaultHoriTextDirR2L() const
Is default horizontal text direction for selected drawing object right-to-left.
Definition: feshview.cxx:3207
Style of a layout element.
Definition: frmfmt.hxx:58
void NoRotate()
Definition: viewdraw.cxx:431
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
void SetSelDrawSlot()
Definition: viewdraw.cxx:637
sal_uInt16 GetModifier() const
static OUString GetShapeTypeFromRequest(SfxRequest const &rReq)
static bool lcl_isTextBox(SdrObject const *pObject)
Definition: viewdraw.cxx:445
SfxBindings & GetBindings()
const OUString & GetValue() const
const SdrMarkList & GetMarkedObjectList() const
const T * GetArg(sal_uInt16 nSlotId) const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
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)
EEHorizontalTextDirection
IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo &, rInfo, void)
Definition: viewdraw.cxx:700
bool IsInsertForm() const
Definition: drawbase.hxx:50
SdrHdl * PickHandle(const Point &rPnt) const
bool IsGroupObject() const
const OutlinerView * GetTextEditOutlinerView() const
void LeaveOneGroup()
bool IsDrawRotate() const
Definition: view.hxx:515
bool IsOnlineSpell() const
Definition: viewopt.hxx:365
void SetCalcFieldValueHdl(Outliner *pOutliner)
Definition: feshview.cxx:2784
void LeaveDrawCreate()
Definition: view.hxx:524
SwDrawBase * GetDrawFuncPtr() const
Definition: view.hxx:512
static bool IsFieldShadings()
Definition: viewopt.hxx:665
bool IsCreateMode() const
Size GetSize() const
virtual SdrInventor GetObjInventor() const
Point PixelToLogic(const Point &rDevicePt) const
void Update(sal_uInt16 nId)
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:52
void SetPointer(PointerStyle)
sal_uInt16 GetSlot() const
void SetSelection(const ESelection &)
virtual bool IsTextEdit() const final override
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:601
#define GetWhich(nSlot)
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
sal_uInt16 GetSlotId() const
Definition: drawbase.hxx:60
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
const OUString & GetShapeType() const
SdrObjectUniquePtr CreateFieldControl(const OUString &rFieldDesc) const
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
void SetBackgroundColor(const Color &rColor)
bool HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const
Definition: viewdraw.cxx:677
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:210
sal_uInt16 GetHitTolerancePixel() const
void SetCreateMode(bool bOn=true)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
void release() const
SAL_DLLPRIVATE bool IsDrawTextHyphenate()
Definition: viewdraw.cxx:724
virtual OutputDevice * getReferenceDevice(bool bCreate) const =0
Returns the current reference device.
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
SdrPageView * GetSdrPageView() const
bool ExecDrwTextSpellPopup(const Point &rPt)
Definition: viewdraw.cxx:708
tools::Long GetHeight() const
sal_uInt16 m_nDrawSfxId
Definition: view.hxx:214
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
Definition: swtypes.cxx:57
SfxShell * m_pShell
Definition: view.hxx:184
const SfxItemPool & GetItemPool() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
void LeaveWait()
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:612
rtl::OString toString() const
bool IsFormMode() const
Definition: viewdraw.cxx:622
OBJ_NONE
void Ignore()
sal_uInt16 getHitTolLog() const
SdrModel * GetModel() const
SdrObjUserCall * GetUserCall() const
bool IsGroupEntered() const
Definition: view.hxx:144
bool IsWrongSpelledWordAtPos(const Point &rPosPixel, bool bMarkIfWrong=false)
Color GetShapeBackgrd() const
SwFEShell::GetShapeBackgrd.
Definition: feshview.cxx:3159