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