1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <sal/log.hxx>
23 #include <vcl/svapp.hxx>
25 #include <OutlineViewShell.hxx>
26 #include <DrawDocShell.hxx>
27 #include <OutlineView.hxx>
29 #include <AccessibleOutlineView.hxx>
30 #include <AccessibleOutlineEditSource.hxx>
31 #include <drawdoc.hxx>
32 #include <strings.hrc>
33 #include <sdresid.hxx>
34 #include <Outliner.hxx>
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::accessibility
;
40 namespace accessibility
{
42 //===== internal ============================================================
44 AccessibleOutlineView::AccessibleOutlineView (
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
>() )
52 SolarMutexGuard aGuard
;
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.
59 ::sd::View
* pView
= pViewShell
->GetView();
61 auto pShellView
= dynamic_cast<::sd::OutlineView
* >( pView
);
65 OutlinerView
* pOutlineView
= pShellView
->GetViewByWindow( pSdWindow
);
66 SdOutliner
& rOutliner
= pShellView
->GetOutliner();
70 maTextHelper
.SetEditSource( ::std::unique_ptr
< SvxEditSource
>( new AccessibleOutlineEditSource(
71 rOutliner
, *pView
, *pOutlineView
, *pSdWindow
) ) );
75 AccessibleOutlineView::~AccessibleOutlineView()
79 void AccessibleOutlineView::Init()
81 // Set event source _before_ starting to listen
82 maTextHelper
.SetEventSource(this);
84 AccessibleDocumentViewBase::Init ();
87 void AccessibleOutlineView::ViewForwarderChanged()
89 AccessibleDocumentViewBase::ViewForwarderChanged();
94 //===== XAccessibleContext ==================================================
97 AccessibleOutlineView::getAccessibleChildCount()
102 return maTextHelper
.GetChildCount();
105 uno::Reference
<XAccessible
> SAL_CALL
106 AccessibleOutlineView::getAccessibleChild (sal_Int64 nIndex
)
109 // Forward request to children manager.
110 return maTextHelper
.GetChild(nIndex
);
114 AccessibleOutlineView::getAccessibleName()
118 OUString sName
= SdResId(SID_SD_A11Y_D_PRESENTATION
);
119 ::sd::View
* pSdView
= static_cast< ::sd::View
* >( maShapeTreeInfo
.GetSdrView() );
122 SdDrawDocument
& rDoc
= pSdView
->GetDoc();
123 OUString sFileName
= rDoc
.getDocAccTitle();
124 if (sFileName
.isEmpty())
126 ::sd::DrawDocShell
* pDocSh
= pSdView
->GetDocSh();
129 sFileName
= pDocSh
->GetTitle( SFX_TITLE_APINAME
);
132 if (!sFileName
.isEmpty())
134 sName
= sFileName
+ " - " + sName
;
140 //===== XAccessibleEventBroadcaster ========================================
142 void SAL_CALL
AccessibleOutlineView::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
144 // delegate listener handling to children manager.
146 maTextHelper
.AddEventListener(xListener
);
147 AccessibleContextBase::addEventListener(xListener
);
150 void SAL_CALL
AccessibleOutlineView::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
154 maTextHelper
.RemoveEventListener(xListener
);
155 AccessibleContextBase::removeEventListener(xListener
);
161 AccessibleOutlineView::getImplementationName()
163 return u
"AccessibleOutlineView"_ustr
;
166 //===== XEventListener ======================================================
168 //===== protected internal ==================================================
170 void AccessibleOutlineView::Activated()
172 SolarMutexGuard aGuard
;
174 // delegate listener handling to children manager.
175 maTextHelper
.SetFocus();
178 void AccessibleOutlineView::Deactivated()
180 SolarMutexGuard aGuard
;
182 // delegate listener handling to children manager.
183 maTextHelper
.SetFocus(false);
186 void SAL_CALL
AccessibleOutlineView::disposing()
189 maTextHelper
.Dispose();
191 AccessibleDocumentViewBase::disposing ();
194 //===== XPropertyChangeListener =============================================
197 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent
& rEventObject
)
201 AccessibleDocumentViewBase::propertyChange (rEventObject
);
203 //add page switch event for slide show mode
204 if (rEventObject
.PropertyName
== "CurrentPage" ||
205 rEventObject
.PropertyName
== "PageChange")
207 // The current page changed. Update the children accordingly.
209 CommitChange(AccessibleEventId::PAGE_CHANGED
,rEventObject
.NewValue
, rEventObject
.OldValue
, -1);
211 else if ( rEventObject
.PropertyName
== "VisibleArea" )
213 // The visible area changed. Update the children accordingly.
218 SAL_INFO("sd", "unhandled");
222 /// Create a name for this view.
223 OUString
AccessibleOutlineView::CreateAccessibleName()
225 return SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N
);
228 void AccessibleOutlineView::UpdateChildren()
230 SolarMutexGuard aGuard
;
232 // Update visible children
233 maTextHelper
.UpdateChildren();
236 } // end of namespace accessibility
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */