LibreOffice Module sw (master) 1
accnotextframe.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 <vcl/svapp.hxx>
21#include <com/sun/star/accessibility/AccessibleEventId.hpp>
22#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24#include <frmfmt.hxx>
25#include <ndnotxt.hxx>
26#include <flyfrm.hxx>
27#include <notxtfrm.hxx>
28#include <hints.hxx>
29#include "accnotextframe.hxx"
30#include <fmturl.hxx>
33#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
34
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::accessibility;
38
40{
41 const SwNoTextNode *pNd = nullptr;
42 const SwFlyFrame *pFlyFrame = static_cast< const SwFlyFrame *>( GetFrame() );
43 if( pFlyFrame->Lower() && pFlyFrame->Lower()->IsNoTextFrame() )
44 {
45 const SwNoTextFrame *pContentFrame =
46 static_cast<const SwNoTextFrame *>(pFlyFrame->Lower());
47 const SwContentNode* pSwContentNode = pContentFrame->GetNode();
48 if(pSwContentNode != nullptr)
49 {
50 pNd = pSwContentNode->GetNoTextNode();
51 }
52 }
53
54 return pNd;
55}
56
58 std::shared_ptr<SwAccessibleMap> const& pInitMap,
59 sal_Int16 nInitRole,
60 const SwFlyFrame* pFlyFrame ) :
61 SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrame )
62{
63 const SwNoTextNode* pNd = GetNoTextNode();
64 // #i73249#
65 // consider new attributes Title and Description
66 if( pNd )
67 {
68 StartListening(const_cast<SwNoTextNode*>(pNd)->GetNotifier());
69 msTitle = pNd->GetTitle();
70
71 msDesc = pNd->GetDescription();
72 if ( msDesc.isEmpty() &&
73 msTitle != GetName() )
74 {
76 }
77 }
78}
79
81{
82}
83
85{
86 const SwNoTextNode* pNd = GetNoTextNode();
87 switch(rHint.GetId())
88 {
89 case SfxHintId::Dying:
91 return;
92 default:
93 return;
94 case SfxHintId::SwTitleChanged:
95 {
96 auto rTitleChanged = static_cast<const sw::TitleChanged&>(rHint);
97 if(rTitleChanged.m_sOld == rTitleChanged.m_sNew)
98 break;
99 msTitle = rTitleChanged.m_sNew;
100 AccessibleEventObject aEvent;
101 aEvent.EventId = AccessibleEventId::NAME_CHANGED;
102 aEvent.OldValue <<= rTitleChanged.m_sOld;
103 aEvent.NewValue <<= msTitle;
105
106 if(!pNd->GetDescription().isEmpty())
107 break;
108 [[fallthrough]];
109 }
110 case SfxHintId::SwDescriptionChanged:
111 if(pNd && GetFrame())
112 {
113 const OUString sOldDesc(msDesc);
114 msDesc = pNd->GetDescription();
115 if(msDesc.isEmpty() && msTitle != GetName())
116 msDesc = msTitle;
117 if(msDesc == sOldDesc)
118 return;
119 AccessibleEventObject aEvent;
120 aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
121 aEvent.OldValue <<= sOldDesc;
122 aEvent.NewValue <<= msDesc;
124 }
125 return;
126 }
127}
128
129void SwAccessibleNoTextFrame::Dispose(bool bRecursive, bool bCanSkipInvisible)
130{
131 SolarMutexGuard aGuard;
133 SwAccessibleFrameBase::Dispose(bRecursive, bCanSkipInvisible);
134}
135
136// #i73249#
138{
139 SolarMutexGuard aGuard;
140
142
143 if ( !msTitle.isEmpty() )
144 {
145 return msTitle;
146 }
147
149}
150
152{
153 SolarMutexGuard aGuard;
154
156
157 return msDesc;
158}
159
160// XInterface
161
163{
164 if( aType ==
166 {
167 uno::Reference<XAccessibleImage> xImage = this;
168 return uno::Any(xImage);
169 }
170 else if ( aType == cppu::UnoType<XAccessibleHypertext>::get())
171 {
172 uno::Reference<XAccessibleHypertext> aAccHypertext = this;
173 return uno::Any( aAccHypertext );
174 }
175 else
176 return SwAccessibleContext::queryInterface( aType );
177}
178
179// XTypeProvider
180
181uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes()
182{
185 SwAccessibleFrameBase::getTypes() ).getTypes();
186}
187
189
194{
196}
197
199{
200 return getSize().Height;
201}
202
204{
205 return getSize().Width;
206}
207
208// XAccessibleText
209sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCaretPosition( ){return 0;}
210sal_Bool SAL_CALL SwAccessibleNoTextFrame::setCaretPosition( sal_Int32 ){return false;}
212css::uno::Sequence< css::beans::PropertyValue > SAL_CALL SwAccessibleNoTextFrame::getCharacterAttributes( sal_Int32 , const css::uno::Sequence< OUString >& )
213{
214 return uno::Sequence<beans::PropertyValue>();
215}
216css::awt::Rectangle SAL_CALL SwAccessibleNoTextFrame::getCharacterBounds( sal_Int32 )
217{
218 return css::awt::Rectangle(0, 0, 0, 0 );
219}
220sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCharacterCount( ){return 0;}
221sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getIndexAtPoint( const css::awt::Point& ){return 0;}
222OUString SAL_CALL SwAccessibleNoTextFrame::getSelectedText( ){return OUString();}
223sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionStart( ){return 0;}
224sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionEnd( ){return 0;}
225sal_Bool SAL_CALL SwAccessibleNoTextFrame::setSelection( sal_Int32 , sal_Int32 ){return true;}
226OUString SAL_CALL SwAccessibleNoTextFrame::getText( ){return OUString();}
227OUString SAL_CALL SwAccessibleNoTextFrame::getTextRange( sal_Int32 , sal_Int32 ){return OUString();}
228css::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextAtIndex( sal_Int32 , sal_Int16 )
229{
230 css::accessibility::TextSegment aResult;
231 return aResult;
232}
233css::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBeforeIndex( sal_Int32, sal_Int16 )
234{
235 css::accessibility::TextSegment aResult;
236 return aResult;
237}
238css::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBehindIndex( sal_Int32 , sal_Int16 )
239{
240 css::accessibility::TextSegment aResult;
241 return aResult;
242}
243
244sal_Bool SAL_CALL SwAccessibleNoTextFrame::copyText( sal_Int32, sal_Int32 ){return true;}
245sal_Bool SAL_CALL SwAccessibleNoTextFrame::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType ){return false;}
246
247// XAccessibleHyperText
248
250{
251 SolarMutexGuard aGuard;
252
254
255 sal_Int32 nCount = 0;
256 SwFormatURL aURL( static_cast<const SwLayoutFrame*>(GetFrame())->GetFormat()->GetURL() );
257
258 if(aURL.GetMap() || !aURL.GetURL().isEmpty())
259 nCount = 1;
260
261 return nCount;
262}
263
264uno::Reference< XAccessibleHyperlink > SAL_CALL
266{
267 SolarMutexGuard aGuard;
268
270
271 SwFormatURL aURL( static_cast<const SwLayoutFrame*>(GetFrame())->GetFormat()->GetURL() );
272
273 if( nLinkIndex > 0 )
274 throw lang::IndexOutOfBoundsException();
275
276 if( aURL.GetMap() || !aURL.GetURL().isEmpty() )
277 {
278 if ( !m_xHyperlink.is() )
279 {
281 }
282
283 return m_xHyperlink;
284 }
285
286 return nullptr;
287}
288
289sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkIndex( sal_Int32 )
290{
291 return 0;
292}
293
294uno::Reference<XAccessibleRelationSet> SAL_CALL SwAccessibleNoTextFrame::getAccessibleRelationSet( )
295{
296 return new AccessibleRelationSetHelper();
297}
298
299/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
SfxHintId GetId() const
void EndListeningAll()
bool StartListening(SvtBroadcaster &rBroadcaster)
const OUString & GetName() const
Definition: acccontext.hxx:334
virtual OUString SAL_CALL getAccessibleName() override
Definition: acccontext.cxx:729
void FireAccessibleEvent(css::accessibility::AccessibleEventObject &rEvent)
Definition: acccontext.cxx:441
virtual css::awt::Size SAL_CALL getSize() override
Definition: acccontext.cxx:959
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
const SwFrame * GetFrame() const
Definition: accframe.hxx:102
css::uno::Reference< css::accessibility::XAccessibleHyperlink > m_xHyperlink
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
virtual sal_Int32 SAL_CALL getAccessibleImageHeight() override
virtual sal_Int32 SAL_CALL getHyperLinkCount() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void Notify(const SfxHint &) override
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &aPoint) override
virtual OUString SAL_CALL getText() override
virtual sal_Int32 SAL_CALL getAccessibleImageWidth() override
virtual OUString SAL_CALL getAccessibleName() override
virtual ~SwAccessibleNoTextFrame() override
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
virtual sal_Int32 SAL_CALL getCharacterCount() override
virtual OUString SAL_CALL getAccessibleImageDescription() override
XAccessibleImage.
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
virtual OUString SAL_CALL getSelectedText() override
virtual sal_Int32 SAL_CALL getHyperLinkIndex(sal_Int32 nCharIndex) override
virtual sal_Int32 SAL_CALL getCaretPosition() override
const SwNoTextNode * GetNoTextNode() const
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
virtual sal_Int32 SAL_CALL getSelectionStart() override
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
SwAccessibleNoTextFrame(std::shared_ptr< SwAccessibleMap > const &pInitMap, sal_Int16 nInitRole, const SwFlyFrame *pFlyFrame)
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
friend class SwAccessibleNoTextHyperlink
virtual css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL getHyperLink(sal_Int32 nLinkIndex) override
virtual sal_Int32 SAL_CALL getSelectionEnd() override
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
SfxPoolItem subclass that wraps a URL.
Definition: fmturl.hxx:33
bool IsNoTextFrame() const
Definition: frame.hxx:1244
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
Definition: layfrm.hxx:36
const SwFrame * Lower() const
Definition: layfrm.hxx:101
const SwContentNode * GetNode() const
Definition: notxtfrm.hxx:77
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:30
OUString GetDescription() const
Definition: ndnotxt.cxx:282
OUString GetTitle() const
Definition: ndnotxt.cxx:258
SwNoTextNode * GetNoTextNode()
Definition: ndnotxt.hxx:95
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
int nCount
URL aURL
virtual OUString GetURL() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
unsigned char sal_Bool
sal_uInt16 sal_Unicode