Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/mutex.hxx>
30 : : #include <vcl/svapp.hxx>
31 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
34 : : #include <unotools/accessiblestatesethelper.hxx>
35 : : #include <frmfmt.hxx>
36 : : #include <ndnotxt.hxx>
37 : : #include <flyfrm.hxx>
38 : : #include <cntfrm.hxx>
39 : : #include <hints.hxx> //#i73249#
40 : : #include "accnotextframe.hxx"
41 : :
42 : : using namespace ::com::sun::star;
43 : : using namespace ::com::sun::star::accessibility;
44 : : using ::rtl::OUString;
45 : :
46 : 4 : const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const
47 : : {
48 : 4 : const SwNoTxtNode *pNd = 0;
49 : 4 : const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm *>( GetFrm() );
50 [ + - ][ + - ]: 4 : if( pFlyFrm->Lower() && pFlyFrm->Lower()->IsNoTxtFrm() )
[ + - ]
51 : : {
52 : : const SwCntntFrm *pCntFrm =
53 : 4 : static_cast<const SwCntntFrm *>( pFlyFrm->Lower() );
54 : 4 : pNd = pCntFrm->GetNode()->GetNoTxtNode();
55 : : }
56 : :
57 : 4 : return pNd;
58 : : }
59 : :
60 : 2 : SwAccessibleNoTextFrame::SwAccessibleNoTextFrame(
61 : : SwAccessibleMap* pInitMap,
62 : : sal_Int16 nInitRole,
63 : : const SwFlyFrm* pFlyFrm ) :
64 : : SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrm ),
65 : 2 : aDepend( this, const_cast < SwNoTxtNode * >( GetNoTxtNode() ) ),
66 : : msTitle(),
67 [ + - ]: 4 : msDesc()
68 : : {
69 : 2 : const SwNoTxtNode* pNd = GetNoTxtNode();
70 : : // #i73249#
71 : : // consider new attributes Title and Description
72 [ + - ]: 2 : if( pNd )
73 : : {
74 [ + - ][ + - ]: 2 : msTitle = pNd->GetTitle();
[ + - ]
75 : :
76 [ + - ][ + - ]: 2 : msDesc = pNd->GetDescription();
[ + - ]
77 [ + - + - ]: 4 : if ( msDesc.isEmpty() &&
[ + - ]
78 : 2 : msTitle != GetName() )
79 : : {
80 : 2 : msDesc = msTitle;
81 : : }
82 : : }
83 : 2 : }
84 : :
85 [ + - ]: 2 : SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame()
86 : : {
87 [ - + ]: 2 : }
88 : :
89 : 0 : void SwAccessibleNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
90 : : {
91 [ # # ][ # # ]: 0 : const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
92 : : // #i73249#
93 : : // suppress handling of RES_NAME_CHANGED in case that attribute Title is
94 : : // used as the accessible name.
95 [ # # # # ]: 0 : if ( nWhich != RES_NAME_CHANGED ||
[ # # ]
96 : 0 : msTitle.isEmpty() )
97 : : {
98 : 0 : SwAccessibleFrameBase::Modify( pOld, pNew );
99 : : }
100 : :
101 : 0 : const SwNoTxtNode *pNd = GetNoTxtNode();
102 : : OSL_ENSURE( pNd == aDepend.GetRegisteredIn(), "invalid frame" );
103 [ # # # ]: 0 : switch( nWhich )
104 : : {
105 : : // #i73249#
106 : : case RES_TITLE_CHANGED:
107 : : {
108 : : const String& sOldTitle(
109 [ # # ]: 0 : dynamic_cast<const SwStringMsgPoolItem*>(pOld)->GetString() );
110 : : const String& sNewTitle(
111 [ # # ]: 0 : dynamic_cast<const SwStringMsgPoolItem*>(pNew)->GetString() );
112 [ # # ][ # # ]: 0 : if ( sOldTitle == sNewTitle )
113 : : {
114 : : break;
115 : : }
116 [ # # ]: 0 : msTitle = sNewTitle;
117 [ # # ]: 0 : AccessibleEventObject aEvent;
118 : 0 : aEvent.EventId = AccessibleEventId::NAME_CHANGED;
119 [ # # ][ # # ]: 0 : aEvent.OldValue <<= OUString( sOldTitle );
120 [ # # ]: 0 : aEvent.NewValue <<= msTitle;
121 [ # # ]: 0 : FireAccessibleEvent( aEvent );
122 : :
123 [ # # ][ # # ]: 0 : if ( pNd->GetDescription().Len() != 0 )
[ # # ]
124 : : {
125 : : break;
126 [ # # ][ # # ]: 0 : }
127 : : }
128 : : // intentional no break here
129 : : case RES_DESCRIPTION_CHANGED:
130 : : {
131 [ # # ][ # # ]: 0 : if ( pNd && GetFrm() )
[ # # ]
132 : : {
133 : 0 : const OUString sOldDesc( msDesc );
134 : :
135 [ # # ]: 0 : const String& rDesc = pNd->GetDescription();
136 [ # # ]: 0 : msDesc = rDesc;
137 [ # # ]: 0 : if ( msDesc.isEmpty() &&
[ # # # # ]
138 : 0 : msTitle != GetName() )
139 : : {
140 : 0 : msDesc = msTitle;
141 : : }
142 : :
143 [ # # ]: 0 : if ( msDesc != sOldDesc )
144 : : {
145 [ # # ]: 0 : AccessibleEventObject aEvent;
146 : 0 : aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
147 [ # # ]: 0 : aEvent.OldValue <<= sOldDesc;
148 [ # # ]: 0 : aEvent.NewValue <<= msDesc;
149 [ # # ][ # # ]: 0 : FireAccessibleEvent( aEvent );
150 [ # # ]: 0 : }
151 : : }
152 : : }
153 : 0 : break;
154 : : }
155 : 0 : }
156 : :
157 : 2 : void SwAccessibleNoTextFrame::Dispose( sal_Bool bRecursive )
158 : : {
159 [ + - ]: 2 : SolarMutexGuard aGuard;
160 : :
161 [ + - ]: 2 : if( aDepend.GetRegisteredIn() )
162 [ + - ]: 2 : const_cast < SwModify *>( aDepend.GetRegisteredIn() )->Remove( &aDepend );
163 : :
164 [ + - ][ + - ]: 2 : SwAccessibleFrameBase::Dispose( bRecursive );
165 : 2 : }
166 : :
167 : : // #i73249#
168 : 0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleName (void)
169 : : throw (uno::RuntimeException)
170 : : {
171 [ # # ]: 0 : SolarMutexGuard aGuard;
172 : :
173 [ # # ][ # # ]: 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
174 : :
175 [ # # ]: 0 : if ( !msTitle.isEmpty() )
176 : : {
177 : 0 : return msTitle;
178 : : }
179 : :
180 [ # # ][ # # ]: 0 : return SwAccessibleFrameBase::getAccessibleName();
181 : : }
182 : :
183 : 0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void)
184 : : throw (uno::RuntimeException)
185 : : {
186 [ # # ]: 0 : SolarMutexGuard aGuard;
187 : :
188 [ # # ][ # # ]: 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
189 : :
190 [ # # ]: 0 : return msDesc;
191 : : }
192 : :
193 : :
194 : :
195 : : //
196 : : // XInterface
197 : : //
198 : :
199 : 86 : uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType )
200 : : throw (uno::RuntimeException)
201 : : {
202 [ - + ]: 86 : if( aType ==
203 : 86 : ::getCppuType( static_cast<uno::Reference<XAccessibleImage>*>( NULL ) ) )
204 : : {
205 [ # # ]: 0 : uno::Reference<XAccessibleImage> xImage = this;
206 : 0 : uno::Any aAny;
207 [ # # ]: 0 : aAny <<= xImage;
208 : 0 : return aAny;
209 : : }
210 : : else
211 : 86 : return SwAccessibleContext::queryInterface( aType );
212 : : }
213 : :
214 : :
215 : : //====== XTypeProvider ====================================================
216 : 0 : uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes() throw(uno::RuntimeException)
217 : : {
218 : 0 : uno::Sequence< uno::Type > aTypes( SwAccessibleFrameBase::getTypes() );
219 : :
220 : 0 : sal_Int32 nIndex = aTypes.getLength();
221 [ # # ]: 0 : aTypes.realloc( nIndex + 1 );
222 : :
223 [ # # ]: 0 : uno::Type* pTypes = aTypes.getArray();
224 [ # # ]: 0 : pTypes[nIndex] = ::getCppuType( static_cast< uno::Reference< XAccessibleImage > * >( 0 ) );
225 : :
226 : 0 : return aTypes;
227 : : }
228 : :
229 : :
230 : : //
231 : : // XAccessibleImage
232 : : //
233 : :
234 : : // implementation of the XAccessibleImage methods is a no-brainer, as
235 : : // all releveant information is already accessible through other
236 : : // methods. So we just delegate to those.
237 : :
238 : 0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageDescription()
239 : : throw ( uno::RuntimeException )
240 : : {
241 : 0 : return getAccessibleDescription();
242 : : }
243 : :
244 : 0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageHeight( )
245 : : throw ( uno::RuntimeException )
246 : : {
247 : 0 : return getSize().Height;
248 : : }
249 : :
250 : 0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth( )
251 : : throw ( uno::RuntimeException )
252 : : {
253 : 0 : return getSize().Width;
254 : : }
255 : :
256 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|