Coverage Report

Created: 2026-02-14 09:37

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