Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/accessibility/AccessibleDocumentViewBase.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 <AccessibleDocumentViewBase.hxx>
21
#include <com/sun/star/drawing/XDrawView.hpp>
22
#include <com/sun/star/frame/XController.hpp>
23
#include <com/sun/star/document/XShapeEventBroadcaster.hpp>
24
#include <com/sun/star/beans/XPropertySet.hpp>
25
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
26
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27
#include <comphelper/sequence.hxx>
28
#include <rtl/ustrbuf.hxx>
29
#include <sfx2/viewfrm.hxx>
30
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
31
#include <com/sun/star/accessibility/AccessibleRole.hpp>
32
#include <sfx2/objsh.hxx>
33
#include <tools/debug.hxx>
34
#include <vcl/vclevent.hxx>
35
36
#include <cppuhelper/queryinterface.hxx>
37
#include <svx/svdobj.hxx>
38
#include <toolkit/helper/vclunohelper.hxx>
39
#include <Window.hxx>
40
#include <OutlineViewShell.hxx>
41
42
#include <svx/svdlayer.hxx>
43
#include <editeng/editobj.hxx>
44
#include <LayerTabBar.hxx>
45
#include <svtools/colorcfg.hxx>
46
#include <ViewShell.hxx>
47
#include <View.hxx>
48
#include <drawdoc.hxx>
49
#include <editeng/outlobj.hxx>
50
#include <sdpage.hxx>
51
#include <DrawViewShell.hxx>
52
#include <PresentationViewShell.hxx>
53
#include <utility>
54
55
using namespace ::com::sun::star;
56
using namespace ::com::sun::star::accessibility;
57
using ::com::sun::star::uno::Reference;
58
59
namespace accessibility {
60
61
AccessibleDocumentViewBase::AccessibleDocumentViewBase (
62
    ::sd::Window* pSdWindow,
63
    ::sd::ViewShell* pViewShell,
64
    uno::Reference<frame::XController> xController,
65
    const uno::Reference<XAccessible>& rxParent)
66
0
    : AccessibleContextBase (rxParent,
67
0
                             pViewShell->GetDoc()->GetDocumentType() == DocumentType::Impress ?
68
0
                                     AccessibleRole::DOCUMENT_PRESENTATION :
69
0
                                     AccessibleRole::DOCUMENT),
70
0
      mxController (std::move(xController)),
71
0
      maViewForwarder (
72
0
        static_cast<SdrPaintView*>(pViewShell->GetView()),
73
0
        *pSdWindow->GetOutDev())
74
0
{
75
0
    if (mxController.is())
76
0
        mxModel = mxController->getModel();
77
78
    // Fill the shape tree info.
79
0
    maShapeTreeInfo.SetModelBroadcaster (
80
0
        uno::Reference<document::XShapeEventBroadcaster>(
81
0
            mxModel, uno::UNO_QUERY_THROW));
82
0
    maShapeTreeInfo.SetController (mxController);
83
0
    maShapeTreeInfo.SetSdrView (pViewShell->GetView());
84
0
    maShapeTreeInfo.SetWindow (pSdWindow);
85
0
    maShapeTreeInfo.SetViewForwarder (&maViewForwarder);
86
87
0
    mxWindow = ::VCLUnoHelper::GetInterface (pSdWindow);
88
0
    mpViewShell = pViewShell;
89
0
}
90
91
AccessibleDocumentViewBase::~AccessibleDocumentViewBase()
92
0
{
93
    // At this place we should be disposed.  You may want to add a
94
    // corresponding assertion into the destructor of a derived class.
95
0
}
96
97
void AccessibleDocumentViewBase::Init()
98
0
{
99
    // Finish the initialization of the shape tree info container.
100
0
    maShapeTreeInfo.SetDocumentWindow (this);
101
102
    // Register as window listener to stay up to date with its size and
103
    // position.
104
0
    mxWindow->addWindowListener (this);
105
    // Register as focus listener to
106
0
    mxWindow->addFocusListener (this);
107
108
    // Determine the list of shapes on the current page.
109
0
    uno::Reference<drawing::XShapes> xShapeList;
110
0
    uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
111
0
    if (xView.is())
112
0
        xShapeList = xView->getCurrentPage();
113
114
    // Register this object as dispose event listener at the model.
115
0
    if (mxModel.is())
116
0
        mxModel->addEventListener (
117
0
            static_cast<awt::XWindowListener*>(this));
118
119
    // Register as property change listener at the controller.
120
0
    uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
121
0
    if (xSet.is())
122
0
        xSet->addPropertyChangeListener (
123
0
            u""_ustr,
124
0
            static_cast<beans::XPropertyChangeListener*>(this));
125
126
    // Register this object as dispose event listener at the controller.
127
0
    if (mxController.is())
128
0
        mxController->addEventListener (
129
0
            static_cast<awt::XWindowListener*>(this));
130
131
    // Register at VCL Window to be informed of activated and deactivated
132
    // OLE objects.
133
0
    vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
134
0
    if (pWindow != nullptr)
135
0
    {
136
0
        maWindowLink = LINK(
137
0
            this, AccessibleDocumentViewBase, WindowChildEventListener);
138
139
0
        pWindow->AddChildEventListener (maWindowLink);
140
141
0
        sal_uInt16 nCount = pWindow->GetChildCount();
142
0
        for (sal_uInt16 i=0; i<nCount; i++)
143
0
        {
144
0
            vcl::Window* pChildWindow = pWindow->GetChild (i);
145
0
            if (pChildWindow &&
146
0
                (AccessibleRole::EMBEDDED_OBJECT
147
0
                    ==pChildWindow->GetAccessibleRole()))
148
0
            {
149
0
                SetAccessibleOLEObject (pChildWindow->GetAccessible());
150
0
            }
151
0
        }
152
0
    }
153
0
    SfxObjectShell* pObjShell = mpViewShell->GetViewFrame()->GetObjectShell();
154
0
    if(!pObjShell->IsReadOnly())
155
0
        SetState(AccessibleStateType::EDITABLE);
156
0
}
157
158
IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener,
159
    VclWindowEvent&, rEvent, void)
160
0
{
161
        //      DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
162
0
        switch (rEvent.GetId())
163
0
        {
164
0
            case VclEventId::ObjectDying:
165
0
            {
166
                // Window is dying. Unregister from VCL Window.
167
                // This is also attempted in the disposing() method.
168
0
                vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
169
0
                vcl::Window* pDyingWindow = rEvent.GetWindow();
170
0
                if (pWindow==pDyingWindow && pWindow!=nullptr && maWindowLink.IsSet())
171
0
                {
172
0
                    pWindow->RemoveChildEventListener (maWindowLink);
173
0
                    maWindowLink = Link<VclWindowEvent&,void>();
174
0
                }
175
0
            }
176
0
            break;
177
178
0
            case VclEventId::WindowShow:
179
0
            {
180
                // A new window has been created.  Is it an OLE object?
181
0
                vcl::Window* pChildWindow = static_cast<vcl::Window*>(
182
0
                    rEvent.GetData());
183
0
                if (pChildWindow!=nullptr
184
0
                    && (pChildWindow->GetAccessibleRole()
185
0
                        == AccessibleRole::EMBEDDED_OBJECT))
186
0
                {
187
0
                    SetAccessibleOLEObject (pChildWindow->GetAccessible());
188
0
                }
189
0
            }
190
0
            break;
191
192
0
            case VclEventId::WindowHide:
193
0
            {
194
                // A window has been destroyed.  Has that been an OLE
195
                // object?
196
0
                vcl::Window* pChildWindow = static_cast<vcl::Window*>(
197
0
                    rEvent.GetData());
198
0
                if (pChildWindow!=nullptr
199
0
                    && (pChildWindow->GetAccessibleRole()
200
0
                        == AccessibleRole::EMBEDDED_OBJECT))
201
0
                {
202
0
                    SetAccessibleOLEObject (nullptr);
203
0
                }
204
0
            }
205
0
            break;
206
207
0
            default: break;
208
0
        }
209
0
}
210
211
//=====  IAccessibleViewForwarderListener  ====================================
212
213
void AccessibleDocumentViewBase::ViewForwarderChanged()
214
0
{
215
    // Empty
216
0
}
217
218
//=====  XAccessibleContext  ==================================================
219
220
Reference<XAccessible> SAL_CALL
221
       AccessibleDocumentViewBase::getAccessibleParent()
222
0
{
223
0
    ensureAlive();
224
225
0
    return AccessibleContextBase::getAccessibleParent();
226
0
}
227
228
sal_Int64 SAL_CALL
229
    AccessibleDocumentViewBase::getAccessibleChildCount()
230
0
{
231
0
    ensureAlive ();
232
233
0
    if (mxAccessibleOLEObject.is())
234
0
        return 1;
235
0
    else
236
0
        return 0;
237
0
}
238
239
Reference<XAccessible> SAL_CALL
240
    AccessibleDocumentViewBase::getAccessibleChild (sal_Int64 nIndex)
241
0
{
242
0
    ensureAlive();
243
244
0
    ::osl::MutexGuard aGuard (m_aMutex);
245
0
    if (mxAccessibleOLEObject.is())
246
0
        if (nIndex == 0)
247
0
            return mxAccessibleOLEObject;
248
249
0
    throw lang::IndexOutOfBoundsException ( "no child with index " + OUString::number(nIndex) );
250
0
}
251
252
//=====  XAccessibleComponent  ================================================
253
254
/** Iterate over all children and test whether the specified point lies
255
    within one of their bounding boxes.  Return the first child for which
256
    this is true.
257
*/
258
uno::Reference<XAccessible > SAL_CALL
259
    AccessibleDocumentViewBase::getAccessibleAtPoint (
260
        const awt::Point& aPoint)
261
0
{
262
0
    ensureAlive();
263
264
0
    ::osl::MutexGuard aGuard (m_aMutex);
265
0
    uno::Reference<XAccessible> xChildAtPosition;
266
267
0
    sal_Int64 nChildCount = getAccessibleChildCount ();
268
0
    for (sal_Int64 i=nChildCount-1; i>=0; --i)
269
0
    {
270
0
        Reference<XAccessible> xChild (getAccessibleChild (i));
271
0
        if (xChild.is())
272
0
        {
273
0
            Reference<XAccessibleComponent> xChildComponent (
274
0
                xChild->getAccessibleContext(), uno::UNO_QUERY);
275
0
            if (xChildComponent.is())
276
0
            {
277
0
                awt::Rectangle aBBox (xChildComponent->getBounds());
278
0
                if ( (aPoint.X >= aBBox.X)
279
0
                    && (aPoint.Y >= aBBox.Y)
280
0
                    && (aPoint.X < aBBox.X+aBBox.Width)
281
0
                    && (aPoint.Y < aBBox.Y+aBBox.Height) )
282
0
                {
283
0
                    xChildAtPosition = std::move(xChild);
284
0
                    break;
285
0
                }
286
0
            }
287
0
        }
288
0
    }
289
290
    // Have not found a child under the given point.  Returning empty
291
    // reference to indicate this.
292
0
    return xChildAtPosition;
293
0
}
294
295
awt::Rectangle AccessibleDocumentViewBase::implGetBounds()
296
0
{
297
    // Transform visible area into screen coordinates.
298
0
    ::tools::Rectangle aVisibleArea (
299
0
        maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
300
0
    ::Point aPixelTopLeft (
301
0
        maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
302
0
            aVisibleArea.TopLeft()));
303
0
    ::Point aPixelSize (
304
0
        maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
305
0
            aVisibleArea.BottomRight())
306
0
        - aPixelTopLeft);
307
308
    // Prepare to subtract the parent position to transform into relative
309
    // coordinates.
310
0
    awt::Point aParentPosition;
311
0
    Reference<XAccessible> xParent = getAccessibleParent ();
312
0
    if (xParent.is())
313
0
    {
314
0
        Reference<XAccessibleComponent> xParentComponent (
315
0
            xParent->getAccessibleContext(), uno::UNO_QUERY);
316
0
        if (xParentComponent.is())
317
0
            aParentPosition = xParentComponent->getLocationOnScreen();
318
0
    }
319
320
0
    return awt::Rectangle (
321
0
        aPixelTopLeft.X() - aParentPosition.X,
322
0
        aPixelTopLeft.Y() - aParentPosition.Y,
323
0
        aPixelSize.X(),
324
0
        aPixelSize.Y());
325
0
}
326
327
//=====  XInterface  ==========================================================
328
329
uno::Any SAL_CALL
330
    AccessibleDocumentViewBase::queryInterface (const uno::Type & rType)
331
0
{
332
0
    uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
333
0
    if ( ! aReturn.hasValue())
334
0
        aReturn = ::cppu::queryInterface (rType,
335
0
            static_cast<XAccessibleComponent*>(this),
336
0
            static_cast<XAccessibleSelection*>(this),
337
0
            static_cast<lang::XEventListener*>(
338
0
                static_cast<awt::XWindowListener*>(this)),
339
0
            static_cast<beans::XPropertyChangeListener*>(this),
340
0
            static_cast<awt::XWindowListener*>(this),
341
0
            static_cast<awt::XFocusListener*>(this)
342
0
           ,static_cast<XAccessibleExtendedAttributes*>(this)
343
0
            );
344
0
    return aReturn;
345
0
}
346
347
void SAL_CALL
348
    AccessibleDocumentViewBase::acquire()
349
    noexcept
350
0
{
351
0
    AccessibleContextBase::acquire ();
352
0
}
353
354
void SAL_CALL
355
    AccessibleDocumentViewBase::release()
356
    noexcept
357
0
{
358
0
    AccessibleContextBase::release ();
359
0
}
360
361
void AccessibleDocumentViewBase::impl_dispose()
362
0
{
363
    // Unregister from VCL Window.
364
0
    vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
365
0
    if (maWindowLink.IsSet())
366
0
    {
367
0
        if (pWindow)
368
0
            pWindow->RemoveChildEventListener (maWindowLink);
369
0
        maWindowLink = Link<VclWindowEvent&,void>();
370
0
    }
371
0
    else
372
0
    {
373
0
        DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing");
374
0
    }
375
376
    // Unregister from window.
377
0
    if (mxWindow.is())
378
0
    {
379
0
        mxWindow->removeWindowListener (this);
380
0
        mxWindow->removeFocusListener (this);
381
0
        mxWindow = nullptr;
382
0
    }
383
384
    // Unregister from the model.
385
0
    if (mxModel.is())
386
0
        mxModel->removeEventListener (
387
0
            static_cast<awt::XWindowListener*>(this));
388
389
    // Unregister from the controller.
390
0
    if (mxController.is())
391
0
    {
392
0
        uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
393
0
        if (xSet.is())
394
0
            xSet->removePropertyChangeListener (u""_ustr, static_cast<beans::XPropertyChangeListener*>(this));
395
396
0
        mxController->removeEventListener (
397
0
            static_cast<awt::XWindowListener*>(this));
398
0
    }
399
400
    // Propagate change of controller down the shape tree.
401
0
    maShapeTreeInfo.SetModelBroadcaster (nullptr);
402
403
    // Reset the model reference.
404
0
    mxModel = nullptr;
405
    // Reset the model reference.
406
0
    mxController = nullptr;
407
408
0
    maShapeTreeInfo.SetDocumentWindow (nullptr);
409
0
    maShapeTreeInfo.dispose();
410
0
    mxAccessibleOLEObject.clear();
411
0
}
412
413
//=====  XEventListener  ======================================================
414
415
void SAL_CALL
416
    AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject)
417
0
{
418
0
    ensureAlive();
419
420
    // Register this object as dispose event and document::XEventListener
421
    // listener at the model.
422
423
0
    if ( ! rEventObject.Source.is())
424
0
    {
425
        // Paranoia. Can this really happen?
426
0
    }
427
0
    else if (rEventObject.Source == mxModel || rEventObject.Source == mxController)
428
0
    {
429
0
        impl_dispose();
430
0
    }
431
0
}
432
433
//=====  XPropertyChangeListener  =============================================
434
435
void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& )
436
0
{
437
    // Empty
438
0
}
439
440
//=====  XWindowListener  =====================================================
441
442
void SAL_CALL
443
    AccessibleDocumentViewBase::windowResized (const css::awt::WindowEvent& )
444
0
{
445
0
    if (!isAlive())
446
0
        return;
447
448
0
    ViewForwarderChanged();
449
0
}
450
451
void SAL_CALL
452
    AccessibleDocumentViewBase::windowMoved (const css::awt::WindowEvent& )
453
0
{
454
0
    if (!isAlive())
455
0
        return;
456
457
0
    ViewForwarderChanged();
458
0
}
459
460
void SAL_CALL
461
    AccessibleDocumentViewBase::windowShown (const css::lang::EventObject& )
462
0
{
463
0
    if (!isAlive())
464
0
        return;
465
466
0
    ViewForwarderChanged();
467
0
}
468
469
void SAL_CALL
470
    AccessibleDocumentViewBase::windowHidden (const css::lang::EventObject& )
471
0
{
472
0
    if (!isAlive())
473
0
        return;
474
475
0
    ViewForwarderChanged();
476
0
}
477
478
//=====  XFocusListener  ==================================================
479
480
void AccessibleDocumentViewBase::focusGained (const css::awt::FocusEvent& e)
481
0
{
482
0
    ensureAlive();
483
0
    if (e.Source == mxWindow)
484
0
        Activated ();
485
0
}
486
487
void AccessibleDocumentViewBase::focusLost (const css::awt::FocusEvent& e)
488
0
{
489
0
    ensureAlive();
490
0
    if (e.Source == mxWindow)
491
0
        Deactivated ();
492
0
}
493
494
//=====  protected internal  ==================================================
495
496
// This method is called from the component helper base class while disposing.
497
void SAL_CALL AccessibleDocumentViewBase::disposing()
498
0
{
499
0
    impl_dispose();
500
501
0
    AccessibleContextBase::disposing ();
502
0
}
503
504
/// Create a name for this view.
505
OUString
506
    AccessibleDocumentViewBase::CreateAccessibleName()
507
0
{
508
0
    return u"AccessibleDocumentViewBase"_ustr;
509
0
}
510
511
void AccessibleDocumentViewBase::Activated()
512
0
{
513
    // Empty.  Overwrite to do something useful.
514
0
}
515
516
void AccessibleDocumentViewBase::Deactivated()
517
0
{
518
    // Empty.  Overwrite to do something useful.
519
0
}
520
521
void AccessibleDocumentViewBase::SetAccessibleOLEObject (
522
    const Reference <XAccessible>& xOLEObject)
523
0
{
524
    // Send child event about removed accessible OLE object if necessary.
525
0
    if (mxAccessibleOLEObject != xOLEObject)
526
0
        if (mxAccessibleOLEObject.is())
527
0
            CommitChange (
528
0
                AccessibleEventId::CHILD,
529
0
                uno::Any(),
530
0
                uno::Any (mxAccessibleOLEObject), -1);
531
532
    // Assume that the accessible OLE Object disposes itself correctly.
533
534
0
    {
535
0
        ::osl::MutexGuard aGuard (m_aMutex);
536
0
        mxAccessibleOLEObject = xOLEObject;
537
0
    }
538
539
    // Send child event about new accessible OLE object if necessary.
540
0
    if (mxAccessibleOLEObject.is())
541
0
        CommitChange (
542
0
            AccessibleEventId::CHILD,
543
0
            uno::Any (mxAccessibleOLEObject),
544
0
            uno::Any(), -1);
545
0
}
546
547
//=====  methods from AccessibleSelectionBase ==================================================
548
549
// return the member maMutex;
550
::osl::Mutex&
551
    AccessibleDocumentViewBase::implGetMutex()
552
0
{
553
0
    return m_aMutex;
554
0
}
555
556
// return ourself as context in default case
557
uno::Reference< XAccessibleContext >
558
    AccessibleDocumentViewBase::implGetAccessibleContext()
559
0
{
560
0
    return this;
561
0
}
562
563
// return false in default case
564
bool
565
    AccessibleDocumentViewBase::implIsSelected( sal_Int64 )
566
0
{
567
0
    return false;
568
0
}
569
570
// do nothing in default case
571
void
572
    AccessibleDocumentViewBase::implSelect( sal_Int64, bool )
573
0
{
574
0
}
575
576
std::unordered_map<OUString, OUString> AccessibleDocumentViewBase::implGetExtendedAttributes()
577
0
{
578
0
    std::unordered_map<OUString, OUString> aAttributes;
579
0
    if (auto pDrViewSh = dynamic_cast<::sd::DrawViewShell* > (mpViewShell))
580
0
    {
581
0
        OUString sDisplay;
582
        // MT IA2: Not used...
583
        // SdPage*  pCurrPge = pDrViewSh->getCurrentPage();
584
0
        SdDrawDocument* pDoc = pDrViewSh->GetDoc();
585
0
        sDisplay = pDrViewSh->getCurrentPage()->GetName();
586
0
        sDisplay = sDisplay.replaceFirst( "\\", "\\\\" );
587
0
        sDisplay = sDisplay.replaceFirst( "=", "\\=" );
588
0
        sDisplay = sDisplay.replaceFirst( ";", "\\;" );
589
0
        sDisplay = sDisplay.replaceFirst( ",", "\\," );
590
0
        sDisplay = sDisplay.replaceFirst( ":", "\\:" );
591
0
        aAttributes
592
0
            = { { u"page-name"_ustr, sDisplay },
593
0
                { u"page-number"_ustr,
594
0
                  OUString::number(static_cast<sal_Int32>(
595
0
                      static_cast<sal_uInt16>((pDrViewSh->getCurrentPage()->GetPageNum() - 1) >> 1)
596
0
                      + 1)) },
597
0
                { u"total-pages"_ustr, OUString::number(static_cast<sal_Int32>(
598
0
                                           pDrViewSh->GetPageTabControl().GetPageCount())) } };
599
0
        if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #i87182#
600
0
        {
601
0
            OUString sLayerName(pDrViewSh->GetLayerTabControl()->GetLayerName(pDrViewSh->GetLayerTabControl()->GetCurPageId()) );
602
0
            sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId());
603
0
            if( pDoc )
604
0
            {
605
0
                SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
606
0
                SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sLayerName);
607
0
                if( aSdrLayer )
608
0
                {
609
0
                    const OUString& layerAltText = aSdrLayer->GetTitle();
610
0
                    if (!layerAltText.isEmpty())
611
0
                    {
612
0
                        sDisplay += u" " + layerAltText;
613
0
                    }
614
0
                }
615
0
            }
616
0
            sDisplay = sDisplay.replaceFirst( "\\", "\\\\" );
617
0
            sDisplay = sDisplay.replaceFirst( "=", "\\=" );
618
0
            sDisplay = sDisplay.replaceFirst( ";", "\\;" );
619
0
            sDisplay = sDisplay.replaceFirst( ",", "\\," );
620
0
            sDisplay = sDisplay.replaceFirst( ":", "\\:" );
621
0
            aAttributes = { { u"page-name"_ustr, sDisplay },
622
0
                            { u"page-number"_ustr, OUString::number(static_cast<sal_Int32>(
623
0
                                                       pDrViewSh->GetActiveTabLayerIndex() + 1)) },
624
0
                            { u"total-pages"_ustr,
625
0
                              OUString::number(static_cast<sal_Int32>(
626
0
                                  pDrViewSh->GetLayerTabControl()->GetPageCount())) } };
627
0
        }
628
0
    }
629
0
    if (auto pPresViewSh = dynamic_cast<::sd::PresentationViewShell* >(mpViewShell))
630
0
    {
631
0
        SdPage* pCurrPge = pPresViewSh->getCurrentPage();
632
0
        SdDrawDocument* pDoc = pPresViewSh->GetDoc();
633
0
        SdPage* pNotesPge = pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, PageKind::Notes);
634
0
        if (pNotesPge)
635
0
        {
636
0
            SdrObject* pNotesObj = pNotesPge->GetPresObj(PresObjKind::Notes);
637
0
            if (pNotesObj)
638
0
            {
639
0
                OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject();
640
0
                if (pPara)
641
0
                {
642
0
                    OUStringBuffer aNoteValue;
643
0
                    const EditTextObject& rEdit = pPara->GetTextObject();
644
0
                    for (sal_Int32 i=0;i<rEdit.GetParagraphCount();i++)
645
0
                    {
646
0
                        OUString strNote = rEdit.GetText(i);
647
0
                        strNote = strNote.replaceFirst( "\\", "\\\\" );
648
0
                        strNote = strNote.replaceFirst( "=", "\\=" );
649
0
                        strNote = strNote.replaceFirst( ";", "\\;" );
650
0
                        strNote = strNote.replaceFirst( ",", "\\," );
651
0
                        strNote = strNote.replaceFirst( ":", "\\:" );
652
0
                        aNoteValue.append(strNote + ";"); //to divide each paragraph
653
0
                    }
654
0
                    aAttributes.emplace(u"note"_ustr, aNoteValue.makeStringAndClear());
655
0
                }
656
0
            }
657
0
        }
658
0
    }
659
0
    if (dynamic_cast<const ::sd::OutlineViewShell* >(mpViewShell ) !=  nullptr )
660
0
    {
661
0
        SdPage* pCurrPge = mpViewShell->GetActualPage();
662
0
        SdDrawDocument* pDoc = mpViewShell->GetDoc();
663
0
        if(pCurrPge && pDoc)
664
0
        {
665
0
            OUString sDisplay;
666
0
            sDisplay = pCurrPge->GetName();
667
0
            sDisplay = sDisplay.replaceFirst( "=", "\\=" );
668
0
            sDisplay = sDisplay.replaceFirst( ";", "\\;" );
669
0
            sDisplay = sDisplay.replaceFirst( ",", "\\," );
670
0
            sDisplay = sDisplay.replaceFirst( ":", "\\:" );
671
0
            aAttributes
672
0
                = { { u"page-name"_ustr, sDisplay },
673
0
                    { u"page-number"_ustr,
674
0
                      OUString::number(static_cast<sal_Int32>(
675
0
                          static_cast<sal_uInt16>((pCurrPge->GetPageNum() - 1) >> 1) + 1)) },
676
0
                    { u"total-pages"_ustr, OUString::number(static_cast<sal_Int32>(
677
0
                                               pDoc->GetSdPageCount(PageKind::Standard))) } };
678
0
        }
679
0
    }
680
681
0
    return aAttributes;
682
0
}
683
684
sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground(  )
685
0
{
686
0
    return sal_Int32(COL_BLACK);
687
0
}
688
689
sal_Int32 SAL_CALL AccessibleDocumentViewBase::getBackground(  )
690
0
{
691
0
    ensureAlive();
692
0
    ::osl::MutexGuard aGuard (m_aMutex);
693
0
    return sal_Int32(mpViewShell->GetView()->getColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor);
694
0
}
695
} // end of namespace accessibility
696
697
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */