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/aeitem.hxx>
22 #include <svl/itempool.hxx>
23 #include <svl/stritem.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdview.hxx>
26 #include <svx/svdpage.hxx>
27 #include <editeng/editview.hxx>
28 #include <editeng/editeng.hxx>
29 #include <editeng/outliner.hxx>
30 #include <svx/fmview.hxx>
32 #include <svx/svxids.hrc>
33 #include <sfx2/viewfrm.hxx>
34 #include <doc.hxx>
36 #include <textboxhelper.hxx>
37 #include <editeng/langitem.hxx>
38 #include <linguistic/lngprops.hxx>
39 #include <editeng/unolingu.hxx>
40 #include <svx/fontworkbar.hxx>
41 #include <svx/fontworkgallery.hxx>
42 #include <editeng/eeitem.hxx>
43 #include <svx/svdogrp.hxx>
44 #include <svx/svdetc.hxx>
45 #include <editeng/editstat.hxx>
46 #include <sfx2/request.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <sfx2/printer.hxx>
49 #include <svx/fmglob.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <svx/svdoutl.hxx>
52 #include <vcl/ptrstyle.hxx>
53 
54 #include <view.hxx>
55 #include <wrtsh.hxx>
56 #include <viewopt.hxx>
57 #include <cmdid.h>
58 #include <drawsh.hxx>
59 #include <drwbassh.hxx>
60 #include <beziersh.hxx>
61 #include <conrect.hxx>
62 #include <conpoly.hxx>
63 #include <conarc.hxx>
64 #include <conform.hxx>
65 #include <concustomshape.hxx>
66 #include <dselect.hxx>
67 #include <edtwin.hxx>
68 
69 #include <dcontact.hxx>
70 
71 #include <svx/svdpagv.hxx>
72 #include <svx/extrusionbar.hxx>
73 #include <vcl/svapp.hxx>
74 #include <comphelper/lok.hxx>
75 #include <sfx2/lokhelper.hxx>
76 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
77 
78 using namespace ::com::sun::star;
79 
80 // Execute Drawing-Ids
81 
83 {
84  const SfxItemSet *pArgs = rReq.GetArgs();
85  const SfxPoolItem* pItem;
86  const SfxStringItem* pStringItem = nullptr;
87  SdrView *pSdrView = m_pWrtShell->GetDrawView();
88  bool bDeselect = false;
89 
90  sal_uInt16 nSlotId = rReq.GetSlot();
91  if(pArgs && SfxItemState::SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), false, &pItem))
92  pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
93 
94  if (nSlotId == SID_OBJECT_SELECT && m_nFormSfxId == nSlotId)
95  {
96  bDeselect = true;
97  }
98  else if (nSlotId == SID_FM_CREATE_CONTROL)
99  {
100  const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
101  if( pIdentifierItem )
102  {
103  sal_uInt16 nNewId = pIdentifierItem->GetValue();
104  if (nNewId == m_nFormSfxId)
105  {
106  bDeselect = true;
107  GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button should popping out
108  }
109  }
110  }
111  else if (nSlotId == SID_FM_CREATE_FIELDCONTROL)
112  {
113  FmFormView* pFormView = dynamic_cast<FmFormView*>(pSdrView);
114  if (pFormView)
115  {
116  const SfxUnoAnyItem* pDescriptorItem = rReq.GetArg<SfxUnoAnyItem>(SID_FM_DATACCESS_DESCRIPTOR);
117  OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
118  if( pDescriptorItem )
119  {
120  svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
121  SdrObjectUniquePtr pObj = pFormView->CreateFieldControl( aDescriptor );
122 
123  if ( pObj )
124  {
125  Size aDocSize(m_pWrtShell->GetDocSize());
126  const SwRect& rVisArea = m_pWrtShell->VisArea();
127  Point aStartPos = rVisArea.Center();
128  if(rVisArea.Width() > aDocSize.Width())
129  aStartPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
130  if(rVisArea.Height() > aDocSize.Height())
131  aStartPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
132 
133  //determine the size of the object
134  if(pObj->IsGroupObject())
135  {
136  const tools::Rectangle& rBoundRect = static_cast<SdrObjGroup*>(pObj.get())->GetCurrentBoundRect();
137  aStartPos.AdjustX( -(rBoundRect.GetWidth()/2) );
138  aStartPos.AdjustY( -(rBoundRect.GetHeight()/2) );
139  }
140 
141  // TODO: unmark all other
142  m_pWrtShell->EnterStdMode();
143  m_pWrtShell->SwFEShell::InsertDrawObj( *(pObj.release()), aStartPos );
144  }
145  }
146  }
147  }
148  else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
149  {
150  vcl::Window& rWin = m_pWrtShell->GetView().GetViewFrame()->GetWindow();
151 
152  rWin.EnterWait();
153 
154  if( !m_pWrtShell->HasDrawView() )
155  m_pWrtShell->MakeDrawView();
156 
157  pSdrView = m_pWrtShell->GetDrawView();
158  if (pSdrView)
159  {
160  SdrObject* pObj = nullptr;
161  svx::FontWorkGalleryDialog aDlg(rWin.GetFrameWeld(), *pSdrView);
162  aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
163  aDlg.run();
164  if ( pObj )
165  {
166  Size aDocSize( m_pWrtShell->GetDocSize() );
167  const SwRect& rVisArea = m_pWrtShell->VisArea();
168  Point aPos( rVisArea.Center() );
169  Size aSize;
170  Size aPrefSize( pObj->GetSnapRect().GetSize() );
171 
172  if( rVisArea.Width() > aDocSize.Width())
173  aPos.setX( aDocSize.Width() / 2 + rVisArea.Left() );
174 
175  if(rVisArea.Height() > aDocSize.Height())
176  aPos.setY( aDocSize.Height() / 2 + rVisArea.Top() );
177 
178  if( aPrefSize.Width() && aPrefSize.Height() )
179  aSize = rWin.PixelToLogic(aPrefSize, MapMode(MapUnit::MapTwip));
180  else
181  aSize = Size( 2835, 2835 );
182 
183  m_pWrtShell->EnterStdMode();
184  m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
185  rReq.Ignore ();
186  }
187  }
188  rWin.LeaveWait();
189  }
190  else if ( m_nFormSfxId != USHRT_MAX )
191  GetViewFrame()->GetDispatcher()->Execute( SID_FM_LEAVE_CREATE );
192 
193  if( nSlotId == SID_DRAW_CS_ID )
194  {
195  //deselect if same custom shape is selected again
196  SwDrawBase* pFuncPtr = GetDrawFuncPtr();
197  if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
198  {
199  ConstCustomShape* pConstCustomShape = static_cast<ConstCustomShape*>(pFuncPtr);
200  OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
201  const OUString& aOld = pConstCustomShape->GetShapeType();
202  if( aNew == aOld )
203  {
204  bDeselect = true;
205  }
206  }
207  }
208 
209  //deselect if same shape is selected again (but different custom shapes do have same slot id)
210  if ( bDeselect || (nSlotId == m_nDrawSfxId &&
211  (!pStringItem || (pStringItem->GetValue() == m_sDrawCustom))
212  && (nSlotId != SID_DRAW_CS_ID) ) )
213  {
214  if (GetDrawFuncPtr())
215  {
217  SetDrawFuncPtr(nullptr);
218  }
219 
220  if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
221  m_pWrtShell->EnterSelFrameMode();
222  LeaveDrawCreate();
223 
224  AttrChangedNotify(m_pWrtShell.get());
225  return;
226  }
227 
228  LeaveDrawCreate();
229 
230  if (m_pWrtShell->IsFrameSelected())
231  m_pWrtShell->EnterStdMode(); // because bug #45639
232 
233  std::unique_ptr<SwDrawBase> pFuncPtr;
234 
235  // for LibreOfficeKit - choosing a shape should construct it directly
236  bool bCreateDirectly = false;
237 
238  switch (nSlotId)
239  {
240  case SID_OBJECT_SELECT:
241  case SID_DRAW_SELECT:
242  pFuncPtr.reset( new DrawSelection(m_pWrtShell.get(), m_pEditWin, this) );
243  m_nDrawSfxId = m_nFormSfxId = SID_OBJECT_SELECT;
244  m_sDrawCustom.clear();
245  break;
246 
247  case SID_LINE_ARROW_END:
248  case SID_LINE_ARROW_CIRCLE:
249  case SID_LINE_ARROW_SQUARE:
250  case SID_LINE_ARROW_START:
251  case SID_LINE_CIRCLE_ARROW:
252  case SID_LINE_SQUARE_ARROW:
253  case SID_LINE_ARROWS:
254  case SID_DRAW_LINE:
255  case SID_DRAW_XLINE:
256  case SID_DRAW_MEASURELINE:
257  case SID_DRAW_RECT:
258  case SID_DRAW_ELLIPSE:
259  case SID_DRAW_TEXT:
260  case SID_DRAW_TEXT_VERTICAL:
261  case SID_DRAW_TEXT_MARQUEE:
262  case SID_DRAW_CAPTION:
263  case SID_DRAW_CAPTION_VERTICAL:
264  pFuncPtr.reset( new ConstRectangle(m_pWrtShell.get(), m_pEditWin, this) );
265  m_nDrawSfxId = nSlotId;
266  m_sDrawCustom.clear();
267  break;
268 
269  case SID_DRAW_XPOLYGON_NOFILL:
270  case SID_DRAW_XPOLYGON:
271  case SID_DRAW_POLYGON_NOFILL:
272  case SID_DRAW_POLYGON:
273  case SID_DRAW_BEZIER_NOFILL:
274  case SID_DRAW_BEZIER_FILL:
275  case SID_DRAW_FREELINE_NOFILL:
276  case SID_DRAW_FREELINE:
277  pFuncPtr.reset( new ConstPolygon(m_pWrtShell.get(), m_pEditWin, this) );
278  m_nDrawSfxId = nSlotId;
279  m_sDrawCustom.clear();
280  break;
281 
282  case SID_DRAW_ARC:
283  case SID_DRAW_PIE:
284  case SID_DRAW_CIRCLECUT:
285  pFuncPtr.reset( new ConstArc(m_pWrtShell.get(), m_pEditWin, this) );
286  m_nDrawSfxId = nSlotId;
287  m_sDrawCustom.clear();
288  break;
289 
290  case SID_FM_CREATE_CONTROL:
291  {
292  const SfxUInt16Item* pIdentifierItem = rReq.GetArg<SfxUInt16Item>(SID_FM_CONTROL_IDENTIFIER);
293  if( pIdentifierItem )
294  nSlotId = pIdentifierItem->GetValue();
295  pFuncPtr.reset( new ConstFormControl(m_pWrtShell.get(), m_pEditWin, this) );
296  m_nFormSfxId = nSlotId;
297  }
298  break;
299 
300  case SID_DRAWTBX_CS_BASIC :
301  case SID_DRAWTBX_CS_SYMBOL :
302  case SID_DRAWTBX_CS_ARROW :
303  case SID_DRAWTBX_CS_FLOWCHART :
304  case SID_DRAWTBX_CS_CALLOUT :
305  case SID_DRAWTBX_CS_STAR :
306  case SID_DRAW_CS_ID :
307  {
308  pFuncPtr.reset( new ConstCustomShape(m_pWrtShell.get(), m_pEditWin, this, rReq ) );
309 
310  bCreateDirectly = comphelper::LibreOfficeKit::isActive();
311 
312  m_nDrawSfxId = nSlotId;
313  if ( nSlotId != SID_DRAW_CS_ID )
314  {
315  if ( pStringItem )
316  {
317  m_sDrawCustom = pStringItem->GetValue();
318  SfxBindings& rBind = GetViewFrame()->GetBindings();
319  rBind.Invalidate( nSlotId );
320  rBind.Update( nSlotId );
321  }
322  }
323  }
324  break;
325 
326  default:
327  break;
328  }
329 
330  GetViewFrame()->GetBindings().Invalidate(SID_ATTRIBUTES_AREA);
331 
332  bool bEndTextEdit = true;
333  if (pFuncPtr)
334  {
335  if (GetDrawFuncPtr())
336  {
338  }
339 
340  auto pTempFuncPtr = pFuncPtr.get();
341  SetDrawFuncPtr(std::move(pFuncPtr));
342  AttrChangedNotify(m_pWrtShell.get());
343 
344  pTempFuncPtr->Activate(nSlotId);
345  NoRotate();
346  if(rReq.GetModifier() == KEY_MOD1 || bCreateDirectly)
347  {
348  if(SID_OBJECT_SELECT == m_nDrawSfxId )
349  {
350  m_pWrtShell->GotoObj(true);
351  }
352  else if (dynamic_cast<ConstCustomShape*>(pTempFuncPtr))
353  {
354  pTempFuncPtr->CreateDefaultObject();
355  }
356  else
357  {
358  pTempFuncPtr->CreateDefaultObject();
359  pTempFuncPtr->Deactivate();
360  SetDrawFuncPtr(nullptr);
361  LeaveDrawCreate();
362  m_pWrtShell->EnterStdMode();
363  SdrView *pTmpSdrView = m_pWrtShell->GetDrawView();
364  const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
365  if(rMarkList.GetMarkCount() == 1 &&
366  (SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
367  SID_DRAW_TEXT_MARQUEE == nSlotId ))
368  {
369  SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
370  BeginTextEdit(pObj);
371  bEndTextEdit = false;
372  }
373  }
374  }
375  }
376  else
377  {
378  if (m_pWrtShell->IsObjSelected() && !m_pWrtShell->IsSelFrameMode())
379  m_pWrtShell->EnterSelFrameMode();
380  }
381 
382  if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
383  pSdrView->SdrEndTextEdit( true );
384 
385  AttrChangedNotify(m_pWrtShell.get());
386 }
387 
388 // End drawing
389 
391 {
392  NoRotate();
393 
394  if(m_pShell)
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  {
413  SdrView *pSdrView = m_pWrtShell->GetDrawView();
414 
415  if (pSdrView && pSdrView->IsGroupEntered())
416  {
417  pSdrView->LeaveOneGroup();
418  pSdrView->UnmarkAll();
419  GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
420  }
421 
422  if (GetDrawFuncPtr())
423  {
424  if (m_pWrtShell->IsSelFrameMode())
425  m_pWrtShell->LeaveSelFrameMode();
427 
428  SetDrawFuncPtr(nullptr);
429  LeaveDrawCreate();
430 
431  GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
432  }
433  GetEditWin().SetPointer(PointerStyle::Text);
434  }
435  }
436 }
437 
438 // Disable rotate mode
439 
441 {
442  if (IsDrawRotate())
443  {
444  m_pWrtShell->SetDragMode(SdrDragMode::Move);
445  FlipDrawRotate();
446 
447  const SfxBoolItem aTmp( SID_OBJECT_ROTATE, false );
448  GetViewFrame()->GetBindings().SetState( aTmp );
449  }
450 }
451 
452 // Enable DrawTextEditMode
453 
454 static bool lcl_isTextBox(SdrObject const * pObject)
455 {
456  if (SwDrawContact* pDrawContact = static_cast<SwDrawContact*>(pObject->GetUserCall()))
457  {
458  if (SwFrameFormat* pFormat = pDrawContact->GetFormat())
460  }
461  return false;
462 }
463 
464 bool SwView::EnterDrawTextMode(const Point& aDocPos)
465 {
466  SwWrtShell *pSh = &GetWrtShell();
467  SdrView *pSdrView = pSh->GetDrawView();
468  OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
469 
470  bool bReturn = false;
471 
472  sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
473  pSdrView->SetHitTolerancePixel( 2 );
474 
475  SdrObject* pObj = nullptr;
476  SdrPageView* pPV = nullptr;
477  if (pSdrView->IsMarkedHit(aDocPos) && !pSdrView->PickHandle(aDocPos) && IsTextTool())
478  pObj = pSdrView->PickObj(aDocPos, pSdrView->getHitTolLog(), pPV, SdrSearchOptions::PICKTEXTEDIT);
479 
480  if (pObj &&
481  // To allow SwDrawVirtObj text objects to be activated, allow their type, too.
482  ( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ||
483  ( dynamic_cast< const SwDrawVirtObj *>( pObj ) != nullptr &&
484  dynamic_cast< const SdrTextObj *>(&static_cast<SwDrawVirtObj*>(pObj)->GetReferencedObj() ) != nullptr ) ) &&
485 
487  {
488  // Refuse to edit editeng text of the shape if it has textbox attached.
489  if (!lcl_isTextBox(pObj))
490  bReturn = BeginTextEdit( pObj, pPV, m_pEditWin );
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  {
580 
581  if(pView)
582  {
583  Color aBackground(pSh->GetShapeBackgrd());
584  pView->SetBackgroundColor(aBackground);
585  }
586 
587  // editing should start at the end of text, spell checking at the beginning ...
589  if (bSetSelectionToStart)
590  aNewSelection = ESelection();
591  if (pView)
592  {
593  pView->SetSelection(aNewSelection);
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?
607 
608 bool SwView::IsTextTool() const
609 {
610  sal_uInt16 nId;
611  SdrInventor nInvent;
612  SdrView *pSdrView = GetWrtShell().GetDrawView();
613  OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
614 
615  if (pSdrView->IsCreateMode())
616  pSdrView->SetCreateMode(false);
617 
618  pSdrView->TakeCurrentObj(nId,nInvent);
619  return nInvent == SdrInventor::Default;
620 }
621 
623 {
624  return GetWrtShell().GetDrawView();
625 }
626 
628 {
629  return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
630 }
631 
632 bool SwView::IsFormMode() const
633 {
634  if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
635  {
636  return GetDrawFuncPtr()->IsInsertForm();
637  }
638 
639  return AreOnlyFormsSelected();
640 }
641 
642 void SwView::SetDrawFuncPtr(std::unique_ptr<SwDrawBase> pFuncPtr)
643 {
644  m_pDrawActual = std::move(pFuncPtr);
645 }
646 
648 {
649  m_nDrawSfxId = SID_OBJECT_SELECT;
650  m_sDrawCustom.clear();
651 }
652 
654 {
655  if ( GetWrtShell().IsFrameSelected() )
656  return false;
657 
658  bool bForm = true;
659 
660  SdrView* pSdrView = GetWrtShell().GetDrawView();
661 
662  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
663  const size_t nCount = rMarkList.GetMarkCount();
664 
665  if (nCount)
666  {
667  for (size_t i = 0; i < nCount; ++i)
668  {
669  // Except controls, are still normal draw objects selected?
670  SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
671 
672  if (!HasOnlyObj(pSdrObj, SdrInventor::FmForm))
673  {
674  bForm = false;
675  break;
676  }
677  }
678  }
679  else
680  bForm = false;
681 
682  return bForm;
683 }
684 
685 bool SwView::HasOnlyObj(SdrObject const *pSdrObj, SdrInventor eObjInventor) const
686 {
687  bool bRet = false;
688 
689  if (pSdrObj->IsGroupObject())
690  {
691  SdrObjList* pList = pSdrObj->GetSubList();
692  const size_t nCnt = pList->GetObjCount();
693 
694  for (size_t i = 0; i < nCnt; ++i)
695  {
696  bRet = HasOnlyObj(pList->GetObj(i), eObjInventor);
697  if (!bRet)
698  break;
699  }
700  }
701  else if (eObjInventor == pSdrObj->GetObjInventor())
702  return true;
703 
704  return bRet;
705 }
706 
707 //#i87414# mod
708 IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo&, rInfo, void)
709 {
710  if (rInfo.nCommand == SpellCallbackCommand::STARTSPELLDLG)
711  GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON);
712  else if (rInfo.nCommand == SpellCallbackCommand::AUTOCORRECT_OPTIONS)
713  GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
714 }
715 
717 {
718  bool bRet = false;
719  SdrView *pSdrView = m_pWrtShell->GetDrawView();
720  OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
721  Point aPos( GetEditWin().LogicToPixel( rPt ) );
722 
723  if (pOLV->IsWrongSpelledWordAtPos( aPos ))
724  {
725  bRet = true;
726  Link<SpellCallbackInfo&,void> aLink = LINK(this, SwView, OnlineSpellCallback);
727  pOLV->ExecuteSpellPopup( aPos,&aLink );
728  }
729  return bRet;
730 }
731 
733 {
734  SdrView *pSdrView = m_pWrtShell->GetDrawView();
735  bool bHyphenate = false;
736 
737  SfxItemSet 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();
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: */
SfxViewFrame * GetViewFrame() const
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
Definition: swtypes.cxx:50
void ExitDraw()
Definition: viewdraw.cxx:390
long GetWidth() const
void ExecDraw(SfxRequest &)
Definition: viewdraw.cxx:82
void SetSdrObjectRef(SdrObject **, SdrModel *pModel)
size_t GetMarkCount() const
long GetHeight() const
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
void ExecuteSpellPopup(const Point &rPosPixel, Link< SpellCallbackInfo &, void > const *pCallBack)
SdrView * GetDrawView()
Definition: vnew.cxx:376
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:507
void SetState(const SfxItemSet &rSet)
long AdjustX(long nHorzMove)
bool AreOnlyFormsSelected() const
Definition: viewdraw.cxx:653
std::unique_ptr< SwWrtShell > m_pWrtShell
Definition: view.hxx:183
#define FN_HYPHENATE_OPT_DLG
Definition: cmdid.h:470
tools::Rectangle const & GetOutputArea() const
SfxDispatcher * GetDispatcher()
void SetHitTolerancePixel(sal_uInt16 nVal)
void FlipDrawRotate()
Definition: view.hxx:517
void EnterWait()
#define EE_INDEX_NOT_FOUND
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
sal_uInt16 GetValue() const
#define EE_PARA_HYPHENATE
#define KEY_MOD1
sal_Int16 nId
SdrInventor
SwEditWin & GetEditWin()
Definition: view.hxx:403
SdrMark * GetMark(size_t nNum) const
void TakeCurrentObj(sal_uInt16 &nIdent, SdrInventor &nInvent) const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
static void notifyOtherViews(SfxViewShell *pThisView, int nType, const OString &rKey, const OString &rPayload)
EEControlBits
bool EnterShapeDrawTextMode(SdrObject *pObject)
Same as EnterDrawTextMode(), but takes an SdrObject instead of guessing it by document position...
Definition: viewdraw.cxx:498
virtual SdrObjList * GetSubList() const
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
virtual const tools::Rectangle & GetSnapRect() const
void SetDrawFuncPtr(std::unique_ptr< SwDrawBase > pFuncPtr)
Definition: viewdraw.cxx:642
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
sal_uInt16 m_nFormSfxId
Definition: view.hxx:218
#define EE_PARA_NOT_FOUND
weld::Window * GetFrameWeld() const
ESelection aNewSelection(GetSelection())
SfxShell * GetShell(sal_uInt16 nIdx) const
void setX(long nX)
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:682
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
OUString m_sDrawCustom
Definition: view.hxx:217
bool EnterDrawTextMode(const Point &aDocPos)
Definition: viewdraw.cxx:464
SAL_DLLPRIVATE bool IsTextTool() const
Definition: viewdraw.cxx:608
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
const css::uno::Any & GetValue() const
bool IsMarkedHit(const Point &rPnt, short nTol=-2) const
std::unique_ptr< SwDrawBase > m_pDrawActual
Definition: view.hxx:204
void UnmarkAll()
void setY(long nY)
virtual void Deactivate()
Definition: drawbase.cxx:441
bool IsDrawRotate()
Definition: view.hxx:516
SAL_DLLPRIVATE void HyphenateDrawText()
Definition: viewdraw.cxx:746
VclPtr< SwEditWin > m_pEditWin
Definition: view.hxx:182
SfxItemPool & GetPool() const
SdrObject * GetMarkedSdrObj() const
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2589
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:3218
Style of a layout element.
Definition: frmfmt.hxx:57
void NoRotate()
Definition: viewdraw.cxx:440
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
long AdjustY(long nVertMove)
void SetSelDrawSlot()
Definition: viewdraw.cxx:647
sal_uInt16 GetModifier() const
static OUString GetShapeTypeFromRequest(SfxRequest const &rReq)
static bool lcl_isTextBox(SdrObject const *pObject)
Definition: viewdraw.cxx:454
SfxBindings & GetBindings()
int i
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:708
bool IsInsertForm() const
Definition: drawbase.hxx:50
SdrHdl * PickHandle(const Point &rPnt) const
bool IsGroupObject() const
const OutlinerView * GetTextEditOutlinerView() const
void LeaveOneGroup()
bool IsOnlineSpell() const
Definition: viewopt.hxx:332
void SetCalcFieldValueHdl(Outliner *pOutliner)
Definition: feshview.cxx:2801
void LeaveDrawCreate()
Definition: view.hxx:525
SwDrawBase * GetDrawFuncPtr() const
Definition: view.hxx:513
static bool IsFieldShadings()
Definition: viewopt.hxx:632
bool IsCreateMode() const
Size GetSize() const
virtual SdrInventor GetObjInventor() const
Point PixelToLogic(const Point &rDevicePt) const
void Update(sal_uInt16 nId)
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:583
#define RES_DRAWFRMFMT
Definition: hintids.hxx:277
#define GetWhich(nSlot)
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:426
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
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:685
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:210
sal_uInt16 GetHitTolerancePixel() const
bool IsDrawSelMode()
Definition: view.hxx:518
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:45
void SetCreateMode(bool bOn=true)
void release() const
SAL_DLLPRIVATE bool IsDrawTextHyphenate()
Definition: viewdraw.cxx:732
virtual OutputDevice * getReferenceDevice(bool bCreate) const =0
Returns the current reference device.
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
SdrPageView * GetSdrPageView() const
bool ExecDrwTextSpellPopup(const Point &rPt)
Definition: viewdraw.cxx:716
sal_uInt16 m_nDrawSfxId
Definition: view.hxx:216
SfxShell * m_pShell
Definition: view.hxx:186
const SfxItemPool & GetItemPool() const
sal_uInt16 GetSlotId()
Definition: drawbase.hxx:60
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:622
rtl::OString toString() const
bool IsFormMode() const
Definition: viewdraw.cxx:632
bool IsBezierEditMode()
Definition: viewdraw.cxx:627
void Ignore()
sal_uInt16 getHitTolLog() const
SdrModel * GetModel() const
SdrObjUserCall * GetUserCall() const
bool IsGroupEntered() const
Definition: view.hxx:146
bool IsWrongSpelledWordAtPos(const Point &rPosPixel, bool bMarkIfWrong=false)
Color GetShapeBackgrd() const
SwFEShell::GetShapeBackgrd.
Definition: feshview.cxx:3170