Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/uno/unotxvw.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 <memory>
21
#include <viscrs.hxx>
22
#include <o3tl/any.hxx>
23
#include <sfx2/printer.hxx>
24
#include <sfx2/viewfrm.hxx>
25
#include <cmdid.h>
26
#include <docsh.hxx>
27
#include <rubylist.hxx>
28
#include <doc.hxx>
29
#include <IDocumentDeviceAccess.hxx>
30
#include <unotxvw.hxx>
31
#include <unodispatch.hxx>
32
#include <unomap.hxx>
33
#include <unoprnms.hxx>
34
#include <view.hxx>
35
#include <viewopt.hxx>
36
#include <unomod.hxx>
37
#include <unoframe.hxx>
38
#include <unocrsr.hxx>
39
#include <wrtsh.hxx>
40
#include <unotbl.hxx>
41
#include <svx/fmshell.hxx>
42
#include <svx/svdview.hxx>
43
#include <svx/svdpage.hxx>
44
#include <svx/svdouno.hxx>
45
#include <editeng/pbinitem.hxx>
46
#include <pagedesc.hxx>
47
#include <editeng/lrspitem.hxx>
48
#include <editeng/ulspitem.hxx>
49
#include <sfx2/bindings.hxx>
50
#include <sfx2/request.hxx>
51
#include <frmatr.hxx>
52
#include <IMark.hxx>
53
#include <unodraw.hxx>
54
#include <svx/svdpagv.hxx>
55
#include <ndtxt.hxx>
56
#include <SwStyleNameMapper.hxx>
57
#include <com/sun/star/beans/PropertyAttribute.hpp>
58
#include <com/sun/star/drawing/ShapeCollection.hpp>
59
#include <editeng/outliner.hxx>
60
#include <editeng/editview.hxx>
61
#include <unoparagraph.hxx>
62
#include <unocrsrhelper.hxx>
63
#include <unotextrange.hxx>
64
#include <sfx2/docfile.hxx>
65
#include <swdtflvr.hxx>
66
#include <rootfrm.hxx>
67
#include <edtwin.hxx>
68
#include <vcl/svapp.hxx>
69
#include <comphelper/processfactory.hxx>
70
#include <comphelper/profilezone.hxx>
71
#include <comphelper/servicehelper.hxx>
72
#include <cppuhelper/supportsservice.hxx>
73
#include <cppuhelper/typeprovider.hxx>
74
#include <tools/UnitConversion.hxx>
75
#include <comphelper/dumpxmltostring.hxx>
76
#include <fmtanchr.hxx>
77
#include <names.hxx>
78
79
using namespace ::com::sun::star;
80
using namespace ::com::sun::star::uno;
81
using namespace ::com::sun::star::lang;
82
using namespace ::com::sun::star::beans;
83
using namespace ::com::sun::star::text;
84
using namespace ::com::sun::star::view;
85
using namespace ::com::sun::star::frame;
86
87
using ::com::sun::star::util::URL;
88
89
SwXTextView::SwXTextView(SwView* pSwView) :
90
3.67k
    SwXTextView_Base(pSwView),
91
3.67k
    m_SelChangedListeners(m_aMutex),
92
3.67k
    m_pView(pSwView),
93
3.67k
    m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) )
94
3.67k
{
95
96
3.67k
}
97
98
SwXTextView::~SwXTextView()
99
0
{
100
0
    Invalidate();
101
0
}
102
103
void SwXTextView::Invalidate()
104
7.35k
{
105
7.35k
    if(mxViewSettings.is())
106
3.67k
    {
107
3.67k
        mxViewSettings->Invalidate();
108
3.67k
        mxViewSettings.clear();
109
3.67k
    }
110
7.35k
    if(mxTextViewCursor.is())
111
0
    {
112
0
        mxTextViewCursor->Invalidate();
113
0
        mxTextViewCursor.clear();
114
0
    }
115
116
7.35k
    osl_atomic_increment(&m_refCount); //prevent second d'tor call
117
118
7.35k
    {
119
7.35k
        uno::Reference<uno::XInterface> const xInt(static_cast<
120
7.35k
                cppu::OWeakObject*>(static_cast<SfxBaseController*>(this)));
121
7.35k
        lang::EventObject aEvent(xInt);
122
7.35k
        m_SelChangedListeners.disposeAndClear(aEvent);
123
7.35k
    }
124
125
7.35k
    osl_atomic_decrement(&m_refCount);
126
7.35k
    m_pView = nullptr;
127
7.35k
}
128
129
sal_Bool SwXTextView::select(const uno::Any& aInterface)
130
0
{
131
0
    SolarMutexGuard aGuard;
132
133
0
    uno::Reference< uno::XInterface >  xInterface;
134
0
    if (!GetView() || !(aInterface >>= xInterface))
135
0
    {
136
0
        return false;
137
0
    }
138
139
0
    SwWrtShell& rSh = GetView()->GetWrtShell();
140
0
    SwDoc* pDoc = GetView()->GetDocShell()->GetDoc();
141
0
    std::vector<SdrObject *> sdrObjects;
142
0
    uno::Reference<awt::XControlModel> const xCtrlModel(xInterface,
143
0
            UNO_QUERY);
144
0
    if (xCtrlModel.is())
145
0
    {
146
0
        uno::Reference<awt::XControl> xControl;
147
0
        SdrObject *const pSdrObject = GetControl(xCtrlModel, xControl);
148
0
        if (pSdrObject) // hmm... needs view to verify it's in right doc...
149
0
        {
150
0
            sdrObjects.push_back(pSdrObject);
151
0
        }
152
0
    }
153
0
    else
154
0
    {
155
0
        std::optional<SwPaM> pPaM;
156
0
        std::pair<UIName, FlyCntType> frame;
157
0
        UIName tableName;
158
0
        SwUnoTableCursor const* pTableCursor(nullptr);
159
0
        ::sw::mark::MarkBase const* pMark(nullptr);
160
0
        SwUnoCursorHelper::GetSelectableFromAny(xInterface, *pDoc,
161
0
                pPaM, frame, tableName, pTableCursor, pMark, sdrObjects);
162
0
        if (pPaM)
163
0
        {
164
0
            rSh.EnterStdMode();
165
0
            rSh.SetSelection(*pPaM);
166
            // the pPaM has been copied - delete it
167
0
            while (pPaM->GetNext() != &*pPaM)
168
0
            {
169
                // coverity[deref_arg] - the SwPaM delete moves a new entry into GetNext()
170
0
                delete pPaM->GetNext();
171
0
            }
172
0
            pPaM.reset();
173
0
            return true;
174
0
        }
175
0
        else if (!frame.first.isEmpty())
176
0
        {
177
0
            bool const bSuccess(rSh.GotoFly(frame.first, frame.second));
178
0
            if (bSuccess)
179
0
            {
180
0
                rSh.HideCursor();
181
0
                rSh.EnterSelFrameMode();
182
0
            }
183
0
            return true;
184
0
        }
185
0
        else if (!tableName.isEmpty())
186
0
        {
187
0
            rSh.EnterStdMode();
188
0
            rSh.GotoTable(tableName);
189
0
            return true;
190
0
        }
191
0
        else if (pTableCursor)
192
0
        {
193
0
            UnoActionRemoveContext const aContext(*pTableCursor);
194
0
            rSh.EnterStdMode();
195
0
            rSh.SetSelection(*pTableCursor);
196
0
            return true;
197
0
        }
198
0
        else if (pMark)
199
0
        {
200
0
            rSh.EnterStdMode();
201
0
            rSh.GotoMark(pMark);
202
0
            return true;
203
0
        }
204
        // sdrObjects handled below
205
0
    }
206
0
    bool bRet(false);
207
0
    if (!sdrObjects.empty())
208
0
    {
209
210
0
        SdrView *const pDrawView = rSh.GetDrawView();
211
0
        SdrPageView *const pPV = pDrawView->GetSdrPageView();
212
213
0
        pDrawView->SdrEndTextEdit();
214
0
        pDrawView->UnmarkAll();
215
216
0
        for (SdrObject* pSdrObject : sdrObjects)
217
0
        {
218
            // GetSelectableFromAny did not check pSdrObject is in right doc!
219
0
            if (pPV && pSdrObject->getSdrPageFromSdrObject() == pPV->GetPage())
220
0
            {
221
0
                pDrawView->MarkObj(pSdrObject, pPV);
222
0
                bRet = true;
223
0
            }
224
0
        }
225
226
        // tdf#112696 if we selected every individual element of a group, then
227
        // select that group instead
228
0
        const SdrMarkList &rMrkList = pDrawView->GetMarkedObjectList();
229
0
        size_t nMarkCount = rMrkList.GetMarkCount();
230
0
        if (nMarkCount > 1)
231
0
        {
232
0
            SdrObject* pObject = rMrkList.GetMark(0)->GetMarkedSdrObj();
233
0
            SdrObject* pGroupParent = pObject->getParentSdrObjectFromSdrObject();
234
0
            for (size_t i = 1; i < nMarkCount; ++i)
235
0
            {
236
0
                pObject = rMrkList.GetMark(i)->GetMarkedSdrObj();
237
0
                SdrObject* pParent = pObject->getParentSdrObjectFromSdrObject();
238
0
                if (pParent != pGroupParent)
239
0
                {
240
0
                    pGroupParent = nullptr;
241
0
                    break;
242
0
                }
243
0
            }
244
245
0
            if (pGroupParent && pGroupParent->IsGroupObject() &&
246
0
                pGroupParent->getChildrenOfSdrObject()->GetObjCount() == nMarkCount)
247
0
            {
248
0
                pDrawView->UnmarkAll();
249
0
                pDrawView->MarkObj(pGroupParent, pPV);
250
0
            }
251
0
        }
252
0
    }
253
0
    return bRet;
254
0
}
255
256
uno::Any SwXTextView::getSelection()
257
0
{
258
0
    SolarMutexGuard aGuard;
259
0
    uno::Reference< uno::XInterface >  aRef;
260
0
    if(GetView())
261
0
    {
262
        //force immediate shell update
263
0
        m_pView->StopShellTimer();
264
        //Generating an interface from the current selection.
265
0
        SwWrtShell& rSh = m_pView->GetWrtShell();
266
0
        ShellMode eSelMode = m_pView->GetShellMode();
267
0
        switch(eSelMode)
268
0
        {
269
0
            case ShellMode::TableText      :
270
0
            {
271
0
                if(rSh.GetTableCursor())
272
0
                {
273
0
                    OSL_ENSURE(rSh.GetTableFormat(), "not a table format?");
274
0
                    uno::Reference< text::XTextTableCursor >  xCursor = new SwXTextTableCursor(*rSh.GetTableFormat(),
275
0
                                                    rSh.GetTableCursor());
276
0
                    aRef.set(xCursor, uno::UNO_QUERY);
277
0
                    break;
278
0
                }
279
0
                [[fallthrough]];
280
                    // without a table selection the text will be delivered
281
0
            }
282
0
            case ShellMode::ListText       :
283
0
            case ShellMode::TableListText:
284
0
            case ShellMode::Text            :
285
0
            {
286
0
                rtl::Reference< SwXTextRanges > xPos = SwXTextRanges::Create(rSh.GetCursor());
287
0
                aRef.set(uno::Reference< container::XIndexAccess >(xPos), uno::UNO_QUERY);
288
0
            }
289
0
            break;
290
0
            case ShellMode::Frame           :
291
0
            {
292
0
                SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat();
293
0
                if (pFormat)
294
0
                {
295
0
                    aRef = cppu::getXWeak(SwXTextFrame::CreateXTextFrame(
296
0
                            pFormat->GetDoc(), pFormat).get());
297
0
                }
298
0
            }
299
0
            break;
300
0
            case ShellMode::Graphic         :
301
0
            {
302
0
                SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat();
303
0
                if (pFormat)
304
0
                {
305
0
                    aRef = cppu::getXWeak(SwXTextGraphicObject::CreateXTextGraphicObject(
306
0
                            pFormat->GetDoc(), pFormat).get());
307
0
                }
308
0
            }
309
0
            break;
310
0
            case ShellMode::Object          :
311
0
            {
312
0
                SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat();
313
0
                if (pFormat)
314
0
                {
315
0
                    aRef = cppu::getXWeak(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
316
0
                            pFormat->GetDoc(), pFormat).get());
317
0
                }
318
0
            }
319
0
            break;
320
0
            case ShellMode::Draw            :
321
0
            case ShellMode::DrawForm        :
322
0
            case ShellMode::DrawText        :
323
0
            case ShellMode::Bezier          :
324
0
            {
325
0
                uno::Reference< drawing::XShapes >  xShCol = drawing::ShapeCollection::create(
326
0
                        comphelper::getProcessComponentContext());
327
328
0
                const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList();
329
0
                for(size_t i = 0; i < rMarkList.GetMarkCount(); ++i)
330
0
                {
331
0
                    SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
332
0
                    uno::Reference<drawing::XShape> xShape = SwFmDrawPage::GetShape( pObj );
333
0
                    xShCol->add(xShape);
334
0
                }
335
0
                aRef.set(xShCol, uno::UNO_QUERY);
336
0
            }
337
0
            break;
338
0
            default:;//prevent warning
339
0
        }
340
0
    }
341
0
    uno::Any aRet(&aRef, cppu::UnoType<uno::XInterface>::get());
342
0
    return aRet;
343
0
}
344
345
void SwXTextView::addSelectionChangeListener(
346
                                    const uno::Reference< view::XSelectionChangeListener > & rxListener)
347
0
{
348
0
    SolarMutexGuard aGuard;
349
0
    m_SelChangedListeners.addInterface(rxListener);
350
0
}
351
352
void SwXTextView::removeSelectionChangeListener(
353
                                        const uno::Reference< view::XSelectionChangeListener > & rxListener)
354
0
{
355
0
    SolarMutexGuard aGuard;
356
0
    m_SelChangedListeners.removeInterface(rxListener);
357
0
}
358
359
SdrObject* SwXTextView::GetControl(
360
        const uno::Reference< awt::XControlModel > & xModel,
361
        uno::Reference< awt::XControl >& xToFill  )
362
0
{
363
0
    SwView* pView2 = GetView();
364
0
    FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : nullptr;
365
0
    SdrView* pDrawView = pView2 ? pView2->GetDrawView() : nullptr;
366
0
    vcl::Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : nullptr;
367
368
0
    OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" );
369
370
0
    SdrObject* pControl = nullptr;
371
0
    if ( pFormShell && pDrawView && pWindow )
372
0
        pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow->GetOutDev(), xToFill );
373
0
    return pControl;
374
0
}
375
376
uno::Reference< awt::XControl >  SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel)
377
0
{
378
0
    SolarMutexGuard aGuard;
379
0
    uno::Reference< awt::XControl >  xRet;
380
0
    GetControl(xModel, xRet);
381
0
    return xRet;
382
0
}
383
384
uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& Form )
385
0
{
386
0
    SolarMutexGuard aGuard;
387
388
0
    SwView* pView2 = GetView();
389
0
    FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : nullptr;
390
0
    SdrView* pDrawView = pView2 ? pView2->GetDrawView() : nullptr;
391
0
    vcl::Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : nullptr;
392
0
    OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" );
393
394
0
    uno::Reference< form::runtime::XFormController > xController;
395
0
    if ( pFormShell && pDrawView && pWindow )
396
0
        xController = FmFormShell::GetFormController( Form, *pDrawView, *pWindow->GetOutDev() );
397
0
    return xController;
398
0
}
399
400
sal_Bool SAL_CALL SwXTextView::isFormDesignMode(  )
401
0
{
402
0
    SolarMutexGuard aGuard;
403
0
    SwView* pView2 = GetView();
404
0
    FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : nullptr;
405
0
    return !pFormShell || pFormShell->IsDesignMode();
406
0
}
407
408
void SAL_CALL SwXTextView::setFormDesignMode( sal_Bool DesignMode )
409
0
{
410
0
    SolarMutexGuard aGuard;
411
0
    SwView* pView2 = GetView();
412
0
    FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : nullptr;
413
0
    if ( pFormShell )
414
0
        pFormShell->SetDesignMode( DesignMode );
415
0
}
416
417
uno::Reference< text::XTextViewCursor >  SwXTextView::getViewCursor()
418
0
{
419
0
    SolarMutexGuard aGuard;
420
0
    comphelper::ProfileZone aZone("getViewCursor");
421
0
    if(!GetView())
422
0
        throw uno::RuntimeException();
423
424
0
    if(!mxTextViewCursor.is())
425
0
    {
426
0
        mxTextViewCursor = new SwXTextViewCursor(GetView());
427
0
    }
428
0
    return mxTextViewCursor;
429
0
}
430
431
uno::Reference<text::XTextRange>
432
SwXTextView::createTextRangeByPixelPosition(const awt::Point& rPixelPosition)
433
0
{
434
0
    SolarMutexGuard aGuard;
435
436
0
    Point aPixelPoint(rPixelPosition.X, rPixelPosition.Y);
437
0
    if (!m_pView)
438
0
        throw RuntimeException();
439
440
0
    Point aLogicPoint = m_pView->GetEditWin().PixelToLogic(aPixelPoint);
441
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
442
0
    SwPosition aPosition(*rSh.GetCurrentShellCursor().GetPoint());
443
0
    rSh.GetLayout()->GetModelPositionForViewPoint(&aPosition, aLogicPoint);
444
445
0
    if (aPosition.GetNode().IsGrfNode())
446
0
    {
447
        // The point is closest to a graphic node, look up its format.
448
0
        const SwFrameFormat* pGraphicFormat = aPosition.GetNode().GetFlyFormat();
449
0
        if (pGraphicFormat)
450
0
        {
451
            // Get the anchor of this format.
452
0
            const SwFormatAnchor& rAnchor = pGraphicFormat->GetAnchor();
453
0
            const SwPosition* pAnchor = rAnchor.GetContentAnchor();
454
0
            if (pAnchor)
455
0
            {
456
0
                aPosition = *pAnchor;
457
0
            }
458
0
            else
459
0
            {
460
                // Page-anchored graphics have no anchor.
461
0
                return {};
462
0
            }
463
0
        }
464
0
    }
465
466
0
    rtl::Reference<SwXTextRange> xRet
467
0
        = SwXTextRange::CreateXTextRange(*rSh.GetDoc(), aPosition, /*pMark=*/nullptr);
468
469
0
    return xRet;
470
0
}
471
472
uno::Reference< beans::XPropertySet >  SwXTextView::getViewSettings()
473
3.67k
{
474
3.67k
    SolarMutexGuard aGuard;
475
3.67k
    if(!m_pView)
476
0
        throw uno::RuntimeException();
477
478
3.67k
    if(!mxViewSettings.is())
479
3.67k
    {
480
3.67k
        mxViewSettings = new SwXViewSettings( m_pView );
481
3.67k
    }
482
483
3.67k
    return mxViewSettings;
484
3.67k
}
485
486
Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ )
487
0
{
488
0
    SolarMutexGuard aGuard;
489
490
0
    if(!GetView())
491
0
        throw RuntimeException();
492
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
493
0
    ShellMode  eSelMode = m_pView->GetShellMode();
494
0
    if (eSelMode != ShellMode::ListText      &&
495
0
        eSelMode != ShellMode::TableListText &&
496
0
        eSelMode != ShellMode::TableText      &&
497
0
        eSelMode != ShellMode::Text           )
498
0
        return Sequence< Sequence< PropertyValue > > ();
499
500
0
    SwRubyList aList;
501
502
0
    const sal_uInt16 nCount = SwDoc::FillRubyList( *rSh.GetCursor(), aList );
503
0
    Sequence< Sequence< PropertyValue > > aRet(nCount);
504
0
    Sequence< PropertyValue >* pRet = aRet.getArray();
505
0
    ProgName aString;
506
0
    for(sal_uInt16 n = 0; n < nCount; n++)
507
0
    {
508
0
        const SwRubyListEntry* pEntry = aList[n].get();
509
510
0
        const OUString& rEntryText = pEntry->GetText();
511
0
        const SwFormatRuby& rAttr = pEntry->GetRubyAttr();
512
513
0
        pRet[n].realloc(6);
514
0
        PropertyValue* pValues = pRet[n].getArray();
515
0
        pValues[0].Name = UNO_NAME_RUBY_BASE_TEXT;
516
0
        pValues[0].Value <<= rEntryText;
517
0
        pValues[1].Name = UNO_NAME_RUBY_TEXT;
518
0
        pValues[1].Value <<= rAttr.GetText();
519
0
        pValues[2].Name = UNO_NAME_RUBY_CHAR_STYLE_NAME;
520
0
        SwStyleNameMapper::FillProgName(rAttr.GetCharFormatName(), aString, SwGetPoolIdFromName::ChrFmt );
521
0
        pValues[2].Value <<= aString.toString();
522
0
        pValues[3].Name = UNO_NAME_RUBY_ADJUST;
523
0
        pValues[3].Value <<= static_cast<sal_Int16>(rAttr.GetAdjustment());
524
0
        pValues[4].Name = UNO_NAME_RUBY_IS_ABOVE;
525
0
        pValues[4].Value <<= !rAttr.GetPosition();
526
0
        pValues[5].Name = UNO_NAME_RUBY_POSITION;
527
0
        pValues[5].Value <<= rAttr.GetPosition();
528
0
    }
529
0
    return aRet;
530
0
}
531
532
void SAL_CALL SwXTextView::setRubyList(
533
    const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ )
534
0
{
535
0
    SolarMutexGuard aGuard;
536
537
0
    if(!GetView() || !rRubyList.hasElements())
538
0
        throw RuntimeException();
539
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
540
0
    ShellMode eSelMode = m_pView->GetShellMode();
541
0
    if (eSelMode != ShellMode::ListText      &&
542
0
        eSelMode != ShellMode::TableListText &&
543
0
        eSelMode != ShellMode::TableText      &&
544
0
        eSelMode != ShellMode::Text           )
545
0
        throw RuntimeException();
546
547
0
    SwRubyList aList;
548
549
0
    for(const Sequence<PropertyValue>& rPropList : rRubyList)
550
0
    {
551
0
        std::unique_ptr<SwRubyListEntry> pEntry(new SwRubyListEntry);
552
0
        OUString sTmp;
553
0
        for(const PropertyValue& rProperty : rPropList)
554
0
        {
555
0
            if(rProperty.Name == UNO_NAME_RUBY_BASE_TEXT)
556
0
            {
557
0
                rProperty.Value >>= sTmp;
558
0
                pEntry->SetText(sTmp);
559
0
            }
560
0
            else if(rProperty.Name == UNO_NAME_RUBY_TEXT)
561
0
            {
562
0
                rProperty.Value >>= sTmp;
563
0
                pEntry->GetRubyAttr().SetText(sTmp);
564
0
            }
565
0
            else if(rProperty.Name == UNO_NAME_RUBY_CHAR_STYLE_NAME)
566
0
            {
567
0
                if(rProperty.Value >>= sTmp)
568
0
                {
569
0
                    UIName sName;
570
0
                    SwStyleNameMapper::FillUIName(ProgName(sTmp), sName, SwGetPoolIdFromName::ChrFmt );
571
0
                    const sal_uInt16 nPoolId = sName.isEmpty() ? 0
572
0
                        : SwStyleNameMapper::GetPoolIdFromUIName(sName,
573
0
                                SwGetPoolIdFromName::ChrFmt );
574
575
0
                    pEntry->GetRubyAttr().SetCharFormatName( sName );
576
0
                    pEntry->GetRubyAttr().SetCharFormatId( nPoolId );
577
0
                }
578
0
            }
579
0
            else if(rProperty.Name == UNO_NAME_RUBY_ADJUST)
580
0
            {
581
0
                sal_Int16 nTmp = 0;
582
0
                if(rProperty.Value >>= nTmp)
583
0
                    pEntry->GetRubyAttr().SetAdjustment(static_cast<css::text::RubyAdjust>(nTmp));
584
0
            }
585
0
            else if(rProperty.Name == UNO_NAME_RUBY_IS_ABOVE)
586
0
            {
587
0
                bool bValue = !rProperty.Value.hasValue() ||
588
0
                    *o3tl::doAccess<bool>(rProperty.Value);
589
0
                pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
590
0
            }
591
0
            else if(rProperty.Name == UNO_NAME_RUBY_POSITION)
592
0
            {
593
0
                sal_Int16 nTmp = 0;
594
0
                if(rProperty.Value >>= nTmp)
595
0
                    pEntry->GetRubyAttr().SetPosition( nTmp );
596
0
            }
597
0
        }
598
0
        aList.push_back(std::move(pEntry));
599
0
    }
600
0
    SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
601
0
    pDoc->SetRubyList( *rSh.GetCursor(), aList );
602
0
}
603
604
SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc()
605
0
{
606
0
    SwWrtShell& rOldSh = m_pView->GetWrtShell();
607
0
    SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess().getPrinter( false );
608
0
    rtl::Reference<SwDocShell> pDocSh = new SwDocShell(SfxObjectCreateMode::STANDARD);
609
0
    SfxObjectShellLock xDocSh(pDocSh.get());
610
0
    xDocSh->DoInitNew();
611
0
    SwDoc *const pTempDoc( pDocSh->GetDoc() );
612
    // #i103634#, #i112425#: do not expand numbering and fields on PDF export
613
0
    pTempDoc->SetClipBoard(true);
614
0
    rOldSh.FillPrtDoc(*pTempDoc,  pPrt);
615
0
    SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, SFX_INTERFACE_NONE );
616
0
    SwView* pDocView = static_cast<SwView*>( pDocFrame->GetViewShell() );
617
0
    pDocView->AttrChangedNotify(nullptr);//So that SelectShell is called.
618
0
    if (SwWrtShell* pSh = pDocView->GetWrtShellPtr())
619
0
    {
620
0
        IDocumentDeviceAccess& rIDDA = pSh->getIDocumentDeviceAccess();
621
0
        SfxPrinter* pTempPrinter = rIDDA.getPrinter( true );
622
623
0
        const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc());
624
625
0
        IDocumentDeviceAccess& rIDDA_old = rOldSh.getIDocumentDeviceAccess();
626
627
0
        if( rIDDA_old.getPrinter( false ) )
628
0
        {
629
0
            rIDDA.setJobsetup( *rIDDA_old.getJobsetup() );
630
            //#69563# if it isn't the same printer then the pointer has been invalidated!
631
0
            pTempPrinter = rIDDA.getPrinter( true );
632
0
        }
633
634
0
        pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
635
0
    }
636
637
0
    return xDocSh;
638
0
}
639
640
void SwXTextView::NotifySelChanged()
641
11.7k
{
642
11.7k
    OSL_ENSURE( m_pView, "view is missing" );
643
644
11.7k
    lang::EventObject const aEvent(getXWeak());
645
11.7k
    m_SelChangedListeners.notifyEach(
646
11.7k
            &view::XSelectionChangeListener::selectionChanged, aEvent);
647
11.7k
}
648
649
void SwXTextView::NotifyDBChanged()
650
0
{
651
0
    URL aURL;
652
0
    aURL.Complete = OUString::createFromAscii(SwXDispatch::GetDBChangeURL());
653
654
0
    m_SelChangedListeners.forEach(
655
0
        [&aURL] (const uno::Reference<XSelectionChangeListener>& xListener)
656
0
        {
657
0
            uno::Reference<XDispatch> xDispatch(xListener, UNO_QUERY);
658
0
            if (xDispatch)
659
0
                xDispatch->dispatch(aURL, {});
660
0
        });
661
0
}
662
663
uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo(  )
664
11.0k
{
665
11.0k
    SolarMutexGuard aGuard;
666
11.0k
    static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
667
11.0k
    return aRef;
668
11.0k
}
669
670
void SAL_CALL SwXTextView::setPropertyValue(
671
        const OUString& rPropertyName, const uno::Any& rValue )
672
0
{
673
0
    SolarMutexGuard aGuard;
674
675
0
    if (rPropertyName == "PDFExport_ShowChanges")
676
0
    {
677
        // hack used in PDF export code to turn off (or on) exporting showing tracked changes
678
        // logic is simplified from FN_REDLINE_SHOW path in SwView
679
0
        bool bShow = false;
680
0
        rValue >>= bShow;
681
0
        SwWrtShell& rSh = m_pView->GetWrtShell();
682
0
        rSh.StartAllAction();
683
0
        rSh.GetLayout()->SetHideRedlines(!bShow);
684
0
        rSh.EndAllAction();
685
0
        return;
686
0
    }
687
688
0
    const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
689
0
    if (!pEntry)
690
0
        throw UnknownPropertyException(rPropertyName);
691
0
    else if (pEntry->nFlags & PropertyAttribute::READONLY)
692
0
        throw PropertyVetoException();
693
0
    else
694
0
    {
695
0
        switch (pEntry->nWID)
696
0
        {
697
0
            case WID_IS_HIDE_SPELL_MARKS :
698
                // deprecated #i91949
699
0
            break;
700
0
            case WID_IS_CONSTANT_SPELLCHECK :
701
0
            {
702
0
                bool bVal = false;
703
0
                const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
704
0
                if (!pOpt || !(rValue >>= bVal))
705
0
                    throw RuntimeException();
706
0
                SwViewOption aNewOpt( *pOpt );
707
0
                if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK)
708
0
                    aNewOpt.SetOnlineSpell(bVal);
709
0
                m_pView->GetWrtShell().ApplyViewOptions( aNewOpt );
710
0
            }
711
0
            break;
712
0
            default :
713
0
                OSL_FAIL("unknown WID");
714
0
        }
715
0
    }
716
0
}
717
718
uno::Any SAL_CALL SwXTextView::getPropertyValue(
719
        const OUString& rPropertyName )
720
0
{
721
0
    SolarMutexGuard aGuard;
722
723
0
    Any aRet;
724
725
0
    if (rPropertyName == "PDFExport_ShowChanges")
726
0
    {
727
0
        const bool bShow = !m_pView->GetWrtShell().GetLayout()->IsHideRedlines();
728
0
        aRet <<= bShow;
729
0
        return aRet;
730
0
    }
731
732
0
    const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
733
0
    if (!pEntry)
734
0
        throw UnknownPropertyException(rPropertyName);
735
736
0
    sal_Int16 nWID = pEntry->nWID;
737
0
    switch (nWID)
738
0
    {
739
0
        case WID_PAGE_COUNT :
740
0
        case WID_LINE_COUNT :
741
0
        {
742
            // format document completely in order to get meaningful
743
            // values for page count and line count
744
0
            m_pView->GetWrtShell().CalcLayout();
745
746
0
            sal_Int32 nCount = -1;
747
0
            if (nWID == WID_PAGE_COUNT)
748
0
                nCount = m_pView->GetWrtShell().GetPageCount();
749
0
            else // WID_LINE_COUNT
750
0
                nCount = m_pView->GetWrtShell().GetLineCount();
751
0
            aRet <<= nCount;
752
0
        }
753
0
        break;
754
0
        case WID_IS_HIDE_SPELL_MARKS :
755
            // deprecated #i91949
756
0
        break;
757
0
        case WID_IS_CONSTANT_SPELLCHECK :
758
0
        {
759
0
            const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
760
0
            if (!pOpt)
761
0
                throw RuntimeException();
762
0
            aRet <<= pOpt->IsOnlineSpell();
763
0
        }
764
0
        break;
765
0
        default :
766
0
            OSL_FAIL("unknown WID");
767
0
    }
768
769
0
    return aRet;
770
0
}
771
772
void SAL_CALL SwXTextView::addPropertyChangeListener(
773
        const OUString& /*rPropertyName*/,
774
        const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
775
0
{
776
0
    OSL_FAIL("not implemented");
777
0
}
778
779
void SAL_CALL SwXTextView::removePropertyChangeListener(
780
        const OUString& /*rPropertyName*/,
781
        const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
782
0
{
783
0
    OSL_FAIL("not implemented");
784
0
}
785
786
void SAL_CALL SwXTextView::addVetoableChangeListener(
787
        const OUString& /*rPropertyName*/,
788
        const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
789
0
{
790
0
    OSL_FAIL("not implemented");
791
0
}
792
793
void SAL_CALL SwXTextView::removeVetoableChangeListener(
794
        const OUString& /*rPropertyName*/,
795
        const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
796
0
{
797
0
    OSL_FAIL("not implemented");
798
0
}
799
800
OUString SwXTextView::getImplementationName()
801
0
{
802
0
    return u"SwXTextView"_ustr;
803
0
}
804
805
sal_Bool SwXTextView::supportsService(const OUString& rServiceName)
806
0
{
807
0
    return cppu::supportsService(this, rServiceName);
808
0
}
809
810
Sequence< OUString > SwXTextView::getSupportedServiceNames()
811
0
{
812
0
    return { u"com.sun.star.text.TextDocumentView"_ustr, u"com.sun.star.view.OfficeDocumentView"_ustr };
813
0
}
814
815
SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) :
816
0
    m_pView(pVw),
817
0
    m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
818
0
{
819
0
}
820
821
SwXTextViewCursor::~SwXTextViewCursor()
822
0
{
823
0
}
824
825
// used to determine if there is a text selection or not.
826
// If there is no text selection the functions that need a working
827
// cursor will be disabled (throw RuntimeException). This will be the case
828
// for the following interfaces:
829
// - XViewCursor
830
// - XTextCursor
831
// - XTextRange
832
// - XLineCursor
833
bool SwXTextViewCursor::IsTextSelection( bool bAllowTables ) const
834
0
{
835
836
0
    bool bRes = false;
837
0
    OSL_ENSURE(m_pView, "m_pView is NULL ???");
838
0
    if(m_pView)
839
0
    {
840
        //! m_pView->GetShellMode() will only work after the shell
841
        //! has already changed and thus can not be used here!
842
0
        SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType();
843
0
        bRes =  ( (SelectionType::Text & eSelType) ||
844
0
                  (SelectionType::NumberList & eSelType) )  &&
845
0
                (!(SelectionType::TableCell & eSelType) || bAllowTables);
846
0
    }
847
0
    return bRes;
848
0
}
849
850
sal_Bool SwXTextViewCursor::isVisible()
851
0
{
852
0
    OSL_FAIL("not implemented");
853
0
    return true;
854
0
}
855
856
void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/)
857
0
{
858
0
    OSL_FAIL("not implemented");
859
0
}
860
861
awt::Point SwXTextViewCursor::getPosition()
862
0
{
863
0
    SolarMutexGuard aGuard;
864
0
    awt::Point aRet;
865
0
    if(!m_pView)
866
0
        throw uno::RuntimeException();
867
868
0
    const SwWrtShell& rSh = m_pView->GetWrtShell();
869
0
    const SwRect& aCharRect(rSh.GetCharRect());
870
871
0
    const SwFrameFormat& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster();
872
873
0
    const SvxULSpaceItem& rUL = rMaster.GetULSpace();
874
0
    const tools::Long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER);
875
0
    aRet.Y = convertTwipToMm100(nY);
876
877
0
    const SvxLRSpaceItem& rLR = rMaster.GetLRSpace();
878
0
    const tools::Long nX = aCharRect.Left() - (rLR.ResolveLeft({}) + DOCUMENTBORDER);
879
0
    aRet.X = convertTwipToMm100(nX);
880
881
0
    return aRet;
882
0
}
883
884
void SwXTextViewCursor::collapseToStart()
885
0
{
886
0
    SolarMutexGuard aGuard;
887
0
    if(!m_pView)
888
0
        throw uno::RuntimeException();
889
890
0
    if (!IsTextSelection())
891
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
892
893
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
894
0
    if(rSh.HasSelection())
895
0
    {
896
0
        SwPaM* pShellCursor = rSh.GetCursor();
897
0
        if(*pShellCursor->GetPoint() > *pShellCursor->GetMark())
898
0
            pShellCursor->Exchange();
899
0
        pShellCursor->DeleteMark();
900
0
        rSh.EnterStdMode();
901
0
        rSh.SetSelection(*pShellCursor);
902
0
    }
903
904
0
}
905
906
void SwXTextViewCursor::collapseToEnd()
907
0
{
908
0
    SolarMutexGuard aGuard;
909
0
    if(!m_pView)
910
0
        throw uno::RuntimeException();
911
912
0
    if (!IsTextSelection())
913
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
914
915
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
916
0
    if(rSh.HasSelection())
917
0
    {
918
0
        SwPaM* pShellCursor = rSh.GetCursor();
919
0
        if(*pShellCursor->GetPoint() < *pShellCursor->GetMark())
920
0
            pShellCursor->Exchange();
921
0
        pShellCursor->DeleteMark();
922
0
        rSh.EnterStdMode();
923
0
        rSh.SetSelection(*pShellCursor);
924
0
    }
925
926
0
}
927
928
sal_Bool SwXTextViewCursor::isCollapsed()
929
0
{
930
0
    SolarMutexGuard aGuard;
931
0
    bool bRet = false;
932
0
    if(!m_pView)
933
0
        throw uno::RuntimeException();
934
935
0
    if (!IsTextSelection())
936
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
937
938
0
    const SwWrtShell& rSh = m_pView->GetWrtShell();
939
0
    bRet = !rSh.HasSelection();
940
941
0
    return bRet;
942
943
0
}
944
945
sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand)
946
0
{
947
0
    SolarMutexGuard aGuard;
948
0
    bool bRet = false;
949
0
    if(!m_pView)
950
0
        throw uno::RuntimeException();
951
952
0
    if (!IsTextSelection())
953
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
954
955
0
    bRet = m_pView->GetWrtShell().Left( SwCursorSkipMode::Chars, bExpand, nCount, true );
956
957
0
    return bRet;
958
0
}
959
960
sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand)
961
0
{
962
0
    SolarMutexGuard aGuard;
963
0
    bool bRet = false;
964
0
    if(!m_pView)
965
0
        throw uno::RuntimeException();
966
967
0
    if (!IsTextSelection())
968
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
969
970
0
    bRet = m_pView->GetWrtShell().Right( SwCursorSkipMode::Chars, bExpand, nCount, true );
971
972
0
    return bRet;
973
974
0
}
975
976
void SwXTextViewCursor::gotoRange(
977
    const uno::Reference< text::XTextRange > & xRange,
978
    sal_Bool bExpand)
979
0
{
980
0
    SolarMutexGuard aGuard;
981
0
    if(!(m_pView && xRange.is()))
982
0
        throw uno::RuntimeException();
983
984
0
    if (!IsTextSelection())
985
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
986
987
0
    SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc());
988
0
    if (!::sw::XTextRangeToSwPaM(rDestPam, xRange))
989
0
    {
990
0
        throw uno::RuntimeException();
991
0
    }
992
993
0
    ShellMode   eSelMode = m_pView->GetShellMode();
994
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
995
    // call EnterStdMode in non-text selections only
996
0
    if(!bExpand ||
997
0
       (eSelMode != ShellMode::TableText &&
998
0
        eSelMode != ShellMode::ListText &&
999
0
        eSelMode != ShellMode::TableListText &&
1000
0
        eSelMode != ShellMode::Text ))
1001
0
            rSh.EnterStdMode();
1002
0
    SwPaM* pShellCursor = rSh.GetCursor();
1003
0
    SwPaM aOwnPaM(*pShellCursor->GetPoint());
1004
0
    if(pShellCursor->HasMark())
1005
0
    {
1006
0
        aOwnPaM.SetMark();
1007
0
        *aOwnPaM.GetMark() = *pShellCursor->GetMark();
1008
0
    }
1009
1010
0
    SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xRange.get());
1011
0
    SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xRange.get());
1012
0
    OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xRange.get());
1013
1014
0
    const FrameTypeFlags nFrameType = rSh.GetFrameType(nullptr,true);
1015
1016
0
    SwStartNodeType eSearchNodeType = SwNormalStartNode;
1017
0
    if(nFrameType & FrameTypeFlags::FLY_ANY)
1018
0
        eSearchNodeType = SwFlyStartNode;
1019
0
    else if(nFrameType &FrameTypeFlags::HEADER)
1020
0
        eSearchNodeType = SwHeaderStartNode;
1021
0
    else if(nFrameType & FrameTypeFlags::FOOTER)
1022
0
        eSearchNodeType = SwFooterStartNode;
1023
0
    else if(nFrameType & FrameTypeFlags::TABLE)
1024
0
        eSearchNodeType = SwTableBoxStartNode;
1025
0
    else if(nFrameType & FrameTypeFlags::FOOTNOTE)
1026
0
        eSearchNodeType = SwFootnoteStartNode;
1027
1028
0
    const SwStartNode* pOwnStartNode = aOwnPaM.GetPointNode().
1029
0
                                            FindStartNodeByType(eSearchNodeType);
1030
1031
0
    const SwNode* pSrcNode = nullptr;
1032
0
    if(pCursor && pCursor->GetPaM())
1033
0
    {
1034
0
        pSrcNode = &pCursor->GetPaM()->GetPointNode();
1035
0
    }
1036
0
    else if (pRange)
1037
0
    {
1038
0
        SwPaM aPam(pRange->GetDoc().GetNodes());
1039
0
        if (pRange->GetPositions(aPam))
1040
0
        {
1041
0
            pSrcNode = &aPam.GetPointNode();
1042
0
        }
1043
0
    }
1044
0
    else if (pPara && pPara->GetTextNode())
1045
0
    {
1046
0
        pSrcNode = pPara->GetTextNode();
1047
0
    }
1048
0
    const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindStartNodeByType(eSearchNodeType) : nullptr;
1049
1050
    //Skip SectionNodes
1051
0
    while(pTmp && pTmp->IsSectionNode())
1052
0
    {
1053
0
        pTmp = pTmp->StartOfSectionNode();
1054
0
    }
1055
0
    while(pOwnStartNode && pOwnStartNode->IsSectionNode())
1056
0
    {
1057
0
        pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1058
0
    }
1059
    //Without Expand it is allowed to jump out with the ViewCursor everywhere,
1060
    //with Expand only in the same environment
1061
0
    if(bExpand &&
1062
0
        (pOwnStartNode != pTmp ||
1063
0
        (eSelMode != ShellMode::TableText &&
1064
0
            eSelMode != ShellMode::ListText &&
1065
0
            eSelMode != ShellMode::TableListText &&
1066
0
            eSelMode != ShellMode::Text)))
1067
0
        throw uno::RuntimeException();
1068
1069
    //Now, the selection must be expanded.
1070
0
    if(bExpand)
1071
0
    {
1072
        // The cursor should include everything that has been included
1073
        // by him and the transferred Range.
1074
0
        SwPosition aOwnLeft(*aOwnPaM.Start());
1075
0
        SwPosition aOwnRight(*aOwnPaM.End());
1076
0
        auto [pParamLeft, pParamRight] = rDestPam.StartEnd(); // SwPosition*
1077
        // Now four SwPositions are there, two of them are needed, but which?
1078
0
        if(aOwnRight > *pParamRight)
1079
0
            *aOwnPaM.GetPoint() = std::move(aOwnRight);
1080
0
        else
1081
0
            *aOwnPaM.GetPoint() = *pParamRight;
1082
0
        aOwnPaM.SetMark();
1083
0
        if(aOwnLeft < *pParamLeft)
1084
0
            *aOwnPaM.GetMark() = std::move(aOwnLeft);
1085
0
        else
1086
0
            *aOwnPaM.GetMark() = *pParamLeft;
1087
0
    }
1088
0
    else
1089
0
    {
1090
        //The cursor shall match the passed range.
1091
0
        *aOwnPaM.GetPoint() = *rDestPam.GetPoint();
1092
0
        if(rDestPam.HasMark())
1093
0
        {
1094
0
            aOwnPaM.SetMark();
1095
0
            *aOwnPaM.GetMark() = *rDestPam.GetMark();
1096
0
        }
1097
0
        else
1098
0
            aOwnPaM.DeleteMark();
1099
0
    }
1100
0
    rSh.SetSelection(aOwnPaM);
1101
1102
1103
0
}
1104
1105
void SwXTextViewCursor::gotoStart(sal_Bool bExpand)
1106
0
{
1107
0
    SolarMutexGuard aGuard;
1108
0
    comphelper::ProfileZone aZone("SwXTextViewCursor::gotoStart");
1109
0
    if(!m_pView)
1110
0
        throw uno::RuntimeException();
1111
1112
0
    if (!IsTextSelection())
1113
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1114
1115
0
    m_pView->GetWrtShell().StartOfSection( bExpand );
1116
1117
0
}
1118
1119
void SwXTextViewCursor::gotoEnd(sal_Bool bExpand)
1120
0
{
1121
0
    SolarMutexGuard aGuard;
1122
0
    comphelper::ProfileZone aZone("SwXTextViewCursor::gotoEnd");
1123
0
    if(!m_pView)
1124
0
        throw uno::RuntimeException();
1125
1126
0
    if (!IsTextSelection())
1127
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1128
1129
0
    m_pView->GetWrtShell().EndOfSection( bExpand );
1130
1131
0
}
1132
1133
sal_Bool SwXTextViewCursor::jumpToFirstPage()
1134
0
{
1135
0
    SolarMutexGuard aGuard;
1136
0
    bool bRet = false;
1137
0
    if(!m_pView)
1138
0
        throw uno::RuntimeException();
1139
1140
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1141
0
    if (rSh.IsSelFrameMode())
1142
0
    {
1143
0
        rSh.UnSelectFrame();
1144
0
        rSh.LeaveSelFrameMode();
1145
0
    }
1146
0
    rSh.EnterStdMode();
1147
0
    bRet = rSh.SttEndDoc(true);
1148
1149
0
    return bRet;
1150
0
}
1151
1152
sal_Bool SwXTextViewCursor::jumpToLastPage()
1153
0
{
1154
0
    SolarMutexGuard aGuard;
1155
0
    bool bRet = false;
1156
0
    if(!m_pView)
1157
0
        throw uno::RuntimeException();
1158
1159
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1160
0
    if (rSh.IsSelFrameMode())
1161
0
    {
1162
0
        rSh.UnSelectFrame();
1163
0
        rSh.LeaveSelFrameMode();
1164
0
    }
1165
0
    rSh.EnterStdMode();
1166
0
    bRet = rSh.SttEndDoc(false);
1167
0
    rSh.SttPg();
1168
1169
0
    return bRet;
1170
0
}
1171
1172
sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage)
1173
0
{
1174
0
    SolarMutexGuard aGuard;
1175
0
    bool bRet = false;
1176
0
    if(!m_pView)
1177
0
        throw uno::RuntimeException();
1178
1179
0
    bRet = m_pView->GetWrtShell().GotoPage(nPage, true);
1180
1181
0
    return bRet;
1182
0
}
1183
1184
sal_Bool SwXTextViewCursor::jumpToNextPage()
1185
0
{
1186
0
    SolarMutexGuard aGuard;
1187
0
    bool bRet = false;
1188
0
    if(!m_pView)
1189
0
        throw uno::RuntimeException();
1190
1191
0
    bRet = m_pView->GetWrtShell().SttNxtPg();
1192
1193
0
    return bRet;
1194
0
}
1195
1196
sal_Bool SwXTextViewCursor::jumpToPreviousPage()
1197
0
{
1198
0
    SolarMutexGuard aGuard;
1199
0
    bool bRet = false;
1200
0
    if(!m_pView)
1201
0
        throw uno::RuntimeException();
1202
1203
0
    bRet = m_pView->GetWrtShell().EndPrvPg();
1204
1205
0
    return bRet;
1206
0
}
1207
1208
sal_Bool SwXTextViewCursor::jumpToEndOfPage()
1209
0
{
1210
0
    SolarMutexGuard aGuard;
1211
0
    bool bRet = false;
1212
0
    if(!m_pView)
1213
0
        throw uno::RuntimeException();
1214
1215
0
    bRet = m_pView->GetWrtShell().EndPg();
1216
1217
0
    return bRet;
1218
0
}
1219
1220
sal_Bool SwXTextViewCursor::jumpToStartOfPage()
1221
0
{
1222
0
    SolarMutexGuard aGuard;
1223
0
    bool bRet = false;
1224
0
    if(!m_pView)
1225
0
        throw uno::RuntimeException();
1226
1227
0
    bRet = m_pView->GetWrtShell().SttPg();
1228
1229
0
    return bRet;
1230
0
}
1231
1232
sal_Int16 SwXTextViewCursor::getPage()
1233
0
{
1234
0
    SolarMutexGuard aGuard;
1235
0
    sal_Int16 nRet = 0;
1236
0
    if(!m_pView)
1237
0
        throw uno::RuntimeException();
1238
1239
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1240
0
    SwPaM* pShellCursor = rSh.GetCursor();
1241
0
    nRet = static_cast<sal_Int16>(pShellCursor->GetPageNum());
1242
1243
0
    return nRet;
1244
0
}
1245
1246
sal_Bool SwXTextViewCursor::screenDown()
1247
0
{
1248
0
    SolarMutexGuard aGuard;
1249
0
    bool bRet = false;
1250
0
    if(!m_pView)
1251
0
        throw uno::RuntimeException();
1252
1253
0
    SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool());
1254
0
    m_pView->Execute(aReq);
1255
0
    const SfxPoolItemHolder& rResult(aReq.GetReturnValue());
1256
0
    bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue();
1257
1258
0
    return bRet;
1259
0
}
1260
1261
sal_Bool SwXTextViewCursor::screenUp()
1262
0
{
1263
0
    SolarMutexGuard aGuard;
1264
0
    bool bRet = false;
1265
0
    if(!m_pView)
1266
0
        throw uno::RuntimeException();
1267
1268
0
    SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool());
1269
0
    m_pView->Execute(aReq);
1270
0
    const SfxPoolItemHolder& rResult(aReq.GetReturnValue());
1271
0
    bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue();
1272
1273
0
    return bRet;
1274
0
}
1275
1276
uno::Reference< text::XText >  SwXTextViewCursor::getText()
1277
0
{
1278
0
    SolarMutexGuard aGuard;
1279
0
    uno::Reference< text::XText >  xRet;
1280
0
    if(!m_pView)
1281
0
        throw uno::RuntimeException();
1282
1283
0
    if (!IsTextSelection( false ))
1284
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1285
1286
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1287
0
    SwPaM* pShellCursor = rSh.GetCursor();
1288
0
    SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1289
0
    xRet = ::sw::CreateParentXText(*pDoc, *pShellCursor->Start());
1290
1291
0
    return xRet;
1292
0
}
1293
1294
uno::Reference< text::XTextRange > SwXTextViewCursor::getStart()
1295
0
{
1296
0
    SolarMutexGuard aGuard;
1297
0
    if(!m_pView)
1298
0
        throw uno::RuntimeException();
1299
1300
0
    if (!IsTextSelection())
1301
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1302
1303
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1304
0
    SwPaM* pShellCursor = rSh.GetCursor();
1305
0
    SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1306
1307
0
    return SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->Start(), nullptr);
1308
0
}
1309
1310
uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd()
1311
0
{
1312
0
    SolarMutexGuard aGuard;
1313
0
    if(!m_pView)
1314
0
        throw uno::RuntimeException();
1315
1316
0
    if (!IsTextSelection())
1317
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1318
1319
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1320
0
    SwPaM* pShellCursor = rSh.GetCursor();
1321
0
    SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
1322
1323
0
    return SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->End(), nullptr);
1324
0
}
1325
1326
OUString SwXTextViewCursor::getString()
1327
0
{
1328
0
    SolarMutexGuard aGuard;
1329
0
    OUString uRet;
1330
0
    if(m_pView)
1331
0
    {
1332
0
        if (!IsTextSelection( false ))
1333
0
        {
1334
0
            SAL_WARN("sw.uno", "no text selection in getString() " << getXWeak());
1335
0
            return uRet;
1336
0
        }
1337
1338
0
        ShellMode eSelMode = m_pView->GetShellMode();
1339
0
        switch(eSelMode)
1340
0
        {
1341
            //! since setString for SEL_TABLE_TEXT (with possible
1342
            //! multi selection of cells) would not work properly we
1343
            //! will ignore this case for both
1344
            //! functions (setString AND getString) because of symmetrie.
1345
1346
0
            case ShellMode::ListText       :
1347
0
            case ShellMode::TableListText:
1348
0
            case ShellMode::Text            :
1349
0
            {
1350
0
                SwWrtShell& rSh = m_pView->GetWrtShell();
1351
0
                SwPaM* pShellCursor = rSh.GetCursor();
1352
0
                SwUnoCursorHelper::GetTextFromPam(*pShellCursor, uRet,
1353
0
                        rSh.GetLayout());
1354
0
                break;
1355
0
            }
1356
0
            default:;//prevent warning
1357
0
        }
1358
0
    }
1359
0
    return uRet;
1360
0
}
1361
1362
void SwXTextViewCursor::setString(const OUString& aString)
1363
0
{
1364
0
    SolarMutexGuard aGuard;
1365
0
    if(!m_pView)
1366
0
        return;
1367
1368
0
    if (!IsTextSelection( false ))
1369
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1370
1371
0
    ShellMode eSelMode = m_pView->GetShellMode();
1372
0
    switch(eSelMode)
1373
0
    {
1374
        //! since setString for SEL_TABLE_TEXT (with possible
1375
        //! multi selection of cells) would not work properly we
1376
        //! will ignore this case for both
1377
        //! functions (setString AND getString) because of symmetrie.
1378
1379
0
        case ShellMode::ListText       :
1380
0
        case ShellMode::TableListText :
1381
0
        case ShellMode::Text            :
1382
0
        {
1383
0
            SwWrtShell& rSh = m_pView->GetWrtShell();
1384
0
            SwCursor* pShellCursor = rSh.GetCursor();
1385
0
            SwUnoCursorHelper::SetString(*pShellCursor, aString);
1386
0
            break;
1387
0
        }
1388
0
        default:;//prevent warning
1389
0
    }
1390
0
}
1391
1392
uno::Reference< XPropertySetInfo >  SwXTextViewCursor::getPropertySetInfo(  )
1393
0
{
1394
0
    static uno::Reference< XPropertySetInfo >  xRef = m_pPropSet->getPropertySetInfo();
1395
0
    return xRef;
1396
0
}
1397
1398
void  SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
1399
0
{
1400
0
    SolarMutexGuard aGuard;
1401
0
    if(!m_pView)
1402
0
        throw RuntimeException();
1403
1404
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1405
0
    SwPaM* pShellCursor = rSh.GetCursor();
1406
0
    SwNode& rNode = pShellCursor->GetPointNode();
1407
0
    if (!rNode.IsTextNode())
1408
0
        throw RuntimeException();
1409
1410
0
    SwUnoCursorHelper::SetPropertyValue(
1411
0
        *pShellCursor, *m_pPropSet, rPropertyName, aValue );
1412
1413
1414
0
}
1415
1416
Any  SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName )
1417
0
{
1418
0
    SolarMutexGuard aGuard;
1419
0
    Any aRet;
1420
0
    if(!m_pView)
1421
0
        throw RuntimeException();
1422
1423
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1424
0
    SwPaM* pShellCursor = rSh.GetCursor();
1425
0
    aRet = SwUnoCursorHelper::GetPropertyValue(
1426
0
            *pShellCursor, *m_pPropSet, rPropertyName);
1427
1428
0
    return aRet;
1429
0
}
1430
1431
void  SwXTextViewCursor::addPropertyChangeListener(
1432
    const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
1433
0
{
1434
0
}
1435
1436
void  SwXTextViewCursor::removePropertyChangeListener(
1437
    const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ )
1438
0
{
1439
0
}
1440
1441
void  SwXTextViewCursor::addVetoableChangeListener(
1442
    const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
1443
0
{
1444
0
}
1445
1446
void  SwXTextViewCursor::removeVetoableChangeListener(
1447
    const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
1448
0
{
1449
0
}
1450
1451
PropertyState  SwXTextViewCursor::getPropertyState( const OUString& rPropertyName )
1452
0
{
1453
0
    SolarMutexGuard aGuard;
1454
0
    PropertyState eState;
1455
0
    if(!m_pView)
1456
0
        throw RuntimeException();
1457
1458
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1459
0
    SwPaM* pShellCursor = rSh.GetCursor();
1460
0
    eState = SwUnoCursorHelper::GetPropertyState(
1461
0
            *pShellCursor, *m_pPropSet, rPropertyName);
1462
1463
0
    return eState;
1464
0
}
1465
1466
Sequence< PropertyState >  SwXTextViewCursor::getPropertyStates(
1467
    const Sequence< OUString >& rPropertyNames )
1468
0
{
1469
0
    SolarMutexGuard aGuard;
1470
0
    Sequence< PropertyState >  aRet;
1471
0
    if(m_pView)
1472
0
    {
1473
0
        SwWrtShell& rSh = m_pView->GetWrtShell();
1474
0
        SwPaM* pShellCursor = rSh.GetCursor();
1475
0
        aRet = SwUnoCursorHelper::GetPropertyStates(
1476
0
                *pShellCursor, *m_pPropSet,  rPropertyNames);
1477
0
    }
1478
0
    return aRet;
1479
0
}
1480
1481
void  SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName )
1482
0
{
1483
0
    SolarMutexGuard aGuard;
1484
0
    if(m_pView)
1485
0
    {
1486
0
        SwWrtShell& rSh = m_pView->GetWrtShell();
1487
0
        SwPaM* pShellCursor = rSh.GetCursor();
1488
0
        SwUnoCursorHelper::SetPropertyToDefault(
1489
0
                *pShellCursor, *m_pPropSet, rPropertyName);
1490
0
    }
1491
0
}
1492
1493
Any  SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName )
1494
0
{
1495
0
    Any aRet;
1496
0
    SolarMutexGuard aGuard;
1497
0
    if(m_pView)
1498
0
    {
1499
0
        SwWrtShell& rSh = m_pView->GetWrtShell();
1500
0
        SwPaM* pShellCursor = rSh.GetCursor();
1501
0
        aRet = SwUnoCursorHelper::GetPropertyDefault(
1502
0
                *pShellCursor, *m_pPropSet, rPropertyName);
1503
0
    }
1504
0
    return aRet;
1505
0
}
1506
1507
sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand)
1508
0
{
1509
0
    SolarMutexGuard aGuard;
1510
0
    comphelper::ProfileZone aZone("SwXTextViewCursor::goDown");
1511
0
    bool bRet = false;
1512
0
    if(!m_pView)
1513
0
        throw uno::RuntimeException();
1514
1515
0
    if (!IsTextSelection())
1516
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1517
1518
0
    bRet = m_pView->GetWrtShell().Down( bExpand, nCount, true );
1519
1520
0
    return bRet;
1521
0
}
1522
1523
sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand)
1524
0
{
1525
0
    SolarMutexGuard aGuard;
1526
0
    comphelper::ProfileZone aZone("SwXTextViewCursor::goUp");
1527
0
    bool bRet = false;
1528
0
    if(!m_pView)
1529
0
        throw uno::RuntimeException();
1530
1531
0
    if (!IsTextSelection())
1532
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1533
1534
0
    bRet = m_pView->GetWrtShell().Up( bExpand, nCount, true );
1535
1536
0
    return bRet;
1537
0
}
1538
1539
sal_Bool SwXTextViewCursor::isAtStartOfLine()
1540
0
{
1541
0
    SolarMutexGuard aGuard;
1542
0
    bool bRet = false;
1543
0
    if(!m_pView)
1544
0
        throw uno::RuntimeException();
1545
1546
0
    if (!IsTextSelection( false ))
1547
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1548
1549
0
    bRet = m_pView->GetWrtShell().IsAtLeftMargin();
1550
1551
0
    return bRet;
1552
0
}
1553
1554
sal_Bool SwXTextViewCursor::isAtEndOfLine()
1555
0
{
1556
0
    SolarMutexGuard aGuard;
1557
0
    bool bRet = false;
1558
0
    if(!m_pView)
1559
0
        throw uno::RuntimeException();
1560
1561
0
    if (!IsTextSelection( false ))
1562
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1563
1564
0
    bRet = m_pView->GetWrtShell().IsAtRightMargin();
1565
1566
0
    return bRet;
1567
0
}
1568
1569
void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand)
1570
0
{
1571
0
    SolarMutexGuard aGuard;
1572
0
    if(!m_pView)
1573
0
        throw uno::RuntimeException();
1574
1575
0
    if (!IsTextSelection( false ))
1576
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1577
1578
0
    m_pView->GetWrtShell().RightMargin(bExpand, true);
1579
1580
0
}
1581
1582
void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand)
1583
0
{
1584
0
    SolarMutexGuard aGuard;
1585
0
    if(!m_pView)
1586
0
        throw uno::RuntimeException();
1587
1588
0
    if (!IsTextSelection( false ))
1589
0
        throw  uno::RuntimeException(u"no text selection"_ustr, getXWeak() );
1590
1591
0
    m_pView->GetWrtShell().LeftMargin(bExpand, true);
1592
1593
0
}
1594
1595
OUString SwXTextViewCursor::getImplementationName()
1596
0
{
1597
0
    return u"SwXTextViewCursor"_ustr;
1598
0
}
1599
1600
sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName)
1601
0
{
1602
0
    return cppu::supportsService(this, rServiceName);
1603
0
}
1604
1605
Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames()
1606
0
{
1607
0
    return { u"com.sun.star.text.TextViewCursor"_ustr,
1608
0
             u"com.sun.star.style.CharacterProperties"_ustr,
1609
0
             u"com.sun.star.style.CharacterPropertiesAsian"_ustr,
1610
0
             u"com.sun.star.style.CharacterPropertiesComplex"_ustr,
1611
0
             u"com.sun.star.style.ParagraphProperties"_ustr,
1612
0
             u"com.sun.star.style.ParagraphPropertiesAsian"_ustr,
1613
0
             u"com.sun.star.style.ParagraphPropertiesComplex"_ustr };
1614
0
}
1615
1616
const SwDoc*        SwXTextViewCursor::GetDoc() const
1617
0
{
1618
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1619
0
    return   rSh.GetCursor() ? &rSh.GetCursor()->GetDoc() : nullptr;
1620
0
}
1621
1622
SwDoc*  SwXTextViewCursor::GetDoc()
1623
0
{
1624
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1625
0
    return   rSh.GetCursor() ? &rSh.GetCursor()->GetDoc() : nullptr;
1626
0
}
1627
1628
const SwPaM*    SwXTextViewCursor::GetPaM() const
1629
0
{
1630
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1631
0
    return rSh.GetCursor();
1632
0
}
1633
1634
SwPaM*  SwXTextViewCursor::GetPaM()
1635
0
{
1636
0
    SwWrtShell& rSh = m_pView->GetWrtShell();
1637
0
    return rSh.GetCursor();
1638
0
}
1639
1640
uno::Reference<datatransfer::XTransferable> SAL_CALL
1641
SwXTextView::getTransferableForTextRange(uno::Reference<text::XTextRange> const& xTextRange)
1642
0
{
1643
0
    SolarMutexGuard aGuard;
1644
1645
    // the point is we can copy PaM that wouldn't be legal as shell cursor
1646
0
    SwUnoInternalPaM aPam(*m_pView->GetDocShell()->GetDoc());
1647
0
    if (!::sw::XTextRangeToSwPaM(aPam, xTextRange, ::sw::TextRangeMode::AllowNonTextNode))
1648
0
    {
1649
0
        throw uno::RuntimeException(u"invalid text range"_ustr);
1650
0
    }
1651
1652
    //force immediate shell update
1653
0
    GetView()->StopShellTimer();
1654
0
    SwWrtShell& rSh = GetView()->GetWrtShell();
1655
0
    rtl::Reference<SwTransferable> pTransfer = new SwTransferable(rSh);
1656
0
    const bool bLockedView = rSh.IsViewLocked();
1657
0
    rSh.LockView( true );
1658
0
    pTransfer->PrepareForCopyTextRange(aPam);
1659
0
    rSh.LockView( bLockedView );
1660
0
    return pTransfer;
1661
0
}
1662
1663
OUString SAL_CALL SwXTextView::dump(const OUString& rKind)
1664
0
{
1665
0
    if (rKind == "layout")
1666
0
    {
1667
0
        SwRootFrame* pLayout = GetView()->GetWrtShell().GetLayout();
1668
0
        return comphelper::dumpXmlToString([pLayout](xmlTextWriterPtr pWriter)
1669
0
                                           { pLayout->dumpAsXml(pWriter); });
1670
0
    }
1671
1672
0
    return OUString();
1673
0
}
1674
1675
uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable()
1676
0
{
1677
0
    SolarMutexGuard aGuard;
1678
1679
    //force immediate shell update
1680
0
    GetView()->StopShellTimer();
1681
0
    SwWrtShell& rSh = GetView()->GetWrtShell();
1682
0
    if ( GetView()->GetShellMode() == ShellMode::DrawText )
1683
0
    {
1684
0
        SdrView *pSdrView = rSh.GetDrawView();
1685
0
        OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
1686
0
        return pOLV->GetEditView().GetTransferable();
1687
0
    }
1688
0
    else
1689
0
    {
1690
0
        rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh );
1691
0
        const bool bLockedView = rSh.IsViewLocked();
1692
0
        rSh.LockView( true );    //lock visible section
1693
0
        pTransfer->PrepareForCopy();
1694
0
        rSh.LockView( bLockedView );
1695
0
        return pTransfer;
1696
0
    }
1697
0
}
1698
1699
void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans )
1700
0
{
1701
0
    SolarMutexGuard aGuard;
1702
1703
    //force immediate shell update
1704
0
    GetView()->StopShellTimer();
1705
0
    SwWrtShell& rSh = GetView()->GetWrtShell();
1706
0
    if ( GetView()->GetShellMode() == ShellMode::DrawText )
1707
0
    {
1708
0
        SdrView *pSdrView = rSh.GetDrawView();
1709
0
        OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
1710
0
        pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), false );
1711
0
    }
1712
0
    else
1713
0
    {
1714
0
        TransferableDataHelper aDataHelper( xTrans );
1715
0
        if ( SwTransferable::IsPaste( rSh, aDataHelper ) )
1716
0
        {
1717
0
            SwTransferable::Paste( rSh, aDataHelper );
1718
0
            if( rSh.IsFrameSelected() || rSh.GetSelectedObjCount() )
1719
0
                rSh.EnterSelFrameMode();
1720
0
            GetView()->AttrChangedNotify(nullptr);
1721
0
        }
1722
0
    }
1723
0
}
1724
1725
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */