LibreOffice Module sd (master) 1
AccessibleOutlineView.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/accessibility/AccessibleEventId.hpp>
21
22#include <sal/log.hxx>
23#include <vcl/svapp.hxx>
24#include <Window.hxx>
25#include <OutlineViewShell.hxx>
26#include <DrawDocShell.hxx>
27#include <OutlineView.hxx>
28#include <View.hxx>
31#include <drawdoc.hxx>
32#include <strings.hrc>
33#include <sdresid.hxx>
34
35#include <memory>
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::accessibility;
39
40namespace accessibility {
41
42//===== internal ============================================================
43
45 ::sd::Window* pSdWindow,
46 ::sd::OutlineViewShell* pViewShell,
47 const uno::Reference<frame::XController>& rxController,
48 const uno::Reference<XAccessible>& rxParent)
49 : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
50 maTextHelper( ::std::unique_ptr< SvxEditSource >() )
51{
52 SolarMutexGuard aGuard;
53
54 // Beware! Here we leave the paths of the UNO API and descend into the
55 // depths of the core. Necessary for making the edit engine accessible.
56 if (!pSdWindow)
57 return;
58
59 ::sd::View* pView = pViewShell->GetView();
60
61 auto pShellView = dynamic_cast<::sd::OutlineView* >( pView );
62 if(!pShellView)
63 return;
64
65 OutlinerView* pOutlineView = pShellView->GetViewByWindow( pSdWindow );
66 SdrOutliner& rOutliner = pShellView->GetOutliner();
67
68 if( pOutlineView )
69 {
70 maTextHelper.SetEditSource( ::std::unique_ptr< SvxEditSource >( new AccessibleOutlineEditSource(
71 rOutliner, *pView, *pOutlineView, *pSdWindow ) ) );
72 }
73}
74
75AccessibleOutlineView::~AccessibleOutlineView()
76{
77}
78
79void AccessibleOutlineView::Init()
80{
81 // Set event source _before_ starting to listen
82 maTextHelper.SetEventSource(this);
83
84 AccessibleDocumentViewBase::Init ();
85}
86
87void AccessibleOutlineView::ViewForwarderChanged()
88{
89 AccessibleDocumentViewBase::ViewForwarderChanged();
90
91 UpdateChildren();
92}
93
94//===== XAccessibleContext ==================================================
95
96sal_Int64 SAL_CALL
97 AccessibleOutlineView::getAccessibleChildCount()
98{
99 ThrowIfDisposed ();
100
101 // forward
102 return maTextHelper.GetChildCount();
103}
104
105uno::Reference<XAccessible> SAL_CALL
106 AccessibleOutlineView::getAccessibleChild (sal_Int64 nIndex)
107{
108 ThrowIfDisposed ();
109 // Forward request to children manager.
110 return maTextHelper.GetChild(nIndex);
111}
112
113OUString SAL_CALL
114 AccessibleOutlineView::getAccessibleName()
115{
117
118 OUString sName = SdResId(SID_SD_A11Y_D_PRESENTATION);
119 ::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() );
120 if ( pSdView )
121 {
122 SdDrawDocument& rDoc = pSdView->GetDoc();
123 OUString sFileName = rDoc.getDocAccTitle();
124 if (sFileName.isEmpty())
125 {
126 ::sd::DrawDocShell* pDocSh = pSdView->GetDocSh();
127 if ( pDocSh )
128 {
129 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME );
130 }
131 }
132 if (!sFileName.isEmpty())
133 {
134 sName = sFileName + " - " + sName;
135 }
136 }
137 return sName;
138}
139
140//===== XAccessibleEventBroadcaster ========================================
141
142void SAL_CALL AccessibleOutlineView::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
143{
144 // delegate listener handling to children manager.
145 if ( ! IsDisposed())
146 maTextHelper.AddEventListener(xListener);
147 AccessibleContextBase::addEventListener(xListener);
148}
149
150void SAL_CALL AccessibleOutlineView::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
151{
152 // forward
153 if ( ! IsDisposed())
154 maTextHelper.RemoveEventListener(xListener);
155 AccessibleContextBase::removeEventListener(xListener);
156}
157
158// XServiceInfo
159
160OUString SAL_CALL
161 AccessibleOutlineView::getImplementationName()
162{
163 return "AccessibleOutlineView";
164}
165
166//===== XEventListener ======================================================
167
168//===== protected internal ==================================================
169
170void AccessibleOutlineView::Activated()
171{
172 SolarMutexGuard aGuard;
173
174 // delegate listener handling to children manager.
175 maTextHelper.SetFocus();
176}
177
178void AccessibleOutlineView::Deactivated()
179{
180 SolarMutexGuard aGuard;
181
182 // delegate listener handling to children manager.
183 maTextHelper.SetFocus(false);
184}
185
186void SAL_CALL AccessibleOutlineView::disposing()
187{
188 // dispose children
189 maTextHelper.Dispose();
190
191 AccessibleDocumentViewBase::disposing ();
192}
193
194//===== XPropertyChangeListener =============================================
195
196void SAL_CALL
197 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
198{
199 ThrowIfDisposed ();
200
201 AccessibleDocumentViewBase::propertyChange (rEventObject);
202
203 //add page switch event for slide show mode
204 if (rEventObject.PropertyName == "CurrentPage" ||
205 rEventObject.PropertyName == "PageChange")
206 {
207 // The current page changed. Update the children accordingly.
208 UpdateChildren();
209 CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue, rEventObject.OldValue, -1);
210 }
211 else if ( rEventObject.PropertyName == "VisibleArea" )
212 {
213 // The visible area changed. Update the children accordingly.
214 UpdateChildren();
215 }
216 else
217 {
218 SAL_INFO("sd", "unhandled");
219 }
220}
221
223OUString AccessibleOutlineView::CreateAccessibleName()
224{
225 return SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N);
226}
227
228void AccessibleOutlineView::UpdateChildren()
229{
230 SolarMutexGuard aGuard;
231
232 // Update visible children
233 maTextHelper.UpdateChildren();
234}
235
236} // end of namespace accessibility
237
238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE const OUString & getDocAccTitle() const
Definition: drawdoc.hxx:124
OUString GetTitle(sal_uInt16 nMaxLen=0) const
AccessibleOutlineView(::sd::Window *pSdWindow, ::sd::OutlineViewShell *pViewShell, const css::uno::Reference< css::frame::XController > &rxController, const css::uno::Reference< css::accessibility::XAccessible > &rxParent)
Show a textual overview of the text contents of all slides.
Derivative of sd::View for the outline mode |* .
Definition: OutlineView.hxx:55
::sd::View * GetView() const
Definition: ViewShell.hxx:144
DrawDocShell * GetDocSh() const
Definition: View.hxx:142
SdDrawDocument & GetDoc() const
Definition: View.hxx:293
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
OUString sName
sal_Int32 nIndex
#define SAL_INFO(area, stream)
#define SFX_TITLE_APINAME
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83