LibreOffice Module svx (master)  1
weldeditview.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 
21 #include <com/sun/star/accessibility/AccessibleRole.hpp>
22 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
27 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <editeng/eeitem.hxx>
33 #include <editeng/fhgtitem.hxx>
34 #include <editeng/fontitem.hxx>
35 #include <editeng/outliner.hxx>
36 #include <editeng/unoedhlp.hxx>
37 #include <editeng/unoedsrc.hxx>
39 #include <osl/diagnose.h>
40 #include <svl/itempool.hxx>
41 #include <svl/itemset.hxx>
42 #include <sal/log.hxx>
46 #include <svx/weldeditview.hxx>
47 #include <tools/diagnose_ex.h>
49 #include <vcl/canvastools.hxx>
50 #include <vcl/cursor.hxx>
51 #include <vcl/event.hxx>
52 #include <vcl/ptrstyle.hxx>
53 #include <vcl/settings.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/window.hxx>
56 #include <vcl/uitest/uiobject.hxx>
57 
58 void WeldEditView::SetText(const OUString& rStr) { GetEditEngine()->SetText(rStr); }
59 
60 OUString WeldEditView::GetText() const { return GetEditEngine()->GetText(); }
61 
63 {
64  GetEditEngine()->SetModifyHdl(rLink);
65 }
66 
68 
70 
72 {
73  EditView* pEditView = GetEditView();
74  return pEditView && pEditView->HasSelection();
75 }
76 
78 {
79  if (EditView* pEditView = GetEditView())
80  pEditView->DeleteSelected();
81 }
82 
84 {
85  if (EditView* pEditView = GetEditView())
86  pEditView->Cut();
87 }
88 
90 {
91  if (EditView* pEditView = GetEditView())
92  pEditView->Copy();
93 }
94 
96 {
97  if (EditView* pEditView = GetEditView())
98  pEditView->Paste();
99 }
100 
102  : m_bAcceptsTab(false)
103 {
104 }
105 
106 // tdf#127033 want to use UI font so override makeEditEngine to enable that
108 {
110 
111  vcl::Font aAppFont(Application::GetSettings().GetStyleSettings().GetAppFont());
112 
113  pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
114  "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
116  pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
117  "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
119  pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
120  "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
122 
123  pItemPool->SetPoolDefaultItem(
124  SvxFontHeightItem(aAppFont.GetFontHeight() * 20, 100, EE_CHAR_FONTHEIGHT));
125  pItemPool->SetPoolDefaultItem(
127  pItemPool->SetPoolDefaultItem(
129 
130  m_xEditEngine.reset(new EditEngine(pItemPool.get()));
131 }
132 
134 {
135  if (EditView* pEditView = GetEditView())
136  {
138  Size aOutputSize(rDevice.PixelToLogic(GetOutputSizePixel()));
139  // Resizes the edit engine to adjust to the size of the output area
140  pEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
141  GetEditEngine()->SetPaperSize(aOutputSize);
142  pEditView->ShowCursor();
143 
144  const tools::Long nMaxVisAreaStart
145  = pEditView->GetEditEngine()->GetTextHeight() - aOutputSize.Height();
146  tools::Rectangle aVisArea(pEditView->GetVisArea());
147  if (aVisArea.Top() > nMaxVisAreaStart)
148  {
149  aVisArea.SetTop(std::max<tools::Long>(nMaxVisAreaStart, 0));
150  aVisArea.SetSize(aOutputSize);
151  pEditView->SetVisArea(aVisArea);
152  pEditView->ShowCursor();
153  }
154 
156  }
158 }
159 
160 void WeldEditView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
161 {
162  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
163  Color aBgColor = rStyleSettings.GetWindowColor();
164 
165  rRenderContext.SetBackground(aBgColor);
166  if (EditView* pEditView = GetEditView())
167  pEditView->SetBackgroundColor(aBgColor);
168 
169  DoPaint(rRenderContext, rRect);
170 }
171 
172 void WeldEditView::DoPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
173 {
174  rRenderContext.Push(vcl::PushFlags::ALL);
175  rRenderContext.SetClipRegion();
176 
177  std::vector<tools::Rectangle> aLogicRects;
178 
179  if (EditView* pEditView = GetEditView())
180  {
181  pEditView->Paint(rRect, &rRenderContext);
182 
183  if (HasFocus())
184  {
185  pEditView->ShowCursor(false);
186  vcl::Cursor* pCursor = pEditView->GetCursor();
187  pCursor->DrawToDevice(rRenderContext);
188  }
189 
190  // get logic selection
191  pEditView->GetSelectionRectangles(aLogicRects);
192  }
193 
194  if (!aLogicRects.empty())
195  {
196  std::vector<basegfx::B2DRange> aLogicRanges;
197  aLogicRanges.reserve(aLogicRects.size());
198 
199  tools::Long nMinX(LONG_MAX), nMaxX(0), nMinY(LONG_MAX), nMaxY(0);
200  for (const auto& aRect : aLogicRects)
201  {
202  nMinX = std::min(nMinX, aRect.Left());
203  nMinY = std::min(nMinY, aRect.Top());
204  nMaxX = std::max(nMaxX, aRect.Right());
205  nMaxY = std::max(nMaxY, aRect.Bottom());
206  }
207 
208  const Size aLogicPixel(rRenderContext.PixelToLogic(Size(1, 1)));
209  for (const auto& aRect : aLogicRects)
210  {
211  // Extend each range by one pixel so multiple lines touch each
212  // other if adjacent, so the whole set is drawn with a single
213  // border around the lot. But keep the selection within the
214  // original max extents.
215  auto nTop = aRect.Top();
216  if (nTop > nMinY)
217  nTop -= aLogicPixel.Height();
218  auto nBottom = aRect.Bottom();
219  if (nBottom < nMaxY)
220  nBottom += aLogicPixel.Height();
221  auto nLeft = aRect.Left();
222  if (nLeft > nMinX)
223  nLeft -= aLogicPixel.Width();
224  auto nRight = aRect.Right();
225  if (nRight < nMaxX)
226  nRight += aLogicPixel.Width();
227 
228  aLogicRanges.emplace_back(nLeft, nTop, nRight, nBottom);
229  }
230 
231  // get the system's highlight color
233 
235  aHighlight, std::move(aLogicRanges), true);
236 
237  const drawinglayer::geometry::ViewInformation2D aViewInformation2D(
238  basegfx::B2DHomMatrix(), rRenderContext.GetViewTransformation(),
239  vcl::unotools::b2DRectangleFromRectangle(rRect), nullptr, 0.0);
240 
241  std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> xProcessor(
243  aViewInformation2D));
244 
245  xProcessor->process(aCursorOverlay.getOverlayObjectPrimitive2DSequence());
246  }
247 
248  rRenderContext.Pop();
249 }
250 
252 {
253  EditView* pEditView = GetEditView();
254  return pEditView && pEditView->MouseMove(rMEvt);
255 }
256 
258 {
259  if (!IsMouseCaptured())
260  CaptureMouse();
261 
262  if (!HasFocus() && CanFocus())
263  GrabFocus();
264 
265  EditView* pEditView = GetEditView();
266  return pEditView && pEditView->MouseButtonDown(rMEvt);
267 }
268 
270 {
271  if (IsMouseCaptured())
272  ReleaseMouse();
273  EditView* pEditView = GetEditView();
274  return pEditView && pEditView->MouseButtonUp(rMEvt);
275 }
276 
278 {
279  EditView* pEditView = GetEditView();
280 
281  sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
282 
283  if (nKey == KEY_TAB && !GetAcceptsTab())
284  {
285  return false;
286  }
287  else if (pEditView && !pEditView->PostKeyEvent(rKEvt))
288  {
289  if (rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2())
290  {
291  if (nKey == KEY_A)
292  {
293  EditEngine* pEditEngine = GetEditEngine();
294  sal_Int32 nPar = pEditEngine->GetParagraphCount();
295  if (nPar)
296  {
297  sal_Int32 nLen = pEditEngine->GetTextLen(nPar - 1);
298  pEditView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
299  }
300  return true;
301  }
302  }
303 
304  return false;
305  }
306 
307  return true;
308 }
309 
311 {
312  EditView* pEditView = GetEditView();
313  if (!pEditView)
314  return false;
315  return pEditView->Command(rCEvt);
316 }
317 
319 {
321 }
322 
323 class WeldEditAccessible;
324 
325 namespace
326 {
327 class WeldViewForwarder : public SvxViewForwarder
328 {
329  WeldEditAccessible& m_rEditAcc;
330 
331  WeldViewForwarder(const WeldViewForwarder&) = delete;
332  WeldViewForwarder& operator=(const WeldViewForwarder&) = delete;
333 
334 public:
335  explicit WeldViewForwarder(WeldEditAccessible& rAcc)
336  : m_rEditAcc(rAcc)
337  {
338  }
339 
340  virtual bool IsValid() const override;
341  virtual Point LogicToPixel(const Point& rPoint, const MapMode& rMapMode) const override;
342  virtual Point PixelToLogic(const Point& rPoint, const MapMode& rMapMode) const override;
343 };
344 }
345 
346 class WeldEditAccessible;
347 
348 namespace
349 {
350 class WeldEditSource;
351 
352 /* analog to SvxEditEngineForwarder */
353 class WeldTextForwarder : public SvxTextForwarder
354 {
355  WeldEditAccessible& m_rEditAcc;
356  WeldEditSource& m_rEditSource;
357 
358  DECL_LINK(NotifyHdl, EENotify&, void);
359 
360  WeldTextForwarder(const WeldTextForwarder&) = delete;
361  WeldTextForwarder& operator=(const WeldTextForwarder&) = delete;
362 
363 public:
364  WeldTextForwarder(WeldEditAccessible& rAcc, WeldEditSource& rSource);
365  virtual ~WeldTextForwarder() override;
366 
367  virtual sal_Int32 GetParagraphCount() const override;
368  virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const override;
369  virtual OUString GetText(const ESelection& rSel) const override;
370  virtual SfxItemSet GetAttribs(const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib
371  = EditEngineAttribs::All) const override;
372  virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const override;
373  virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet& rSet) override;
374  virtual void RemoveAttribs(const ESelection& rSelection) override;
375  virtual void GetPortions(sal_Int32 nPara, std::vector<sal_Int32>& rList) const override;
376 
377  virtual SfxItemState GetItemState(const ESelection& rSel, sal_uInt16 nWhich) const override;
378  virtual SfxItemState GetItemState(sal_Int32 nPara, sal_uInt16 nWhich) const override;
379 
380  virtual void QuickInsertText(const OUString& rText, const ESelection& rSel) override;
381  virtual void QuickInsertField(const SvxFieldItem& rFld, const ESelection& rSel) override;
382  virtual void QuickSetAttribs(const SfxItemSet& rSet, const ESelection& rSel) override;
383  virtual void QuickInsertLineBreak(const ESelection& rSel) override;
384 
385  virtual SfxItemPool* GetPool() const override;
386 
387  virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
388  std::optional<Color>& rpTxtColor,
389  std::optional<Color>& rpFldColor) override;
390  virtual void FieldClicked(const SvxFieldItem&) override;
391  virtual bool IsValid() const override;
392 
393  virtual LanguageType GetLanguage(sal_Int32, sal_Int32) const override;
394  virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const override;
395  virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const override;
396  virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const override;
397  virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const override;
398  virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const override;
399  virtual MapMode GetMapMode() const override;
400  virtual OutputDevice* GetRefDevice() const override;
401  virtual bool GetIndexAtPoint(const Point&, sal_Int32& nPara, sal_Int32& nIndex) const override;
402  virtual bool GetWordIndices(sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart,
403  sal_Int32& nEnd) const override;
404  virtual bool GetAttributeRun(sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara,
405  sal_Int32 nIndex, bool bInCell = false) const override;
406  virtual sal_Int32 GetLineCount(sal_Int32 nPara) const override;
407  virtual sal_Int32 GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const override;
408  virtual void GetLineBoundaries(/*out*/ sal_Int32& rStart, /*out*/ sal_Int32& rEnd,
409  sal_Int32 nParagraph, sal_Int32 nLine) const override;
410  virtual sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nLine) const override;
411  virtual bool Delete(const ESelection&) override;
412  virtual bool InsertText(const OUString&, const ESelection&) override;
413  virtual bool QuickFormatDoc(bool bFull = false) override;
414 
415  virtual sal_Int16 GetDepth(sal_Int32 nPara) const override;
416  virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth) override;
417 
418  virtual const SfxItemSet* GetEmptyItemSetPtr() override;
419  // implementation functions for XParagraphAppend and XTextPortionAppend
420  virtual void AppendParagraph() override;
421  virtual sal_Int32 AppendTextPortion(sal_Int32 nPara, const OUString& rText,
422  const SfxItemSet& rSet) override;
423 
424  virtual void CopyText(const SvxTextForwarder& rSource) override;
425 };
426 
427 /* analog to SvxEditEngineViewForwarder */
428 class WeldEditViewForwarder : public SvxEditViewForwarder
429 {
430  WeldEditAccessible& m_rEditAcc;
431 
432  WeldEditViewForwarder(const WeldEditViewForwarder&) = delete;
433  WeldEditViewForwarder& operator=(const WeldEditViewForwarder&) = delete;
434 
435 public:
436  explicit WeldEditViewForwarder(WeldEditAccessible& rAcc);
437 
438  virtual bool IsValid() const override;
439 
440  virtual Point LogicToPixel(const Point& rPoint, const MapMode& rMapMode) const override;
441  virtual Point PixelToLogic(const Point& rPoint, const MapMode& rMapMode) const override;
442 
443  virtual bool GetSelection(ESelection& rSelection) const override;
444  virtual bool SetSelection(const ESelection& rSelection) override;
445  virtual bool Copy() override;
446  virtual bool Cut() override;
447  virtual bool Paste() override;
448 };
449 
450 class WeldEditSource : public SvxEditSource
451 {
452  SfxBroadcaster m_aBroadCaster;
453  WeldViewForwarder m_aViewFwd;
454  WeldTextForwarder m_aTextFwd;
455  WeldEditViewForwarder m_aEditViewFwd;
456  WeldEditAccessible& m_rEditAcc;
457 
458  WeldEditSource(const WeldEditSource& rSrc)
459  : SvxEditSource()
460  , m_aViewFwd(rSrc.m_rEditAcc)
461  , m_aTextFwd(rSrc.m_rEditAcc, *this)
462  , m_aEditViewFwd(rSrc.m_rEditAcc)
463  , m_rEditAcc(rSrc.m_rEditAcc)
464  {
465  }
466 
467  WeldEditSource& operator=(const WeldEditSource&) = delete;
468 
469 public:
470  WeldEditSource(WeldEditAccessible& rAcc)
471  : m_aViewFwd(rAcc)
472  , m_aTextFwd(rAcc, *this)
473  , m_aEditViewFwd(rAcc)
474  , m_rEditAcc(rAcc)
475  {
476  }
477 
478  virtual std::unique_ptr<SvxEditSource> Clone() const override
479  {
480  return std::unique_ptr<SvxEditSource>(new WeldEditSource(*this));
481  }
482 
483  virtual SvxTextForwarder* GetTextForwarder() override { return &m_aTextFwd; }
484 
485  virtual SvxViewForwarder* GetViewForwarder() override { return &m_aViewFwd; }
486 
487  virtual SvxEditViewForwarder* GetEditViewForwarder(bool /*bCreate*/) override
488  {
489  return &m_aEditViewFwd;
490  }
491 
492  virtual void UpdateData() override
493  {
494  // would possibly only by needed if the XText interface is implemented
495  // and its text needs to be updated.
496  }
497  virtual SfxBroadcaster& GetBroadcaster() const override
498  {
499  return const_cast<WeldEditSource*>(this)->m_aBroadCaster;
500  }
501 };
502 }
503 
504 typedef cppu::WeakImplHelper<css::lang::XServiceInfo, css::accessibility::XAccessible,
505  css::accessibility::XAccessibleComponent,
506  css::accessibility::XAccessibleContext,
507  css::accessibility::XAccessibleEventBroadcaster>
509 
511 {
515  std::unique_ptr<::accessibility::AccessibleTextHelper> m_xTextHelper;
516 
517 public:
519  : m_pController(pController)
520  , m_pEditEngine(nullptr)
521  , m_pEditView(nullptr)
522  {
523  }
524 
525  ::accessibility::AccessibleTextHelper* GetTextHelper() { return m_xTextHelper.get(); }
526 
527  void Init(EditEngine* pEditEngine, EditView* pEditView)
528  {
529  m_pEditEngine = pEditEngine;
530  m_pEditView = pEditView;
531  m_xTextHelper.reset(
532  new ::accessibility::AccessibleTextHelper(std::make_unique<WeldEditSource>(*this)));
533  m_xTextHelper->SetEventSource(this);
534  }
535 
538 
539  void ClearWin()
540  {
541  // remove handler before current object gets destroyed
542  // (avoid handler being called for already dead object)
543  m_pEditEngine->SetNotifyHdl(Link<EENotify&, void>());
544 
545  m_pEditEngine = nullptr;
546  m_pEditView = nullptr;
547  m_pController = nullptr; // implicitly results in AccessibleStateType::DEFUNC set
548 
550  m_xTextHelper->SetEditSource(::std::unique_ptr<SvxEditSource>());
551 
554  m_xTextHelper->Dispose();
555  m_xTextHelper.reset();
556  }
557 
558  // XAccessible
559  virtual css::uno::Reference<css::accessibility::XAccessibleContext>
560  SAL_CALL getAccessibleContext() override
561  {
562  return this;
563  }
564 
565  // XAccessibleComponent
566  virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point& rPoint) override
567  {
570  SolarMutexGuard aGuard;
571  if (!m_pController)
572  throw css::uno::RuntimeException();
573 
574  Size aSz(m_pController->GetOutputSizePixel());
575  return rPoint.X >= 0 && rPoint.Y >= 0 && rPoint.X < aSz.Width() && rPoint.Y < aSz.Height();
576  }
577 
578  virtual css::uno::Reference<css::accessibility::XAccessible>
579  SAL_CALL getAccessibleAtPoint(const css::awt::Point& rPoint) override
580  {
581  SolarMutexGuard aGuard;
582  if (!m_xTextHelper)
583  throw css::uno::RuntimeException();
584 
585  return m_xTextHelper->GetAt(rPoint);
586  }
587 
588  virtual css::awt::Rectangle SAL_CALL getBounds() override
589  {
590  SolarMutexGuard aGuard;
591  if (!m_pController)
592  throw css::uno::RuntimeException();
593 
594  const Point aOutPos;
595  const Size aOutSize(m_pController->GetOutputSizePixel());
596  css::awt::Rectangle aRet;
597 
598  aRet.X = aOutPos.X();
599  aRet.Y = aOutPos.Y();
600  aRet.Width = aOutSize.Width();
601  aRet.Height = aOutSize.Height();
602 
603  return aRet;
604  }
605 
606  virtual css::awt::Point SAL_CALL getLocation() override
607  {
608  SolarMutexGuard aGuard;
609  if (!m_pController)
610  throw css::uno::RuntimeException();
611 
612  const css::awt::Rectangle aRect(getBounds());
613  css::awt::Point aRet;
614 
615  aRet.X = aRect.X;
616  aRet.Y = aRect.Y;
617 
618  return aRet;
619  }
620 
621  virtual css::awt::Point SAL_CALL getLocationOnScreen() override
622  {
623  SolarMutexGuard aGuard;
624  if (!m_pController)
625  throw css::uno::RuntimeException();
626 
627  css::awt::Point aScreenLoc(0, 0);
628 
629  if (weld::DrawingArea* pDrawingArea = m_pController->GetDrawingArea())
630  {
631  Point aPos = pDrawingArea->get_accessible_location_on_screen();
632  aScreenLoc.X = aPos.X();
633  aScreenLoc.Y = aPos.Y();
634  }
635 
636  return aScreenLoc;
637  }
638 
639  virtual css::awt::Size SAL_CALL getSize() override
640  {
641  SolarMutexGuard aGuard;
642  if (!m_pController)
643  throw css::uno::RuntimeException();
644 
645  Size aSz(m_pController->GetOutputSizePixel());
646  return css::awt::Size(aSz.Width(), aSz.Height());
647  }
648 
649  virtual void SAL_CALL grabFocus() override { m_pController->GrabFocus(); }
650 
651  virtual sal_Int32 SAL_CALL getForeground() override
652  {
653  SolarMutexGuard aGuard;
654  if (!m_pController)
655  throw css::uno::RuntimeException();
656 
657  Color nCol = m_pEditEngine->GetAutoColor();
658  return static_cast<sal_Int32>(nCol);
659  }
660 
661  virtual sal_Int32 SAL_CALL getBackground() override
662  {
663  SolarMutexGuard aGuard;
664  if (!m_pController)
665  throw css::uno::RuntimeException();
666 
667  Color nCol = m_pEditEngine->GetBackgroundColor();
668  return static_cast<sal_Int32>(nCol);
669  }
670 
671  // XAccessibleContext
672  virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
673  {
674  if (m_xTextHelper)
675  return m_xTextHelper->GetChildCount();
676  return 0;
677  }
678 
679  virtual css::uno::Reference<css::accessibility::XAccessible>
680  SAL_CALL getAccessibleChild(sal_Int32 i) override
681  {
682  if (m_xTextHelper)
683  return m_xTextHelper->GetChild(i);
684  throw css::lang::IndexOutOfBoundsException(); // there is no child...
685  }
686 
687  virtual css::uno::Reference<css::accessibility::XAccessible>
688  SAL_CALL getAccessibleParent() override
689  {
690  SolarMutexGuard aGuard;
691  if (!m_pController)
692  throw css::uno::RuntimeException();
693 
694  return m_pController->GetDrawingArea()->get_accessible_parent();
695  }
696 
697  virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
698  {
699  SolarMutexGuard aGuard;
700  if (!m_pController)
701  throw css::uno::RuntimeException();
702 
703  // -1 for child not found/no parent (according to specification)
704  sal_Int32 nRet = -1;
705 
706  css::uno::Reference<css::accessibility::XAccessible> xParent(getAccessibleParent());
707  if (!xParent)
708  return nRet;
709 
710  try
711  {
712  css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext(
713  xParent->getAccessibleContext());
714 
715  // iterate over parent's children and search for this object
716  if (xParentContext.is())
717  {
718  sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
719  for (sal_Int32 nChild = 0; (nChild < nChildCount) && (-1 == nRet); ++nChild)
720  {
721  css::uno::Reference<css::accessibility::XAccessible> xChild(
722  xParentContext->getAccessibleChild(nChild));
723  if (xChild.get() == this)
724  nRet = nChild;
725  }
726  }
727  }
728  catch (const css::uno::Exception&)
729  {
730  TOOLS_WARN_EXCEPTION("svx", "WeldEditAccessible::getAccessibleIndexInParent");
731  }
732 
733  return nRet;
734  }
735 
736  virtual sal_Int16 SAL_CALL getAccessibleRole() override
737  {
738  return css::accessibility::AccessibleRole::TEXT_FRAME;
739  }
740 
741  virtual OUString SAL_CALL getAccessibleDescription() override
742  {
743  SolarMutexGuard aGuard;
744 
745  OUString aRet;
746 
747  if (m_pController)
748  {
749  aRet = m_pController->GetAccessibleDescription();
750  }
751 
752  return aRet;
753  }
754 
755  virtual OUString SAL_CALL getAccessibleName() override
756  {
757  SolarMutexGuard aGuard;
758 
759  OUString aRet;
760 
761  if (m_pController)
762  {
763  aRet = m_pController->GetAccessibleName();
764  }
765 
766  return aRet;
767  }
768 
769  virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet>
770  SAL_CALL getAccessibleRelationSet() override
771  {
772  SolarMutexGuard aGuard;
773  if (!m_pController)
774  throw css::uno::RuntimeException();
775 
776  return m_pController->GetDrawingArea()->get_accessible_relation_set();
777  }
778 
779  virtual css::uno::Reference<css::accessibility::XAccessibleStateSet>
780  SAL_CALL getAccessibleStateSet() override
781  {
782  SolarMutexGuard aGuard;
784  = new ::utl::AccessibleStateSetHelper;
785 
786  if (!m_pController || !m_xTextHelper)
787  pStateSet->AddState(css::accessibility::AccessibleStateType::DEFUNC);
788  else
789  {
790  pStateSet->AddState(css::accessibility::AccessibleStateType::MULTI_LINE);
791  pStateSet->AddState(css::accessibility::AccessibleStateType::ENABLED);
792  pStateSet->AddState(css::accessibility::AccessibleStateType::EDITABLE);
793  pStateSet->AddState(css::accessibility::AccessibleStateType::FOCUSABLE);
794  pStateSet->AddState(css::accessibility::AccessibleStateType::SELECTABLE);
795  if (m_pController->HasFocus())
796  pStateSet->AddState(css::accessibility::AccessibleStateType::FOCUSED);
797  if (m_pController->IsActive())
798  pStateSet->AddState(css::accessibility::AccessibleStateType::ACTIVE);
799  if (m_pController->IsVisible())
800  pStateSet->AddState(css::accessibility::AccessibleStateType::SHOWING);
801  if (m_pController->IsReallyVisible())
802  pStateSet->AddState(css::accessibility::AccessibleStateType::VISIBLE);
803  if (COL_TRANSPARENT != m_pEditEngine->GetBackgroundColor())
804  pStateSet->AddState(css::accessibility::AccessibleStateType::OPAQUE);
805  }
806 
807  return pStateSet;
808  }
809 
810  virtual css::lang::Locale SAL_CALL getLocale() override
811  {
812  SolarMutexGuard aGuard;
813  return LanguageTag(m_pEditEngine->GetDefaultLanguage()).getLocale();
814  }
815 
816  // XAccessibleEventBroadcaster
817  virtual void SAL_CALL addAccessibleEventListener(
818  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& rListener) override
819  {
820  if (!m_xTextHelper) // not disposing (about to destroy view shell)
821  return;
822  m_xTextHelper->AddEventListener(rListener);
823  }
824 
825  virtual void SAL_CALL removeAccessibleEventListener(
826  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& rListener) override
827  {
828  if (!m_xTextHelper) // not disposing (about to destroy view shell)
829  return;
830  m_xTextHelper->RemoveEventListener(rListener);
831  }
832 
833  virtual OUString SAL_CALL getImplementationName() override { return "WeldEditAccessible"; }
834 
835  virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override
836  {
837  return cppu::supportsService(this, rServiceName);
838  }
839 
840  virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
841  {
842  return { "css::accessibility::Accessible", "css::accessibility::AccessibleComponent",
843  "css::accessibility::AccessibleContext" };
844  }
845 };
846 
847 css::uno::Reference<css::accessibility::XAccessible> WeldEditView::CreateAccessible()
848 {
849  if (!m_xAccessible.is())
850  m_xAccessible.set(new WeldEditAccessible(this));
851  return m_xAccessible;
852 }
853 
855 {
856  if (m_xAccessible.is())
857  {
858  m_xAccessible->ClearWin(); // make Accessible nonfunctional
859  m_xAccessible.clear();
860  }
861 }
862 
863 bool WeldViewForwarder::IsValid() const { return m_rEditAcc.GetEditView() != nullptr; }
864 
865 Point WeldViewForwarder::LogicToPixel(const Point& rPoint, const MapMode& rMapMode) const
866 {
867  EditView* pEditView = m_rEditAcc.GetEditView();
868  if (!pEditView)
869  return Point();
870  OutputDevice& rOutDev = pEditView->GetOutputDevice();
871  MapMode aMapMode(rOutDev.GetMapMode());
872  Point aPoint(OutputDevice::LogicToLogic(rPoint, rMapMode, MapMode(aMapMode.GetMapUnit())));
873  aMapMode.SetOrigin(Point());
874  return rOutDev.LogicToPixel(aPoint, aMapMode);
875 }
876 
877 Point WeldViewForwarder::PixelToLogic(const Point& rPoint, const MapMode& rMapMode) const
878 {
879  EditView* pEditView = m_rEditAcc.GetEditView();
880  if (!pEditView)
881  return Point();
882  OutputDevice& rOutDev = pEditView->GetOutputDevice();
883  MapMode aMapMode(rOutDev.GetMapMode());
884  aMapMode.SetOrigin(Point());
885  Point aPoint(rOutDev.PixelToLogic(rPoint, aMapMode));
886  return OutputDevice::LogicToLogic(aPoint, MapMode(aMapMode.GetMapUnit()), rMapMode);
887 }
888 
889 WeldTextForwarder::WeldTextForwarder(WeldEditAccessible& rAcc, WeldEditSource& rSource)
890  : m_rEditAcc(rAcc)
891  , m_rEditSource(rSource)
892 {
893  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
894  if (pEditEngine)
895  pEditEngine->SetNotifyHdl(LINK(this, WeldTextForwarder, NotifyHdl));
896 }
897 
898 WeldTextForwarder::~WeldTextForwarder()
899 {
900  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
901  if (pEditEngine)
902  pEditEngine->SetNotifyHdl(Link<EENotify&, void>());
903 }
904 
905 IMPL_LINK(WeldTextForwarder, NotifyHdl, EENotify&, rNotify, void)
906 {
907  if (EditEngine* pEditEngine = m_rEditAcc.GetEditEngine())
908  {
909  if (rNotify.eNotificationType == EE_NOTIFY_PROCESSNOTIFICATIONS
910  && !pEditEngine->IsUpdateLayout())
911  {
912  // tdf#143088 an UpdateMode of false will just to on to cause
913  // AccessibleTextHelper_Impl::GetTextForwarder to throw an
914  // exception as a Frozen EditEngine is considered Invalid so return
915  // early instead
916  return;
917  }
918  }
919 
920  ::std::unique_ptr<SfxHint> aHint = SvxEditSourceHelper::EENotification2Hint(&rNotify);
921  if (aHint)
922  m_rEditSource.GetBroadcaster().Broadcast(*aHint);
923 }
924 
925 sal_Int32 WeldTextForwarder::GetParagraphCount() const
926 {
927  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
928  return pEditEngine ? pEditEngine->GetParagraphCount() : 0;
929 }
930 
931 sal_Int32 WeldTextForwarder::GetTextLen(sal_Int32 nParagraph) const
932 {
933  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
934  return pEditEngine ? pEditEngine->GetTextLen(nParagraph) : 0;
935 }
936 
937 OUString WeldTextForwarder::GetText(const ESelection& rSel) const
938 {
939  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
940  OUString aRet;
941  if (pEditEngine)
942  aRet = pEditEngine->GetText(rSel);
943  return convertLineEnd(aRet, GetSystemLineEnd());
944 }
945 
946 SfxItemSet WeldTextForwarder::GetAttribs(const ESelection& rSel,
947  EditEngineAttribs nOnlyHardAttrib) const
948 {
949  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
950  assert(pEditEngine && "EditEngine missing");
951  if (rSel.nStartPara == rSel.nEndPara)
952  {
953  GetAttribsFlags nFlags = GetAttribsFlags::NONE;
954  switch (nOnlyHardAttrib)
955  {
956  case EditEngineAttribs::All:
957  nFlags = GetAttribsFlags::ALL;
958  break;
959  case EditEngineAttribs::OnlyHard:
960  nFlags = GetAttribsFlags::CHARATTRIBS;
961  break;
962  default:
963  SAL_WARN("svx", "unknown flags for WeldTextForwarder::GetAttribs");
964  }
965 
966  return pEditEngine->GetAttribs(rSel.nStartPara, rSel.nStartPos, rSel.nEndPos, nFlags);
967  }
968  else
969  {
970  return pEditEngine->GetAttribs(rSel, nOnlyHardAttrib);
971  }
972 }
973 
974 SfxItemSet WeldTextForwarder::GetParaAttribs(sal_Int32 nPara) const
975 {
976  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
977  assert(pEditEngine && "EditEngine missing");
978 
979  SfxItemSet aSet(pEditEngine->GetParaAttribs(nPara));
980 
981  sal_uInt16 nWhich = EE_PARA_START;
982  while (nWhich <= EE_PARA_END)
983  {
984  if (aSet.GetItemState(nWhich) != SfxItemState::SET)
985  {
986  if (pEditEngine->HasParaAttrib(nPara, nWhich))
987  aSet.Put(pEditEngine->GetParaAttrib(nPara, nWhich));
988  }
989  nWhich++;
990  }
991 
992  return aSet;
993 }
994 
995 void WeldTextForwarder::SetParaAttribs(sal_Int32 nPara, const SfxItemSet& rSet)
996 {
997  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
998  if (pEditEngine)
999  pEditEngine->SetParaAttribs(nPara, rSet);
1000 }
1001 
1002 SfxItemPool* WeldTextForwarder::GetPool() const
1003 {
1004  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1005  return pEditEngine ? pEditEngine->GetEmptyItemSet().GetPool() : nullptr;
1006 }
1007 
1008 void WeldTextForwarder::RemoveAttribs(const ESelection& rSelection)
1009 {
1010  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1011  if (pEditEngine)
1012  pEditEngine->RemoveAttribs(rSelection, false /*bRemoveParaAttribs*/, 0);
1013 }
1014 
1015 void WeldTextForwarder::GetPortions(sal_Int32 nPara, std::vector<sal_Int32>& rList) const
1016 {
1017  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1018  if (pEditEngine)
1019  pEditEngine->GetPortions(nPara, rList);
1020 }
1021 
1022 void WeldTextForwarder::QuickInsertText(const OUString& rText, const ESelection& rSel)
1023 {
1024  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1025  if (pEditEngine)
1026  pEditEngine->QuickInsertText(rText, rSel);
1027 }
1028 
1029 void WeldTextForwarder::QuickInsertLineBreak(const ESelection& rSel)
1030 {
1031  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1032  if (pEditEngine)
1033  pEditEngine->QuickInsertLineBreak(rSel);
1034 }
1035 
1036 void WeldTextForwarder::QuickInsertField(const SvxFieldItem& rFld, const ESelection& rSel)
1037 {
1038  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1039  if (pEditEngine)
1040  pEditEngine->QuickInsertField(rFld, rSel);
1041 }
1042 
1043 void WeldTextForwarder::QuickSetAttribs(const SfxItemSet& rSet, const ESelection& rSel)
1044 {
1045  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1046  if (pEditEngine)
1047  pEditEngine->QuickSetAttribs(rSet, rSel);
1048 }
1049 
1050 bool WeldTextForwarder::IsValid() const
1051 {
1052  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1053  // cannot reliably query EditEngine state
1054  // while in the middle of an update
1055  return pEditEngine && pEditEngine->IsUpdateLayout();
1056 }
1057 
1058 OUString WeldTextForwarder::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara,
1059  sal_Int32 nPos, std::optional<Color>& rpTxtColor,
1060  std::optional<Color>& rpFldColor)
1061 {
1062  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1063  return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor)
1064  : OUString();
1065 }
1066 
1067 void WeldTextForwarder::FieldClicked(const SvxFieldItem&) {}
1068 
1069 static SfxItemState GetSvxEditEngineItemState(EditEngine const& rEditEngine, const ESelection& rSel,
1070  sal_uInt16 nWhich)
1071 {
1072  std::vector<EECharAttrib> aAttribs;
1073 
1074  const SfxPoolItem* pLastItem = nullptr;
1075 
1076  SfxItemState eState = SfxItemState::DEFAULT;
1077 
1078  // check all paragraphs inside the selection
1079  for (sal_Int32 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++)
1080  {
1081  SfxItemState eParaState = SfxItemState::DEFAULT;
1082 
1083  // calculate start and endpos for this paragraph
1084  sal_Int32 nPos = 0;
1085  if (rSel.nStartPara == nPara)
1086  nPos = rSel.nStartPos;
1087 
1088  sal_Int32 nEndPos = rSel.nEndPos;
1089  if (rSel.nEndPara != nPara)
1090  nEndPos = rEditEngine.GetTextLen(nPara);
1091 
1092  // get list of char attribs
1093  rEditEngine.GetCharAttribs(nPara, aAttribs);
1094 
1095  bool bEmpty = true; // we found no item inside the selection of this paragraph
1096  bool bGaps = false; // we found items but there are gaps between them
1097  sal_Int32 nLastEnd = nPos;
1098 
1099  const SfxPoolItem* pParaItem = nullptr;
1100 
1101  for (const auto& rAttrib : aAttribs)
1102  {
1103  OSL_ENSURE(rAttrib.pAttr, "GetCharAttribs gives corrupt data");
1104 
1105  const bool bEmptyPortion = (rAttrib.nStart == rAttrib.nEnd);
1106  if ((!bEmptyPortion && (rAttrib.nStart >= nEndPos))
1107  || (bEmptyPortion && (rAttrib.nStart > nEndPos)))
1108  break; // break if we are already behind our selection
1109 
1110  if ((!bEmptyPortion && (rAttrib.nEnd <= nPos))
1111  || (bEmptyPortion && (rAttrib.nEnd < nPos)))
1112  continue; // or if the attribute ends before our selection
1113 
1114  if (rAttrib.pAttr->Which() != nWhich)
1115  continue; // skip if is not the searched item
1116 
1117  // if we already found an item
1118  if (pParaItem)
1119  {
1120  // ... and its different to this one than the state is don't care
1121  if (*pParaItem != *(rAttrib.pAttr))
1122  return SfxItemState::DONTCARE;
1123  }
1124  else
1125  {
1126  pParaItem = rAttrib.pAttr;
1127  }
1128 
1129  if (bEmpty)
1130  bEmpty = false;
1131 
1132  if (!bGaps && rAttrib.nStart > nLastEnd)
1133  bGaps = true;
1134 
1135  nLastEnd = rAttrib.nEnd;
1136  }
1137 
1138  if (!bEmpty && !bGaps && nLastEnd < (nEndPos - 1))
1139  bGaps = true;
1140  if (bEmpty)
1141  eParaState = SfxItemState::DEFAULT;
1142  else if (bGaps)
1143  eParaState = SfxItemState::DONTCARE;
1144  else
1145  eParaState = SfxItemState::SET;
1146 
1147  // if we already found an item check if we found the same
1148  if (pLastItem)
1149  {
1150  if ((pParaItem == nullptr) || (*pLastItem != *pParaItem))
1151  return SfxItemState::DONTCARE;
1152  }
1153  else
1154  {
1155  pLastItem = pParaItem;
1156  eState = eParaState;
1157  }
1158  }
1159 
1160  return eState;
1161 }
1162 
1163 SfxItemState WeldTextForwarder::GetItemState(const ESelection& rSel, sal_uInt16 nWhich) const
1164 {
1165  SfxItemState nState = SfxItemState::DISABLED;
1166  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1167  if (pEditEngine)
1168  nState = GetSvxEditEngineItemState(*pEditEngine, rSel, nWhich);
1169  return nState;
1170 }
1171 
1172 SfxItemState WeldTextForwarder::GetItemState(sal_Int32 nPara, sal_uInt16 nWhich) const
1173 {
1174  SfxItemState nState = SfxItemState::DISABLED;
1175  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1176  if (pEditEngine)
1177  {
1178  const SfxItemSet& rSet = pEditEngine->GetParaAttribs(nPara);
1179  nState = rSet.GetItemState(nWhich);
1180  }
1181  return nState;
1182 }
1183 
1184 LanguageType WeldTextForwarder::GetLanguage(sal_Int32 nPara, sal_Int32 nIndex) const
1185 {
1186  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1187  return pEditEngine ? pEditEngine->GetLanguage(nPara, nIndex) : LANGUAGE_NONE;
1188 }
1189 
1190 sal_Int32 WeldTextForwarder::GetFieldCount(sal_Int32 nPara) const
1191 {
1192  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1193  return pEditEngine ? pEditEngine->GetFieldCount(nPara) : 0;
1194 }
1195 
1196 EFieldInfo WeldTextForwarder::GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const
1197 {
1198  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1199  return pEditEngine ? pEditEngine->GetFieldInfo(nPara, nField) : EFieldInfo();
1200 }
1201 
1202 EBulletInfo WeldTextForwarder::GetBulletInfo(sal_Int32 /*nPara*/) const { return EBulletInfo(); }
1203 
1204 tools::Rectangle WeldTextForwarder::GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const
1205 {
1206  tools::Rectangle aRect(0, 0, 0, 0);
1207  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1208 
1209  if (pEditEngine)
1210  {
1211  // Handle virtual position one-past-the end of the string
1212  if (nIndex >= pEditEngine->GetTextLen(nPara))
1213  {
1214  if (nIndex)
1215  aRect = pEditEngine->GetCharacterBounds(EPosition(nPara, nIndex - 1));
1216 
1217  aRect.Move(aRect.Right() - aRect.Left(), 0);
1218  aRect.SetSize(Size(1, pEditEngine->GetTextHeight()));
1219  }
1220  else
1221  {
1222  aRect = pEditEngine->GetCharacterBounds(EPosition(nPara, nIndex));
1223  }
1224  }
1225  return aRect;
1226 }
1227 
1228 tools::Rectangle WeldTextForwarder::GetParaBounds(sal_Int32 nPara) const
1229 {
1230  tools::Rectangle aRect(0, 0, 0, 0);
1231  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1232 
1233  if (pEditEngine)
1234  {
1235  const Point aPnt = pEditEngine->GetDocPosTopLeft(nPara);
1236  const sal_Int32 nWidth = pEditEngine->CalcTextWidth();
1237  const sal_Int32 nHeight = pEditEngine->GetTextHeight(nPara);
1238  aRect = tools::Rectangle(aPnt.X(), aPnt.Y(), aPnt.X() + nWidth, aPnt.Y() + nHeight);
1239  }
1240 
1241  return aRect;
1242 }
1243 
1244 MapMode WeldTextForwarder::GetMapMode() const
1245 {
1246  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1247  return pEditEngine ? pEditEngine->GetRefMapMode() : MapMode(MapUnit::Map100thMM);
1248 }
1249 
1250 OutputDevice* WeldTextForwarder::GetRefDevice() const
1251 {
1252  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1253  return pEditEngine ? pEditEngine->GetRefDevice() : nullptr;
1254 }
1255 
1256 bool WeldTextForwarder::GetIndexAtPoint(const Point& rPos, sal_Int32& nPara,
1257  sal_Int32& nIndex) const
1258 {
1259  bool bRes = false;
1260  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1261  if (pEditEngine)
1262  {
1263  EPosition aDocPos = pEditEngine->FindDocPosition(rPos);
1264  nPara = aDocPos.nPara;
1265  nIndex = aDocPos.nIndex;
1266  bRes = true;
1267  }
1268  return bRes;
1269 }
1270 
1271 bool WeldTextForwarder::GetWordIndices(sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart,
1272  sal_Int32& nEnd) const
1273 {
1274  bool bRes = false;
1275  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1276  if (pEditEngine)
1277  {
1278  ESelection aRes = pEditEngine->GetWord(ESelection(nPara, nIndex, nPara, nIndex),
1279  css::i18n::WordType::DICTIONARY_WORD);
1280 
1281  if (aRes.nStartPara == nPara && aRes.nStartPara == aRes.nEndPara)
1282  {
1283  nStart = aRes.nStartPos;
1284  nEnd = aRes.nEndPos;
1285 
1286  bRes = true;
1287  }
1288  }
1289 
1290  return bRes;
1291 }
1292 
1293 bool WeldTextForwarder::GetAttributeRun(sal_Int32& nStartIndex, sal_Int32& nEndIndex,
1294  sal_Int32 nPara, sal_Int32 nIndex, bool bInCell) const
1295 {
1296  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1297  if (!pEditEngine)
1298  return false;
1299  SvxEditSourceHelper::GetAttributeRun(nStartIndex, nEndIndex, *pEditEngine, nPara, nIndex,
1300  bInCell);
1301  return true;
1302 }
1303 
1304 sal_Int32 WeldTextForwarder::GetLineCount(sal_Int32 nPara) const
1305 {
1306  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1307  return pEditEngine ? pEditEngine->GetLineCount(nPara) : 0;
1308 }
1309 
1310 sal_Int32 WeldTextForwarder::GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const
1311 {
1312  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1313  return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0;
1314 }
1315 
1316 void WeldTextForwarder::GetLineBoundaries(/*out*/ sal_Int32& rStart, /*out*/ sal_Int32& rEnd,
1317  sal_Int32 nPara, sal_Int32 nLine) const
1318 {
1319  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1320  if (pEditEngine)
1321  pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
1322  else
1323  rStart = rEnd = 0;
1324 }
1325 
1326 sal_Int32 WeldTextForwarder::GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const
1327 {
1328  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1329  return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0;
1330 }
1331 
1332 bool WeldTextForwarder::QuickFormatDoc(bool /*bFull*/)
1333 {
1334  bool bRes = false;
1335  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1336  if (pEditEngine)
1337  {
1338  pEditEngine->QuickFormatDoc();
1339  bRes = true;
1340  }
1341  return bRes;
1342 }
1343 
1344 sal_Int16 WeldTextForwarder::GetDepth(sal_Int32 /*nPara*/) const
1345 {
1346  // math has no outliner...
1347  return -1;
1348 }
1349 
1350 bool WeldTextForwarder::SetDepth(sal_Int32 /*nPara*/, sal_Int16 nNewDepth)
1351 {
1352  // math has no outliner...
1353  return -1 == nNewDepth; // is it the value from 'GetDepth' ?
1354 }
1355 
1356 bool WeldTextForwarder::Delete(const ESelection& rSelection)
1357 {
1358  bool bRes = false;
1359  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1360  if (pEditEngine)
1361  {
1362  pEditEngine->QuickDelete(rSelection);
1363  pEditEngine->QuickFormatDoc();
1364  bRes = true;
1365  }
1366  return bRes;
1367 }
1368 
1369 bool WeldTextForwarder::InsertText(const OUString& rStr, const ESelection& rSelection)
1370 {
1371  bool bRes = false;
1372  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1373  if (pEditEngine)
1374  {
1375  pEditEngine->QuickInsertText(rStr, rSelection);
1376  pEditEngine->QuickFormatDoc();
1377  bRes = true;
1378  }
1379  return bRes;
1380 }
1381 
1382 const SfxItemSet* WeldTextForwarder::GetEmptyItemSetPtr()
1383 {
1384  const SfxItemSet* pItemSet = nullptr;
1385  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1386  if (pEditEngine)
1387  {
1388  pItemSet = &pEditEngine->GetEmptyItemSet();
1389  }
1390  return pItemSet;
1391 }
1392 
1393 void WeldTextForwarder::AppendParagraph()
1394 {
1395  // append an empty paragraph
1396  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1397  if (pEditEngine)
1398  {
1399  sal_Int32 nParaCount = pEditEngine->GetParagraphCount();
1400  pEditEngine->InsertParagraph(nParaCount, OUString());
1401  }
1402 }
1403 
1404 sal_Int32 WeldTextForwarder::AppendTextPortion(sal_Int32 nPara, const OUString& rText,
1405  const SfxItemSet& rSet)
1406 {
1407  sal_uInt16 nRes = 0;
1408  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1409  if (pEditEngine && nPara < pEditEngine->GetParagraphCount())
1410  {
1411  // append text
1412  ESelection aSel(nPara, pEditEngine->GetTextLen(nPara));
1413  pEditEngine->QuickInsertText(rText, aSel);
1414 
1415  // set attributes for new appended text
1416  nRes = aSel.nEndPos = pEditEngine->GetTextLen(nPara);
1417  pEditEngine->QuickSetAttribs(rSet, aSel);
1418  }
1419  return nRes;
1420 }
1421 
1422 void WeldTextForwarder::CopyText(const SvxTextForwarder& rSource)
1423 {
1424  const WeldTextForwarder* pSourceForwarder = dynamic_cast<const WeldTextForwarder*>(&rSource);
1425  if (!pSourceForwarder)
1426  return;
1427  EditEngine* pSourceEditEngine = pSourceForwarder->m_rEditAcc.GetEditEngine();
1428  EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
1429  if (pEditEngine && pSourceEditEngine)
1430  {
1431  std::unique_ptr<EditTextObject> pNewTextObject = pSourceEditEngine->CreateTextObject();
1432  pEditEngine->SetText(*pNewTextObject);
1433  }
1434 }
1435 
1436 WeldEditViewForwarder::WeldEditViewForwarder(WeldEditAccessible& rAcc)
1437  : m_rEditAcc(rAcc)
1438 {
1439 }
1440 
1441 bool WeldEditViewForwarder::IsValid() const { return m_rEditAcc.GetEditView() != nullptr; }
1442 
1443 Point WeldEditViewForwarder::LogicToPixel(const Point& rPoint, const MapMode& rMapMode) const
1444 {
1445  EditView* pEditView = m_rEditAcc.GetEditView();
1446  if (!pEditView)
1447  return Point();
1448  OutputDevice& rOutDev = pEditView->GetOutputDevice();
1449  MapMode aMapMode(rOutDev.GetMapMode());
1450  Point aPoint(OutputDevice::LogicToLogic(rPoint, rMapMode, MapMode(aMapMode.GetMapUnit())));
1451  aMapMode.SetOrigin(Point());
1452  return rOutDev.LogicToPixel(aPoint, aMapMode);
1453 }
1454 
1455 Point WeldEditViewForwarder::PixelToLogic(const Point& rPoint, const MapMode& rMapMode) const
1456 {
1457  EditView* pEditView = m_rEditAcc.GetEditView();
1458  if (!pEditView)
1459  return Point();
1460  OutputDevice& rOutDev = pEditView->GetOutputDevice();
1461  MapMode aMapMode(rOutDev.GetMapMode());
1462  aMapMode.SetOrigin(Point());
1463  Point aPoint(rOutDev.PixelToLogic(rPoint, aMapMode));
1464  return OutputDevice::LogicToLogic(aPoint, MapMode(aMapMode.GetMapUnit()), rMapMode);
1465 }
1466 
1467 bool WeldEditViewForwarder::GetSelection(ESelection& rSelection) const
1468 {
1469  bool bRes = false;
1470  EditView* pEditView = m_rEditAcc.GetEditView();
1471  if (pEditView)
1472  {
1473  rSelection = pEditView->GetSelection();
1474  bRes = true;
1475  }
1476  return bRes;
1477 }
1478 
1479 bool WeldEditViewForwarder::SetSelection(const ESelection& rSelection)
1480 {
1481  bool bRes = false;
1482  EditView* pEditView = m_rEditAcc.GetEditView();
1483  if (pEditView)
1484  {
1485  pEditView->SetSelection(rSelection);
1486  bRes = true;
1487  }
1488  return bRes;
1489 }
1490 
1491 bool WeldEditViewForwarder::Copy()
1492 {
1493  bool bRes = false;
1494  EditView* pEditView = m_rEditAcc.GetEditView();
1495  if (pEditView)
1496  {
1497  pEditView->Copy();
1498  bRes = true;
1499  }
1500  return bRes;
1501 }
1502 
1503 bool WeldEditViewForwarder::Cut()
1504 {
1505  bool bRes = false;
1506  EditView* pEditView = m_rEditAcc.GetEditView();
1507  if (pEditView)
1508  {
1509  pEditView->Cut();
1510  bRes = true;
1511  }
1512  return bRes;
1513 }
1514 
1515 bool WeldEditViewForwarder::Paste()
1516 {
1517  bool bRes = false;
1518  EditView* pEditView = m_rEditAcc.GetEditView();
1519  if (pEditView)
1520  {
1521  pEditView->Paste();
1522  bRes = true;
1523  }
1524  return bRes;
1525 }
1526 
1528 {
1529  Size aSize(pDrawingArea->get_size_request());
1530  if (aSize.Width() == -1)
1531  aSize.setWidth(500);
1532  if (aSize.Height() == -1)
1533  aSize.setHeight(100);
1534  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
1535 
1536  SetOutputSizePixel(aSize);
1537 
1539 
1540  EnableRTL(false);
1541 
1542  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1543  Color aBgColor = rStyleSettings.GetWindowColor();
1544 
1545  OutputDevice& rDevice = pDrawingArea->get_ref_device();
1546 
1547  rDevice.SetMapMode(MapMode(MapUnit::MapTwip));
1548  rDevice.SetBackground(aBgColor);
1549 
1550  Size aOutputSize(rDevice.PixelToLogic(aSize));
1551  aSize = aOutputSize;
1552  aSize.setHeight(aSize.Height());
1553 
1554  makeEditEngine();
1555  m_xEditEngine->SetPaperSize(aSize);
1556  m_xEditEngine->SetRefDevice(&rDevice);
1557 
1558  m_xEditEngine->SetControlWord(m_xEditEngine->GetControlWord() | EEControlBits::MARKFIELDS);
1559 
1560  m_xEditView.reset(new EditView(m_xEditEngine.get(), nullptr));
1561  m_xEditView->setEditViewCallbacks(this);
1562  m_xEditView->SetOutputArea(tools::Rectangle(Point(0, 0), aOutputSize));
1563 
1564  m_xEditView->SetBackgroundColor(aBgColor);
1565  m_xEditEngine->InsertView(m_xEditView.get());
1566 
1567  pDrawingArea->set_cursor(PointerStyle::Text);
1568 
1569  InitAccessible();
1570 }
1571 
1573 {
1574  if (m_xAccessible.is())
1576 }
1577 
1578 int WeldEditView::GetSurroundingText(OUString& rSurrounding)
1579 {
1580  EditView* pEditView = GetEditView();
1581  if (!pEditView)
1582  return -1;
1583  rSurrounding = pEditView->GetSurroundingText();
1584  return pEditView->GetSurroundingTextSelection().Min();
1585 }
1586 
1588 {
1589  EditView* pEditView = GetEditView();
1590  if (!pEditView)
1591  return false;
1592  return pEditView->DeleteSurroundingText(rRange);
1593 }
1594 
1596 {
1597  EditView* pEditView = GetEditView();
1598  if (pEditView)
1599  {
1600  pEditView->ShowCursor(false);
1601  Invalidate(); // redraw with cursor
1602  }
1603 
1605 
1606  if (m_xAccessible.is())
1607  {
1608  // Note: will implicitly send the AccessibleStateType::FOCUSED event
1609  ::accessibility::AccessibleTextHelper* pHelper = m_xAccessible->GetTextHelper();
1610  if (pHelper)
1611  pHelper->SetFocus();
1612  }
1613 }
1614 
1616 {
1618  Invalidate(); // redraw without cursor
1619 
1620  if (m_xAccessible.is())
1621  {
1622  // Note: will implicitly send the AccessibleStateType::FOCUSED event
1623  ::accessibility::AccessibleTextHelper* pHelper = m_xAccessible->GetTextHelper();
1624  if (pHelper)
1625  pHelper->SetFocus(false);
1626  }
1627 }
1628 
1629 bool WeldEditView::CanFocus() const { return true; }
1630 
1631 css::uno::Reference<css::datatransfer::dnd::XDropTarget> WeldEditView::GetDropTarget()
1632 {
1633  if (!m_xDropTarget)
1635  return m_xDropTarget;
1636 }
1637 
1638 css::uno::Reference<css::datatransfer::clipboard::XClipboard> WeldEditView::GetClipboard() const
1639 {
1641 }
1642 
1643 namespace
1644 {
1645 class WeldEditViewUIObject final : public DrawingAreaUIObject
1646 {
1647 private:
1648  WeldEditView* mpEditView;
1649 
1650 public:
1651  WeldEditViewUIObject(const VclPtr<vcl::Window>& rDrawingArea)
1652  : DrawingAreaUIObject(rDrawingArea)
1653  , mpEditView(static_cast<WeldEditView*>(mpController))
1654  {
1655  }
1656 
1657  static std::unique_ptr<UIObject> create(vcl::Window* pWindow)
1658  {
1659  return std::unique_ptr<UIObject>(new WeldEditViewUIObject(pWindow));
1660  }
1661 
1662  virtual StringMap get_state() override
1663  {
1665  aMap["Text"] = mpEditView->GetText();
1666  return aMap;
1667  }
1668 
1669 private:
1670  virtual OUString get_name() const override { return "WeldEditViewUIObject"; }
1671 };
1672 }
1673 
1674 FactoryFunction WeldEditView::GetUITestFactory() const { return WeldEditViewUIObject::create; }
1675 
1676 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetClipRegion()
OUString GetText() const
void QuickInsertLineBreak(const ESelection &rSel)
virtual Point get_pointer_position() const =0
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define LANGUAGE_NONE
OUString GetText(LineEnd eEnd=LINEEND_LF) const
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
OutputDevice & GetOutputDevice() const
sal_Int32 nStartPara
virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const =0
virtual css::awt::Point SAL_CALL getLocation() override
Color GetAutoColor() const
virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const =0
virtual bool IsValid() const =0
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
OUString GetWord(sal_Int32 nPara, sal_Int32 nIndex)
void DrawToDevice(OutputDevice &rRenderContext)
virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override
virtual OUString SAL_CALL getAccessibleName() override
const OUString & GetFamilyName() const
virtual std::unique_ptr< SvxEditSource > Clone() const =0
virtual void FieldClicked(const SvxFieldItem &rField)=0
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor)
void Cut()
virtual void Resize() override
void setWidth(tools::Long nWidth)
virtual a11yref get_accessible_parent()=0
bool Command(const CommandEvent &rCEvt)
Helper class for objects containing EditEngine/Outliner text.
const SfxItemSet & GetEmptyItemSet() const
virtual void AppendParagraph()=0
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
MapMode const & GetRefMapMode() const
virtual SvxEditViewForwarder * GetEditViewForwarder(bool bCreate=false)
virtual void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)=0
virtual SfxItemState GetItemState(const ESelection &rSel, sal_uInt16 nWhich) const =0
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const
virtual sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const =0
virtual bool GetSelection(ESelection &rSelection) const =0
static SfxItemState GetSvxEditEngineItemState(EditEngine const &rEditEngine, const ESelection &rSel, sal_uInt16 nWhich)
virtual bool Paste()=0
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
static::std::unique_ptr< SfxHint > EENotification2Hint(EENotify const *aNotify)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
OUString GetAccessibleDescription() const
constexpr sal_uInt16 KEY_A
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
LanguageType GetDefaultLanguage() const
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
SvxTableController * mpController
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
void InitAccessible()
sal_Int32 GetLineCount(sal_Int32 nParagraph) const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void QuickInsertLineBreak(const ESelection &rSel)=0
bool HasSelection() const
virtual bool DeleteSurroundingText(const Selection &rRange) override
const MapMode & GetMapMode() const
sal_uInt16 GetCode() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual bool Copy()=0
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
bool MouseButtonUp(const MouseEvent &rMouseEvent)
Selection GetSurroundingTextSelection() const
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
OUString GetSurroundingText() const
void DoPaint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
IMPL_LINK(WeldTextForwarder, NotifyHdl, EENotify &, rNotify, void)
virtual a11yrelationset get_accessible_relation_set()=0
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
LanguageType GetLanguage(const EditPaM &rPaM) const
void SetText(const OUString &rStr)
void SetMapMode()
EditEngineAttribs
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
virtual OUString get_name() const
std::unique_ptr<::accessibility::AccessibleTextHelper > m_xTextHelper
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
std::unique_ptr< BaseProcessor2D > createProcessor2DFromOutputDevice(OutputDevice &rTargetOutDev, const drawinglayer::geometry::ViewInformation2D &rViewInformation2D)
Size const & GetOutputSizePixel() const
EditEngine * m_pEditEngine
FontFamily GetFamilyType()
tools::Long GetFontHeight() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
std::map< OUString, OUString > StringMap
virtual void EditViewScrollStateChange()
virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const override
GetAttribsFlags
SvxEditSource & operator=(SvxEditSource const &)=default
bool HasParaAttrib(sal_Int32 nPara, sal_uInt16 nWhich) const
constexpr tools::Long Width() const
HashMap_OWString_Interface aMap
Color const & GetBackgroundColor() const
static rtl::Reference< SfxItemPool > CreatePool()
virtual sal_Int16 SAL_CALL getAccessibleRole() override
WeldEditAccessible(weld::CustomWidgetController *pController)
virtual EditEngine * GetEditEngine() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
::accessibility::AccessibleTextHelper * GetTextHelper()
void SetBackground()
void Copy()
virtual sal_Int32 AppendTextPortion(sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet)=0
virtual bool InsertText(const OUString &rText, const ESelection &rSel)=0
virtual StringMap get_state() override
void SetText(const OUString &rStr)
tools::Rectangle GetCharacterBounds(const EPosition &rPos) const
virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth)=0
virtual bool Cut()=0
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const =0
LineEnd GetSystemLineEnd()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
EPosition FindDocPosition(const Point &rDocPos) const
virtual bool QuickFormatDoc(bool bFull=false)=0
virtual void CopyText(const SvxTextForwarder &rSource)=0
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
weld::CustomWidgetController * m_pController
virtual OutputDevice & get_ref_device()=0
sal_Int32 nEndPos
sal_Int32 GetTextLen() const
virtual sal_Int32 SAL_CALL getForeground() override
void SetNotifyHdl(const Link< EENotify &, void > &rLink)
virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const =0
virtual FactoryFunction GetUITestFactory() const override
void QuickFormatDoc(bool bFull=false)
virtual LanguageType GetLanguage(sal_Int32 nPara, sal_Int32 nIndex) const =0
virtual void GetLineBoundaries(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine) const =0
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
virtual void set_cursor(PointerStyle ePointerStyle)=0
sal_Int32 nEndPara
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet)=0
virtual SfxBroadcaster & GetBroadcaster() const
virtual OutputDevice * GetRefDevice() const =0
void GetCharAttribs(sal_Int32 nPara, std::vector< EECharAttrib > &rLst) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Point GetDocPosTopLeft(sal_Int32 nParagraph)
sal_Int32 nIndex
virtual Size get_size_request() const =0
sal_Int32 GetLineLen(sal_Int32 nParagraph, sal_Int32 nLine) const
constexpr sal_uInt16 EE_PARA_START(EE_ITEMS_START+0)
bool DeleteSurroundingText(const Selection &rRange)
virtual OUString SAL_CALL getImplementationName() override
OUString GetAccessibleName() const
sal_Int32 nPara
bool MouseMove(const MouseEvent &rMouseEvent)
virtual MapMode GetMapMode() const =0
virtual SfxItemPool * GetPool() const =0
EditView * m_pEditView
virtual sal_Int16 GetDepth(sal_Int32 nPara) const =0
std::unique_ptr< EditTextObject > CreateTextObject()
virtual css::lang::Locale SAL_CALL getLocale() override
unsigned char sal_Bool
virtual SvxTextForwarder * GetTextForwarder()=0
virtual bool GetAttributeRun(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell=false) const =0
virtual bool MouseMove(const MouseEvent &rMEvt) override
void GetLineBoundaries(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine) const
virtual SvxViewForwarder * GetViewForwarder()
PITCH_DONTKNOW
std::unique_ptr< EditView > m_xEditView
virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const =0
virtual void GetFocus() override
virtual css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget() override
virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const =0
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &rListener) override
SfxItemPool * GetPool() const
sal_uInt16 GetFieldCount(sal_Int32 nPara) const
void SetOutputSizePixel(const Size &rSize)
constexpr void SetTop(tools::Long v)
virtual css::awt::Rectangle SAL_CALL getBounds() override
const long LONG_MAX
sal_Int32 GetParagraphCount() const
virtual Point LogicToPixel(const Point &rPoint, const MapMode &rMapMode) const =0
virtual sal_Int32 GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const =0
virtual EditView * GetEditView() const
virtual css::awt::Size SAL_CALL getSize() override
virtual Point PixelToLogic(const Point &rPoint, const MapMode &rMapMode) const =0
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)
static void GetAttributeRun(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex, const EditEngine &rEE, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell=false)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
virtual void SAL_CALL grabFocus() override
virtual int GetSurroundingText(OUString &rSurrounding) override
void Init(EditEngine *pEditEngine, EditView *pEditView)
void SetPaperSize(const Size &rSize)
void SetModifyHdl(const Link< LinkParamNone *, void > &rLink)
virtual sal_Int32 GetLineCount(sal_Int32 nPara) const =0
virtual bool KeyInput(const KeyEvent &rKEvt) override
const vcl::KeyCode & GetKeyCode() const
bool PostKeyEvent(const KeyEvent &rKeyEvent, vcl::Window const *pFrameWin=nullptr)
virtual bool GetWordIndices(sal_Int32 nPara, sal_Int32 nIndex, sal_Int32 &rStart, sal_Int32 &rEnd) const =0
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
weld::DrawingArea * GetDrawingArea() const
SfxItemState
EE_NOTIFY_PROCESSNOTIFICATIONS
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
EditView * GetEditView()
constexpr tools::Long Height() const
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const
virtual ~WeldEditView() override
bool MouseButtonDown(const MouseEvent &rMouseEvent)
virtual void SAL_CALL removeAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &rListener) override
tools::Long Min() const
void InsertParagraph(sal_Int32 nPara, const EditTextObject &rTxtObj, const bool bAppend=false)
void RemoveAttribs(const ESelection &rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich)
virtual bool Delete(const ESelection &rSelection)=0
bool IsUpdateLayout() const
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList)
sal_uInt32 GetTextHeight() const
virtual bool GetIndexAtPoint(const Point &rPoint, sal_Int32 &rPara, sal_Int32 &rIndex) const =0
bool IsMod1() const
virtual void makeEditEngine()
virtual SfxItemSet GetAttribs(const ESelection &rSel, EditEngineAttribs nOnlyHardAttrib=EditEngineAttribs::All) const =0
virtual sal_Int32 SAL_CALL getBackground() override
virtual bool IsValid() const =0
void QuickDelete(const ESelection &rSel)
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
rtl::Reference< WeldEditAccessible > m_xAccessible
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const
virtual void RemoveAttribs(const ESelection &rSelection)=0
const Color & GetWindowColor() const
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const =0
OutputDevice * GetRefDevice() const
void SetSelection(const ESelection &rNewSel)
void setHeight(tools::Long nHeight)
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
virtual void QuickInsertText(const OUString &rText, const ESelection &rSel)=0
std::unique_ptr< EditEngine > m_xEditEngine
virtual void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList) const =0
virtual const SfxItemSet * GetEmptyItemSetPtr()=0
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual void LoseFocus() override
#define SAL_WARN(area, stream)
css::uno::Reference< css::datatransfer::dnd::XDropTarget > m_xDropTarget
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
bool GetAcceptsTab() const
ESelection GetSelection() const
void QuickInsertText(const OUString &rText, const ESelection &rSel)
sal_uInt32 CalcTextWidth()
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rpTxtColor, std::optional< Color > &rpFldColor)=0
virtual bool Command(const CommandEvent &rCEvt) override
void SetFocus(bool bHaveFocus=true)
Set the focus state of the accessibility object.
virtual void set_size_request(int nWidth, int nHeight)=0
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
virtual OUString SAL_CALL getAccessibleDescription() override
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &rPoint) override
virtual sal_Int32 GetParagraphCount() const =0
basegfx::B2DHomMatrix GetViewTransformation() const
virtual drawinglayer::primitive2d::Primitive2DContainer getOverlayObjectPrimitive2DSequence() const override
override to check conditions for last createOverlayObjectPrimitive2DSequence
const SfxPoolItem & GetParaAttrib(sal_Int32 nPara, sal_uInt16 nWhich) const
cppu::WeakImplHelper< css::lang::XServiceInfo, css::accessibility::XAccessible, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleContext, css::accessibility::XAccessibleEventBroadcaster > WeldEditAccessibleBaseClass
void Paste()
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
sal_Int32 nState
bool HasSelection() const
EditEngine * GetEditEngine()
virtual void UpdateData()=0
const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const
virtual bool SetSelection(const ESelection &rSelection)=0
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
virtual Point EditViewPointerPosPixel() const override
virtual bool CanFocus() const
constexpr sal_uInt16 KEY_TAB
virtual void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)=0
virtual OUString GetText(const ESelection &rSel) const =0
void EnableRTL(bool bEnable)
bool IsMod2() const
sal_Int32 nStartPos
::rtl::Reference< IEventProcessor > xProcessor