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